d759b5
From 829716665e195f34e484c1aec691a02d5035ae3a Mon Sep 17 00:00:00 2001
d759b5
Message-Id: <829716665e195f34e484c1aec691a02d5035ae3a@dist-git>
d759b5
From: Peter Krempa <pkrempa@redhat.com>
d759b5
Date: Fri, 16 Aug 2019 14:36:57 +0200
d759b5
Subject: [PATCH] qemu: Allow suppressing errors from qemuStorageLimitsRefresh
d759b5
MIME-Version: 1.0
d759b5
Content-Type: text/plain; charset=UTF-8
d759b5
Content-Transfer-Encoding: 8bit
d759b5
d759b5
qemuStorageLimitsRefresh uses qemuDomainStorageOpenStat internally and
d759b5
there are callers which don't care about the error. Propagate the
d759b5
skipInaccessible flag so that we can log less errors.
d759b5
d759b5
Callers currently don't care about the return value change.
d759b5
d759b5
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d759b5
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d759b5
(cherry picked from commit ea26e22f94cea989b566e13e1930d76e06baf2c9)
d759b5
https: //bugzilla.redhat.com/show_bug.cgi?id=1724808
d759b5
Message-Id: <dd9323d0f10b7ad2992c389d37d1a643040ba743.1565958906.git.pkrempa@redhat.com>
d759b5
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d759b5
---
d759b5
 src/qemu/qemu_driver.c | 20 +++++++++++++-------
d759b5
 1 file changed, 13 insertions(+), 7 deletions(-)
d759b5
d759b5
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
d759b5
index 72c75e308b..88a9f565c4 100644
d759b5
--- a/src/qemu/qemu_driver.c
d759b5
+++ b/src/qemu/qemu_driver.c
d759b5
@@ -11894,6 +11894,7 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver,
d759b5
  * @cfg: driver configuration data
d759b5
  * @vm: domain object
d759b5
  * @src: storage source data
d759b5
+ * @skipInaccessible: Suppress reporting of common errors when accessing @src
d759b5
  *
d759b5
  * Refresh the capacity and allocation limits of a given storage source.
d759b5
  *
d759b5
@@ -11915,22 +11916,27 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver,
d759b5
  * is sparse, but the amount of sparseness changes due to writes or
d759b5
  * punching holes), and physical size of a non-raw file can change.
d759b5
  *
d759b5
- * Returns 0 on success, -1 on failure
d759b5
+ * Returns 1 if @src was successfully updated, 0 if @src can't be opened and
d759b5
+ * @skipInaccessible is true (no errors are reported) or -1 otherwise (errors
d759b5
+ * are reported).
d759b5
  */
d759b5
 static int
d759b5
 qemuStorageLimitsRefresh(virQEMUDriverPtr driver,
d759b5
                          virQEMUDriverConfigPtr cfg,
d759b5
                          virDomainObjPtr vm,
d759b5
-                         virStorageSourcePtr src)
d759b5
+                         virStorageSourcePtr src,
d759b5
+                         bool skipInaccessible)
d759b5
 {
d759b5
+    int rc;
d759b5
     int ret = -1;
d759b5
     int fd = -1;
d759b5
     struct stat sb;
d759b5
     char *buf = NULL;
d759b5
     ssize_t len;
d759b5
 
d759b5
-    if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) < 0)
d759b5
-        goto cleanup;
d759b5
+    if ((rc = qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb,
d759b5
+                                        skipInaccessible)) <= 0)
d759b5
+        return rc;
d759b5
 
d759b5
     if (virStorageSourceIsLocalStorage(src)) {
d759b5
         if ((len = virFileReadHeaderFD(fd, VIR_STORAGE_MAX_HEADER, &buf)) < 0) {
d759b5
@@ -11958,7 +11964,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver,
d759b5
         S_ISBLK(sb.st_mode))
d759b5
         src->allocation = 0;
d759b5
 
d759b5
-    ret = 0;
d759b5
+    ret = 1;
d759b5
 
d759b5
  cleanup:
d759b5
     VIR_FREE(buf);
d759b5
@@ -12011,7 +12017,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
d759b5
 
d759b5
     /* for inactive domains we have to peek into the files */
d759b5
     if (!virDomainObjIsActive(vm)) {
d759b5
-        if ((qemuStorageLimitsRefresh(driver, cfg, vm, disk->src)) < 0)
d759b5
+        if ((qemuStorageLimitsRefresh(driver, cfg, vm, disk->src, false)) < 0)
d759b5
             goto endjob;
d759b5
 
d759b5
         info->capacity = disk->src->capacity;
d759b5
@@ -20029,7 +20035,7 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver,
d759b5
     if (virStorageSourceIsEmpty(src))
d759b5
         return 0;
d759b5
 
d759b5
-    if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) {
d759b5
+    if (qemuStorageLimitsRefresh(driver, cfg, dom, src, false) < 0) {
d759b5
         virResetLastError();
d759b5
         return 0;
d759b5
     }
d759b5
-- 
d759b5
2.22.1
d759b5