# HG changeset patch
# User Cole Robinson <crobinso@redhat.com>
# Date 1253130900 14400
# Node ID 761714f08589587d6d24d4564664561d660becd6
# Parent be36b376adad1d7a57eff536aacae769c432f4c0
Use virtual networking (not user) if we are non-root on qemu:///system.
Since virt-install can use policykit now, we can be non-root and still use
qemu:///system.
diff -r be36b376adad -r 761714f08589 virtinst/User.py
--- a/virtinst/User.py Wed Sep 16 15:51:31 2009 -0400
+++ b/virtinst/User.py Wed Sep 16 15:55:00 2009 -0400
@@ -19,6 +19,7 @@
import platform
import os
+import _util
class User(object):
"""Defines a particular user account."""
@@ -50,6 +51,9 @@
if priv == self.PRIV_QEMU_SYSTEM:
return self._euid == 0
+ if priv == self.PRIV_CREATE_NETWORK:
+ return (self._euid == 0) or _util.is_qemu_system(conn)
+
if platform.system() != 'SunOS':
is_xen = not conn or conn.lower()[0:3] == 'xen'
if priv in [ self.PRIV_CLONE, self.PRIV_CREATE_DOMAIN ]:
diff -r be36b376adad -r 761714f08589 virtinst/__init__.py
--- a/virtinst/__init__.py Wed Sep 16 15:51:31 2009 -0400
+++ b/virtinst/__init__.py Wed Sep 16 15:55:00 2009 -0400
@@ -24,7 +24,6 @@
def _virtinst(msg):
return gettext.dgettext(gettext_app, msg)
-import util
import Storage
from Guest import Guest, XenGuest
from VirtualDevice import VirtualDevice
@@ -47,6 +46,7 @@
from ImageManager import ImageInstaller
from CloneManager import CloneDesign
from User import User
+import util
# This represents the PUBLIC API. Any changes to these classes (or 'util.py')
# must be mindful of this fact.
diff -r be36b376adad -r 761714f08589 virtinst/_util.py
--- a/virtinst/_util.py Wed Sep 16 15:51:31 2009 -0400
+++ b/virtinst/_util.py Wed Sep 16 15:55:00 2009 -0400
@@ -374,6 +374,16 @@
return None
+def is_qemu_system(conn):
+ if not conn:
+ return False
+
+ (scheme, ignore, ignore,
+ path, ignore, ignore) = uri_split(conn)
+ if path == "/system" and scheme.startswith("qemu"):
+ return True
+ return False
+
#
# These functions accidentally ended up in the API under virtinst.util
#
diff -r be36b376adad -r 761714f08589 virtinst/cli.py
--- a/virtinst/cli.py Wed Sep 16 15:51:31 2009 -0400
+++ b/virtinst/cli.py Wed Sep 16 15:55:00 2009 -0400
@@ -638,7 +638,7 @@
net = _util.default_network(conn)
networks.append(net[0] + ":" + net[1])
else:
- networks.append("user")
+ networks.append(VirtualNetworkInterface.TYPE_USER)
# ensure we have less macs then networks, otherwise autofill the mac list
if len(macs) > len(networks):
@@ -654,7 +654,7 @@
net = _util.default_network(conn)
networks.append(net[0] + ":" + net[1])
else:
- networks.append("user")
+ networks.append(VirtualNetworkInterface.TYPE_USER)
macs.append(None)
net_init_dicts = []
diff -r be36b376adad -r 761714f08589 virtinst/util.py
--- a/virtinst/util.py Wed Sep 16 15:51:31 2009 -0400
+++ b/virtinst/util.py Wed Sep 16 15:55:00 2009 -0400
@@ -40,7 +40,7 @@
from virtinst import _virtinst as _
import virtinst
import CapabilitiesParser
-from User import User
+import User
KEYBOARD_DIR = "/etc/sysconfig/keyboard"
XORG_CONF = "/etc/X11/xorg.conf"
@@ -107,7 +107,7 @@
os.path.exists("/usr/bin/qemu-kvm") or \
os.path.exists("/usr/bin/kvm") or \
os.path.exists("/usr/bin/xenner"):
- if User.current().has_priv(User.PRIV_QEMU_SYSTEM):
+ if User.User.current().has_priv(User.User.PRIV_QEMU_SYSTEM):
return "qemu:///system"
else:
return "qemu:///session"