---
src/qemu/qemu_driver.c | 54 +++++++++++---------------------------------------
1 file changed, 12 insertions(+), 42 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1f43386..72da014 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3246,8 +3246,8 @@ qemuDomainManagedSavePath(virQEMUDriverPtr driver, virDomainObjPtr
vm) {
static int
qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
{
- virQEMUDriverPtr driver = dom->conn->privateData;
- virDomainObjPtr vm = NULL;
+ virQEMUDriverPtr driver;
+ virDomainObjPtr vm;
char *name = NULL;
int ret = -1;
int compressed;
@@ -3256,15 +3256,8 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
VIR_DOMAIN_SAVE_RUNNING |
VIR_DOMAIN_SAVE_PAUSED, -1);
- qemuDriverLock(driver);
- vm = virDomainFindByUUID(&driver->domains, dom->uuid);
- if (!vm) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(dom->uuid, uuidstr);
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching uuid '%s'"),
uuidstr);
- goto cleanup;
- }
+ if (!(vm = qemuDomObjFromDomainDriver(dom, &driver)))
+ return -1;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
@@ -3323,50 +3316,28 @@ cleanup:
static int
qemuDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
{
- virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm = NULL;
- int ret = -1;
virCheckFlags(0, -1);
- qemuDriverLock(driver);
- vm = virDomainFindByUUID(&driver->domains, dom->uuid);
- if (!vm) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(dom->uuid, uuidstr);
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching uuid '%s'"),
uuidstr);
- goto cleanup;
- }
-
- ret = vm->hasManagedSave;
+ if (!(vm = qemuDomObjFromDomain(dom)))
+ return -1;
-cleanup:
- if (vm)
- virDomainObjUnlock(vm);
- qemuDriverUnlock(driver);
- return ret;
+ return vm->hasManagedSave;
}
static int
qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
{
- virQEMUDriverPtr driver = dom->conn->privateData;
- virDomainObjPtr vm = NULL;
+ virQEMUDriverPtr driver;
+ virDomainObjPtr vm;
int ret = -1;
char *name = NULL;
virCheckFlags(0, -1);
- qemuDriverLock(driver);
- vm = virDomainFindByUUID(&driver->domains, dom->uuid);
- if (!vm) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(dom->uuid, uuidstr);
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching uuid '%s'"),
uuidstr);
- goto cleanup;
- }
+ if (!(vm = qemuDomObjFromDomainDriver(dom, &driver)))
+ return -1;
name = qemuDomainManagedSavePath(driver, vm);
if (name == NULL)
@@ -3377,8 +3348,7 @@ qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
cleanup:
VIR_FREE(name);
- if (vm)
- virDomainObjUnlock(vm);
+ virDomainObjUnlock(vm);
qemuDriverUnlock(driver);
return ret;
}
--
1.8.0