]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: move the guest status check before agent config and status check
authorLuyao Huang <lhuang@redhat.com>
Fri, 3 Jul 2015 06:58:05 +0000 (14:58 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 8 Jul 2015 08:51:51 +0000 (10:51 +0200)
When use setvcpus command with --guest option to a offline vm,
we will get error:

 # virsh setvcpus test3 1 --guest
 error: Guest agent is not responding: QEMU guest agent is not connected

However guest is not running, agent status could not be connected.
In this case, report domain is not running will be better than agent is
not connected. Move the guest status check more early to output error to
point out guest status is not right.

Also from the logic, a running vm is a basic requirement to use
agent, we cannot use agent if vm is not running.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c

index f9bf32c61d805932121aff3ee4b84b2f37730bf2..78df7d1bf5b8ae73747fb653b2e2875b8cc15295 100644 (file)
@@ -3076,6 +3076,13 @@ qemuDomainAgentAvailable(virDomainObjPtr vm,
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
 
+    if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
+        if (reportError) {
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                           _("domain is not running"));
+        }
+        return false;
+    }
     if (priv->agentError) {
         if (reportError) {
             virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
@@ -3099,13 +3106,6 @@ qemuDomainAgentAvailable(virDomainObjPtr vm,
             return false;
         }
     }
-    if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
-        if (reportError) {
-            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                           _("domain is not running"));
-        }
-        return false;
-    }
     return true;
 }