diff --git a/tools/virsh.c b/tools/virsh.c index 31d784cece..7307ccb5ca 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -16482,10 +16482,10 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) qsort(&names[0], actual, sizeof(char*), namesorter); - if (tree || ctl->useSnapshotOld) { + if (tree || (from && ctl->useSnapshotOld)) { parents = vshCalloc(ctl, sizeof(char *), actual); for (i = (from && !ctl->useSnapshotOld); i < actual; i++) { - if (ctl->useSnapshotOld && STREQ(names[i], from)) { + if (from && ctl->useSnapshotOld && STREQ(names[i], from)) { start_index = i; continue; } @@ -16507,7 +16507,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) char indentBuf[INDENT_BUFLEN]; for (i = 0 ; i < actual ; i++) { memset(indentBuf, '\0', sizeof(indentBuf)); - if (ctl->useSnapshotOld ? STREQ(names[i], from) : !parents[i]) + if ((from && ctl->useSnapshotOld) ? STREQ(names[i], from) : + !parents[i]) cmdNodeListDevicesPrint(ctl, names, parents, @@ -16576,7 +16577,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) } for (i = 0; i < actual; i++) { - if (ctl->useSnapshotOld && + if (from && ctl->useSnapshotOld && (descendants ? !names[i] : STRNEQ_NULLABLE(parents[i], from))) continue;