0a7476
From 6d4f6fa057a8c8801530c97c4f78fa477ece6f4a Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <6d4f6fa057a8c8801530c97c4f78fa477ece6f4a@dist-git>
0a7476
From: Jiri Denemark <jdenemar@redhat.com>
0a7476
Date: Thu, 4 Apr 2019 11:50:35 +0200
0a7476
Subject: [PATCH] virsh: Require explicit --domain for domxml-to-native
0a7476
0a7476
The domxml-to-native virsh command accepts either --xml or --domain
0a7476
option followed by a file or domain name respectively. The --domain
0a7476
option is documented as required, which means an argument with no option
0a7476
is treated as --xml. Commit v4.3.0-127-gd86531daf2 broke this by making
0a7476
--domain optional and thus an argument with no option was treated as
0a7476
--domain.
0a7476
0a7476
https://bugzilla.redhat.com/show_bug.cgi?id=1633077
0a7476
0a7476
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
0a7476
(cherry picked from commit b7ccd0757de73344a4b973ede946dad40de846c7)
0a7476
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
0a7476
Message-Id: <5531d22f2eb774ff080d333975557f6aa03e4b9d.1554371431.git.jdenemar@redhat.com>
0a7476
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
0a7476
---
0a7476
 tools/virsh-domain.c | 6 +++---
0a7476
 tools/virsh.h        | 8 +++++---
0a7476
 2 files changed, 8 insertions(+), 6 deletions(-)
0a7476
0a7476
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
0a7476
index 6aa79f11b9..db4834dd1f 100644
0a7476
--- a/tools/virsh-domain.c
0a7476
+++ b/tools/virsh-domain.c
0a7476
@@ -9387,7 +9387,7 @@ static const vshCmdInfo info_qemu_monitor_event[] = {
0a7476
 
0a7476
 static const vshCmdOptDef opts_qemu_monitor_event[] = {
0a7476
     VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
0a7476
-                                      0),
0a7476
+                                      0, 0),
0a7476
     {.name = "event",
0a7476
      .type = VSH_OT_STRING,
0a7476
      .help = N_("filter by event name")
0a7476
@@ -9940,7 +9940,7 @@ static const vshCmdOptDef opts_domxmltonative[] = {
0a7476
      .flags = VSH_OFLAG_REQ,
0a7476
      .help = N_("target config data type format")
0a7476
     },
0a7476
-    VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(0),
0a7476
+    VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(VSH_OFLAG_REQ_OPT, 0),
0a7476
     {.name = "xml",
0a7476
      .type = VSH_OT_STRING,
0a7476
      .help = N_("xml data file to export from")
0a7476
@@ -13189,7 +13189,7 @@ static const vshCmdInfo info_event[] = {
0a7476
 
0a7476
 static const vshCmdOptDef opts_event[] = {
0a7476
     VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
0a7476
-                                      0),
0a7476
+                                      0, 0),
0a7476
     {.name = "event",
0a7476
      .type = VSH_OT_STRING,
0a7476
      .completer = virshDomainEventNameCompleter,
0a7476
diff --git a/tools/virsh.h b/tools/virsh.h
0a7476
index e164aabcee..b0a3cdbb97 100644
0a7476
--- a/tools/virsh.h
0a7476
+++ b/tools/virsh.h
0a7476
@@ -110,16 +110,18 @@
0a7476
      .help = _helpstr \
0a7476
     }
0a7476
 
0a7476
-# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING(_helpstr, cflags) \
0a7476
+# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING(_helpstr, oflags, cflags) \
0a7476
     {.name = "domain", \
0a7476
      .type = VSH_OT_STRING, \
0a7476
+     .flags = oflags, \
0a7476
      .help = _helpstr, \
0a7476
      .completer = virshDomainNameCompleter, \
0a7476
      .completer_flags = cflags, \
0a7476
     }
0a7476
 
0a7476
-# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(cflags) \
0a7476
-    VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("domain name, id or uuid"), cflags)
0a7476
+# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(oflags, cflags) \
0a7476
+    VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("domain name, id or uuid"), \
0a7476
+                                      oflags, cflags)
0a7476
 
0a7476
 # define VIRSH_COMMON_OPT_DOMAIN_OT_ARGV(_helpstr, cflags) \
0a7476
     {.name = "domain", \
0a7476
-- 
0a7476
2.21.0
0a7476