libvirt/libvirt-qemu-Handle-quirks-of-device-field-of-BLOCK_IO_ERROR-event-in-monitor-code.patch
Jiri Denemark 26e17db3c8 libvirt-10.10.0-6.el9
- build: Bump minimum glib2 version to 2.66.0 (RHEL-77884)
- qemuProcessHandleIOError: Refactor to extract 'priv' instead of 'driver' (RHEL-77884)
- qemu: Handle quirks of 'device' field of BLOCK_IO_ERROR event in monitor code (RHEL-77884)
- qemu: Rename 'diskAlias' to 'device' in qemu IO error event handling (RHEL-77884)
- qemuProcessHandleIOError: Rename local variables (RHEL-77884)
- qemuMonitorJSONHandleIOError: Do not munge 'reason' field of IO error event (RHEL-77884)
- qemuProcessHandleIOError: Prefer lookup by node name (RHEL-77884)
- qemuMonitorJSONHandleIOError: Propagate new 'qom-path' field (RHEL-77884)
- virStorageSource: Add fields for storing last I/O error message (RHEL-77884)
- qemuProcessHandleIOError: Populate I/O error reason to virStorageSource (RHEL-77884)
- qemuProcessHandleIOError: Log IO errors in the VM log file (RHEL-77884)
- libxlDomainGetMessages: Add existing flags to 'virCheckFlags' (RHEL-77884)
- virDomainObjGetMessages: Refactor using GPtrArray (RHEL-77884)
- virDomainGetMessages: Introduce VIR_DOMAIN_MESSAGE_IOERRORS (RHEL-77884)
- include: libvirt-domain: Reword documentation for @reason of VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON (RHEL-77884)
- include: libvirt-domain: Add 'message' @reason of VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON (RHEL-77884)
- qemuSnapshotForEachQcow2: Don't initialize 'nrollback' (RHEL-73315)
- qemu: process: Export qemuPrepareNVRAM for use in snapshot code (RHEL-73315)
- qemu: snapshot: Ensure that NVRAM image exists when taking inactive internal snapshot (RHEL-73315)
- qemuxmlconftest: Allow testing of the 'writable' flag for passed FDs for disks (RHEL-37519)
- qemuxmlconftest: Add testing of FDs with 'writable' flag in 'disk-source-fd' (RHEL-37519)
- qemu: domain: Initialize FD passthrough for a virStorageSource before using it (RHEL-37519)

Resolves: RHEL-37519, RHEL-73315, RHEL-77884
2025-02-07 15:56:31 +01:00

67 lines
2.5 KiB
Diff

From 62e633d298639fd7b7e9c12e6b9d095872c8e6a3 Mon Sep 17 00:00:00 2001
Message-ID: <62e633d298639fd7b7e9c12e6b9d095872c8e6a3.1738940191.git.jdenemar@redhat.com>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 27 Jan 2025 13:03:58 +0100
Subject: [PATCH] qemu: Handle quirks of 'device' field of BLOCK_IO_ERROR event
in monitor code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
BLOCK_IO_ERROR's 'device' field is an empty string in case when it isn't
applicable as it was originally mandatory in the qemu API docs.
Move the logic that convert's empty string back to NULL from
'qemuProcessHandleIOError()' to 'qemuMonitorJSONHandleIOError()'
This also fixes a hypothetical NULL-dereference if qemu would indeed
report an IO error without the 'device' field present.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 2f8359f827ce92e0b454eca55640a928367131fd)
https://issues.redhat.com/browse/RHEL-77884
---
src/qemu/qemu_monitor_json.c | 9 ++++++++-
src/qemu/qemu_process.c | 3 ---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 1b4288b744..345e9383e3 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -708,8 +708,15 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSONValue *data)
action = "ignore";
}
- if ((device = virJSONValueObjectGetString(data, "device")) == NULL)
+ if ((device = virJSONValueObjectGetString(data, "device")) == NULL) {
VIR_WARN("missing device in disk io error event");
+ } else {
+ /* 'device' was documented as mandatory in the qemu event, but later became
+ * optional, in which case an empty string is sent by qemu. Convert it back
+ * to NULL */
+ if (*device == '\0')
+ device = NULL;
+ }
nodename = virJSONValueObjectGetString(data, "node-name");
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c618fbf69c..b4f6d358f3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -840,9 +840,6 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED,
virObjectLock(vm);
priv = QEMU_DOMAIN_PRIVATE(vm);
- if (*diskAlias == '\0')
- diskAlias = NULL;
-
if (diskAlias)
disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL);
else if (nodename)
--
2.48.1