[libvirt] [PATCH 0/2] qemu: conf: Fix memory leaks
by Peter Krempa
Peter Krempa (2):
qemu: conf: Don't leak snapshot image format conf variable
qemu: conf: Don't leak 'namespaces' temporary variable while parsing
config
src/qemu/qemu_conf.c | 2 ++
1 file changed, 2 insertions(+)
--
2.12.2
7 years, 7 months
[libvirt] [PATCH] util: fix potential segfault
by Wang King
virBufferCurrentContent might be get a NULL string, and then without checking it,
this can cause a segfault as strlen expects a string != NULL. Use virBufferCheckError
to check error before calling strlen.
---
src/util/virsystemd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index ceb1c1a..cfc4bdb 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -135,6 +135,8 @@ virSystemdAppendValidMachineName(virBufferPtr buf,
bool skip_dot = false;
for (; *name; name++) {
+ if (virBufferCheckError(buf) < 0)
+ break;
if (strlen(virBufferCurrentContent(buf)) >= 64)
break;
--
2.8.3
7 years, 7 months
[libvirt] [PATCH 0/9] virsh: don't overwrite errors in virDomain(Snapshot)Free functions and other refactors
by Peter Krempa
Avoid the annoying problem that virDomainFree and virDomainSnapshotFree reset
libvirt errors and thus errors from helper functions don't get reported.
This seriesl also contains other refactors which I noticed along.
Peter Krempa (9):
virsh: Add new file for utility functions and move a few
virsh-util: Move domain lookup helpers into virsh-util
virsh-util: Add wrapper for virDomainFree
virsh: Add wrapper for virDomainSnapshotFree
vsh: Add helper for safe remembering of libvirt errors
virsh: add helpers for getting domain XML for XPath purposes
virsh-domain-monitor: Use the virsh wrappers for getting XML to
simplify code
virsh-domain: Use the virsh wrappers for getting XML to simplify code
virsh-domain: Refactor cmdTTYConsole
cfg.mk | 8 +
po/POTFILES.in | 1 +
tools/Makefile.am | 1 +
tools/virsh-domain-monitor.c | 89 +++--------
tools/virsh-domain.c | 370 ++++++++++++++-----------------------------
tools/virsh-domain.h | 12 --
tools/virsh-host.c | 1 -
tools/virsh-snapshot.c | 74 ++++-----
tools/virsh-util.c | 222 ++++++++++++++++++++++++++
tools/virsh-util.h | 78 +++++++++
tools/virsh-volume.c | 1 +
tools/virsh.c | 41 -----
tools/virsh.h | 4 -
tools/vsh.c | 15 ++
tools/vsh.h | 1 +
15 files changed, 493 insertions(+), 425 deletions(-)
create mode 100644 tools/virsh-util.c
create mode 100644 tools/virsh-util.h
--
2.12.2
7 years, 7 months
[libvirt] [PATCH] qemu: Fix mdev checking for VFIO support
by Erik Skultety
Commit a4a39d90 added a check that checks for VFIO support with mediated
devices. The problem is that the hostdev preparing functions behave like
a fallthrough if device of that specific type doesn't exist. However,
the check for VFIO support was independent of the existence of a mdev
device which caused the guest to fail to start with any device to be
directly assigned if VFIO was disabled/unavailable in the kernel.
The proposed change first ensures that it makes sense to check for VFIO
support in the first place, and only then performs the VFIO support check
itself.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1441291
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
src/qemu/qemu_hostdev.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 685bf5b59..9b5504832 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -330,11 +330,19 @@ qemuHostdevPrepareMediatedDevices(virQEMUDriverPtr driver,
int nhostdevs)
{
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
+ bool supportsVFIO = qemuHostdevHostSupportsPassthroughVFIO();
+ size_t i;
- if (!qemuHostdevHostSupportsPassthroughVFIO()) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("host doesn't support VFIO PCI interface"));
- return -1;
+ for (i = 0; i < nhostdevs; i++) {
+ if (hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) {
+ if (!supportsVFIO) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("host doesn't support VFIO PCI interface"));
+ return -1;
+ }
+ break;
+ }
}
return virHostdevPrepareMediatedDevices(hostdev_mgr, QEMU_DRIVER_NAME,
--
2.12.2
7 years, 7 months
[libvirt] [PATCH] util: Resolve coverity issues
by Wang King
Coverity complains about virBufferCurrentContent might be return null when calling
strlen, so check virBufferError first before calling strlen.
---
src/util/virsystemd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index ceb1c1a..83737a2 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -135,6 +135,8 @@ virSystemdAppendValidMachineName(virBufferPtr buf,
bool skip_dot = false;
for (; *name; name++) {
+ if (virBufferError(buf))
+ break;
if (strlen(virBufferCurrentContent(buf)) >= 64)
break;
--
2.8.3
7 years, 7 months
[libvirt] [PATCH] Align vol-resize arguments with the output of help
by Martin Kletzander
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
tools/virsh.pod | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index d1030808a3ed..34679e363a8e 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -4025,12 +4025,12 @@ I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume
is in. I<vol-name-or-path> is the name or path of the volume to return the
volume key for.
-=item B<vol-resize> [I<--pool> I<pool-or-uuid>] I<vol-name-or-path>
-I<pool-or-uuid> I<capacity> [I<--allocate>] [I<--delta>] [I<--shrink>]
+=item B<vol-resize> I<vol-name-or-path> I<capacity> [I<--pool> I<pool-or-uuid>]
+[I<--allocate>] [I<--delta>] [I<--shrink>]
Resize the capacity of the given volume, in bytes.
I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume
-is in. I<vol-name-or-key-or-path> is the name or key or path of the volume
+is in. I<vol-name-or-path> is the name or key or path of the volume
to resize. The new capacity might be sparse unless I<--allocate> is
specified. Normally, I<capacity> is the new size, but if I<--delta>
is present, then it is added to the existing size. Attempts to shrink
--
2.12.2
7 years, 7 months
[libvirt] [PATCH] interface: Fix resource leak in netcfConnectListAllInterfaces error path
by Wang King
On virGetInterface failure, call virInterfaceDefFree for the @def.
---
src/interface/interface_backend_netcf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index 700a8a0..c7cc071 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -622,8 +622,10 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
}
if (ifaces) {
- if (!(iface_obj = virGetInterface(conn, def->name, def->mac)))
+ if (!(iface_obj = virGetInterface(conn, def->name, def->mac))) {
+ virInterfaceDefFree(def);
goto cleanup;
+ }
tmp_iface_objs[niface_objs] = iface_obj;
}
niface_objs++;
--
2.8.3
7 years, 7 months
[libvirt] [PATCH] tools: don't leak @cpumap
by Wang King
==18591== 16 bytes in 1 blocks are definitely lost in loss record 41 of 183
==18591== at 0x4C2B934: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==18591== by 0x54EBB1C: virAllocN (viralloc.c:191)
==18591== by 0x1628CA: _vshMalloc (vsh.c:136)
==18591== by 0x1344C4: virshVcpuPinQuery (virsh-domain.c:6603)
==18591== by 0x1344C4: cmdVcpuPin (virsh-domain.c:6707)
==18591== by 0x1631BF: vshCommandRun (vsh.c:1312)
==18591== by 0x12DBB1: main (virsh.c:961)
---
tools/virsh-domain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 4b6c13c..e5fb11a 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6618,6 +6618,7 @@ virshVcpuPinQuery(vshControl *ctl,
}
}
+ VIR_FREE(cpumap);
return ret;
}
--
2.8.3
7 years, 7 months