]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Introduce new VIR_ERR_AGENT_UNRESPONSIVE error code
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 27 Aug 2012 10:24:59 +0000 (12:24 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 27 Aug 2012 16:00:10 +0000 (18:00 +0200)
Currently, when guest agent is configured but not responsive
(e.g. due to appropriate service not running in the guest)
we return VIR_ERR_INTERNAL_ERROR. Both are wrong. Therefore
we need to introduce new error code to reflect this case.

include/libvirt/virterror.h
src/qemu/qemu_agent.c
src/qemu/qemu_driver.c
src/util/virterror.c

index 69c64aa36359763f87323a20a57095a7a2a2969b..5140c38ea66d82d13231bd308e1a855e4dfcf7a3 100644 (file)
@@ -283,6 +283,8 @@ typedef enum {
     VIR_ERR_OPERATION_UNSUPPORTED = 84, /* The requested operation is not
                                            supported */
     VIR_ERR_SSH = 85,                   /* error in ssh transport driver */
+    VIR_ERR_AGENT_UNRESPONSIVE = 86,    /* guest agent is unresponsive,
+                                           not running or not usable */
 } virErrorNumber;
 
 /**
index c658bf8db6e6e8377547e7bf2e675b0496c1e0b4..ba2978397509bffac3e88af07cbcc84eaab794b8 100644 (file)
@@ -880,7 +880,7 @@ static int qemuAgentSend(qemuAgentPtr mon,
         if ((timeout && virCondWaitUntil(&mon->notify, &mon->lock, then) < 0) ||
             (!timeout && virCondWait(&mon->notify, &mon->lock) < 0)) {
             if (errno == ETIMEDOUT) {
-                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
                                _("Guest agent not available for now"));
                 ret = -2;
             } else {
index 3fcca0ef943bf88d6dca51aa4b86de68501bee3e..f64d9ec36ea0435394a8c40b4c63db0c59b99a78 100644 (file)
@@ -1734,8 +1734,9 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) {
 
     if (useAgent) {
         if (priv->agentError) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("QEMU guest agent is not available due to an error"));
+            virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
+                           _("QEMU guest agent is not "
+                             "available due to an error"));
             goto cleanup;
         }
         if (!priv->agent) {
@@ -1815,8 +1816,9 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags)
 
     if (useAgent) {
         if (priv->agentError) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("QEMU guest agent is not available due to an error"));
+            virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
+                           _("QEMU guest agent is not "
+                             "available due to an error"));
             goto cleanup;
         }
         if (!priv->agent) {
@@ -10391,7 +10393,7 @@ qemuDomainSnapshotFSFreeze(struct qemud_driver *driver,
     int freezed;
 
     if (priv->agentError) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+        virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
                        _("QEMU guest agent is not "
                          "available due to an error"));
         return -1;
@@ -10419,7 +10421,7 @@ qemuDomainSnapshotFSThaw(struct qemud_driver *driver,
 
     if (priv->agentError) {
         if (report)
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+            virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
                            _("QEMU guest agent is not "
                              "available due to an error"));
         return -1;
@@ -13708,8 +13710,9 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
     }
 
     if (priv->agentError) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("QEMU guest agent is not available due to an error"));
+        virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
+                       _("QEMU guest agent is not "
+                         "available due to an error"));
         goto cleanup;
     }
 
@@ -13849,8 +13852,9 @@ qemuDomainAgentCommand(virDomainPtr domain,
     }
 
     if (priv->agentError) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("QEMU guest agent is not available due to an error"));
+        virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
+                       _("QEMU guest agent is not "
+                         "available due to an error"));
         goto cleanup;
     }
 
index 3ee2ae0aa25d93125d237ffd88e00cc17704ca44..7caa69e925b544123bca4ae8d01ff9bdbb5640b0 100644 (file)
@@ -1199,6 +1199,13 @@ virErrorMsg(virErrorNumber error, const char *info)
                 errmsg = _("SSH transport error");
             else
                 errmsg = _("SSH transport error: %s");
+            break;
+        case VIR_ERR_AGENT_UNRESPONSIVE:
+            if (info == NULL)
+                errmsg = _("Guest agent is not responding");
+            else
+                errmsg = _("Guest agent is not responding: %s");
+            break;
     }
     return errmsg;
 }