提交 390665a9 编写于 作者: N Nikolay Shirokovskiy 提交者: John Ferlan

libxl: reuse virDomainObjUpdateModificationImpact

Original current flag expansion does not filter out non
_CONFIG and _LIVE flags explicitly but they are prohibited
earlier by virCheckFlags.
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 7d3230d3
...@@ -3655,25 +3655,8 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml, ...@@ -3655,25 +3655,8 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
goto cleanup; goto cleanup;
if (virDomainObjIsActive(vm)) { if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
} else {
if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
/* check consistency between flags and the vm state */
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is not running"));
goto endjob; goto endjob;
}
}
if ((flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) && !vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify device on transient domain"));
goto endjob;
}
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
if (!(dev = virDomainDeviceDefParse(xml, vm->def, if (!(dev = virDomainDeviceDefParse(xml, vm->def,
...@@ -3763,25 +3746,8 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, ...@@ -3763,25 +3746,8 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
goto cleanup; goto cleanup;
if (virDomainObjIsActive(vm)) { if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
} else {
if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
/* check consistency between flags and the vm state */
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is not running"));
goto endjob; goto endjob;
}
}
if ((flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) && !vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify device on transient domain"));
goto endjob;
}
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
if (!(dev = virDomainDeviceDefParse(xml, vm->def, if (!(dev = virDomainDeviceDefParse(xml, vm->def,
...@@ -3868,25 +3834,8 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml, ...@@ -3868,25 +3834,8 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup; goto cleanup;
if (virDomainObjIsActive(vm)) { if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
} else {
if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
/* check consistency between flags and the vm state */
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is not running"));
goto cleanup;
}
}
if ((flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) && !vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify device on transient domain"));
goto cleanup; goto cleanup;
}
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
if (!(dev = virDomainDeviceDefParse(xml, vm->def, if (!(dev = virDomainDeviceDefParse(xml, vm->def,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册