Historically, the dumpxml command reject any unknown arguments,
for instance:
virsh dumpxml fedora xxx
However, after v8.5.0-rc1~31 the second argument ('xxx') is
treated as an XPath, but it's not that clearly visible.
Therefore, require the --xpath switch, like this:
virsh dumpxml fedora --xpath xxx
Yes, this breaks already released virsh, but I think we can argue
that the pool of users of this particular function is very small.
The sooner we do this change, the better.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103524
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
tools/virsh-domain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 43034f2f81..a181ae005f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10461,6 +10461,7 @@ static const vshCmdOptDef opts_dumpxml[] = {
},
{.name = "xpath",
.type = VSH_OT_STRING,
+ .flags = VSH_OFLAG_REQ_OPT,
.completer = virshCompleteEmpty,
.help = N_("xpath expression to filter the XML document")
},
--
2.35.1
On Fri, Jul 08, 2022 at 12:49:13PM +0200, Michal Privoznik wrote: > Historically, the dumpxml command reject any unknown arguments, > for instance: > > virsh dumpxml fedora xxx > > However, after v8.5.0-rc1~31 the second argument ('xxx') is > treated as an XPath, but it's not that clearly visible. > Therefore, require the --xpath switch, like this: > > virsh dumpxml fedora --xpath xxx > > Yes, this breaks already released virsh, but I think we can argue > that the pool of users of this particular function is very small. > The sooner we do this change, the better. > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103524 > Signed-off-by: Michal Privoznik <mprivozn@redhat.com> > --- > tools/virsh-domain.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c > index 43034f2f81..a181ae005f 100644 > --- a/tools/virsh-domain.c > +++ b/tools/virsh-domain.c > @@ -10461,6 +10461,7 @@ static const vshCmdOptDef opts_dumpxml[] = { > }, > {.name = "xpath", > .type = VSH_OT_STRING, > + .flags = VSH_OFLAG_REQ_OPT, > .completer = virshCompleteEmpty, > .help = N_("xpath expression to filter the XML document") > }, Opps, shouldn't we do the same change for all the other 'xpath' parameters. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
On 7/8/22 13:23, Daniel P. Berrangé wrote: > On Fri, Jul 08, 2022 at 12:49:13PM +0200, Michal Privoznik wrote: >> Historically, the dumpxml command reject any unknown arguments, >> for instance: >> >> virsh dumpxml fedora xxx >> >> However, after v8.5.0-rc1~31 the second argument ('xxx') is >> treated as an XPath, but it's not that clearly visible. >> Therefore, require the --xpath switch, like this: >> >> virsh dumpxml fedora --xpath xxx >> >> Yes, this breaks already released virsh, but I think we can argue >> that the pool of users of this particular function is very small. >> The sooner we do this change, the better. >> >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103524 >> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> >> --- >> tools/virsh-domain.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c >> index 43034f2f81..a181ae005f 100644 >> --- a/tools/virsh-domain.c >> +++ b/tools/virsh-domain.c >> @@ -10461,6 +10461,7 @@ static const vshCmdOptDef opts_dumpxml[] = { >> }, >> {.name = "xpath", >> .type = VSH_OT_STRING, >> + .flags = VSH_OFLAG_REQ_OPT, >> .completer = virshCompleteEmpty, >> .help = N_("xpath expression to filter the XML document") >> }, > > Opps, shouldn't we do the same change for all the other 'xpath' > parameters. > I guess we should. But I worry that we might break some users scripts. But I guess if you're okay with it then so am I. Michal
On Fri, Jul 08, 2022 at 01:58:08PM +0200, Michal Prívozník wrote: > On 7/8/22 13:23, Daniel P. Berrangé wrote: > > On Fri, Jul 08, 2022 at 12:49:13PM +0200, Michal Privoznik wrote: > >> Historically, the dumpxml command reject any unknown arguments, > >> for instance: > >> > >> virsh dumpxml fedora xxx > >> > >> However, after v8.5.0-rc1~31 the second argument ('xxx') is > >> treated as an XPath, but it's not that clearly visible. > >> Therefore, require the --xpath switch, like this: > >> > >> virsh dumpxml fedora --xpath xxx > >> > >> Yes, this breaks already released virsh, but I think we can argue > >> that the pool of users of this particular function is very small. > >> The sooner we do this change, the better. > >> > >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103524 > >> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> > >> --- > >> tools/virsh-domain.c | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c > >> index 43034f2f81..a181ae005f 100644 > >> --- a/tools/virsh-domain.c > >> +++ b/tools/virsh-domain.c > >> @@ -10461,6 +10461,7 @@ static const vshCmdOptDef opts_dumpxml[] = { > >> }, > >> {.name = "xpath", > >> .type = VSH_OT_STRING, > >> + .flags = VSH_OFLAG_REQ_OPT, > >> .completer = virshCompleteEmpty, > >> .help = N_("xpath expression to filter the XML document") > >> }, > > > > Opps, shouldn't we do the same change for all the other 'xpath' > > parameters. > > > > I guess we should. But I worry that we might break some users scripts. > But I guess if you're okay with it then so am I. It was documented as --xpath in the man page. That you could give it positionally was an oversight of mine, thanks to our crazy homegrown CLI parser behaviour. Did I mention I wished we just used getopt... With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
© 2016 - 2024 Red Hat, Inc.