diff --git a/libvirt/debian/patches/0010-qemu-capabilities-Introduce-QEMU_CAPS_OBJECT_QAPIFIE.patch b/libvirt/debian/patches/0010-qemu-capabilities-Introduce-QEMU_CAPS_OBJECT_QAPIFIE.patch new file mode 100644 index 0000000..64fef71 --- /dev/null +++ b/libvirt/debian/patches/0010-qemu-capabilities-Introduce-QEMU_CAPS_OBJECT_QAPIFIE.patch @@ -0,0 +1,54 @@ +From d5f22ad0310e6f8068189647d2f5b45dde662691 Mon Sep 17 00:00:00 2001 +From: Thales Elero Cervi +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 +Reviewed-by: Michal Privoznik +[ Patch defuzzed for libvirt 7.0.0] +Signed-off-by: Thales Elero Cervi +--- + 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 + diff --git a/libvirt/debian/patches/0011-qemu-monitor-Make-wrapping-of-props-of-object-add-op.patch b/libvirt/debian/patches/0011-qemu-monitor-Make-wrapping-of-props-of-object-add-op.patch new file mode 100644 index 0000000..e1140d3 --- /dev/null +++ b/libvirt/debian/patches/0011-qemu-monitor-Make-wrapping-of-props-of-object-add-op.patch @@ -0,0 +1,197 @@ +From 150c1d229e2f3a24784875cb9e7de8b60bee5cb5 Mon Sep 17 00:00:00 2001 +From: Thales Elero Cervi +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 +Reviewed-by: Michal Privoznik +[ Patch defuzzed for libvirt 7.0.0] +Signed-off-by: Thales Elero Cervi +--- + 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 + diff --git a/libvirt/debian/patches/0012-qemuMonitorCreateObjectPropsWrap-Open-code-in-qemuBu.patch b/libvirt/debian/patches/0012-qemuMonitorCreateObjectPropsWrap-Open-code-in-qemuBu.patch new file mode 100644 index 0000000..c1b428e --- /dev/null +++ b/libvirt/debian/patches/0012-qemuMonitorCreateObjectPropsWrap-Open-code-in-qemuBu.patch @@ -0,0 +1,82 @@ +From 4d984701dd6440fdc541fb803e72bd59c1950d4d Mon Sep 17 00:00:00 2001 +From: Thales Elero Cervi +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 +Reviewed-by: Michal Privoznik +[ Patch defuzzed for libvirt 7.0.0] +Signed-off-by: Thales Elero Cervi +--- + 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 + diff --git a/libvirt/debian/patches/0013-qemu-monitor-Don-t-add-props-wrapper-if-qemu-has-QEM.patch b/libvirt/debian/patches/0013-qemu-monitor-Don-t-add-props-wrapper-if-qemu-has-QEM.patch new file mode 100644 index 0000000..2e10ef1 --- /dev/null +++ b/libvirt/debian/patches/0013-qemu-monitor-Don-t-add-props-wrapper-if-qemu-has-QEM.patch @@ -0,0 +1,49 @@ +From 26175ffbda7997115b3a168061e62008d7136bd4 Mon Sep 17 00:00:00 2001 +From: Thales Elero Cervi +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 +Reviewed-by: Michal Privoznik +[ Patch defuzzed for libvirt 7.0.0] +Signed-off-by: Thales Elero Cervi +--- + 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 + diff --git a/libvirt/debian/patches/series b/libvirt/debian/patches/series index 69b145c..1566e31 100644 --- a/libvirt/debian/patches/series +++ b/libvirt/debian/patches/series @@ -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