Boot OpenBSD with bhyve and libvirt automatically.

William B william at firstyear.id.au
Fri Jan 2 03:33:44 UTC 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 31 Dec 2014 00:16:23 -0800
Peter Grehan <grehan at freebsd.org> wrote:

> Hi William,
> 
> > An inspection of ps shows that it is at the grub-bhyve command. I
> > daresay it is waiting for the stdin lines:
> >
> > kopenbsd -h com0 (hd0,openbsd1)/bsd
> > boot
> >
> > The "automatic" boot seems not to work.
> >
> > Is there a way to "automate" the input of these lines into
> > grub-bhyve from libvirt so that my virsh start command works? Or
> > will I need to run this with grub-bhyve / bhyve commands for now?
> > Is this a feature that should be added to grub-bhyve to accept a
> > parameter that is a boot script perhaps? Or libvirt to have a
> > function to direct into stdin of the grub-bhyve prompt.
> 
>   This can be done with grub-bhyve's command-line options. The
> default device is "(host)", so you can have a grub.cfg file on the
> host with the path specified with the '-d' option e.g. if you have a
> grub.cfg in /usr/bhyve, you would start grub with
> 
>   grub-bhyve -d /usr/bhyve  <keep remaining options>
> 
>   No need to specify a '-r' param since it defaults to host.
> 
>   You can use the existing kopenbsd line in your grub.cfg since you
> are manually specifying the complete device spec and path.
> 

Thanks. The grub-bhyve --help flag isn't 100% clear about it's
capabilites, and there seems to be a lack of a man page. But your tips
got me in the correct direction. Here is the solution.

However, I have now gotten this work work with libvirt also.

First, the command was to make:

- --root host --directory /var/lib/libvirt/boot/openbsd
- --device-map /var/run/libvirt/bhyve/grub_bhyve-guest-device.map
- --memory 512 guest

Inside of the directory on the bhyve host /var/lib/libvirt/boot/openbsd
a file called grub.cfg contains

kopenbsd -h com0 -r sd0a (hd0,msdos4)/bsd
boot

The key thing here is that grub-bhyve has a device called (host) that
allows inclusion of files from the host.

Following this working, this command line string is added to virsh's
xml definition under <boolloader_args>

You cannot just add the extra arguments "--root" and "--directory" to
bootload_args as it is a complete replacement of the automatically
generated arguments that libvirt creates. I however, still rely on the
autogenerated device map file that it creates (Note it's in /var/run)

Perhaps this is a deficiency that should be addressed in the bootloader
compontent of libvirt to make this process a bit easier?



- -- 
Sincerely,

William Brown

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJUphGhAAoJEO/EFteBqAmak1AP/0ldLhfFblP5WoRa1V6pN60K
9YR0bgMo1goUPeHrQbKLOMrVD3SleuhGugvjPSQbQz+9FKkeE+REqrwPLuAbDZHS
IVeuQsZuHimdBaoSB5XUE/xOjnkBNIZWCmDjiHI8QEdc3o6u5x4lPRL3xbqoTJ7c
KTw46cWaLwKsdDzanRpSOqC4q1gNt/TAbYM9Srpf+h1ed3ezTaWaIcSzzHHHXMfR
RCjoycHKpblPelXKXIRcZKtS4yT+M5C5N7W+t2c8vSQ9JccSBuxWxv5UQiuszKun
Q4TgVsxYWOsH2czb3xncghPhG9kSJxUiQ0hVPRRWXRvy6G0huCjzq1g1DRESfRBy
zB3U2bI/Fa1RUrHs24bP9Mulq3PdJyyyMOIDWqEiCUVLnEEawG7XQaHV3j1sfr+J
nOHkrNZCpwFDH+3smhWUQOqAD/4OayWgfoBKKufsraQDFDxcIpfL8/kkyqNo4OoU
n3ro1QtyN9GHXlWus3vMtLXKl6uPVcoNifboBhnkXmqC9ycNeEjtPIu9Qo1FbDas
jSHZKar2IfwT6VfWPaAHlZv8ZPlcQWdDYPJ2d9ldDgZPqWd5gcD2YoAdf+Z2KyVJ
Tew/UMBUiwd61qu7qs6hZyUiQbKZocO6QHqN3oo0NYRdTLYkhs9TxZvEFHqzyO/x
3zYUy50AWfVJd63hO6i3
=/Aoa
-----END PGP SIGNATURE-----


More information about the freebsd-virtualization mailing list