]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: don't log error for missing optional storage sources on stats
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Fri, 9 Nov 2018 09:21:50 +0000 (12:21 +0300)
committerNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Fri, 21 Dec 2018 09:13:31 +0000 (12:13 +0300)
Every time we call all domain stats for inactive domain with
unavailable storage source we get error message in logs [1]. It's a bit noisy.
While it's arguable whether we need such message or not for mandatory
disks we would like not to see messages for optional disks. Let's
filter at least for cases of local files. Fixing other cases would
require passing flag down the stack to .backendInit of storage
which is ugly.

Stats for active domain are fine because we either drop disks
with unavailable sources or clean source which is handled
by virStorageSourceIsEmpty in qemuDomainGetStatsOneBlockFallback.

We have these logs for successful stats since 25aa7035d (version 1.2.15)
which in turn fixes 596a13713 (version 1.2.12 )which added substantial
stats for offline disks.

[1] error message example:
qemuOpenFileAs:3324 : Failed to open file '/path/to/optional/disk': No such file or directory

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_driver.c

index 6f10235b43f0886f0283a738ec305c2d8213865e..4f729500b7e1f170a3d0260e9e52acd2b4e3263e 100644 (file)
@@ -13704,3 +13704,12 @@ qemuDomainIsUsingNoShutdown(qemuDomainObjPrivatePtr priv)
 {
     return priv->monJSON && priv->allowReboot == VIR_TRISTATE_BOOL_YES;
 }
+
+
+bool
+qemuDomainDiskIsMissingLocalOptional(virDomainDiskDefPtr disk)
+{
+    return disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_OPTIONAL &&
+           virStorageSourceIsLocalStorage(disk->src) && disk->src->path &&
+           !virFileExists(disk->src->path);
+}
index 4414a50c81b29d8737609040f86abaca50aa6297..73d16966e59b20133534971155dfbd6d5d2644cd 100644 (file)
@@ -1095,4 +1095,7 @@ qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);
 bool
 qemuDomainIsUsingNoShutdown(qemuDomainObjPrivatePtr priv);
 
+bool
+qemuDomainDiskIsMissingLocalOptional(virDomainDiskDefPtr disk);
+
 #endif /* LIBVIRT_QEMU_DOMAIN_H */
index e32257f21eee82081e727c1041317edf9e89a589..ea316f61d11b284ac7507cfafab86a3e51593742 100644 (file)
@@ -20720,6 +20720,20 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
     const char *backendstoragealias;
     int ret = -1;
 
+    /*
+     * This helps to keep logs clean from error messages on getting stats
+     * for optional disk with nonexistent source file. We won't get any
+     * stats for such a disk anyway in below code.
+     */
+    if (!virDomainObjIsActive(dom) &&
+        qemuDomainDiskIsMissingLocalOptional(disk)) {
+        VIR_INFO("optional disk '%s' source file is missing, "
+                 "skip getting stats", disk->dst);
+
+        return qemuDomainGetStatsBlockExportHeader(disk, disk->src, *recordnr,
+                                                   records, nrecords);
+    }
+
     for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
         if (blockdev) {
             frontendalias = QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName;