mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-09 23:10:08 +00:00
test_driver: support VIR_DOMAIN_AFFECT_LIVE in testUpdateDeviceFlags()
Pick up some more of the qemu_driver.c code so this function supports both CONFIG and LIVE updates. Note that qemuDomainUpdateDeviceFlags() passed vm->def to virDomainDeviceDefParse() for the VIR_DOMAIN_AFFECT_CONFIG case, which is technically incorrect; in the test driver code we'll fix this. Signed-off-by: John Levon <john.levon@nutanix.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1ebb892472
commit
9559130693
@ -10239,7 +10239,7 @@ testDomainAttachDevice(virDomainPtr domain, const char *xml)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testDomainUpdateDeviceConfig(virDomainDef *vmdef,
|
testDomainUpdateDevice(virDomainDef *vmdef,
|
||||||
virDomainDeviceDef *dev,
|
virDomainDeviceDef *dev,
|
||||||
unsigned int parse_flags,
|
unsigned int parse_flags,
|
||||||
virDomainXMLOption *xmlopt)
|
virDomainXMLOption *xmlopt)
|
||||||
@ -10316,12 +10316,16 @@ testDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
testDriver *driver = dom->conn->privateData;
|
testDriver *driver = dom->conn->privateData;
|
||||||
virDomainObj *vm = NULL;
|
virDomainObj *vm = NULL;
|
||||||
virObjectEvent *event = NULL;
|
virObjectEvent *event = NULL;
|
||||||
|
virDomainDef *def = NULL;
|
||||||
|
virDomainDef *persistentDef = NULL;
|
||||||
g_autoptr(virDomainDef) vmdef = NULL;
|
g_autoptr(virDomainDef) vmdef = NULL;
|
||||||
g_autoptr(virDomainDeviceDef) dev = NULL;
|
g_autoptr(virDomainDeviceDef) dev_live = NULL;
|
||||||
|
g_autoptr(virDomainDeviceDef) dev_config = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
unsigned int parse_flags = 0;
|
unsigned int parse_flags = 0;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_CONFIG, -1);
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
|
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
||||||
|
|
||||||
if (!(vm = testDomObjFromDomain(dom)))
|
if (!(vm = testDomObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -10337,8 +10341,19 @@ testDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dev = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt,
|
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||||
NULL, parse_flags))) {
|
goto cleanup;
|
||||||
|
|
||||||
|
if (def) {
|
||||||
|
if (!(dev_live = virDomainDeviceDefParse(xml, def, driver->xmlopt,
|
||||||
|
NULL, parse_flags)))
|
||||||
|
goto endjob;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (persistentDef) {
|
||||||
|
if (!(dev_config = virDomainDeviceDefParse(xml, persistentDef,
|
||||||
|
driver->xmlopt, NULL,
|
||||||
|
parse_flags)))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10350,17 +10365,18 @@ testDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
/* virDomainDefCompatibleDevice call is delayed until we know the
|
/* virDomainDefCompatibleDevice call is delayed until we know the
|
||||||
* device we're going to update. */
|
* device we're going to update. */
|
||||||
if ((ret = testDomainUpdateDeviceConfig(vmdef, dev,
|
if ((ret = testDomainUpdateDevice(vmdef, dev_config,
|
||||||
parse_flags,
|
parse_flags,
|
||||||
driver->xmlopt)) < 0)
|
driver->xmlopt)) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||||
ret = -1;
|
/* virDomainDefCompatibleDevice call is delayed until we know the
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
* device we're going to update. */
|
||||||
_("live update of device '%1$s' is not supported"),
|
if ((ret = testDomainUpdateDevice(def, dev_live,
|
||||||
virDomainDeviceTypeToString(dev->type));
|
parse_flags,
|
||||||
|
driver->xmlopt)) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user