[libvirt] [PATCH] virsh: Require explicit --domain for domxml-to-native

Jiri Denemark posted 1 patch 5 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/2f64cfeb8c6f8b9bc2e47c9ef5abee7064b9ef5d.1537948977.git.jdenemar@redhat.com
tools/virsh-domain.c | 6 +++---
tools/virsh.h        | 8 +++++---
2 files changed, 8 insertions(+), 6 deletions(-)
[libvirt] [PATCH] virsh: Require explicit --domain for domxml-to-native
Posted by Jiri Denemark 5 years, 6 months ago
The domxml-to-native virsh command accepts either --xml or --domain
option followed by a file or domain name respectively. The --domain
option is documented as required, which means an argument with no option
is treated as --xml. Commit v4.3.0-127-gd86531daf2 broke this by making
--domain optional and thus an argument with no option was treated as
--domain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 tools/virsh-domain.c | 6 +++---
 tools/virsh.h        | 8 +++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index cfb0095333..372bdb95d3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9509,7 +9509,7 @@ static const vshCmdInfo info_qemu_monitor_event[] = {
 
 static const vshCmdOptDef opts_qemu_monitor_event[] = {
     VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
-                                      0),
+                                      0, 0),
     {.name = "event",
      .type = VSH_OT_STRING,
      .help = N_("filter by event name")
@@ -10062,7 +10062,7 @@ static const vshCmdOptDef opts_domxmltonative[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("target config data type format")
     },
-    VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(0),
+    VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(VSH_OFLAG_REQ_OPT, 0),
     {.name = "xml",
      .type = VSH_OT_STRING,
      .help = N_("xml data file to export from")
@@ -13312,7 +13312,7 @@ static const vshCmdInfo info_event[] = {
 
 static const vshCmdOptDef opts_event[] = {
     VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
-                                      0),
+                                      0, 0),
     {.name = "event",
      .type = VSH_OT_STRING,
      .completer = virshDomainEventNameCompleter,
diff --git a/tools/virsh.h b/tools/virsh.h
index af0d6ce686..6ff5c74b5e 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -107,16 +107,18 @@
      .help = _helpstr \
     }
 
-# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING(_helpstr, cflags) \
+# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING(_helpstr, oflags, cflags) \
     {.name = "domain", \
      .type = VSH_OT_STRING, \
+     .flags = oflags, \
      .help = _helpstr, \
      .completer = virshDomainNameCompleter, \
      .completer_flags = cflags, \
     }
 
-# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(cflags) \
-    VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("domain name, id or uuid"), cflags)
+# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(oflags, cflags) \
+    VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("domain name, id or uuid"), \
+                                      oflags, cflags)
 
 # define VIRSH_COMMON_OPT_DOMAIN_OT_ARGV(_helpstr, cflags) \
     {.name = "domain", \
-- 
2.19.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virsh: Require explicit --domain for domxml-to-native
Posted by Jiri Denemark 5 years, 6 months ago
On Wed, Sep 26, 2018 at 10:02:57 +0200, Jiri Denemark wrote:
> The domxml-to-native virsh command accepts either --xml or --domain
> option followed by a file or domain name respectively. The --domain
> option is documented as required, which means an argument with no option
> is treated as --xml. Commit v4.3.0-127-gd86531daf2 broke this by making
> --domain optional and thus an argument with no option was treated as
> --domain.

I forgot to add a link to bugzilla:

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

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virsh: Require explicit --domain for domxml-to-native
Posted by Michal Privoznik 5 years, 6 months ago
On 09/26/2018 10:02 AM, Jiri Denemark wrote:
> The domxml-to-native virsh command accepts either --xml or --domain
> option followed by a file or domain name respectively. The --domain
> option is documented as required, which means an argument with no option
> is treated as --xml. Commit v4.3.0-127-gd86531daf2 broke this by making
> --domain optional and thus an argument with no option was treated as
> --domain.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  tools/virsh-domain.c | 6 +++---
>  tools/virsh.h        | 8 +++++---
>  2 files changed, 8 insertions(+), 6 deletions(-)

ACK

Michal

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