Re: [libvirt] [virt-tools-list] [PATCH] virt-manager: Show if the shut off vm has a saved image

[adding libvirt, for a virsh idea] On 08/01/2011 02:19 PM, Cole Robinson wrote:
On 07/30/2011 04:15 PM, Miklos Vajna wrote:
Hi,
So far in virt-manager one had to click on a shut off vm in the "Shutoff" state to see if it has a saved image: once the item is selected then the "play" icon will be "Run" or "Restore". This means that in case one has a lot of VMs, it's hard to get an overview of what VM has a saved image and what not.
The attached patch changes the "Shutoff" status message to "Saved" in case the vm has a saved image.
Good idea, I've pushed your patch:
Awesome idea; in fact, I think 'virsh list --all' should probably also be enhanced to do something similar (show "saved" instead of "shutoff", and perhaps requiring a new --managed-save flag so as not to break back-compat). Note that virsh 0.9.4 is gaining 'virsh dominfo' as a way of querying whether a managed save image exists (previously virsh had no way to expose that information), but 'virsh dominfo' on a single domain at a time is much slower than doing it in bulk in 'virsh list'. Alas, we've missed the deadline for getting a patch like that into libvirt 0.9.4. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Mon, Aug 01, 2011 at 02:56:53PM -0600, Eric Blake <eblake@redhat.com> wrote:
Awesome idea; in fact, I think 'virsh list --all' should probably also be enhanced to do something similar (show "saved" instead of "shutoff", and perhaps requiring a new --managed-save flag so as not to break back-compat). Note that virsh 0.9.4 is gaining 'virsh dominfo' as a way of querying whether a managed save image exists (previously virsh had no way to expose that information), but 'virsh dominfo' on a single domain at a time is much slower than doing it in bulk in 'virsh list'.
Hi Eric, You mean virsh list --all would still print "shutoff", but virsh list --all --managed-save would print "saved"? Thanks.

On 08/18/2011 05:41 PM, Miklos Vajna wrote:
On Mon, Aug 01, 2011 at 02:56:53PM -0600, Eric Blake<eblake@redhat.com> wrote:
Awesome idea; in fact, I think 'virsh list --all' should probably also be enhanced to do something similar (show "saved" instead of "shutoff", and perhaps requiring a new --managed-save flag so as not to break back-compat). Note that virsh 0.9.4 is gaining 'virsh dominfo' as a way of querying whether a managed save image exists (previously virsh had no way to expose that information), but 'virsh dominfo' on a single domain at a time is much slower than doing it in bulk in 'virsh list'.
Hi Eric,
You mean virsh list --all would still print "shutoff", but virsh list --all --managed-save would print "saved"?
Yes, that's what I envision; now if only I had time to write the patch... -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Knowing whether 'virsh start' will resume a saved image or do a fresh boot is useful enough to expose via 'virsh list'. * tools/virsh.c (cmdList): add --managed-save flag * tools/virsh.pod (list): Document it. Based on a suggestion by Miklos Vajna. --- Turned out to not be too tough. tools/virsh.c | 12 +++++++++++- tools/virsh.pod | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 27d0d6f..c701764 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -851,6 +851,8 @@ static const vshCmdInfo info_list[] = { static const vshCmdOptDef opts_list[] = { {"inactive", VSH_OT_BOOL, 0, N_("list inactive domains")}, {"all", VSH_OT_BOOL, 0, N_("list inactive & active domains")}, + {"managed-save", VSH_OT_BOOL, 0, + N_("mark domains with managed save state")}, {NULL, 0, 0, NULL} }; @@ -864,6 +866,9 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) int *ids = NULL, maxid = 0, i; char **names = NULL; int maxname = 0; + bool managed = vshCommandOptBool(cmd, "managed-save"); + int state; + inactive |= all; if (!vshConnectionUsability(ctl, ctl->conn)) @@ -932,10 +937,15 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) continue; } + state = vshDomainState(ctl, dom, NULL); + if (managed && state == VIR_DOMAIN_SHUTOFF && + virDomainHasManagedSaveImage(dom, 0) > 0) + state = -2; + vshPrint(ctl, "%3s %-20s %s\n", "-", names[i], - _(vshDomainStateToString(vshDomainState(ctl, dom, NULL)))); + state == -2 ? _("saved") : _(vshDomainStateToString(state))); virDomainFree(dom); VIR_FREE(names[i]); diff --git a/tools/virsh.pod b/tools/virsh.pod index 0af0f3c..9e5ff2e 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -266,7 +266,7 @@ The XML also show the NUMA topology information if available. Inject NMI to the guest. -=item B<list> [I<--inactive> | I<--all>] +=item B<list> [I<--inactive> | I<--all>] [I<--managed-save>] Prints information about existing domains. If no options are specified it prints out information about running domains. @@ -337,6 +337,10 @@ crashed. =back +If I<--managed-save> is specified, then domains that have managed save +state (only possible if they are in the B<shut off> state) will +instead show as B<saved> in the listing. + =item B<freecell> [B<cellno> | I<--all>] Prints the available amount of memory on the machine or within a -- 1.7.4.4

On Thu, Aug 18, 2011 at 06:05:28PM -0600, Eric Blake wrote:
Knowing whether 'virsh start' will resume a saved image or do a fresh boot is useful enough to expose via 'virsh list'.
* tools/virsh.c (cmdList): add --managed-save flag * tools/virsh.pod (list): Document it. Based on a suggestion by Miklos Vajna. ---
Turned out to not be too tough.
tools/virsh.c | 12 +++++++++++- tools/virsh.pod | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 08/24/2011 07:57 AM, Daniel P. Berrange wrote:
On Thu, Aug 18, 2011 at 06:05:28PM -0600, Eric Blake wrote:
Knowing whether 'virsh start' will resume a saved image or do a fresh boot is useful enough to expose via 'virsh list'.
* tools/virsh.c (cmdList): add --managed-save flag * tools/virsh.pod (list): Document it. Based on a suggestion by Miklos Vajna. ---
Turned out to not be too tough.
tools/virsh.c | 12 +++++++++++- tools/virsh.pod | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-)
ACK
Pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Miklos Vajna