Blame SOURCES/libvirt-qemu-driver-Improve-error-suppression-in-qemuDomainStorageUpdatePhysical.patch

99cbc7
From 2c1a60343710fc11a5c8bcfd022fd2a8aa6681ff Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <2c1a60343710fc11a5c8bcfd022fd2a8aa6681ff@dist-git>
99cbc7
From: Peter Krempa <pkrempa@redhat.com>
99cbc7
Date: Fri, 16 Aug 2019 14:36:56 +0200
99cbc7
Subject: [PATCH] qemu: driver: Improve error suppression in
99cbc7
 qemuDomainStorageUpdatePhysical
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
None of the callers of qemuDomainStorageUpdatePhysical care about
99cbc7
errors.
99cbc7
99cbc7
Use the new flag for qemuDomainStorageOpenStat which suppresses some
99cbc7
errors and move the reset of the rest of the uncommon errors into this
99cbc7
function. Document what is happening in a comment for the function.
99cbc7
99cbc7
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
(cherry picked from commit 3d7ea4165b890880f43074e1e5e6e10bf0ad21d6)
99cbc7
https: //bugzilla.redhat.com/show_bug.cgi?id=1724808
99cbc7
Message-Id: <65325f9c156ebab937b81e89c9bfe6c1b6d8251b.1565958905.git.pkrempa@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_driver.c | 24 ++++++++++++++++++------
99cbc7
 1 file changed, 18 insertions(+), 6 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
99cbc7
index 91eeb05319..72c75e308b 100644
99cbc7
--- a/src/qemu/qemu_driver.c
99cbc7
+++ b/src/qemu/qemu_driver.c
99cbc7
@@ -11849,6 +11849,19 @@ qemuDomainStorageCloseStat(virStorageSourcePtr src,
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
+/**
99cbc7
+ * qemuDomainStorageUpdatePhysical:
99cbc7
+ * @driver: qemu driver
99cbc7
+ * @cfg: qemu driver configuration object
99cbc7
+ * @vm: domain object
99cbc7
+ * @src: storage source to update
99cbc7
+ *
99cbc7
+ * Update the physical size of the disk by reading the actual size of the image
99cbc7
+ * on disk.
99cbc7
+ *
99cbc7
+ * Returns 0 on successful update and -1 otherwise (some uncommon errors may be
99cbc7
+ * reported but are reset (thus only logged)).
99cbc7
+ */
99cbc7
 static int
99cbc7
 qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver,
99cbc7
                                 virQEMUDriverConfigPtr cfg,
99cbc7
@@ -11862,8 +11875,11 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver,
99cbc7
     if (virStorageSourceIsEmpty(src))
99cbc7
         return 0;
99cbc7
 
99cbc7
-    if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) < 0)
99cbc7
+    if ((ret = qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, true)) <= 0) {
99cbc7
+        if (ret < 0)
99cbc7
+            virResetLastError();
99cbc7
         return -1;
99cbc7
+    }
99cbc7
 
99cbc7
     ret = virStorageSourceUpdatePhysicalSize(src, fd, &sb);
99cbc7
 
99cbc7
@@ -12058,7 +12074,6 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
99cbc7
         if (qemuDomainStorageUpdatePhysical(driver, cfg, vm, disk->src) == 0) {
99cbc7
             info->physical = disk->src->physical;
99cbc7
         } else {
99cbc7
-            virResetLastError();
99cbc7
             info->physical = entry->physical;
99cbc7
         }
99cbc7
     } else {
99cbc7
@@ -20132,12 +20147,9 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
99cbc7
         QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
99cbc7
                                  "physical", entry->physical);
99cbc7
     } else {
99cbc7
-        if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) == 0) {
99cbc7
+        if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) == 0)
99cbc7
             QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
99cbc7
                                      "physical", src->physical);
99cbc7
-        } else {
99cbc7
-            virResetLastError();
99cbc7
-        }
99cbc7
     }
99cbc7
 
99cbc7
     if (qemuDomainGetStatsOneBlockNode(record, maxparams, src, block_idx,
99cbc7
-- 
99cbc7
2.22.1
99cbc7