[PATCHv7 6/7] bhyve: Add console support for grub-bhyve bootloader

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

 



This enables booting interactive GRUB menus (e.g. install CDs) with
libvirt-bhyve.

Caveat: A terminal other than the '--console' option to 'virsh start'
(e.g. 'cu -l /dev/nmdm0B -s 115200') must be used to connect to
grub-bhyve because the bhyve loader path is synchronous and must occur
before the VM actually starts.

Changing the bhyveProcessStart logic around to accommodate '--console'
for interactive loader use seems like a significant project and probably
not worth it, if UEFI/BIOS support for bhyve is "coming soon."
---
 src/bhyve/bhyve_command.c | 18 ++++++++++++++++++
 src/bhyve/bhyve_driver.c  | 13 +++++++++++++
 src/bhyve/bhyve_driver.h  |  2 ++
 src/bhyve/bhyve_utils.h   |  2 ++
 4 files changed, 35 insertions(+)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 203495c..26d4797 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -25,8 +25,10 @@
 #include <net/if.h>
 #include <net/if_tap.h>
 
+#include "bhyve_capabilities.h"
 #include "bhyve_command.h"
 #include "bhyve_domain.h"
+#include "bhyve_driver.h"
 #include "datatypes.h"
 #include "viralloc.h"
 #include "virfile.h"
@@ -447,6 +449,22 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
     virCommandAddArgFormat(cmd, "%llu",
                            VIR_DIV_UP(def->mem.max_balloon, 1024));
 
+    if ((bhyveDriverGetGrubCaps(conn) & BHYVE_GRUB_CAP_CONSDEV) != 0 &&
+        def->nserials > 0) {
+        virDomainChrDefPtr chr;
+
+        chr = def->serials[0];
+
+        if (chr->source.type != VIR_DOMAIN_CHR_TYPE_NMDM) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("only nmdm console types are supported"));
+            return NULL;
+        }
+
+        virCommandAddArg(cmd, "--cons-dev");
+        virCommandAddArg(cmd, chr->source.data.file.path);
+    }
+
     /* VM name */
     virCommandAddArg(cmd, def->name);
 
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 4aee249..3820737 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1169,6 +1169,9 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
     if (!(bhyve_driver->caps = virBhyveCapsBuild()))
         goto cleanup;
 
+    if (virBhyveProbeGrubCaps(&bhyve_driver->grubcaps) < 0)
+        goto cleanup;
+
     if (!(bhyve_driver->xmlopt = virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
                                                        &virBhyveDriverPrivateDataCallbacks,
                                                        NULL)))
@@ -1226,6 +1229,16 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
     return -1;
 }
 
+unsigned
+bhyveDriverGetGrubCaps(virConnectPtr conn)
+{
+    bhyveConnPtr driver = conn->privateData;
+
+    if (driver != NULL)
+        return driver->grubcaps;
+    return 0;
+}
+
 static void
 bhyveStateAutoStart(void)
 {
diff --git a/src/bhyve/bhyve_driver.h b/src/bhyve/bhyve_driver.h
index b70991d..af2424a 100644
--- a/src/bhyve/bhyve_driver.h
+++ b/src/bhyve/bhyve_driver.h
@@ -25,4 +25,6 @@
 
 int bhyveRegister(void);
 
+unsigned bhyveDriverGetGrubCaps(virConnectPtr conn);
+
 #endif /* __BHYVE_DRIVER_H__ */
diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h
index 848f9a1..bbaa3a3 100644
--- a/src/bhyve/bhyve_utils.h
+++ b/src/bhyve/bhyve_utils.h
@@ -45,6 +45,8 @@ struct _bhyveConn {
     virObjectEventStatePtr domainEventState;
 
     virCloseCallbacksPtr closeCallbacks;
+
+    unsigned grubcaps;
 };
 
 typedef struct _bhyveConn bhyveConn;
-- 
1.9.3

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