Use libvirt in qrexec-policy

Import connection for core qubes module.
This commit is contained in:
Marek Marczykowski 2013-04-22 05:17:07 +02:00 committed by Marek Marczykowski-Górecki
parent 7bdf7b3f36
commit 6d2755abe6

View File

@ -3,7 +3,7 @@ import sys
import os import os
import os.path import os.path
import subprocess import subprocess
import xen.lowlevel.xl from qubes.qubes import libvirt_conn
import qubes.guihelpers import qubes.guihelpers
from optparse import OptionParser from optparse import OptionParser
import fcntl import fcntl
@ -82,13 +82,11 @@ def find_policy(policy, domain, target):
return get_default_policy() return get_default_policy()
def is_domain_running(target): def is_domain_running(target):
xl_ctx = xen.lowlevel.xl.ctx() libvirt_dom = libvirt_conn.lookupByName(target)
domains = xl_ctx.list_domains() if libvirt_dom:
for dominfo in domains: return libvirt_dom.isActive()
domname = xl_ctx.domid_to_name(dominfo.domid) else:
if domname == target: return False
return True
return False
def validate_target(target): def validate_target(target):
# special targets # special targets