]> xenbits.xensource.com Git - libvirt.git/commitdiff
bhyve: Add console support for grub-bhyve bootloader
authorConrad Meyer <cse.cem@gmail.com>
Sat, 8 Nov 2014 16:48:35 +0000 (11:48 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 12 Nov 2014 08:55:22 +0000 (09:55 +0100)
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
src/bhyve/bhyve_driver.c
src/bhyve/bhyve_driver.h
src/bhyve/bhyve_utils.h

index 203495cd9db4b3e1fe3df5f1dbe2dfc5533403eb..26d4797465a1a2b95ada9a56a18a6cd976ad1379 100644 (file)
 #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);
 
index 4aee2491672912a7432f08162e8812c26178b502..38207374b9a228f926ac5763e16070e4ba50a1e1 100644 (file)
@@ -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)
 {
index b70991d7e17b032afa9fef30a304493157a61501..af2424ad3d1c760b4775bf0851c3fb87e0e40726 100644 (file)
@@ -25,4 +25,6 @@
 
 int bhyveRegister(void);
 
+unsigned bhyveDriverGetGrubCaps(virConnectPtr conn);
+
 #endif /* __BHYVE_DRIVER_H__ */
index 848f9a1cdcdbaccecd9fedaba4cd133ad2093e86..bbaa3a35fa578d9a428e73efdd76733fa8f8dbd1 100644 (file)
@@ -45,6 +45,8 @@ struct _bhyveConn {
     virObjectEventStatePtr domainEventState;
 
     virCloseCallbacksPtr closeCallbacks;
+
+    unsigned grubcaps;
 };
 
 typedef struct _bhyveConn bhyveConn;