[PATCH v2 05/15] qemuProcessHandleIOError: Prefer lookup by node name

Peter Krempa posted 15 patches 7 months, 1 week ago
[PATCH v2 05/15] qemuProcessHandleIOError: Prefer lookup by node name
Posted by Peter Krempa 7 months, 1 week ago
When qemu reports a node name for an I/O error we should prefer the
lookup by node name instead as it gives us the path to the specific
image which caused the error instead of the top level image path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_process.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 80a73643f0..1849f68634 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -837,22 +837,26 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED,
     const char *eventPath = "";
     const char *eventAlias = "";
     const char *eventReason = "";
-    virDomainDiskDef *disk;
+    virDomainDiskDef *disk = NULL;
+    virStorageSource *src = NULL;

     virObjectLock(vm);
     priv = QEMU_DOMAIN_PRIVATE(vm);

-    if (device)
+    if (nodename)
+        disk = qemuDomainDiskLookupByNodename(vm->def, priv->backup, nodename, &src);
+
+    if (!disk)
         disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, device, NULL);
-    else if (nodename)
-        disk = qemuDomainDiskLookupByNodename(vm->def, NULL, nodename, NULL);
-    else
-        disk = NULL;

-    if (disk) {
-        eventPath = virDomainDiskGetSource(disk);
+    if (!src && disk)
+        src = disk->src;
+
+    if (disk)
         eventAlias = disk->info.alias;
-    }
+
+    if (src && src->path)
+        eventPath = src->path;

     if (nospace)
         eventReason = "enospc";
-- 
2.48.1
Re: [PATCH v2 05/15] qemuProcessHandleIOError: Prefer lookup by node name
Posted by Daniel P. Berrangé 7 months, 1 week ago
On Tue, Jan 28, 2025 at 05:28:09PM +0100, Peter Krempa wrote:
> When qemu reports a node name for an I/O error we should prefer the
> lookup by node name instead as it gives us the path to the specific
> image which caused the error instead of the top level image path.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_process.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With 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 :|