A device needs to be checked for compatibility with the domain definition it corresponds to. Specifically, for VIR_DOMAIN_AFFECT_CONFIG case we should check against persistent def rather than active def. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/lxc/lxc_driver.c | 20 +++++++++++--------- src/qemu/qemu_driver.c | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1ae04c5..ca82fd2 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5015,13 +5015,14 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom, } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainDefCompatibleDevice(vm->def, dev) < 0) - goto cleanup; - /* Make a copy for updated domain. */ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto cleanup; + + if (virDomainDefCompatibleDevice(vmdef, dev) < 0) + goto cleanup; + if ((ret = lxcDomainAttachDeviceConfig(vmdef, dev)) < 0) goto cleanup; } @@ -5141,13 +5142,14 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom, } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainDefCompatibleDevice(vm->def, dev) < 0) - goto cleanup; - /* Make a copy for updated domain. */ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto cleanup; + + if (virDomainDefCompatibleDevice(vmdef, dev) < 0) + goto cleanup; + if ((ret = lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0) goto cleanup; } @@ -5251,14 +5253,14 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom, } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainDefCompatibleDevice(vm->def, dev) < 0) - goto cleanup; - /* Make a copy for updated domain. */ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto cleanup; + if (virDomainDefCompatibleDevice(vmdef, dev) < 0) + goto cleanup; + if ((ret = lxcDomainDetachDeviceConfig(vmdef, dev)) < 0) goto cleanup; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2707bec..8ec8912 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6946,13 +6946,14 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainDefCompatibleDevice(vm->def, dev) < 0) - goto endjob; - /* Make a copy for updated domain. */ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto endjob; + + if (virDomainDefCompatibleDevice(vmdef, dev) < 0) + goto endjob; + if ((ret = qemuDomainAttachDeviceConfig(qemuCaps, vmdef, dev)) < 0) goto endjob; } @@ -7089,14 +7090,14 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, goto cleanup; if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainDefCompatibleDevice(vm->def, dev) < 0) - goto endjob; - /* Make a copy for updated domain. */ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto endjob; + if (virDomainDefCompatibleDevice(vmdef, dev) < 0) + goto endjob; + if ((ret = qemuDomainUpdateDeviceConfig(qemuCaps, vmdef, dev)) < 0) goto endjob; } @@ -7228,13 +7229,14 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - if (virDomainDefCompatibleDevice(vm->def, dev) < 0) - goto endjob; - /* Make a copy for updated domain. */ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto endjob; + + if (virDomainDefCompatibleDevice(vmdef, dev) < 0) + goto endjob; + if ((ret = qemuDomainDetachDeviceConfig(vmdef, dev)) < 0) goto endjob; } -- 1.9.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list