driver->xmlopt)))
goto endjob;
- if ((ret = libxlDomainAttachDeviceConfig(vmdef, dev)) < 0)
+ if (libxlDomainAttachDeviceConfig(vmdef, dev) < 0)
goto endjob;
- } else {
- ret = 0;
}
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
VIR_DOMAIN_XML_INACTIVE)))
goto endjob;
- if ((ret = libxlDomainAttachDeviceLive(driver, priv, vm, dev)) < 0)
+ if (libxlDomainAttachDeviceLive(driver, priv, vm, dev) < 0)
goto endjob;
/*
* changed even if we attach the device failed.
*/
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
- ret = -1;
+ goto endjob;
}
+ ret = 0;
+
/* Finally, if no error until here, we can save config. */
- if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) {
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
driver->xmlopt)))
goto endjob;
- if ((ret = libxlDomainDetachDeviceConfig(vmdef, dev)) < 0)
+ if (libxlDomainDetachDeviceConfig(vmdef, dev) < 0)
goto endjob;
- } else {
- ret = 0;
}
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
VIR_DOMAIN_XML_INACTIVE)))
goto endjob;
- if ((ret = libxlDomainDetachDeviceLive(driver, priv, vm, dev)) < 0)
+ if (libxlDomainDetachDeviceLive(driver, priv, vm, dev) < 0)
goto endjob;
/*
* changed even if we attach the device failed.
*/
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
- ret = -1;
+ goto endjob;
}
+ ret = 0;
+
/* Finally, if no error until here, we can save config. */
- if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) {
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);