[libvirt] [PATCH 2/2] qemu: fixing internationalization problem with sched kernel entry.
by Julio Faracco
In qemuGetSchedInfo(), libvirt is trying to parse some field of /proc/*/sched.
Some fields are floating point numbers and their separator is always a dot.
When you change the locale of the system, you can change the mantissa
separator (to a comma separator) of floating point numbers and it affects the
parser.
This commit introduces the virStrToDoubleSafe() to avoid comma as a separator.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1457634
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1457481
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ba1dba5..f1b104f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1369,7 +1369,7 @@ qemuGetSchedInfo(unsigned long long *cpuWait,
while (*line == ' ')
line++;
- if (virStrToDouble(line, NULL, &val) < 0) {
+ if (virStrToDoubleSafe(line, NULL, &val) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to parse sched info value '%s'"),
line);
--
2.7.4
7 years, 5 months
[libvirt] [PATCH v5 0/4] Loadparm support
by Farhan Ali
This patch series introduces the support for new s390x 'loadparm'
feature. The 'loadparm' can be used to select the boot entry to
boot from, for a boot device.
Here is a link to the QEMU patches:
https://lists.nongnu.org/archive/html/qemu-devel/2017-05/msg00192.html
ChangeLog
---------
v4 -> v5:
- Separated qemu capabilities data into a separate
patch. (patch 3)
- Add formatdomain.html.in to patch 1
v3 -> v4
- Break news and documentation updates to a
separate patch (patch 3)
- Merge test cases with qemu patch (patch 2)
- Add xml2xml test case (patch 2)
- Add qemucapabilities test (patch 2)
- Rebased the patch series on master commit
5970b13 udev: Fix build on older platforms
v2 -> v3:
- Updated news.xml and formatdomain.html.in with a more architectural
description of loadparm (patch 1)
v1 -> v2:
- Rebased the patch series on the latest master, commit
2f69dd3 virfiletest: include linux/falloc.h
Thanks
Farhan Ali
Farhan Ali (4):
conf : Add loadparm boot option for a boot device
qemu : Add loadparm to qemu command line string
qemu: capabilities: Add data for qemu capabilities for s390x
news: Update news for loadparm feature
docs/formatdomain.html.in | 9 +-
docs/news.xml | 11 +
docs/schemas/domaincommon.rng | 7 +
src/conf/device_conf.h | 1 +
src/conf/domain_conf.c | 69 +-
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_capabilities.h | 3 +
src/qemu/qemu_command.c | 33 +
.../qemucapabilitiesdata/caps_2.9.50.s390x.replies | 14587 +++++++++++++++++++
tests/qemucapabilitiesdata/caps_2.9.50.s390x.xml | 302 +
...-machine-loadparm-multiple-disks-nets-s390.args | 28 +
...v-machine-loadparm-multiple-disks-nets-s390.xml | 43 +
.../qemuxml2argv-machine-loadparm-net-s390.args | 20 +
.../qemuxml2argv-machine-loadparm-net-s390.xml | 26 +
...xml2argv-machine-loadparm-s390-char-invalid.xml | 26 +
...uxml2argv-machine-loadparm-s390-len-invalid.xml | 26 +
.../qemuxml2argv-machine-loadparm-s390.args | 20 +
.../qemuxml2argv-machine-loadparm-s390.xml | 26 +
tests/qemuxml2argvtest.c | 19 +
...t-machine-loadparm-multiple-disks-nets-s390.xml | 44 +
tests/qemuxml2xmltest.c | 4 +
21 files changed, 15303 insertions(+), 4 deletions(-)
create mode 100644 tests/qemucapabilitiesdata/caps_2.9.50.s390x.replies
create mode 100644 tests/qemucapabilitiesdata/caps_2.9.50.s390x.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-loadparm-multiple-disks-nets-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-loadparm-multiple-disks-nets-s390.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-loadparm-net-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-loadparm-net-s390.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-loadparm-s390-char-invalid.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-loadparm-s390-len-invalid.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-loadparm-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-loadparm-s390.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-machine-loadparm-multiple-disks-nets-s390.xml
--
1.9.1
7 years, 5 months
[libvirt] [PATCH] Disable the -Wduplicated-branches warning
by Daniel P. Berrange
Depending on the platform/architecture, a number of conditionals
in libvirt code expand the same on both branches. This is expected
behaviour and harmless, so disable the warning to avoid creating
unexpected build failures
Two examples, mingw32:
../../src/util/vircommand.c: In function 'virCommandWait':
../../src/util/vircommand.c:2562:51: error: this condition has identical branches [-Werror=duplicated-branches]
*exitstatus = cmd->rawStatus ? status : WEXITSTATUS(status);
^
and gcc7.1
In file included from util/virobject.c:28:0:
util/virobject.c: In function 'virClassNew':
util/viratomic.h:176:46: error: this condition has identical branches [-Werror=duplicated-branches]
(void)(0 ? *(atomic) ^ *(atomic) : 0); \
^
util/virobject.c:144:20: note: in expansion of macro 'virAtomicIntInc'
klass->magic = virAtomicIntInc(&magicCounter);
^~~~~~~~~~~~~~~
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
m4/virt-compile-warnings.m4 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 768a5c8..d7bb172 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -61,6 +61,9 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dontwarn="$dontwarn -Wenum-compare"
# gcc 5.1 -Wformat-signedness mishandles enums, not ready for prime time
dontwarn="$dontwarn -Wformat-signedness"
+ # Several conditionals expand the same on both branches
+ # depending on the particular platform/architecture
+ dontwarn="$dontwarn -Wduplicated-branches"
# gcc 4.2 treats attribute(format) as an implicit attribute(nonnull),
# which triggers spurious warnings for our usage
--
2.9.3
7 years, 5 months
[libvirt] [PATCH] qemu: Pass the number of heads even with -vga qxl
by Martin Kletzander
When added in multiple previous commits, it was used only with -device
qxl(-vga), but for some QEMUs (< 1.6) we need to add this
functionality when using -vga qxl as well.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1283207
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_command.c | 8 ++++
.../qemuxml2argv-video-vga-qxl-heads.args | 30 ++++++++++++++
.../qemuxml2argv-video-vga-qxl-heads.xml | 47 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
4 files changed, 88 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3e1552a1b593..9687d367a6d4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4613,6 +4613,14 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
dev, vgamem / 1024);
}
+
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS))
+ video->heads = 0;
+ if (video->heads) {
+ virCommandAddArg(cmd, "-global");
+ virCommandAddArgFormat(cmd, "%s.max_outputs=%u",
+ dev, video->heads);
+ }
}
if (video->vram &&
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
new file mode 100644
index 000000000000..411a2eedbc4b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
@@ -0,0 +1,30 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-vga qxl \
+-global qxl-vga.ram_size=67108864 \
+-global qxl-vga.vram_size=67108864 \
+-global qxl-vga.max_outputs=1 \
+-device qxl,id=video1,ram_size=67108864,vram_size=33554432,max_outputs=3,\
+bus=pci.0,addr=0x4 \
+-device qxl,id=video2,ram_size=67108864,vram_size=67108864,max_outputs=7,\
+bus=pci.0,addr=0x5 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml
new file mode 100644
index 000000000000..d878ddcd6d2e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml
@@ -0,0 +1,47 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <video>
+ <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='3'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </video>
+ <video>
+ <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='7'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </video>
+ <video>
+ <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 43d3f1bd3973..ea8403122feb 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1734,6 +1734,9 @@ mymain(void)
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_QXL_MAX_OUTPUTS);
+ DO_TEST("video-vga-qxl-heads",
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_QXL_MAX_OUTPUTS);
DO_TEST("video-qxl-noheads",
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_QXL,
--
2.13.1
7 years, 5 months
[libvirt] [PATCH] qemu: Avoid parsing empty nodeset string
by Nitesh Konkar
The advisory nodeset from numad is parsed irrespective of
the string being empty or not. Avoid parsing an empty nodeset
string.
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/qemu/qemu_process.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 85b800d..1c49fa6 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5456,7 +5456,7 @@ qemuProcessPrepareDomain(virConnectPtr conn,
if (virDomainDefNeedsPlacementAdvice(vm->def)) {
nodeset = virNumaGetAutoPlacementAdvice(virDomainDefGetVcpus(vm->def),
virDomainDefGetMemoryTotal(vm->def));
- if (!nodeset)
+ if (virStringIsEmpty(nodeset))
goto cleanup;
VIR_DEBUG("Nodeset returned from numad: %s", nodeset);
--
2.9.4
7 years, 5 months
[libvirt] [PATCH 0/4] Fix regression in migration with custom XML
by Jiri Denemark
When making ABI stability checks for an active domain, we need to make
sure we use the same migratable definition which virDomainGetXMLDesc
with the MIGRATABLE flag provides, otherwise the ABI check will fail.
https://bugzilla.redhat.com/show_bug.cgi?id=1460952
Jiri Denemark (4):
qemu: Introduce qemuDomainDefFromXML helper
qemu: Add qemuDomainMigratableDefCheckABIStability
qemu: Add qemuDomainCheckABIStability
qemu: Use qemuDomainCheckABIStability where needed
src/qemu/qemu_domain.c | 108 ++++++++++++++++++++++++++++++++++------------
src/qemu/qemu_domain.h | 4 ++
src/qemu/qemu_driver.c | 71 +++++++++++++++++-------------
src/qemu/qemu_migration.c | 2 +-
4 files changed, 126 insertions(+), 59 deletions(-)
--
2.13.1
7 years, 5 months
[libvirt] [PATCH] qemu: Don't try to use hugepages if not enabled
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1214369
My fix 671d18594f4 was incomplete. If domain doesn't have
hugepages enalbed, because of missing condition we would still be
putting hugepages path onto qemu cmd line. Clean up the
conditions so that it's more visible next time.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 12 +++++-----
.../qemuxml2argv-cpu-numa-memshared.args | 26 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
3 files changed, 33 insertions(+), 6 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3e1552a1b..8c12b2be0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3408,23 +3408,23 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
if (pagesize || mem->nvdimmPath || memAccess ||
def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
*backendType = "memory-backend-file";
- if (mem->nvdimmPath) {
+ if (pagesize) {
+ if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
+ goto cleanup;
+ prealloc = true;
+ } else if (mem->nvdimmPath) {
if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
goto cleanup;
prealloc = true;
- } else if (!pagesize && def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
+ } else {
/* We can have both pagesize and mem source. If that's the case,
* prefer hugepages as those are more specific. */
if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
goto cleanup;
- } else {
- if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
- goto cleanup;
- prealloc = true;
}
if (virJSONValueObjectAdd(props,
"B:prealloc", prealloc,
"s:mem-path", memPath,
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
new file mode 100644
index 000000000..cceffce3a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 16,sockets=2,cores=4,threads=2 \
+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
+share=yes,size=112197632 \
+-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
+-object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
+share=no,size=112197632 \
+-numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot n \
+-usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 43d3f1bd3..799aea9fa 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1539,10 +1539,11 @@ mymain(void)
DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
DO_TEST_FAILURE("cpu-numa-disjoint", NONE);
DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
DO_TEST_FAILURE("cpu-numa-memshared", NONE);
+ DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
DO_TEST("cpu-host-model", NONE);
DO_TEST("cpu-host-model-vendor", NONE);
skipLegacyCPUs = true;
DO_TEST("cpu-host-model-fallback", NONE);
DO_TEST_FAILURE("cpu-host-model-nofallback", NONE);
--
2.13.0
7 years, 5 months
[libvirt] [PATCH] Use sys/uio.h for writev()
by Daniel P. Berrange
With glibc >= 2.25.90 writev() is only available if you explicitly
include sys/uio.h
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
A build breaker, but not yet pushed in case anyone has opinions...
configure.ac | 2 +-
src/util/virlog.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 1a73b34..1a48bb0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -328,7 +328,7 @@ dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([pwd.h regex.h sys/un.h \
sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
sys/un.h sys/syscall.h sys/sysctl.h netinet/tcp.h ifaddrs.h \
- libtasn1.h sys/ucred.h sys/mount.h stdarg.h])
+ libtasn1.h sys/ucred.h sys/mount.h stdarg.h sys/uio.h])
dnl Check whether endian provides handy macros.
AC_CHECK_DECLS([htole64], [], [], [[#include <endian.h>]])
AC_CHECK_FUNCS([stat stat64 __xstat __xstat64 lstat lstat64 __lxstat __lxstat64])
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 7933e1a..3a28e5e 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -32,6 +32,9 @@
#include <unistd.h>
#include <execinfo.h>
#include <regex.h>
+#if HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
#if HAVE_SYSLOG_H
# include <syslog.h>
#endif
--
2.9.3
7 years, 5 months
[libvirt] [PATCH] EventRegister: Fix double deference error in libvirt_virConnectDomainEventRegisterAny
by fangying
As descriped at https://www.spinics.net/linux/fedora/libvir/msg148562.html,
even when virConnectDomainEventRegisterAny returns -1 there is still a
scenario in which it will trigger the free callback. We fix the problem in the
following way:
(1) implement a function virObjectEventStateSetFreeCB to add freecallback.
(2) call virObjectEventStateSetFreeCB only if the event is successfully added.
Signed-off-by: fangying <fangying1(a)huawei.com>
---
src/conf/object_event.c | 34 ++++++++++++++++++++++++++++++++++
src/conf/object_event.h | 7 +++++++
src/libvirt_private.syms | 2 +-
src/remote/remote_driver.c | 4 ++--
4 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index e5f942f..a770978 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -923,6 +923,40 @@ virObjectEventStateRegisterID(virConnectPtr conn,
/**
+ * virObjectEventStateSetFreeCB:
+ * @conn: connection to associate with callback
+ * @state: object event state
+ * @callbackID: ID of the function to remove from event
+ * @freecb: freecb to be added
+ *
+ * Add the callbalck function @freecb for @callbackID with connection @conn,
+ * from @state, for events.
+ */
+void
+virObjectEventStateSetFreeCB(virConnectPtr conn,
+ virObjectEventStatePtr state,
+ int callbackID,
+ virFreeCallback freecb)
+{
+ size_t i;
+ virObjectEventCallbackListPtr cbList;
+
+ virObjectEventStateLock(state);
+ cbList = state->callbacks;
+ for (i = 0; i < cbList->count; i++) {
+ virObjectEventCallbackPtr cb = cbList->callbacks[i];
+
+ if (cb->callbackID == callbackID && cb->conn == conn) {
+ cb->freecb = freecb;
+ break;
+ }
+ }
+
+ virObjectEventStateUnlock(state);
+}
+
+
+/**
* virObjectEventStateDeregisterID:
* @conn: connection to associate with callback
* @state: object event state
diff --git a/src/conf/object_event.h b/src/conf/object_event.h
index 7a9995e..a7d29a0 100644
--- a/src/conf/object_event.h
+++ b/src/conf/object_event.h
@@ -90,4 +90,11 @@ virObjectEventStateSetRemote(virConnectPtr conn,
int remoteID)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+void
+virObjectEventStateSetFreeCB(virConnectPtr conn,
+ virObjectEventStatePtr state,
+ int callbackID,
+ virFreeCallback freecb)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
+
#endif
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 429b095..e9d9cb6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -791,7 +791,7 @@ virObjectEventStateDeregisterID;
virObjectEventStateEventID;
virObjectEventStateNew;
virObjectEventStateQueue;
-
+virObjectEventStateSetFreeCB;
# conf/secret_conf.h
virSecretDefFormat;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d27e96f..71177bd 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5947,7 +5947,7 @@ remoteConnectDomainEventRegisterAny(virConnectPtr conn,
if ((count = virDomainEventStateRegisterClient(conn, priv->eventState,
dom, eventID, callback,
- opaque, freecb, false,
+ opaque, NULL, false,
&callbackID,
priv->serverEventFilter)) < 0)
goto done;
@@ -5993,7 +5993,7 @@ remoteConnectDomainEventRegisterAny(virConnectPtr conn,
}
rv = callbackID;
-
+ virObjectEventStateSetFreeCB(conn, priv->eventState, callbackID, freecb);
done:
remoteDriverUnlock(priv);
return rv;
--
2.10.0.windows.1
7 years, 5 months
[libvirt] [PATCH] fix memory leak in qemuMonitorJSONAttachCharDevCommand
by Yi Wang
The @tlsalias allocated in qemuAliasTLSObjFromSrcAlias may lost
when append string to json.
Signed-off-by: Xi Xu <xu.xi8(a)zte.com.cn>
---
src/qemu/qemu_monitor_json.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f208dd0..773de0f 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6487,6 +6487,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias) < 0)
goto error;
+ VIR_FREE(tlsalias);
}
break;
--
1.8.3.1
7 years, 5 months