Skip to content

Commit

Permalink
core: fix vm.run_service 'wait' argument handling
Browse files Browse the repository at this point in the history
1. wait=False isn't supportet together with localcmd (explicit, or
   implicit via 'input') - qrexec-client refuses such combination
2. When using localcmd, qrexec-client exists as soon as the local command
   terminates, not necessary remote. This may not be desired effect when
   used with wait=True (the default), so do not use localcmd in such a
   case

Found while debugging tests for qubes.USBAttach/qubes.USBDetach - with
wait=True broken, there were a lot of race conditions.

Related to QubesOS/qubes-issues#531

(cherry picked from commit 046149e)
  • Loading branch information
marmarek committed Jun 21, 2016
1 parent 1e29d7f commit e6eb2f5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core-modules/000QubesVm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,13 +1676,17 @@ def run_service(self, service, source="dom0", user=None,
if bool(input) + bool(passio_popen) + bool(localcmd) > 1:
raise ValueError("'input', 'passio_popen', 'localcmd' cannot be "
"used together")
if not wait and (localcmd or input):
raise ValueError("Cannot use wait=False with input or "
"localcmd specified")
if localcmd:
return self.run("QUBESRPC %s %s" % (service, source),
localcmd=localcmd, user=user, wait=wait, gui=gui)
elif input:
return self.run("QUBESRPC %s %s" % (service, source),
localcmd="echo %s" % input, user=user, wait=wait,
gui=gui)
p = self.run("QUBESRPC %s %s" % (service, source),
user=user, wait=wait, gui=gui, passio_popen=True)
p.communicate(input)
return p.returncode
else:
return self.run("QUBESRPC %s %s" % (service, source),
passio_popen=passio_popen, user=user, wait=wait,
Expand Down

0 comments on commit e6eb2f5

Please sign in to comment.