Now that we can filter on this information, we should also make it easy to get at. * tools/virsh-snapshot.c (cmdSnapshotInfo): Add another output row. --- tools/virsh-snapshot.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index d5c71be..da1e75f 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -797,7 +797,8 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd) virDomainSnapshotPtr snapshot = NULL; const char *name; char *doc = NULL; - char *tmp; + char *state; + bool internal; char *parent = NULL; bool ret = false; int count; @@ -839,15 +840,36 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd) if (!doc) goto cleanup; - tmp = strstr(doc, "<state>"); - if (!tmp) { + state = strstr(doc, "<state>"); + if (!state) { vshError(ctl, "%s", _("unexpected problem reading snapshot xml")); goto cleanup; } - tmp += strlen("<state>"); + state += strlen("<state>"); vshPrint(ctl, "%-15s %.*s\n", _("State:"), - (int) (strchr(tmp, '<') - tmp), tmp); + (int) (strchr(state, '<') - state), state); + + /* In addition to state, location is useful. If the snapshot has + * a <memory> element, then the existence of snapshot='external' + * prior to <domain> is the deciding factor; for snapshots + * created prior to 1.0.1, a state of disk-only is the only + * external snapshot. */ + if (strstr(state, "<memory")) { + char *domain = strstr(state, "<domain"); + + if (!domain) { + vshError(ctl, "%s", + _("unexpected problem reading snapshot xml")); + goto cleanup; + } + internal = !memmem(state, domain - state, "snapshot='external'", + strlen("snapshot='external'")); + } else { + internal = !STRPREFIX(state, "disk-snapshot"); + } + vshPrint(ctl, "%-15s %s\n", _("Location:"), + internal ? _("internal") : _("external")); if (vshGetSnapshotParent(ctl, snapshot, &parent) < 0) goto cleanup; -- 1.7.11.7 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list