Patch 55ce6564634 caused a problem fixed in 1e0534a7702, described as below: Some members are generated during XML parse (e.g. MAC address of an interface); However, with current implementation, if we are plugging a device both to persistent and live config, we parse given XML twice: first time for live, second for config. This is wrong then as the second time we are not guaranteed to generate same values as we did for the first time. To solve that, we should use the same def when attaching a device config and live. And leave the current process unchanged when using --config and --live separately. Signed-off-by: Wu Jing <wujing42@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 617d7d5..eca54d0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8615,6 +8615,22 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + if (flags & VIR_DOMAIN_AFFECT_CONFIG && + flags & VIR_DOMAIN_AFFECT_LIVE) { + /* If we are affecting both CONFIG and LIVE + * use the same xml of device preferentially + * to make the configuration consistent. + */ + devLive = virDomainDeviceDefParse(xml, vm->def, + caps, driver->xmlopt, + parse_flags); + if (!devLive) + goto cleanup; + devConf = virDomainDeviceDefCopy(devLive, vm->def, caps, driver->xmlopt); + if (!devConf) + goto cleanup; + } + /* The config and live post processing address auto-generation algorithms * rely on the correct vm->def or vm->newDef being passed, so call the * device parse based on which definition is in use */ @@ -8623,7 +8639,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm, if (!vmdef) goto cleanup; - if (!(devConf = virDomainDeviceDefParse(xml, vmdef, caps, + if (!devConf && + !(devConf = virDomainDeviceDefParse(xml, vmdef, caps, driver->xmlopt, parse_flags))) goto cleanup; @@ -8643,7 +8660,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm, } if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (!(devLive = virDomainDeviceDefParse(xml, vm->def, caps, + if (!devLive && + !(devLive = virDomainDeviceDefParse(xml, vm->def, caps, driver->xmlopt, parse_flags))) goto cleanup; -- 2.19.1 |
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list