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

2017-11-12 Thread Fabian Freyer
On 12 Nov 2017, at 0:46, Allan Jude wrote:
> 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.

Yes it does[1]. Also be aware that bootloader_args has some quoting issues.

CC’ing novel@ as he does a lot of the libvirt+bhyve driver stuff.

Fabian.

[1] https://libvirt.org/drvbhyve.html#uefi


signature.asc
Description: OpenPGP digital signature


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

2017-11-12 Thread Christian Schwarz
Hi Alan,

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

Thanks for the tip, I just converted the disk to GPT and now use UEFI directly.

The only problem I encountered with the UEFI firmware is that it will always
prefer the virtualized cdrom over hdd or, more generally, one cannot define a
boot order.

This gist contains a working minimal UEFI-only libvirt domain:

https://gist.github.com/problame/79a94ae05f5b17e11c3b5bc2fe5910c8

If you have any idea how to set the boot order via bhyve command line flags
I would be "happy" to patch libvirt to support this feature.

Otherwise, I hope this helps anyone reading this in the future,

  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"


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"


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"