libvirt: cherry-picks fix for qmp props param deprecation

After the QEMU uprev to be based on version 7.2+dfsg-7+deb12u5, while we
keep libvirt base version on 7.0.0-3 we are having an incompatibility
issue already reported usptream between qemu 6.0+ and libvirt <7.2 [1].
After version 6.0, qmp command 'object-add' does not support 'props'
parameter but libvirt 7.0.0-3 stills use it when assembling the
command [2-3].

This patch, then, brings the libvirt upstream commits that fixed this
issue starting from v7.2.0. While it is not possible to uprev our libvirt
this patch will be useful to fix the problem and enable proper
device attach when actions are performed on QEMU instances.

When we decide to uprev libvirt, this patch will no longer be needed.

[1] https://bugs.launchpad.net/starlingx/+bug/2078857
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1958302
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1944985

The list of upstream cherry-picked commits follows:

commit 1786cd4179fbaafe83f022c98fc6ee425177ceba
qemu: monitor: Don't add 'props' wrapper if qemu has QEMU_CAPS_OBJECT_QAPIFIED
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Mon Nov 30 18:30:46 2020 +0100
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 96850dfe216f99019978a55027a1e763135ae88f)

commit 9f3a38f3adbdf5f68e960b9c70aa84543c8e7d57
qemuMonitorCreateObjectPropsWrap: Open-code in qemuBuildMemoryBackendProps
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Mon Nov 30 17:08:46 2020 +0100
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 71828a7bc0646ef834af37509fa8300ef4e74340)

commit d2546ae335628e9589cae7c301c42f58772a6218
qemu: monitor: Make wrapping of 'props' of 'object-add' optional
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Mon Nov 30 16:03:57 2020 +0100
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit e0eeb2cc67d960a48937f99c659fb63dbd4049dc)

commit b545d8bf1a6ae4f651daa92a32fecc8819ee0a6c
qemu: capabilities: Introduce QEMU_CAPS_OBJECT_QAPIFIED
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Fri Nov 27 07:06:13 2020 +0100
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 3d50ecc9bb2be88a56f00cd60335215b0d1132c2)

TEST PLAN:
PASS - build-pkgs -c -p libvirt
PASS - build-image stx-libvirt
PASS - Update a running AIO-DX stx-openstack deployment with the new
       image and ensure libvirt pods are updated and Running
PASS - Live-Migrate a running VM instance with a volume
PASS - Cold-Migrate a running VM instance with a volume

Closes-Bug: 2078857

Change-Id: I6dafafa220809c79f08420d181b2c4ef97f3b71b
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
This commit is contained in:
Thales Elero Cervi 2024-09-04 19:46:00 -03:00
parent c2f773a9d9
commit a4fad169ad
5 changed files with 386 additions and 0 deletions

View File

@ -0,0 +1,54 @@
From d5f22ad0310e6f8068189647d2f5b45dde662691 Mon Sep 17 00:00:00 2001
From: Thales Elero Cervi <thaleselero.cervi@windriver.com>
Date: Wed, 18 Sep 2024 18:56:53 -0300
Subject: [PATCH] qemu: capabilities: Introduce QEMU_CAPS_OBJECT_QAPIFIED
Starting from qemu-6.0 the parameters of -object/object-add are formally
described by the QAPI schema. Additionally this changes the nesting of
the properties as the 'props' nested object will be flattened to the
parent.
We'll need to detect whether qemu switched to this new approach to
generate the objects with proper nesting and also allow testing.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
[ Patch defuzzed for libvirt 7.0.0]
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
---
src/qemu/qemu_capabilities.c | 4 ++++
src/qemu/qemu_capabilities.h | 3 +++
2 files changed, 7 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4d132defbd4..fba718f53df 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -609,6 +609,10 @@ VIR_ENUM_IMPL(virQEMUCaps,
"ncr53c90",
"dc390",
"am53c974",
+
+ /* 395 */
+ "object.qapified",
+
);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 0f90efa4598..9d891f1c942 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -590,6 +590,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
QEMU_CAPS_SCSI_DC390, /* -device dc-390 */
QEMU_CAPS_SCSI_AM53C974, /* -device am53c974 */
+ /* 395 */
+ QEMU_CAPS_OBJECT_QAPIFIED, /* parameters for object-add are formally described */
+
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
--
2.34.1

View File

@ -0,0 +1,197 @@
From 150c1d229e2f3a24784875cb9e7de8b60bee5cb5 Mon Sep 17 00:00:00 2001
From: Thales Elero Cervi <thaleselero.cervi@windriver.com>
Date: Wed, 18 Sep 2024 18:57:40 -0300
Subject: [PATCH] qemu: monitor: Make wrapping of 'props' of 'object-add'
optional
Construct the JSON object which is used for object-add without the
'props' wrapper and add the wrapper only in the monitor code.
This simplifies the JSON->commandline generator in the first place and
also prepares for upcoming qemu where 'props' will be removed.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
[ Patch defuzzed for libvirt 7.0.0]
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
---
src/qemu/qemu_monitor.c | 66 ++++++++++++++++++++++++++++-------------
src/util/virqemu.c | 34 +++++++--------------
2 files changed, 56 insertions(+), 44 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index ac8960cfc45..2e280b82689 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -109,6 +109,9 @@ struct _qemuMonitor {
qemuMonitorReportDomainLogError logFunc;
void *logOpaque;
virFreeCallback logDestroy;
+
+ /* true if qemu no longer wants 'props' sub-object of object-add */
+ bool objectAddNoWrap;
};
/**
@@ -3031,14 +3034,11 @@ qemuMonitorCreateObjectPropsWrap(const char *type,
const char *alias,
virJSONValuePtr *props)
{
- virJSONValuePtr ret;
+ if (virJSONValueObjectPrependString(*props, "id", alias) < 0 ||
+ virJSONValueObjectPrependString(*props, "qom-type", type))
+ return NULL;
- ignore_value(virJSONValueObjectCreate(&ret,
- "s:qom-type", type,
- "s:id", alias,
- "A:props", props,
- NULL));
- return ret;
+ return g_steal_pointer(props);
}
@@ -3058,26 +3058,27 @@ qemuMonitorCreateObjectProps(virJSONValuePtr *propsret,
const char *alias,
...)
{
- virJSONValuePtr props = NULL;
- int ret = -1;
+ g_autoptr(virJSONValue) props = NULL;
+ int rc;
va_list args;
- *propsret = NULL;
+ if (virJSONValueObjectCreate(&props,
+ "s:qom-type", type,
+ "s:id", alias,
+ NULL) < 0)
+ return -1;
va_start(args, alias);
- if (virJSONValueObjectCreateVArgs(&props, args) < 0)
- goto cleanup;
+ rc = virJSONValueObjectAddVArgs(props, args);
- if (!(*propsret = qemuMonitorCreateObjectPropsWrap(type, alias, &props)))
- goto cleanup;
+ va_end(args);
- ret = 0;
+ if (rc < 0)
+ return -1;
- cleanup:
- virJSONValueFree(props);
- va_end(args);
- return ret;
+ *propsret = g_steal_pointer(&props);
+ return 0;
}
@@ -3097,6 +3098,7 @@ qemuMonitorAddObject(qemuMonitorPtr mon,
virJSONValuePtr *props,
char **alias)
{
+ g_autoptr(virJSONValue) pr = NULL;
const char *type = NULL;
const char *id = NULL;
g_autofree char *aliasCopy = NULL;
@@ -3124,7 +3126,31 @@ qemuMonitorAddObject(qemuMonitorPtr mon,
if (alias)
aliasCopy = g_strdup(id);
- if (qemuMonitorJSONAddObject(mon, props) < 0)
+ if (mon->objectAddNoWrap) {
+ pr = g_steal_pointer(props);
+ } else {
+ /* we need to create a wrapper which has the 'qom-type' and 'id' and
+ * store everything else under a 'props' sub-object */
+ g_autoptr(virJSONValue) typeobj = NULL;
+ g_autoptr(virJSONValue) idobj = NULL;
+
+ ignore_value(virJSONValueObjectRemoveKey(*props, "qom-type", &typeobj));
+ ignore_value(virJSONValueObjectRemoveKey(*props, "id", &idobj));
+
+ if (!virJSONValueObjectGetKey(*props, 0)) {
+ virJSONValueFree(*props);
+ *props = NULL;
+ }
+
+ if (virJSONValueObjectCreate(&pr,
+ "s:qom-type", type,
+ "s:id", id,
+ "A:props", props,
+ NULL) < 0)
+ return -1;
+ }
+
+ if (qemuMonitorJSONAddObject(mon, &pr) < 0)
return -1;
if (alias)
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index c4b6e8b3db2..a6011e55c9f 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -319,12 +319,13 @@ virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr props,
}
-static int
-virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
- const char *type,
- const char *alias,
- virJSONValuePtr props)
+int
+virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
+ virJSONValuePtr objprops)
{
+ const char *type = virJSONValueObjectGetString(objprops, "qom-type");
+ const char *alias = virJSONValueObjectGetString(objprops, "id");
+
if (!type || !alias) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing 'type'(%s) or 'alias'(%s) field of QOM 'object'"),
@@ -332,31 +333,16 @@ virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
return -1;
}
- virBufferAsprintf(buf, "%s,id=%s", type, alias);
+ virBufferAsprintf(buf, "%s,", type);
- if (props) {
- virBufferAddLit(buf, ",");
- if (virQEMUBuildCommandLineJSON(props, buf, NULL, false,
- virQEMUBuildCommandLineJSONArrayBitmap) < 0)
- return -1;
- }
+ if (virQEMUBuildCommandLineJSON(objprops, buf, "qom-type", false,
+ virQEMUBuildCommandLineJSONArrayBitmap) < 0)
+ return -1;
return 0;
}
-int
-virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
- virJSONValuePtr objprops)
-{
- const char *type = virJSONValueObjectGetString(objprops, "qom-type");
- const char *alias = virJSONValueObjectGetString(objprops, "id");
- virJSONValuePtr props = virJSONValueObjectGetObject(objprops, "props");
-
- return virQEMUBuildObjectCommandlineFromJSONInternal(buf, type, alias, props);
-}
-
-
char *
virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef)
{
--
2.34.1

View File

@ -0,0 +1,82 @@
From 4d984701dd6440fdc541fb803e72bd59c1950d4d Mon Sep 17 00:00:00 2001
From: Thales Elero Cervi <thaleselero.cervi@windriver.com>
Date: Wed, 18 Sep 2024 19:01:29 -0300
Subject: [PATCH] qemuMonitorCreateObjectPropsWrap: Open-code in
qemuBuildMemoryBackendProps
There's just one caller left. Since qemuBuildMemoryBackendProps is too
complex to be modified for now, just move the adding of 'id' and 'qom'
type directly into the function.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
[ Patch defuzzed for libvirt 7.0.0]
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
---
src/qemu/qemu_command.c | 6 ++++--
src/qemu/qemu_monitor.c | 14 --------------
src/qemu/qemu_monitor.h | 4 ----
3 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fa40f36cf25..f3462c528ce 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3256,10 +3256,12 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
rc = 0;
}
- if (!(*backendProps = qemuMonitorCreateObjectPropsWrap(backendType, alias,
- &props)))
+ if (virJSONValueObjectPrependString(props, "id", alias) < 0 ||
+ virJSONValueObjectPrependString(props, "qom-type", backendType) < 0)
return -1;
+ *backendProps = g_steal_pointer(&props);
+
return rc;
}
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2e280b82689..4665f451640 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3029,20 +3029,6 @@ qemuMonitorAddDeviceArgs(qemuMonitorPtr mon,
}
-virJSONValuePtr
-qemuMonitorCreateObjectPropsWrap(const char *type,
- const char *alias,
- virJSONValuePtr *props)
-{
- if (virJSONValueObjectPrependString(*props, "id", alias) < 0 ||
- virJSONValueObjectPrependString(*props, "qom-type", type))
- return NULL;
-
- return g_steal_pointer(props);
-}
-
-
-
/**
* qemuMonitorCreateObjectProps:
* @propsret: returns full object properties
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index a46b971a33f..792b74a67ea 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1006,10 +1006,6 @@ int qemuMonitorAddDeviceWithFd(qemuMonitorPtr mon,
int qemuMonitorDelDevice(qemuMonitorPtr mon,
const char *devalias);
-virJSONValuePtr qemuMonitorCreateObjectPropsWrap(const char *type,
- const char *alias,
- virJSONValuePtr *props);
-
int qemuMonitorCreateObjectProps(virJSONValuePtr *propsret,
const char *type,
const char *alias,
--
2.34.1

View File

@ -0,0 +1,49 @@
From 26175ffbda7997115b3a168061e62008d7136bd4 Mon Sep 17 00:00:00 2001
From: Thales Elero Cervi <thaleselero.cervi@windriver.com>
Date: Wed, 18 Sep 2024 19:02:56 -0300
Subject: [PATCH] qemu: monitor: Don't add 'props' wrapper if qemu has
QEMU_CAPS_OBJECT_QAPIFIED
Set 'objectAddNoWrap' when the capability is present.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
[ Patch defuzzed for libvirt 7.0.0]
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
---
src/qemu/qemu_monitor.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 4665f451640..5fb4d32678f 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -32,6 +32,7 @@
#include "qemu_monitor_json.h"
#include "qemu_domain.h"
#include "qemu_process.h"
+#include "qemu_capabilities.h"
#include "virerror.h"
#include "viralloc.h"
#include "virlog.h"
@@ -672,6 +673,7 @@ qemuMonitorOpenInternal(virDomainObjPtr vm,
qemuMonitorCallbacksPtr cb,
void *opaque)
{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
qemuMonitorPtr mon;
g_autoptr(GError) gerr = NULL;
@@ -704,6 +706,9 @@ qemuMonitorOpenInternal(virDomainObjPtr vm,
mon->cb = cb;
mon->callbackOpaque = opaque;
+ if (priv)
+ mon->objectAddNoWrap = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_QAPIFIED);
+
if (virSetCloseExec(mon->fd) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Unable to set monitor close-on-exec flag"));
--
2.34.1

View File

@ -7,3 +7,7 @@
0007-STX-Stop-processing-memory-stats-if-balloon-info.patch
0008-STX-Increase-timeout-for-connecting-to-monitor.patch
0009-STX-pci-sriov-perform-limited-retry-on-netlink.patch
0010-qemu-capabilities-Introduce-QEMU_CAPS_OBJECT_QAPIFIE.patch
0011-qemu-monitor-Make-wrapping-of-props-of-object-add-op.patch
0012-qemuMonitorCreateObjectPropsWrap-Open-code-in-qemuBu.patch
0013-qemu-monitor-Don-t-add-props-wrapper-if-qemu-has-QEM.patch