mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 15:52:55 +00:00
libxl: Remove unnecessary driver locking
Now that most fields of libxlDriverPrivate struct are immutable or self-locking, there is no need to acquire the driver lock in much of the libxl driver.
This commit is contained in:
parent
cf735fe03c
commit
21bdbb829f
@ -1110,7 +1110,12 @@ error:
|
|||||||
libxlDriverConfigPtr
|
libxlDriverConfigPtr
|
||||||
libxlDriverConfigGet(libxlDriverPrivatePtr driver)
|
libxlDriverConfigGet(libxlDriverPrivatePtr driver)
|
||||||
{
|
{
|
||||||
return virObjectRef(driver->config);
|
libxlDriverConfigPtr cfg;
|
||||||
|
|
||||||
|
libxlDriverLock(driver);
|
||||||
|
cfg = virObjectRef(driver->config);
|
||||||
|
libxlDriverUnlock(driver);
|
||||||
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
virCapsPtr
|
virCapsPtr
|
||||||
|
@ -77,7 +77,6 @@ static int
|
|||||||
libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
||||||
bool start_paused, int restore_fd);
|
bool start_paused, int restore_fd);
|
||||||
|
|
||||||
/* driver must be locked before calling */
|
|
||||||
static void
|
static void
|
||||||
libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
|
libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
|
||||||
{
|
{
|
||||||
@ -156,17 +155,21 @@ libxlDomainManagedSavePath(libxlDriverPrivatePtr driver, virDomainObjPtr vm) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This internal function expects the driver lock to already be held on
|
/*
|
||||||
* entry. */
|
* This internal function expects the driver lock to already be held on
|
||||||
static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
|
* entry.
|
||||||
libxlSaveImageOpen(libxlDriverPrivatePtr driver, const char *from,
|
*/
|
||||||
virDomainDefPtr *ret_def, libxlSavefileHeaderPtr ret_hdr)
|
static int ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5)
|
||||||
|
libxlSaveImageOpen(libxlDriverPrivatePtr driver,
|
||||||
|
libxlDriverConfigPtr cfg,
|
||||||
|
const char *from,
|
||||||
|
virDomainDefPtr *ret_def,
|
||||||
|
libxlSavefileHeaderPtr ret_hdr)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
libxlSavefileHeader hdr;
|
libxlSavefileHeader hdr;
|
||||||
char *xml = NULL;
|
char *xml = NULL;
|
||||||
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
|
||||||
|
|
||||||
if ((fd = virFileOpenAs(from, O_RDONLY, 0, -1, -1, 0)) < 0) {
|
if ((fd = virFileOpenAs(from, O_RDONLY, 0, -1, -1, 0)) < 0) {
|
||||||
virReportSystemError(-fd,
|
virReportSystemError(-fd,
|
||||||
@ -212,7 +215,6 @@ libxlSaveImageOpen(libxlDriverPrivatePtr driver, const char *from,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
VIR_FREE(xml);
|
VIR_FREE(xml);
|
||||||
virObjectUnref(cfg);
|
|
||||||
|
|
||||||
*ret_def = def;
|
*ret_def = def;
|
||||||
*ret_hdr = hdr;
|
*ret_hdr = hdr;
|
||||||
@ -221,7 +223,6 @@ libxlSaveImageOpen(libxlDriverPrivatePtr driver, const char *from,
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
VIR_FREE(xml);
|
VIR_FREE(xml);
|
||||||
virObjectUnref(cfg);
|
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
return -1;
|
return -1;
|
||||||
@ -349,10 +350,7 @@ libxlEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
|
|||||||
if (xl_reason == LIBXL_SHUTDOWN_REASON_SUSPEND)
|
if (xl_reason == LIBXL_SHUTDOWN_REASON_SUSPEND)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByID(driver->domains, event->domid);
|
vm = virDomainObjListFindByID(driver->domains, event->domid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm)
|
if (!vm)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -386,11 +384,8 @@ libxlEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (dom_event) {
|
if (dom_event)
|
||||||
libxlDriverLock(driver);
|
|
||||||
libxlDomainEventQueue(driver, dom_event);
|
libxlDomainEventQueue(driver, dom_event);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
}
|
|
||||||
/* Cast away any const */
|
/* Cast away any const */
|
||||||
libxl_event_free(priv->ctx, (libxl_event *)event);
|
libxl_event_free(priv->ctx, (libxl_event *)event);
|
||||||
}
|
}
|
||||||
@ -549,7 +544,8 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
|||||||
|
|
||||||
if (virFileExists(managed_save_path)) {
|
if (virFileExists(managed_save_path)) {
|
||||||
|
|
||||||
managed_save_fd = libxlSaveImageOpen(driver, managed_save_path,
|
managed_save_fd = libxlSaveImageOpen(driver, cfg,
|
||||||
|
managed_save_path,
|
||||||
&def, &hdr);
|
&def, &hdr);
|
||||||
if (managed_save_fd < 0)
|
if (managed_save_fd < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -811,7 +807,6 @@ libxlStateInitialize(bool privileged,
|
|||||||
VIR_FREE(libxl_driver);
|
VIR_FREE(libxl_driver);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
libxlDriverLock(libxl_driver);
|
|
||||||
|
|
||||||
/* Allocate bitmap for vnc port reservation */
|
/* Allocate bitmap for vnc port reservation */
|
||||||
if (!(libxl_driver->reservedVNCPorts =
|
if (!(libxl_driver->reservedVNCPorts =
|
||||||
@ -901,13 +896,9 @@ libxlStateInitialize(bool privileged,
|
|||||||
virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
|
virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
|
||||||
libxl_driver);
|
libxl_driver);
|
||||||
|
|
||||||
libxlDriverUnlock(libxl_driver);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (libxl_driver)
|
|
||||||
libxlDriverUnlock(libxl_driver);
|
|
||||||
libxlStateCleanup();
|
libxlStateCleanup();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -918,10 +909,8 @@ libxlStateAutoStart(void)
|
|||||||
if (!libxl_driver)
|
if (!libxl_driver)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
libxlDriverLock(libxl_driver);
|
|
||||||
virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
|
virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
|
||||||
libxl_driver);
|
libxl_driver);
|
||||||
libxlDriverUnlock(libxl_driver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -932,7 +921,6 @@ libxlStateReload(void)
|
|||||||
if (!libxl_driver)
|
if (!libxl_driver)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
libxlDriverLock(libxl_driver);
|
|
||||||
cfg = libxlDriverConfigGet(libxl_driver);
|
cfg = libxlDriverConfigGet(libxl_driver);
|
||||||
|
|
||||||
virDomainObjListLoadAllConfigs(libxl_driver->domains,
|
virDomainObjListLoadAllConfigs(libxl_driver->domains,
|
||||||
@ -948,8 +936,6 @@ libxlStateReload(void)
|
|||||||
libxl_driver);
|
libxl_driver);
|
||||||
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
libxlDriverUnlock(libxl_driver);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1028,11 +1014,9 @@ libxlConnectGetVersion(virConnectPtr conn, unsigned long *version)
|
|||||||
if (virConnectGetVersionEnsureACL(conn) < 0)
|
if (virConnectGetVersionEnsureACL(conn) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
cfg = libxlDriverConfigGet(driver);
|
cfg = libxlDriverConfigGet(driver);
|
||||||
*version = cfg->version;
|
*version = cfg->version;
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1111,11 +1095,9 @@ libxlConnectGetCapabilities(virConnectPtr conn)
|
|||||||
if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
|
if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
cfg = libxlDriverConfigGet(driver);
|
cfg = libxlDriverConfigGet(driver);
|
||||||
if ((xml = virCapabilitiesFormatXML(cfg->caps)) == NULL)
|
if ((xml = virCapabilitiesFormatXML(cfg->caps)) == NULL)
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return xml;
|
return xml;
|
||||||
@ -1130,10 +1112,8 @@ libxlConnectListDomains(virConnectPtr conn, int *ids, int nids)
|
|||||||
if (virConnectListDomainsEnsureACL(conn) < 0)
|
if (virConnectListDomainsEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
n = virDomainObjListGetActiveIDs(driver->domains, ids, nids,
|
n = virDomainObjListGetActiveIDs(driver->domains, ids, nids,
|
||||||
virConnectListDomainsCheckACL, conn);
|
virConnectListDomainsCheckACL, conn);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -1147,10 +1127,8 @@ libxlConnectNumOfDomains(virConnectPtr conn)
|
|||||||
if (virConnectNumOfDomainsEnsureACL(conn) < 0)
|
if (virConnectNumOfDomainsEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
n = virDomainObjListNumOfDomains(driver->domains, true,
|
n = virDomainObjListNumOfDomains(driver->domains, true,
|
||||||
virConnectNumOfDomainsCheckACL, conn);
|
virConnectNumOfDomainsCheckACL, conn);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -1167,7 +1145,6 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_START_PAUSED, NULL);
|
virCheckFlags(VIR_DOMAIN_START_PAUSED, NULL);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
|
if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
|
||||||
1 << VIR_DOMAIN_VIRT_XEN,
|
1 << VIR_DOMAIN_VIRT_XEN,
|
||||||
VIR_DOMAIN_XML_INACTIVE)))
|
VIR_DOMAIN_XML_INACTIVE)))
|
||||||
@ -1198,7 +1175,6 @@ cleanup:
|
|||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return dom;
|
return dom;
|
||||||
}
|
}
|
||||||
@ -1210,10 +1186,7 @@ libxlDomainLookupByID(virConnectPtr conn, int id)
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virDomainPtr dom = NULL;
|
virDomainPtr dom = NULL;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByID(driver->domains, id);
|
vm = virDomainObjListFindByID(driver->domains, id);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1239,10 +1212,7 @@ libxlDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virDomainPtr dom = NULL;
|
virDomainPtr dom = NULL;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1268,10 +1238,7 @@ libxlDomainLookupByName(virConnectPtr conn, const char *name)
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virDomainPtr dom = NULL;
|
virDomainPtr dom = NULL;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByName(driver->domains, name);
|
vm = virDomainObjListFindByName(driver->domains, name);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1300,10 +1267,7 @@ libxlDomainSuspend(virDomainPtr dom)
|
|||||||
virDomainEventPtr event = NULL;
|
virDomainEventPtr event = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
@ -1344,11 +1308,8 @@ libxlDomainSuspend(virDomainPtr dom)
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (event) {
|
if (event)
|
||||||
libxlDriverLock(driver);
|
|
||||||
libxlDomainEventQueue(driver, event);
|
libxlDomainEventQueue(driver, event);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
}
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1364,10 +1325,7 @@ libxlDomainResume(virDomainPtr dom)
|
|||||||
virDomainEventPtr event = NULL;
|
virDomainEventPtr event = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
@ -1409,11 +1367,8 @@ libxlDomainResume(virDomainPtr dom)
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (event) {
|
if (event)
|
||||||
libxlDriverLock(driver);
|
|
||||||
libxlDomainEventQueue(driver, event);
|
libxlDomainEventQueue(driver, event);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
}
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1428,7 +1383,6 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -1463,7 +1417,6 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1484,7 +1437,6 @@ libxlDomainReboot(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -1515,7 +1467,6 @@ libxlDomainReboot(virDomainPtr dom, unsigned int flags)
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1530,7 +1481,6 @@ libxlDomainDestroyFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -1570,7 +1520,6 @@ cleanup:
|
|||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (event)
|
if (event)
|
||||||
libxlDomainEventQueue(driver, event);
|
libxlDomainEventQueue(driver, event);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1587,9 +1536,7 @@ libxlDomainGetOSType(virDomainPtr dom)
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
@ -1617,10 +1564,7 @@ libxlDomainGetMaxMemory(virDomainPtr dom)
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
unsigned long long ret = 0;
|
unsigned long long ret = 0;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1653,10 +1597,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
VIR_DOMAIN_MEM_CONFIG |
|
VIR_DOMAIN_MEM_CONFIG |
|
||||||
VIR_DOMAIN_MEM_MAXIMUM, -1);
|
VIR_DOMAIN_MEM_MAXIMUM, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1779,10 +1720,7 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
@ -1830,10 +1768,7 @@ libxlDomainGetState(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
@ -1944,9 +1879,7 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
@ -1976,7 +1909,6 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1991,6 +1923,7 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
|
|||||||
const char *dxml, unsigned int flags)
|
const char *dxml, unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = conn->privateData;
|
libxlDriverPrivatePtr driver = conn->privateData;
|
||||||
|
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
libxlSavefileHeader hdr;
|
libxlSavefileHeader hdr;
|
||||||
@ -2004,22 +1937,26 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lock the driver until domain def is read from the saved
|
||||||
|
image and a virDomainObj is created and locked.
|
||||||
|
*/
|
||||||
libxlDriverLock(driver);
|
libxlDriverLock(driver);
|
||||||
|
|
||||||
fd = libxlSaveImageOpen(driver, from, &def, &hdr);
|
fd = libxlSaveImageOpen(driver, cfg, from, &def, &hdr);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto cleanup;
|
goto cleanup_unlock;
|
||||||
|
|
||||||
if (virDomainRestoreFlagsEnsureACL(conn, def) < 0)
|
if (virDomainRestoreFlagsEnsureACL(conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup_unlock;
|
||||||
|
|
||||||
if (!(vm = virDomainObjListAdd(driver->domains, def,
|
if (!(vm = virDomainObjListAdd(driver->domains, def,
|
||||||
driver->xmlopt,
|
driver->xmlopt,
|
||||||
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
||||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||||
NULL)))
|
NULL)))
|
||||||
goto cleanup;
|
goto cleanup_unlock;
|
||||||
|
|
||||||
|
libxlDriverUnlock(driver);
|
||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
ret = libxlVmStart(driver, vm, (flags & VIR_DOMAIN_SAVE_PAUSED) != 0, fd);
|
ret = libxlVmStart(driver, vm, (flags & VIR_DOMAIN_SAVE_PAUSED) != 0, fd);
|
||||||
@ -2034,8 +1971,12 @@ cleanup:
|
|||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
cleanup_unlock:
|
||||||
|
libxlDriverUnlock(driver);
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -2056,10 +1997,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH, -1);
|
virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
@ -2098,12 +2036,11 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
|||||||
goto cleanup_unpause;
|
goto cleanup_unpause;
|
||||||
}
|
}
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
if (flags & VIR_DUMP_CRASH) {
|
if (flags & VIR_DUMP_CRASH) {
|
||||||
if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED) != 0) {
|
if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED) != 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to destroy domain '%d'"), dom->id);
|
_("Failed to destroy domain '%d'"), dom->id);
|
||||||
goto cleanup_unlock;
|
goto cleanup_unpause;
|
||||||
}
|
}
|
||||||
|
|
||||||
event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
|
event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
|
||||||
@ -2117,8 +2054,6 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup_unlock:
|
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
cleanup_unpause:
|
cleanup_unpause:
|
||||||
if (virDomainObjIsActive(vm) && paused) {
|
if (virDomainObjIsActive(vm) && paused) {
|
||||||
if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
|
if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
|
||||||
@ -2133,11 +2068,8 @@ cleanup_unpause:
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (event) {
|
if (event)
|
||||||
libxlDriverLock(driver);
|
|
||||||
libxlDomainEventQueue(driver, event);
|
libxlDomainEventQueue(driver, event);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2151,7 +2083,6 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -2193,7 +2124,6 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
VIR_FREE(name);
|
VIR_FREE(name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2229,7 +2159,6 @@ libxlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -2247,7 +2176,6 @@ libxlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2261,7 +2189,6 @@ libxlDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -2285,7 +2212,6 @@ cleanup:
|
|||||||
VIR_FREE(name);
|
VIR_FREE(name);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2325,10 +2251,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2446,10 +2369,7 @@ libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
VIR_DOMAIN_VCPU_CONFIG |
|
VIR_DOMAIN_VCPU_CONFIG |
|
||||||
VIR_DOMAIN_VCPU_MAXIMUM, -1);
|
VIR_DOMAIN_VCPU_MAXIMUM, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2507,10 +2427,7 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
libxl_bitmap map;
|
libxl_bitmap map;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2576,10 +2493,7 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
|
|||||||
size_t i;
|
size_t i;
|
||||||
unsigned char *cpumap;
|
unsigned char *cpumap;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2642,10 +2556,7 @@ libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
/* Flags checked by virDomainDefFormat */
|
/* Flags checked by virDomainDefFormat */
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
@ -2763,10 +2674,8 @@ libxlConnectListDefinedDomains(virConnectPtr conn,
|
|||||||
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
|
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
n = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
|
n = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
|
||||||
virConnectListDefinedDomainsCheckACL, conn);
|
virConnectListDefinedDomainsCheckACL, conn);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2779,12 +2688,9 @@ libxlConnectNumOfDefinedDomains(virConnectPtr conn)
|
|||||||
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
|
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
n = virDomainObjListNumOfDomains(driver->domains, false,
|
n = virDomainObjListNumOfDomains(driver->domains, false,
|
||||||
virConnectNumOfDefinedDomainsCheckACL,
|
virConnectNumOfDefinedDomainsCheckACL,
|
||||||
conn);
|
conn);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2798,7 +2704,6 @@ libxlDomainCreateWithFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_START_PAUSED, -1);
|
virCheckFlags(VIR_DOMAIN_START_PAUSED, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -2822,7 +2727,6 @@ libxlDomainCreateWithFlags(virDomainPtr dom,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2843,22 +2747,25 @@ libxlDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
virDomainEventPtr event = NULL;
|
virDomainEventPtr event = NULL;
|
||||||
virDomainDefPtr oldDef = NULL;
|
virDomainDefPtr oldDef = NULL;
|
||||||
|
|
||||||
|
/* Lock the driver until the virDomainObj is created and locked */
|
||||||
libxlDriverLock(driver);
|
libxlDriverLock(driver);
|
||||||
if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
|
if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
|
||||||
1 << VIR_DOMAIN_VIRT_XEN,
|
1 << VIR_DOMAIN_VIRT_XEN,
|
||||||
VIR_DOMAIN_XML_INACTIVE)))
|
VIR_DOMAIN_XML_INACTIVE)))
|
||||||
goto cleanup;
|
goto cleanup_unlock;
|
||||||
|
|
||||||
if (virDomainDefineXMLEnsureACL(conn, def) < 0)
|
if (virDomainDefineXMLEnsureACL(conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup_unlock;
|
||||||
|
|
||||||
if (!(vm = virDomainObjListAdd(driver->domains, def,
|
if (!(vm = virDomainObjListAdd(driver->domains, def,
|
||||||
driver->xmlopt,
|
driver->xmlopt,
|
||||||
0,
|
0,
|
||||||
&oldDef)))
|
&oldDef)))
|
||||||
goto cleanup;
|
goto cleanup_unlock;
|
||||||
|
|
||||||
def = NULL;
|
def = NULL;
|
||||||
vm->persistent = 1;
|
vm->persistent = 1;
|
||||||
|
libxlDriverUnlock(driver);
|
||||||
|
|
||||||
if (virDomainSaveConfig(cfg->configDir,
|
if (virDomainSaveConfig(cfg->configDir,
|
||||||
vm->newDef ? vm->newDef : vm->def) < 0) {
|
vm->newDef ? vm->newDef : vm->def) < 0) {
|
||||||
@ -2883,9 +2790,12 @@ cleanup:
|
|||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (event)
|
if (event)
|
||||||
libxlDomainEventQueue(driver, event);
|
libxlDomainEventQueue(driver, event);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return dom;
|
return dom;
|
||||||
|
|
||||||
|
cleanup_unlock:
|
||||||
|
libxlDriverUnlock(driver);
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -2901,9 +2811,7 @@ libxlDomainUndefineFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, -1);
|
virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
@ -2962,7 +2870,6 @@ libxlDomainUndefineFlags(virDomainPtr dom,
|
|||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (event)
|
if (event)
|
||||||
libxlDomainEventQueue(driver, event);
|
libxlDomainEventQueue(driver, event);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3333,9 +3240,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
|
|||||||
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
||||||
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3416,7 +3321,6 @@ cleanup:
|
|||||||
virDomainDeviceDefFree(dev);
|
virDomainDeviceDefFree(dev);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3443,9 +3347,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
|
|||||||
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
||||||
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3526,7 +3428,6 @@ cleanup:
|
|||||||
virDomainDeviceDefFree(dev);
|
virDomainDeviceDefFree(dev);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3553,9 +3454,7 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
|
|||||||
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
||||||
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3636,7 +3535,6 @@ cleanup:
|
|||||||
virDomainDeviceDefFree(dev);
|
virDomainDeviceDefFree(dev);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3724,11 +3622,9 @@ libxlConnectDomainEventRegister(virConnectPtr conn,
|
|||||||
if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
|
if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
ret = virDomainEventStateRegister(conn,
|
ret = virDomainEventStateRegister(conn,
|
||||||
driver->domainEventState,
|
driver->domainEventState,
|
||||||
callback, opaque, freecb);
|
callback, opaque, freecb);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3744,11 +3640,9 @@ libxlConnectDomainEventDeregister(virConnectPtr conn,
|
|||||||
if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
|
if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
ret = virDomainEventStateDeregister(conn,
|
ret = virDomainEventStateDeregister(conn,
|
||||||
driver->domainEventState,
|
driver->domainEventState,
|
||||||
callback);
|
callback);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3760,10 +3654,7 @@ libxlDomainGetAutostart(virDomainPtr dom, int *autostart)
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
@ -3793,9 +3684,7 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart)
|
|||||||
char *configFile = NULL, *autostartLink = NULL;
|
char *configFile = NULL, *autostartLink = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
@ -3853,7 +3742,6 @@ cleanup:
|
|||||||
VIR_FREE(autostartLink);
|
VIR_FREE(autostartLink);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3868,10 +3756,7 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
|
|||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
libxl_scheduler sched_id;
|
libxl_scheduler sched_id;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3938,10 +3823,7 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
/* We don't return strings, and thus trivially support this flag. */
|
/* We don't return strings, and thus trivially support this flag. */
|
||||||
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
|
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
@ -4024,10 +3906,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4105,9 +3984,7 @@ libxlDomainOpenConsole(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
@ -4208,10 +4085,7 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
|
|||||||
* the filtering on behalf of older clients that can't parse it. */
|
* the filtering on behalf of older clients that can't parse it. */
|
||||||
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
|
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
@ -4321,9 +4195,7 @@ libxlDomainIsActive(virDomainPtr dom)
|
|||||||
virDomainObjPtr obj;
|
virDomainObjPtr obj;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4347,9 +4219,7 @@ libxlDomainIsPersistent(virDomainPtr dom)
|
|||||||
virDomainObjPtr obj;
|
virDomainObjPtr obj;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4373,9 +4243,7 @@ libxlDomainIsUpdated(virDomainPtr dom)
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4403,13 +4271,11 @@ libxlConnectDomainEventRegisterAny(virConnectPtr conn, virDomainPtr dom, int eve
|
|||||||
if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
|
if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
if (virDomainEventStateRegisterID(conn,
|
if (virDomainEventStateRegisterID(conn,
|
||||||
driver->domainEventState,
|
driver->domainEventState,
|
||||||
dom, eventID, callback, opaque,
|
dom, eventID, callback, opaque,
|
||||||
freecb, &ret) < 0)
|
freecb, &ret) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4424,11 +4290,9 @@ libxlConnectDomainEventDeregisterAny(virConnectPtr conn, int callbackID)
|
|||||||
if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
|
if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
ret = virDomainEventStateDeregisterID(conn,
|
ret = virDomainEventStateDeregisterID(conn,
|
||||||
driver->domainEventState,
|
driver->domainEventState,
|
||||||
callbackID);
|
callbackID);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4453,10 +4317,8 @@ libxlConnectListAllDomains(virConnectPtr conn,
|
|||||||
if (virConnectListAllDomainsEnsureACL(conn) < 0)
|
if (virConnectListAllDomainsEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
libxlDriverLock(driver);
|
|
||||||
ret = virDomainObjListExport(driver->domains, conn, domains,
|
ret = virDomainObjListExport(driver->domains, conn, domains,
|
||||||
virConnectListAllDomainsCheckACL, flags);
|
virConnectListAllDomainsCheckACL, flags);
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user