render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a1c947
From 045c3fbdc6f4a5b98013a00fcaefcd3481c1df39 Mon Sep 17 00:00:00 2001
a1c947
Message-Id: <045c3fbdc6f4a5b98013a00fcaefcd3481c1df39@dist-git>
a1c947
From: Michal Privoznik <mprivozn@redhat.com>
a1c947
Date: Fri, 8 Jul 2022 12:45:42 +0200
a1c947
Subject: [PATCH] virsh: Require --xpath for *dumpxml
a1c947
a1c947
Historically, the dumpxml command reject any unknown arguments,
a1c947
for instance:
a1c947
a1c947
    virsh dumpxml fedora xxx
a1c947
a1c947
However, after v8.5.0-rc1~31 the second argument ('xxx') is
a1c947
treated as an XPath, but it's not that clearly visible.
a1c947
Therefore, require the --xpath switch, like this:
a1c947
a1c947
    virsh dumpxml fedora --xpath xxx
a1c947
a1c947
Yes, this breaks already released virsh, but I think we can argue
a1c947
that the pool of users of this particular function is very small.
a1c947
We also document the argument being mandatory:
a1c947
a1c947
   dumpxml [--inactive] [--security-info] [--update-cpu] [--migratable]
a1c947
           [--xpath EXPRESSION] [--wrap] domain
a1c947
a1c947
The sooner we do this change, the better.
a1c947
a1c947
The same applies for other *dumpxml functions (net-dumpxml,
a1c947
pool-dumpxml, vol-dumpxl to name a few).
a1c947
a1c947
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103524
a1c947
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a1c947
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
a1c947
(cherry picked from commit e90d48ae6e22eaf1650f920abc0a6b87d2daa82b)
a1c947
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a1c947
---
a1c947
 tools/virsh-backup.c     | 1 +
a1c947
 tools/virsh-checkpoint.c | 1 +
a1c947
 tools/virsh-domain.c     | 3 +++
a1c947
 tools/virsh-interface.c  | 1 +
a1c947
 tools/virsh-network.c    | 2 ++
a1c947
 tools/virsh-nodedev.c    | 1 +
a1c947
 tools/virsh-nwfilter.c   | 2 ++
a1c947
 tools/virsh-pool.c       | 1 +
a1c947
 tools/virsh-secret.c     | 1 +
a1c947
 tools/virsh-snapshot.c   | 1 +
a1c947
 tools/virsh-volume.c     | 1 +
a1c947
 11 files changed, 15 insertions(+)
a1c947
a1c947
diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c
a1c947
index db122abc09..1bb2c63113 100644
a1c947
--- a/tools/virsh-backup.c
a1c947
+++ b/tools/virsh-backup.c
a1c947
@@ -117,6 +117,7 @@ static const vshCmdOptDef opts_backup_dumpxml[] = {
a1c947
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
a1c947
index a7ef39849d..9605c893af 100644
a1c947
--- a/tools/virsh-checkpoint.c
a1c947
+++ b/tools/virsh-checkpoint.c
a1c947
@@ -854,6 +854,7 @@ static const vshCmdOptDef opts_checkpoint_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
a1c947
index da63cc95ff..76d12d2b70 100644
a1c947
--- a/tools/virsh-domain.c
a1c947
+++ b/tools/virsh-domain.c
a1c947
@@ -4529,6 +4529,7 @@ static const vshCmdOptDef opts_save_image_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
@@ -4961,6 +4962,7 @@ static const vshCmdOptDef opts_managed_save_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
@@ -10469,6 +10471,7 @@ static const vshCmdOptDef opts_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
a1c947
index b29ffc9bef..39ea53ec9d 100644
a1c947
--- a/tools/virsh-interface.c
a1c947
+++ b/tools/virsh-interface.c
a1c947
@@ -472,6 +472,7 @@ static const vshCmdOptDef opts_interface_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
a1c947
index 99ced6ccc6..004719dad6 100644
a1c947
--- a/tools/virsh-network.c
a1c947
+++ b/tools/virsh-network.c
a1c947
@@ -351,6 +351,7 @@ static const vshCmdOptDef opts_network_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
@@ -1556,6 +1557,7 @@ static const vshCmdOptDef opts_network_port_dumpxml[] = {
a1c947
     VIRSH_COMMON_OPT_NETWORK_PORT(0),
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
a1c947
index 37e361c701..2adcad9c10 100644
a1c947
--- a/tools/virsh-nodedev.c
a1c947
+++ b/tools/virsh-nodedev.c
a1c947
@@ -567,6 +567,7 @@ static const vshCmdOptDef opts_node_device_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
a1c947
index ff7f6f4026..d4112c8620 100644
a1c947
--- a/tools/virsh-nwfilter.c
a1c947
+++ b/tools/virsh-nwfilter.c
a1c947
@@ -188,6 +188,7 @@ static const vshCmdOptDef opts_nwfilter_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
@@ -610,6 +611,7 @@ static const vshCmdOptDef opts_nwfilter_binding_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
a1c947
index 820a61f889..8a98c6ae40 100644
a1c947
--- a/tools/virsh-pool.c
a1c947
+++ b/tools/virsh-pool.c
a1c947
@@ -777,6 +777,7 @@ static const vshCmdOptDef opts_pool_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
a1c947
index 79fa3faf5a..17d2bbd88d 100644
a1c947
--- a/tools/virsh-secret.c
a1c947
+++ b/tools/virsh-secret.c
a1c947
@@ -140,6 +140,7 @@ static const vshCmdOptDef opts_secret_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
a1c947
index 83fdfb9616..8fa64ba903 100644
a1c947
--- a/tools/virsh-snapshot.c
a1c947
+++ b/tools/virsh-snapshot.c
a1c947
@@ -1609,6 +1609,7 @@ static const vshCmdOptDef opts_snapshot_dumpxml[] = {
a1c947
     },
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
a1c947
index bf72d8135f..300a0aa8e5 100644
a1c947
--- a/tools/virsh-volume.c
a1c947
+++ b/tools/virsh-volume.c
a1c947
@@ -1161,6 +1161,7 @@ static const vshCmdOptDef opts_vol_dumpxml[] = {
a1c947
     VIRSH_COMMON_OPT_POOL_OPTIONAL,
a1c947
     {.name = "xpath",
a1c947
      .type = VSH_OT_STRING,
a1c947
+     .flags = VSH_OFLAG_REQ_OPT,
a1c947
      .completer = virshCompleteEmpty,
a1c947
      .help = N_("xpath expression to filter the XML document")
a1c947
     },
a1c947
-- 
a1c947
2.35.1
a1c947