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 graphics arguments changed with config flag. Signed-off-by: Wang Rui <moon.wangrui@xxxxxxxxxx> --- src/conf/domain_conf.c | 2 +- src/qemu/qemu_driver.c | 18 +++++++++++++++++- src/qemu/qemu_hotplug.c | 14 ++++++++++++++ src/qemu/qemu_hotplug.h | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2d81c37..468260c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21066,7 +21066,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, { virDomainDeviceDefPtr ret = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; - int flags = VIR_DOMAIN_XML_INACTIVE; + int flags = VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE; char *xmlStr = NULL; int rc = -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9152cf5..fa03cbe 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7460,6 +7460,7 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps, virDomainDeviceDefPtr dev) { virDomainDiskDefPtr orig, disk; + virDomainGraphicsDefPtr newGraphics; virDomainNetDefPtr net; int pos; @@ -7498,6 +7499,22 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps, orig->startupPolicy = disk->startupPolicy; break; + case VIR_DOMAIN_DEVICE_GRAPHICS: + newGraphics = dev->data.graphics; + pos = qemuDomainFindGraphicsIndex(vmdef, newGraphics); + if (pos < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot find existing graphics type '%s' device to modify"), + virDomainGraphicsTypeToString(newGraphics->type)); + return -1; + } + + virDomainGraphicsDefFree(vmdef->graphics[pos]); + + vmdef->graphics[pos] = newGraphics; + dev->data.graphics = NULL; + break; + case VIR_DOMAIN_DEVICE_NET: net = dev->data.net; if ((pos = virDomainNetFindIdx(vmdef, net)) < 0) @@ -7517,7 +7534,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: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ec0122b..d7437db 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2312,6 +2312,20 @@ qemuDomainFindGraphics(virDomainObjPtr vm, } int +qemuDomainFindGraphicsIndex(virDomainDefPtr def, + virDomainGraphicsDefPtr dev) +{ + size_t i; + + for (i = 0; i < def->ngraphics; i++) { + if (def->graphics[i]->type == dev->type) + return i; + } + + return -1; +} + +int qemuDomainChangeGraphics(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainGraphicsDefPtr dev) diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 1c9ca8f..d13c532 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -55,6 +55,8 @@ int qemuDomainAttachHostDevice(virConnectPtr conn, virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev); +int qemuDomainFindGraphicsIndex(virDomainDefPtr def, + virDomainGraphicsDefPtr dev); int qemuDomainChangeGraphics(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainGraphicsDefPtr dev); -- 1.7.12.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list