Blame SOURCES/libvirt-qemu-move-the-guest-status-check-before-agent-config-and-status-check.patch

7a3408
From 80c40537679e42b440f88e97007136aca748d613 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <80c40537679e42b440f88e97007136aca748d613@dist-git>
7a3408
From: Luyao Huang <lhuang@redhat.com>
7a3408
Date: Fri, 10 Jul 2015 09:25:23 +0200
7a3408
Subject: [PATCH] qemu: move the guest status check before agent config and
7a3408
 status check
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1240979
7a3408
7a3408
When use setvcpus command with --guest option to a offline vm,
7a3408
we will get error:
7a3408
7a3408
 # virsh setvcpus test3 1 --guest
7a3408
 error: Guest agent is not responding: QEMU guest agent is not connected
7a3408
7a3408
However guest is not running, agent status could not be connected.
7a3408
In this case, report domain is not running will be better than agent is
7a3408
not connected. Move the guest status check more early to output error to
7a3408
point out guest status is not right.
7a3408
7a3408
Also from the logic, a running vm is a basic requirement to use
7a3408
agent, we cannot use agent if vm is not running.
7a3408
7a3408
Signed-off-by: Luyao Huang <lhuang@redhat.com>
7a3408
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7a3408
(cherry picked from commit 0b3fcfb1eac845ba24ac2ad6eefb969d5f7b8395)
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_domain.c | 14 +++++++-------
7a3408
 1 file changed, 7 insertions(+), 7 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
7a3408
index e3793bd..c247737 100644
7a3408
--- a/src/qemu/qemu_domain.c
7a3408
+++ b/src/qemu/qemu_domain.c
7a3408
@@ -3076,6 +3076,13 @@ qemuDomainAgentAvailable(virDomainObjPtr vm,
7a3408
 {
7a3408
     qemuDomainObjPrivatePtr priv = vm->privateData;
7a3408
 
7a3408
+    if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
7a3408
+        if (reportError) {
7a3408
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
7a3408
+                           _("domain is not running"));
7a3408
+        }
7a3408
+        return false;
7a3408
+    }
7a3408
     if (priv->agentError) {
7a3408
         if (reportError) {
7a3408
             virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
7a3408
@@ -3099,13 +3106,6 @@ qemuDomainAgentAvailable(virDomainObjPtr vm,
7a3408
             return false;
7a3408
         }
7a3408
     }
7a3408
-    if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
7a3408
-        if (reportError) {
7a3408
-            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
7a3408
-                           _("domain is not running"));
7a3408
-        }
7a3408
-        return false;
7a3408
-    }
7a3408
     return true;
7a3408
 }
7a3408
 
7a3408
-- 
7a3408
2.4.5
7a3408