From a0765b7f70ff43d15a7212d36da29487b8f2cafc Mon Sep 17 00:00:00 2001 From: eabdullin Date: Thu, 16 Nov 2023 14:22:38 +0000 Subject: [PATCH] import CS libvirt-8.0.0-22.module_el8+596+27e96798 --- ...-controller-for-restrictive-numatune.patch | 77 +++++++++ ...-in-virNodeDeviceGetPCIVPDDynamicCap.patch | 52 ++++++ ...bvirt-nodedev-update-transient-mdevs.patch | 79 +++++++++ ...e-struct-_qemuMonitorMessage-private.patch | 105 ++++++++++++ ...elds-from-struct-_qemuMonitorMessage.patch | 44 +++++ ...-_qemuMonitor-to-qemu_monitor_priv.h.patch | 157 ++++++++++++++++++ ...-block-nodes-supports-flat-parameter.patch | 57 +++++++ ...NodeData-Remove-pointless-error-path.patch | 53 ++++++ ...d-memory-check-for-vhostuser-daemons.patch | 65 ++++++++ ...flat-mode-of-query-named-block-nodes.patch | 41 +++++ ...in-virPCIVirtualFunctionList-cleanup.patch | 56 +++++++ SPECS/libvirt.spec | 30 +++- 12 files changed, 815 insertions(+), 1 deletion(-) create mode 100644 SOURCES/libvirt-lib-Set-up-cpuset-controller-for-restrictive-numatune.patch create mode 100644 SOURCES/libvirt-node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch create mode 100644 SOURCES/libvirt-nodedev-update-transient-mdevs.patch create mode 100644 SOURCES/libvirt-qemu-Make-struct-_qemuMonitorMessage-private.patch create mode 100644 SOURCES/libvirt-qemu-monitor-Drop-old-monitor-fields-from-struct-_qemuMonitorMessage.patch create mode 100644 SOURCES/libvirt-qemu-monitor-Move-declaration-of-struct-_qemuMonitor-to-qemu_monitor_priv.h.patch create mode 100644 SOURCES/libvirt-qemu-monitor-Store-whether-query-named-block-nodes-supports-flat-parameter.patch create mode 100644 SOURCES/libvirt-qemu-qemuBlockGetNamedNodeData-Remove-pointless-error-path.patch create mode 100644 SOURCES/libvirt-qemu-relax-shared-memory-check-for-vhostuser-daemons.patch create mode 100644 SOURCES/libvirt-qemuMonitorJSONBlockStatsUpdateCapacityBlockdev-Use-flat-mode-of-query-named-block-nodes.patch create mode 100644 SOURCES/libvirt-virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch diff --git a/SOURCES/libvirt-lib-Set-up-cpuset-controller-for-restrictive-numatune.patch b/SOURCES/libvirt-lib-Set-up-cpuset-controller-for-restrictive-numatune.patch new file mode 100644 index 0000000..e9e7bc6 --- /dev/null +++ b/SOURCES/libvirt-lib-Set-up-cpuset-controller-for-restrictive-numatune.patch @@ -0,0 +1,77 @@ +From 08ddc711a2e6d94a0fce55fec8e012a434655d2c Mon Sep 17 00:00:00 2001 +Message-ID: <08ddc711a2e6d94a0fce55fec8e012a434655d2c.1690812875.git.jdenemar@redhat.com> +From: Michal Privoznik +Date: Fri, 1 Apr 2022 14:30:05 +0200 +Subject: [PATCH] lib: Set up cpuset controller for restrictive numatune +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The aim of 'restrictive' numatune mode is to rely solely on +CGroups to have QEMU running on configured NUMA nodes. However, +we were never setting the cpuset controller when a domain was +starting up. We are doing so only when +virDomainSetNumaParameters() is called (aka live pinning). + +This is obviously wrong. Fortunately, fix is simple as +'restrictive' is similar to 'strict' - every location where +VIR_DOMAIN_NUMATUNE_MEM_STRICT occurs can be audited and +VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE case can be added. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2070380 +Signed-off-by: Michal Privoznik +Reviewed-by: Ján Tomko +(cherry picked from commit 629282d8845407c1aff9a26f5dc026e15121f8cd) + +Conflicts: +- src/ch/ch_process.c: The CH driver diverged because it's + unsupported downstream. Just drop the conflicting hunk from + there. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2223464 +Signed-off-by: Michal Privoznik +--- + src/lxc/lxc_controller.c | 3 ++- + src/qemu/qemu_process.c | 6 ++++-- + 2 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c +index 3c930eaacd..6fd8373256 100644 +--- a/src/lxc/lxc_controller.c ++++ b/src/lxc/lxc_controller.c +@@ -812,7 +812,8 @@ static int virLXCControllerSetupResourceLimits(virLXCController *ctrl) + virDomainNumatuneMemMode mode; + + if (virDomainNumatuneGetMode(ctrl->def->numa, -1, &mode) == 0) { +- if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && ++ if ((mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT || ++ mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) && + virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) { + /* Use virNuma* API iff necessary. Once set and child is exec()-ed, + * there's no way for us to change it. Rely on cgroups (if available +diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c +index 0fb665bc82..73d54f01cd 100644 +--- a/src/qemu/qemu_process.c ++++ b/src/qemu/qemu_process.c +@@ -2645,7 +2645,8 @@ qemuProcessSetupPid(virDomainObj *vm, + virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { + + if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 && +- mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && ++ (mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT || ++ mem_mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) && + virDomainNumatuneMaybeFormatNodeset(vm->def->numa, + priv->autoNodeset, + &mem_mask, -1) < 0) +@@ -3162,7 +3163,8 @@ static int qemuProcessHook(void *data) + goto cleanup; + + if (virDomainNumatuneGetMode(h->vm->def->numa, -1, &mode) == 0) { +- if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && ++ if ((mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT || ++ mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) && + h->cfg->cgroupControllers & (1 << VIR_CGROUP_CONTROLLER_CPUSET) && + virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) { + /* Use virNuma* API iff necessary. Once set and child is exec()-ed, +-- +2.41.0 diff --git a/SOURCES/libvirt-node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch b/SOURCES/libvirt-node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch new file mode 100644 index 0000000..628809a --- /dev/null +++ b/SOURCES/libvirt-node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch @@ -0,0 +1,52 @@ +From 989a569c9c9da0fbf89aab7f292669366b2503f1 Mon Sep 17 00:00:00 2001 +Message-Id: <989a569c9c9da0fbf89aab7f292669366b2503f1@dist-git> +From: Michal Privoznik +Date: Wed, 30 Nov 2022 14:53:21 +0100 +Subject: [PATCH] node_device_conf: Avoid memleak in + virNodeDeviceGetPCIVPDDynamicCap() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The virNodeDeviceGetPCIVPDDynamicCap() function is called from +virNodeDeviceGetPCIDynamicCaps() and therefore has to be a wee +bit more clever about adding VPD capability. Namely, it has to +remove the old one before adding a new one. This is how other +functions called from virNodeDeviceGetPCIDynamicCaps() behave +as well. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143235 +Signed-off-by: Michal Privoznik +Reviewed-by: Peter Krempa +(cherry picked from commit 64d32118540aca3d42bc5ee21c8b780cafe04bfa) +https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2023-2700 +Signed-off-by: Ján Tomko +--- + src/conf/node_device_conf.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 16b9497faf..eee94a3900 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -3100,6 +3100,9 @@ virNodeDeviceGetPCIVPDDynamicCap(virNodeDevCapPCIDev *devCapPCIDev) + virPCIDeviceAddress devAddr; + g_autoptr(virPCIVPDResource) res = NULL; + ++ g_clear_pointer(&devCapPCIDev->vpd, virPCIVPDResourceFree); ++ devCapPCIDev->flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VPD; ++ + devAddr.domain = devCapPCIDev->domain; + devAddr.bus = devCapPCIDev->bus; + devAddr.slot = devCapPCIDev->slot; +@@ -3113,8 +3116,6 @@ virNodeDeviceGetPCIVPDDynamicCap(virNodeDevCapPCIDev *devCapPCIDev) + if ((res = virPCIDeviceGetVPD(pciDev))) { + devCapPCIDev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VPD; + devCapPCIDev->vpd = g_steal_pointer(&res); +- } else { +- virPCIVPDResourceFree(g_steal_pointer(&devCapPCIDev->vpd)); + } + } + return 0; +-- +2.40.1 diff --git a/SOURCES/libvirt-nodedev-update-transient-mdevs.patch b/SOURCES/libvirt-nodedev-update-transient-mdevs.patch new file mode 100644 index 0000000..f32e5a5 --- /dev/null +++ b/SOURCES/libvirt-nodedev-update-transient-mdevs.patch @@ -0,0 +1,79 @@ +From aebcc09c7060f6eace93821c6a782031cf107d85 Mon Sep 17 00:00:00 2001 +Message-ID: +From: Boris Fiuczynski +Date: Mon, 8 May 2023 19:10:46 +0200 +Subject: [PATCH] nodedev: update transient mdevs + +Instead of updating defined mdevs only add another update for active +devices as well to cover transient mdev devices as well. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143158 +Signed-off-by: Boris Fiuczynski +Reviewed-by: Jonathon Jongsma + +Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2143160 + +(cherry picked from commit 44a0f2f0c8ff5e78c238013ed297b8fce223ac5a) +Signed-off-by: Jonathon Jongsma +--- + src/node_device/node_device_driver.c | 31 ++++++++++++++++++++++++++++ + 1 file changed, 31 insertions(+) + +diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c +index e6ab4bb94c..943f6121a0 100644 +--- a/src/node_device/node_device_driver.c ++++ b/src/node_device/node_device_driver.c +@@ -1651,6 +1651,24 @@ virMdevctlListDefined(virNodeDeviceDef ***devs, char **errmsg) + } + + ++static int ++virMdevctlListActive(virNodeDeviceDef ***devs, char **errmsg) ++{ ++ int status; ++ g_autofree char *output = NULL; ++ g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlListCommand(false, &output, errmsg); ++ ++ if (virCommandRun(cmd, &status) < 0 || status != 0) { ++ return -1; ++ } ++ ++ if (!output) ++ return -1; ++ ++ return nodeDeviceParseMdevctlJSON(output, devs); ++} ++ ++ + typedef struct _virMdevctlForEachData virMdevctlForEachData; + struct _virMdevctlForEachData { + int ndefs; +@@ -1712,6 +1730,8 @@ int + nodeDeviceUpdateMediatedDevices(void) + { + g_autofree virNodeDeviceDef **defs = NULL; ++ g_autofree virNodeDeviceDef **act_defs = NULL; ++ int act_ndefs = 0; + g_autofree char *errmsg = NULL; + g_autofree char *mdevctl = NULL; + virMdevctlForEachData data = { 0, }; +@@ -1738,6 +1758,17 @@ nodeDeviceUpdateMediatedDevices(void) + if (nodeDeviceUpdateMediatedDevice(defs[i]) < 0) + return -1; + ++ /* Update active/transient mdev devices */ ++ if ((act_ndefs = virMdevctlListActive(&act_defs, &errmsg)) < 0) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("failed to query mdevs from mdevctl: %1$s"), errmsg); ++ return -1; ++ } ++ ++ for (i = 0; i < act_ndefs; i++) ++ if (nodeDeviceUpdateMediatedDevice(act_defs[i]) < 0) ++ return -1; ++ + return 0; + } + +-- +2.41.0 diff --git a/SOURCES/libvirt-qemu-Make-struct-_qemuMonitorMessage-private.patch b/SOURCES/libvirt-qemu-Make-struct-_qemuMonitorMessage-private.patch new file mode 100644 index 0000000..ffd8ae6 --- /dev/null +++ b/SOURCES/libvirt-qemu-Make-struct-_qemuMonitorMessage-private.patch @@ -0,0 +1,105 @@ +From 85b7d8295d72214b08f0fff93c473baaa88a569b Mon Sep 17 00:00:00 2001 +Message-Id: <85b7d8295d72214b08f0fff93c473baaa88a569b@dist-git> +From: Peter Krempa +Date: Mon, 14 Feb 2022 15:57:21 +0100 +Subject: [PATCH] qemu: Make 'struct _qemuMonitorMessage' private +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Move the declaration of the struct into 'qemu_monitor_priv.h' as other +code has no business in peeking into the monitor messages. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit f9ae469a6ebb17e0990096e826f049c1c46cd760) +https://bugzilla.redhat.com/show_bug.cgi?id=2170472 +--- + src/qemu/qemu_monitor.h | 14 -------------- + src/qemu/qemu_monitor_json.c | 3 +++ + src/qemu/qemu_monitor_priv.h | 16 ++++++++++++++++ + tests/qemucapsprobemock.c | 3 +++ + 4 files changed, 22 insertions(+), 14 deletions(-) + +diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h +index a4a4edf5a6..d00967d84f 100644 +--- a/src/qemu/qemu_monitor.h ++++ b/src/qemu/qemu_monitor.h +@@ -34,21 +34,7 @@ + #include "virenum.h" + + typedef struct _qemuMonitor qemuMonitor; +- + typedef struct _qemuMonitorMessage qemuMonitorMessage; +-struct _qemuMonitorMessage { +- int txFD; +- +- const char *txBuffer; +- int txOffset; +- int txLength; +- +- /* Used by the JSON monitor to hold reply / error */ +- void *rxObject; +- +- /* True if rxObject is ready, or a fatal error occurred on the monitor channel */ +- bool finished; +-}; + + typedef enum { + QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE = 0, +diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c +index 34a46b9b41..7d8755246f 100644 +--- a/src/qemu/qemu_monitor_json.c ++++ b/src/qemu/qemu_monitor_json.c +@@ -44,6 +44,9 @@ + # include "libvirt_qemu_probes.h" + #endif + ++#define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW ++#include "qemu_monitor_priv.h" ++ + #define VIR_FROM_THIS VIR_FROM_QEMU + + VIR_LOG_INIT("qemu.qemu_monitor_json"); +diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h +index 31bb3526b9..6115f830de 100644 +--- a/src/qemu/qemu_monitor_priv.h ++++ b/src/qemu/qemu_monitor_priv.h +@@ -24,5 +24,21 @@ + + #include "qemu_monitor.h" + ++ ++struct _qemuMonitorMessage { ++ int txFD; ++ ++ const char *txBuffer; ++ int txOffset; ++ int txLength; ++ ++ /* Used by the JSON monitor to hold reply / error */ ++ void *rxObject; ++ ++ /* True if rxObject is ready, or a fatal error occurred on the monitor channel */ ++ bool finished; ++}; ++ ++ + void + qemuMonitorResetCommandID(qemuMonitor *mon); +diff --git a/tests/qemucapsprobemock.c b/tests/qemucapsprobemock.c +index 915036d178..2717ed5d84 100644 +--- a/tests/qemucapsprobemock.c ++++ b/tests/qemucapsprobemock.c +@@ -25,6 +25,9 @@ + #include "qemu/qemu_monitor.h" + #include "qemu/qemu_monitor_json.h" + ++#define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW ++#include "qemu/qemu_monitor_priv.h" ++ + #define REAL_SYM(realFunc) \ + do { \ + if (!realFunc && !(realFunc = dlsym(RTLD_NEXT, __FUNCTION__))) { \ +-- +2.40.1 diff --git a/SOURCES/libvirt-qemu-monitor-Drop-old-monitor-fields-from-struct-_qemuMonitorMessage.patch b/SOURCES/libvirt-qemu-monitor-Drop-old-monitor-fields-from-struct-_qemuMonitorMessage.patch new file mode 100644 index 0000000..f436915 --- /dev/null +++ b/SOURCES/libvirt-qemu-monitor-Drop-old-monitor-fields-from-struct-_qemuMonitorMessage.patch @@ -0,0 +1,44 @@ +From a4d8210ae9fd84740e01b96d28bfb6183f3f3270 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Mon, 14 Feb 2022 16:02:29 +0100 +Subject: [PATCH] qemu: monitor: Drop old monitor fields from 'struct + _qemuMonitorMessage' +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The fields are no longer used since we've deleted support for HMP-only +qemus. The HMP command pass-through works via a QMP command. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit c5eb99a9d9af8683789e99cc904671e343580058) +https://bugzilla.redhat.com/show_bug.cgi?id=2170472 +--- + src/qemu/qemu_monitor.h | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h +index d2037914be..a4a4edf5a6 100644 +--- a/src/qemu/qemu_monitor.h ++++ b/src/qemu/qemu_monitor.h +@@ -43,15 +43,10 @@ struct _qemuMonitorMessage { + int txOffset; + int txLength; + +- /* Used by the text monitor reply / error */ +- char *rxBuffer; +- int rxLength; + /* Used by the JSON monitor to hold reply / error */ + void *rxObject; + +- /* True if rxBuffer / rxObject are ready, or a +- * fatal error occurred on the monitor channel +- */ ++ /* True if rxObject is ready, or a fatal error occurred on the monitor channel */ + bool finished; + }; + +-- +2.40.1 diff --git a/SOURCES/libvirt-qemu-monitor-Move-declaration-of-struct-_qemuMonitor-to-qemu_monitor_priv.h.patch b/SOURCES/libvirt-qemu-monitor-Move-declaration-of-struct-_qemuMonitor-to-qemu_monitor_priv.h.patch new file mode 100644 index 0000000..145de29 --- /dev/null +++ b/SOURCES/libvirt-qemu-monitor-Move-declaration-of-struct-_qemuMonitor-to-qemu_monitor_priv.h.patch @@ -0,0 +1,157 @@ +From c2ed5aeee7bf365877e0764699f032fb749630b0 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Mon, 14 Feb 2022 16:07:41 +0100 +Subject: [PATCH] qemu: monitor: Move declaration of struct _qemuMonitor to + qemu_monitor_priv.h +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +In order to mock the SCM_RIGHTS sendmsg to simulate sending +filedescriptors to fake qemu in tests we need access to some fields of +'struct _qemuMonitor'. Move its declaration to the private header file. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit 7c35c483eaa78eb847e0865cbb210d5355f75d7a) +https://bugzilla.redhat.com/show_bug.cgi?id=2170472 +--- + src/qemu/qemu_monitor.c | 50 --------------------------------- + src/qemu/qemu_monitor_priv.h | 54 ++++++++++++++++++++++++++++++++++++ + 2 files changed, 54 insertions(+), 50 deletions(-) + +diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c +index 23638d3fe8..bba92592c5 100644 +--- a/src/qemu/qemu_monitor.c ++++ b/src/qemu/qemu_monitor.c +@@ -65,56 +65,6 @@ VIR_LOG_INIT("qemu.qemu_monitor"); + */ + #define QEMU_MONITOR_MAX_RESPONSE (10 * 1024 * 1024) + +-struct _qemuMonitor { +- virObjectLockable parent; +- +- virCond notify; +- +- int fd; +- +- GMainContext *context; +- GSocket *socket; +- GSource *watch; +- +- virDomainObj *vm; +- char *domainName; +- +- qemuMonitorCallbacks *cb; +- void *callbackOpaque; +- +- /* If there's a command being processed this will be +- * non-NULL */ +- qemuMonitorMessage *msg; +- +- /* Buffer incoming data ready for Text/QMP monitor +- * code to process & find message boundaries */ +- size_t bufferOffset; +- size_t bufferLength; +- char *buffer; +- +- /* If anything went wrong, this will be fed back +- * the next monitor msg */ +- virError lastError; +- +- /* Set to true when EOF is detected on the monitor */ +- bool goteof; +- +- int nextSerial; +- +- bool waitGreeting; +- +- /* If found, path to the virtio memballoon driver */ +- char *balloonpath; +- bool ballooninit; +- +- /* Log file context of the qemu process to dig for usable info */ +- qemuMonitorReportDomainLogError logFunc; +- void *logOpaque; +- virFreeCallback logDestroy; +- +- /* true if qemu no longer wants 'props' sub-object of object-add */ +- bool objectAddNoWrap; +-}; + + /** + * QEMU_CHECK_MONITOR_FULL: +diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h +index 6115f830de..606aa79fbd 100644 +--- a/src/qemu/qemu_monitor_priv.h ++++ b/src/qemu/qemu_monitor_priv.h +@@ -24,6 +24,8 @@ + + #include "qemu_monitor.h" + ++#include ++ + + struct _qemuMonitorMessage { + int txFD; +@@ -40,5 +42,57 @@ struct _qemuMonitorMessage { + }; + + ++struct _qemuMonitor { ++ virObjectLockable parent; ++ ++ virCond notify; ++ ++ int fd; ++ ++ GMainContext *context; ++ GSocket *socket; ++ GSource *watch; ++ ++ virDomainObj *vm; ++ char *domainName; ++ ++ qemuMonitorCallbacks *cb; ++ void *callbackOpaque; ++ ++ /* If there's a command being processed this will be ++ * non-NULL */ ++ qemuMonitorMessage *msg; ++ ++ /* Buffer incoming data ready for Text/QMP monitor ++ * code to process & find message boundaries */ ++ size_t bufferOffset; ++ size_t bufferLength; ++ char *buffer; ++ ++ /* If anything went wrong, this will be fed back ++ * the next monitor msg */ ++ virError lastError; ++ ++ /* Set to true when EOF is detected on the monitor */ ++ bool goteof; ++ ++ int nextSerial; ++ ++ bool waitGreeting; ++ ++ /* If found, path to the virtio memballoon driver */ ++ char *balloonpath; ++ bool ballooninit; ++ ++ /* Log file context of the qemu process to dig for usable info */ ++ qemuMonitorReportDomainLogError logFunc; ++ void *logOpaque; ++ virFreeCallback logDestroy; ++ ++ /* true if qemu no longer wants 'props' sub-object of object-add */ ++ bool objectAddNoWrap; ++}; ++ ++ + void + qemuMonitorResetCommandID(qemuMonitor *mon); +-- +2.40.1 diff --git a/SOURCES/libvirt-qemu-monitor-Store-whether-query-named-block-nodes-supports-flat-parameter.patch b/SOURCES/libvirt-qemu-monitor-Store-whether-query-named-block-nodes-supports-flat-parameter.patch new file mode 100644 index 0000000..23ee422 --- /dev/null +++ b/SOURCES/libvirt-qemu-monitor-Store-whether-query-named-block-nodes-supports-flat-parameter.patch @@ -0,0 +1,57 @@ +From b3ffc8876adf777c7baefb6e467d7552c0a03251 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Wed, 9 Nov 2022 10:53:49 +0100 +Subject: [PATCH] qemu: monitor: Store whether 'query-named-block-nodes' + supports 'flat' parameter +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Rather than having callers always pass this flag store it in the +qemuMonitor object. Following patches will convert the code to use this +internal flag. + +In the future this will also simplify removal when all supported qemu +versions will support the new mode. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit b0e4ad5263c73a926b8246028c76c552b07fca74) +https://bugzilla.redhat.com/show_bug.cgi?id=2170472 +--- + src/qemu/qemu_monitor.c | 4 +++- + src/qemu/qemu_monitor_priv.h | 2 ++ + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c +index bba92592c5..99667fdf2f 100644 +--- a/src/qemu/qemu_monitor.c ++++ b/src/qemu/qemu_monitor.c +@@ -610,8 +610,10 @@ qemuMonitorOpenInternal(virDomainObj *vm, + mon->cb = cb; + mon->callbackOpaque = opaque; + +- if (priv) ++ if (priv) { + mon->objectAddNoWrap = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_JSON); ++ mon->queryNamedBlockNodesFlat = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT); ++ } + + if (virSetCloseExec(mon->fd) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, +diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h +index 606aa79fbd..e32928805f 100644 +--- a/src/qemu/qemu_monitor_priv.h ++++ b/src/qemu/qemu_monitor_priv.h +@@ -91,6 +91,8 @@ struct _qemuMonitor { + + /* true if qemu no longer wants 'props' sub-object of object-add */ + bool objectAddNoWrap; ++ /* query-named-block-nodes supports the 'flat' option */ ++ bool queryNamedBlockNodesFlat; + }; + + +-- +2.40.1 diff --git a/SOURCES/libvirt-qemu-qemuBlockGetNamedNodeData-Remove-pointless-error-path.patch b/SOURCES/libvirt-qemu-qemuBlockGetNamedNodeData-Remove-pointless-error-path.patch new file mode 100644 index 0000000..ac8b3e2 --- /dev/null +++ b/SOURCES/libvirt-qemu-qemuBlockGetNamedNodeData-Remove-pointless-error-path.patch @@ -0,0 +1,53 @@ +From 31986239312c0e460800f5b9921f6593f1556015 Mon Sep 17 00:00:00 2001 +Message-Id: <31986239312c0e460800f5b9921f6593f1556015@dist-git> +From: Peter Krempa +Date: Wed, 9 Nov 2022 10:45:27 +0100 +Subject: [PATCH] qemu: qemuBlockGetNamedNodeData: Remove pointless error path +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We don't need automatic freeing for 'blockNamedNodeData' and we can +directly return it rather than checking it for NULL-ness first. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit 3fe74ebd9037d695df906ed137d22a8d8d77e169) + + Conflicts: + src/qemu/qemu_block.c + + - qemuDomainObjEnter/ExitMonitor still needs 'driver' + +https://bugzilla.redhat.com/show_bug.cgi?id=2170472 +--- + src/qemu/qemu_block.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c +index aa566d0097..c9229d1918 100644 +--- a/src/qemu/qemu_block.c ++++ b/src/qemu/qemu_block.c +@@ -3020,7 +3020,7 @@ qemuBlockGetNamedNodeData(virDomainObj *vm, + { + qemuDomainObjPrivate *priv = vm->privateData; + virQEMUDriver *driver = priv->driver; +- g_autoptr(GHashTable) blockNamedNodeData = NULL; ++ GHashTable *blockNamedNodeData = NULL; + bool supports_flat = virQEMUCapsGet(priv->qemuCaps, + QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT); + +@@ -3031,10 +3031,7 @@ qemuBlockGetNamedNodeData(virDomainObj *vm, + + qemuDomainObjExitMonitor(driver, vm); + +- if (!blockNamedNodeData) +- return NULL; +- +- return g_steal_pointer(&blockNamedNodeData); ++ return blockNamedNodeData; + } + + +-- +2.40.1 diff --git a/SOURCES/libvirt-qemu-relax-shared-memory-check-for-vhostuser-daemons.patch b/SOURCES/libvirt-qemu-relax-shared-memory-check-for-vhostuser-daemons.patch new file mode 100644 index 0000000..ae3ebae --- /dev/null +++ b/SOURCES/libvirt-qemu-relax-shared-memory-check-for-vhostuser-daemons.patch @@ -0,0 +1,65 @@ +From e9418cec1ba24b6cf78f85bbbef8586ed612692a Mon Sep 17 00:00:00 2001 +Message-Id: +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Mon, 13 Mar 2023 13:56:47 +0100 +Subject: [PATCH] qemu: relax shared memory check for vhostuser daemons +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +For some vhostuser daemons, we validate that the guest memory is shared +with the host. + +With earlier versions of QEMU, it was only possible to mark memory +as shared by defining an explicit NUMA topology. Later, QEMU exposed +the name of the default memory backend (defaultRAMid) so we can mark +that memory as shared. + +Since libvirt commit: + commit bff2ad5d6b1f25da02802273934d2a519159fec7 + qemu: Relax validation for mem->access if guest has no NUMA +we already check for the case when user requests shared memory, +but QEMU did not expose defaultRAMid. + +Drop the duplicit check from vhostuser device validation, to make +it pass on hotplug even after libvirtd restart. + +This avoids the need to store the defaultRAMid, since we don't really +need it for anything after the VM has been already started. + +https://bugzilla.redhat.com/show_bug.cgi?id=2078693 +https://bugzilla.redhat.com/show_bug.cgi?id=2177701 + +Signed-off-by: Ján Tomko +Reviewed-by: Michal Privoznik +(cherry picked from commit d5c7b7870e45575f81fffcb611c2546d0e02e778) +Signed-off-by: Ján Tomko +--- + src/qemu/qemu_validate.c | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c +index 7bc14293d6..4069f47c12 100644 +--- a/src/qemu/qemu_validate.c ++++ b/src/qemu/qemu_validate.c +@@ -1588,16 +1588,12 @@ qemuValidateDomainVirtioOptions(const virDomainVirtioOptions *virtio, + static int + qemuValidateDomainDefVhostUserRequireSharedMemory(const virDomainDef *def, + const char *name, +- virQEMUCaps *qemuCaps) ++ virQEMUCaps *qemuCaps G_GNUC_UNUSED) + { +- const char *defaultRAMId = virQEMUCapsGetMachineDefaultRAMid(qemuCaps, +- def->virtType, +- def->os.machine); + size_t numa_nodes = virDomainNumaGetNodeCount(def->numa); + size_t i; + +- if (numa_nodes == 0 && +- !(defaultRAMId && def->mem.access == VIR_DOMAIN_MEMORY_ACCESS_SHARED)) { ++ if (numa_nodes == 0 && def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_SHARED) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("'%s' requires shared memory"), name); + return -1; +-- +2.40.1 diff --git a/SOURCES/libvirt-qemuMonitorJSONBlockStatsUpdateCapacityBlockdev-Use-flat-mode-of-query-named-block-nodes.patch b/SOURCES/libvirt-qemuMonitorJSONBlockStatsUpdateCapacityBlockdev-Use-flat-mode-of-query-named-block-nodes.patch new file mode 100644 index 0000000..a143d04 --- /dev/null +++ b/SOURCES/libvirt-qemuMonitorJSONBlockStatsUpdateCapacityBlockdev-Use-flat-mode-of-query-named-block-nodes.patch @@ -0,0 +1,41 @@ +From f20062e1fe1e7bca8b97d2383f9e8a06f0f4111a Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Wed, 9 Nov 2022 11:06:25 +0100 +Subject: [PATCH] qemuMonitorJSONBlockStatsUpdateCapacityBlockdev: Use 'flat' + mode of query-named-block-nodes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +'query-named-block-nodes' in non-flat mode returns redundantly nested +data under the 'backing-image' field. Fortunately we don't need it when +updating the capacity stats. + +This function was unfortunately not fixed originally when the support +for flat mode was added. Use the flat cached in the monitor object to +force flat mode if available. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit bbd4d4899391b3bd1906cce61a3634f42f4b1bdf) +https://bugzilla.redhat.com/show_bug.cgi?id=2170472 +--- + src/qemu/qemu_monitor_json.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c +index 7d8755246f..789554e225 100644 +--- a/src/qemu/qemu_monitor_json.c ++++ b/src/qemu/qemu_monitor_json.c +@@ -2679,7 +2679,7 @@ qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuMonitor *mon, + { + g_autoptr(virJSONValue) nodes = NULL; + +- if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon, false))) ++ if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon, mon->queryNamedBlockNodesFlat))) + return -1; + + if (virJSONValueArrayForeachSteal(nodes, +-- +2.40.1 diff --git a/SOURCES/libvirt-virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch b/SOURCES/libvirt-virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch new file mode 100644 index 0000000..ffc4a36 --- /dev/null +++ b/SOURCES/libvirt-virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch @@ -0,0 +1,56 @@ +From 0e91f4dc214d01e9d9537b1111ce67010530fd20 Mon Sep 17 00:00:00 2001 +Message-Id: <0e91f4dc214d01e9d9537b1111ce67010530fd20@dist-git> +From: Tim Shearer +Date: Mon, 1 May 2023 13:15:48 +0000 +Subject: [PATCH] virpci: Resolve leak in virPCIVirtualFunctionList cleanup +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Repeatedly querying an SR-IOV PCI device's capabilities exposes a +memory leak caused by a failure to free the virPCIVirtualFunction +array within the parent struct's g_autoptr cleanup. + +Valgrind output after getting a single interface's XML description +1000 times: + +==325982== 256,000 bytes in 1,000 blocks are definitely lost in loss record 2,634 of 2,635 +==325982== at 0x4C3C096: realloc (vg_replace_malloc.c:1437) +==325982== by 0x59D952D: g_realloc (in /usr/lib64/libglib-2.0.so.0.5600.4) +==325982== by 0x4EE1F52: virReallocN (viralloc.c:52) +==325982== by 0x4EE1FB7: virExpandN (viralloc.c:78) +==325982== by 0x4EE219A: virInsertElementInternal (viralloc.c:183) +==325982== by 0x4EE23B2: virAppendElement (viralloc.c:288) +==325982== by 0x4F65D85: virPCIGetVirtualFunctionsFull (virpci.c:2389) +==325982== by 0x4F65753: virPCIGetVirtualFunctions (virpci.c:2256) +==325982== by 0x505CB75: virNodeDeviceGetPCISRIOVCaps (node_device_conf.c:2969) +==325982== by 0x505D181: virNodeDeviceGetPCIDynamicCaps (node_device_conf.c:3099) +==325982== by 0x505BC4E: virNodeDeviceUpdateCaps (node_device_conf.c:2677) +==325982== by 0x260FCBB2: nodeDeviceGetXMLDesc (node_device_driver.c:355) + +Signed-off-by: Tim Shearer +Reviewed-by: Ján Tomko +(cherry picked from commit 6425a311b8ad19d6f9c0b315bf1d722551ea3585) + +https://bugzilla.redhat.com/show_bug.cgi?id=2196351 +https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2023-2700 + +Signed-off-by: Ján Tomko +--- + src/util/virpci.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/util/virpci.c b/src/util/virpci.c +index 4949d1a3d4..2714d11a7d 100644 +--- a/src/util/virpci.c ++++ b/src/util/virpci.c +@@ -2255,6 +2255,7 @@ virPCIVirtualFunctionListFree(virPCIVirtualFunctionList *list) + g_free(list->functions[i].ifname); + } + ++ g_free(list->functions); + g_free(list); + } + +-- +2.40.1 diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec index bf8f899..e2d6779 100644 --- a/SPECS/libvirt.spec +++ b/SPECS/libvirt.spec @@ -210,7 +210,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 8.0.0 -Release: 19%{?dist}%{?extra_release} +Release: 22%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -306,6 +306,17 @@ Patch83: libvirt-vircpi-Add-PCIe-5.0-and-6.0-link-speeds.patch Patch84: libvirt-conf-Make-VIR_DOMAIN_NET_TYPE_ETHERNET-not-share-host-view.patch Patch85: libvirt-qemu-domain-Fix-logic-when-tainting-domain.patch Patch86: libvirt-qemu-agent-Make-fetching-of-can-offline-member-from-guest-query-vcpus-optional.patch +Patch87: libvirt-qemu-monitor-Drop-old-monitor-fields-from-struct-_qemuMonitorMessage.patch +Patch88: libvirt-qemu-Make-struct-_qemuMonitorMessage-private.patch +Patch89: libvirt-qemu-monitor-Move-declaration-of-struct-_qemuMonitor-to-qemu_monitor_priv.h.patch +Patch90: libvirt-qemu-qemuBlockGetNamedNodeData-Remove-pointless-error-path.patch +Patch91: libvirt-qemu-monitor-Store-whether-query-named-block-nodes-supports-flat-parameter.patch +Patch92: libvirt-qemuMonitorJSONBlockStatsUpdateCapacityBlockdev-Use-flat-mode-of-query-named-block-nodes.patch +Patch93: libvirt-qemu-relax-shared-memory-check-for-vhostuser-daemons.patch +Patch94: libvirt-virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch +Patch95: libvirt-node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch +Patch96: libvirt-nodedev-update-transient-mdevs.patch +Patch97: libvirt-lib-Set-up-cpuset-controller-for-restrictive-numatune.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2185,6 +2196,23 @@ exit 0 %changelog +* Mon Jul 31 2023 Jiri Denemark - 8.0.0-22 +- lib: Set up cpuset controller for restrictive numatune (rhbz#2223464) + +* Thu Jun 22 2023 Jiri Denemark - 8.0.0-21 +- nodedev: update transient mdevs (rhbz#2143160) + +* Fri May 19 2023 Jiri Denemark - 8.0.0-20 +- qemu: monitor: Drop old monitor fields from 'struct _qemuMonitorMessage' (rhbz#2170472) +- qemu: Make 'struct _qemuMonitorMessage' private (rhbz#2170472) +- qemu: monitor: Move declaration of struct _qemuMonitor to qemu_monitor_priv.h (rhbz#2170472) +- qemu: qemuBlockGetNamedNodeData: Remove pointless error path (rhbz#2170472) +- qemu: monitor: Store whether 'query-named-block-nodes' supports 'flat' parameter (rhbz#2170472) +- qemuMonitorJSONBlockStatsUpdateCapacityBlockdev: Use 'flat' mode of query-named-block-nodes (rhbz#2170472) +- qemu: relax shared memory check for vhostuser daemons (rhbz#2177701) +- virpci: Resolve leak in virPCIVirtualFunctionList cleanup (CVE-2023-2700) +- node_device_conf: Avoid memleak in virNodeDeviceGetPCIVPDDynamicCap() (CVE-2023-2700) + * Tue Mar 14 2023 Jiri Denemark - 8.0.0-19 - qemu: domain: Fix logic when tainting domain (rhbz#2174447) - qemu: agent: Make fetching of 'can-offline' member from 'guest-query-vcpus' optional (rhbz#2174447)