[GSoC PATCH 6/9] Jailhouse driver: Implementation of DomainLookup* callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/jailhouse/jailhouse_driver.c | 70 ++++++++++++++++++++++++++++----
 1 file changed, 61 insertions(+), 9 deletions(-)

diff --git a/src/jailhouse/jailhouse_driver.c b/src/jailhouse/jailhouse_driver.c
index 2bb249f996..8c84a23388 100644
--- a/src/jailhouse/jailhouse_driver.c
+++ b/src/jailhouse/jailhouse_driver.c
@@ -292,25 +292,77 @@ jailhouseConnectListAllDomains(virConnectPtr conn,
 static virDomainPtr
 jailhouseDomainLookupByID(virConnectPtr conn, int id)
 {
-    UNUSED(conn);
-    UNUSED(id);
-    return NULL;
+virJailhouseDriverPtr driver = conn->privateData;
+    virDomainObjPtr cell;
+    virDomainPtr dom = NULL;
+
+    cell = virDomainObjListFindByID(driver->domains, id);
+
+    if (!cell) {
+        virReportError(VIR_ERR_NO_DOMAIN,
+                       _("No domain with matching ID '%d'"), id);
+        goto cleanup;
+    }
+
+    if (virDomainLookupByIDEnsureACL(conn, cell->def) < 0)
+        goto cleanup;
+
+    dom = virGetDomain(conn, cell->def->name, cell->def->uuid, cell->def->id);
+ cleanup:
+    virDomainObjEndAPI(&cell);
+    return dom;
 }
 
 static virDomainPtr
 jailhouseDomainLookupByName(virConnectPtr conn, const char *name)
 {
-    UNUSED(conn);
-    UNUSED(name);
-    return NULL;
+    virJailhouseDriverPtr driver = conn->privateData;
+    virDomainObjPtr cell;
+    virDomainPtr dom = NULL;
+
+    cell = virDomainObjListFindByName(driver->domains, name);
+
+    if (!cell) {
+        virReportError(VIR_ERR_NO_DOMAIN,
+                       _("No domain with matching name '%s'"), name);
+        goto cleanup;
+    }
+
+    if (virDomainLookupByNameEnsureACL(conn, cell->def) < 0)
+        goto cleanup;
+
+    dom = virGetDomain(conn, cell->def->name, cell->def->uuid, cell->def->id);
+
+ cleanup:
+    virDomainObjEndAPI(&cell);
+    return dom;
 }
 
 static virDomainPtr
 jailhouseDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
 {
-    UNUSED(conn);
-    UNUSED(uuid);
-    return NULL;
+    virJailhouseDriverPtr driver = conn->privateData;
+    virDomainObjPtr cell;
+    virDomainPtr dom = NULL;
+
+    cell = virDomainObjListFindByUUID(driver->domains, uuid);
+
+    if (!cell) {
+        char uuidstr[VIR_UUID_STRING_BUFLEN];
+        virUUIDFormat(uuid, uuidstr);
+        virReportError(VIR_ERR_NO_DOMAIN,
+                       _("No domain with matching UUID '%s'"), uuidstr);
+        goto cleanup;
+    }
+
+    if (virDomainLookupByUUIDEnsureACL(conn, cell->def) < 0)
+        goto cleanup;
+
+    dom = virGetDomain(conn, cell->def->name, cell->def->uuid, cell->def->id);
+
+ cleanup:
+    virDomainObjEndAPI(&cell);
+    return dom;
 }
 
 static virDomainObjPtr
-- 
2.17.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux