Gentoo Archives: gentoo-commits

From: "Micheal Marineau (marineam)" <marineam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-emulation/virt-manager/files: virt-manager-0.6.0-read-only-fallback.patch
Date: Tue, 02 Dec 2008 03:38:15
Message-Id: E1L7M5T-0002YH-0f@stork.gentoo.org
1 marineam 08/12/02 03:38:11
2
3 Added: virt-manager-0.6.0-read-only-fallback.patch
4 Log:
5 Allow user access without policykit
6 (Portage version: 2.1.4.5)
7
8 Revision Changes Path
9 1.1 app-emulation/virt-manager/files/virt-manager-0.6.0-read-only-fallback.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-emulation/virt-manager/files/virt-manager-0.6.0-read-only-fallback.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-emulation/virt-manager/files/virt-manager-0.6.0-read-only-fallback.patch?rev=1.1&content-type=text/plain
13
14 Index: virt-manager-0.6.0-read-only-fallback.patch
15 ===================================================================
16 --- virt-manager-0.6.0/src/virtManager/connection.py.orig 2008-09-10 15:37:12.000000000 -0400
17 +++ virt-manager-0.6.0/src/virtManager/connection.py 2008-12-01 22:33:34.000000000 -0500
18 @@ -38,11 +38,6 @@
19 from virtManager.netdev import vmmNetDevice
20 from virtManager.storagepool import vmmStoragePool
21
22 -LIBVIRT_POLICY_FILES = [
23 - "/usr/share/PolicyKit/policy/libvirtd.policy",
24 - "/usr/share/PolicyKit/policy/org.libvirt.unix.policy"
25 -]
26 -
27 def get_local_hostname():
28 try:
29 (host, aliases, ipaddrs) = gethostbyaddr(gethostname())
30 @@ -139,15 +134,6 @@
31 self.uri = "xen:///"
32
33 self.readOnly = readOnly
34 - if not self.is_remote() and os.getuid() != 0 and self.uri != "qemu:///session":
35 - hasPolkit = False
36 - for f in LIBVIRT_POLICY_FILES:
37 - if os.path.exists(f):
38 - hasPolkit = True
39 -
40 - if not hasPolkit:
41 - self.readOnly = True
42 -
43 self.state = self.STATE_DISCONNECTED
44 self.vmm = None
45 self.storage_capable = None
46 @@ -464,8 +450,7 @@
47 logging.error(self.connectError)
48 return -1
49
50 - def _open_thread(self):
51 - logging.debug("Background thread is running")
52 + def _try_open(self):
53 try:
54 flags = 0
55 if self.readOnly:
56 @@ -478,12 +463,34 @@
57 libvirt.VIR_CRED_EXTERNAL],
58 self._do_creds,
59 None], flags)
60 + except:
61 + exc_info = sys.exc_info()
62 +
63 + # If the previous attempt was read/write try to fall back
64 + # on read-only connection, otherwise report the error.
65 + if not self.readOnly:
66 + try:
67 + self.vmm = libvirt.openReadOnly(self.uri)
68 + self.readOnly = True
69 + logging.info("Read/write connection failed to %s,"
70 + "falling back on read-only." % self.uri)
71 + return
72 + except:
73 + pass
74 +
75 + return exc_info
76
77 + def _open_thread(self):
78 + logging.debug("Background thread is running")
79 +
80 + open_error = self._try_open()
81 +
82 + if not open_error:
83 self.state = self.STATE_ACTIVE
84 - except:
85 + else:
86 self.state = self.STATE_DISCONNECTED
87
88 - (type, value, stacktrace) = sys.exc_info ()
89 + (type, value, stacktrace) = open_error
90 # Detailed error message, in English so it can be Googled.
91 self.connectError = \
92 ("Unable to open connection to hypervisor URI '%s':\n" %