]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix startup with VNC password expiry on old QEMU
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 18 Jan 2011 18:37:45 +0000 (18:37 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 21 Jan 2011 16:24:13 +0000 (16:24 +0000)
The code which set VNC passwords correctly had fallback for
the set_password command, but was lacking it for the
expire_password command. This made it impossible to start
a guest. It also failed to check whether QEMU was still
running after the initial 'set_password' command completed

* src/qemu/qemu_hotplug.c: Fix error handling when
  password expiry fails
* src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_text.c: Fix
  return code for missing expire_password command

src/qemu/qemu_hotplug.c
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_text.c

index a4227dd5af9bc7db93cbdf8794562fbc0226b31e..8be993bd13c6123cc039ab666cdeeb47fecb80fe 100644 (file)
@@ -1751,6 +1751,15 @@ qemuDomainChangeGraphicsPasswords(struct qemud_driver *driver,
                                             auth->passwd ? auth->passwd : defaultPasswd);
         }
     }
+    if (ret != 0)
+        goto cleanup;
+
+    if (!virDomainObjIsActive(vm)) {
+        ret = -1;
+        qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("guest unexpectedly quit"));
+        goto cleanup;
+    }
 
     if (auth->expires) {
         time_t lifetime = auth->validTo - now;
@@ -1770,9 +1779,12 @@ qemuDomainChangeGraphicsPasswords(struct qemud_driver *driver,
             qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                             _("Expiry of passwords is not supported"));
             ret = -1;
+        } else {
+            ret = 0;
         }
     }
 
+cleanup:
     qemuDomainObjExitMonitorWithDriver(driver, vm);
 
     return ret;
index 7387089aff4467c1338202f0a094389e4e5fc92f..2e159c754bf0b31a2c9f20d2395b3c275d19a432 100644 (file)
@@ -1298,6 +1298,7 @@ cleanup:
     return ret;
 }
 
+/* Returns -1 on error, -2 if not supported */
 int qemuMonitorJSONExpirePassword(qemuMonitorPtr mon,
                                   const char *protocol,
                                   const char *expire_time)
@@ -1313,9 +1314,16 @@ int qemuMonitorJSONExpirePassword(qemuMonitorPtr mon,
 
     ret = qemuMonitorJSONCommand(mon, cmd, &reply);
 
-    if (ret == 0)
+    if (ret == 0) {
+        if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
+            ret = -2;
+            goto cleanup;
+        }
+
         ret = qemuMonitorJSONCheckError(cmd, reply);
+    }
 
+cleanup:
     virJSONValueFree(cmd);
     virJSONValueFree(reply);
     return ret;
index 291d958135e361199ecbfddc3723bf55ca410d42..4cf87fefa9f92996a46f25fa3b479061473a5cb0 100644 (file)
@@ -803,6 +803,7 @@ cleanup:
     return ret;
 }
 
+/* Returns -1 on error, -2 if not supported */
 int qemuMonitorTextExpirePassword(qemuMonitorPtr mon,
                                   const char *protocol,
                                   const char *expire_time)
@@ -824,8 +825,7 @@ int qemuMonitorTextExpirePassword(qemuMonitorPtr mon,
     }
 
     if (strstr(reply, "unknown command:")) {
-        qemuReportError(VIR_ERR_NO_SUPPORT,
-                        _("expiring password not supported by this qemu: %s"), reply);
+        ret = -2;
         goto cleanup;
     }