edecca
From 7875a7866086dc80e174dd62a53aa687daa012c7 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <7875a7866086dc80e174dd62a53aa687daa012c7@dist-git>
edecca
From: Jiri Denemark <jdenemar@redhat.com>
edecca
Date: Wed, 26 Sep 2018 09:59:08 +0200
edecca
Subject: [PATCH] virsh: Require explicit --domain for domxml-to-native
edecca
MIME-Version: 1.0
edecca
Content-Type: text/plain; charset=UTF-8
edecca
Content-Transfer-Encoding: 8bit
edecca
edecca
The domxml-to-native virsh command accepts either --xml or --domain
edecca
option followed by a file or domain name respectively. The --domain
edecca
option is documented as required, which means an argument with no option
edecca
is treated as --xml. Commit v4.3.0-127-gd86531daf2 broke this by making
edecca
--domain optional and thus an argument with no option was treated as
edecca
--domain.
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1633077
edecca
edecca
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
edecca
(cherry picked from commit b7ccd0757de73344a4b973ede946dad40de846c7)
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1634769
edecca
edecca
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
edecca
Reviewed-by: Ján Tomko <jtomko@redhat.com>
edecca
---
edecca
 tools/virsh-domain.c | 6 +++---
edecca
 tools/virsh.h        | 8 +++++---
edecca
 2 files changed, 8 insertions(+), 6 deletions(-)
edecca
edecca
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
edecca
index 6aa79f11b9..db4834dd1f 100644
edecca
--- a/tools/virsh-domain.c
edecca
+++ b/tools/virsh-domain.c
edecca
@@ -9387,7 +9387,7 @@ static const vshCmdInfo info_qemu_monitor_event[] = {
edecca
 
edecca
 static const vshCmdOptDef opts_qemu_monitor_event[] = {
edecca
     VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
edecca
-                                      0),
edecca
+                                      0, 0),
edecca
     {.name = "event",
edecca
      .type = VSH_OT_STRING,
edecca
      .help = N_("filter by event name")
edecca
@@ -9940,7 +9940,7 @@ static const vshCmdOptDef opts_domxmltonative[] = {
edecca
      .flags = VSH_OFLAG_REQ,
edecca
      .help = N_("target config data type format")
edecca
     },
edecca
-    VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(0),
edecca
+    VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(VSH_OFLAG_REQ_OPT, 0),
edecca
     {.name = "xml",
edecca
      .type = VSH_OT_STRING,
edecca
      .help = N_("xml data file to export from")
edecca
@@ -13189,7 +13189,7 @@ static const vshCmdInfo info_event[] = {
edecca
 
edecca
 static const vshCmdOptDef opts_event[] = {
edecca
     VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
edecca
-                                      0),
edecca
+                                      0, 0),
edecca
     {.name = "event",
edecca
      .type = VSH_OT_STRING,
edecca
      .completer = virshDomainEventNameCompleter,
edecca
diff --git a/tools/virsh.h b/tools/virsh.h
edecca
index e164aabcee..b0a3cdbb97 100644
edecca
--- a/tools/virsh.h
edecca
+++ b/tools/virsh.h
edecca
@@ -110,16 +110,18 @@
edecca
      .help = _helpstr \
edecca
     }
edecca
 
edecca
-# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING(_helpstr, cflags) \
edecca
+# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING(_helpstr, oflags, cflags) \
edecca
     {.name = "domain", \
edecca
      .type = VSH_OT_STRING, \
edecca
+     .flags = oflags, \
edecca
      .help = _helpstr, \
edecca
      .completer = virshDomainNameCompleter, \
edecca
      .completer_flags = cflags, \
edecca
     }
edecca
 
edecca
-# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(cflags) \
edecca
-    VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("domain name, id or uuid"), cflags)
edecca
+# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(oflags, cflags) \
edecca
+    VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("domain name, id or uuid"), \
edecca
+                                      oflags, cflags)
edecca
 
edecca
 # define VIRSH_COMMON_OPT_DOMAIN_OT_ARGV(_helpstr, cflags) \
edecca
     {.name = "domain", \
edecca
-- 
edecca
2.19.1
edecca