From 6d2755abe618dea34cd5f13d766a826fccb8891d Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 22 Apr 2013 05:17:07 +0200 Subject: [PATCH] Use libvirt in qrexec-policy Import connection for core qubes module. --- qrexec/qrexec-policy | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/qrexec/qrexec-policy b/qrexec/qrexec-policy index 95d81ca..5329bf3 100755 --- a/qrexec/qrexec-policy +++ b/qrexec/qrexec-policy @@ -3,7 +3,7 @@ import sys import os import os.path import subprocess -import xen.lowlevel.xl +from qubes.qubes import libvirt_conn import qubes.guihelpers from optparse import OptionParser import fcntl @@ -82,14 +82,12 @@ def find_policy(policy, domain, target): return get_default_policy() def is_domain_running(target): - xl_ctx = xen.lowlevel.xl.ctx() - domains = xl_ctx.list_domains() - for dominfo in domains: - domname = xl_ctx.domid_to_name(dominfo.domid) - if domname == target: - return True - return False - + libvirt_dom = libvirt_conn.lookupByName(target) + if libvirt_dom: + return libvirt_dom.isActive() + else: + return False + def validate_target(target): # special targets if target in ['$dispvm', 'dom0']: