umlDriverUnlock(uml_driver);
}
+
+static virDomainObjPtr
+umlDomObjFromDomainLocked(struct uml_driver *driver,
+ const unsigned char *uuid)
+{
+ virDomainObjPtr vm;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
+ virUUIDFormat(uuid, uuidstr);
+
+ virReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"), uuidstr);
+ return NULL;
+ }
+
+ return vm;
+}
+
+
+static virDomainObjPtr
+umlDomObjFromDomain(struct uml_driver *driver,
+ const unsigned char *uuid)
+{
+ virDomainObjPtr vm;
+
+ umlDriverLock(driver);
+ vm = umlDomObjFromDomainLocked(driver, uuid);
+ umlDriverUnlock(driver);
+ return vm;
+}
+
+
static virNWFilterCallbackDriver umlCallbackDriver = {
.name = "UML",
.vmFilterRebuild = umlVMFilterRebuild,
}
static virDomainPtr umlDomainLookupByUUID(virConnectPtr conn,
- const unsigned char *uuid)
+ const unsigned char *uuid)
{
struct uml_driver *driver = (struct uml_driver *)conn->privateData;
virDomainObjPtr vm;
virDomainPtr dom = NULL;
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, uuid);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, NULL);
- goto cleanup;
- }
+ if (!(vm = umlDomObjFromDomain(driver, uuid)))
+ return NULL;
if (virDomainLookupByUUIDEnsureACL(conn, vm->def) < 0)
goto cleanup;
virDomainObjPtr obj;
int ret = -1;
- umlDriverLock(driver);
- obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
- if (!obj) {
- virReportError(VIR_ERR_NO_DOMAIN, NULL);
- goto cleanup;
- }
+ if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainIsActiveEnsureACL(dom->conn, obj->def) < 0)
goto cleanup;
virDomainObjPtr obj;
int ret = -1;
- umlDriverLock(driver);
- obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
- if (!obj) {
- virReportError(VIR_ERR_NO_DOMAIN, NULL);
- goto cleanup;
- }
+ if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainIsPersistentEnsureACL(dom->conn, obj->def) < 0)
goto cleanup;
virDomainObjPtr obj;
int ret = -1;
- umlDriverLock(driver);
- obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
- if (!obj) {
- virReportError(VIR_ERR_NO_DOMAIN, NULL);
- goto cleanup;
- }
+ if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainIsUpdatedEnsureACL(dom->conn, obj->def) < 0)
goto cleanup;
virCheckFlags(0, -1);
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching id %d"), dom->id);
- goto cleanup;
- }
+ if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
virCheckFlags(0, -1);
umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching id %d"), dom->id);
- goto cleanup;
- }
+ if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
+ return -1;
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virDomainObjPtr vm;
char *type = NULL;
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
- goto cleanup;
- }
+ if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
+ return NULL;
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virDomainObjPtr vm;
unsigned long long ret = 0;
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
-
- 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 = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virDomainObjPtr vm;
int ret = -1;
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
-
- 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 = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainSetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virDomainObjPtr vm;
int ret = -1;
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
-
- 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 = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainSetMemoryEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virDomainObjPtr vm;
int ret = -1;
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
- goto cleanup;
- }
+ if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virCheckFlags(0, -1);
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
- goto cleanup;
- }
+ if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
/* Flags checked by virDomainDefFormat */
umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
+ if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
goto cleanup;
- }
if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
virNWFilterReadLockFilterUpdates();
umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
+ if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
goto cleanup;
- }
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virCheckFlags(0, -1);
umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
+ if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
goto cleanup;
- }
if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
umlDriverLock(driver);
- 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 = umlDomObjFromDomainLocked(driver, dom->uuid)))
goto cleanup;
- }
if (virDomainAttachDeviceEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
int ret = -1;
umlDriverLock(driver);
- 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 = umlDomObjFromDomainLocked(driver, dom->uuid)))
goto cleanup;
- }
if (virDomainDetachDeviceEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
int ret = -1;
umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
+ if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
goto cleanup;
- }
if (virDomainGetAutostartEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
int ret = -1;
umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
+ if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
goto cleanup;
- }
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virCheckFlags(0, -1);
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
- goto cleanup;
- }
+ if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainBlockPeekEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
{
struct uml_driver *driver = dom->conn->privateData;
virDomainObjPtr vm = NULL;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
int ret = -1;
virDomainChrDefPtr chr = NULL;
size_t i;
virCheckFlags(0, -1);
umlDriverLock(driver);
- virUUIDFormat(dom->uuid, uuidstr);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching uuid '%s'"), uuidstr);
+ if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
goto cleanup;
- }
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
virCheckFlags(0, -1);
- umlDriverLock(driver);
- vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, NULL);
- goto cleanup;
- }
+ if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
+ return -1;
if (virDomainHasManagedSaveImageEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;