]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainGetStatsIOThread: Don't error out if fetching iothread info fails
authorPeter Krempa <pkrempa@redhat.com>
Mon, 17 Feb 2025 13:22:46 +0000 (14:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Feb 2025 14:15:41 +0000 (15:15 +0100)
The bulk domain stats API is meant to collect as much data as possible
without erroring out. Ignore errors from 'qemuDomainGetIOThreadsMon()'
and skip the data if an error happens.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index 8d413fc4dfd9edd1880db553f9105cfad1d4c9b9..e513223de2bb2b7b66de773a7cdf5071fb95bc24 100644 (file)
@@ -17531,22 +17531,21 @@ qemuDomainGetStatsIOThread(virQEMUDriver *driver G_GNUC_UNUSED,
                            unsigned int privflags)
 {
     size_t i;
-    qemuMonitorIOThreadInfo **iothreads = NULL;
+    g_autofree qemuMonitorIOThreadInfo **iothreads = NULL;
     int niothreads = 0;
-    int ret = -1;
 
     if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom))
         return 0;
 
-    if (qemuDomainGetIOThreadsMon(dom, &iothreads, &niothreads) < 0)
-        return -1;
+    if (qemuDomainGetIOThreadsMon(dom, &iothreads, &niothreads) < 0) {
+        virResetLastError();
+        return 0;
+    }
 
     /* qemuDomainGetIOThreadsMon returns a NULL-terminated list, so we must free
      * it even if it returns 0 */
-    if (niothreads == 0) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (niothreads == 0)
+        return 0;
 
     virTypedParamListAddUInt(params, niothreads, "iothread.count");
 
@@ -17564,14 +17563,10 @@ qemuDomainGetStatsIOThread(virQEMUDriver *driver G_GNUC_UNUSED,
         }
     }
 
-    ret = 0;
-
- cleanup:
     for (i = 0; i < niothreads; i++)
         VIR_FREE(iothreads[i]);
-    VIR_FREE(iothreads);
 
-    return ret;
+    return 0;
 }