[libvirt] <seclabel> inside a //disk/source element
by Richard W.M. Jones
According to the docs, it should be possible to do:
<disk device="disk" type="file">
<source file="/path/to/some/file">
<seclabel relabel="no"/> <---- NB
</source>
<target dev="sda" bus="scsi"/>
<driver name="qemu" type="qcow2"/>
</disk>
However I tried it, and it simply doesn't work. Furthermore I looked
at the code in domain_conf.c, and I can't see how it's even supposed
to work. It doesn't look to me as if <seclabel> is ever parsed in
that context.
Can anyone else confirm that this is a bug or point out my error?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
11 years, 8 months
[libvirt] [PATCH] Fix autodestroy of QEMU guests
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The virQEMUCloseCallbacksRunOne method was passing a uuid string
to virDomainObjListFindByUUID, when it actually expected to get
a raw uuid buffer. This was not caught by the compiler because
the method was using a 'void *uuid' instead of first casting
it to the expected type.
This regression was accidentally caused by refactoring in
commit 568a6cda277f04ab9baaeb97490e548b7b608aa6
Author: Jiri Denemark <jdenemar(a)redhat.com>
Date: Fri Feb 15 15:11:47 2013 +0100
qemu: Avoid deadlock in autodestroy
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_conf.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4f0cb18..1cd4b7c 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -805,22 +805,26 @@ struct virQEMUCloseCallbacksData {
static void
virQEMUCloseCallbacksRunOne(void *payload,
- const void *uuid,
+ const void *key,
void *opaque)
{
struct virQEMUCloseCallbacksData *data = opaque;
qemuDriverCloseDefPtr closeDef = payload;
virDomainObjPtr dom;
+ const char *uuidstr = key;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+
+ if (virUUIDParse(uuidstr, uuid) < 0)
+ return;
VIR_DEBUG("conn=%p, thisconn=%p, uuid=%s, cb=%p",
- closeDef->conn, data->conn, (const char *) uuid, closeDef->cb);
+ closeDef->conn, data->conn, uuidstr, closeDef->cb);
if (data->conn != closeDef->conn || !closeDef->cb)
return;
if (!(dom = virDomainObjListFindByUUID(data->driver->domains, uuid))) {
- VIR_DEBUG("No domain object with UUID %s",
- (const char *) uuid);
+ VIR_DEBUG("No domain object with UUID %s", uuidstr);
return;
}
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] Fix typo in internal VIR_QEMU_PROCESS_START_AUTODESROY constant
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
s/VIR_QEMU_PROCESS_START_AUTODESROY/VIR_QEMU_PROCESS_START_AUTODESTROY/
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_driver.c | 4 ++--
src/qemu/qemu_migration.c | 2 +-
src/qemu/qemu_process.c | 4 ++--
src/qemu/qemu_process.h | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8dae8f9..0f6a431 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1460,7 +1460,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml,
if (flags & VIR_DOMAIN_START_PAUSED)
start_flags |= VIR_QEMU_PROCESS_START_PAUSED;
if (flags & VIR_DOMAIN_START_AUTODESTROY)
- start_flags |= VIR_QEMU_PROCESS_START_AUTODESROY;
+ start_flags |= VIR_QEMU_PROCESS_START_AUTODESTROY;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
@@ -5403,7 +5403,7 @@ qemuDomainObjStart(virConnectPtr conn,
unsigned int start_flags = VIR_QEMU_PROCESS_START_COLD;
start_flags |= start_paused ? VIR_QEMU_PROCESS_START_PAUSED : 0;
- start_flags |= autodestroy ? VIR_QEMU_PROCESS_START_AUTODESROY : 0;
+ start_flags |= autodestroy ? VIR_QEMU_PROCESS_START_AUTODESTROY : 0;
/*
* If there is a managed saved state restore it instead of starting
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index cae58fa..a58a79d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2124,7 +2124,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
if (qemuProcessStart(dconn, driver, vm, migrateFrom, dataFD[0], NULL, NULL,
VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START,
VIR_QEMU_PROCESS_START_PAUSED |
- VIR_QEMU_PROCESS_START_AUTODESROY) < 0) {
+ VIR_QEMU_PROCESS_START_AUTODESTROY) < 0) {
virDomainAuditStart(vm, "migrated", false);
/* Note that we don't set an error here because qemuProcessStart
* should have already done that.
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b9fdcd2..db95d6e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3516,7 +3516,7 @@ int qemuProcessStart(virConnectPtr conn,
* but doesn't hurt to check */
virCheckFlags(VIR_QEMU_PROCESS_START_COLD |
VIR_QEMU_PROCESS_START_PAUSED |
- VIR_QEMU_PROCESS_START_AUTODESROY, -1);
+ VIR_QEMU_PROCESS_START_AUTODESTROY, -1);
cfg = virQEMUDriverGetConfig(driver);
@@ -4043,7 +4043,7 @@ int qemuProcessStart(virConnectPtr conn,
VIR_DOMAIN_PAUSED_USER);
}
- if (flags & VIR_QEMU_PROCESS_START_AUTODESROY &&
+ if (flags & VIR_QEMU_PROCESS_START_AUTODESTROY &&
qemuProcessAutoDestroyAdd(driver, vm, conn) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index bc4d54d..7d0aaa8 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -47,7 +47,7 @@ int qemuProcessAssignPCIAddresses(virDomainDefPtr def);
typedef enum {
VIR_QEMU_PROCESS_START_COLD = 1 << 0,
VIR_QEMU_PROCESS_START_PAUSED = 1 << 1,
- VIR_QEMU_PROCESS_START_AUTODESROY = 1 << 2,
+ VIR_QEMU_PROCESS_START_AUTODESTROY = 1 << 2,
} qemuProcessStartFlags;
int qemuProcessStart(virConnectPtr conn,
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] Avoid spamming logs with cgroups warnings
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The code for putting the emulator threads in a separate cgroup
would spam the logs with warnings
2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 3
2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 4
2013-02-27 16:08:26.732+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 6
This is because it has only created child cgroups for 3 of the
controllers, but was trying to move the processes from all the
controllers. The fix is to only try to move threads in the
controllers we actually created. Also remove the warning and
make it return a hard error to avoid such lazy callers in the
future.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_cgroup.c | 5 +++++
src/util/vircgroup.c | 3 +--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index e65b486..671d613 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -692,6 +692,11 @@ int qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
}
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+ if (i != VIR_CGROUP_CONTROLLER_CPU &&
+ i != VIR_CGROUP_CONTROLLER_CPUACCT &&
+ i != VIR_CGROUP_CONTROLLER_CPUSET)
+ continue;
+
if (!qemuCgroupControllerActive(driver, i))
continue;
rc = virCgroupMoveTask(cgroup, cgroup_emulator, i);
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 48cba93..532e704 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -884,8 +884,7 @@ int virCgroupMoveTask(virCgroupPtr src_group, virCgroupPtr dest_group,
if (!src_group->controllers[controller].mountPoint ||
!dest_group->controllers[controller].mountPoint) {
- VIR_WARN("no vm cgroup in controller %d", controller);
- return 0;
+ return -EINVAL;
}
rc = virCgroupGetValueStr(src_group, controller, "tasks", &content);
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] Don't try to add non-existant devices to ACL
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The QEMU driver has a list of devices nodes that are whitelisted
for all guests. The kernel has recently started returning an
error if you try to whitelist a device which does not exist.
This causes a warning in libvirt logs and an audit error for
any missing devices. eg
2013-02-27 16:08:26.515+0000: 29625: warning : virDomainAuditCgroup:451 : success=no virt=kvm resrc=cgroup reason=allow vm="vm031714" uuid=9d8f1de0-44f4-a0b1-7d50-e41ee6cd897b cgroup="/sys/fs/cgroup/devices/libvirt/qemu/vm031714/" class=path path=/dev/kqemu rdev=? acl=rw
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_cgroup.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 671d613..9d6e88b 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -265,6 +265,12 @@ int qemuSetupCgroup(virQEMUDriverPtr driver,
}
for (i = 0; deviceACL[i] != NULL ; i++) {
+ if (access(deviceACL[i], F_OK) < 0) {
+ VIR_DEBUG("Ignoring non-existant device %s",
+ deviceACL[i]);
+ continue;
+ }
+
rc = virCgroupAllowDevicePath(cgroup, deviceACL[i],
VIR_CGROUP_DEVICE_RW);
virDomainAuditCgroupPath(vm, cgroup, "allow", deviceACL[i], "rw", rc);
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] qemu: -numa doesn't (yet) support disjoint range
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=896092 mentions that
qemu 1.4 and earlier only accept a simple start-stop range for
the cpu=... argument of -numa. Libvirt would attempt to use
-numa cpu=1,3 for a disjoint range, which did not work as intended.
Upstream qemu will be adding a new syntax for disjoint cpu ranges
in 1.5; but the design for that syntax is still under discussion
at the time of this patch. So for libvirt 1.0.3, it is safest to
just reject attempts to build an invalid qemu command line; in the
future, we can add a capability bit and translate to the final
accepted design for selecting a disjoint cpu range in numa.
* src/qemu/qemu_command.c (qemuBuildNumaArgStr): Reject disjoint
ranges.
---
Also in response to:
https://www.redhat.com/archives/libvir-list/2013-February/msg01414.html
src/qemu/qemu_command.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1c9bfc9..4f426e5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4756,32 +4756,47 @@ qemuBuildNumaArgStr(const virDomainDefPtr def, virCommandPtr cmd)
{
int i;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- char *cpumask;
+ char *cpumask = NULL;
+ int ret = -1;
for (i = 0; i < def->cpu->ncells; i++) {
+ VIR_FREE(cpumask);
virCommandAddArg(cmd, "-numa");
virBufferAsprintf(&buf, "node,nodeid=%d", def->cpu->cells[i].cellid);
virBufferAddLit(&buf, ",cpus=");
cpumask = virBitmapFormat(def->cpu->cells[i].cpumask);
if (cpumask) {
- virBufferAsprintf(&buf, "%s", cpumask);
- VIR_FREE(cpumask);
+ /* Up through qemu 1.4, -numa does not accept a cpus
+ * argument any more complex than start-stop.
+ *
+ * XXX For qemu 1.5, the syntax has not yet been decided;
+ * but when it is, we need a capability bit and
+ * translation of our cpumask into the qemu syntax. */
+ if (strchr(cpumask, ',')) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("disjoint NUMA cpu ranges are not supported "
+ "with this QEMU"));
+ goto cleanup;
+ }
+ virBufferAdd(&buf, cpumask, -1);
}
def->cpu->cells[i].mem = VIR_DIV_UP(def->cpu->cells[i].mem,
1024) * 1024;
virBufferAsprintf(&buf, ",mem=%d", def->cpu->cells[i].mem / 1024);
- if (virBufferError(&buf))
- goto error;
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ goto cleanup;
+ }
virCommandAddArgBuffer(cmd, &buf);
}
- return 0;
+ ret = 0;
-error:
+cleanup:
+ VIR_FREE(cpumask);
virBufferFreeAndReset(&buf);
- virReportOOMError();
- return -1;
+ return ret;
}
static int
--
1.8.1.2
11 years, 8 months
[libvirt] [PATCH] util: Add docs for virXMLProp string
by Peter Krempa
To avoid confusion about usage of this function explicitly document that
this function returns copy of the attribute string.
---
src/util/virxml.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 74f8beb..aa55a33 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -468,6 +468,16 @@ virXPathLongLong(const char *xpath,
return ret;
}
+/**
+ * virXMLPropString:
+ * @node: XML dom node pointer
+ * @name: Name of the property (attribute) to get
+ *
+ * Convenience function to return copy of an attribute value of a XML node.
+ *
+ * Returns the property (attribute) value as string or NULL in case of failure.
+ * The caller is responsible for freeing the returned buffer.
+ */
char *
virXMLPropString(xmlNodePtr node,
const char *name)
--
1.8.1.1
11 years, 8 months
[libvirt] Hard requirement on gcrypt.h?
by Eugene Marcotte
Hi,
I'm building libvirt for the first time and figuring out what libraries
are required to get the simplest possible thing working.
Is there a hard requirement on gcrypt? I got libvirt past the configure
script but the build failed on gcrypt.h. It looks like the include for
it could be moved inside the #if WITH_GNUTLS section of libirt.c, if I
understand what configure.ac is trying to set up.
Thoughts?
Thanks!
Eugene
11 years, 8 months
[libvirt] [PATCH] tests: fix leaks in storagevolxml2argvtest
by Ján Tomko
Reported by John Ferlan.
---
tests/storagevolxml2argvtest.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 416bb6f..77ba800 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -89,6 +89,10 @@ cleanup:
virCommandFree(cmd);
VIR_FREE(actualCmdline);
VIR_FREE(expectedCmdline);
+ VIR_FREE(poolXmlData);
+ VIR_FREE(volXmlData);
+ VIR_FREE(inputvolXmlData);
+ virObjectUnref(conn);
return ret;
}
--
1.7.12.4
11 years, 8 months