core: add simple 'run_service' function

This commit is contained in:
Marek Marczykowski-Górecki 2014-04-01 01:07:23 +02:00
parent bc70581bd3
commit 2eaf649eed

View File

@ -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