[libvirt] [PATCH 0/4] Take 3 - Patchset to avoid uid problems in volume creation
by Laine Stump
The last iteration of this work (which is now completely obsoleted) is
at https://www.redhat.com/archives/libvir-list/2010-January/msg00302.html
These patches are intended in particular to deal with problems
creating storage volumes on pools that are located on root-squashing
NFS servers, but hopefully they are overall just "a good thing" and
will solve other as-yet-unencountered/unreported problems.
Differences from previous version of the patches:
1) For completeness, chmod is done inside virFileCreate and
virDirCreate as well as setting uid and gid.
2) Both of those functions now take an additional flag -
VIR_FILE_CREATE_ALLOW_EXIST, which does exactly what you'd think.
3) I now always attempt to set uid/gid correctly, even if not running
as root (per Serge Hallyn's suggestions during the last go around)
4) I've added a patch that uses similar logic to get the uid/gid/mode
of the directories for newly created pools correct as well.
(Previously, we'd been ignoring the permission bits of pool
definition xml).
14 years, 11 months
[libvirt] [PATCH 1/3] Make sure that the vmx2xml test data files are shipped in the distribution.
by Diego Elio Pettenò
Without these files the tests will fail when ESX support is enabled.
---
tests/Makefile.am | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 335b0e5..cf51162 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,6 +47,67 @@ qemuhelpdata = \
qemu-kvm-0.10.5 \
qemu-kvm-0.11.0-rc2
+vmx2xmldata = \
+ vmx2xml-cdrom-ide-device.vmx \
+ vmx2xml-cdrom-ide-device.xml \
+ vmx2xml-cdrom-ide-file.vmx \
+ vmx2xml-cdrom-ide-file.xml \
+ vmx2xml-cdrom-scsi-device.vmx \
+ vmx2xml-cdrom-scsi-device.xml \
+ vmx2xml-cdrom-scsi-file.vmx \
+ vmx2xml-cdrom-scsi-file.xml \
+ vmx2xml-esx-in-the-wild-1.vmx \
+ vmx2xml-esx-in-the-wild-1.xml \
+ vmx2xml-esx-in-the-wild-2.vmx \
+ vmx2xml-esx-in-the-wild-2.xml \
+ vmx2xml-esx-in-the-wild-3.vmx \
+ vmx2xml-esx-in-the-wild-3.xml \
+ vmx2xml-esx-in-the-wild-4.vmx \
+ vmx2xml-esx-in-the-wild-4.xml \
+ vmx2xml-ethernet-bridged.vmx \
+ vmx2xml-ethernet-bridged.xml \
+ vmx2xml-ethernet-custom.vmx \
+ vmx2xml-ethernet-custom.xml \
+ vmx2xml-ethernet-e1000.vmx \
+ vmx2xml-ethernet-e1000.xml \
+ vmx2xml-floppy-device.vmx \
+ vmx2xml-floppy-device.xml \
+ vmx2xml-floppy-file.vmx \
+ vmx2xml-floppy-file.xml \
+ vmx2xml-gsx-in-the-wild-1.vmx \
+ vmx2xml-gsx-in-the-wild-1.xml \
+ vmx2xml-gsx-in-the-wild-2.vmx \
+ vmx2xml-gsx-in-the-wild-2.xml \
+ vmx2xml-gsx-in-the-wild-3.vmx \
+ vmx2xml-gsx-in-the-wild-3.xml \
+ vmx2xml-gsx-in-the-wild-4.vmx \
+ vmx2xml-gsx-in-the-wild-4.xml \
+ vmx2xml-harddisk-ide-file.vmx \
+ vmx2xml-harddisk-ide-file.xml \
+ vmx2xml-harddisk-scsi-file.vmx \
+ vmx2xml-harddisk-scsi-file.xml \
+ vmx2xml-minimal-64bit.vmx \
+ vmx2xml-minimal-64bit.xml \
+ vmx2xml-minimal.vmx \
+ vmx2xml-minimal.xml \
+ vmx2xml-parallel-device.vmx \
+ vmx2xml-parallel-device.xml \
+ vmx2xml-parallel-file.vmx \
+ vmx2xml-parallel-file.xml \
+ vmx2xml-scsi-buslogic.vmx \
+ vmx2xml-scsi-buslogic.xml \
+ vmx2xml-scsi-writethrough.vmx \
+ vmx2xml-scsi-writethrough.xml \
+ vmx2xml-serial-device.vmx \
+ vmx2xml-serial-device.xml \
+ vmx2xml-serial-file.vmx \
+ vmx2xml-serial-file.xml \
+ vmx2xml-serial-pipe-client-app.vmx \
+ vmx2xml-serial-pipe-client-vm.vmx \
+ vmx2xml-serial-pipe-server-app.vmx \
+ vmx2xml-serial-pipe-server-vm.vmx \
+ vmx2xml-serial-pipe.xml
+
EXTRA_DIST = \
oomtrace.pl \
test-lib.sh \
@@ -69,7 +130,8 @@ EXTRA_DIST = \
storagevolxml2xmlin \
nodedevschematest \
nodedevschemadata \
- $(patsubst %,qemuhelpdata/%,$(qemuhelpdata))
+ $(patsubst %,qemuhelpdata/%,$(qemuhelpdata)) \
+ $(patsubst %,vmx2xmldata/%,$(vmx2xmldata))
noinst_PROGRAMS = virshtest conftest \
nodeinfotest statstest qparamtest
--
1.6.6.rc4
14 years, 11 months
[libvirt] [PATCH] qemu: Don't allocate zero bytes
by Matthias Bolte
---
src/qemu/qemu_conf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 38eb3fd..92a9348 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -836,7 +836,7 @@ qemudCapsInitGuest(virCapsPtr caps,
return -1;
}
- if (VIR_ALLOC_N(machines, nmachines) < 0) {
+ if (VIR_ALLOC_N(machines, 1) < 0) {
virReportOOMError(NULL);
VIR_FREE(machine->name);
VIR_FREE(machine);
--
1.6.3.3
14 years, 11 months
[libvirt] [PATCH] node_device_linux_sysfs.c: avoid opendir/fd leak on error path
by Jim Meyering
This looks pretty clear.
It calls closedir upon successful return, but not in the error case.
>From 526a2bc2d87f0bf7a0c16a2a96316e5c1d5dae2e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 20 Jan 2010 17:49:35 +0100
Subject: [PATCH] node_device_linux_sysfs.c: avoid opendir/fd leak on error path
* src/node_device/node_device_linux_sysfs.c(get_virtual_functions_linux):
Don't leak a DIR buffer and file descriptor on error path.
---
src/node_device/node_device_linux_sysfs.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c
index ff7aaf0..e611e1a 100644
--- a/src/node_device/node_device_linux_sysfs.c
+++ b/src/node_device/node_device_linux_sysfs.c
@@ -2,7 +2,7 @@
* node_device_hal_linuc.c: Linux specific code to gather device data
* not available through HAL.
*
- * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2009-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -371,6 +371,8 @@ int get_virtual_functions_linux(const char *sysfs_path,
ret = 0;
out:
+ if (dir)
+ closedir(dir);
VIR_FREE(device_link);
return 0;
}
--
1.6.6.516.gb72f
14 years, 11 months
[libvirt] [PATCH] domain_conf.c: avoid a leak and the need for "cleanup:" block
by Jim Meyering
This avoids a leak and the need for a "cleanup:" block,
along with its three goto statements.
While often I prefer to write functions with a single return point,
this one no longer has the need, now that "addr" is freed immediately
after allocation.
Adding the semicolon in the "case..." stmt may look odd.
It's there because the first stmt is the declaration of "port".
If you'd prefer, an alternative is to put the contents of that
case inside a {...} block.
>From dc879b00ccf6cc451b95ca3712e647605579ee0b Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 20 Jan 2010 19:27:43 +0100
Subject: [PATCH] domain_conf.c: avoid a leak and the need for "cleanup:" block
* src/conf/domain_conf.c (virDomainChrDefFormat): Plug a leak on
an error path, and at the same time, eliminate the need for a
"cleanup:" block. Before, the "return -1" after the switch
would leak an "addr" string. Now, by reversing the port,addr-
getting blocks we can free "addr" immediately and skip the goto.
---
src/conf/domain_conf.c | 30 +++++++++++++-----------------
1 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6254dc8..7815805 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1,7 +1,7 @@
/*
* domain_conf.c: domain XML processing
*
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -4831,7 +4831,6 @@ virDomainChrDefFormat(virConnectPtr conn,
const char *targetName = virDomainChrTargetTypeToString(def->targetType);
const char *elementName;
- const char *addr = NULL;
int ret = 0;
switch (def->targetType) {
@@ -4847,8 +4846,7 @@ virDomainChrDefFormat(virConnectPtr conn,
if (!type) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("unexpected char type %d"), def->type);
- ret = -1;
- goto cleanup;
+ return -1;
}
/* Compat with legacy <console tty='/dev/pts/5'/> syntax */
@@ -4931,22 +4929,23 @@ virDomainChrDefFormat(virConnectPtr conn,
switch (def->targetType) {
case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
- addr = virSocketFormatAddr(def->target.addr);
- if (addr == NULL) {
- virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to format guestfwd address"));
- ret = -1;
- goto cleanup;
- }
+ ; /* dummy stmt, for following declaration */
int port = virSocketGetPort(def->target.addr);
if (port < 0) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to format guestfwd port"));
- ret = -1;
- goto cleanup;
+ return -1;
+ }
+ const char *addr = virSocketFormatAddr(def->target.addr);
+ if (addr == NULL) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unable to format guestfwd address"));
+ return -1;
}
- virBufferVSprintf(buf, " <target type='guestfwd' address='%s' port='%d'/>\n",
+ virBufferVSprintf(buf,
+ " <target type='guestfwd' address='%s' port='%d'/>\n",
addr, port);
+ VIR_FREE(addr);
break;
case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL:
@@ -4969,9 +4968,6 @@ virDomainChrDefFormat(virConnectPtr conn,
virBufferVSprintf(buf, " </%s>\n",
elementName);
-cleanup:
- VIR_FREE(addr);
-
return ret;
}
--
1.6.6.516.gb72f
14 years, 11 months
Re: [libvirt] [PATCH] Document cpu-compare command in virsh man page
by Jiri Denemark
On Wed, Jan 20, 2010 at 16:17:32 +0100, Daniel Veillard wrote:
> On Wed, Jan 20, 2010 at 03:16:29PM +0100, Jiri Denemark wrote:
> > Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
> > ---
> > tools/virsh.pod | 9 +++++++++
> > 1 files changed, 9 insertions(+), 0 deletions(-)
> >
> > diff --git a/tools/virsh.pod b/tools/virsh.pod
> > index 84a8564..10f622f 100644
> > --- a/tools/virsh.pod
> > +++ b/tools/virsh.pod
> > @@ -213,6 +213,15 @@ crashed.
> > Prints the available amount of memory on the machine or within a
> > NUMA cell if I<cellno> is provided.
> >
> > +=item B<cpu-compare> I<FILE>
> > +
> > +Compare CPU definition from XML <file> with host CPU. The XML <file> may
> > +contain either host or guest CPU definition. The host CPU definition is the
> > +<cpu> element and its contents as printed by B<capabilities> command. The
> > +guest CPU definition is the <cpu> element and its contents from domain XML
> > +definition. For more information on guest CPU definition see:
> > +L<http://libvirt.org/formatdomain.html#elementsCPU>
> > +
> > =back
> >
> > =head1 DOMAIN COMMANDS
>
> ACK,
Thanks, pushed.
Jirka
14 years, 11 months
[libvirt] [PATCH] Document cpu-compare command in virsh man page
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
tools/virsh.pod | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 84a8564..10f622f 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -213,6 +213,15 @@ crashed.
Prints the available amount of memory on the machine or within a
NUMA cell if I<cellno> is provided.
+=item B<cpu-compare> I<FILE>
+
+Compare CPU definition from XML <file> with host CPU. The XML <file> may
+contain either host or guest CPU definition. The host CPU definition is the
+<cpu> element and its contents as printed by B<capabilities> command. The
+guest CPU definition is the <cpu> element and its contents from domain XML
+definition. For more information on guest CPU definition see:
+L<http://libvirt.org/formatdomain.html#elementsCPU>
+
=back
=head1 DOMAIN COMMANDS
--
1.6.6
14 years, 11 months
[libvirt] [PATCH] Libvirt Snapshot API
by Philip Jameson
A little while ago I submitted a patch to add a snapshot API, but I was informed that it got somewhat lost in the list. I have attached a patch that implements this API at least for the qemu driver, and it also added another function for screenshots, just because it usually is nice to get a view of the screen with the snapshot.
The snapshot functions just take names, as I figure it should be up to libvirt to figure out where the snapshots go. e.g. for qemu, they just get stored with the drive using qemu's built in facilities. If someone were using LVM, then that could be managed by libvirt, just like it does for qemu monitors and such. The 'list snapshots' just returns a list of names for now, as that's all I needed, but I think it would probably be best to add a struct that would be name/time.
I don't know if it's of any use at the moment, but I needed these functions implemented, so I figured I'd at least submit my changes
Philip Jameson
14 years, 11 months
[libvirt] XML for the "boot=on" option
by Shi Jin
Hi, there,
In order to install windows 2008 using the virtio driver, I had to modify the KVM command to include the boot=on option like:
-drive file=<path>/virtioWin08.raw,if=virtio,index=0,boot=on
However, I haven't been able to find a corresponding libvirt XML element that can enable this "boot=on" option. Is there a way to do this?
Thanks a lot.
--
Shi Jin, PhD
14 years, 11 months
[libvirt] [PATCH] Fix QEMU driver custom domain status XML extensions
by Daniel P. Berrange
Invoking the virConnectGetCapabilities() method causes the QEMU
driver to rebuild its internal capabilities object. Unfortunately
it was forgetting to register the custom domain status XML hooks
again.
To avoid this kind of error in the future, the code which builds
capabilities is refactored into one single method, which can be
called from all locations, ensuring reliable rebuilds.
* src/qemu/qemu_driver.c: Fix rebuilding of capabilities XML and
guarentee it is always consistent
---
src/qemu/qemu_driver.c | 110 +++++++++++++++++++++++-------------------------
1 files changed, 53 insertions(+), 57 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2d80774..9a3ddfb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -892,34 +892,6 @@ qemuReconnectDomains(struct qemud_driver *driver)
static int
-qemudSecurityCapsInit(virSecurityDriverPtr secdrv,
- virCapsPtr caps)
-{
- const char *doi, *model;
-
- doi = virSecurityDriverGetDOI(secdrv);
- model = virSecurityDriverGetModel(secdrv);
-
- caps->host.secModel.model = strdup(model);
- if (!caps->host.secModel.model) {
- virReportOOMError(NULL);
- return -1;
- }
-
- caps->host.secModel.doi = strdup(doi);
- if (!caps->host.secModel.doi) {
- virReportOOMError(NULL);
- return -1;
- }
-
- VIR_DEBUG("Initialized caps for security driver \"%s\" with "
- "DOI \"%s\"", model, doi);
-
- return 0;
-}
-
-
-static int
qemudSecurityInit(struct qemud_driver *qemud_drv)
{
int ret;
@@ -940,15 +912,52 @@ qemudSecurityInit(struct qemud_driver *qemud_drv)
qemud_drv->securityDriver = security_drv;
VIR_INFO("Initialized security driver %s", security_drv->name);
-
- /*
- * Add security policy host caps now that the security driver is
- * initialized.
- */
- return qemudSecurityCapsInit(security_drv, qemud_drv->caps);
+ return 0;
}
+static virCapsPtr
+qemuCreateCapabilities(virCapsPtr oldcaps,
+ virSecurityDriverPtr secDriver)
+{
+ virCapsPtr caps;
+
+ /* Basic host arch / guest machine capabilities */
+ if (!(caps = qemudCapsInit(oldcaps))) {
+ virReportOOMError(NULL);
+ return NULL;
+ }
+
+ /* Domain XML parser hooks */
+ caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc;
+ caps->privateDataFreeFunc = qemuDomainObjPrivateFree;
+ caps->privateDataXMLFormat = qemuDomainObjPrivateXMLFormat;
+ caps->privateDataXMLParse = qemuDomainObjPrivateXMLParse;
+
+
+ /* Security driver data */
+ if (secDriver) {
+ const char *doi, *model;
+
+ doi = virSecurityDriverGetDOI(secDriver);
+ model = virSecurityDriverGetModel(secDriver);
+
+ if (!(caps->host.secModel.model = strdup(model)))
+ goto no_memory;
+ if (!(caps->host.secModel.doi = strdup(doi)))
+ goto no_memory;
+
+ VIR_DEBUG("Initialized caps for security driver \"%s\" with "
+ "DOI \"%s\"", model, doi);
+ }
+
+ return caps;
+
+no_memory:
+ virReportOOMError(NULL);
+ virCapabilitiesFree(caps);
+ return NULL;
+}
/**
* qemudStartup:
@@ -1074,13 +1083,12 @@ qemudStartup(int privileged) {
virStrerror(-rc, buf, sizeof(buf)));
}
- if ((qemu_driver->caps = qemudCapsInit(NULL)) == NULL)
- goto out_of_memory;
+ if (qemudSecurityInit(qemu_driver) < 0)
+ goto error;
- qemu_driver->caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc;
- qemu_driver->caps->privateDataFreeFunc = qemuDomainObjPrivateFree;
- qemu_driver->caps->privateDataXMLFormat = qemuDomainObjPrivateXMLFormat;
- qemu_driver->caps->privateDataXMLParse = qemuDomainObjPrivateXMLParse;
+ if ((qemu_driver->caps = qemuCreateCapabilities(NULL,
+ qemu_driver->securityDriver)) == NULL)
+ goto error;
if ((qemu_driver->activePciHostdevs = pciDeviceListNew(NULL)) == NULL)
goto error;
@@ -1104,10 +1112,6 @@ qemudStartup(int privileged) {
}
}
- if (qemudSecurityInit(qemu_driver) < 0) {
- goto error;
- }
-
/* If hugetlbfs is present, then we need to create a sub-directory within
* it, since we can't assume the root mount point has permissions that
* will let our spawned QEMU instances use it.
@@ -3255,15 +3259,12 @@ static char *qemudGetCapabilities(virConnectPtr conn) {
char *xml = NULL;
qemuDriverLock(driver);
- if ((caps = qemudCapsInit(qemu_driver->caps)) == NULL)
- goto no_memory;
- caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc;
- caps->privateDataFreeFunc = qemuDomainObjPrivateFree;
-
- if (qemu_driver->securityDriver &&
- qemudSecurityCapsInit(qemu_driver->securityDriver, caps) < 0)
- goto no_memory;
+ if ((caps = qemuCreateCapabilities(qemu_driver->caps,
+ qemu_driver->securityDriver)) == NULL) {
+ virCapabilitiesFree(caps);
+ goto cleanup;
+ }
virCapabilitiesFree(qemu_driver->caps);
qemu_driver->caps = caps;
@@ -3275,11 +3276,6 @@ cleanup:
qemuDriverUnlock(driver);
return xml;
-
-no_memory:
- virCapabilitiesFree(caps);
- virReportOOMError(conn);
- goto cleanup;
}
--
1.6.5.2
14 years, 11 months