[libvirt] [PATCH] leaseshelper: fix crash
by Pavel Hrdina
Commit baafe668 introduced new leaseshelper with a crash of freeing
env string. Calling 'getenv()' inside 'virGetEnvAllowSUID()' may
return a static string and we definitely should not free it.
The author probably want to free the copy of that string.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
pushed under trivial rule
src/network/leaseshelper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index b6f6c32..69081c3 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -351,7 +351,7 @@ main(int argc, char **argv)
virPidFileReleasePath(pid_file, pid_file_fd);
VIR_FREE(pid_file);
- VIR_FREE(exptime_tmp);
+ VIR_FREE(exptime);
VIR_FREE(custom_lease_file);
virJSONValueFree(lease_new);
virJSONValueFree(leases_array);
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCH v3 0/2] Empty first lines series
by Martin Kletzander
v3 -- use the whole VC_LIST_EXCEPT, create exception for necessities
and clear the rest
v2 -- s/FILENAME:1:/FILENAME ":1:"/
Martin Kletzander (2):
Remove unnecessary empty first lines
maint: prohibit empty first lines
cfg.mk | 10 ++++++++++
docs/generic.css | 1 -
docs/libvirt.css | 2 --
src/locking/lockd.conf | 1 -
src/locking/sanlock.conf | 1 -
tests/nodeinfodata/linux-test3/node/node0/meminfo | 1 -
tests/nodeinfodata/linux-test3/node/node1/meminfo | 1 -
tests/nodeinfodata/linux-test3/node/node2/meminfo | 1 -
tests/nodeinfodata/linux-test3/node/node3/meminfo | 1 -
tests/nodeinfodata/linux-test3/node/node4/meminfo | 1 -
tests/nodeinfodata/linux-test3/node/node5/meminfo | 1 -
tests/nodeinfodata/linux-test3/node/node6/meminfo | 1 -
tests/nodeinfodata/linux-test3/node/node7/meminfo | 1 -
tests/nodeinfodata/linux-test4/node/node0/meminfo | 1 -
tests/nodeinfodata/linux-test4/node/node1/meminfo | 1 -
tests/nodeinfodata/linux-test6/node/node0/meminfo | 1 -
tests/nodeinfodata/linux-test8/cpu/offline | 1 -
tests/nodeinfodata/linux-test8/node/node0/meminfo | 1 -
tests/nodeinfodata/linux-test8/node/node1/meminfo | 1 -
tests/nodeinfodata/linux-test8/node/node2/meminfo | 1 -
tests/nodeinfodata/linux-test8/node/node3/meminfo | 1 -
tests/nodeinfodata/linux-test8/node/node4/meminfo | 1 -
tests/nodeinfodata/linux-test8/node/node5/meminfo | 1 -
tests/nodeinfodata/linux-test8/node/node6/meminfo | 1 -
tests/nodeinfodata/linux-test8/node/node7/meminfo | 1 -
25 files changed, 10 insertions(+), 25 deletions(-)
--
2.0.0
10 years, 5 months
[libvirt] [PATCH v4] qemu: Properly label FDs when restoring domain with static label
by Shivaprasad G Bhat
When saving domain with relabel=no, the file that gets created must have the
context set anyway. That way restore can be successful without the need of
relabeling the file.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5d40239..cf5c27c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2966,6 +2966,9 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
if (fd < 0)
goto cleanup;
+ if (virSecurityManagerSetImageFDLabel(driver->securityManager, vm->def, fd) < 0)
+ goto cleanup;
+
if (!(wrapperFd = virFileWrapperFdNew(&fd, path, wrapperFlags)))
goto cleanup;
10 years, 5 months
[libvirt] [PATCH v8 0/4] Handling of undefine and re define snapshots with VirtualBox 4.2 or higher
by Yohan BELLEGUIC
Hello,
This is a new series of patches in order to support undefining and redefining
snapshots with VirtualBox 4.2 or higher.
These patches are based on Manuel Vives' patches, taking into account Daniel
P. Berrange's remarks.
The VirtualBox API provides only high level operations to manipulate snapshots,
so it not possible to support flags like VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE and
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY with only API calls.
Following an IRC talk with Eric Blake, the decision was made to emulate these
behaviours by manipulating directly the .vbox XML files.
The first patch adds extra details in the snapshot XML returned by libvirt. We
will need those details in order to redefine the snapshots.
The second patch adds a new API to manipulate the VirtualBox XML file. It
provides several structs describing the VirtualBox XML file nodes and
functions which can manipulate these structs.
The third patch adds support of the VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE
and VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT flags in virDomainSnapshotCreateXML.
The idea is to unregister the machine, add the snapshot in the Virtualbox XML
file and re-register the machine.
However, VirtualBox forbids a machine to have snapshots but no current
snapshot. So, if the real current snapshot has not been redefined yet, we
create fake disks, allowing us to have an intermediate state in order to not
corrupt the snapshot's read-write disks. These fake disks will be deleted during the
next redefine.
The fourth and last patch adds support of the
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY flag in virDomainSnapshotDelete.
As in the third patch, we also create fake disks to not corrupt the snapshot's read-write disks.
The patches were only tested with VirtualBox 4.3.10 and VirtualBox 4.2.24.
Regards
Yohan BELLEGUIC
v8:
* Fix patches according to Daniel P. Berrange review (May 01, 2014)
* Rename all the methods in vbox_snapshot.{c,h}
* Add a test case for serialize and deserialize a virVBoxSnapshotConfMachine
* Fix memory leaks
v7:
* Add vbox_snapshot_conf.{h,c} files to (de)serialize VirtualBox XML files
* Update the code to use the API exposed by vbox_snapshot_conf.h
* Handle the fact that VirtualBox forbids a machine to have snapshots but no
current snapshot
v6:
* Rebased because of a massive change in vbox_tmpl.c due to changes in
the handling of different versions of VirtualBox
v5:
* The patches are modified according to a first review by Laine Stump:
* renamed virSearchUuid to virSearchRegex and moved it from
viruuid.{c,h} to virstring.{c,h}.
* Various fixes.
v4:
* The code is compliant with Virtualbox 4.3 API
* Some minor modifications in order to satisfy "make syntax-check"
v3:
* Use of STREQ_NULLABLE instead of STREQ in one case
* Fix the method for finding uuids according to Ján Tomko review
v2:
* Fix a licence problem with the method for string replacement
Manuel VIVES (1):
vbox_tmpl.c: Better XML description for snapshots
Yohan BELLEGUIC (3):
Add vbox_snapshot_conf struct
vbox_tmpl.c: Patch for redefining snapshots
vbox_tmpl.c: Add function for undefining snapshot
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/vbox/vbox_snapshot_conf.c | 1490 +++++++++++++++
src/vbox/vbox_snapshot_conf.h | 105 ++
src/vbox/vbox_tmpl.c | 1982 +++++++++++++++++++-
tests/Makefile.am | 15 +
tests/vboxsnapshotxmldata/2disks-1snap.vbox | 322 ++++
tests/vboxsnapshotxmldata/2disks-2snap.vbox | 478 +++++
.../vboxsnapshotxmldata/2disks-3snap-brother.vbox | 786 ++++++++
tests/vboxsnapshotxmldata/2disks-3snap.vbox | 636 +++++++
tests/vboxsnapshotxmldata/2disks-nosnap.vbox | 168 ++
tests/vboxsnapshotxmltest.c | 161 ++
12 files changed, 6100 insertions(+), 45 deletions(-)
create mode 100644 src/vbox/vbox_snapshot_conf.c
create mode 100644 src/vbox/vbox_snapshot_conf.h
create mode 100644 tests/vboxsnapshotxmldata/2disks-1snap.vbox
create mode 100644 tests/vboxsnapshotxmldata/2disks-2snap.vbox
create mode 100644 tests/vboxsnapshotxmldata/2disks-3snap-brother.vbox
create mode 100644 tests/vboxsnapshotxmldata/2disks-3snap.vbox
create mode 100644 tests/vboxsnapshotxmldata/2disks-nosnap.vbox
create mode 100644 tests/vboxsnapshotxmltest.c
--
1.7.10.4
10 years, 5 months
[libvirt] [PATCH] virnetdev: Use ifname in virNetDevGetLinkInfo
by Michal Privoznik
If we're compiling on non-Linux platform, the virNetDevGetLinkInfo()
is a dummy function which barely logs debug message that getting link
info is not supported. However, while the debug message was prepared
for printing the interface name too, I actually forgot to pass the
variable which resulted in build error on platforms like mingw or
FreeBSD.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Notes:
Pushed under build breaker rule.
src/util/virnetdev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index cbf086e..6f3a202 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1921,7 +1921,8 @@ virNetDevGetLinkInfo(const char *ifname,
virInterfaceLinkPtr lnk)
{
/* Port me */
- VIR_DEBUG("Getting link info on %s is not implemented on this platform");
+ VIR_DEBUG("Getting link info on %s is not implemented on this platform",
+ ifname);
lnk->speed = lnk->state = 0;
return 0;
}
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCH] vmware: make version parsing more robust
by Jean-Baptiste Rouault
Since commit d69415d4, vmware version is parsed from both stdout and
stderr. This patch makes version parsing work even if there is garbage
(libvirt debug messages for example) in the command output.
Add test data for this case.
---
src/vmware/vmware_conf.c | 10 ++++++++--
tests/vmwareverdata/workstation-7.0.0-with-garbage.txt | 3 +++
tests/vmwarevertest.c | 1 +
3 files changed, 12 insertions(+), 2 deletions(-)
create mode 100644 tests/vmwareverdata/workstation-7.0.0-with-garbage.txt
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index 5ff6396..1f6f3bd 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -1,7 +1,7 @@
/*---------------------------------------------------------------------------*/
/*
* Copyright (C) 2011-2014 Red Hat, Inc.
- * Copyright 2010, diateam (www.diateam.net)
+ * Copyright (C) 2010-2014, diateam (www.diateam.net)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -241,7 +241,13 @@ vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
return -1;
}
- if ((tmp = STRSKIP(verbuf, pattern)) == NULL) {
+ if ((tmp = strstr(verbuf, pattern)) == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot find version pattern \"%s\""), pattern);
+ return -1;
+ }
+
+ if ((tmp = STRSKIP(tmp, pattern)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to parse %sversion"), pattern);
return -1;
diff --git a/tests/vmwareverdata/workstation-7.0.0-with-garbage.txt b/tests/vmwareverdata/workstation-7.0.0-with-garbage.txt
new file mode 100644
index 0000000..b3c8085
--- /dev/null
+++ b/tests/vmwareverdata/workstation-7.0.0-with-garbage.txt
@@ -0,0 +1,3 @@
+garbage line
+VMware Workstation 7.0.0 build-203739 Release
+garbage line
diff --git a/tests/vmwarevertest.c b/tests/vmwarevertest.c
index 16e48de..24de9e1 100644
--- a/tests/vmwarevertest.c
+++ b/tests/vmwarevertest.c
@@ -88,6 +88,7 @@ mymain(void)
} while (0)
DO_TEST("ws", "workstation-7.0.0", 7000000);
+ DO_TEST("ws", "workstation-7.0.0-with-garbage", 7000000);
DO_TEST("fusion", "fusion-5.0.3", 5000003);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
--
1.8.5.3
10 years, 5 months
[libvirt] [PATCH] nodeinfo: avoid uninitialized variable on error
by Eric Blake
Commit 8ba0a58 introduced a compiler warning that I hit during
a run of ./autobuild.sh:
../../src/nodeinfo.c: In function 'nodeCapsInitNUMA':
../../src/nodeinfo.c:1853:43: error: 'nsiblings' may be used uninitialized in this function [-Werror=maybe-uninitialized]
if (virCapabilitiesAddHostNUMACell(caps, n, memory,
^
Sure enough, nsiblings starts uninitialized, and is set by a call
to virNodeCapsGetSiblingInfo, but that function fails to assign
through the pointer if virNumaGetDistances fails.
* src/nodeinfo.c (nodeCapsInitNUMA): Initialize nsiblings.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
src/nodeinfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 5eef42e..5332ede 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -1803,7 +1803,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
virCapsHostNUMACellCPUPtr cpus = NULL;
virBitmapPtr cpumap = NULL;
virCapsHostNUMACellSiblingInfoPtr siblings = NULL;
- int nsiblings;
+ int nsiblings = 0;
int ret = -1;
int ncpus = 0;
int cpu;
--
1.9.3
10 years, 5 months
[libvirt] [PATCH] libxl: support interface type=network
by Jim Fehlig
Add support for <interface type='network'> in the libxl driver.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_conf.c | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index cec37d6..6efcea6 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -908,7 +908,44 @@ libxlMakeNic(virDomainDefPtr def,
if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
return -1;
break;
- default:
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ {
+ bool error = true;
+ char *brname = NULL;
+ virNetworkPtr network = NULL;
+ virConnectPtr conn;
+
+ if (!(conn = virConnectOpen("xen:///system")))
+ return -1;
+
+ if (!(network =
+ virNetworkLookupByName(conn, l_nic->data.network.name)))
+ goto cleanup_net;
+
+ if (!(brname = virNetworkGetBridgeName(network)))
+ goto cleanup_net;
+
+ if (VIR_STRDUP(x_nic->bridge, brname) < 0)
+ goto cleanup_net;
+
+ error = false;
+
+ cleanup_net:
+ VIR_FREE(brname);
+ virNetworkFree(network);
+ virObjectUnref(conn);
+ if (error)
+ return -1;
+ break;
+ }
+ case VIR_DOMAIN_NET_TYPE_USER:
+ case VIR_DOMAIN_NET_TYPE_SERVER:
+ case VIR_DOMAIN_NET_TYPE_CLIENT:
+ case VIR_DOMAIN_NET_TYPE_MCAST:
+ case VIR_DOMAIN_NET_TYPE_INTERNAL:
+ case VIR_DOMAIN_NET_TYPE_DIRECT:
+ case VIR_DOMAIN_NET_TYPE_HOSTDEV:
+ case VIR_DOMAIN_NET_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight does not support network device type %s"),
virDomainNetTypeToString(l_nic->type));
@@ -919,7 +956,7 @@ libxlMakeNic(virDomainDefPtr def,
}
static int
-libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
{
virDomainNetDefPtr *l_nics = def->nets;
size_t nnics = def->nnets;
--
1.8.0.1
10 years, 5 months
[libvirt] [PATCH] storage: fix memory leak with encrypted images
by Eric Blake
Jim Fehlig reported a regression found by libvirt-TCK tests:
> ~ # perl /usr/share/libvirt-tck/tests/qemu/100-disk-encryption.t
...
> ok 4 - defined persistent domain config
> # Starting inactive domain config
> libvirt error code: 1, message: internal error: unable to execute QEMU command
> 'cont': 'drive-ide0-0-1'
> (/var/cache/libvirt-tck/300-disk-encryption/demo.qcow2) is encrypted
Commit 2279d560 converted a boolean into a pointer with the intent of
transferring that pointer out of a temporary object into the caller's
data structure. The temporary structure meant that meta->encryption
was always NULL on entry, so we could get away with blindly allocating
the pointer when the header said so. But later commits then tweaked
things to do backing chain detection in-place, rather than via a
temporary object; this has the net result that meta->encryption can be
non-NULL on entry. Not only did this turn the latent behavior into a
memory leak, it is also a behavior regression: blindly allocating a
new pointer wipes out what secrets we already knew about the chain,
making it impossible to restart the domain.
Of course, no one in their right mind should be relying on qcow2
encryption - it is fundamentally flawed. And sadly, the TCK tests
don't get run often enough, and this shows that our virstoragetest
does not exercise encrypted images at all. Otherwise, we could
have avoided a release containing this regression.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal):
Don't nuke an already-existing encryption.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/util/virstoragefile.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 43b7a5a..0792dd8 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -805,7 +805,8 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
crypt_format = virReadBufInt32BE(buf +
fileTypeInfo[meta->format].qcowCryptOffset);
- if (crypt_format && VIR_ALLOC(meta->encryption) < 0)
+ if (crypt_format && !meta->encryption &&
+ VIR_ALLOC(meta->encryption) < 0)
goto cleanup;
}
--
1.9.3
10 years, 5 months
[libvirt] [PATCH] vbox: fix compilation error
by Roman Bogorodskiy
clang complains about possibly uninitialized variable:
vbox/vbox_snapshot_conf.c:1355:9: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (!(xPathContext = xmlXPathNewContext(xml))) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So init 'ret' with NULL.
---
src/vbox/vbox_snapshot_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
index 4909665..9c78410 100644
--- a/src/vbox/vbox_snapshot_conf.c
+++ b/src/vbox/vbox_snapshot_conf.c
@@ -1336,7 +1336,7 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char *filePath,
{
int result = -1;
size_t i = 0;
- char **ret;
+ char **ret = NULL;
xmlDocPtr xml = NULL;
xmlXPathContextPtr xPathContext = NULL;
xmlNodePtr *nodes = NULL;
--
1.9.0
10 years, 5 months