[libvirt] [PATCH 3/3] qemu: make persistent update of graphics device supported
Ján Tomko
jtomko at redhat.com
Thu Dec 4 13:10:12 UTC 2014
On 11/19/2014 05:50 AM, Wang Rui wrote:
> 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 at 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);
I'd rather add the flag to the 'flags' variable initialization. (It has no
effect on formatting other devices anyway).
> 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;
> +
We can just free the old device and replace it with the new one, like we do
for DEVICE_NET. (This will also make it work for other graphics types)
Jan
> + 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:
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141204/94e0303b/attachment-0001.sig>
More information about the libvir-list
mailing list