Browse Source

Merge remote-tracking branch 'origin/pr/140'

* origin/pr/140:
  use function to determine pacat domid
  connect to PA in stubdom if audio-model enabled run pacat in low latency mode by default
Marek Marczykowski-Górecki 3 years ago
parent
commit
ae39c75867
1 changed files with 12 additions and 2 deletions
  1. 12 2
      qubesadmin/tools/qvm_start_daemon.py

+ 12 - 2
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,7 +350,7 @@ class DAEMONLauncher:
         :param vm: VM for which start AUDIO daemon
         """
         # pylint: disable=no-self-use
-        pacat_cmd = [PACAT_DAEMON_PATH, vm.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)
@@ -387,7 +396,8 @@ class DAEMONLauncher:
         if not vm.features.check_with_template('audio', True):
             return
 
-        if not os.path.exists(self.pacat_pidfile(vm.xid)):
+        xid = self.pacat_domid(vm)
+        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):