From ec90829695a42f186f6bba9d8236413fe3ddade8 Mon Sep 17 00:00:00 2001 From: Dmitry Fedorov Date: Fri, 29 May 2020 12:07:38 +0300 Subject: [PATCH 1/2] connect to PA in stubdom if audio-model enabled run pacat in low latency mode by default --- qubesadmin/tools/qvm_start_daemon.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qubesadmin/tools/qvm_start_daemon.py b/qubesadmin/tools/qvm_start_daemon.py index e42a7f5..dd5a87c 100644 --- a/qubesadmin/tools/qvm_start_daemon.py +++ b/qubesadmin/tools/qvm_start_daemon.py @@ -341,7 +341,10 @@ class DAEMONLauncher: :param vm: VM for which start AUDIO daemon """ # pylint: disable=no-self-use - pacat_cmd = [PACAT_DAEMON_PATH, vm.xid, vm.name] + xid = vm.stubdom_xid if vm.features.check_with_template('audio-model', False) \ + and vm.virt_mode == 'hvm' else vm.xid + + pacat_cmd = [PACAT_DAEMON_PATH, '-l', xid, vm.name] vm.log.info('Starting AUDIO') yield from asyncio.create_subprocess_exec(*pacat_cmd) @@ -387,7 +390,10 @@ class DAEMONLauncher: if not vm.features.check_with_template('audio', True): return - if not os.path.exists(self.pacat_pidfile(vm.xid)): + xid = vm.stubdom_xid if vm.features.check_with_template('audio-model', False) \ + and vm.virt_mode == 'hvm' else vm.xid + + if not os.path.exists(self.pacat_pidfile(xid)): yield from self.start_audio_for_vm(vm) def on_domain_spawn(self, vm, _event, **kwargs): From d99045f05efcb28274539a07812be92a391dca89 Mon Sep 17 00:00:00 2001 From: Dmitry Fedorov Date: Sun, 31 May 2020 21:11:33 +0300 Subject: [PATCH 2/2] use function to determine pacat domid --- qubesadmin/tools/qvm_start_daemon.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/qubesadmin/tools/qvm_start_daemon.py b/qubesadmin/tools/qvm_start_daemon.py index dd5a87c..f7a8a3b 100644 --- a/qubesadmin/tools/qvm_start_daemon.py +++ b/qubesadmin/tools/qvm_start_daemon.py @@ -275,6 +275,15 @@ class DAEMONLauncher: """Helper function to construct an AUDIO pidfile path""" return '/var/run/qubes/pacat.{}'.format(xid) + @staticmethod + def pacat_domid(vm): + """Determine target domid for an AUDIO daemon""" + xid = vm.stubdom_xid \ + if vm.features.check_with_template('audio-model', False) \ + and vm.virt_mode == 'hvm' \ + else vm.xid + return xid + @asyncio.coroutine def start_gui_for_vm(self, vm, monitor_layout=None): """Start GUI daemon (qubes-guid) connected directly to a VM @@ -341,10 +350,7 @@ class DAEMONLauncher: :param vm: VM for which start AUDIO daemon """ # pylint: disable=no-self-use - xid = vm.stubdom_xid if vm.features.check_with_template('audio-model', False) \ - and vm.virt_mode == 'hvm' else vm.xid - - pacat_cmd = [PACAT_DAEMON_PATH, '-l', xid, vm.name] + pacat_cmd = [PACAT_DAEMON_PATH, '-l', self.pacat_domid(vm), vm.name] vm.log.info('Starting AUDIO') yield from asyncio.create_subprocess_exec(*pacat_cmd) @@ -390,9 +396,7 @@ class DAEMONLauncher: if not vm.features.check_with_template('audio', True): return - xid = vm.stubdom_xid if vm.features.check_with_template('audio-model', False) \ - and vm.virt_mode == 'hvm' else vm.xid - + xid = self.pacat_domid(vm) if not os.path.exists(self.pacat_pidfile(xid)): yield from self.start_audio_for_vm(vm)