[libvirt] [PATCH] virsh-domain: Check if domain is running for ttyconsole cmd

Yanbing Du ydu at redhat.com
Tue Aug 13 09:48:07 UTC 2013


Signed-off-by: Yanbing Du <ydu at redhat.com>
---
 tools/virsh-domain.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 4081451..9ccbc35 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9139,6 +9139,12 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
+    /* Check if the domain is active */
+    if (!virDomainIsActive(dom)) {
+        vshError(ctl, _("Domain is not running"));
+        goto cleanup;
+    }
+
     doc = virDomainGetXMLDesc(dom, 0);
     if (!doc)
         goto cleanup;
-- 
1.7.1




More information about the libvir-list mailing list