[PATCH] domain: Improve error output for virDomainListGetStats

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

 



When pass flags --domain and --list-* to cmdDomstats,
a unsupport error will output from qemuConnectGetAllDomainStats.

error: unsupported flags (0x1) in function qemuConnectGetAllDomainStats

>From manual of virsh: The approaches can't be combined.

Improve error to:

error: --domain and --list-* flags are mutually exclusive

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 src/libvirt-domain.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 7dc3146..6ae6dd2 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11053,6 +11053,19 @@ virDomainListGetStats(virDomainPtr *doms,
         goto cleanup;
     }
 
+    if (flags & (VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+                 VIR_CONNECT_LIST_DOMAINS_INACTIVE |
+                 VIR_CONNECT_LIST_DOMAINS_PERSISTENT |
+                 VIR_CONNECT_LIST_DOMAINS_TRANSIENT |
+                 VIR_CONNECT_LIST_DOMAINS_RUNNING |
+                 VIR_CONNECT_LIST_DOMAINS_SHUTOFF |
+                 VIR_CONNECT_LIST_DOMAINS_PAUSED |
+                 VIR_CONNECT_LIST_DOMAINS_OTHER)) {
+        virReportInvalidArg(flags, "%s",
+                    _("--domain and --list-* flags are mutually exclusive"));
+        goto cleanup;
+    }
+
     conn = doms[0]->conn;
     virCheckConnectReturn(conn, -1);
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]