[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] qemu: improve error message for domain stats API



Filtering specific list of domains is not supported yet.  Print a better
error message.

old error message:
    error: unsupported flags (0x1) in function qemuConnectGetAllDomainStats

new error message:
    error: using filters with list of domains is not implemented yet

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1143837

Signed-off-by: Pavel Hrdina <phrdina redhat com>
Signed-off-by: Luyao Huang <lhuang redhat com>
---

Based on https://www.redhat.com/archives/libvir-list/2014-November/msg00069.html
with different commit and error message.

 src/qemu/qemu_driver.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f8d493d..b88e2cc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19809,15 +19809,19 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
     unsigned int privflags = 0;
     unsigned int domflags = 0;
 
-    if (ndoms)
-        virCheckFlags(VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING |
-                      VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, -1);
-    else
-        virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE |
-                      VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT |
-                      VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE |
-                      VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING |
-                      VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, -1);
+    if (ndoms && (flags & (VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE |
+                           VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT |
+                           VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE))) {
+        virReportInvalidArg(flags, "%s", _("using filters with list of domains "
+                                           "is not implemented yet"));
+        return -1;
+    }
+
+    virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE |
+                  VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT |
+                  VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE |
+                  VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING |
+                  VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, -1);
 
     if (virConnectGetAllDomainStatsEnsureACL(conn) < 0)
         return -1;
-- 
2.3.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]