[libvirt] [PATCH 4/6] qemu: driver: Improve error suppression in qemuDomainStorageUpdatePhysical

Ján Tomko jtomko at redhat.com
Thu Aug 15 18:43:52 UTC 2019


On Wed, Aug 14, 2019 at 06:59:19PM +0200, Peter Krempa wrote:
>None of the callers of qemuDomainStorageUpdatePhysical care about
>errors.
>
>Use the new flag for qemuDomainStorageOpenStat which suppresses some
>errors and move the reset of the rest of the uncommon errors into this
>function. Document what is happening in a comment for the function.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/qemu/qemu_driver.c | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index cc296c1fe3..2dffef9642 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -12318,6 +12318,19 @@ qemuDomainStorageCloseStat(virStorageSourcePtr src,
> }
>
>
>+/**
>+ * qemuDomainStorageUpdatePhysical:
>+ * @driver: qemu driver
>+ * @cfg: qemu driver configuration object
>+ * @vm: domain object
>+ * @src: storage source to update
>+ *
>+ * Update the physical size of the disk by reading the actual size of the image
>+ * on disk.
>+ *
>+ * Returns 0 on successful update and -1 otherwise (some uncommon errors may be
>+ * reported but are reset (thus only logged)).

By uncommon you mean missing network storage? :)

>+ */
> static int
> qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver,
>                                 virQEMUDriverConfigPtr cfg,
>@@ -12331,8 +12344,11 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver,
>     if (virStorageSourceIsEmpty(src))
>         return 0;
>
>-    if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) < 0)
>+    if ((ret = qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, true)) <= 0) {
>+        if (ret < 0)
>+            virResetLastError();

Still ugly to use virResetLastError, but at least it's an improvement.

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190815/0363b2dc/attachment-0001.sig>


More information about the libvir-list mailing list