[libvirt] [PATCH 00/11] Resolution to various Coverity warnings
by John Ferlan
I upgraded to a new version of Coverity last night (6.5.1) since I was
informed it resolved the BAD_SIZEOF errors from the TRACE macros. A majority
were resolved, except for 3 which just required a couple of changes to avoid.
Since I was down to only a few warnings I tried ratcheting up the
analysis "aggressiveness-level" from the default of low to medium
and high. There many false positives out of those, but I did manage
to find a few more leaks and a missing error check in openvz_driver.c.
After this series only a couple of warnings exist in the tests area;
however, I've seen IRC chatter on vircommand.c and commandtest.c, so
I'll patiently wait on that. There are some warnings in a couple of
gnulib modules as well as /usr/include/bits/stdio2.h.
John Ferlan (11):
tlscontext: Make sure to get proper pointer to name
keepalive: Resolve Coverity complaint
storage: Resolve resource leaks with cmd processing
network: Remove conditional settings to resolve resource leak
parallels: Need to free memory on error path
openvz: Need to error check openvzDomainSetVcpusFlagsInternal()
uml: If need to requery, then VIR_FREE(res)
rpc: Need to virCommandFree on error path
lxc: Need to call usbFreeDevice()
qemu_cgroup: Need to call usbFreeDevice()
qemu_hotplug: Need to call usbFreeDevice()
src/lxc/lxc_cgroup.c | 8 +++++---
src/network/bridge_driver.c | 9 +++------
src/openvz/openvz_driver.c | 9 +++++++--
src/parallels/parallels_utils.c | 4 +++-
src/qemu/qemu_cgroup.c | 6 ++++--
src/qemu/qemu_hotplug.c | 7 +++++--
src/rpc/virkeepalive.c | 14 +++++++-------
src/rpc/virnetsocket.c | 1 +
src/rpc/virnettlscontext.c | 8 +++++---
src/storage/storage_backend_disk.c | 28 +++++++++++++++-------------
src/uml/uml_driver.c | 3 ++-
11 files changed, 57 insertions(+), 40 deletions(-)
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] sanitytest.py: Do not rely on system libvirt
by Jiri Denemark
When running sanitytest.py we should not rely on libvirt library
installed on the system. And since we generate a nice wrapper called
"run" that sets both PYTHON_PATH and LD_LIBRARY_PATH, we should just use
it rather than trying to duplicate it in the Makefile.
---
python/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/Makefile.am b/python/Makefile.am
index ef3c3eb..55c5e41 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -122,7 +122,7 @@ $(libvirtmod_lxc_la_OBJECTS): $(LXC_GENERATED)
EXTRA_DIST += sanitytest.py
check-local:
- $(AM_V_GEN)PYTHONPATH=$(abs_topbuilddir):$(abs_topbuilddir)/.libs $(PYTHON) $(srcdir)/sanitytest.py
+ $(AM_V_GEN)../run $(PYTHON) $(srcdir)/sanitytest.py
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(pyexecdir)
--
1.8.1.2
11 years, 8 months
[libvirt] [PATCH] Fix typo in configure.ac causing $LIBS to gain a copy of $CFLAGS
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The virt-dbus.m4 check for DBus was preserving $LIBS before
modifying it. Except it wasn't. It was preserving another
copy of $CFLAGS. The result was that after the check completed,
$LIBS got polluted with $CFLAGS
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
m4/virt-dbus.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/m4/virt-dbus.m4 b/m4/virt-dbus.m4
index 16cb864..4ef0c82 100644
--- a/m4/virt-dbus.m4
+++ b/m4/virt-dbus.m4
@@ -22,7 +22,7 @@ AC_DEFUN([LIBVIRT_CHECK_DBUS],[
if test "$with_dbus" = "yes" ; then
old_CFLAGS="$CFLAGS"
- old_LIBS="$CFLAGS"
+ old_LIBS="$LIBS"
CFLAGS="$CFLAGS $DBUS_CFLAGS"
LIBS="$LIBS $DBUS_LIBS"
AC_CHECK_FUNCS([dbus_watch_get_unix_fd])
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] tests: reserve more fds for commandtest
by Eric Blake
Commit 39c77fe triggered random failures, depending on the platform
and what other fds leak into the testsuite (for me, it passed on
RHEL 6 but failed on Fedora 18). The reason was that we were
expecting an fd that fell outside of our reserved range. By reserving
a larger range, the test once again passes on all platforms.
* tests/commandtest.c (mymain): Reserve enough fds.
---
I'll wait a bit for a review, but if I don't get one, I'll push
this under the build-breaker rule.
tests/commanddata/test3.log | 2 +-
tests/commandtest.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/tests/commanddata/test3.log b/tests/commanddata/test3.log
index bd06371..c6da253 100644
--- a/tests/commanddata/test3.log
+++ b/tests/commanddata/test3.log
@@ -9,6 +9,6 @@ FD:0
FD:1
FD:2
FD:5
-FD:8
+FD:7
DAEMON:no
CWD:/tmp
diff --git a/tests/commandtest.c b/tests/commandtest.c
index f4e335f..93c6333 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -1,7 +1,7 @@
/*
* commandtest.c: Test the libCommand API
*
- * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2010-2013 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
@@ -960,7 +960,10 @@ mymain(void)
dup2(fd, 3) < 0 ||
dup2(fd, 4) < 0 ||
dup2(fd, 5) < 0 ||
- (fd > 5 && VIR_CLOSE(fd) < 0))
+ dup2(fd, 6) < 0 ||
+ dup2(fd, 7) < 0 ||
+ dup2(fd, 8) < 0 ||
+ (fd > 8 && VIR_CLOSE(fd) < 0))
return EXIT_FAILURE;
/* Prime the debug/verbose settings from the env vars,
@@ -978,6 +981,12 @@ mymain(void)
VIR_FORCE_CLOSE(fd);
fd = 5;
VIR_FORCE_CLOSE(fd);
+ fd = 6;
+ VIR_FORCE_CLOSE(fd);
+ fd = 7;
+ VIR_FORCE_CLOSE(fd);
+ fd = 8;
+ VIR_FORCE_CLOSE(fd);
virEventRegisterDefaultImpl();
if (VIR_ALLOC(test) < 0) {
--
1.8.1
11 years, 8 months
[libvirt] [PATCH] Fix missing error constants in libvirt python module
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The previous change to the generator, changed too much - only
the functions are in 'virerror.c', the constants remained in
'virerror.h' which could not be renamed for API compat reasons.
Add a test case to sanity check the generated python bindings
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
python/Makefile.am | 5 +++++
python/generator.py | 4 +++-
python/sanitytest.py | 31 +++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 python/sanitytest.py
diff --git a/python/Makefile.am b/python/Makefile.am
index dd69600..ef3c3eb 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -119,6 +119,11 @@ $(libvirtmod_la_OBJECTS): $(GENERATED)
$(libvirtmod_qemu_la_OBJECTS): $(QEMU_GENERATED)
$(libvirtmod_lxc_la_OBJECTS): $(LXC_GENERATED)
+EXTRA_DIST += sanitytest.py
+
+check-local:
+ $(AM_V_GEN)PYTHONPATH=$(abs_topbuilddir):$(abs_topbuilddir)/.libs $(PYTHON) $(srcdir)/sanitytest.py
+
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(pyexecdir)
$(INSTALL) -m 0644 libvirt.py $(DESTDIR)$(pyexecdir)
diff --git a/python/generator.py b/python/generator.py
index 71ca883..ceade6b 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -122,8 +122,9 @@ class docParser(xml.sax.handler.ContentHandler):
if attrs.has_key('field'):
self.function_return_field = attrs['field']
elif tag == 'enum':
+ # enums come from header files, hence virterror.h
if (attrs['file'] == "libvirt" or
- attrs['file'] == "virerror"):
+ attrs['file'] == "virterror"):
enum(attrs['type'],attrs['name'],attrs['value'])
elif attrs['file'] == "libvirt-lxc":
lxc_enum(attrs['type'],attrs['name'],attrs['value'])
@@ -134,6 +135,7 @@ class docParser(xml.sax.handler.ContentHandler):
if debug:
print "end %s" % tag
if tag == 'function':
+ # fuctions come from source files, hence 'virerror.c'
if self.function != None:
if (self.function_module == "libvirt" or
self.function_module == "virevent" or
diff --git a/python/sanitytest.py b/python/sanitytest.py
new file mode 100644
index 0000000..047450b
--- /dev/null
+++ b/python/sanitytest.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import libvirt
+
+globals = dir(libvirt)
+
+# Sanity test that the generator hasn't gone wrong
+
+# Look for core classes
+assert("virConnect" in globals)
+assert("virDomain" in globals)
+assert("virDomainSnapshot" in globals)
+assert("virInterface" in globals)
+assert("virNWFilter" in globals)
+assert("virNodeDevice" in globals)
+assert("virNetwork" in globals)
+assert("virSecret" in globals)
+assert("virStoragePool" in globals)
+assert("virStorageVol" in globals)
+assert("virStream" in globals)
+assert("VIR_CONNECT_RO" in globals)
+
+# Error related bits
+assert("libvirtError" in globals)
+assert("VIR_ERR_AUTH_FAILED" in globals)
+assert("virGetLastError" in globals)
+
+# Some misc methods
+assert("virInitialize" in globals)
+assert("virEventAddHandle" in globals)
+assert("virEventRegisterDefaultImpl" in globals)
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] virDomainSaveXML: Reject domains which name contain '/'
by Christophe Fergeau
Similarly to 790f912b4 which rejects snapshots names containing,
this commit changes virDomainSaveXML to reject domains with a '/'
in their name. The domain name is used as a filename, so this
leads to unexpected results when used in combination with '..'
---
If someone is using domains with '/' in their name, this will cause a
regression for them as libvirt will no longer be able to re-write the
domain XML and will just fail. However, if someone is (ab)using this,
the domain must end up in an already existing directory as libvirt will
not create it so this is hopefully unconvenient enough that noone is
doing that.
If we only want to error out on new domain creation, this may be doable
by introducing a virDomainSaveXMLFlags, but will be more invasive.
Christophe
src/conf/domain_conf.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 85a798d..86641d6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14728,6 +14728,14 @@ int virDomainSaveXML(const char *configDir,
char *configFile = NULL;
int ret = -1;
+ if (strchr(def->name, '/')) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("invalid domain name '%s': name can't contain '/'"),
+ def->name);
+ goto cleanup;
+
+ }
+
if ((configFile = virDomainConfigFile(configDir, def->name)) == NULL)
goto cleanup;
--
1.8.1
11 years, 8 months
[libvirt] [PATCH] qemu: don't log failure during QMP add-fd probe
by Eric Blake
Otherwise, we get a lot of scary (but harmless) noise in the logs:
2013-02-05 15:35:48.555+0000: 8637: error : qemuMonitorJSONCheckError:353 : internal error unable to execute QEMU command 'add-fd': Parameter 'fdset-id' expects an existing fdset-id
one for every qemu 1.2 binary that we probe.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONAddFd): During
probe, avoid logging failures.
---
src/qemu/qemu_monitor_json.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 686cee9..a86d90c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2660,8 +2660,16 @@ qemuMonitorJSONAddFd(qemuMonitorPtr mon, int fdset, int fd, const char *name)
ret = qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply);
- if (ret == 0)
+ if (ret == 0) {
+ /* qemu 1.2 lacks the functionality we need; but we have to
+ * probe to find that out. Don't log errors in that case. */
+ if (STREQ_NULLABLE(name, "/dev/null") &&
+ qemuMonitorJSONHasError(reply, "GenericError")) {
+ ret = -2;
+ goto cleanup;
+ }
ret = qemuMonitorJSONCheckError(cmd, reply);
+ }
if (ret == 0) {
virJSONValuePtr data = virJSONValueObjectGet(reply, "return");
--
1.8.1
11 years, 8 months
[libvirt] [PATCH 0/4] Implement basic support for virtio-rng
by Peter Krempa
This patchset implements very basic functionality that will allow to use the
virtio-rng device. I will follow up later with more advanced sections of this
support as I have to figure out how hotplug of the qom backend device could
work in qemu.
I'm posting this so we can settle on the naming scheme and other stuff.
Peter Krempa (4):
doc: schema: Add basic documentation for the virtual RNG device
support
conf: Use correct type for device type enum in virDomainDeviceDefFree
conf: Add basic support for RNG configuration
qemu: Implement support for the RNG device and the random backend
docs/formatdomain.html.in | 54 +++++++++++++++
docs/schemas/domaincommon.rng | 31 +++++++++
src/conf/domain_conf.c | 157 +++++++++++++++++++++++++++++++++++++++++-
src/conf/domain_conf.h | 36 ++++++++++
src/libvirt_private.syms | 2 +
src/qemu/qemu_capabilities.c | 5 +-
src/qemu/qemu_capabilities.h | 3 +
src/qemu/qemu_command.c | 108 +++++++++++++++++++++++++++++
8 files changed, 393 insertions(+), 3 deletions(-)
--
1.8.1
11 years, 8 months
[libvirt] persistent virtual networks
by Gene Czarcinski
I seem to remember that, if you use net-define, the network will be
persistent and, if you use net-create, the network will not be persistent.
I am now running libvirt-1.0.2 on Fedora 18.
When I use net-define a network from a template and then do a net-list
--all, the network is NOT marked as persistent. If I restart
libvirtd.service, then the defined networks are persistent.
I noticed that the libvirt-1.0.2 announcement included:
- network: bridge: Fix regression when defining persistent networks
(Peter Krempa)
Do I have a bug to report?
Gene
11 years, 8 months
[libvirt] [PATCH] build: Add libcurl dependency to libvirt_driver.la
by Jiri Denemark
libvirt.c calls curl_global_init() if WITH_CURL is defined and thus it
should be linked with libcurl. This fixes link failure in case neither
xenapi nor esx driver is enabled (they are the only users of libcurl).
---
src/Makefile.am | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 070a089..f6162df 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -792,9 +792,11 @@ noinst_LTLIBRARIES += libvirt_driver.la
libvirt_la_BUILT_LIBADD += libvirt_driver.la
libvirt_driver_la_SOURCES = $(DRIVER_SOURCES)
-libvirt_driver_la_CFLAGS = $(NUMACTL_CFLAGS) $(GNUTLS_CFLAGS) \
+libvirt_driver_la_CFLAGS = \
+ $(NUMACTL_CFLAGS) $(GNUTLS_CFLAGS) $(CURL_CFLAGS) \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
-libvirt_driver_la_LIBADD = $(NUMACTL_LIBS) $(GNUTLS_LIBS) $(DLOPEN_LIBS)
+libvirt_driver_la_LIBADD = \
+ $(NUMACTL_LIBS) $(GNUTLS_LIBS) $(CURL_LIBS) $(DLOPEN_LIBS)
USED_SYM_FILES = $(srcdir)/libvirt_private.syms
--
1.8.1.2
11 years, 8 months