[PATCH] Add support for VNC autoport feature for bhyve hypervisor.

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

 



This patch adds support for automatic VNC port assignment for bhyve guests.

---
 src/bhyve/bhyve_command.c | 9 +++++++++
 src/bhyve/bhyve_driver.c  | 5 +++++
 src/bhyve/bhyve_utils.h   | 3 +++
 3 files changed, 17 insertions(+)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index eae5cb3ca..4d35a05c5 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -339,6 +339,9 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
     virBuffer opt = VIR_BUFFER_INITIALIZER;
     virDomainGraphicsListenDefPtr glisten = NULL;
     bool escapeAddr;
+    unsigned short port;
+
+    bhyveConnPtr driver = conn->privateData;
 
     if (!(bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) ||
         def->os.bootloader ||
@@ -401,6 +404,12 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
                 virBufferAdd(&opt, glisten->address, -1);
         }
 
+        if (graphics->data.vnc.autoport) {
+            if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
+                return -1;
+            graphics->data.vnc.port = port;
+        }
+
         virBufferAsprintf(&opt, ":%d", graphics->data.vnc.port);
         break;
     default:
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index ed2221a35..bffeea7d9 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -52,6 +52,7 @@
 #include "viraccessapicheck.h"
 #include "virhostcpu.h"
 #include "virhostmem.h"
+#include "virportallocator.h"
 #include "conf/domain_capabilities.h"
 
 #include "bhyve_conf.h"
@@ -1219,6 +1220,7 @@ bhyveStateCleanup(void)
     virObjectUnref(bhyve_driver->closeCallbacks);
     virObjectUnref(bhyve_driver->domainEventState);
     virObjectUnref(bhyve_driver->config);
+    virObjectUnref(bhyve_driver->remotePorts);
 
     virMutexDestroy(&bhyve_driver->lock);
     VIR_FREE(bhyve_driver);
@@ -1265,6 +1267,9 @@ bhyveStateInitialize(bool privileged,
     if (!(bhyve_driver->domainEventState = virObjectEventStateNew()))
         goto cleanup;
 
+    if (!(bhyve_driver->remotePorts = virPortAllocatorNew(_("display"), 5900, 65535, 0)))
+        goto cleanup;
+
     bhyve_driver->hostsysinfo = virSysinfoRead();
 
     if (!(bhyve_driver->config = virBhyveDriverConfigNew()))
diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h
index db50e012a..8ad2698d4 100644
--- a/src/bhyve/bhyve_utils.h
+++ b/src/bhyve/bhyve_utils.h
@@ -28,6 +28,7 @@
 # include "virdomainobjlist.h"
 # include "virthread.h"
 # include "virclosecallbacks.h"
+# include "virportallocator.h"
 
 # define BHYVE_AUTOSTART_DIR    SYSCONFDIR "/libvirt/bhyve/autostart"
 # define BHYVE_CONFIG_DIR       SYSCONFDIR "/libvirt/bhyve"
@@ -58,6 +59,8 @@ struct _bhyveConn {
 
     virCloseCallbacksPtr closeCallbacks;
 
+    virPortAllocatorPtr remotePorts;
+
     unsigned bhyvecaps;
     unsigned grubcaps;
 };
-- 
2.12.1


--
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]
  Powered by Linux