diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 5b4874688c7cb68bbe963321ed60e6d1dff30c94..95f90ef4cc90214da7f88e158b3659ca2858b4fd 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -2128,12 +2128,6 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, virDomainObjPtr vm, } vm->hasManagedSave = true; - - if (!vm->persistent) { - virDomainRemoveInactive(&driver->domains, vm); - vm = NULL; - } - ret = 0; cleanup: @@ -2176,7 +2170,15 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml, goto cleanup; } - ret = libxlDoDomainSave(driver, vm, to); + if (libxlDoDomainSave(driver, vm, to) < 0) + goto cleanup; + + if (!vm->persistent) { + virDomainRemoveInactive(&driver->domains, vm); + vm = NULL; + } + + ret = 0; cleanup: if (vm) @@ -2375,7 +2377,15 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags) VIR_INFO("Saving state to %s", name); - ret = libxlDoDomainSave(driver, vm, name); + if (libxlDoDomainSave(driver, vm, name) < 0) + goto cleanup; + + if (!vm->persistent) { + virDomainRemoveInactive(&driver->domains, vm); + vm = NULL; + } + + ret = 0; cleanup: if (vm)