Share default_uri function
This commit is contained in:
parent
ead31139b0
commit
d427800f11
|
@ -27,9 +27,8 @@ from gi.repository import GObject
|
|||
from gi.repository import Gtk
|
||||
# pylint: enable=E0611
|
||||
|
||||
import virtinst
|
||||
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager import util
|
||||
|
||||
HV_XEN = 0
|
||||
HV_QEMU = 1
|
||||
|
@ -153,7 +152,7 @@ class vmmConnect(vmmGObjectUI):
|
|||
return self.widget("connect-remote").get_active()
|
||||
|
||||
def set_default_hypervisor(self):
|
||||
default = virtinst.util.default_connection()
|
||||
default = util.default_uri(always_system=True)
|
||||
if not default or default.startswith("qemu"):
|
||||
self.widget("hypervisor").set_active(1)
|
||||
elif default.startswith("xen"):
|
||||
|
|
|
@ -55,19 +55,6 @@ from virtManager.delete import vmmDeleteDialog
|
|||
debug_ref_leaks = False
|
||||
|
||||
|
||||
def default_uri():
|
||||
tryuri = None
|
||||
if os.path.exists("/var/lib/xend") and os.path.exists("/proc/xen"):
|
||||
tryuri = "xen:///"
|
||||
elif (os.path.exists("/dev/kvm") or
|
||||
os.path.exists("/usr/bin/qemu") or
|
||||
os.path.exists("/usr/bin/qemu-kvm") or
|
||||
os.path.exists("/usr/bin/kvm") or
|
||||
os.path.exists("/usr/libexec/qemu-kvm")):
|
||||
tryuri = "qemu:///system"
|
||||
|
||||
return tryuri
|
||||
|
||||
DETAILS_PERF = 1
|
||||
DETAILS_CONFIG = 2
|
||||
DETAILS_CONSOLE = 3
|
||||
|
@ -199,7 +186,7 @@ class vmmEngine(vmmGObject):
|
|||
if ret is not None:
|
||||
tryuri = "qemu:///system"
|
||||
else:
|
||||
tryuri = default_uri()
|
||||
tryuri = util.default_uri(always_system=True)
|
||||
|
||||
if tryuri is None:
|
||||
manager.set_startup_error(msg)
|
||||
|
|
|
@ -367,3 +367,20 @@ def set_list_selection(widget, rownum):
|
|||
selection.unselect_all()
|
||||
widget.set_cursor(path)
|
||||
selection.select_path(path)
|
||||
|
||||
|
||||
def default_uri(always_system=False):
|
||||
if os.path.exists('/var/lib/xend'):
|
||||
if (os.path.exists('/dev/xen/evtchn') or
|
||||
os.path.exists("/proc/xen")):
|
||||
return 'xen:///'
|
||||
|
||||
if (os.path.exists("/usr/bin/qemu") or
|
||||
os.path.exists("/usr/bin/qemu-kvm") or
|
||||
os.path.exists("/usr/bin/kvm") or
|
||||
os.path.exists("/usr/libexec/qemu-kvm")):
|
||||
if always_system or os.geteuid() == 0:
|
||||
return "qemu:///system"
|
||||
else:
|
||||
return "qemu:///session"
|
||||
return None
|
||||
|
|
|
@ -376,23 +376,6 @@ def default_network(conn):
|
|||
return ret
|
||||
|
||||
|
||||
def default_connection():
|
||||
if os.path.exists('/var/lib/xend'):
|
||||
if (os.path.exists('/dev/xen/evtchn') or
|
||||
os.path.exists("/proc/xen")):
|
||||
return 'xen'
|
||||
|
||||
if (os.path.exists("/usr/bin/qemu") or
|
||||
os.path.exists("/usr/bin/qemu-kvm") or
|
||||
os.path.exists("/usr/bin/kvm") or
|
||||
os.path.exists("/usr/bin/xenner")):
|
||||
if os.geteuid() == 0:
|
||||
return "qemu:///system"
|
||||
else:
|
||||
return "qemu:///session"
|
||||
return None
|
||||
|
||||
|
||||
def is_blktap_capable(conn):
|
||||
# Ideally we would get this from libvirt capabilities XML
|
||||
if conn.is_remote():
|
||||
|
|
Loading…
Reference in New Issue