diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index fc6217df..354e1231 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -1428,8 +1428,8 @@ class QubesVm(object): return vmdev = m.group(1) try: - self.run("QUBESRPC qubes.DetachPciDevice dom0", user="root", - localcmd="echo 00:%s" % vmdev, wait=True) + self.run_service("qubes.DetachPciDevice", + user="root", input="00:%s" % vmdev) subprocess.check_call(['sudo', 'xl', 'pci-detach', str(self.xid), pci]) except Exception as e: print >>sys.stderr, "Failed to detach PCI device on the fly " \ @@ -1500,6 +1500,18 @@ class QubesVm(object): null.close() return retcode + def run_service(self, service, source="dom0", user=None, + passio_popen = False, input=None): + if input and passio_popen: + raise ValueError("'input' and 'passio_popen' cannot be used " + "together") + if input: + return self.run("QUBESRPC %s %s" % (service, source), + localcmd="echo %s" % input, user=user, wait=True) + else: + return self.run("QUBESRPC %s %s" % (service, source), + passio_popen=passio_popen, user=user, wait=True) + def attach_network(self, verbose = False, wait = True, netvm = None): if dry_run: return