grub-bhyve: support overriding just --root flag

2017-11-11 Thread Christian Schwarz
(Disclaimer: also submitted this to the libvirt mailing list, but this list
 seems more appropriate)

Hi,

I was trying to get a GPT-formatted VM boot on FreeBSD using the bhyve driver
and the grub-bhyve bootloader.

Turns out that libvirt 3.9.0 hardcodes the boot partition to (hd0,msdos1)
or allows overriding it completly using .

I hacked together a patch that allows overring just the --root argument to
grub-bhyve and updated the documentation:

https://github.com/problame/libvirt/commit/5fd1265c05987d907d9f1d9913dbee832a227889

Obviously, this does not meet quality standards and should not be merged as is,
but maybe spawn some discussion (if anyone is actually using bhyve + libvirt).

Cheers,

  Christian


---

commit 5fd1265c05987d907d9f1d9913dbee832a227889
Author: Christian Schwarz 
Date:   Sat Nov 11 16:15:05 2017 +0100

bhyve: grub-bhyve: support overriding just the --root argument in domain 
config

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 63260afae..2583bfa01 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -300,17 +300,26 @@ are omitted, libvirt will try and infer boot ordering 
from user-supplied
 boot order='N' configuration in the domain. Failing that, it will boot
 the first disk in the domain (either cdrom- or
 disk-type devices). If the disk type is disk, it will
-attempt to boot from the first partition in the disk image.
+attempt to boot from the first partition in the disk image, assuming
+an msdos partitioning scheme
+(i.e. grub-bhyve --root hd0,msdos1).
+You can override this behavior using bootloader_args or 
bootloader_grub_root.
+
 
 
 ...
 bootloader/usr/local/sbin/grub-bhyve/bootloader
+!-- the following tag overrides all args to grub-bhyve --
 bootloader_args.../bootloader_args
+!-- the following tag overrides just the --root argument to grub-bhyve 
--
+bootloader_grub_roothd0,gpt1/bootloader_grub_root
 ...
 
 
-Caveat: bootloader_args does not support any quoting.
-Filenames, etc, must not have spaces or they will be tokenized incorrectly.
+Caveats when using bootloader_args: it  does not support any 
quoting.
+Filenames, etc, must not have spaces or they will be tokenized incorrectly.
+Additionally, you will have to maintain your own --device-map
+file and keep it in sync with the domain XML.
 
 Using UEFI bootrom, VNC, and USB tablet
 
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 55032ae1d..6cab6e516 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -774,15 +774,21 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
 }
 
 virCommandAddArg(cmd, "--root");
-if (userdef != NULL) {
-if (userdef->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+if (def->os.bootloaderGrubRoot != NULL) {
+virCommandAddArg(cmd, def->os.bootloaderGrubRoot);
+} else {
+
+if (userdef != NULL) {
+if (userdef->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+virCommandAddArg(cmd, "cd");
+else
+virCommandAddArg(cmd, "hd0,msdos1");
+} else if (cd != NULL) {
 virCommandAddArg(cmd, "cd");
-else
+} else {
 virCommandAddArg(cmd, "hd0,msdos1");
-} else if (cd != NULL) {
-virCommandAddArg(cmd, "cd");
-} else {
-virCommandAddArg(cmd, "hd0,msdos1");
+}
+
 }
 
 virCommandAddArg(cmd, "--device-map");
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7dfd7b54e..ecd1f71dd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18141,6 +18141,7 @@ virDomainDefParseXML(xmlDocPtr xml,
 
 def->os.bootloader = virXPathString("string(./bootloader)", ctxt);
 def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt);
+def->os.bootloaderGrubRoot = 
virXPathString("string(./bootloader_grub_root)", ctxt);
 
 tmp = virXPathString("string(./os/type[1])", ctxt);
 if (!tmp) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e3f060b12..f969e9195 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1884,6 +1884,7 @@ struct _virDomainOSDef {
 char *slic_table;
 virDomainLoaderDefPtr loader;
 char *bootloader;
+char *bootloaderGrubRoot;
 char *bootloaderArgs;
 int smbios_mode;
 
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


[Bug 203994] bhyve kernel module may need to relax some checks when running nested under KVM

2017-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203994

--- Comment #20 from Roman Bogorodskiy  ---
(In reply to Peter Grehan from comment #19)

As for me, kernels >= 4.10 are fine for me. I use Fedora for my Linux-related
stuff, Fedora 26 comes with 4.11, and Fedora 27 that will be released soon will
have 4.13 I think.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


Re: grub-bhyve: support overriding just --root flag

2017-11-11 Thread Allan Jude
On 11/11/2017 10:38, Christian Schwarz wrote:
> (Disclaimer: also submitted this to the libvirt mailing list, but this list
>  seems more appropriate)
> 
> Hi,
> 
> I was trying to get a GPT-formatted VM boot on FreeBSD using the bhyve driver
> and the grub-bhyve bootloader.
> 
> Turns out that libvirt 3.9.0 hardcodes the boot partition to (hd0,msdos1)
> or allows overriding it completly using .
> 
> I hacked together a patch that allows overring just the --root argument to
> grub-bhyve and updated the documentation:
> 
> https://github.com/problame/libvirt/commit/5fd1265c05987d907d9f1d9913dbee832a227889
> 
> Obviously, this does not meet quality standards and should not be merged as 
> is,
> but maybe spawn some discussion (if anyone is actually using bhyve + libvirt).
> 
> Cheers,
> 
>   Christian
> 
> 
> freebsd-virtualization@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
> To unsubscribe, send any mail to 
> "freebsd-virtualization-unsubscr...@freebsd.org"
> 

Does libvirt support using the bhyve UEFI-CSM firmware instead? That
would let the VM boot using the native grub installed inside the VM, and
avoid this issue entirely. It also makes starting a bhyve a single
command instead of 2.

-- 
Allan Jude
___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"