Skip to content

Commit

Permalink
use function to determine pacat domid
Browse files Browse the repository at this point in the history
  • Loading branch information
easydozen committed May 31, 2020
1 parent ec90829 commit d99045f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions qubesadmin/tools/qvm_start_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ def pacat_pidfile(xid):
"""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
Expand Down Expand Up @@ -341,10 +350,7 @@ def start_audio_for_vm(self, vm):
: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)
Expand Down Expand Up @@ -390,9 +396,7 @@ def start_audio(self, vm):
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)

Expand Down

0 comments on commit d99045f

Please sign in to comment.