[libvirt] [PATCH v2] polkit: Allow password-less access for 'libvirtadm' group
by Cole Robinson
Many users, who admin their own machines, want to be able to access
system libvirtd via tools like virt-manager without having to enter
a root password. Just google 'virt-manager without password' and
you'll find many hits. I've read at least 5 blog posts over the years
describing slightly different ways of achieving this goal.
Let's finally add official support for this.
Install a polkit-1 rules file granting password-less auth for any user
in the new 'libvirtadm' group. Create the group on RPM install
https://bugzilla.redhat.com/show_bug.cgi?id=957300
---
v2:
- Name the group libvirtadm (danpb)
- Name the source file libvirt.rules and rename on install (eblake)
daemon/Makefile.am | 13 +++++++++++++
daemon/libvirt.rules | 9 +++++++++
libvirt.spec.in | 15 +++++++++++++--
3 files changed, 35 insertions(+), 2 deletions(-)
create mode 100644 daemon/libvirt.rules
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 300b9a5..974feed 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -53,6 +53,7 @@ EXTRA_DIST = \
libvirtd.init.in \
libvirtd.upstart \
libvirtd.policy.in \
+ libvirt.rules \
libvirtd.sasl \
libvirtd.service.in \
libvirtd.socket.in \
@@ -233,6 +234,8 @@ policyauth = auth_admin_keep_session
else ! WITH_POLKIT0
policydir = $(datadir)/polkit-1/actions
policyauth = auth_admin_keep
+rulesdir = $(datadir)/polkit-1/rules.d
+rulesfile = libvirt.rules
endif ! WITH_POLKIT0
endif WITH_POLKIT
@@ -263,9 +266,19 @@ if WITH_POLKIT
install-data-polkit::
$(MKDIR_P) $(DESTDIR)$(policydir)
$(INSTALL_DATA) libvirtd.policy $(DESTDIR)$(policydir)/org.libvirt.unix.policy
+if ! WITH_POLKIT0
+ $(MKDIR_P) $(DESTDIR)$(rulesdir)
+ $(INSTALL_DATA) $(srcdir)/$(rulesfile) $(DESTDIR)$(rulesdir)/50-libvirt.rules
+endif ! WITH_POLKIT0
+
uninstall-data-polkit::
rm -f $(DESTDIR)$(policydir)/org.libvirt.unix.policy
rmdir $(DESTDIR)$(policydir) || :
+if ! WITH_POLKIT0
+ rm -f $(DESTDIR)$(rulesdir)/50-libvirt.rules
+ rmdir $(DESTDIR)$(rulesdir) || :
+endif ! WITH_POLKIT0
+
else ! WITH_POLKIT
install-data-polkit::
uninstall-data-polkit::
diff --git a/daemon/libvirt.rules b/daemon/libvirt.rules
new file mode 100644
index 0000000..e70c09b
--- /dev/null
+++ b/daemon/libvirt.rules
@@ -0,0 +1,9 @@
+// Allow any user in the 'libvirtadm' group to connect to system libvirtd
+// without entering a password.
+
+polkit.addRule(function(action, subject) {
+ if (action.id == "org.libvirt.unix.manage" &&
+ subject.isInGroup("libvirtadm")) {
+ return polkit.Result.YES;
+ }
+});
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 20af502..10a28a2 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1645,9 +1645,9 @@ then
fi
%if %{with_libvirtd}
+%pre daemon
%if ! %{with_driver_modules}
%if %{with_qemu}
-%pre daemon
%if 0%{?fedora} || 0%{?rhel} >= 6
# We want soft static allocation of well-known ids, as disk images
# are commonly shared across NFS mounts by id rather than name; see
@@ -1661,11 +1661,21 @@ if ! getent passwd qemu >/dev/null; then
useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
fi
fi
-exit 0
%endif
%endif
%endif
+ %if %{with_polkit}
+ %if 0%{?fedora} || 0%{?rhel} >= 6
+# 'libvirtadm' group is just to allow password-less polkit access to
+# libvirtd. The uid number is irrelevant, so we use dynamic allocation
+# described at the above link.
+getent group libvirtadm >/dev/null || groupadd -r libvirtadm
+ %endif
+ %endif
+
+exit 0
+
%post daemon
%if %{with_systemd}
@@ -1939,6 +1949,7 @@ exit 0
%if 0%{?fedora} || 0%{?rhel} >= 6
%{_datadir}/polkit-1/actions/org.libvirt.unix.policy
%{_datadir}/polkit-1/actions/org.libvirt.api.policy
+%{_datadir}/polkit-1/rules.d/50-libvirt.rules
%else
%{_datadir}/PolicyKit/policy/org.libvirt.unix.policy
%endif
--
2.3.6
9 years, 7 months
[libvirt] [PATCH v2 0/7] Cleanup flags checking and fix setvcpus
by Pavel Hrdina
The first four patches only cleanup the flags checking in our APIs by
introducing new macros to check exclusive flags and requirements.
Patch 5/7 uses the new macros to do better flags checking for
virDomainSetvcpusFlags API.
Patch 6/7 introduces macro to check virsh options requirements.
The last patch uses the requirement macro to cleanup virsh setvcpus code
and fixes a bug with --maximum option.
Because only the last patch actually fixes a bug issue, I'm not sure whether
this patch series should wait for next release cycle.
Luyao Huang (1):
tools: fix the wrong check when use virsh setvcpus --maximum
Pavel Hrdina (6):
internal: introduce macro helpers to reject exclusive flags
internal: introduce macro helpers to check flag requirements
use new macro helpers to check exclusive flags
use new macro helpers to check flag requirements
qemu: use new macros for setvcpus to check flags and cleanup the code
virsh: introduce new macros to help check flag requirements
src/internal.h | 87 +++++++++++
src/libvirt-domain-snapshot.c | 56 +++-----
src/libvirt-domain.c | 286 +++++++++++--------------------------
src/qemu/qemu_driver.c | 33 +----
src/storage/storage_backend_disk.c | 10 +-
src/storage/storage_backend_fs.c | 11 +-
tools/virsh-domain.c | 30 +---
tools/virsh.h | 52 +++++++
8 files changed, 256 insertions(+), 309 deletions(-)
--
2.0.5
9 years, 8 months
[libvirt] [python PATCH] examples: Add example to make guest agent lifecycle event useful
by Peter Krempa
This example allows to use the guest agent event and metadata to track
vCPU count set via the guest agent (agent-based onlining/offlining) and
keep it persistent accross domain restarts.
The daemon listens for the agent lifecycle event, and if it's received
it looks into doman's metadata to see whether a desired count was set
and issues the guest agent command.
---
MANIFEST.in | 2 +
examples/README | 2 +
examples/guest-vcpus/guest-vcpu-daemon.py | 131 ++++++++++++++++++++++++++++++
examples/guest-vcpus/guest-vcpu.py | 76 +++++++++++++++++
4 files changed, 211 insertions(+)
create mode 100755 examples/guest-vcpus/guest-vcpu-daemon.py
create mode 100755 examples/guest-vcpus/guest-vcpu.py
diff --git a/MANIFEST.in b/MANIFEST.in
index dd05221..2cd1b46 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -11,6 +11,8 @@ include examples/domsave.py
include examples/domstart.py
include examples/esxlist.py
include examples/event-test.py
+include examples/guest-vcpus/guest-vcpu-daemon.py
+include examples/guest-vcpus/guest-vcpu.py
include examples/topology.py
include generator.py
include libvirt-lxc-override-api.xml
diff --git a/examples/README b/examples/README
index 1d4b425..0cb4513 100644
--- a/examples/README
+++ b/examples/README
@@ -12,6 +12,8 @@ esxlist.py - list active domains of an VMware ESX host and print some info.
also demonstrates how to use the libvirt.openAuth() method
dhcpleases.py - list dhcp leases for a given virtual network
domipaddrs.py - list IP addresses for guest domains
+guest-vcpus - two helpers to make the guest agent event useful with agent based
+ vCPU state modification
The XML files in this directory are examples of the XML format that libvirt
expects, and will have to be adapted for your setup. They are only needed
diff --git a/examples/guest-vcpus/guest-vcpu-daemon.py b/examples/guest-vcpus/guest-vcpu-daemon.py
new file mode 100755
index 0000000..e5a389e
--- /dev/null
+++ b/examples/guest-vcpus/guest-vcpu-daemon.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+
+import libvirt
+import threading
+from xml.dom import minidom
+import time
+
+uri = "qemu:///system"
+customXMLuri = "guest-cpu.python.libvirt.org"
+connectRetryTimeout = 5
+
+class workerData:
+ def __init__(self):
+ self.doms = list()
+ self.conn = None
+ self.cond = threading.Condition()
+
+ def notify(self):
+ self.cond.acquire()
+ self.cond.notify()
+ self.cond.release()
+
+ def waitNotify(self):
+ self.cond.acquire()
+ self.cond.wait()
+ self.cond.release()
+
+ def addDomainNotify(self, dom):
+ self.doms.append(dom)
+ self.notify()
+
+ def closeConnectNotify(self):
+ conn = self.conn
+ self.conn = None
+ conn.close()
+ self.notify()
+
+ def setConnect(self, conn):
+ self.conn = conn
+
+ def hasConn(self):
+ return self.conn is not None
+
+ def hasDom(self):
+ return len(self.doms) > 0
+
+ def getDom(self):
+ return self.doms.pop()
+
+ def setDoms(self, doms):
+ self.doms = doms
+
+
+def virEventLoopNativeRun():
+ while True:
+ libvirt.virEventRunDefaultImpl()
+
+def handleAgentLifecycleEvent(conn, dom, state, reason, opaque):
+ if state == libvirt.VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_STATE_CONNECTED:
+ opaque.addDomainNotify(dom)
+
+def handleConnectClose(conn, reason, opaque):
+ print('Disconnected from ' + uri)
+ opaque.closeConnectNotify()
+
+def handleLibvirtLibraryError(opaque, error):
+ pass
+
+def processAgentConnect(dom):
+ try:
+ cpus = dom.metadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT, customXMLuri,
+ libvirt.VIR_DOMAIN_AFFECT_LIVE)
+ doc = minidom.parseString(cpus)
+ ncpus = int(doc.getElementsByTagName('ncpus')[0].getAttribute('count'))
+ except:
+ return
+
+ try:
+ dom.setVcpusFlags(ncpus, libvirt.VIR_DOMAIN_AFFECT_LIVE | libvirt.VIR_DOMAIN_VCPU_GUEST)
+ print("seting vcpus for domain " + dom.name() + " count " + str(ncpus))
+ except:
+ print("failed to set vcpu count for domain " + dom.name())
+
+def work():
+ data = workerData()
+
+ print("Using uri: " + uri)
+
+ while True:
+ if not data.hasConn():
+ try:
+ conn = libvirt.open(uri)
+ except:
+ print('Failed to connect to ' + uri + ' Retry in ' + str(connectRetryTimeout)) + ' seconds'
+ time.sleep(connectRetryTimeout)
+ continue
+
+ print('Connected to ' + uri)
+
+ data.setConnect(conn)
+ conn.registerCloseCallback(handleConnectClose, data)
+ conn.setKeepAlive(5, 3)
+ conn.domainEventRegisterAny(None,
+ libvirt.VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE,
+ handleAgentLifecycleEvent,
+ data)
+
+ data.setDoms(conn.listAllDomains(libvirt.VIR_CONNECT_LIST_DOMAINS_ACTIVE))
+
+ while data.hasConn() and data.hasDom():
+ processAgentConnect(data.getDom())
+
+ data.waitNotify()
+
+def main():
+ libvirt.virEventRegisterDefaultImpl()
+ libvirt.registerErrorHandler(handleLibvirtLibraryError, None)
+
+ worker = threading.Thread(target=work)
+ worker.setDaemon(True)
+ worker.start()
+
+ eventLoop = threading.Thread(target=virEventLoopNativeRun)
+ eventLoop.setDaemon(True)
+ eventLoop.start()
+
+ while True:
+ time.sleep(1)
+
+if __name__ == "__main__":
+ main()
diff --git a/examples/guest-vcpus/guest-vcpu.py b/examples/guest-vcpus/guest-vcpu.py
new file mode 100755
index 0000000..965b09c
--- /dev/null
+++ b/examples/guest-vcpus/guest-vcpu.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+import libvirt
+import sys
+import getopt
+import os
+
+customXMLuri = "guest-cpu.python.libvirt.org"
+
+def usage():
+ print("usage: "+os.path.basename(sys.argv[0])+" [-hcl] domain count [uri]")
+ print(" uri will default to qemu:///system")
+ print(" --help, -h Print(this help message")
+ print(" --config, -c Modify persistent domain configuration")
+ print(" --live, -l Modify live domain configuration")
+ print("")
+ print("Sets the vCPU count via the guest agent and sets the metadata element " +
+ "used by guest-vcpu-daemon.py example")
+
+uri = "qemu:///system"
+flags = 0
+live = False;
+config = False;
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hcl", ["help", "config", "live"])
+except getopt.GetoptError as err:
+ # print help information and exit:
+ print(str(err)) # will print something like "option -a not recognized"
+ usage()
+ sys.exit(2)
+for o, a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ sys.exit()
+ if o in ("-c", "--config"):
+ config = True
+ flags |= libvirt.VIR_DOMAIN_AFFECT_CONFIG
+
+ if o in ("-l", "--live"):
+ live = True
+ flags |= libvirt.VIR_DOMAIN_AFFECT_LIVE
+
+if len(args) < 2:
+ usage()
+ sys.exit(1)
+elif len(args) >= 3:
+ uri = args[2]
+
+domain = args[0]
+count = int(args[1])
+
+conn = libvirt.open(uri)
+dom = conn.lookupByName(domain)
+
+if flags == 0 or config:
+ confvcpus = dom.vcpusFlags(libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+
+ if confvcpus < count:
+ print("Persistent domain configuration has only " + str(confvcpus) + " vcpus configured")
+ sys.exit(1)
+
+if flags == 0 or live:
+ livevcpus = dom.vcpusFlags(libvirt.VIR_DOMAIN_AFFECT_LIVE)
+
+ if livevcpus < count:
+ print("Live domain configuration has only " + str(livevcpus) + " vcpus configured")
+ sys.exit(1)
+
+
+if flags == 0 or live:
+ dom.setVcpusFlags(count, libvirt.VIR_DOMAIN_AFFECT_LIVE | libvirt.VIR_DOMAIN_VCPU_GUEST)
+
+meta = "<ncpus count='" + str(count) + "'/>"
+
+dom.setMetadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT, meta, "guestvcpudaemon", customXMLuri, flags)
--
2.3.5
9 years, 8 months
[libvirt] [PATCH] domain: conf: Drop unused OSTYPE_AIX
by Cole Robinson
The phyp driver stuffed it into a DomainDefPtr during its attachdevice
routine, but the value is never advertised via capabilities so it should
be safe to drop.
Have the phyp driver use OSTYPE_LINUX, which is what it advertises via
capabilities.
---
docs/schemas/capability.rng | 3 ++-
src/conf/domain_conf.c | 3 +--
src/conf/domain_conf.h | 1 -
src/phyp/phyp_driver.c | 2 +-
tests/vircapstest.c | 2 +-
5 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 5f3ec70..88e08d2 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -262,7 +262,8 @@
<element name='os_type'>
<choice>
<value>xen</value> <!-- Xen 3.0 pv -->
- <value>linux</value> <!-- same as 'xen' - legacy -->
+ <value>linux</value> <!-- same as 'xen' - meant to be legacy,
+ but is also used by phyp driver -->
<value>hvm</value> <!-- unmodified OS -->
<value>exe</value> <!-- For container based virt -->
<value>uml</value> <!-- user mode linux -->
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 479b4c2..6565350 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -120,8 +120,7 @@ VIR_ENUM_IMPL(virDomainOS, VIR_DOMAIN_OSTYPE_LAST,
"xen",
"linux",
"exe",
- "uml",
- "aix")
+ "uml")
VIR_ENUM_IMPL(virDomainBoot, VIR_DOMAIN_BOOT_LAST,
"fd",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 25d3ee6..7a374d7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -233,7 +233,6 @@ typedef enum {
VIR_DOMAIN_OSTYPE_LINUX,
VIR_DOMAIN_OSTYPE_EXE,
VIR_DOMAIN_OSTYPE_UML,
- VIR_DOMAIN_OSTYPE_AIX,
VIR_DOMAIN_OSTYPE_LAST
} virDomainOSType;
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index e9a31d0..c558c48 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1720,7 +1720,7 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml)
if (domain_name == NULL)
goto cleanup;
- def->os.type = VIR_DOMAIN_OSTYPE_AIX;
+ def->os.type = VIR_DOMAIN_OSTYPE_LINUX;
dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE);
diff --git a/tests/vircapstest.c b/tests/vircapstest.c
index 5a43d63..0c79af8 100644
--- a/tests/vircapstest.c
+++ b/tests/vircapstest.c
@@ -250,7 +250,7 @@ test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED)
VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64LE,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries");
- CAPS_EXPECT_ERR(VIR_DOMAIN_OSTYPE_AIX, VIR_ARCH_NONE, -1, NULL, NULL);
+ CAPS_EXPECT_ERR(VIR_DOMAIN_OSTYPE_LINUX, VIR_ARCH_NONE, -1, NULL, NULL);
CAPS_EXPECT_ERR(-1, VIR_ARCH_PPC64LE, -1, NULL, "pc");
CAPS_EXPECT_ERR(-1, VIR_ARCH_MIPS, -1, NULL, NULL);
CAPS_EXPECT_ERR(-1, VIR_ARCH_AARCH64, VIR_DOMAIN_VIRT_KVM,
--
2.3.5
9 years, 8 months
[libvirt] [PATCH 0/5] Use synchronous block job events in qemu_migration
by Michael Chapman
This patch series converts qemu_migration to use the synchronous block job
event code introduced in commit 630ee5ac.
It fixes two problems:
- Drive mirroring has been broken since that commit, since the event
indicating mirror readiness isn't processed while the VM object is locked.
- Migration did not wait until the drive mirrors were properly cancelled,
and this could cause disk corruption.
Patch 1 moves qemuBlockJobEventProcess into a separate source file so it can
be used by both qemu_driver and qemu_migration. Patch 2 introduces new
qemuBlockJobSync* help functions to manage a synchronous block job. Patch 3
ensures that a thread waiting on a synchronous block job event is woken up
should the domain crash. Patches 4 and 5 use the new synchronous block job
helpers in qemu_driver and qemu_migration respectively.
Michael Chapman (5):
qemuBlockJobEventProcess: move to new source file
qemuBlockJobSync*: introduce sync block job helpers
qemuProcessStop: wake up pending sync block jobs
qemuDomainBlockJobAbort: use sync block job helpers
qemu: migration: use sync block job helpers
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/qemu/qemu_blockjob.c | 331 ++++++++++++++++++++++++++++++++++
src/qemu/qemu_blockjob.h | 49 ++++++
src/qemu/qemu_driver.c | 174 +++---------------
src/qemu/qemu_migration.c | 439 ++++++++++++++++++++++++++++------------------
src/qemu/qemu_process.c | 7 +
7 files changed, 676 insertions(+), 326 deletions(-)
create mode 100644 src/qemu/qemu_blockjob.c
create mode 100644 src/qemu/qemu_blockjob.h
--
2.1.0
9 years, 8 months
[libvirt] [libvirt-test-api][PATCH 1/3] introduce 2 functions in utils
by Luyao Huang
get_standard_deviation() is to get Standard Deviation, and
param_to_tuple_nolength() allow do not pass lengh when use
param_to_tuple().
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
utils/utils.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/utils/utils.py b/utils/utils.py
index c3e46f6..954b2bf 100644
--- a/utils/utils.py
+++ b/utils/utils.py
@@ -31,6 +31,7 @@ import string
import subprocess
import hashlib
import libvirt
+import math
from xml.dom import minidom
from urlparse import urlparse
@@ -896,3 +897,30 @@ def validate_remote_blk_type(hostname, username, password,
else:
logger.info("lspci and lsmod return nothing")
return 1
+
+def get_standard_deviation(cb1, cb2, opaque1, opaque2, number = 1000):
+ """ pass two callback functions and opaque return Standard Deviation,
+ this function will be useful when need equal some quick change
+ value (like memory, cputime), default loop times are 1000,
+ and notice callback functions cb1 and cb2 should allways success
+ """
+ D = 0
+ for i in range(number):
+ a = cb1(opaque1)
+ b = cb2(opaque2)
+ D += (int(a) - int(b))**2
+ return math.sqrt(D/number)
+
+def param_to_tuple_nolength(paramlist):
+ """paramlist contains numbers which can be divided by '-', '^' and
+ ',', return tuple only have True or False value
+ """
+ d = []
+ a = paramlist.split(',')
+ for i in range(len(a)):
+ if a[i].find('^') >= 0:
+ continue
+ d += a[i].split('-')
+ lengh = max(d)
+
+ return param_to_tuple(paramlist, int(lengh) + 1)
--
1.8.3.1
9 years, 8 months
[libvirt] [PATCH 0/3] qemu: Add baybysitting for memory hotplug users
by Peter Krempa
Add sanity checks for some unsupported/invalid configs of memory devices.
Peter Krempa (3):
qemu: conf: Reject memory device if it would exceed configured max
size
qemu: command: Validate that memory devices slot ID is in range
qemu: Validate available slot count for memory devices
src/conf/domain_conf.c | 11 +++++++++++
src/qemu/qemu_command.c | 19 ++++++++++++++++++-
src/qemu/qemu_command.h | 1 +
src/qemu/qemu_driver.c | 6 ++++++
src/qemu/qemu_hotplug.c | 8 +++++++-
5 files changed, 43 insertions(+), 2 deletions(-)
--
2.3.5
9 years, 8 months
[libvirt] [PATCHv2] qemu: blockCopy: Allow reuse of raw image for shallow block copy
by Peter Krempa
The documentation states that for shallow block copy the image has to
have the same guest visible content as backing file of the current
image if the file is being reused. This condition can be achieved also
with a raw file (or a qcow without a backing file) so remove the
condition that would disallow it.
(This patch additionally fixes crash described in
https://bugzilla.redhat.com/show_bug.cgi?id=1215569 )
---
V2:
- different approach to fix Eric's comment
src/qemu/qemu_driver.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 80463f2..581211a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17122,11 +17122,17 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
goto endjob;
+ /* clear the _SHALLOW flag if there is only one layer */
+ if (!disk->src->backingStore)
+ flags &= ~VIR_DOMAIN_BLOCK_COPY_SHALLOW;
+
+ /* unless the user provides a pre-created file, shallow copy into a raw
+ * file is not possible */
if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) &&
- mirror->format == VIR_STORAGE_FILE_RAW &&
- disk->src->backingStore->path) {
+ !(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT) &&
+ mirror->format == VIR_STORAGE_FILE_RAW) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("disk '%s' has backing file, so raw shallow copy "
+ _("shallow copy of disk '%s' into a raw file "
"is not possible"),
disk->dst);
goto endjob;
--
2.3.5
9 years, 8 months
[libvirt] [libvirt-test-API][PATCH 0/3] Modify the existing cases to cover 4 new APIs
by jiahu
Modify the existing cases to cover below 4 new APIs:
networkLookupByUUIDString/networkLookupByUUID
storagePoolLookupByUUIDString/storagePoolLookupByUUID
jiahu (3):
Add two testing cases to test_connection.conf
Modify the case to cover two new APIs
Modify the case to cover two new APIs
cases/test_connection.conf | 8 +++++
repos/network/network_uuid.py | 68 ++++++++++++++++++++++++++++++++++++-------
repos/storage/pool_uuid.py | 49 ++++++++++++++++++++++++++++++-
3 files changed, 114 insertions(+), 11 deletions(-)
--
1.8.3.1
9 years, 8 months
[libvirt] [PATCH] openvz: Drop useless domain lookup
by Michal Privoznik
The lookup is just for check whether a domain we are about to add does
not already exists. Well, the virDomainObjListAdd() function does that
for us already so there's no need to duplicate the check.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/openvz/openvz_driver.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 10d94ff..d1a327c 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1001,14 +1001,6 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
parse_flags)) == NULL)
goto cleanup;
- vm = virDomainObjListFindByName(driver->domains, vmdef->name);
- if (vm) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("Already an OPENVZ VM active with the id '%s'"),
- vmdef->name);
- virDomainObjEndAPI(&vm);
- goto cleanup;
- }
if (!(vm = virDomainObjListAdd(driver->domains, vmdef,
driver->xmlopt,
0, NULL)))
@@ -1098,14 +1090,6 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
parse_flags)) == NULL)
goto cleanup;
- vm = virDomainObjListFindByName(driver->domains, vmdef->name);
- if (vm) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("Already an OPENVZ VM defined with the id '%s'"),
- vmdef->name);
- virDomainObjEndAPI(&vm);
- goto cleanup;
- }
if (!(vm = virDomainObjListAdd(driver->domains,
vmdef,
driver->xmlopt,
--
2.0.5
9 years, 8 months