Until now when '--name' was used the parent was not printed and the option was ignored. One option would be to declare the options mutually exclusive, but for testing it may come handy to print both the snapshot name and parent. Adjust the code to print them tab-separated and adjust the docs. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- docs/manpages/virsh.rst | 15 ++++++++++----- tools/virsh-checkpoint.c | 18 ++++++++++++------ tools/virsh-snapshot.c | 18 ++++++++++++------ 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 115b802c45..5cf510b6e9 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -7673,9 +7673,11 @@ If *--parent* is specified, add a column to the output table giving the name of the parent of each snapshot. If *--roots* is specified, the list will be filtered to just snapshots that have no parents. If *--tree* is specified, the output will be in a tree format, listing -just snapshot names. These three options are mutually exclusive. If -*--name* is specified only the snapshot name is printed. This option is -mutually exclusive with *--tree*. +just snapshot names. These three options are mutually exclusive. + +If *--name* is specified only the snapshot name is printed optionally +followed by a tab-separated name of the parent snapshot if *--parent* is used +as well. This option is mutually exclusive with *--tree*. If *--from* is provided, filter the list to snapshots which are children of the given ``snapshot``; or if *--current* is provided, @@ -7989,8 +7991,11 @@ the name of the parent of each checkpoint. If *--roots* is specified, the list will be filtered to just checkpoints that have no parents. If *--tree* is specified, the output will be in a tree format, listing just checkpoint names. These three options are -mutually exclusive. If *--name* is specified only the checkpoint name -is printed. This option is mutually exclusive with *--tree*. +mutually exclusive. + +If *--name* is specified only the checkpoint name is printed optionally +followed by a tab-separated name of the parent checkpoint if *--parent* is used +as well. This option is mutually exclusive with *--tree*. If *--from* is provided, filter the list to checkpoints which are children of the given ``checkpoint``. When used in isolation or with diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index 869c071700..ebad2907e5 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -753,12 +753,6 @@ cmdCheckpointList(vshControl *ctl, chk_name = virDomainCheckpointGetName(checkpoint); assert(chk_name); - if (name) { - /* just print the checkpoint name */ - vshPrint(ctl, "%s\n", chk_name); - continue; - } - if (!(doc = virDomainCheckpointGetXMLDesc(checkpoint, 0))) continue; @@ -769,6 +763,18 @@ cmdCheckpointList(vshControl *ctl, parent_chk = virXPathString("string(/domaincheckpoint/parent/name)", ctxt); + if (name) { + vshPrint(ctl, "%s", chk_name); + + if (parent_chk) + vshPrint(ctl, "\t%s", parent_chk); + + vshPrint(ctl, "\n"); + + /* just print the checkpoint name */ + continue; + } + if (virXPathLongLong("string(/domaincheckpoint/creationTime)", ctxt, &creation_longlong) < 0) continue; diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 899bae7e9a..7b22962efb 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -1509,12 +1509,6 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) snap_name = virDomainSnapshotGetName(snapshot); assert(snap_name); - if (name) { - /* just print the snapshot name */ - vshPrint(ctl, "%s\n", snap_name); - continue; - } - if (!(doc = virDomainSnapshotGetXMLDesc(snapshot, 0))) continue; @@ -1525,6 +1519,18 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) parent_snap = virXPathString("string(/domainsnapshot/parent/name)", ctxt); + if (name) { + vshPrint(ctl, "%s", snap_name); + + if (parent_snap) + vshPrint(ctl, "\t%s", parent_snap); + + vshPrint(ctl, "\n"); + + /* just print the snapshot name */ + continue; + } + if (!(state = virXPathString("string(/domainsnapshot/state)", ctxt))) continue; -- 2.44.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx