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