[libvirt] [PATCH] Report correct error in virNetDevTapCreate
by Ján Tomko
ioctl returns -1, not the errno value
---
src/util/virnetdevtap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 0b444fa..d64e64f 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -294,7 +294,7 @@ int virNetDevTapCreate(char **ifname,
}
if ((flags & VIR_NETDEV_TAP_CREATE_PERSIST) &&
- (errno = ioctl(fd, TUNSETPERSIST, 1))) {
+ ioctl(fd, TUNSETPERSIST, 1) < 0) {
virReportSystemError(errno,
_("Unable to set tap device %s to persistent"),
NULLSTR(*ifname));
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCH] tests: Fix syntax-check after cdd11151791bc9e61538988438980f41c0185681
by Peter Krempa
makefile_conditionals
tests/Makefile.am:293:endif
maint.mk: match "if FOO" with "endif FOO" in Makefiles
make: *** [sc_makefile_conditionals] Error 1
---
Notes:
Pushing under the build breaker rule and putting on the brown paper box of shame :/
tests/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2f762a6..025b847 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -290,7 +290,7 @@ endif WITH_STORAGE
if WITH_STORAGE_FS
test_programs += virstoragetest
-endif
+endif WITH_STORAGE_FS
if WITH_LINUX
test_programs += virscsitest
--
1.9.3
10 years, 5 months
[libvirt] [PATCH] Fix invalid write in virNumaGetDistances
by Ján Tomko
==== Invalid write of size 4
==== at 0x52E678C: virNumaGetDistances (virnuma.c:479)
==== by 0x5396890: nodeCapsInitNUMA (nodeinfo.c:1796)
==== by 0x203C2B: virQEMUCapsInit (qemu_capabilities.c:960)
==== Address 0xe10a1e0 is 0 bytes after a block of size 0 alloc'd
==== at 0x4C2A6D0: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==== by 0x52A10D6: virAllocN (viralloc.c:191)
==== by 0x52E674D: virNumaGetDistances (virnuma.c:470)
==== by 0x5396890: nodeCapsInitNUMA (nodeinfo.c:1796)
==== by 0x203C2B: virQEMUCapsInit (qemu_capabilities.c:960)
---
src/util/virnuma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index c8e7f40..c494e17 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -467,7 +467,7 @@ virNumaGetDistances(int node,
if ((max_node = virNumaGetMaxNode()) < 0)
goto cleanup;
- if (VIR_ALLOC_N(*distances, max_node) < 0)
+ if (VIR_ALLOC_N(*distances, max_node + 1) < 0)
goto cleanup;
*ndistances = max_node + 1;
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCH] Do not call closedir with NULL argument
by Ján Tomko
Only three other callers possibly call closedir on a NULL argument.
Even though these probably won't be used on FreeBSD where this crashes,
let's be nice and only call closedir on an actual directory stream.
---
src/parallels/parallels_storage.c | 2 +-
src/util/virscsi.c | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index 4dbaed1..53bcfcb 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -340,7 +340,7 @@ static int parallelsFindVmVolumes(virStoragePoolObjPtr pool,
virReportSystemError(errno,
_("cannot open path '%s'"),
pdom->home);
- goto cleanup;
+ return ret;
}
while ((direrr = virDirRead(dir, &ent, pdom->home)) > 0) {
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 9a0205f..9f5cf0d 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -143,7 +143,8 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
}
cleanup:
- closedir(dir);
+ if (dir)
+ closedir(dir);
VIR_FREE(path);
return sg;
}
@@ -188,7 +189,8 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
}
cleanup:
- closedir(dir);
+ if (dir)
+ closedir(dir);
VIR_FREE(path);
return name;
}
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCHv2] test: Disable storage test when FS backend isn't compiled in
by Peter Krempa
'virstoragetest' accesses backing chains of files on local storage with
the help of the storage driver. Disable the test on builds without the
storage driver as the test is crashing otherwise.
Reported by: Roman Bogorodskiy
---
Notes:
Version 2:
- Don't run the test from the makefile instead of adding code that might not compile cleanly
tests/Makefile.am | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c999061..2f762a6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -285,10 +285,13 @@ test_programs += nwfilterxml2firewalltest
endif WITH_NWFILTER
if WITH_STORAGE
-test_programs += storagevolxml2argvtest \
- virstoragetest
+test_programs += storagevolxml2argvtest
endif WITH_STORAGE
+if WITH_STORAGE_FS
+test_programs += virstoragetest
+endif
+
if WITH_LINUX
test_programs += virscsitest
endif WITH_LINUX
--
1.9.3
10 years, 5 months
[libvirt] [PATCH] test: Skip storage test when filesystem storage backend isn't compiled in
by Peter Krempa
'virstoragetest' accesses backing chains of files on local storage with
the help of the storage driver. Disable the test on builds without the
storage driver as the test is crashing otherwise.
---
tests/virstoragetest.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index e15578c..043c5e6 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -536,6 +536,12 @@ mymain(void)
virStorageSourcePtr chain2; /* short for chain->backingStore */
virStorageSourcePtr chain3; /* short for chain2->backingStore */
+#if !WITH_STORAGE_FS
+ /* this test doesn't make sense without storage driver access
+ * to local files */
+ return EXIT_AM_SKIP;
+#endif
+
/* Prep some files with qemu-img; if that is not found on PATH, or
* if it lacks support for qcow2 and qed, skip this test. */
if ((ret = testPrepImages()) != 0)
--
1.9.3
10 years, 5 months
[libvirt] [PATCH 00/10] Work In Progress: Refactor dealing with disk source data
by Peter Krempa
This is a work in progress snapshot of my current state to get rid
of a few very ugly places where we deal with storage source information
while labelling images.
The goal of this series will be to get rid of the ugly places and additionally
fix problem when block-copying a networked disk which may break badly.
Peter Krempa (10):
storage: encryption: Add deep copy function for storage encryption
util: seclabel: Add deep copy function for device labels
util: storagefile: Introduce helper to free storage source perms
util: storagesource: Add helper to copy and free storage source
seclabels
util: storagefile: Add deep copy for struct virStorageSource
qemu: cgroup: Add functions to set cgroup image stuff on individual
imgs
util: Don't require full disk definition when getting imagelabels
security: Sanitize type of @migrated in
virSecurityManagerRestoreAllLabel
security: Rename virSecurityManagerSetImageLabel to *Disk*
qemu: snapshot: Improve approach to deal with snapshot metadata
src/conf/domain_conf.c | 14 ---
src/conf/domain_conf.h | 3 -
src/libvirt_private.syms | 6 +-
src/lxc/lxc_controller.c | 2 +-
src/lxc/lxc_driver.c | 4 +-
src/qemu/qemu_cgroup.c | 92 ++++++++++-------
src/qemu/qemu_cgroup.h | 5 +
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_driver.c | 121 ++++++----------------
src/qemu/qemu_hotplug.c | 16 +--
src/qemu/qemu_process.c | 2 +-
src/security/security_apparmor.c | 8 +-
src/security/security_dac.c | 24 ++---
src/security/security_driver.h | 10 +-
src/security/security_manager.c | 12 +--
src/security/security_manager.h | 8 +-
src/security/security_nop.c | 10 +-
src/security/security_selinux.c | 20 ++--
src/security/security_stack.c | 12 +--
src/util/virseclabel.c | 23 +++++
src/util/virseclabel.h | 6 +-
src/util/virstorageencryption.c | 40 ++++++++
src/util/virstorageencryption.h | 3 +
src/util/virstoragefile.c | 217 +++++++++++++++++++++++++++++++++++++--
src/util/virstoragefile.h | 10 ++
25 files changed, 449 insertions(+), 221 deletions(-)
--
1.9.3
10 years, 5 months
[libvirt] [PATCH] Properly check the return value of CCWAddressAsString
by Ján Tomko
It returns NULL on failure. Checking if the negation of it
is less than zero makes no sense. (Found by coverity after moving
the code)
In another case, the return value wasn't checked at all.
---
src/conf/domain_addr.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index a756f12..fb4a76f 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -614,7 +614,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
goto cleanup;
}
} else if (autoassign && !dev->addr.ccw.assigned) {
- if (!(addr = virDomainCCWAddressAsString(&addrs->next)) < 0)
+ if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
goto cleanup;
while (virHashLookup(addrs->defined, addr)) {
@@ -624,7 +624,8 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
goto cleanup;
}
VIR_FREE(addr);
- addr = virDomainCCWAddressAsString(&addrs->next);
+ if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
+ goto cleanup;
}
dev->addr.ccw = addrs->next;
dev->addr.ccw.assigned = true;
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCH] lxc: don't update memUsage when failing to get memory usage
by Chen Hanxiao
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/lxc/lxc_cgroup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 8dfdc60..af95941 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -194,7 +194,8 @@ static int virLXCCgroupGetMemUsage(virCgroupPtr cgroup,
unsigned long memUsage;
ret = virCgroupGetMemoryUsage(cgroup, &memUsage);
- meminfo->memusage = (unsigned long long) memUsage;
+ if (ret == 0)
+ meminfo->memusage = (unsigned long long) memUsage;
return ret;
}
--
1.9.0
10 years, 5 months
[libvirt] [PATCH] domain_addr: Resolve Coverity warning
by John Ferlan
Recent changes in the module :
http://www.redhat.com/archives/libvir-list/2014-June/msg00978.html
seem to have caused Coverity to "take a look"...
The virDomainCCWAddressAsString() API returns either a NULL or a string
and the comparison of the returned value to "< 0" caused following errors:
[1] CONSTANT_EXPRESSION_RESULT
(1) Event result_independent_of_operands:
"!(addr = virDomainCCWAddressAsString(&addrs->next)) < 0" is always
false regardless of the values of its operands. This occurs as the
logical operand of if.
and
2] DEADCODE
(1) Event between:
At condition "!(addr = virDomainCCWAddressAsString(&addrs->next)) < 0",
the value of "addr = virDomainCCWAddressAsString(&addrs->next)" must
be between 0 and 1.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/domain_addr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index a756f12..4a14ee0 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -614,7 +614,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
goto cleanup;
}
} else if (autoassign && !dev->addr.ccw.assigned) {
- if (!(addr = virDomainCCWAddressAsString(&addrs->next)) < 0)
+ if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
goto cleanup;
while (virHashLookup(addrs->defined, addr)) {
--
1.9.3
10 years, 5 months