We can change vnc password by using virDomainUpdateDeviceFlags API with
live flag. But it can't be changed with config flag. Error is reported as
below.
error: Operation not supported: persistent update of device 'graphics' is not
supported
This patch supports the vnc/spice auth arguments changed with config flag.
Signed-off-by: Wang Rui <moon.wangrui(a)huawei.com>
---
src/conf/domain_conf.c | 3 ++-
src/qemu/qemu_driver.c | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5f4b9f6..5879f54 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20847,7 +20847,8 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
rc = virDomainControllerDefFormat(&buf, src->data.controller, flags);
break;
case VIR_DOMAIN_DEVICE_GRAPHICS:
- rc = virDomainGraphicsDefFormat(&buf, src->data.graphics, flags);
+ rc = virDomainGraphicsDefFormat(&buf, src->data.graphics,
+ flags | VIR_DOMAIN_XML_SECURE);
break;
case VIR_DOMAIN_DEVICE_HUB:
rc = virDomainHubDefFormat(&buf, src->data.hub, flags);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a84fd47..3096ae4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7397,11 +7397,48 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
virDomainDefPtr vmdef,
virDomainDeviceDefPtr dev)
{
+ virDomainGraphicsDefPtr graphics, newGraphics;
virDomainDiskDefPtr orig, disk;
virDomainNetDefPtr net;
int pos;
switch ((virDomainDeviceType) dev->type) {
+ case VIR_DOMAIN_DEVICE_GRAPHICS:
+ newGraphics = dev->data.graphics;
+ graphics = qemuDomainFindGraphics(vmdef, newGraphics);
+ if (!graphics) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot find existing graphics type '%s' device
to modify"),
+ virDomainGraphicsTypeToString(newGraphics->type));
+ return -1;
+ }
+ switch (graphics->type) {
+ case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+ VIR_FREE(graphics->data.vnc.auth.passwd);
+ graphics->data.vnc.auth.passwd =
newGraphics->data.vnc.auth.passwd;
+ newGraphics->data.vnc.auth.passwd = NULL;
+ graphics->data.vnc.auth.validTo =
newGraphics->data.vnc.auth.validTo;
+ graphics->data.vnc.auth.expires =
newGraphics->data.vnc.auth.expires;
+ graphics->data.vnc.auth.connected =
newGraphics->data.vnc.auth.connected;
+ break;
+
+ case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+ VIR_FREE(graphics->data.spice.auth.passwd);
+ graphics->data.spice.auth.passwd =
newGraphics->data.spice.auth.passwd;
+ newGraphics->data.spice.auth.passwd = NULL;
+ graphics->data.spice.auth.validTo =
newGraphics->data.spice.auth.validTo;
+ graphics->data.spice.auth.expires =
newGraphics->data.spice.auth.expires;
+ graphics->data.spice.auth.connected =
newGraphics->data.spice.auth.connected;
+ break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to change config on '%s' graphics
type"),
+ virDomainGraphicsTypeToString(newGraphics->type));
+ return -1;
+ }
+ break;
+
case VIR_DOMAIN_DEVICE_DISK:
disk = dev->data.disk;
pos = virDomainDiskIndexByName(vmdef, disk->dst, false);
@@ -7455,7 +7492,6 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
case VIR_DOMAIN_DEVICE_SOUND:
case VIR_DOMAIN_DEVICE_VIDEO:
case VIR_DOMAIN_DEVICE_WATCHDOG:
- case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB:
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_MEMBALLOON:
--
1.7.12.4