qemu: make persistent update of graphics device supported

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@huawei.com>
This commit is contained in:
Wang Rui 2014-12-08 21:48:33 +08:00 committed by Michal Privoznik
parent dec5f07b9e
commit 9603bce7b1
4 changed files with 34 additions and 2 deletions

View File

@ -21136,7 +21136,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;

View File

@ -7451,6 +7451,7 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
virDomainDeviceDefPtr dev)
{
virDomainDiskDefPtr orig, disk;
virDomainGraphicsDefPtr newGraphics;
virDomainNetDefPtr net;
int pos;
@ -7489,6 +7490,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)
@ -7508,7 +7525,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:

View File

@ -2271,6 +2271,20 @@ qemuDomainFindGraphics(virDomainObjPtr vm,
return NULL;
}
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,

View File

@ -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);