[PATCH] bhyve: add domainLookupByID

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

 



Implement domain lookup by its ID.
---
 src/bhyve/bhyve_driver.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index f54dff0..38a7f41 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -778,6 +778,34 @@ bhyveNodeSetMemoryParameters(virConnectPtr conn,
     return nodeSetMemoryParameters(params, nparams, flags);
 }
 
+static virDomainPtr
+bhyveDomainLookupByID(virConnectPtr conn,
+                      int id)
+{
+    bhyveConnPtr privconn = conn->privateData;
+    virDomainObjPtr vm;
+    virDomainPtr dom = NULL;
+
+    vm = virDomainObjListFindByID(privconn->domains, id);
+
+    if (!vm) {
+        virReportError(VIR_ERR_NO_DOMAIN,
+                       _("No domain with matching ID '%d'"), id);
+        goto cleanup;
+    }
+
+    if (virDomainLookupByIDEnsureACL(conn, vm->def) < 0)
+        goto cleanup;
+
+    dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
+    if (dom)
+        dom->id = vm->def->id;
+
+ cleanup:
+    virObjectUnlock(vm);
+    return dom;
+}
+
 static virDriver bhyveDriver = {
     .no = VIR_DRV_BHYVE,
     .name = "bhyve",
@@ -811,6 +839,7 @@ static virDriver bhyveDriver = {
     .nodeGetCPUMap = bhyveNodeGetCPUMap, /* 1.2.3 */
     .nodeGetMemoryParameters = bhyveNodeGetMemoryParameters, /* 1.2.3 */
     .nodeSetMemoryParameters = bhyveNodeSetMemoryParameters, /* 1.2.3 */
+    .domainLookupByID = bhyveDomainLookupByID, /* 1.2.3 */
 };
 
 
-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]