提交 c57f3fd2 编写于 作者: M Michal Privoznik

conf: Validate device on update-device

https://bugzilla.redhat.com/show_bug.cgi?id=1439991

Whenever a device is being updated via
virDomainUpdateDeviceFlags() API, we parse the device XML and
ideally run some generic checks to validate the configuration
(e.g. if device defines per-device boot order but the domain has
os/boot element already). Well, that's the theory - due to a
missing check we've jumped early from that check function.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 fbe315bd
......@@ -26023,14 +26023,10 @@ virDomainDeviceInfoCheckBootIndex(virDomainDefPtr def ATTRIBUTE_UNUSED,
int
virDomainDefCompatibleDevice(virDomainDefPtr def,
virDomainDeviceDefPtr dev,
virDomainDeviceAction action)
virDomainDeviceDefPtr dev)
{
virDomainDeviceInfoPtr info = virDomainDeviceGetInfo(dev);
if (action != VIR_DOMAIN_DEVICE_ACTION_ATTACH)
return 0;
if (!virDomainDefHasUSB(def) &&
def->os.type != VIR_DOMAIN_OSTYPE_EXE &&
virDomainDeviceIsUSB(dev)) {
......
......@@ -2962,8 +2962,7 @@ typedef enum {
} virDomainDeviceAction;
int virDomainDefCompatibleDevice(virDomainDefPtr def,
virDomainDeviceDefPtr dev,
virDomainDeviceAction action);
virDomainDeviceDefPtr dev);
void virDomainRNGDefFree(virDomainRNGDefPtr def);
......
......@@ -4806,8 +4806,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
if (!vmdef)
goto endjob;
if (virDomainDefCompatibleDevice(vmdef, dev,
VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto endjob;
if ((ret = lxcDomainAttachDeviceConfig(vmdef, dev)) < 0)
......@@ -4815,8 +4814,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (virDomainDefCompatibleDevice(vm->def, dev_copy,
VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
goto endjob;
if ((ret = lxcDomainAttachDeviceLive(dom->conn, driver, vm, dev_copy)) < 0)
......@@ -4919,8 +4917,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
if (!vmdef)
goto endjob;
if (virDomainDefCompatibleDevice(vmdef, dev,
VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0)
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto endjob;
if ((ret = lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0)
......@@ -4928,8 +4925,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (virDomainDefCompatibleDevice(vm->def, dev_copy,
VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0)
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
goto endjob;
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
......@@ -5016,19 +5012,11 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
if (!vmdef)
goto endjob;
if (virDomainDefCompatibleDevice(vmdef, dev,
VIR_DOMAIN_DEVICE_ACTION_DETACH) < 0)
goto endjob;
if ((ret = lxcDomainDetachDeviceConfig(vmdef, dev)) < 0)
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (virDomainDefCompatibleDevice(vm->def, dev_copy,
VIR_DOMAIN_DEVICE_ACTION_DETACH) < 0)
goto endjob;
if ((ret = lxcDomainDetachDeviceLive(driver, vm, dev_copy)) < 0)
goto endjob;
/*
......
......@@ -8303,8 +8303,7 @@ qemuDomainAttachDeviceLiveAndConfig(virConnectPtr conn,
if (!vmdef)
goto cleanup;
if (virDomainDefCompatibleDevice(vmdef, dev,
VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto cleanup;
if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, conn, caps,
parse_flags,
......@@ -8313,8 +8312,7 @@ qemuDomainAttachDeviceLiveAndConfig(virConnectPtr conn,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (virDomainDefCompatibleDevice(vm->def, dev_copy,
VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
goto cleanup;
if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, conn, driver)) < 0)
......@@ -8454,8 +8452,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
if (!vmdef)
goto endjob;
if (virDomainDefCompatibleDevice(vmdef, dev,
VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0)
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
goto endjob;
if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps,
......@@ -8465,8 +8462,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (virDomainDefCompatibleDevice(vm->def, dev_copy,
VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0)
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
goto endjob;
if ((ret = qemuDomainUpdateDeviceLive(dom->conn, vm, dev_copy, dom, force)) < 0)
......@@ -8554,10 +8550,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
if (!vmdef)
goto cleanup;
if (virDomainDefCompatibleDevice(vmdef, dev,
VIR_DOMAIN_DEVICE_ACTION_DETACH) < 0)
goto cleanup;
if ((ret = qemuDomainDetachDeviceConfig(vmdef, dev, caps,
parse_flags,
driver->xmlopt)) < 0)
......@@ -8565,10 +8557,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (virDomainDefCompatibleDevice(vm->def, dev_copy,
VIR_DOMAIN_DEVICE_ACTION_DETACH) < 0)
goto cleanup;
if ((ret = qemuDomainDetachDeviceLive(vm, dev_copy, driver)) < 0)
goto cleanup;
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册