A unsupport error will output from qemuConnectGetAllDomainStats. Add a
check for the flags in qemuConnectGetAllDomainStats and improve the error
in the current implementation.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(a)redhat.com>
---
src/qemu/qemu_driver.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6acaea8..60c3882 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18487,13 +18487,18 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
unsigned int privflags = 0;
unsigned int domflags = 0;
- if (ndoms)
- virCheckFlags(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_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",
+ _("--domain and --list-* flags are mutually exclusive"));
+ 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_ENFORCE_STATS, -1);
if (virConnectGetAllDomainStatsEnsureACL(conn) < 0)
return -1;
--
1.8.3.1
Show replies by date