[libvirt] [PATCH 0/4] test_driver: implement virDomainSaveImageGetXMLDesc and virDomainSaveImageDefineXML
by Ilias Stamatis
While implementing virDomainSaveImageGetXMLDesc and
virDomainSaveImageDefineXML for the test driver, I realized that there
exists already code for saving and loading test images which can be
reused. However, it needed to be extracted from testDomainSaveFlags and
testDomainRestoreFlags into separate functions. The new functions are
inspired by the corresponding QEMU driver code where e.g.
qemuDomainSaveImageOpen serves as a helper used by other functions.
This series of patches initially extracts the code mentioned above into
separate functions and then provides the test driver with
implementations for virDomainSaveImageGetXMLDesc and
virDomainSaveImageDefineXML which make use of the newly introduced
functions.
Ilias Stamatis (4):
test_driver: extract image saving code into a separate function
test_driver: extract image loading code into a separate function
test_driver: implement virDomainSaveImageDefineXML
test_driver: implement virDomainSaveImageGetXMLDesc
src/test/test_driver.c | 281 ++++++++++++++++++++++++++++-------------
1 file changed, 193 insertions(+), 88 deletions(-)
--
2.21.0
5 years, 6 months
[libvirt] [PATCH] qemu: Fix NULL pointer access in qemuProcessInitCpuAffinity()
by Andrea Bolognani
Commit 2f2254c7f4e5 attempted to fix a memory leak by ensuring
cpumapToSet is always a freshly allocated bitmap, but regrettably
introduced a NULL pointer access while doing so, because it called
virBitmapCopy() without allocating the destination bitmap first.
Solve the issue by using virBitmapNewCopy() instead.
Reported-by: John Ferlan <jferlan(a)redhat.com>
Signed-off-by: Andrea Bolognani <abologna(a)redhat.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 42a6271411..50a76aa0ed 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2498,7 +2498,7 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
if (virNumaNodesetToCPUset(nodeset, &cpumapToSet) < 0)
return -1;
} else if (vm->def->cputune.emulatorpin) {
- if (virBitmapCopy(cpumapToSet, vm->def->cputune.emulatorpin) < 0)
+ if (!(cpumapToSet = virBitmapNewCopy(vm->def->cputune.emulatorpin)))
return -1;
} else {
if (qemuProcessGetAllCpuAffinity(&cpumapToSet) < 0)
--
2.21.0
5 years, 6 months
[libvirt] [PATCH v2 00/11] Grab modify job for changing domain XML
by Michal Privoznik
v2 of:
https://www.redhat.com/archives/libvir-list/2019-May/msg00858.html
diff to v1:
- 1/9 from the original series is pushed now. It's independent from the
feature.
- Acquiring job is done in a way suggested by Nikolay in review of v1.
Michal Prívozník (11):
virDomainObjListAddObjLocked: Don't expect vm->def to be set
virDomainObjListAddLocked: Set vm->def only in success path
virDomainObjIsActive: Allow vm->def to be NULL
virDomainObjListAdd: Leave def assigning as an exercise for caller
virDomainObjListAdd: Remove unused flag
qemu: Grab modify job for changing domain XML
qemu_domain: Allow qemuDomainObjListAdd to keep job upon return
lxc: Grab modify job for changing domain XML
lxc_domain: Allow lxcDomainObjListAdd to keep job upon return
libxl: Grab modify job for changing domain XML
libxl_domain: Allow libxlDomainObjListAdd to keep job upon return
src/bhyve/bhyve_driver.c | 10 +++---
src/conf/domain_conf.h | 2 +-
src/conf/virdomainobjlist.c | 44 +++++++++---------------
src/conf/virdomainobjlist.h | 6 ++--
src/libxl/libxl_domain.c | 68 +++++++++++++++++++++++++++++++++++++
src/libxl/libxl_domain.h | 8 +++++
src/libxl/libxl_driver.c | 40 +++++-----------------
src/libxl/libxl_migration.c | 28 +++------------
src/lxc/lxc_domain.c | 68 +++++++++++++++++++++++++++++++++++++
src/lxc/lxc_domain.h | 8 +++++
src/lxc/lxc_driver.c | 28 ++++++---------
src/openvz/openvz_conf.c | 12 +++----
src/openvz/openvz_driver.c | 17 +++++-----
src/qemu/qemu_domain.c | 66 +++++++++++++++++++++++++++++++++++
src/qemu/qemu_domain.h | 7 ++++
src/qemu/qemu_driver.c | 43 ++++++++---------------
src/qemu/qemu_migration.c | 7 ++--
src/test/test_driver.c | 21 +++++++-----
src/vmware/vmware_conf.c | 4 +--
src/vmware/vmware_driver.c | 9 +++--
src/vz/vz_sdk.c | 4 ++-
21 files changed, 326 insertions(+), 174 deletions(-)
--
2.21.0
5 years, 6 months
[libvirt] [PATCH 0/2] qemu: Fix leak in qemuProcessInitCpuAffinity()
by Andrea Bolognani
Spotted by John through Coverity.
Andrea Bolognani (2):
qemu: Fix leak in qemuProcessInitCpuAffinity()
qemu: Drop cleanup label from qemuProcessInitCpuAffinity()
src/qemu/qemu_process.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
--
2.21.0
5 years, 6 months
[libvirt] [PATCH] cpu_conf: Fix XPath for parsing TSC frequency
by Jiri Denemark
Due to this bug the following command would fail on any host where TSC
frequency can be probed:
$ virsh capabilities | virsh cpu-baseline /dev/stdin
error: unsupported configuration: Invalid TSC frequency
https://bugzilla.redhat.com/show_bug.cgi?id=1641702
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/conf/cpu_conf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index dc46e7f57a..825df88246 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -417,8 +417,8 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
if (VIR_ALLOC(tsc) < 0)
goto cleanup;
- if (virXPathULongLong("./counter[@name='tsc']/@frequency", ctxt,
- &tsc->frequency) < 0) {
+ if (virXPathULongLong("string(./counter[@name='tsc']/@frequency)",
+ ctxt, &tsc->frequency) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid TSC frequency"));
goto cleanup;
--
2.21.0
5 years, 6 months
[libvirt] [PATCH 0/3] virsh: undefine: Clarify things around snapshots
by Peter Krempa
Peter Krempa (3):
virsh: undefine: Clarify help string for --snapshots-metadata
virsh: undefine: Rename --delete-snapshots to
--delete-storage-volume-snapshots
virsh: undefine: Clarify that --delete-storage-volume-snapshots causes
failures
tools/virsh-domain.c | 6 +++++-
tools/virsh.pod | 10 ++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
--
2.21.0
5 years, 6 months
[libvirt] QMP; unsigned 64-bit ints; JSON standards compliance
by Daniel P. Berrangé
The QEMU QMP service is based on JSON which is nice because that is a
widely supported "standard" data format.....
....except QEMU's implementation (and indeed most impls) are not strictly
standards compliant.
Specifically the problem is around representing 64-bit integers, whether
signed or unsigned.
The JSON standard declares that largest integer is 2^53-1 and the
likewise the smallest is -(2^53-1):
http://www.ecma-international.org/ecma-262/6.0/index.html#sec-number.max_...
A crazy limit inherited from its javascript origins IIUC.
QEMU, and indeed many applications, want to handle 64-bit integers.
The C JSON library impls have traditionally mapped integers to the
data type 'long long int' which gives a min/max of -(2^63) / 2^63-1.
QEMU however /really/ needs 64-bit unsigned integers, ie a max 2^64-1.
Libvirt has historically used the YAJL library which uses 'long long int'
and thus can't officially go beyond 2^63-1 values. Fortunately it lets
libvirt get at the raw json string, so libvirt can re-parse the value
to get an 'unsigned long long'.
We recently tried to switch to Jansson because YAJL has a dead upstream
for many years and countless unanswered bugs & patches. Unfortunately we
forgot about this need for 2^64-1 max, and Jansson also uses 'long long int'
and raises a fatal parse error for unsigned 64-bit values above 2^63-1. It
also provides no backdoor for libvirt todo its own integer parsing. Thus
we had to abort our switch to jansson as it broke parsing QEMU's JSON:
https://bugzilla.redhat.com/show_bug.cgi?id=1614569
Other JSON libraries we've investigated have similar problems. I imagine
the same may well be true of non-C based JOSN impls, though I've not
investigated in any detail.
Essentially libvirt is stuck with either using the dead YAJL library
forever, or writing its own JSON parser (most likely copying QEMU's
JSON code into libvirt's git).
This feels like a very unappealing situation to be in as not being
able to use a JSON library of our choice is loosing one of the key
benefits of using a standard data format.
Thus I'd like to see a solution to this to allow QMP to be reliably
consumed by any JSON library that exists.
I can think of some options:
1. Encode unsigned 64-bit integers as signed 64-bit integers.
This follows the example that most C libraries map JSON ints
to 'long long int'. This is still relying on undefined
behaviour as apps don't need to support > 2^53-1.
Apps would need to cast back to 'unsigned long long' for
those QMP fields they know are supposed to be unsigned.
2. Encode all 64-bit integers as a pair of 32-bit integers.
This is fully compliant with the JSON spec as each half
is fully within the declared limits. App has to split or
assemble the 2 pieces from/to a signed/unsigned 64-bit
int as needed.
3. Encode all 64-bit integers as strings
The application has todo all parsing/formatting client
side.
None of these changes are backwards compatible, so I doubt we could make
the change transparently in QMP. Instead we would have to have a
QMP greeting message capability where the client can request enablement
of the enhanced integer handling.
Any of the three options above would likely work for libvirt, but I
would have a slight preference for either 2 or 3, so that we become
100% standards compliant.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
5 years, 6 months
[libvirt] [PATCH] tests: Fix parentheses order in an assignment-comparison conditional
by Erik Skultety
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1717090
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
Pushed as trivial.
tests/testutilsqemu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index bce847ce5e..9ac9f9bd39 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -918,7 +918,7 @@ testQemuCapsIterate(const char *suffix,
if (virDirOpen(&dir, TEST_QEMU_CAPS_PATH) < 0)
goto cleanup;
- while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH) > 0)) {
+ while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
char *tmp = ent->d_name;
char *base = NULL;
char *archName = NULL;
--
2.20.1
5 years, 6 months
[libvirt] [PATCH 0/9] Grab modify job for changing domain XML
by Michal Privoznik
This is an alternative proposal to:
https://www.redhat.com/archives/libvir-list/2019-May/msg00830.html
The problem I'm trying to fix is described here:
https://www.redhat.com/archives/libvir-list/2019-May/msg00810.html
Michal Prívozník (9):
virDomainObjListAddLocked: Drop useless @cleanup label
virDomainObjListAddObjLocked: Don't expect vm->def to be set
virDomainObjListAddLocked: Set vm->def only in success path
virDomainObjIsActive: Allow vm->def to be NULL
virDomainObjListAdd: Leave def assigning as an exercise for caller
qemu: Allow vm->def == NULL in job control APIs
qemu: Grab modify job for changing domain XML
lxc: Grab modify job for changing domain XML
libxl: Grab modify job for changing domain XML
src/bhyve/bhyve_driver.c | 10 +++++---
src/conf/domain_conf.h | 2 +-
src/conf/virdomainobjlist.c | 48 ++++++++++++++----------------------
src/conf/virdomainobjlist.h | 3 +--
src/libxl/libxl_domain.c | 3 ++-
src/libxl/libxl_driver.c | 48 ++++++++++++++++++++++++------------
src/libxl/libxl_migration.c | 14 +++++------
src/lxc/lxc_domain.c | 3 ++-
src/lxc/lxc_driver.c | 23 +++++++++++------
src/openvz/openvz_conf.c | 12 ++++-----
src/openvz/openvz_driver.c | 17 +++++++------
src/qemu/qemu_domain.c | 30 ++++++++++++++---------
src/qemu/qemu_driver.c | 49 ++++++++++++++++++++++++++-----------
src/qemu/qemu_migration.c | 13 +++++++---
src/test/test_driver.c | 21 +++++++++-------
src/vmware/vmware_conf.c | 4 +--
src/vmware/vmware_driver.c | 9 +++----
src/vz/vz_sdk.c | 4 ++-
18 files changed, 183 insertions(+), 130 deletions(-)
--
2.21.0
5 years, 6 months
[libvirt] [PATCH 0/4] qemu: Fix qemuProcessInitCpuAffinity()
by Andrea Bolognani
See detailed explanation in the commit message for patch 1/4
and the corresponding bug report.
Andrea Bolognani (4):
util: Introduce virBitmapUnion()
fixup? util: Optimize virBitmapUnion()
util: Introduce virNumaNodesetToCPUset()
qemu: Fix qemuProcessInitCpuAffinity()
src/libvirt_private.syms | 2 ++
src/qemu/qemu_process.c | 7 ++++-
src/util/virbitmap.c | 32 +++++++++++++++++++++++
src/util/virbitmap.h | 4 +++
src/util/virnuma.c | 55 ++++++++++++++++++++++++++++++++++++++++
src/util/virnuma.h | 2 ++
tests/virbitmaptest.c | 37 +++++++++++++++++++++++++++
7 files changed, 138 insertions(+), 1 deletion(-)
--
2.21.0
5 years, 6 months