Similar to the QEMU and LXC drivers, add a helper function to lookup a domain, and use it instead of much copy and paste. Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx> --- src/libxl/libxl_driver.c | 269 ++++++++++------------------------------------- 1 file changed, 56 insertions(+), 213 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 22bd26f..17d1960 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -77,6 +77,27 @@ static int libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm, bool start_paused, int restore_fd); + +/* Function definitions */ +static virDomainObjPtr +libxlDomObjFromDomain(virDomainPtr dom) +{ + virDomainObjPtr vm; + libxlDriverPrivatePtr driver = dom->conn->privateData; + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); + if (!vm) { + virUUIDFormat(dom->uuid, uuidstr); + virReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s' (%s)"), + uuidstr, dom->name); + return NULL; + } + + return vm; +} + static void libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event) { @@ -1260,14 +1281,8 @@ libxlDomainSuspend(virDomainPtr dom) virDomainEventPtr event = NULL; int ret = -1; - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1318,14 +1333,8 @@ libxlDomainResume(virDomainPtr dom) virDomainEventPtr event = NULL; int ret = -1; - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1369,21 +1378,14 @@ cleanup: static int libxlDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; libxlDomainObjPrivatePtr priv; virCheckFlags(0, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1423,21 +1425,14 @@ libxlDomainShutdown(virDomainPtr dom) static int libxlDomainReboot(virDomainPtr dom, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; libxlDomainObjPrivatePtr priv; virCheckFlags(0, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainRebootEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1474,14 +1469,8 @@ libxlDomainDestroyFlags(virDomainPtr dom, virCheckFlags(0, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1525,18 +1514,11 @@ libxlDomainDestroy(virDomainPtr dom) static char * libxlDomainGetOSType(virDomainPtr dom) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; char *type = NULL; - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1553,15 +1535,11 @@ cleanup: static unsigned long long libxlDomainGetMaxMemory(virDomainPtr dom) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; unsigned long long ret = 0; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1590,11 +1568,8 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, VIR_DOMAIN_MEM_CONFIG | VIR_DOMAIN_MEM_MAXIMUM, -1); - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -1707,18 +1682,13 @@ libxlDomainSetMaxMemory(virDomainPtr dom, unsigned long memory) static int libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; libxl_dominfo d_info; libxlDomainObjPrivatePtr priv; int ret = -1; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1755,18 +1725,13 @@ libxlDomainGetState(virDomainPtr dom, int *reason, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; virCheckFlags(0, -1); - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1872,14 +1837,8 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml, return -1; } - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1989,14 +1948,8 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags) virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2075,14 +2028,8 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags) virCheckFlags(0, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2145,20 +2092,13 @@ cleanup: static int libxlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm = NULL; int ret = -1; virCheckFlags(0, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainHasManagedSaveImageEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2181,14 +2121,8 @@ libxlDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) virCheckFlags(0, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainManagedSaveRemoveEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2243,11 +2177,8 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, return -1; } - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -2351,7 +2282,6 @@ libxlDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) static int libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; virDomainDefPtr def; int ret = -1; @@ -2361,11 +2291,8 @@ libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) VIR_DOMAIN_VCPU_CONFIG | VIR_DOMAIN_VCPU_MAXIMUM, -1); - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2419,11 +2346,8 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap, int ret = -1; libxl_bitmap map; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainPinVcpuEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2476,7 +2400,6 @@ static int libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo, unsigned char *cpumaps, int maplen) { - libxlDriverPrivatePtr driver = dom->conn->privateData; libxlDomainObjPrivatePtr priv; virDomainObjPtr vm; int ret = -1; @@ -2485,11 +2408,8 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo, size_t i; unsigned char *cpumap; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2542,18 +2462,13 @@ cleanup: static char * libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; char *ret = NULL; /* Flags checked by virDomainDefFormat */ - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -2696,14 +2611,8 @@ libxlDomainCreateWithFlags(virDomainPtr dom, virCheckFlags(VIR_DOMAIN_START_PAUSED, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2803,15 +2712,8 @@ libxlDomainUndefineFlags(virDomainPtr dom, virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, -1); - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -3232,11 +3134,8 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml, virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE | VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1); - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -3339,11 +3238,8 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE | VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1); - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -3446,11 +3342,8 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml, virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE | VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1); - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -3642,18 +3535,11 @@ libxlConnectDomainEventDeregister(virConnectPtr conn, static int libxlDomainGetAutostart(virDomainPtr dom, int *autostart) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetAutostartEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -3676,14 +3562,8 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart) char *configFile = NULL, *autostartLink = NULL; int ret = -1; - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -3741,18 +3621,14 @@ cleanup: static char * libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams) { - libxlDriverPrivatePtr driver = dom->conn->privateData; libxlDomainObjPrivatePtr priv; virDomainObjPtr vm; char * ret = NULL; const char *name = NULL; libxl_scheduler sched_id; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -3803,7 +3679,6 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom, int *nparams, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; libxlDomainObjPrivatePtr priv; virDomainObjPtr vm; libxl_domain_sched_params sc_info; @@ -3815,12 +3690,8 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom, /* We don't return strings, and thus trivially support this flag. */ flags &= ~VIR_TYPED_PARAM_STRING_OKAY; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -3881,7 +3752,6 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom, int nparams, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; libxlDomainObjPrivatePtr priv; virDomainObjPtr vm; libxl_domain_sched_params sc_info; @@ -3898,11 +3768,8 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom, NULL) < 0) return -1; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -3960,7 +3827,6 @@ libxlDomainOpenConsole(virDomainPtr dom, virStreamPtr st, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm = NULL; int ret = -1; virDomainChrDefPtr chr = NULL; @@ -3976,14 +3842,8 @@ libxlDomainOpenConsole(virDomainPtr dom, goto cleanup; } - vm = virDomainObjListFindByUUID(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); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -4059,7 +3919,6 @@ libxlDomainGetNumaParameters(virDomainPtr dom, int *nparams, unsigned int flags) { - libxlDriverPrivatePtr driver = dom->conn->privateData; libxlDomainObjPrivatePtr priv; virDomainObjPtr vm; libxl_bitmap nodemap; @@ -4077,12 +3936,8 @@ libxlDomainGetNumaParameters(virDomainPtr dom, * the filtering on behalf of older clients that can't parse it. */ flags &= ~VIR_TYPED_PARAM_STRING_OKAY; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -4183,15 +4038,11 @@ cleanup: static int libxlDomainIsActive(virDomainPtr dom) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr obj; int ret = -1; - obj = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!obj) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); + if (!(obj = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainIsActiveEnsureACL(dom->conn, obj->def) < 0) goto cleanup; @@ -4207,15 +4058,11 @@ libxlDomainIsActive(virDomainPtr dom) static int libxlDomainIsPersistent(virDomainPtr dom) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr obj; int ret = -1; - obj = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!obj) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); + if (!(obj = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainIsPersistentEnsureACL(dom->conn, obj->def) < 0) goto cleanup; @@ -4231,15 +4078,11 @@ libxlDomainIsPersistent(virDomainPtr dom) static int libxlDomainIsUpdated(virDomainPtr dom) { - libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; - vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); + if (!(vm = libxlDomObjFromDomain(dom))) goto cleanup; - } if (virDomainIsUpdatedEnsureACL(dom->conn, vm->def) < 0) goto cleanup; -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list