[libvirt] [PATCH 1/2] bhyve: stub for domainResume

Wojciech Macek wma at semihalf.com
Tue Apr 8 05:01:33 UTC 2014


bhyve does not support suspend nor resume. To enable OpenStack
procedure (create -> resume) use stub for domainResume function.
If domain is running then report success; return failure in all other
cases.
---
 src/bhyve/bhyve_driver.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 84d1915..f7a8912 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1041,6 +1041,39 @@ bhyveConnectCompareCPU(virConnectPtr conn,
     return ret;
 }
 
+static int
+bhyveDomainResume(virDomainPtr dom)
+{
+    virDomainObjPtr vm;
+    int ret = -1;
+    int state;
+
+    if (!(vm = bhyveDomObjFromDomain(dom)))
+        return -1;
+
+    if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
+        goto cleanup;
+
+
+    if (!virDomainObjIsActive(vm)) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       "%s", _("domain is not running"));
+        goto cleanup;
+    }
+
+    /* If domain is already running, return success */
+    state = virDomainObjGetState(vm, NULL);
+    if (state == VIR_DOMAIN_RUNNING) {
+        ret = 0;
+    }
+
+    /*Return failure in all other cases - bhyve does not support resuming */
+ cleanup:
+    if (vm)
+        virObjectUnlock(vm);
+    return ret;
+}
+
 static virDriver bhyveDriver = {
     .no = VIR_DRV_BHYVE,
     .name = "bhyve",
@@ -1080,6 +1113,7 @@ static virDriver bhyveDriver = {
     .nodeSetMemoryParameters = bhyveNodeSetMemoryParameters, /* 1.2.3 */
     .connectBaselineCPU = bhyveConnectBaselineCPU, /* 1.2.4 */
     .connectCompareCPU = bhyveConnectCompareCPU, /* 1.2.4 */
+    .domainResume = bhyveDomainResume, /* 1.2.4 */
 };
 
 
-- 
1.9.0




More information about the libvir-list mailing list