提交 6dc75f56 编写于 作者: J Jiri Denemark

Fix usage of virDomainDefCompatibleDevice

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: NJiri Denemark <jdenemar@redhat.com>
上级 cfa7ceab
...@@ -5025,13 +5025,14 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom, ...@@ -5025,13 +5025,14 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (virDomainDefCompatibleDevice(vm->def, dev) < 0)
goto cleanup;
/* Make a copy for updated domain. */ /* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef) if (!vmdef)
goto cleanup; goto cleanup;
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto cleanup;
if ((ret = lxcDomainAttachDeviceConfig(vmdef, dev)) < 0) if ((ret = lxcDomainAttachDeviceConfig(vmdef, dev)) < 0)
goto cleanup; goto cleanup;
} }
...@@ -5151,13 +5152,14 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom, ...@@ -5151,13 +5152,14 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (virDomainDefCompatibleDevice(vm->def, dev) < 0)
goto cleanup;
/* Make a copy for updated domain. */ /* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef) if (!vmdef)
goto cleanup; goto cleanup;
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto cleanup;
if ((ret = lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0) if ((ret = lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0)
goto cleanup; goto cleanup;
} }
...@@ -5261,14 +5263,14 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom, ...@@ -5261,14 +5263,14 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (virDomainDefCompatibleDevice(vm->def, dev) < 0)
goto cleanup;
/* Make a copy for updated domain. */ /* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef) if (!vmdef)
goto cleanup; goto cleanup;
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto cleanup;
if ((ret = lxcDomainDetachDeviceConfig(vmdef, dev)) < 0) if ((ret = lxcDomainDetachDeviceConfig(vmdef, dev)) < 0)
goto cleanup; goto cleanup;
} }
......
...@@ -6972,13 +6972,14 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml, ...@@ -6972,13 +6972,14 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
goto cleanup; goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (virDomainDefCompatibleDevice(vm->def, dev) < 0)
goto endjob;
/* Make a copy for updated domain. */ /* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef) if (!vmdef)
goto endjob; goto endjob;
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto endjob;
if ((ret = qemuDomainAttachDeviceConfig(qemuCaps, vmdef, dev)) < 0) if ((ret = qemuDomainAttachDeviceConfig(qemuCaps, vmdef, dev)) < 0)
goto endjob; goto endjob;
} }
...@@ -7115,14 +7116,14 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, ...@@ -7115,14 +7116,14 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
goto cleanup; goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (virDomainDefCompatibleDevice(vm->def, dev) < 0)
goto endjob;
/* Make a copy for updated domain. */ /* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef) if (!vmdef)
goto endjob; goto endjob;
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto endjob;
if ((ret = qemuDomainUpdateDeviceConfig(qemuCaps, vmdef, dev)) < 0) if ((ret = qemuDomainUpdateDeviceConfig(qemuCaps, vmdef, dev)) < 0)
goto endjob; goto endjob;
} }
...@@ -7254,13 +7255,14 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, ...@@ -7254,13 +7255,14 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
goto cleanup; goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (virDomainDefCompatibleDevice(vm->def, dev) < 0)
goto endjob;
/* Make a copy for updated domain. */ /* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef) if (!vmdef)
goto endjob; goto endjob;
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto endjob;
if ((ret = qemuDomainDetachDeviceConfig(vmdef, dev)) < 0) if ((ret = qemuDomainDetachDeviceConfig(vmdef, dev)) < 0)
goto endjob; goto endjob;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册