diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2009-11-12 14:14:23 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2009-11-13 11:50:16 +0000 |
commit | c7a8e1bf74996ed464ca3b71edc2a12b6c68c167 (patch) | |
tree | 6f5f93b87a181539ebd5c3de3127025c5ff303e0 | |
parent | Fix incorrect variable passed to LXC event callback (diff) | |
download | libvirt-c7a8e1bf74996ed464ca3b71edc2a12b6c68c167.tar.gz libvirt-c7a8e1bf74996ed464ca3b71edc2a12b6c68c167.tar.bz2 libvirt-c7a8e1bf74996ed464ca3b71edc2a12b6c68c167.zip |
Check that domain is running when starting console
The 'virsh console' command did not check if the domain was
already running before attempting to fetch the XML and extract
the console PTY path. This caused a slightly unhelpful / misleading
error message for the user. The explicit check ensures the user
gets an explicit 'domain is not running' message.
* tools/virsh.c: Validate that state != VIR_DOMAIN_SHUTOFF in
virsh console command
-rw-r--r-- | tools/virsh.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/virsh.c b/tools/virsh.c index 0d0ebca89..9faac350e 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -523,6 +523,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom) char *doc; char *thatHost = NULL; char *thisHost = NULL; + virDomainInfo dominfo; if (!(thisHost = virGetHostname(ctl->conn))) { vshError(ctl, "%s", _("Failed to get local hostname")); @@ -539,6 +540,16 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom) goto cleanup; } + if (virDomainGetInfo(dom, &dominfo) < 0) { + vshError(ctl, "%s", _("Unable to get domain status")); + goto cleanup; + } + + if (dominfo.state == VIR_DOMAIN_SHUTOFF) { + vshError(ctl, "%s", _("The domain is not running")); + goto cleanup; + } + doc = virDomainGetXMLDesc(dom, 0); if (!doc) goto cleanup; |