|
|
99cbc7 |
From 71278b86a232d83e0e848b61514b9886e7e2697f Mon Sep 17 00:00:00 2001
|
|
|
99cbc7 |
Message-Id: <71278b86a232d83e0e848b61514b9886e7e2697f@dist-git>
|
|
|
99cbc7 |
From: Laine Stump <laine@laine.org>
|
|
|
99cbc7 |
Date: Thu, 11 Apr 2019 15:14:37 -0400
|
|
|
99cbc7 |
Subject: [PATCH] qemu_hotplug: move qemuDomainChangeGraphicsPasswords()
|
|
|
99cbc7 |
|
|
|
99cbc7 |
It was sitting down in the middle of all the qemuDomainDetach*()
|
|
|
99cbc7 |
functions. Move it up with the rest of the qemuDomain*Graphics*()
|
|
|
99cbc7 |
functions.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Laine Stump <laine@laine.org>
|
|
|
99cbc7 |
ACKed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
99cbc7 |
(cherry picked from commit 036a4521f3c539c58bb5706b4710db0f1a16eec6)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Partially-Resolves: https://bugzilla.redhat.com/1658198
|
|
|
99cbc7 |
Signed-off-by: Laine Stump <laine@redhat.com>
|
|
|
99cbc7 |
Signed-off-by: Laine Stump <laine@laine.org>
|
|
|
99cbc7 |
Message-Id: <20190411191453.24055-26-laine@redhat.com>
|
|
|
99cbc7 |
Acked-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
99cbc7 |
---
|
|
|
99cbc7 |
src/qemu/qemu_hotplug.c | 151 ++++++++++++++++++++--------------------
|
|
|
99cbc7 |
1 file changed, 77 insertions(+), 74 deletions(-)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
99cbc7 |
index 8a3946a6e2..d80b9b005b 100644
|
|
|
99cbc7 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
99cbc7 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
99cbc7 |
@@ -3574,6 +3574,83 @@ qemuDomainFindGraphicsIndex(virDomainDefPtr def,
|
|
|
99cbc7 |
return -1;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+int
|
|
|
99cbc7 |
+qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|
|
99cbc7 |
+ virDomainObjPtr vm,
|
|
|
99cbc7 |
+ int type,
|
|
|
99cbc7 |
+ virDomainGraphicsAuthDefPtr auth,
|
|
|
99cbc7 |
+ const char *defaultPasswd,
|
|
|
99cbc7 |
+ int asyncJob)
|
|
|
99cbc7 |
+{
|
|
|
99cbc7 |
+ qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
99cbc7 |
+ time_t now = time(NULL);
|
|
|
99cbc7 |
+ const char *expire;
|
|
|
99cbc7 |
+ char *validTo = NULL;
|
|
|
99cbc7 |
+ const char *connected = NULL;
|
|
|
99cbc7 |
+ const char *password;
|
|
|
99cbc7 |
+ int ret = -1;
|
|
|
99cbc7 |
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (!auth->passwd && !defaultPasswd) {
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ password = auth->passwd ? auth->passwd : defaultPasswd;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (auth->connected)
|
|
|
99cbc7 |
+ connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected);
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ ret = qemuMonitorSetPassword(priv->mon, type, password, connected);
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (ret == -2) {
|
|
|
99cbc7 |
+ if (type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
|
|
99cbc7 |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
99cbc7 |
+ _("Graphics password only supported for VNC"));
|
|
|
99cbc7 |
+ ret = -1;
|
|
|
99cbc7 |
+ } else {
|
|
|
99cbc7 |
+ ret = qemuMonitorSetVNCPassword(priv->mon, password);
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ if (ret != 0)
|
|
|
99cbc7 |
+ goto end_job;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (password[0] == '\0' ||
|
|
|
99cbc7 |
+ (auth->expires && auth->validTo <= now)) {
|
|
|
99cbc7 |
+ expire = "now";
|
|
|
99cbc7 |
+ } else if (auth->expires) {
|
|
|
99cbc7 |
+ if (virAsprintf(&validTo, "%lu", (unsigned long)auth->validTo) < 0)
|
|
|
99cbc7 |
+ goto end_job;
|
|
|
99cbc7 |
+ expire = validTo;
|
|
|
99cbc7 |
+ } else {
|
|
|
99cbc7 |
+ expire = "never";
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ ret = qemuMonitorExpirePassword(priv->mon, type, expire);
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (ret == -2) {
|
|
|
99cbc7 |
+ /* XXX we could fake this with a timer */
|
|
|
99cbc7 |
+ if (auth->expires) {
|
|
|
99cbc7 |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
99cbc7 |
+ _("Expiry of passwords is not supported"));
|
|
|
99cbc7 |
+ ret = -1;
|
|
|
99cbc7 |
+ } else {
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ end_job:
|
|
|
99cbc7 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
99cbc7 |
+ ret = -1;
|
|
|
99cbc7 |
+ cleanup:
|
|
|
99cbc7 |
+ VIR_FREE(validTo);
|
|
|
99cbc7 |
+ virObjectUnref(cfg);
|
|
|
99cbc7 |
+ return ret;
|
|
|
99cbc7 |
+}
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
int
|
|
|
99cbc7 |
qemuDomainChangeGraphics(virQEMUDriverPtr driver,
|
|
|
99cbc7 |
virDomainObjPtr vm,
|
|
|
99cbc7 |
@@ -5272,80 +5349,6 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
|
|
|
99cbc7 |
return ret;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
-int
|
|
|
99cbc7 |
-qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|
|
99cbc7 |
- virDomainObjPtr vm,
|
|
|
99cbc7 |
- int type,
|
|
|
99cbc7 |
- virDomainGraphicsAuthDefPtr auth,
|
|
|
99cbc7 |
- const char *defaultPasswd,
|
|
|
99cbc7 |
- int asyncJob)
|
|
|
99cbc7 |
-{
|
|
|
99cbc7 |
- qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
99cbc7 |
- time_t now = time(NULL);
|
|
|
99cbc7 |
- const char *expire;
|
|
|
99cbc7 |
- char *validTo = NULL;
|
|
|
99cbc7 |
- const char *connected = NULL;
|
|
|
99cbc7 |
- const char *password;
|
|
|
99cbc7 |
- int ret = -1;
|
|
|
99cbc7 |
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (!auth->passwd && !defaultPasswd) {
|
|
|
99cbc7 |
- ret = 0;
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
- }
|
|
|
99cbc7 |
- password = auth->passwd ? auth->passwd : defaultPasswd;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (auth->connected)
|
|
|
99cbc7 |
- connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected);
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
- ret = qemuMonitorSetPassword(priv->mon, type, password, connected);
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (ret == -2) {
|
|
|
99cbc7 |
- if (type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
|
|
99cbc7 |
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
99cbc7 |
- _("Graphics password only supported for VNC"));
|
|
|
99cbc7 |
- ret = -1;
|
|
|
99cbc7 |
- } else {
|
|
|
99cbc7 |
- ret = qemuMonitorSetVNCPassword(priv->mon, password);
|
|
|
99cbc7 |
- }
|
|
|
99cbc7 |
- }
|
|
|
99cbc7 |
- if (ret != 0)
|
|
|
99cbc7 |
- goto end_job;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (password[0] == '\0' ||
|
|
|
99cbc7 |
- (auth->expires && auth->validTo <= now)) {
|
|
|
99cbc7 |
- expire = "now";
|
|
|
99cbc7 |
- } else if (auth->expires) {
|
|
|
99cbc7 |
- if (virAsprintf(&validTo, "%lu", (unsigned long)auth->validTo) < 0)
|
|
|
99cbc7 |
- goto end_job;
|
|
|
99cbc7 |
- expire = validTo;
|
|
|
99cbc7 |
- } else {
|
|
|
99cbc7 |
- expire = "never";
|
|
|
99cbc7 |
- }
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- ret = qemuMonitorExpirePassword(priv->mon, type, expire);
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (ret == -2) {
|
|
|
99cbc7 |
- /* XXX we could fake this with a timer */
|
|
|
99cbc7 |
- if (auth->expires) {
|
|
|
99cbc7 |
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
99cbc7 |
- _("Expiry of passwords is not supported"));
|
|
|
99cbc7 |
- ret = -1;
|
|
|
99cbc7 |
- } else {
|
|
|
99cbc7 |
- ret = 0;
|
|
|
99cbc7 |
- }
|
|
|
99cbc7 |
- }
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- end_job:
|
|
|
99cbc7 |
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
99cbc7 |
- ret = -1;
|
|
|
99cbc7 |
- cleanup:
|
|
|
99cbc7 |
- VIR_FREE(validTo);
|
|
|
99cbc7 |
- virObjectUnref(cfg);
|
|
|
99cbc7 |
- return ret;
|
|
|
99cbc7 |
-}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
int qemuDomainAttachLease(virQEMUDriverPtr driver,
|
|
|
99cbc7 |
virDomainObjPtr vm,
|
|
|
99cbc7 |
--
|
|
|
99cbc7 |
2.21.0
|
|
|
99cbc7 |
|