Re: [libvirt] [PATCH] drvbhyve: Automatically tear down guest domains on shutdown

2014-12-04 Thread Conrad Meyer
On Thu, Dec 4, 2014 at 5:18 AM, Michal Privoznik mpriv...@redhat.com wrote:
 On 14.11.2014 17:03, Conrad Meyer wrote:

 +status = kev.data;
 +if (WIFSIGNALED(status)  WCOREDUMP(status)) {
 +VIR_ERROR(Guest %s got signal %d and crashed, 
 mon-vm-def-name,
 +  WTERMSIG(status));

 This needs to be virReportError(). And since you're doing gettext 
 translations _() you need to change po/POTFILES.in too.

Sorry, I am pretty unfamiliar with gettext translations!


 +virBhyveProcessStop(mon-driver, mon-vm,
 +VIR_DOMAIN_SHUTOFF_CRASHED);
 +} else if (WIFEXITED(status)) {
 +if (WEXITSTATUS(status) == 0) {
 +/* 0 - reboot */
 +/* TODO: Implementing reboot is a little more complicated. 
 */
 +VIR_INFO(Guest %s rebooted; destroying domain.,
 + mon-vm-def-name);
 +virBhyveProcessStop(mon-driver, mon-vm,
 +VIR_DOMAIN_SHUTOFF_SHUTDOWN);
 +} else if (WEXITSTATUS(status)  3) {
 +/* 1 - shutdown, 2 - halt, 3 - triple fault. others - error 
 */
 +VIR_INFO(Guest %s shut itself down; destroying domain.,
 + mon-vm-def-name);
 +virBhyveProcessStop(mon-driver, mon-vm,
 +VIR_DOMAIN_SHUTOFF_SHUTDOWN);
 +} else {
 +VIR_INFO(Guest %s had an error and exited with status %d; 
 destroying domain.,
 + mon-vm-def-name, WEXITSTATUS(status));
 +virBhyveProcessStop(mon-driver, mon-vm,
 +VIR_DOMAIN_SHUTOFF_UNKNOWN);
 +}
 +}
 +}
 +}

 ACKed with this squashed in:

 diff --git a/po/POTFILES.in b/po/POTFILES.in
 index f17b35f..d07b75a 100644
 --- a/po/POTFILES.in
 +++ b/po/POTFILES.in
 @@ -11,6 +11,7 @@ src/access/viraccessmanager.c
  src/bhyve/bhyve_command.c
  src/bhyve/bhyve_device.c
  src/bhyve/bhyve_driver.c
 +src/bhyve/bhyve_monitor.c
  src/bhyve/bhyve_process.c
  src/conf/capabilities.c
  src/conf/cpu_conf.c
 diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c
 index cd3cf6e..7f19c6e 100644
 --- a/src/bhyve/bhyve_monitor.c
 +++ b/src/bhyve/bhyve_monitor.c
 @@ -84,8 +84,10 @@ bhyveMonitorIO(int watch, int kq, int events 
 ATTRIBUTE_UNUSED, void *opaque)

  status = kev.data;
  if (WIFSIGNALED(status)  WCOREDUMP(status)) {
 -VIR_ERROR(Guest %s got signal %d and crashed, 
 mon-vm-def-name,
 -  WTERMSIG(status));
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(Guest %s got signal %d and crashed),
 +   mon-vm-def-name,
 +   WTERMSIG(status));
  virBhyveProcessStop(mon-driver, mon-vm,
  VIR_DOMAIN_SHUTOFF_CRASHED);
  } else if (WIFEXITED(status)) {

 Fixed and pushed.

 Michal


Thanks for fixing it up! Looks good to me.

Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] drvbhyve: Automatically tear down guest domains on shutdown

2014-11-20 Thread Conrad Meyer
Reboot requires more sophistication and is left as a future work item --
but at least part of the plumbing is in place.
---
 src/Makefile.am   |   2 +
 src/bhyve/bhyve_monitor.c | 184 ++
 src/bhyve/bhyve_monitor.h |  36 +
 src/bhyve/bhyve_process.c |  14 +++-
 4 files changed, 233 insertions(+), 3 deletions(-)
 create mode 100644 src/bhyve/bhyve_monitor.c
 create mode 100644 src/bhyve/bhyve_monitor.h

diff --git a/src/Makefile.am b/src/Makefile.am
index d8fe624..b6c1701 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -833,6 +833,8 @@ BHYVE_DRIVER_SOURCES =  
\
bhyve/bhyve_domain.h\
bhyve/bhyve_driver.h\
bhyve/bhyve_driver.c\
+   bhyve/bhyve_monitor.c   \
+   bhyve/bhyve_monitor.h   \
bhyve/bhyve_process.c   \
bhyve/bhyve_process.h   \
bhyve/bhyve_utils.h \
diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c
new file mode 100644
index 000..cd3cf6e
--- /dev/null
+++ b/src/bhyve/bhyve_monitor.c
@@ -0,0 +1,184 @@
+/*
+ * bhyve_monitor.c: Tear-down or reboot bhyve domains on guest shutdown
+ *
+ * Copyright (C) 2014 Conrad Meyer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * http://www.gnu.org/licenses/.
+ *
+ * Author: Conrad Meyer cse@gmail.com
+ */
+
+#include config.h
+
+#include sys/types.h
+#include sys/event.h
+#include sys/time.h
+#include sys/wait.h
+
+#include bhyve_monitor.h
+#include bhyve_process.h
+#include viralloc.h
+#include virerror.h
+#include virfile.h
+#include virlog.h
+
+#define VIR_FROM_THIS  VIR_FROM_BHYVE
+
+VIR_LOG_INIT(bhyve.bhyve_monitor);
+
+struct _bhyveMonitor {
+int kq;
+int watch;
+virDomainObjPtr vm;
+bhyveConnPtr driver;
+};
+
+static void
+bhyveMonitorIO(int watch, int kq, int events ATTRIBUTE_UNUSED, void *opaque)
+{
+const struct timespec zerowait = {};
+bhyveMonitorPtr mon = opaque;
+struct kevent kev;
+int rc, status;
+
+if (watch != mon-watch || kq != mon-kq) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(event from unexpected fd %d!=%d / watch %d!=%d),
+   mon-kq, kq, mon-watch, watch);
+return;
+}
+
+rc = kevent(kq, NULL, 0, kev, 1, zerowait);
+if (rc  0) {
+virReportSystemError(errno, %s, _(Unable to query kqueue));
+return;
+}
+
+if (rc == 0)
+return;
+
+if ((kev.flags  EV_ERROR) != 0) {
+virReportSystemError(kev.data, %s, _(Unable to query kqueue));
+return;
+}
+
+if (kev.filter == EVFILT_PROC  (kev.fflags  NOTE_EXIT) != 0) {
+if ((pid_t)kev.ident != mon-vm-pid) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+_(event from unexpected proc %ju!=%ju),
+(uintmax_t)mon-vm-pid, (uintmax_t)kev.ident);
+return;
+}
+
+status = kev.data;
+if (WIFSIGNALED(status)  WCOREDUMP(status)) {
+VIR_ERROR(Guest %s got signal %d and crashed, mon-vm-def-name,
+  WTERMSIG(status));
+virBhyveProcessStop(mon-driver, mon-vm,
+VIR_DOMAIN_SHUTOFF_CRASHED);
+} else if (WIFEXITED(status)) {
+if (WEXITSTATUS(status) == 0) {
+/* 0 - reboot */
+/* TODO: Implementing reboot is a little more complicated. */
+VIR_INFO(Guest %s rebooted; destroying domain.,
+ mon-vm-def-name);
+virBhyveProcessStop(mon-driver, mon-vm,
+VIR_DOMAIN_SHUTOFF_SHUTDOWN);
+} else if (WEXITSTATUS(status)  3) {
+/* 1 - shutdown, 2 - halt, 3 - triple fault. others - error */
+VIR_INFO(Guest %s shut itself down; destroying domain.,
+ mon-vm-def-name);
+virBhyveProcessStop(mon-driver, mon-vm,
+VIR_DOMAIN_SHUTOFF_SHUTDOWN);
+} else {
+VIR_INFO(Guest %s had

Re: [libvirt] [PATCH 1/2] virdbus: don't force users to pass int for bool values

2014-11-20 Thread Conrad Meyer
Hi Eric,

I think this change breaks build on FreeBSD:

  CC   util/libvirt_util_la-virdbus.lo
util/virdbus.c:956:13: error: cast from 'bool *' to 'dbus_bool_t *' (aka 
'unsigned int *') increases required alignment from 1 to 4 
[-Werror,-Wcast-align]
GET_NEXT_VAL(dbus_bool_t, bool_val, bool, %d);
^~~
util/virdbus.c:858:17: note: expanded from macro 'GET_NEXT_VAL'
x = (dbustype *)(*xptrptr + (*narrayptr - 1));  \
^ 1 error generated.

(CC is Clang.)

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] drvbhyve: Automatically tear down guest domains on shutdown

2014-11-14 Thread Conrad Meyer
Reboot requires more sophistication and is left as a future work item --
but at least part of the plumbing is in place.
---
Looking for feedback. I'm pretty unfamiliar with libvirt; maybe this isn't
quite the right way to do this. Sorry. If you want me to rework it in some way,
just let me know.

I tried to model this off of DrvQEMU, which I knew to support this behavior.

Reboot should probably be processed on a threadpool thread outside of the event
loop, so I omitted it for now.

P.S., the 'read-non-seekable' check test seems to just hang forever on FreeBSD.
I haven't dug into it, but POSIX FIFO behavior is pretty weird.
---
 src/Makefile.am   |   2 +
 src/bhyve/bhyve_monitor.c | 184 ++
 src/bhyve/bhyve_monitor.h |  36 +
 src/bhyve/bhyve_process.c |  14 +++-
 4 files changed, 233 insertions(+), 3 deletions(-)
 create mode 100644 src/bhyve/bhyve_monitor.c
 create mode 100644 src/bhyve/bhyve_monitor.h

diff --git a/src/Makefile.am b/src/Makefile.am
index d8fe624..b6c1701 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -833,6 +833,8 @@ BHYVE_DRIVER_SOURCES =  
\
bhyve/bhyve_domain.h\
bhyve/bhyve_driver.h\
bhyve/bhyve_driver.c\
+   bhyve/bhyve_monitor.c   \
+   bhyve/bhyve_monitor.h   \
bhyve/bhyve_process.c   \
bhyve/bhyve_process.h   \
bhyve/bhyve_utils.h \
diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c
new file mode 100644
index 000..cd3cf6e
--- /dev/null
+++ b/src/bhyve/bhyve_monitor.c
@@ -0,0 +1,184 @@
+/*
+ * bhyve_monitor.c: Tear-down or reboot bhyve domains on guest shutdown
+ *
+ * Copyright (C) 2014 Conrad Meyer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * http://www.gnu.org/licenses/.
+ *
+ * Author: Conrad Meyer cse@gmail.com
+ */
+
+#include config.h
+
+#include sys/types.h
+#include sys/event.h
+#include sys/time.h
+#include sys/wait.h
+
+#include bhyve_monitor.h
+#include bhyve_process.h
+#include viralloc.h
+#include virerror.h
+#include virfile.h
+#include virlog.h
+
+#define VIR_FROM_THIS  VIR_FROM_BHYVE
+
+VIR_LOG_INIT(bhyve.bhyve_monitor);
+
+struct _bhyveMonitor {
+int kq;
+int watch;
+virDomainObjPtr vm;
+bhyveConnPtr driver;
+};
+
+static void
+bhyveMonitorIO(int watch, int kq, int events ATTRIBUTE_UNUSED, void *opaque)
+{
+const struct timespec zerowait = {};
+bhyveMonitorPtr mon = opaque;
+struct kevent kev;
+int rc, status;
+
+if (watch != mon-watch || kq != mon-kq) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(event from unexpected fd %d!=%d / watch %d!=%d),
+   mon-kq, kq, mon-watch, watch);
+return;
+}
+
+rc = kevent(kq, NULL, 0, kev, 1, zerowait);
+if (rc  0) {
+virReportSystemError(errno, %s, _(Unable to query kqueue));
+return;
+}
+
+if (rc == 0)
+return;
+
+if ((kev.flags  EV_ERROR) != 0) {
+virReportSystemError(kev.data, %s, _(Unable to query kqueue));
+return;
+}
+
+if (kev.filter == EVFILT_PROC  (kev.fflags  NOTE_EXIT) != 0) {
+if ((pid_t)kev.ident != mon-vm-pid) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+_(event from unexpected proc %ju!=%ju),
+(uintmax_t)mon-vm-pid, (uintmax_t)kev.ident);
+return;
+}
+
+status = kev.data;
+if (WIFSIGNALED(status)  WCOREDUMP(status)) {
+VIR_ERROR(Guest %s got signal %d and crashed, mon-vm-def-name,
+  WTERMSIG(status));
+virBhyveProcessStop(mon-driver, mon-vm,
+VIR_DOMAIN_SHUTOFF_CRASHED);
+} else if (WIFEXITED(status)) {
+if (WEXITSTATUS(status) == 0) {
+/* 0 - reboot */
+/* TODO: Implementing reboot is a little more complicated. */
+VIR_INFO(Guest %s rebooted; destroying domain.,
+ mon-vm-def-name);
+virBhyveProcessStop(mon-driver

Re: [libvirt] [PATCH] drvbhyve: Use boot-order for grub-bhyve boot device

2014-11-13 Thread Conrad Meyer
On Thu, Nov 13, 2014 at 8:30 AM, Michal Privoznik mpriv...@redhat.com wrote:
 I think we need to honor boot order for CD-ROMs too. I mean, if you have two 
 CD-ROMS like this:

 disk type='file' device='cdrom'
   driver name='file' type='raw'/
   source file='/tmp/freebsd1.iso'/
   target dev='hda' bus='sata'/
   boot order='2'/
 /disk
 disk type='file' device='cdrom'
   driver name='file' type='raw'/
   source file='/tmp/freebsd2.iso'/
   target dev='hda' bus='sata'/
   boot order='1'/
 /disk

I agree. I think the patch should do so.


 I'd expect to boot from /tmp/freebsd2.iso. Although, on the other hand, 
 there's only onde device we can boot from, right? If that's the case, your 
 code works too. Or am I just off the page?

 Michal

Right. grub-bhyve only knows how to boot one device (as far as I
know). In that example it should pick freebsd2.iso.

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv8.1 5/7] bhyve: Probe grub-bhyve for --cons-dev capability

2014-11-12 Thread Conrad Meyer
On Wed, Nov 12, 2014 at 4:07 AM, Michal Privoznik mpriv...@redhat.com wrote:
 On 11.11.2014 16:35, Conrad Meyer wrote:
 +/* These are bit flags: */
 +enum {
 +BHYVE_GRUB_CAP_CONSDEV = 0x0001,
 +};


 I think this should be rather typedef enum {...} virBhyveGrubCapsFlags;

Ok.

 +int virBhyveProbeGrubCaps(unsigned *caps);


 And hence s/unsigned/virBhyveGrubCapsFlags/

This seems like a confusing use of an enum to me — with 2+ flags, you
can return values that are no longer present in the enum as enum type.


 +
   #endif


 I'm fixing this and pushing. ACK.

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] drvbhyve: Clean-up some used ATTRIBUTE_UNUSEDs.

2014-11-12 Thread Conrad Meyer
---
 src/bhyve/bhyve_device.c  |  2 +-
 src/bhyve/bhyve_driver.c  | 10 +-
 src/bhyve/bhyve_process.c |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index fa266de..b458275 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -62,7 +62,7 @@ bhyveCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
 }
 
 virDomainPCIAddressSetPtr
-bhyveDomainPCIAddressSetCreate(virDomainDefPtr def ATTRIBUTE_UNUSED, unsigned 
int nbuses)
+bhyveDomainPCIAddressSetCreate(virDomainDefPtr def, unsigned int nbuses)
 {
 virDomainPCIAddressSetPtr addrs;
 
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 3820737..331f310 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -231,7 +231,7 @@ bhyveConnectClose(virConnectPtr conn)
 }
 
 static char *
-bhyveConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
+bhyveConnectGetHostname(virConnectPtr conn)
 {
 if (virConnectGetHostnameEnsureACL(conn)  0)
 return NULL;
@@ -265,7 +265,7 @@ bhyveConnectGetSysinfo(virConnectPtr conn, unsigned int 
flags)
 }
 
 static int
-bhyveConnectGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned long 
*version)
+bhyveConnectGetVersion(virConnectPtr conn, unsigned long *version)
 {
 struct utsname ver;
 
@@ -1143,7 +1143,7 @@ bhyveStateCleanup(void)
 }
 
 static int
-bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
+bhyveStateInitialize(bool priveleged,
  virStateInhibitCallback callback ATTRIBUTE_UNUSED,
  void *opaque ATTRIBUTE_UNUSED)
 {
@@ -1249,7 +1249,7 @@ bhyveStateAutoStart(void)
 }
 
 static int
-bhyveConnectGetMaxVcpus(virConnectPtr conn ATTRIBUTE_UNUSED,
+bhyveConnectGetMaxVcpus(virConnectPtr conn,
 const char *type)
 {
 if (virConnectGetMaxVcpusEnsureACL(conn)  0)
@@ -1317,7 +1317,7 @@ bhyveNodeSetMemoryParameters(virConnectPtr conn,
 }
 
 static char *
-bhyveConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
+bhyveConnectBaselineCPU(virConnectPtr conn,
 const char **xmlCPUs,
 unsigned int ncpus,
 unsigned int flags)
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index 21f8331..a30e36a 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -251,7 +251,7 @@ virBhyveProcessStart(virConnectPtr conn,
 int
 virBhyveProcessStop(bhyveConnPtr driver,
 virDomainObjPtr vm,
-virDomainShutoffReason reason ATTRIBUTE_UNUSED)
+virDomainShutoffReason reason)
 {
 int ret = -1;
 virCommandPtr cmd = NULL;
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] drvbhyve: Use boot-order for grub-bhyve boot device

2014-11-12 Thread Conrad Meyer
Rather than just picking the first CD (or failing that, HDD) we come
across, if the user has picked a boot device ordering with boot
order='', respect that (and just try to boot the lowest-index device).

Adds two sets of tests to bhyve2xmlargv; 'grub-bootorder' shows that we
pick a user-specified device over the first device in the domain;
'grub-bootorder2' shows that we pick the first (lowest index) device.
---
This is a follow-up to the 'Add non-FreeBSD guest support to Bhyve driver'
patch series to fix the grub-bhyve automagic configuration to respect boot
order='' in the domain. (Requested by both Roman and Michal, I believe.)
---
 docs/drvbhyve.html.in  |  9 +--
 src/bhyve/bhyve_command.c  | 64 --
 .../bhyvexml2argv-grub-bootorder.args  |  6 ++
 .../bhyvexml2argv-grub-bootorder.devmap|  1 +
 .../bhyvexml2argv-grub-bootorder.ldargs|  2 +
 .../bhyvexml2argv-grub-bootorder.xml   | 36 
 .../bhyvexml2argv-grub-bootorder2.args |  6 ++
 .../bhyvexml2argv-grub-bootorder2.devmap   |  1 +
 .../bhyvexml2argv-grub-bootorder2.ldargs   |  2 +
 .../bhyvexml2argv-grub-bootorder2.xml  | 38 +
 tests/bhyvexml2argvtest.c  |  2 +
 11 files changed, 146 insertions(+), 21 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.xml

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index bd4b35e..5479511 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -234,10 +234,11 @@ management./p
 pIt's possible to boot non-FreeBSD guests by specifying an explicit
 bootloader, e.g. codegrub-bhyve(1)/code. Arguments to the bootloader may be
 specified as well. If the bootloader is codegrub-bhyve/code and arguments
-are omitted, libvirt will try and boot the first disk in the domain (either
-codecdrom/code- or codedisk/code-type devices). If the disk type is
-codedisk/code, it will attempt to boot from the first partition in the disk
-image./p
+are omitted, libvirt will try and infer boot ordering from user-supplied
+lt;boot order='N'gt; configuration in the domain. Failing that, it will boot
+the first disk in the domain (either codecdrom/code- or
+codedisk/code-type devices). If the disk type is codedisk/code, it will
+attempt to boot from the first partition in the disk image./p
 
 pre
   ...
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 26d4797..6e3bf03 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -381,38 +381,62 @@ virBhyveUsableDisk(virConnectPtr conn, 
virDomainDiskDefPtr disk)
 return true;
 }
 
+static void
+virBhyveFormatGrubDevice(virBufferPtr devicemap, virDomainDiskDefPtr def)
+{
+
+if (def-device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+virBufferAsprintf(devicemap, (cd) %s\n,
+  virDomainDiskGetSource(def));
+else
+virBufferAsprintf(devicemap, (hd0) %s\n,
+  virDomainDiskGetSource(def));
+}
+
 static virCommandPtr
 virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
  virConnectPtr conn,
  const char *devmap_file,
  char **devicesmap_out)
 {
-virDomainDiskDefPtr disk, cd;
+virDomainDiskDefPtr hdd, cd, userdef, diskdef;
 virBuffer devicemap;
 virCommandPtr cmd;
+int best_idx;
 size_t i;
 
 if (def-os.bootloaderArgs != NULL)
 return virBhyveProcessBuildCustomLoaderCmd(def);
 
+best_idx = INT_MAX;
 devicemap = (virBuffer)VIR_BUFFER_INITIALIZER;
 
-/* Search disk list for CD or HDD device. */
-cd = disk = NULL;
+/* Search disk list for CD or HDD device. We'll respect boot order='' if
+ * present and otherwise pick the first CD or failing that HDD we come
+ * across. */
+cd = hdd = userdef = NULL;
 for (i = 0; i  def-ndisks; i++) {
 if (!virBhyveUsableDisk(conn, def-disks[i]))
 continue;
 
+diskdef = def-disks[i];
+
+if (diskdef-info.bootIndex  diskdef-info.bootIndex  best_idx) {
+userdef = diskdef;
+best_idx = userdef-info.bootIndex;
+continue;
+}
+
 if (cd == NULL 
 def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
-

Re: [libvirt] [PATCHv8 1/7] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-11-11 Thread Conrad Meyer
On Tue, Nov 11, 2014 at 9:52 AM, Michal Privoznik mpriv...@redhat.com wrote:
 On 08.11.2014 17:48, Conrad Meyer wrote:
 +static virCommandPtr
 +virBhyveProcessBuildBhyveloadCmd(virDomainDefPtr def, virDomainDiskDefPtr
 disk)
   {
   virCommandPtr cmd;
 -virDomainDiskDefPtr disk;

 -if (def-ndisks  1) {
 -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 -   _(domain should have at least one disk
 defined));
 +cmd = virCommandNew(BHYVELOAD);
 +
 +if (def-os.bootloaderArgs == NULL) {
 +VIR_DEBUG(bhyveload with default arguments);
 +
 +/* Memory (MB) */
 +virCommandAddArg(cmd, -m);
 +virCommandAddArgFormat(cmd, %llu,
 +   VIR_DIV_UP(def-mem.max_balloon, 1024));

 One of the things I'm worried about is, if the boot args are not specified
 we properly add memory configured in domain XML.

 +
 +/* Image path */
 +virCommandAddArg(cmd, -d);
 +virCommandAddArg(cmd, virDomainDiskGetSource(disk));
 +
 +/* VM name */
 +virCommandAddArg(cmd, def-name);
 +} else {
 +VIR_DEBUG(bhyveload with arguments);
 +virAppendBootloaderArgs(cmd, def);
 +}
 +


 However, IIUC the memory amount can be overridden with boot args. Is that
 expected?

Yes. If you use bootloader_args, you get exactly what you ask for and no more.

 +static virCommandPtr
 +virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
 + virConnectPtr conn,
 + const char *devmap_file,
 + char **devicesmap_out)
 +{
 +virDomainDiskDefPtr disk, cd;
 +virBuffer devicemap;
 +virCommandPtr cmd;
 +size_t i;
 +
 +if (def-os.bootloaderArgs != NULL)
 +return virBhyveProcessBuildCustomLoaderCmd(def);
 +
 +devicemap = (virBuffer)VIR_BUFFER_INITIALIZER;
 +
 +/* Search disk list for CD or HDD device. */
 +cd = disk = NULL;
 +for (i = 0; i  def-ndisks; i++) {
 +if (!virBhyveUsableDisk(conn, def-disks[i]))
 +continue;
 +
 +if (cd == NULL 
 +def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
 +cd = def-disks[i];
 +VIR_INFO(Picking %s as boot CD,
 virDomainDiskGetSource(cd));
 +}
 +
 +if (disk == NULL 
 +def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_DISK) {
 +disk = def-disks[i];
 +VIR_INFO(Picking %s as HDD, virDomainDiskGetSource(disk));
 +}


 Can we utilize boot order='X'/ attribute here?

This has come up before and the answer is yes, but I'd prefer to do so
in a later patch series; this one is already growing unwieldy.



 +}
 +
 +cmd = virCommandNew(def-os.bootloader);
 +
 +VIR_DEBUG(grub-bhyve with default arguments);
 +
 +if (devicesmap_out != NULL) {
 +/* Grub device.map (just for boot) */
 +if (disk != NULL)
 +virBufferAsprintf(devicemap, (hd0) %s\n,
 +  virDomainDiskGetSource(disk));
 +
 +if (cd != NULL)
 +virBufferAsprintf(devicemap, (cd) %s\n,
 +  virDomainDiskGetSource(cd));
 +
 +*devicesmap_out = virBufferContentAndReset(devicemap);
 +}
 +
 +if (cd != NULL) {
 +virCommandAddArg(cmd, --root);
 +virCommandAddArg(cmd, cd);
 +} else {
 +virCommandAddArg(cmd, --root);
 +virCommandAddArg(cmd, hd0,msdos1);
 +}
 +
 +virCommandAddArg(cmd, --device-map);
 +virCommandAddArg(cmd, devmap_file);
 +
 +/* Memory in MB */
 +virCommandAddArg(cmd, --memory);
   virCommandAddArgFormat(cmd, %llu,
  VIR_DIV_UP(def-mem.max_balloon, 1024));

 -/* Image path */
 -virCommandAddArg(cmd, -d);
 -virCommandAddArg(cmd, virDomainDiskGetSource(disk));
 -
   /* VM name */
   virCommandAddArg(cmd, def-name);

   return cmd;
   }


 Otherwise looking good.

 Michal

Thanks!

Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv8 0/7] Add non-FreeBSD guest support to Bhyve driver.

2014-11-11 Thread Conrad Meyer
On Tue, Nov 11, 2014 at 9:52 AM, Michal Privoznik mpriv...@redhat.com wrote:
 Looking good. Basically ACK to the patches. BUT, please post a follow-up
 patches to 1/7 and 5/7 (as reply to individual patches or cover letter
 ideally). I don't want to make you to send another version. I'll merge the
 patches then.

 Michal


Great. I've posted a minor follow-up to 5/7; if you think the 1/7 is
completely trivial, I can do the follow up there, but I'd rather fix
it up separately.

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv8.1 5/7] bhyve: Probe grub-bhyve for --cons-dev capability

2014-11-11 Thread Conrad Meyer
---
 src/bhyve/bhyve_capabilities.c | 37 +
 src/bhyve/bhyve_capabilities.h |  6 ++
 2 files changed, 43 insertions(+)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 132ce91..6e9a943 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -23,6 +23,7 @@
 #include sys/utsname.h
 
 #include viralloc.h
+#include virfile.h
 #include virlog.h
 #include virstring.h
 #include cpu/cpu.h
@@ -104,3 +105,39 @@ virBhyveCapsBuild(void)
 virObjectUnref(caps);
 return NULL;
 }
+
+int
+virBhyveProbeGrubCaps(unsigned *caps)
+{
+char *binary, *help;
+virCommandPtr cmd;
+int ret, exit;
+
+ret = 0;
+*caps = 0;
+cmd = NULL;
+help = NULL;
+
+binary = virFindFileInPath(grub-bhyve);
+if (binary == NULL)
+goto out;
+if (!virFileIsExecutable(binary))
+goto out;
+
+cmd = virCommandNew(binary);
+virCommandAddArg(cmd, --help);
+virCommandSetOutputBuffer(cmd, help);
+if (virCommandRun(cmd, exit)  0) {
+ret = -1;
+goto out;
+}
+
+if (strstr(help, --cons-dev) != NULL)
+*caps |= BHYVE_GRUB_CAP_CONSDEV;
+
+ out:
+VIR_FREE(help);
+virCommandFree(cmd);
+VIR_FREE(binary);
+return ret;
+}
diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h
index c52e0d0..a559d2a 100644
--- a/src/bhyve/bhyve_capabilities.h
+++ b/src/bhyve/bhyve_capabilities.h
@@ -26,4 +26,10 @@
 
 virCapsPtr virBhyveCapsBuild(void);
 
+/* These are bit flags: */
+enum {
+BHYVE_GRUB_CAP_CONSDEV = 0x0001,
+};
+int virBhyveProbeGrubCaps(unsigned *caps);
+
 #endif
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv8 1/7] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-11-11 Thread Conrad Meyer
On Tue, Nov 11, 2014 at 10:40 AM, Michal Privoznik mpriv...@redhat.com wrote:
 On 11.11.2014 16:17, Conrad Meyer wrote:

 On Tue, Nov 11, 2014 at 9:52 AM, Michal Privoznik mpriv...@redhat.com
 wrote:
 One of the things I'm worried about is, if the boot args are not
 specified
 we properly add memory configured in domain XML.

 However, IIUC the memory amount can be overridden with boot args. Is that
 expected?


 Yes. If you use bootloader_args, you get exactly what you ask for and no
 more.


 Well, if one is modifying XML to change booloader_args already he can change
 the memory amount there too. What I'm trying to say is, we should add '-m
 def-mem.max_balloon' unconditionally. Or do you intend to give users so
 much freedom? I worried it can bite us later when libvirt fails to see the
 real amount of memory that domain has.

I think also bhyve(8) itself will be unhappy. The man page specifies:


 -m size[K|k|M|m|G|g|T|t]
 Guest physical memory size in bytes.  This must be the same
 size that was given to bhyveload(8).


However, I think the messaging around bootloader_args for bhyve /
bhyveload is and should remain: if you need this, you're on your own
and need to specify *everything* manually. We expect most users to
not need bootloader for bhyve at all, especially in the medium-term
future, and even fewer users to need bootloader_args.

IMO, as a user it is more surprising to get additional arguments
prepended to the arguments I have specified than to have them passed
through unmodified. And we would have to prepend or otherwise shove
the -m flag in the middle somewhere. I think it is probably too much
magic.




 +static virCommandPtr
 +virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
 + virConnectPtr conn,
 + const char *devmap_file,
 + char **devicesmap_out)
 +{
 +virDomainDiskDefPtr disk, cd;
 +virBuffer devicemap;
 +virCommandPtr cmd;
 +size_t i;
 +
 +if (def-os.bootloaderArgs != NULL)
 +return virBhyveProcessBuildCustomLoaderCmd(def);
 +
 +devicemap = (virBuffer)VIR_BUFFER_INITIALIZER;
 +
 +/* Search disk list for CD or HDD device. */
 +cd = disk = NULL;
 +for (i = 0; i  def-ndisks; i++) {
 +if (!virBhyveUsableDisk(conn, def-disks[i]))
 +continue;
 +
 +if (cd == NULL 
 +def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
 +cd = def-disks[i];
 +VIR_INFO(Picking %s as boot CD,
 virDomainDiskGetSource(cd));
 +}
 +
 +if (disk == NULL 
 +def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_DISK) {
 +disk = def-disks[i];
 +VIR_INFO(Picking %s as HDD,
 virDomainDiskGetSource(disk));
 +}



 Can we utilize boot order='X'/ attribute here?


 This has come up before and the answer is yes, but I'd prefer to do so
 in a later patch series; this one is already growing unwieldy.


 Agreed. This can be addressed later, when needed.

 Michal

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv8 1/7] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-11-08 Thread Conrad Meyer
We still default to bhyveloader(1) if no explicit bootloader
configuration is supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk (or a CD if one exists,
under the assumption that for a VM a CD is likely an install source).

Caveat: Assumes the HDD boots from the msdos1 partition. I think this is
a pretty reasonable assumption for a VM. (DrvBhyve with Bhyveload
already assumes that the first disk should be booted.)

I've tested both HDD and CD boot and they seem to work.
---
 docs/drvbhyve.html.in | 100 +--
 docs/formatdomain.html.in |   4 +-
 src/bhyve/bhyve_command.c | 173 +-
 src/bhyve/bhyve_command.h |   5 +-
 src/bhyve/bhyve_driver.c  |   3 +-
 src/bhyve/bhyve_process.c |  38 +-
 6 files changed, 295 insertions(+), 28 deletions(-)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 39afdf5..bd4b35e 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
tunnelled)
 h3Example config/h3
 p
 The bhyve driver in libvirt is in its early stage and under active 
development. So it supports
-only limited number of features bhyve provides. All the supported features 
could be found
-in this sample domain XML.
+only limited number of features bhyve provides.
 /p
 
 p
@@ -48,10 +47,21 @@ disk device were supported per-domain. However,
 up to 31 PCI devices.
 /p
 
+p
+Note: the Bhyve driver in libvirt will boot whichever device is first. If you
+want to install from CD, put the CD device first. If not, put the root HDD
+first.
+/p
+
+p
+Note: Only the SATA bus is supported. Only codecdrom/code- and
+codedisk/code-type disks are supported.
+/p
+
 pre
 lt;domain type='bhyve'gt;
-  lt;namegt;bhyvelt;/namegt;
-  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;namegt;bhyvelt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 lt;memorygt;219136lt;/memorygt;
 lt;currentMemorygt;219136lt;/currentMemorygt;
 lt;vcpugt;1lt;/vcpugt;
@@ -76,6 +86,7 @@ up to 31 PCI devices.
 lt;driver name='file' type='raw'/gt;
 lt;source file='/path/to/cdrom.iso'/gt;
 lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
   lt;/diskgt;
   lt;interface type='bridge'gt;
 lt;model type='virtio'/gt;
@@ -85,6 +96,53 @@ up to 31 PCI devices.
 lt;/domaingt;
 /pre
 
+p(The lt;diskgt; sections may be swapped in order to install from
+emcdrom.iso/em.)/p
+
+h3Example config (Linux guest)/h3
+
+p
+Note the addition of lt;bootloadergt;.
+/p
+
+pre
+lt;domain type='bhyve'gt;
+lt;namegt;linux_guestlt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;memorygt;131072lt;/memorygt;
+lt;currentMemorygt;131072lt;/currentMemorygt;
+lt;vcpugt;1lt;/vcpugt;
+lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
+lt;osgt;
+   lt;typegt;hvmlt;/typegt;
+lt;/osgt;
+lt;featuresgt;
+  lt;apic/gt;
+  lt;acpi/gt;
+lt;/featuresgt;
+lt;clock offset='utc'/gt;
+lt;on_poweroffgt;destroylt;/on_poweroffgt;
+lt;on_rebootgt;restartlt;/on_rebootgt;
+lt;on_crashgt;destroylt;/on_crashgt;
+lt;devicesgt;
+  lt;disk type='file' device='disk'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/guest_hdd.img'/gt;
+lt;target dev='hda' bus='sata'/gt;
+  lt;/diskgt;
+  lt;disk type='file' device='cdrom'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/cdrom.iso'/gt;
+lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
+  lt;/diskgt;
+  lt;interface type='bridge'gt;
+lt;model type='virtio'/gt;
+lt;source bridge=virbr0/gt;
+  lt;/interfacegt;
+lt;/devicesgt;
+lt;/domaingt;
+/pre
 
 h2a name=usageGuest usage / management/a/h2
 
@@ -119,6 +177,20 @@ to let a guest boot or start a guest using:/p
 
 prestart --console domname/pre
 
+pbNB:/b An bootloader configured to require user interaction will prevent
+the domain from starting (and thus codevirsh console/code or codestart
+--console/code from functioning) until the user interacts with it manually on
+the VM host. Because users typically do not have access to the VM host,
+interactive bootloaders are unsupported by libvirt. emHowever,/em if you 
happen to
+run into this scenario and also happen to have access to the Bhyve host
+machine, you may select a boot option and allow the domain to finish starting
+by using an alternative terminal client on the VM host to connect to the
+domain-configured null modem device. One example (assuming
+code/dev/nmdm0B/code is configured as the slave end of the domain serial
+device) is:/p
+
+precu -l /dev/nmdm0B/pre
+
 h3a name=xmltonativeConverting from domain 

[libvirt] [PATCHv8 0/7] Add non-FreeBSD guest support to Bhyve driver.

2014-11-08 Thread Conrad Meyer
Drvbhyve hardcodes bhyveload(8) as the host bootloader for guests.
bhyveload(8) loader only supports FreeBSD guests.

This patch series adds bootloader and bootloader_args handling to
bhyve_command, so libvirt can boot non-FreeBSD guests in Bhyve.

Additionally, support for grub-bhyve(1)'s --cons-dev argument is added so that
interactive GRUB menus can be manipulated with the domain-configured serial
device.

See patch logs for further details.

Thanks,
Conrad

Changes in v8:
  - Fix typo in virBhyveProcessStart that prevented booting bhyve VMs.

Conrad Meyer (7):
  bhyve: Support /domain/bootloader configuration for non-FreeBSD
guests.
  bhyvexml2argv: Add loader argv tests.
  domaincommon.rng: Add 'bootloader' to os=hvm schema for Bhyve
  bhyvexml2argv: Add tests for domain-configured bootloader, args
  bhyve: Probe grub-bhyve for --cons-dev capability
  bhyve: Add console support for grub-bhyve bootloader
  bhyvexml2argv: Add test for grub console support

 docs/drvbhyve.html.in  | 100 ++-
 docs/formatdomain.html.in  |   4 +-
 docs/schemas/domaincommon.rng  |  17 +-
 src/bhyve/bhyve_capabilities.c |  37 
 src/bhyve/bhyve_capabilities.h |   3 +
 src/bhyve/bhyve_command.c  | 189 +++--
 src/bhyve/bhyve_command.h  |   5 +-
 src/bhyve/bhyve_driver.c   |  16 +-
 src/bhyve/bhyve_driver.h   |   2 +
 src/bhyve/bhyve_process.c  |  38 -
 src/bhyve/bhyve_utils.h|   2 +
 .../bhyvexml2argv-acpiapic.ldargs  |   1 +
 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs  |   1 +
 .../bhyvexml2argv-bhyveload-explicitargs.args  |   3 +
 .../bhyvexml2argv-bhyveload-explicitargs.ldargs|   1 +
 .../bhyvexml2argv-bhyveload-explicitargs.xml   |  23 +++
 .../bhyvexml2argvdata/bhyvexml2argv-console.ldargs |   1 +
 .../bhyvexml2argv-custom-loader.args   |   3 +
 .../bhyvexml2argv-custom-loader.ldargs |   1 +
 .../bhyvexml2argv-custom-loader.xml|  24 +++
 .../bhyvexml2argv-disk-cdrom-grub.args |   3 +
 .../bhyvexml2argv-disk-cdrom-grub.devmap   |   1 +
 .../bhyvexml2argv-disk-cdrom-grub.ldargs   |   2 +
 .../bhyvexml2argv-disk-cdrom-grub.xml  |  23 +++
 .../bhyvexml2argv-disk-cdrom.ldargs|   1 +
 .../bhyvexml2argv-disk-virtio.ldargs   |   1 +
 .../bhyvexml2argv-grub-defaults.args   |   3 +
 .../bhyvexml2argv-grub-defaults.devmap |   1 +
 .../bhyvexml2argv-grub-defaults.ldargs |   2 +
 .../bhyvexml2argv-grub-defaults.xml|  23 +++
 .../bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs |   1 +
 .../bhyvexml2argv-serial-grub-nocons.args  |   4 +
 .../bhyvexml2argv-serial-grub-nocons.devmap|   1 +
 .../bhyvexml2argv-serial-grub-nocons.ldargs|   2 +
 .../bhyvexml2argv-serial-grub-nocons.xml   |  26 +++
 .../bhyvexml2argv-serial-grub.args |   4 +
 .../bhyvexml2argv-serial-grub.devmap   |   1 +
 .../bhyvexml2argv-serial-grub.ldargs   |   2 +
 .../bhyvexml2argv-serial-grub.xml  |  26 +++
 .../bhyvexml2argvdata/bhyvexml2argv-serial.ldargs  |   1 +
 tests/bhyvexml2argvtest.c  |  71 +++-
 41 files changed, 631 insertions(+), 39 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.ldargs
 create mode 100644 tests

[libvirt] [PATCHv8 2/7] bhyvexml2argv: Add loader argv tests.

2014-11-08 Thread Conrad Meyer
---
 .../bhyvexml2argv-acpiapic.ldargs  |  1 +
 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs  |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-console.ldargs |  1 +
 .../bhyvexml2argv-disk-cdrom.ldargs|  1 +
 .../bhyvexml2argv-disk-virtio.ldargs   |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-serial.ldargs  |  1 +
 tests/bhyvexml2argvtest.c  | 60 +++---
 8 files changed, 61 insertions(+), 6 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
new file mode 100644
index 000..0eb3cc9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/cdrom.iso bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index b9be378..3ff6696 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -15,14 +15,16 @@
 static bhyveConn driver;
 
 static int testCompareXMLToArgvFiles(const char *xml,
- const char *cmdline)
+ const char *cmdline,
+ const char *ldcmdline,
+ const char *dmcmdline)
 {
-char *expectargv = NULL;
+char *expectargv = NULL, *expectld = NULL, *expectdm = NULL;
 int len;
-char *actualargv = NULL;
+char *actualargv = NULL, *actualld = NULL, *actualdm = NULL;
 virDomainDefPtr vmdef = NULL;
 virDomainObj vm;
-virCommandPtr cmd = NULL;
+virCommandPtr cmd = NULL, ldcmd = NULL;
 virConnectPtr conn;
 int ret = -1;
 
@@ -42,6 +44,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
 if (!(actualargv = virCommandToString(cmd)))
 goto out;
 
+if (!(ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, device.map,
+  actualdm)))
+goto out;
+
+if (actualdm != NULL)
+virTrimSpaces(actualdm, NULL);
+
+if (!(actualld = virCommandToString(ldcmd)))
+goto out;
+
 len = virtTestLoadFile(cmdline, expectargv);
 if (len  0)
 goto out;
@@ -49,17 +61,49 @@ static int testCompareXMLToArgvFiles(const char *xml,
 if (len  expectargv[len - 1] == '\n')
 expectargv[len - 1] = '\0';
 
+len = virtTestLoadFile(ldcmdline, expectld);
+if (len  0)
+goto out;
+
+if (len  expectld[len - 1] == '\n')
+expectld[len - 1] = '\0';
+
+len = 

[libvirt] [PATCHv8 4/7] bhyvexml2argv: Add tests for domain-configured bootloader, args

2014-11-08 Thread Conrad Meyer
---
 .../bhyvexml2argv-bhyveload-explicitargs.args  |  3 +++
 .../bhyvexml2argv-bhyveload-explicitargs.ldargs|  1 +
 .../bhyvexml2argv-bhyveload-explicitargs.xml   | 23 +
 .../bhyvexml2argv-custom-loader.args   |  3 +++
 .../bhyvexml2argv-custom-loader.ldargs |  1 +
 .../bhyvexml2argv-custom-loader.xml| 24 ++
 .../bhyvexml2argv-disk-cdrom-grub.args |  3 +++
 .../bhyvexml2argv-disk-cdrom-grub.devmap   |  1 +
 .../bhyvexml2argv-disk-cdrom-grub.ldargs   |  2 ++
 .../bhyvexml2argv-disk-cdrom-grub.xml  | 23 +
 .../bhyvexml2argv-grub-defaults.args   |  3 +++
 .../bhyvexml2argv-grub-defaults.devmap |  1 +
 .../bhyvexml2argv-grub-defaults.ldargs |  2 ++
 .../bhyvexml2argv-grub-defaults.xml| 23 +
 tests/bhyvexml2argvtest.c  |  4 
 15 files changed, 117 insertions(+)
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.xml

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
new file mode 100644
index 000..4122e62
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
@@ -0,0 +1,3 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
diff --git 
a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
new file mode 100644
index 000..a3f58f0
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -X -Y -Z
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
new file mode 100644
index 000..65823cd
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
@@ -0,0 +1,23 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader_args-X -Y -Z/bootloader_args
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img'/
+  target dev='hda' bus='sata'/
+  address type='pci' domain='0x' bus='0x00' slot='0x02' 
function='0x0'/
+/disk
+interface type='bridge'
+  model type='virtio'/
+  source bridge=virbr0/
+  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/
+/interface
+  /devices
+/domain
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
new file mode 100644
index 000..4122e62
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
@@ -0,0 +1,3 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
new file mode 100644
index 000..100e163
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
@@ -0,0 +1 @@
+/fizz_buzz_bazz -X -Y -Z
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
new file mode 100644
index 000..e9e0d5e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
@@ -0,0 +1,24 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/fizz_buzz_bazz/bootloader
+  

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

2014-11-08 Thread Conrad Meyer
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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv8 5/7] bhyve: Probe grub-bhyve for --cons-dev capability

2014-11-08 Thread Conrad Meyer
---
 src/bhyve/bhyve_capabilities.c | 37 +
 src/bhyve/bhyve_capabilities.h |  3 +++
 2 files changed, 40 insertions(+)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 132ce91..6e9a943 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -23,6 +23,7 @@
 #include sys/utsname.h
 
 #include viralloc.h
+#include virfile.h
 #include virlog.h
 #include virstring.h
 #include cpu/cpu.h
@@ -104,3 +105,39 @@ virBhyveCapsBuild(void)
 virObjectUnref(caps);
 return NULL;
 }
+
+int
+virBhyveProbeGrubCaps(unsigned *caps)
+{
+char *binary, *help;
+virCommandPtr cmd;
+int ret, exit;
+
+ret = 0;
+*caps = 0;
+cmd = NULL;
+help = NULL;
+
+binary = virFindFileInPath(grub-bhyve);
+if (binary == NULL)
+goto out;
+if (!virFileIsExecutable(binary))
+goto out;
+
+cmd = virCommandNew(binary);
+virCommandAddArg(cmd, --help);
+virCommandSetOutputBuffer(cmd, help);
+if (virCommandRun(cmd, exit)  0) {
+ret = -1;
+goto out;
+}
+
+if (strstr(help, --cons-dev) != NULL)
+*caps |= BHYVE_GRUB_CAP_CONSDEV;
+
+ out:
+VIR_FREE(help);
+virCommandFree(cmd);
+VIR_FREE(binary);
+return ret;
+}
diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h
index c52e0d0..f4ebd90 100644
--- a/src/bhyve/bhyve_capabilities.h
+++ b/src/bhyve/bhyve_capabilities.h
@@ -26,4 +26,7 @@
 
 virCapsPtr virBhyveCapsBuild(void);
 
+# define BHYVE_GRUB_CAP_CONSDEV 0x0001
+int virBhyveProbeGrubCaps(unsigned *caps);
+
 #endif
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv8 3/7] domaincommon.rng: Add 'bootloader' to os=hvm schema for Bhyve

2014-11-08 Thread Conrad Meyer
Additionally, make the bootloader tag optional (for bhyveload with
custom arguments) (also, matches the actual parser).
---
 docs/schemas/domaincommon.rng | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 20d81ae..87ba888 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -234,6 +234,9 @@
 /choice
   /define
   define name=oshvm
+optional
+  ref name=bootloader/
+/optional
 element name=os
   ref name=ostypehvm/
   interleave
@@ -1054,12 +1057,14 @@
 --
   define name=bootloader
 interleave
-  element name=bootloader
-choice
-  ref name=absFilePath/
-  empty/
-/choice
-  /element
+  optional
+element name=bootloader
+  choice
+ref name=absFilePath/
+empty/
+  /choice
+/element
+  /optional
   optional
 element name=bootloader_args
   text/
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv8 7/7] bhyvexml2argv: Add test for grub console support

2014-11-08 Thread Conrad Meyer
---
 .../bhyvexml2argv-serial-grub-nocons.args  |  4 
 .../bhyvexml2argv-serial-grub-nocons.devmap|  1 +
 .../bhyvexml2argv-serial-grub-nocons.ldargs|  2 ++
 .../bhyvexml2argv-serial-grub-nocons.xml   | 26 ++
 .../bhyvexml2argv-serial-grub.args |  4 
 .../bhyvexml2argv-serial-grub.devmap   |  1 +
 .../bhyvexml2argv-serial-grub.ldargs   |  2 ++
 .../bhyvexml2argv-serial-grub.xml  | 26 ++
 tests/bhyvexml2argvtest.c  |  7 ++
 9 files changed, 73 insertions(+)
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.devmap
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args
new file mode 100644
index 000..df50290
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args
@@ -0,0 +1,4 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img \
+-s 1,lpc -l com1,/dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.devmap 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.devmap
new file mode 100644
index 000..68c35da
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.devmap
@@ -0,0 +1 @@
+(hd0) /tmp/freebsd.img
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.ldargs
new file mode 100644
index 000..91c15ce
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.ldargs
@@ -0,0 +1,2 @@
+/usr/local/sbin/grub-bhyve --root hd0,msdos1 --device-map 'device.map' \
+--memory 214 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.xml
new file mode 100644
index 000..8c451f7
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.xml
@@ -0,0 +1,26 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/usr/local/sbin/grub-bhyve/bootloader
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img'/
+  target dev='hda' bus='sata'/
+  address type='pci' domain='0x' bus='0x00' slot='0x02' 
function='0x0'/
+/disk
+interface type='bridge'
+  model type='virtio'/
+  source bridge=virbr0/
+  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/
+/interface
+serial type='nmdm'
+  source master='/dev/nmdm0A' slave='/dev/nmdm0B'/
+/serial
+  /devices
+/domain
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
new file mode 100644
index 000..df50290
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
@@ -0,0 +1,4 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img \
+-s 1,lpc -l com1,/dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
new file mode 100644
index 000..68c35da
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
@@ -0,0 +1 @@
+(hd0) /tmp/freebsd.img
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
new file mode 100644
index 000..5645097
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
@@ -0,0 +1,2 @@
+/usr/local/sbin/grub-bhyve --root hd0,msdos1 --device-map 'device.map' \
+--memory 214 --cons-dev /dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
new file mode 100644
index 000..8c451f7
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
@@ -0,0 +1,26 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/usr/local/sbin/grub-bhyve/bootloader
+  os
+  

Re: [libvirt] [PATCHv7 1/7] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-11-01 Thread Conrad Meyer
Hi all,

There is an issue in this patch as-is; the short version is this is needed:

--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -162,7 +162,7 @@ virBhyveProcessStart(virConnectPtr conn,
  * domain is ready to be started, so we can build
  * and execute bhyveload command */
 rc = virBhyveFormatDevMapFile(vm-def-name, devmap_file);
-if (rc)
+if (rc  0)
 goto cleanup;

 if (!(load_cmd = virBhyveProcessBuildLoadCmd(conn, vm-def, devmap_file,

Apologies for sending a broken patchset. At the time I think compile
was broken due to the multicast stuff on FreeBSD and I failed to test
it. I will send a v8 set, but I'm at a conference on the laptop and
don't have git-send-email set up here. I will try and resend
Wednesday, if not sooner.

Thanks,
Conrad


On Thu, Oct 30, 2014 at 11:56 AM, Conrad Meyer cse@gmail.com wrote:
 We still default to bhyveloader(1) if no explicit bootloader
 configuration is supplied in the domain.

 If the /domain/bootloader looks like grub-bhyve and the user doesn't
 supply /domain/bootloader_args, we make an intelligent guess and try
 chainloading the first partition on the disk (or a CD if one exists,
 under the assumption that for a VM a CD is likely an install source).

 Caveat: Assumes the HDD boots from the msdos1 partition. I think this is
 a pretty reasonable assumption for a VM. (DrvBhyve with Bhyveload
 already assumes that the first disk should be booted.)

 I've tested both HDD and CD boot and they seem to work.
 ---
  docs/drvbhyve.html.in | 100 +--
  docs/formatdomain.html.in |   4 +-
  src/bhyve/bhyve_command.c | 173 
 +-
  src/bhyve/bhyve_command.h |   5 +-
  src/bhyve/bhyve_driver.c  |   3 +-
  src/bhyve/bhyve_process.c |  38 +-
  6 files changed, 295 insertions(+), 28 deletions(-)

 diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
 index 39afdf5..bd4b35e 100644
 --- a/docs/drvbhyve.html.in
 +++ b/docs/drvbhyve.html.in
 @@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
 tunnelled)
  h3Example config/h3
  p
  The bhyve driver in libvirt is in its early stage and under active 
 development. So it supports
 -only limited number of features bhyve provides. All the supported features 
 could be found
 -in this sample domain XML.
 +only limited number of features bhyve provides.
  /p

  p
 @@ -48,10 +47,21 @@ disk device were supported per-domain. However,
  up to 31 PCI devices.
  /p

 +p
 +Note: the Bhyve driver in libvirt will boot whichever device is first. If you
 +want to install from CD, put the CD device first. If not, put the root HDD
 +first.
 +/p
 +
 +p
 +Note: Only the SATA bus is supported. Only codecdrom/code- and
 +codedisk/code-type disks are supported.
 +/p
 +
  pre
  lt;domain type='bhyve'gt;
 -  lt;namegt;bhyvelt;/namegt;
 -  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 +lt;namegt;bhyvelt;/namegt;
 +lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
  lt;memorygt;219136lt;/memorygt;
  lt;currentMemorygt;219136lt;/currentMemorygt;
  lt;vcpugt;1lt;/vcpugt;
 @@ -76,6 +86,7 @@ up to 31 PCI devices.
  lt;driver name='file' type='raw'/gt;
  lt;source file='/path/to/cdrom.iso'/gt;
  lt;target dev='hdc' bus='sata'/gt;
 +lt;readonly/gt;
lt;/diskgt;
lt;interface type='bridge'gt;
  lt;model type='virtio'/gt;
 @@ -85,6 +96,53 @@ up to 31 PCI devices.
  lt;/domaingt;
  /pre

 +p(The lt;diskgt; sections may be swapped in order to install from
 +emcdrom.iso/em.)/p
 +
 +h3Example config (Linux guest)/h3
 +
 +p
 +Note the addition of lt;bootloadergt;.
 +/p
 +
 +pre
 +lt;domain type='bhyve'gt;
 +lt;namegt;linux_guestlt;/namegt;
 +lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 +lt;memorygt;131072lt;/memorygt;
 +lt;currentMemorygt;131072lt;/currentMemorygt;
 +lt;vcpugt;1lt;/vcpugt;
 +lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
 +lt;osgt;
 +   lt;typegt;hvmlt;/typegt;
 +lt;/osgt;
 +lt;featuresgt;
 +  lt;apic/gt;
 +  lt;acpi/gt;
 +lt;/featuresgt;
 +lt;clock offset='utc'/gt;
 +lt;on_poweroffgt;destroylt;/on_poweroffgt;
 +lt;on_rebootgt;restartlt;/on_rebootgt;
 +lt;on_crashgt;destroylt;/on_crashgt;
 +lt;devicesgt;
 +  lt;disk type='file' device='disk'gt;
 +lt;driver name='file' type='raw'/gt;
 +lt;source file='/path/to/guest_hdd.img'/gt;
 +lt;target dev='hda' bus='sata'/gt;
 +  lt;/diskgt;
 +  lt;disk type='file' device='cdrom'gt;
 +lt;driver name='file' type='raw'/gt;
 +lt;source file='/path/to/cdrom.iso'/gt;
 +lt;target dev='hdc' bus='sata'/gt;
 +lt;readonly/gt;
 +  lt;/diskgt;
 +  lt;interface type='bridge'gt;
 +lt;model type='virtio'/gt;
 +lt;source bridge=virbr0/gt;
 +  lt;/interfacegt;
 +lt;/devicesgt;
 +lt

Re: [libvirt] [PATCHv6 5/6] bhyve: Add console support for grub-bhyve bootloader

2014-10-30 Thread Conrad Meyer
On Thu, Oct 30, 2014 at 2:29 AM, Roman Bogorodskiy
bogorods...@gmail.com wrote:
   Conrad Meyer wrote:

 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.

 I'm still feeling doubtful about this part. I see the impact of this
 change in the following way.

  * Users, who wish to use console with grub-bhyve:
- They still cannot use 'virsh console' for that and need to use 'cu'
  or something like that
- They need to update to a specific grub-bhyve version (currently
  unreleased). The information about required version is not very
  easy to find, so the chance is high that most users will miss it

  * Users, who doesn't need to use console with grub-bhyve:
- They will still need to update to the specific grub-bhyve version,
  otherwise a domain with bhyve-grub bootloader will fail with not
  very obvious from user's POV error because of the unknown argument
  to grub-bhyve

 If we leave the thing as is, e.g. only have bootloader support, then we
 will have:

  * Users, who with to use console with grub-bhyve:
- Have to construct bootloader_args manually to add the --cons-dev
argument
- Like in a case with an explicit support, cannot use 'virsh console'
  for the bootloader step
- Obviously, need to update grub-bhyve

  * users, who doesn't need to use console with grub-bhyve
- Nothing changes for them, they can use an older grub-bhyve without
  issues

 Roman Bogorodskiy

Hi,

I will improve patch 5 to at least do detection and resubmit 5-6. In
the mean time, patches 1-4 do not depend on 5-6 and can stand on their
own. I believe critiques brought up in earlier reviews have been
addressed.

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


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

2014-10-30 Thread Conrad Meyer
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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv7 3/7] domaincommon.rng: Add 'bootloader' to os=hvm schema for Bhyve

2014-10-30 Thread Conrad Meyer
Additionally, make the bootloader tag optional (for bhyveload with
custom arguments) (also, matches the actual parser).
---
 docs/schemas/domaincommon.rng | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 20d81ae..87ba888 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -234,6 +234,9 @@
 /choice
   /define
   define name=oshvm
+optional
+  ref name=bootloader/
+/optional
 element name=os
   ref name=ostypehvm/
   interleave
@@ -1054,12 +1057,14 @@
 --
   define name=bootloader
 interleave
-  element name=bootloader
-choice
-  ref name=absFilePath/
-  empty/
-/choice
-  /element
+  optional
+element name=bootloader
+  choice
+ref name=absFilePath/
+empty/
+  /choice
+/element
+  /optional
   optional
 element name=bootloader_args
   text/
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv7 5/7] bhyve: Probe grub-bhyve for --cons-dev capability

2014-10-30 Thread Conrad Meyer
---
 src/bhyve/bhyve_capabilities.c | 37 +
 src/bhyve/bhyve_capabilities.h |  3 +++
 2 files changed, 40 insertions(+)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 132ce91..6e9a943 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -23,6 +23,7 @@
 #include sys/utsname.h
 
 #include viralloc.h
+#include virfile.h
 #include virlog.h
 #include virstring.h
 #include cpu/cpu.h
@@ -104,3 +105,39 @@ virBhyveCapsBuild(void)
 virObjectUnref(caps);
 return NULL;
 }
+
+int
+virBhyveProbeGrubCaps(unsigned *caps)
+{
+char *binary, *help;
+virCommandPtr cmd;
+int ret, exit;
+
+ret = 0;
+*caps = 0;
+cmd = NULL;
+help = NULL;
+
+binary = virFindFileInPath(grub-bhyve);
+if (binary == NULL)
+goto out;
+if (!virFileIsExecutable(binary))
+goto out;
+
+cmd = virCommandNew(binary);
+virCommandAddArg(cmd, --help);
+virCommandSetOutputBuffer(cmd, help);
+if (virCommandRun(cmd, exit)  0) {
+ret = -1;
+goto out;
+}
+
+if (strstr(help, --cons-dev) != NULL)
+*caps |= BHYVE_GRUB_CAP_CONSDEV;
+
+ out:
+VIR_FREE(help);
+virCommandFree(cmd);
+VIR_FREE(binary);
+return ret;
+}
diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h
index c52e0d0..f4ebd90 100644
--- a/src/bhyve/bhyve_capabilities.h
+++ b/src/bhyve/bhyve_capabilities.h
@@ -26,4 +26,7 @@
 
 virCapsPtr virBhyveCapsBuild(void);
 
+# define BHYVE_GRUB_CAP_CONSDEV 0x0001
+int virBhyveProbeGrubCaps(unsigned *caps);
+
 #endif
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv7 1/7] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-30 Thread Conrad Meyer
We still default to bhyveloader(1) if no explicit bootloader
configuration is supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk (or a CD if one exists,
under the assumption that for a VM a CD is likely an install source).

Caveat: Assumes the HDD boots from the msdos1 partition. I think this is
a pretty reasonable assumption for a VM. (DrvBhyve with Bhyveload
already assumes that the first disk should be booted.)

I've tested both HDD and CD boot and they seem to work.
---
 docs/drvbhyve.html.in | 100 +--
 docs/formatdomain.html.in |   4 +-
 src/bhyve/bhyve_command.c | 173 +-
 src/bhyve/bhyve_command.h |   5 +-
 src/bhyve/bhyve_driver.c  |   3 +-
 src/bhyve/bhyve_process.c |  38 +-
 6 files changed, 295 insertions(+), 28 deletions(-)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 39afdf5..bd4b35e 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
tunnelled)
 h3Example config/h3
 p
 The bhyve driver in libvirt is in its early stage and under active 
development. So it supports
-only limited number of features bhyve provides. All the supported features 
could be found
-in this sample domain XML.
+only limited number of features bhyve provides.
 /p
 
 p
@@ -48,10 +47,21 @@ disk device were supported per-domain. However,
 up to 31 PCI devices.
 /p
 
+p
+Note: the Bhyve driver in libvirt will boot whichever device is first. If you
+want to install from CD, put the CD device first. If not, put the root HDD
+first.
+/p
+
+p
+Note: Only the SATA bus is supported. Only codecdrom/code- and
+codedisk/code-type disks are supported.
+/p
+
 pre
 lt;domain type='bhyve'gt;
-  lt;namegt;bhyvelt;/namegt;
-  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;namegt;bhyvelt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 lt;memorygt;219136lt;/memorygt;
 lt;currentMemorygt;219136lt;/currentMemorygt;
 lt;vcpugt;1lt;/vcpugt;
@@ -76,6 +86,7 @@ up to 31 PCI devices.
 lt;driver name='file' type='raw'/gt;
 lt;source file='/path/to/cdrom.iso'/gt;
 lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
   lt;/diskgt;
   lt;interface type='bridge'gt;
 lt;model type='virtio'/gt;
@@ -85,6 +96,53 @@ up to 31 PCI devices.
 lt;/domaingt;
 /pre
 
+p(The lt;diskgt; sections may be swapped in order to install from
+emcdrom.iso/em.)/p
+
+h3Example config (Linux guest)/h3
+
+p
+Note the addition of lt;bootloadergt;.
+/p
+
+pre
+lt;domain type='bhyve'gt;
+lt;namegt;linux_guestlt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;memorygt;131072lt;/memorygt;
+lt;currentMemorygt;131072lt;/currentMemorygt;
+lt;vcpugt;1lt;/vcpugt;
+lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
+lt;osgt;
+   lt;typegt;hvmlt;/typegt;
+lt;/osgt;
+lt;featuresgt;
+  lt;apic/gt;
+  lt;acpi/gt;
+lt;/featuresgt;
+lt;clock offset='utc'/gt;
+lt;on_poweroffgt;destroylt;/on_poweroffgt;
+lt;on_rebootgt;restartlt;/on_rebootgt;
+lt;on_crashgt;destroylt;/on_crashgt;
+lt;devicesgt;
+  lt;disk type='file' device='disk'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/guest_hdd.img'/gt;
+lt;target dev='hda' bus='sata'/gt;
+  lt;/diskgt;
+  lt;disk type='file' device='cdrom'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/cdrom.iso'/gt;
+lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
+  lt;/diskgt;
+  lt;interface type='bridge'gt;
+lt;model type='virtio'/gt;
+lt;source bridge=virbr0/gt;
+  lt;/interfacegt;
+lt;/devicesgt;
+lt;/domaingt;
+/pre
 
 h2a name=usageGuest usage / management/a/h2
 
@@ -119,6 +177,20 @@ to let a guest boot or start a guest using:/p
 
 prestart --console domname/pre
 
+pbNB:/b An bootloader configured to require user interaction will prevent
+the domain from starting (and thus codevirsh console/code or codestart
+--console/code from functioning) until the user interacts with it manually on
+the VM host. Because users typically do not have access to the VM host,
+interactive bootloaders are unsupported by libvirt. emHowever,/em if you 
happen to
+run into this scenario and also happen to have access to the Bhyve host
+machine, you may select a boot option and allow the domain to finish starting
+by using an alternative terminal client on the VM host to connect to the
+domain-configured null modem device. One example (assuming
+code/dev/nmdm0B/code is configured as the slave end of the domain serial
+device) is:/p
+
+precu -l /dev/nmdm0B/pre
+
 h3a name=xmltonativeConverting from domain 

[libvirt] [PATCHv7 0/7] Add non-FreeBSD guest support to Bhyve driver.

2014-10-30 Thread Conrad Meyer
Drvbhyve hardcodes bhyveload(8) as the host bootloader for guests.
bhyveload(8) loader only supports FreeBSD guests.

This patch series adds bootloader and bootloader_args handling to
bhyve_command, so libvirt can boot non-FreeBSD guests in Bhyve.

Additionally, support for grub-bhyve(1)'s --cons-dev argument is added so that
interactive GRUB menus can be manipulated with the domain-configured serial
device.

See patch logs for further details.

Thanks,
Conrad

Changes in v7:
  - Detect grub-bhyve support for --cons-dev automatically; only pass the
domain-configured serial device if supported.
  - Add '-nocons' version of the grub-serial unit tests to confirm we construct
the loader Cmd correctly if the capability is missing.


Conrad Meyer (7):
  bhyve: Support /domain/bootloader configuration for non-FreeBSD
guests.
  bhyvexml2argv: Add loader argv tests.
  domaincommon.rng: Add 'bootloader' to os=hvm schema for Bhyve
  bhyvexml2argv: Add tests for domain-configured bootloader, args
  bhyve: Probe grub-bhyve for --cons-dev capability
  bhyve: Add console support for grub-bhyve bootloader
  bhyvexml2argv: Add test for grub console support

 docs/drvbhyve.html.in  | 100 ++-
 docs/formatdomain.html.in  |   4 +-
 docs/schemas/domaincommon.rng  |  17 +-
 src/bhyve/bhyve_capabilities.c |  37 
 src/bhyve/bhyve_capabilities.h |   3 +
 src/bhyve/bhyve_command.c  | 189 +++--
 src/bhyve/bhyve_command.h  |   5 +-
 src/bhyve/bhyve_driver.c   |  16 +-
 src/bhyve/bhyve_driver.h   |   2 +
 src/bhyve/bhyve_process.c  |  38 -
 src/bhyve/bhyve_utils.h|   2 +
 .../bhyvexml2argv-acpiapic.ldargs  |   1 +
 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs  |   1 +
 .../bhyvexml2argv-bhyveload-explicitargs.args  |   3 +
 .../bhyvexml2argv-bhyveload-explicitargs.ldargs|   1 +
 .../bhyvexml2argv-bhyveload-explicitargs.xml   |  23 +++
 .../bhyvexml2argvdata/bhyvexml2argv-console.ldargs |   1 +
 .../bhyvexml2argv-custom-loader.args   |   3 +
 .../bhyvexml2argv-custom-loader.ldargs |   1 +
 .../bhyvexml2argv-custom-loader.xml|  24 +++
 .../bhyvexml2argv-disk-cdrom-grub.args |   3 +
 .../bhyvexml2argv-disk-cdrom-grub.devmap   |   1 +
 .../bhyvexml2argv-disk-cdrom-grub.ldargs   |   2 +
 .../bhyvexml2argv-disk-cdrom-grub.xml  |  23 +++
 .../bhyvexml2argv-disk-cdrom.ldargs|   1 +
 .../bhyvexml2argv-disk-virtio.ldargs   |   1 +
 .../bhyvexml2argv-grub-defaults.args   |   3 +
 .../bhyvexml2argv-grub-defaults.devmap |   1 +
 .../bhyvexml2argv-grub-defaults.ldargs |   2 +
 .../bhyvexml2argv-grub-defaults.xml|  23 +++
 .../bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs |   1 +
 .../bhyvexml2argv-serial-grub-nocons.args  |   4 +
 .../bhyvexml2argv-serial-grub-nocons.devmap|   1 +
 .../bhyvexml2argv-serial-grub-nocons.ldargs|   2 +
 .../bhyvexml2argv-serial-grub-nocons.xml   |  26 +++
 .../bhyvexml2argv-serial-grub.args |   4 +
 .../bhyvexml2argv-serial-grub.devmap   |   1 +
 .../bhyvexml2argv-serial-grub.ldargs   |   2 +
 .../bhyvexml2argv-serial-grub.xml  |  26 +++
 .../bhyvexml2argvdata/bhyvexml2argv-serial.ldargs  |   1 +
 tests/bhyvexml2argvtest.c  |  71 +++-
 41 files changed, 631 insertions(+), 39 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub

[libvirt] [PATCHv7 4/7] bhyvexml2argv: Add tests for domain-configured bootloader, args

2014-10-30 Thread Conrad Meyer
---
 .../bhyvexml2argv-bhyveload-explicitargs.args  |  3 +++
 .../bhyvexml2argv-bhyveload-explicitargs.ldargs|  1 +
 .../bhyvexml2argv-bhyveload-explicitargs.xml   | 23 +
 .../bhyvexml2argv-custom-loader.args   |  3 +++
 .../bhyvexml2argv-custom-loader.ldargs |  1 +
 .../bhyvexml2argv-custom-loader.xml| 24 ++
 .../bhyvexml2argv-disk-cdrom-grub.args |  3 +++
 .../bhyvexml2argv-disk-cdrom-grub.devmap   |  1 +
 .../bhyvexml2argv-disk-cdrom-grub.ldargs   |  2 ++
 .../bhyvexml2argv-disk-cdrom-grub.xml  | 23 +
 .../bhyvexml2argv-grub-defaults.args   |  3 +++
 .../bhyvexml2argv-grub-defaults.devmap |  1 +
 .../bhyvexml2argv-grub-defaults.ldargs |  2 ++
 .../bhyvexml2argv-grub-defaults.xml| 23 +
 tests/bhyvexml2argvtest.c  |  4 
 15 files changed, 117 insertions(+)
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.xml

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
new file mode 100644
index 000..4122e62
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
@@ -0,0 +1,3 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
diff --git 
a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
new file mode 100644
index 000..a3f58f0
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -X -Y -Z
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
new file mode 100644
index 000..65823cd
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
@@ -0,0 +1,23 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader_args-X -Y -Z/bootloader_args
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img'/
+  target dev='hda' bus='sata'/
+  address type='pci' domain='0x' bus='0x00' slot='0x02' 
function='0x0'/
+/disk
+interface type='bridge'
+  model type='virtio'/
+  source bridge=virbr0/
+  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/
+/interface
+  /devices
+/domain
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
new file mode 100644
index 000..4122e62
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
@@ -0,0 +1,3 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
new file mode 100644
index 000..100e163
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
@@ -0,0 +1 @@
+/fizz_buzz_bazz -X -Y -Z
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
new file mode 100644
index 000..e9e0d5e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
@@ -0,0 +1,24 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/fizz_buzz_bazz/bootloader
+  

[libvirt] [PATCHv7 2/7] bhyvexml2argv: Add loader argv tests.

2014-10-30 Thread Conrad Meyer
---
 .../bhyvexml2argv-acpiapic.ldargs  |  1 +
 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs  |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-console.ldargs |  1 +
 .../bhyvexml2argv-disk-cdrom.ldargs|  1 +
 .../bhyvexml2argv-disk-virtio.ldargs   |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-serial.ldargs  |  1 +
 tests/bhyvexml2argvtest.c  | 60 +++---
 8 files changed, 61 insertions(+), 6 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
new file mode 100644
index 000..0eb3cc9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/cdrom.iso bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index b9be378..3ff6696 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -15,14 +15,16 @@
 static bhyveConn driver;
 
 static int testCompareXMLToArgvFiles(const char *xml,
- const char *cmdline)
+ const char *cmdline,
+ const char *ldcmdline,
+ const char *dmcmdline)
 {
-char *expectargv = NULL;
+char *expectargv = NULL, *expectld = NULL, *expectdm = NULL;
 int len;
-char *actualargv = NULL;
+char *actualargv = NULL, *actualld = NULL, *actualdm = NULL;
 virDomainDefPtr vmdef = NULL;
 virDomainObj vm;
-virCommandPtr cmd = NULL;
+virCommandPtr cmd = NULL, ldcmd = NULL;
 virConnectPtr conn;
 int ret = -1;
 
@@ -42,6 +44,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
 if (!(actualargv = virCommandToString(cmd)))
 goto out;
 
+if (!(ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, device.map,
+  actualdm)))
+goto out;
+
+if (actualdm != NULL)
+virTrimSpaces(actualdm, NULL);
+
+if (!(actualld = virCommandToString(ldcmd)))
+goto out;
+
 len = virtTestLoadFile(cmdline, expectargv);
 if (len  0)
 goto out;
@@ -49,17 +61,49 @@ static int testCompareXMLToArgvFiles(const char *xml,
 if (len  expectargv[len - 1] == '\n')
 expectargv[len - 1] = '\0';
 
+len = virtTestLoadFile(ldcmdline, expectld);
+if (len  0)
+goto out;
+
+if (len  expectld[len - 1] == '\n')
+expectld[len - 1] = '\0';
+
+len = 

[libvirt] [PATCHv7 7/7] bhyvexml2argv: Add test for grub console support

2014-10-30 Thread Conrad Meyer
---
 .../bhyvexml2argv-serial-grub-nocons.args  |  4 
 .../bhyvexml2argv-serial-grub-nocons.devmap|  1 +
 .../bhyvexml2argv-serial-grub-nocons.ldargs|  2 ++
 .../bhyvexml2argv-serial-grub-nocons.xml   | 26 ++
 .../bhyvexml2argv-serial-grub.args |  4 
 .../bhyvexml2argv-serial-grub.devmap   |  1 +
 .../bhyvexml2argv-serial-grub.ldargs   |  2 ++
 .../bhyvexml2argv-serial-grub.xml  | 26 ++
 tests/bhyvexml2argvtest.c  |  7 ++
 9 files changed, 73 insertions(+)
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.devmap
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args
new file mode 100644
index 000..df50290
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args
@@ -0,0 +1,4 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img \
+-s 1,lpc -l com1,/dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.devmap 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.devmap
new file mode 100644
index 000..68c35da
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.devmap
@@ -0,0 +1 @@
+(hd0) /tmp/freebsd.img
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.ldargs
new file mode 100644
index 000..91c15ce
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.ldargs
@@ -0,0 +1,2 @@
+/usr/local/sbin/grub-bhyve --root hd0,msdos1 --device-map 'device.map' \
+--memory 214 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.xml
new file mode 100644
index 000..8c451f7
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.xml
@@ -0,0 +1,26 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/usr/local/sbin/grub-bhyve/bootloader
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img'/
+  target dev='hda' bus='sata'/
+  address type='pci' domain='0x' bus='0x00' slot='0x02' 
function='0x0'/
+/disk
+interface type='bridge'
+  model type='virtio'/
+  source bridge=virbr0/
+  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/
+/interface
+serial type='nmdm'
+  source master='/dev/nmdm0A' slave='/dev/nmdm0B'/
+/serial
+  /devices
+/domain
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
new file mode 100644
index 000..df50290
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
@@ -0,0 +1,4 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img \
+-s 1,lpc -l com1,/dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
new file mode 100644
index 000..68c35da
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
@@ -0,0 +1 @@
+(hd0) /tmp/freebsd.img
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
new file mode 100644
index 000..5645097
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
@@ -0,0 +1,2 @@
+/usr/local/sbin/grub-bhyve --root hd0,msdos1 --device-map 'device.map' \
+--memory 214 --cons-dev /dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
new file mode 100644
index 000..8c451f7
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
@@ -0,0 +1,26 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/usr/local/sbin/grub-bhyve/bootloader
+  os
+  

[libvirt] [PATCH v6 0/6] Add non-FreeBSD guest support to Bhyve driver.

2014-10-29 Thread Conrad Meyer
Drvbhyve hardcodes bhyveload(8) as the host bootloader for guests.
bhyveload(8) loader only supports FreeBSD guests.

This patch series adds bootloader and bootloader_args handling to
bhyve_command, so libvirt can boot non-FreeBSD guests in Bhyve.

Additionally, support for grub-bhyve(1)'s --cons-dev argument is added so that
interactive GRUB menus can be manipulated with the domain-configured serial
device.

See patch logs for further details.

Thanks,
Conrad

Changes in v6:
  - Simplified domain schema changes; just add bootloader section to HVM-type
OS, and make the bootloader tag optional.
  - Update drvbhyve.html.in copy to explicitly state that interactive
bootloaders are unsupported.
  - Move GRUB device.map file creation out of BuildLoadCmd; instead emit
device.map as a string.
  - Add devicemap contents tests to bhyvexml2argv.

Conrad Meyer (6):
  bhyve: Support /domain/bootloader configuration for non-FreeBSD
guests.
  bhyvexml2argv: Add loader argv tests.
  domaincommon.rng: Add 'bootloader' to os=hvm schema for Bhyve
  bhyvexml2argv: Add tests for domain-configured bootloader, args
  bhyve: Add console support for grub-bhyve bootloader
  bhyvexml2argv: Add test for grub console support

 docs/drvbhyve.html.in  | 100 ++-
 docs/formatdomain.html.in  |   4 +-
 docs/schemas/domaincommon.rng  |  17 +-
 src/bhyve/bhyve_command.c  | 186 +++--
 src/bhyve/bhyve_command.h  |   5 +-
 src/bhyve/bhyve_driver.c   |   3 +-
 src/bhyve/bhyve_process.c  |  38 -
 .../bhyvexml2argv-acpiapic.ldargs  |   1 +
 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs  |   1 +
 .../bhyvexml2argv-bhyveload-explicitargs.args  |   3 +
 .../bhyvexml2argv-bhyveload-explicitargs.ldargs|   1 +
 .../bhyvexml2argv-bhyveload-explicitargs.xml   |  23 +++
 .../bhyvexml2argvdata/bhyvexml2argv-console.ldargs |   1 +
 .../bhyvexml2argv-custom-loader.args   |   3 +
 .../bhyvexml2argv-custom-loader.ldargs |   1 +
 .../bhyvexml2argv-custom-loader.xml|  24 +++
 .../bhyvexml2argv-disk-cdrom-grub.args |   3 +
 .../bhyvexml2argv-disk-cdrom-grub.devmap   |   1 +
 .../bhyvexml2argv-disk-cdrom-grub.ldargs   |   2 +
 .../bhyvexml2argv-disk-cdrom-grub.xml  |  23 +++
 .../bhyvexml2argv-disk-cdrom.ldargs|   1 +
 .../bhyvexml2argv-disk-virtio.ldargs   |   1 +
 .../bhyvexml2argv-grub-defaults.args   |   3 +
 .../bhyvexml2argv-grub-defaults.devmap |   1 +
 .../bhyvexml2argv-grub-defaults.ldargs |   2 +
 .../bhyvexml2argv-grub-defaults.xml|  23 +++
 .../bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs |   1 +
 .../bhyvexml2argv-serial-grub.args |   4 +
 .../bhyvexml2argv-serial-grub.devmap   |   1 +
 .../bhyvexml2argv-serial-grub.ldargs   |   2 +
 .../bhyvexml2argv-serial-grub.xml  |  26 +++
 .../bhyvexml2argvdata/bhyvexml2argv-serial.ldargs  |   1 +
 tests/bhyvexml2argvtest.c  |  65 ++-
 33 files changed, 532 insertions(+), 39 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
 create mode 100644 tests

[libvirt] [PATCHv6 5/6] bhyve: Add console support for grub-bhyve bootloader

2014-10-29 Thread Conrad Meyer
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 | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 203495c..12eaf71 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -447,6 +447,21 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
 virCommandAddArgFormat(cmd, %llu,
VIR_DIV_UP(def-mem.max_balloon, 1024));
 
+if (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);
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv6 2/6] bhyvexml2argv: Add loader argv tests.

2014-10-29 Thread Conrad Meyer
---
 .../bhyvexml2argv-acpiapic.ldargs  |  1 +
 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs  |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-console.ldargs |  1 +
 .../bhyvexml2argv-disk-cdrom.ldargs|  1 +
 .../bhyvexml2argv-disk-virtio.ldargs   |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-serial.ldargs  |  1 +
 tests/bhyvexml2argvtest.c  | 60 +++---
 8 files changed, 61 insertions(+), 6 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
new file mode 100644
index 000..0eb3cc9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/cdrom.iso bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index b9be378..3ff6696 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -15,14 +15,16 @@
 static bhyveConn driver;
 
 static int testCompareXMLToArgvFiles(const char *xml,
- const char *cmdline)
+ const char *cmdline,
+ const char *ldcmdline,
+ const char *dmcmdline)
 {
-char *expectargv = NULL;
+char *expectargv = NULL, *expectld = NULL, *expectdm = NULL;
 int len;
-char *actualargv = NULL;
+char *actualargv = NULL, *actualld = NULL, *actualdm = NULL;
 virDomainDefPtr vmdef = NULL;
 virDomainObj vm;
-virCommandPtr cmd = NULL;
+virCommandPtr cmd = NULL, ldcmd = NULL;
 virConnectPtr conn;
 int ret = -1;
 
@@ -42,6 +44,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
 if (!(actualargv = virCommandToString(cmd)))
 goto out;
 
+if (!(ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, device.map,
+  actualdm)))
+goto out;
+
+if (actualdm != NULL)
+virTrimSpaces(actualdm, NULL);
+
+if (!(actualld = virCommandToString(ldcmd)))
+goto out;
+
 len = virtTestLoadFile(cmdline, expectargv);
 if (len  0)
 goto out;
@@ -49,17 +61,49 @@ static int testCompareXMLToArgvFiles(const char *xml,
 if (len  expectargv[len - 1] == '\n')
 expectargv[len - 1] = '\0';
 
+len = virtTestLoadFile(ldcmdline, expectld);
+if (len  0)
+goto out;
+
+if (len  expectld[len - 1] == '\n')
+expectld[len - 1] = '\0';
+
+len = 

[libvirt] [PATCHv6 6/6] bhyvexml2argv: Add test for grub console support

2014-10-29 Thread Conrad Meyer
---
 .../bhyvexml2argv-serial-grub.args |  4 
 .../bhyvexml2argv-serial-grub.devmap   |  1 +
 .../bhyvexml2argv-serial-grub.ldargs   |  2 ++
 .../bhyvexml2argv-serial-grub.xml  | 26 ++
 tests/bhyvexml2argvtest.c  |  1 +
 5 files changed, 34 insertions(+)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
new file mode 100644
index 000..df50290
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
@@ -0,0 +1,4 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img \
+-s 1,lpc -l com1,/dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
new file mode 100644
index 000..68c35da
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.devmap
@@ -0,0 +1 @@
+(hd0) /tmp/freebsd.img
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
new file mode 100644
index 000..5645097
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
@@ -0,0 +1,2 @@
+/usr/local/sbin/grub-bhyve --root hd0,msdos1 --device-map 'device.map' \
+--memory 214 --cons-dev /dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
new file mode 100644
index 000..8c451f7
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
@@ -0,0 +1,26 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/usr/local/sbin/grub-bhyve/bootloader
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img'/
+  target dev='hda' bus='sata'/
+  address type='pci' domain='0x' bus='0x00' slot='0x02' 
function='0x0'/
+/disk
+interface type='bridge'
+  model type='virtio'/
+  source bridge=virbr0/
+  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/
+/interface
+serial type='nmdm'
+  source master='/dev/nmdm0A' slave='/dev/nmdm0B'/
+/serial
+  /devices
+/domain
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 64e6c0d..ffb10f1 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -164,6 +164,7 @@ mymain(void)
 DO_TEST(bhyveload-explicitargs);
 DO_TEST(custom-loader);
 DO_TEST(disk-cdrom-grub);
+DO_TEST(serial-grub);
 
 virObjectUnref(driver.caps);
 virObjectUnref(driver.xmlopt);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv6 1/6] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-29 Thread Conrad Meyer
We still default to bhyveloader(1) if no explicit bootloader
configuration is supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk (or a CD if one exists,
under the assumption that for a VM a CD is likely an install source).

Caveat: Assumes the HDD boots from the msdos1 partition. I think this is
a pretty reasonable assumption for a VM. (DrvBhyve with Bhyveload
already assumes that the first disk should be booted.)

I've tested both HDD and CD boot and they seem to work.
---
 docs/drvbhyve.html.in | 100 +--
 docs/formatdomain.html.in |   4 +-
 src/bhyve/bhyve_command.c | 173 +-
 src/bhyve/bhyve_command.h |   5 +-
 src/bhyve/bhyve_driver.c  |   3 +-
 src/bhyve/bhyve_process.c |  38 +-
 6 files changed, 295 insertions(+), 28 deletions(-)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 39afdf5..bd4b35e 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
tunnelled)
 h3Example config/h3
 p
 The bhyve driver in libvirt is in its early stage and under active 
development. So it supports
-only limited number of features bhyve provides. All the supported features 
could be found
-in this sample domain XML.
+only limited number of features bhyve provides.
 /p
 
 p
@@ -48,10 +47,21 @@ disk device were supported per-domain. However,
 up to 31 PCI devices.
 /p
 
+p
+Note: the Bhyve driver in libvirt will boot whichever device is first. If you
+want to install from CD, put the CD device first. If not, put the root HDD
+first.
+/p
+
+p
+Note: Only the SATA bus is supported. Only codecdrom/code- and
+codedisk/code-type disks are supported.
+/p
+
 pre
 lt;domain type='bhyve'gt;
-  lt;namegt;bhyvelt;/namegt;
-  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;namegt;bhyvelt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 lt;memorygt;219136lt;/memorygt;
 lt;currentMemorygt;219136lt;/currentMemorygt;
 lt;vcpugt;1lt;/vcpugt;
@@ -76,6 +86,7 @@ up to 31 PCI devices.
 lt;driver name='file' type='raw'/gt;
 lt;source file='/path/to/cdrom.iso'/gt;
 lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
   lt;/diskgt;
   lt;interface type='bridge'gt;
 lt;model type='virtio'/gt;
@@ -85,6 +96,53 @@ up to 31 PCI devices.
 lt;/domaingt;
 /pre
 
+p(The lt;diskgt; sections may be swapped in order to install from
+emcdrom.iso/em.)/p
+
+h3Example config (Linux guest)/h3
+
+p
+Note the addition of lt;bootloadergt;.
+/p
+
+pre
+lt;domain type='bhyve'gt;
+lt;namegt;linux_guestlt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;memorygt;131072lt;/memorygt;
+lt;currentMemorygt;131072lt;/currentMemorygt;
+lt;vcpugt;1lt;/vcpugt;
+lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
+lt;osgt;
+   lt;typegt;hvmlt;/typegt;
+lt;/osgt;
+lt;featuresgt;
+  lt;apic/gt;
+  lt;acpi/gt;
+lt;/featuresgt;
+lt;clock offset='utc'/gt;
+lt;on_poweroffgt;destroylt;/on_poweroffgt;
+lt;on_rebootgt;restartlt;/on_rebootgt;
+lt;on_crashgt;destroylt;/on_crashgt;
+lt;devicesgt;
+  lt;disk type='file' device='disk'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/guest_hdd.img'/gt;
+lt;target dev='hda' bus='sata'/gt;
+  lt;/diskgt;
+  lt;disk type='file' device='cdrom'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/cdrom.iso'/gt;
+lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
+  lt;/diskgt;
+  lt;interface type='bridge'gt;
+lt;model type='virtio'/gt;
+lt;source bridge=virbr0/gt;
+  lt;/interfacegt;
+lt;/devicesgt;
+lt;/domaingt;
+/pre
 
 h2a name=usageGuest usage / management/a/h2
 
@@ -119,6 +177,20 @@ to let a guest boot or start a guest using:/p
 
 prestart --console domname/pre
 
+pbNB:/b An bootloader configured to require user interaction will prevent
+the domain from starting (and thus codevirsh console/code or codestart
+--console/code from functioning) until the user interacts with it manually on
+the VM host. Because users typically do not have access to the VM host,
+interactive bootloaders are unsupported by libvirt. emHowever,/em if you 
happen to
+run into this scenario and also happen to have access to the Bhyve host
+machine, you may select a boot option and allow the domain to finish starting
+by using an alternative terminal client on the VM host to connect to the
+domain-configured null modem device. One example (assuming
+code/dev/nmdm0B/code is configured as the slave end of the domain serial
+device) is:/p
+
+precu -l /dev/nmdm0B/pre
+
 h3a name=xmltonativeConverting from domain 

[libvirt] [PATCHv6 4/6] bhyvexml2argv: Add tests for domain-configured bootloader, args

2014-10-29 Thread Conrad Meyer
---
 .../bhyvexml2argv-bhyveload-explicitargs.args  |  3 +++
 .../bhyvexml2argv-bhyveload-explicitargs.ldargs|  1 +
 .../bhyvexml2argv-bhyveload-explicitargs.xml   | 23 +
 .../bhyvexml2argv-custom-loader.args   |  3 +++
 .../bhyvexml2argv-custom-loader.ldargs |  1 +
 .../bhyvexml2argv-custom-loader.xml| 24 ++
 .../bhyvexml2argv-disk-cdrom-grub.args |  3 +++
 .../bhyvexml2argv-disk-cdrom-grub.devmap   |  1 +
 .../bhyvexml2argv-disk-cdrom-grub.ldargs   |  2 ++
 .../bhyvexml2argv-disk-cdrom-grub.xml  | 23 +
 .../bhyvexml2argv-grub-defaults.args   |  3 +++
 .../bhyvexml2argv-grub-defaults.devmap |  1 +
 .../bhyvexml2argv-grub-defaults.ldargs |  2 ++
 .../bhyvexml2argv-grub-defaults.xml| 23 +
 tests/bhyvexml2argvtest.c  |  4 
 15 files changed, 117 insertions(+)
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.devmap
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.xml

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
new file mode 100644
index 000..4122e62
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
@@ -0,0 +1,3 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
diff --git 
a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
new file mode 100644
index 000..a3f58f0
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -X -Y -Z
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
new file mode 100644
index 000..65823cd
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
@@ -0,0 +1,23 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader_args-X -Y -Z/bootloader_args
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img'/
+  target dev='hda' bus='sata'/
+  address type='pci' domain='0x' bus='0x00' slot='0x02' 
function='0x0'/
+/disk
+interface type='bridge'
+  model type='virtio'/
+  source bridge=virbr0/
+  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/
+/interface
+  /devices
+/domain
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
new file mode 100644
index 000..4122e62
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
@@ -0,0 +1,3 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
new file mode 100644
index 000..100e163
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
@@ -0,0 +1 @@
+/fizz_buzz_bazz -X -Y -Z
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
new file mode 100644
index 000..e9e0d5e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
@@ -0,0 +1,24 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/fizz_buzz_bazz/bootloader
+  

[libvirt] [PATCHv6 3/6] domaincommon.rng: Add 'bootloader' to os=hvm schema for Bhyve

2014-10-29 Thread Conrad Meyer
Additionally, make the bootloader tag optional (for bhyveload with
custom arguments) (also, matches the actual parser).
---
 docs/schemas/domaincommon.rng | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 20d81ae..87ba888 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -234,6 +234,9 @@
 /choice
   /define
   define name=oshvm
+optional
+  ref name=bootloader/
+/optional
 element name=os
   ref name=ostypehvm/
   interleave
@@ -1054,12 +1057,14 @@
 --
   define name=bootloader
 interleave
-  element name=bootloader
-choice
-  ref name=absFilePath/
-  empty/
-/choice
-  /element
+  optional
+element name=bootloader
+  choice
+ref name=absFilePath/
+empty/
+  /choice
+/element
+  /optional
   optional
 element name=bootloader_args
   text/
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Entering freeze and release of cadidate release 1 of 1.2.10

2014-10-29 Thread Conrad Meyer
Hi all,

The recent commit with SHA1 cc0e8c244d080f56392278e836cc378ba848e7aa,
util: Functions to update host network device's multicast filter,
breaks the build on FreeBSD, so please address this before 1.2.10
release.

Here is the output from Clang:

  CC   util/libvirt_util_la-virnetdev.lo
util/virnetdev.c:1995:9: error: no member named 'ifr_hwaddr' in 'struct ifreq'
ifr.ifr_hwaddr.sa_family = AF_UNSPEC;
~~~ ^
util/virnetdev.c:1996:52: error: no member named 'ifr_hwaddr' in 'struct ifreq'
virMacAddrGetRaw(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data);
   ~~~ ^
util/virnetdev.c:2043:9: error: no member named 'ifr_hwaddr' in 'struct ifreq'
ifr.ifr_hwaddr.sa_family = AF_UNSPEC;
~~~ ^
util/virnetdev.c:2044:52: error: no member named 'ifr_hwaddr' in 'struct ifreq'
virMacAddrGetRaw(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data);
   ~~~ ^
4 errors generated.

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv5 5/6] bhyve: Add console support for grub-bhyve bootloader

2014-10-28 Thread Conrad Meyer
On Tue, Oct 28, 2014 at 7:53 AM, Roman Bogorodskiy
bogorods...@gmail.com wrote:
   Conrad Meyer wrote:

 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.

 Could you please elaborate on that?

Sure.

 It's not the obvious what's the
 limitation...

The limitation is in virBhyveProcessStart and bhyveload / bhyve
itself. The problem is that we cannot start bhyve until the loader has
exited. So in BhyveProcessStart, we run the loader synchronously, then
run bhyve asynchronously when the loader completes. Finally when
BhyveProcessStart returns and sets the domain as started, 'virsh
console' and 'virsh start --console' connect and start working.

To allow 'virsh start --console', etc, I believe we'd have to start
bhyveload / GRUB asynchronously in BhyveProcessStart, mark the domain
as started, handle the asynchronous termination of bhyveload / GRUB,
start bhyve... it sounds very painful.

I suppose it would be a lot easier / cleaner if the bhyve binary
itself learned how to start the bootloader (even if we had to
explicitly give it the executable and arguments).

 Without being able to connect using virsh console, it's
 not very convenient for user to connect to the console (esp. if he runs
 virsh over a remote libvirt).

Agreed. It's not perfect, but is an incremental improvement. I think
probably most VMs should be configured to boot without getting stuck
in the bootloader.


 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.

 Sponsored by:  EMC / Isilon storage division

 Signed-off-by: Conrad Meyer conrad.me...@isilon.com
 ---
  src/bhyve/bhyve_command.c | 15 +++
  1 file changed, 15 insertions(+)

 diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
 index 01f1795..07d209e 100644
 --- a/src/bhyve/bhyve_command.c
 +++ b/src/bhyve/bhyve_command.c
 @@ -468,6 +468,21 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
  virCommandAddArgFormat(cmd, %llu,
 VIR_DIV_UP(def-mem.max_balloon, 1024));

 +if (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);

 IMHO, one more thing worth to do is probe if the supplied grub-bhyve has
 this '--cons-dev' argument (e.g. check if it's there in its --help
 output). Otherwise, for users running an older grub-bhyve will get a
 weird error that they will not know how to fix.

I think there are few enough bhyve-grub and libvirt users at this
point, and the experience is already broken enough, that we can just
document in release notes that libvirt-1.x.y Bhyve support needs
grub2-bhyve = 808fa4f1b1 and ensure packagers and porters know to get
the run-time dependency correct.

 Other option is to check required version of grub-bhyve using autotools,
 but I guess it's not good because users will have to rebuild libvirt if
 they want to update bhyve-grub.

Hm, why would they have to rebuild?

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv5 3/6] domaincommon.rng: Add bootloader, bootloader_arg to os=hvm schema for Bhyve

2014-10-28 Thread Conrad Meyer
On Tue, Oct 28, 2014 at 10:49 AM, Daniel P. Berrange
berra...@redhat.com wrote:
 I understand you created separate bhyvebootloader vs xenbootloader
 schema rules, so that the Xen case can keep bootloader as compulsory
 for use when bootloader_args is set, while for bhyve you allow
 bootloader_args without any corresponding bootloader.

 The actual XML parser meanwhile, always allows bootloader_args
 even when bootloader is not set. So I think you don't really
 need to have the complexity of making the schema provide different
 rules for xen vs bhyve.

 Lets just stay simple and keep a single define name=bootloader/element
 and make the bootloader optional to match what the parser actually
 does.

Sure, sounds reasonable to me. I'll fix it in the next submission.

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv5 1/6] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-28 Thread Conrad Meyer
On Tue, Oct 28, 2014 at 10:39 AM, Daniel P. Berrange
berra...@redhat.com wrote:
 On Mon, Oct 27, 2014 at 10:37:36AM -0400, Conrad Meyer wrote:
 +p
 +Note: the Bhyve driver in libvirt will boot whichever device is first. If 
 you
 +want to install from CD, put the CD device first. If not, put the root HDD
 +first.
 +/p

 FYI, the libvirt XML allows for a boot order='NNN'/  element to be
 included by the user in any disk, interface or hostdev element.

 This is considered to obsolete the boot dev=cdrom|disk|network/
 config we originally used, so that we can get fine grained control
 over device boot order, independant of XML format.

 Your patch is fine as it is, i just mention this as something you
 might consider adding support for in later work.

Right, that would be nice to fix eventually. libvirt's bhyve driver
doesn't support boot order at all yet (it just picks
'domdef-drives[0]'). Fixing that is orthogonal to adding grub-bhyve
as a loader option, IMO.

  h2a name=usageGuest usage / management/a/h2

 @@ -119,6 +177,14 @@ to let a guest boot or start a guest using:/p

  prestart --console domname/pre

 +pbNB:/b An interactive bootloader will keep the domain from starting 
 (and
 +thus codevirsh console/code or codestart --console/code) until the
 +console is opened by a client. To select a boot option and allow the domain 
 to
 +finish starting, one must use an alternative terminal client to connect to 
 the
 +null modem device. One example is:/p

 Can you clarify what you mean by this. It seems like this is saying that
 the 'virDomainCreate' API (virsh start GUEST command) will not return
 controll to the caller until you've interacted with the bootloader.

For GRUB configurations that do not automatically boot something
without user interaction, you are correct.

 If correct, I don't think this is a very satisfactory solution. There
 should not be any requirement to interact with the guest domain until
 after the virDomainCreate API call completes successfully. If succesfully
 booting requires that you go via an out-of-band channel to interact with
 the bootloader that's even more of a problem.

I agree, however — this is the status quo of libvirt-bhyve. This
patchset doesn't make it any worse than it already is.

 Because libvirt has an RPC based mechanism for API access, we need to
 always bear in mind that the application/user talking to libvirt drivers
 is either local but unprivileged, or even entirely remote from the hypervisor
 node. The libvirt built-in console tunnels over our RPC channel to provide
 apps access.

 So if my understanding is correct, this limitation you describe is going
 to prevent use of this kind of setup from most apps using libvirt.

I think most apps probably have automatic boot in their GRUB
configuration. But for anything that requires user input before GRUB
will load the OS, you are correct.

 We need to at least come up with a plan of how we'd address this problem
 in the medium term.

I think the medium- or long-term plan is to not require an external
bootloader at all, this is sort of an interim solution.

 +if (priv != NULL) {
 +rc = virAsprintf(priv-grub_devicesmap_file,
 + %s/grub_bhyve-%s-device.map, BHYVE_STATE_DIR,
 + def-name);
 +if (rc  0)
 +goto error;
 +
 +f = fopen(priv-grub_devicesmap_file, wb);
 +if (f == NULL) {
 +virReportSystemError(errno, _(Failed to open '%s'),
 + priv-grub_devicesmap_file);
 +goto error;
 +}
 +
 +/* Grub device.map (just for boot) */
 +if (disk != NULL)
 +fprintf(f, (hd0) %s\n, virDomainDiskGetSource(disk));
 +
 +if (cd != NULL)
 +fprintf(f, (cd) %s\n, virDomainDiskGetSource(cd));
 +
 +if (VIR_FCLOSE(f)  0) {
 +virReportSystemError(errno, %s, _(failed to close file));
 +goto error;
 +}

 As a general rule we prefer that the APIs for constructing command line
 args don't have side effects on system state, such as creating external
 files, because we want to be able to test all these code paths in the
 unit tests.

Definitely.

 The 'if (priv)' approach is somewhat fragile and means we don't get test
 coverage of the grub file format writing code.

 I think I'd suggest we need a way to just write the grub device.map
 to a 'char **' parameter we pass into this method, and bubble that
 all the wayy back to the top

 Then make the caller of virBhyveProcessBuildLoadCmd be responsible
 for writing it to disk, using virFileWriteStr. That way we can fully
 test the code in virBhyveProcessBuildLoadCmd without hitting the file
 writing path.

I have some reservations about this (additional complexity, not a lot
of value IMO), but it can be done if you want it.


 +}
 +
 +if (cd != NULL) {
 +VIR_WARN(Trying to boot cd with grub-bhyve. If this is 
 + not what you

Re: [libvirt] [PATCHv5 1/6] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-28 Thread Conrad Meyer
On Tue, Oct 28, 2014 at 11:01 AM, Roman Bogorodskiy
bogorods...@gmail.com wrote:
   Daniel P. Berrange wrote:
 On Mon, Oct 27, 2014 at 10:37:36AM -0400, Conrad Meyer wrote:
   prestart --console domname/pre
 
  +pbNB:/b An interactive bootloader will keep the domain from 
  starting (and
  +thus codevirsh console/code or codestart --console/code) until the
  +console is opened by a client. To select a boot option and allow the 
  domain to
  +finish starting, one must use an alternative terminal client to connect 
  to the
  +null modem device. One example is:/p

 Can you clarify what you mean by this. It seems like this is saying that
 the 'virDomainCreate' API (virsh start GUEST command) will not return
 controll to the caller until you've interacted with the bootloader.

 If correct, I don't think this is a very satisfactory solution. There
 should not be any requirement to interact with the guest domain until
 after the virDomainCreate API call completes successfully. If succesfully
 booting requires that you go via an out-of-band channel to interact with
 the bootloader that's even more of a problem.

 Because libvirt has an RPC based mechanism for API access, we need to
 always bear in mind that the application/user talking to libvirt drivers
 is either local but unprivileged, or even entirely remote from the hypervisor
 node. The libvirt built-in console tunnels over our RPC channel to provide
 apps access.

 So if my understanding is correct, this limitation you describe is going
 to prevent use of this kind of setup from most apps using libvirt.

 We need to at least come up with a plan of how we'd address this problem
 in the medium term.

 That is my concern as well. :(
 I'm wondering if we probably should just state that we're currently
 support VMs that don't need any interactive interactions at the boot
 loader step?

Sure.

 Vaporware or not, I'm sure that solving it on the Bhyve sise (e.g.
 either get UEFI support or at least pass loader options to it so it
 could run it itself) is a much better solution than development of the
 workarounds in libvirt...

Yes. I can draft a patch for bhyve to run the loader itself, but I
fear they might reject it due to UEFI/BIOS support is coming.
Anyway, I think that's a bit orthogonal to this change. We already
block / fall over in the same way if bhyveload pauses and waits for
user input.

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv5 4/6] bhyvexml2argv: Add tests for domain-configured bootloader, args

2014-10-28 Thread Conrad Meyer
On Tue, Oct 28, 2014 at 10:55 AM, Daniel P. Berrange
berra...@redhat.com wrote:
 On Mon, Oct 27, 2014 at 10:37:39AM -0400, Conrad Meyer wrote:
 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs 
 b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 new file mode 100644
 index 000..d9161ba
 --- /dev/null
 +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 @@ -0,0 +1,2 @@
 +/usr/local/sbin/grub-bhyve --root cd --device-map 'device.map' --memory 
 214 \
 +bhyve

 Ah ha, I thought my command about device.map would become relevant :-)

 We probably want a 3rd expected data file  '.devmap' containing the
 expected device map contents to compare against.

This can be done, sure. (IMO GRUB only needs to know about the boot
device, be it CD or HDD, so this configuration will never be very
exciting / surprising.)

Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv5 1/6] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-28 Thread Conrad Meyer
On Tue, Oct 28, 2014 at 11:14 AM, Daniel P. Berrange
berra...@redhat.com wrote:
 On Tue, Oct 28, 2014 at 06:01:51PM +0300, Roman Bogorodskiy wrote:
   Daniel P. Berrange wrote:

  On Mon, Oct 27, 2014 at 10:37:36AM -0400, Conrad Meyer wrote:
prestart --console domname/pre
  
   +pbNB:/b An interactive bootloader will keep the domain from 
   starting (and
   +thus codevirsh console/code or codestart --console/code) until 
   the
   +console is opened by a client. To select a boot option and allow the 
   domain to
   +finish starting, one must use an alternative terminal client to connect 
   to the
   +null modem device. One example is:/p
 
  Can you clarify what you mean by this. It seems like this is saying that
  the 'virDomainCreate' API (virsh start GUEST command) will not return
  controll to the caller until you've interacted with the bootloader.
 
  If correct, I don't think this is a very satisfactory solution. There
  should not be any requirement to interact with the guest domain until
  after the virDomainCreate API call completes successfully. If succesfully
  booting requires that you go via an out-of-band channel to interact with
  the bootloader that's even more of a problem.
 
  Because libvirt has an RPC based mechanism for API access, we need to
  always bear in mind that the application/user talking to libvirt drivers
  is either local but unprivileged, or even entirely remote from the 
  hypervisor
  node. The libvirt built-in console tunnels over our RPC channel to provide
  apps access.
 
  So if my understanding is correct, this limitation you describe is going
  to prevent use of this kind of setup from most apps using libvirt.
 
  We need to at least come up with a plan of how we'd address this problem
  in the medium term.

 That is my concern as well. :(
 I'm wondering if we probably should just state that we're currently
 support VMs that don't need any interactive interactions at the boot
 loader step?

 Vaporware or not, I'm sure that solving it on the Bhyve sise (e.g.
 either get UEFI support or at least pass loader options to it so it
 could run it itself) is a much better solution than development of the
 workarounds in libvirt...

 Maybe it suffices to just say that libvirt does not officially support
 interactive bootloaders. Don't try to block any specific configurations.
 People can use the out-of-band hack if they really want to, but we make
 no promises about future compatibility or support of this hack. So if
 it breaks in a upgrade they get to keep both pieces. Then long term just
 focus on fully interactive BIOS running guestside.

+1 from me (so long as the out-of-band hack isn't explicitly blocked).

Best,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/2] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-28 Thread Conrad Meyer
 I don't think it's safe to pass arbitrary arguments from XML. I find this
 too critical to ACK the patch, buy maybe further discussion can change my
 mind.

Michal,

You're reviewing a 4-revision old version of this patch, see v5 for
the most recent set. However, this bit is still present in v5. What is
bootloader_args in the XML is for, if not arbitrary arguments?


Thanks,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv5 6/6] bhyvexml2argv: Add test for grub console support

2014-10-27 Thread Conrad Meyer
Sponsored by:  EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 .../bhyvexml2argv-serial-grub.args |  4 
 .../bhyvexml2argv-serial-grub.ldargs   |  2 ++
 .../bhyvexml2argv-serial-grub.xml  | 26 ++
 tests/bhyvexml2argvtest.c  |  1 +
 4 files changed, 33 insertions(+)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
new file mode 100644
index 000..df50290
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
@@ -0,0 +1,4 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img \
+-s 1,lpc -l com1,/dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
new file mode 100644
index 000..5645097
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
@@ -0,0 +1,2 @@
+/usr/local/sbin/grub-bhyve --root hd0,msdos1 --device-map 'device.map' \
+--memory 214 --cons-dev /dev/nmdm0A bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
new file mode 100644
index 000..8c451f7
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
@@ -0,0 +1,26 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/usr/local/sbin/grub-bhyve/bootloader
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img'/
+  target dev='hda' bus='sata'/
+  address type='pci' domain='0x' bus='0x00' slot='0x02' 
function='0x0'/
+/disk
+interface type='bridge'
+  model type='virtio'/
+  source bridge=virbr0/
+  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/
+/interface
+serial type='nmdm'
+  source master='/dev/nmdm0A' slave='/dev/nmdm0B'/
+/serial
+  /devices
+/domain
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 0f8582e..d4d2133 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -140,6 +140,7 @@ mymain(void)
 DO_TEST(bhyveload-explicitargs);
 DO_TEST(custom-loader);
 DO_TEST(disk-cdrom-grub);
+DO_TEST(serial-grub);
 
 virObjectUnref(driver.caps);
 virObjectUnref(driver.xmlopt);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv5 5/6] bhyve: Add console support for grub-bhyve bootloader

2014-10-27 Thread Conrad Meyer
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.

Sponsored by:  EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 src/bhyve/bhyve_command.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 01f1795..07d209e 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -468,6 +468,21 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
 virCommandAddArgFormat(cmd, %llu,
VIR_DIV_UP(def-mem.max_balloon, 1024));
 
+if (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);
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv5 3/6] domaincommon.rng: Add bootloader, bootloader_arg to os=hvm schema for Bhyve

2014-10-27 Thread Conrad Meyer
Sponsored by:  EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 docs/schemas/domaincommon.rng | 41 ++---
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 20d81ae..1c444e0 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -213,7 +213,7 @@
 choice
   group
 optional
-  ref name=bootloader/
+  ref name=xenbootloader/
 /optional
 element name=os
   ref name=ostypexen/
@@ -221,7 +221,7 @@
 /element
   /group
   group
-ref name=bootloader/
+ref name=xenbootloader/
 optional
   element name=os
 ref name=ostypexen/
@@ -234,6 +234,9 @@
 /choice
   /define
   define name=oshvm
+optional
+  ref name=bhyvebootloader/
+/optional
 element name=os
   ref name=ostypehvm/
   interleave
@@ -1053,17 +1056,33 @@
   binary or script used to extract the data from the first disk device.
 --
   define name=bootloader
+element name=bootloader
+  choice
+ref name=absFilePath/
+empty/
+  /choice
+/element
+  /define
+  define name=bootloader_args
+element name=bootloader_args
+  text/
+/element
+  /define
+  define name=xenbootloader
 interleave
-  element name=bootloader
-choice
-  ref name=absFilePath/
-  empty/
-/choice
-  /element
+  ref name=bootloader/
   optional
-element name=bootloader_args
-  text/
-/element
+ref name=bootloader_args/
+  /optional
+/interleave
+  /define
+  define name=bhyvebootloader
+interleave
+  optional
+ref name=bootloader/
+  /optional
+  optional
+ref name=bootloader_args/
   /optional
 /interleave
   /define
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv5 4/6] bhyvexml2argv: Add tests for domain-configured bootloader, args

2014-10-27 Thread Conrad Meyer
Sponsored by:  EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 .../bhyvexml2argv-bhyveload-explicitargs.args  |  3 +++
 .../bhyvexml2argv-bhyveload-explicitargs.ldargs|  1 +
 .../bhyvexml2argv-bhyveload-explicitargs.xml   | 23 +
 .../bhyvexml2argv-custom-loader.args   |  3 +++
 .../bhyvexml2argv-custom-loader.ldargs |  1 +
 .../bhyvexml2argv-custom-loader.xml| 24 ++
 .../bhyvexml2argv-disk-cdrom-grub.args |  3 +++
 .../bhyvexml2argv-disk-cdrom-grub.ldargs   |  2 ++
 .../bhyvexml2argv-disk-cdrom-grub.xml  | 23 +
 .../bhyvexml2argv-grub-defaults.args   |  3 +++
 .../bhyvexml2argv-grub-defaults.ldargs |  2 ++
 .../bhyvexml2argv-grub-defaults.xml| 23 +
 tests/bhyvexml2argvtest.c  |  4 
 13 files changed, 115 insertions(+)
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.xml

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
new file mode 100644
index 000..4122e62
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
@@ -0,0 +1,3 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
diff --git 
a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
new file mode 100644
index 000..a3f58f0
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -X -Y -Z
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
new file mode 100644
index 000..65823cd
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
@@ -0,0 +1,23 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader_args-X -Y -Z/bootloader_args
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img'/
+  target dev='hda' bus='sata'/
+  address type='pci' domain='0x' bus='0x00' slot='0x02' 
function='0x0'/
+/disk
+interface type='bridge'
+  model type='virtio'/
+  source bridge=virbr0/
+  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/
+/interface
+  /devices
+/domain
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
new file mode 100644
index 000..4122e62
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
@@ -0,0 +1,3 @@
+/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 2:0,ahci-hd,/tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
new file mode 100644
index 000..100e163
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
@@ -0,0 +1 @@
+/fizz_buzz_bazz -X -Y -Z
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
new file mode 100644
index 000..e9e0d5e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
@@ -0,0 +1,24 @@
+domain type='bhyve'
+  namebhyve/name
+  uuiddf3be7e7-a104-11e3-aeb0-50e5492bd3dc/uuid
+  memory219136/memory
+  vcpu1/vcpu
+  bootloader/fizz_buzz_bazz/bootloader
+  bootloader_args-X -Y -Z/bootloader_args
+  os
+typehvm/type
+  /os
+  devices
+disk type='file'
+  driver name='file' type='raw'/
+  source file='/tmp/freebsd.img

[libvirt] [PATCHv5 1/6] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-27 Thread Conrad Meyer
We still default to bhyveloader(1) if no explicit bootloader
configuration is supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk (or a CD if one exists,
under the assumption that for a VM a CD is likely an install source).

Caveat: Assumes the HDD boots from the msdos1 partition. I think this is
a pretty reasonable assumption for a VM. (DrvBhyve with Bhyveload
already assumes that the first disk should be booted.)

I've tested both HDD and CD boot and they seem to work.

Sponsored by:  EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 docs/drvbhyve.html.in |  94 -
 docs/formatdomain.html.in |   4 +-
 src/bhyve/bhyve_command.c | 202 +-
 src/bhyve/bhyve_command.h |   5 +-
 src/bhyve/bhyve_domain.c  |   5 ++
 src/bhyve/bhyve_domain.h  |   1 +
 src/bhyve/bhyve_driver.c  |   2 +-
 src/bhyve/bhyve_process.c |  13 ++-
 8 files changed, 298 insertions(+), 28 deletions(-)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 39afdf5..ee1317e 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
tunnelled)
 h3Example config/h3
 p
 The bhyve driver in libvirt is in its early stage and under active 
development. So it supports
-only limited number of features bhyve provides. All the supported features 
could be found
-in this sample domain XML.
+only limited number of features bhyve provides.
 /p
 
 p
@@ -48,10 +47,21 @@ disk device were supported per-domain. However,
 up to 31 PCI devices.
 /p
 
+p
+Note: the Bhyve driver in libvirt will boot whichever device is first. If you
+want to install from CD, put the CD device first. If not, put the root HDD
+first.
+/p
+
+p
+Note: Only the SATA bus is supported. Only codecdrom/code- and
+codedisk/code-type disks are supported.
+/p
+
 pre
 lt;domain type='bhyve'gt;
-  lt;namegt;bhyvelt;/namegt;
-  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;namegt;bhyvelt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 lt;memorygt;219136lt;/memorygt;
 lt;currentMemorygt;219136lt;/currentMemorygt;
 lt;vcpugt;1lt;/vcpugt;
@@ -76,6 +86,7 @@ up to 31 PCI devices.
 lt;driver name='file' type='raw'/gt;
 lt;source file='/path/to/cdrom.iso'/gt;
 lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
   lt;/diskgt;
   lt;interface type='bridge'gt;
 lt;model type='virtio'/gt;
@@ -85,6 +96,53 @@ up to 31 PCI devices.
 lt;/domaingt;
 /pre
 
+p(The lt;diskgt; sections may be swapped in order to install from
+emcdrom.iso/em.)/p
+
+h3Example config (Linux guest)/h3
+
+p
+Note the addition of lt;bootloadergt;.
+/p
+
+pre
+lt;domain type='bhyve'gt;
+lt;namegt;linux_guestlt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;memorygt;131072lt;/memorygt;
+lt;currentMemorygt;131072lt;/currentMemorygt;
+lt;vcpugt;1lt;/vcpugt;
+lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
+lt;osgt;
+   lt;typegt;hvmlt;/typegt;
+lt;/osgt;
+lt;featuresgt;
+  lt;apic/gt;
+  lt;acpi/gt;
+lt;/featuresgt;
+lt;clock offset='utc'/gt;
+lt;on_poweroffgt;destroylt;/on_poweroffgt;
+lt;on_rebootgt;restartlt;/on_rebootgt;
+lt;on_crashgt;destroylt;/on_crashgt;
+lt;devicesgt;
+  lt;disk type='file' device='disk'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/guest_hdd.img'/gt;
+lt;target dev='hda' bus='sata'/gt;
+  lt;/diskgt;
+  lt;disk type='file' device='cdrom'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/cdrom.iso'/gt;
+lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
+  lt;/diskgt;
+  lt;interface type='bridge'gt;
+lt;model type='virtio'/gt;
+lt;source bridge=virbr0/gt;
+  lt;/interfacegt;
+lt;/devicesgt;
+lt;/domaingt;
+/pre
 
 h2a name=usageGuest usage / management/a/h2
 
@@ -119,6 +177,14 @@ to let a guest boot or start a guest using:/p
 
 prestart --console domname/pre
 
+pbNB:/b An interactive bootloader will keep the domain from starting (and
+thus codevirsh console/code or codestart --console/code) until the
+console is opened by a client. To select a boot option and allow the domain to
+finish starting, one must use an alternative terminal client to connect to the
+null modem device. One example is:/p
+
+precu -l /dev/nmdm0B/pre
+
 h3a name=xmltonativeConverting from domain XML to Bhyve args/a/h3
 
 p
@@ -157,5 +223,25 @@ An example of domain XML device entry for that will look 
like:/p
 pPlease refer to the a href=storage.htmlStorage documentation/a for 
more details on storage
 management./p
 
+h3a name=grubbhyveUsing grub2

[libvirt] [PATCHv5 2/6] bhyvexml2argv: Add loader argv tests.

2014-10-27 Thread Conrad Meyer
Sponsored by:  EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 .../bhyvexml2argv-acpiapic.ldargs  |  1 +
 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs  |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-console.ldargs |  1 +
 .../bhyvexml2argv-disk-cdrom.ldargs|  1 +
 .../bhyvexml2argv-disk-virtio.ldargs   |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs |  1 +
 .../bhyvexml2argvdata/bhyvexml2argv-serial.ldargs  |  1 +
 tests/bhyvexml2argvtest.c  | 36 ++
 8 files changed, 37 insertions(+), 6 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs

diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
new file mode 100644
index 000..0eb3cc9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/cdrom.iso bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs
new file mode 100644
index 000..215d65f
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs
@@ -0,0 +1 @@
+/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index b9be378..db45ae5 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -15,14 +15,15 @@
 static bhyveConn driver;
 
 static int testCompareXMLToArgvFiles(const char *xml,
- const char *cmdline)
+ const char *cmdline,
+ const char *ldcmdline)
 {
-char *expectargv = NULL;
+char *expectargv = NULL, *expectld = NULL;
 int len;
-char *actualargv = NULL;
+char *actualargv = NULL, *actualld = NULL;
 virDomainDefPtr vmdef = NULL;
 virDomainObj vm;
-virCommandPtr cmd = NULL;
+virCommandPtr cmd = NULL, ldcmd = NULL;
 virConnectPtr conn;
 int ret = -1;
 
@@ -42,6 +43,12 @@ static int testCompareXMLToArgvFiles(const char *xml,
 if (!(actualargv = virCommandToString(cmd)))
 goto out;
 
+if (!(ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, NULL)))
+goto out;
+
+if (!(actualld = virCommandToString(ldcmd)))
+goto out;
+
 len = virtTestLoadFile(cmdline, expectargv);
 if (len  0)
 goto out;
@@ -49,17 +56,32 @@ static int testCompareXMLToArgvFiles(const char *xml,
 if (len  expectargv[len - 1] == '\n')
 expectargv[len - 1] = '\0';
 
+len = virtTestLoadFile(ldcmdline, expectld);
+if (len  0)
+goto out;
+
+if (len  expectld[len - 1] == '\n')
+expectld[len - 1] = '\0';
+
 if (STRNEQ(expectargv, actualargv)) {
 virtTestDifference(stderr, expectargv, actualargv);
 goto out;
 }
 
+if (STRNEQ(expectld, actualld

[libvirt] [PATCHv5 0/6] Add non-FreeBSD guest support to Bhyve driver.

2014-10-27 Thread Conrad Meyer
Drvbhyve hardcodes bhyveload(8) as the host bootloader for guests.
bhyveload(8) loader only supports FreeBSD guests.

This patch series adds bootloader and bootloader_args handling to
bhyve_command, so libvirt can boot non-FreeBSD guests in Bhyve.

Additionally, support for grub-bhyve(1)'s --cons-dev argument is added so that
interactive GRUB menus can be manipulated with the domain-configured serial
device.

See patch logs for further details.

Thanks,
Conrad

Changelog for v5:
  - Added loader arguments tests to the bhyvexml2argvtest harness
  - Dropped po/pot file changes per Daniel
  - Added bootloader, bootloader_args to domain XML schema
  - Added xml2argv tests for new bhyve bootloader handling
  - Added xml2argv test for grub with console device

Conrad Meyer (6):
  bhyve: Support /domain/bootloader configuration for non-FreeBSD
guests.
  bhyvexml2argv: Add loader argv tests.
  domaincommon.rng: Add bootloader, bootloader_arg to os=hvm schema for
Bhyve
  bhyvexml2argv: Add tests for domain-configured bootloader, args
  bhyve: Add console support for grub-bhyve bootloader
  bhyvexml2argv: Add test for grub console support

 docs/drvbhyve.html.in  |  94 -
 docs/formatdomain.html.in  |   4 +-
 docs/schemas/domaincommon.rng  |  41 ++--
 src/bhyve/bhyve_command.c  | 215 +++--
 src/bhyve/bhyve_command.h  |   5 +-
 src/bhyve/bhyve_domain.c   |   5 +
 src/bhyve/bhyve_domain.h   |   1 +
 src/bhyve/bhyve_driver.c   |   2 +-
 src/bhyve/bhyve_process.c  |  13 +-
 .../bhyvexml2argv-acpiapic.ldargs  |   1 +
 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs  |   1 +
 .../bhyvexml2argv-bhyveload-explicitargs.args  |   3 +
 .../bhyvexml2argv-bhyveload-explicitargs.ldargs|   1 +
 .../bhyvexml2argv-bhyveload-explicitargs.xml   |  23 +++
 .../bhyvexml2argvdata/bhyvexml2argv-console.ldargs |   1 +
 .../bhyvexml2argv-custom-loader.args   |   3 +
 .../bhyvexml2argv-custom-loader.ldargs |   1 +
 .../bhyvexml2argv-custom-loader.xml|  24 +++
 .../bhyvexml2argv-disk-cdrom-grub.args |   3 +
 .../bhyvexml2argv-disk-cdrom-grub.ldargs   |   2 +
 .../bhyvexml2argv-disk-cdrom-grub.xml  |  23 +++
 .../bhyvexml2argv-disk-cdrom.ldargs|   1 +
 .../bhyvexml2argv-disk-virtio.ldargs   |   1 +
 .../bhyvexml2argv-grub-defaults.args   |   3 +
 .../bhyvexml2argv-grub-defaults.ldargs |   2 +
 .../bhyvexml2argv-grub-defaults.xml|  23 +++
 .../bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs |   1 +
 .../bhyvexml2argv-serial-grub.args |   4 +
 .../bhyvexml2argv-serial-grub.ldargs   |   2 +
 .../bhyvexml2argv-serial-grub.xml  |  26 +++
 .../bhyvexml2argvdata/bhyvexml2argv-serial.ldargs  |   1 +
 tests/bhyvexml2argvtest.c  |  41 +++-
 32 files changed, 527 insertions(+), 44 deletions(-)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-base.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial.ldargs

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv3 1/2] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-26 Thread Conrad Meyer
On Sun, Oct 26, 2014 at 7:00 AM, Roman Bogorodskiy
bogorods...@gmail.com wrote:
   Conrad Meyer wrote:

 I've tested the HDD boot and it seems to work.

 I've tried to boot from CD and had a problem with that. It generates a
 command like that:

 /usr/local/sbin/grub-bhyve -v --root cd --device-map
 /usr/local/var/run/libvirt/bhyve/grub-bhyve-device.map_63694 --memory
 512 linux3

 and the error is:

 Could not create VM linux3
 Error in initializing VM

 Map file looks this way:

 (hd0) /home/novel/linux.img
 (cd) /home/novel/ubuntu-14.04-server-amd64.iso

 Any idea what could be wrong with that?

It looks like the map files I've seen from GRUB documentation (and
I've also tried cd0 and couldn't get grub-bhyve to boot that), but
that might be legacy GRUB only.

Maybe just (hd1) and root=(hd1) will work. I don't know.

 @@ -157,5 +156,26 @@ An example of domain XML device entry for that will 
 look like:/p
  pPlease refer to the a href=storage.htmlStorage documentation/a for 
 more details on storage
  management./p

 +h3a name=grubbhyveUsing grub2-bhyve or Alternative 
 Bootloaders/a/h3
 +
 +pIt's possible to boot non-FreeBSD guests by specifying an explicit
 +bootloader, e.g. codegrub-bhyve(1)/code. Arguments to the bootloader 
 may be
 +specified as well. If no arguments are given and bootloader is
 +codegrub-bhyve/code, libvirt will try and boot from the first partition 
 of
 +the disk image./p
 +
 +pre
 +  ...
 +lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
 +lt;bootloader_argsgt;...lt;/bootloader_argsgt;
 +  ...
 +/pre
 +

 I think it would be also great to add a complete domain XML for Linux
 guest into 'Example guest domain XML configurations' section.

Okay, will do.

 +if (def-os.bootloaderArgs == NULL) {
 +VIR_DEBUG(%s: bhyveload with default arguments, __func__);

 Adding __func__ here is not needed because it'll be included in the log
 message as well, e.g.:

 2014-10-26 10:16:28.285+: 34498181120: info :
 virBhyveProcessBuildGrubbhyveCmd:410 : virBhyveProcessBuildGrubbhyveCmd:
 Picking /home/novel/linux.img as HDD

 (Yes, it's a different log entry, but idea is the same).

Sure, thanks. I will fix up this and the other __func__ / style / period issues.

 +/* XXX: Handle quoted? */
 +blargs = virStringSplit(def-os.bootloaderArgs,  , 0);
 +virCommandAddArgSet(cmd, (const char * const *)blargs);
 +virStringFreeList(blargs);

 As this block is used two times without changes, I'm wondering if it's
 worth to move it out into a function as well or is it small enough for
 that...

I was on the fence. I think the risk of someone coming along and
accidentally implementing quoting for only one of the sections is
fairly low.

 + virDomainDiskGetSource(cd));
 +}
 +
 +if (disk == NULL 
 +def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_DISK) {
 +disk = def-disks[i];
 +VIR_INFO(%s: Picking %s as HDD, __func__,
 + virDomainDiskGetSource(disk));

 Ditto wrt __func__.

 Wondering if it would make sense to break the loop if cd != NULL and
 disk != NULL after the iteration as we pick the first match anyway?

Because of performance concerns, or for clarity? The number of disks
you might typically have in a VM is so small, I think simpler code is
maybe nicer. But if it's unclear, it can be changed.

 +
 +/*
 + * XXX Default grub-bhyve has some minor caveats, but MAY work for some
 + * typical configurations. In particular:
 + *
 + *   - For HDD boot, assumes a GRUB install on hd0,msdos1
 + */
 +
 +VIR_FREE(privconn-grub_devicesmap_file);
 +rc = virAsprintf(privconn-grub_devicesmap_file,
 + %s/grub-bhyve-device.map_%ju, BHYVE_STATE_DIR,
 + (uintmax_t)getpid());

 Could you please elaborate on deciding to store this filename in
 privconn? In this case we need to make sure that it's not a subject for
 races. Probably other option would be to make it per-domain based, as
 it's a per-domain resource anyway?

Domain-based would be better; privconn was just a guess based on
'pidfile'. Do we have some per-domain private data yet? And if so,
where is it?

Thanks for taking a look.

Best,
Conrad

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv4 0/3] Add non-FreeBSD guest support to Bhyve driver.

2014-10-26 Thread Conrad Meyer
Drvbhyve hardcodes bhyveload(8) as the host bootloader for guests.
bhyveload(8) loader only supports FreeBSD guests.

This patch series adds bootloader and bootloader_args handling to
bhyve_command, so libvirt can boot non-FreeBSD guests in Bhyve.

Additionally, support for grub-bhyve(1)'s --cons-dev argument is added so that
interactive GRUB menus can be manipulated with the domain-configured serial
device.

See patch logs for further details.

Thanks,
Conrad

Changelog:
v4:
  - Supports interactive GRUB menus (Per Roman) (Ubuntu CD tested)
  - Various style fixes (per Roman) (syntax-check clean)
  - Moved devices.map filename from driver connection object to domain private
object (per Roman)
  - Fleshed out drvbhyve.html (per Roman)
v3:
  - Based on latest git as of less than an hour ago; tested HDD booting a Linux
guest several times.
  - Added first cut at CD booting. I'm not sure grub-bhyve supports this
(was not able to to test it).
  - make 'syntax-check' clean
  - Per Roman (off-list), split up virBhyveProcessBuildLoadCmd into a few
smaller functions.
  - Also per Roman (off-list), use virCommandAddArgSet() for bootloader_args.
(Without the nasty cast, my compiler complains.)
v2:
  - Dropped hvm - xen change per Peter's feedback.


Conrad Meyer (3):
  bhyve: Support /domain/bootloader configuration for non-FreeBSD
guests.
  Generated PO files for 'bhyve: Support /domain/bootloader'
  bhyve: Add console support for grub-bhyve bootloader

 docs/drvbhyve.html.in |  94 +++-
 docs/formatdomain.html.in |   4 +-
 po/af.po  |   7 +-
 po/am.po  |   7 +-
 po/ar.po  |   7 +-
 po/as.po  |   7 +-
 po/be.po  |   7 +-
 po/bg.po  |   7 +-
 po/bn.po  |   7 +-
 po/bn_IN.po   |   7 +-
 po/bo.po  |   7 +-
 po/bs.po  |   7 +-
 po/ca.po  |   7 +-
 po/cs.po  |   7 +-
 po/cy.po  |   7 +-
 po/da.po  |   7 +-
 po/de.po  |   7 +-
 po/el.po  |   7 +-
 po/en_GB.po   |   7 +-
 po/es.po  |   7 +-
 po/et.po  |   7 +-
 po/eu_ES.po   |   7 +-
 po/fa.po  |   7 +-
 po/fi.po  |   7 +-
 po/fr.po  |   7 +-
 po/gl.po  |   7 +-
 po/gu.po  |   7 +-
 po/he.po  |   7 +-
 po/hi.po  |   7 +-
 po/hr.po  |   7 +-
 po/hu.po  |   7 +-
 po/hy.po  |   7 +-
 po/id.po  |   7 +-
 po/is.po  |   7 +-
 po/it.po  |   7 +-
 po/ja.po  |   7 +-
 po/ka.po  |   7 +-
 po/kn.po  |   7 +-
 po/ko.po  |   7 +-
 po/ku.po  |   7 +-
 po/libvirt.pot|   7 +-
 po/lo.po  |   7 +-
 po/lt.po  |   7 +-
 po/lv.po  |   7 +-
 po/mk.po  |   7 +-
 po/ml.po  |   7 +-
 po/mr.po  |   7 +-
 po/ms.po  |   7 +-
 po/my.po  |   7 +-
 po/nb.po  |   7 +-
 po/nl.po  |   7 +-
 po/nn.po  |   7 +-
 po/nso.po |   7 +-
 po/or.po  |   7 +-
 po/pa.po  |   7 +-
 po/pl.po  |   7 +-
 po/pt.po  |   7 +-
 po/pt_BR.po   |   7 +-
 po/ro.po  |   7 +-
 po/ru.po  |   7 +-
 po/si.po  |   7 +-
 po/sk.po  |   7 +-
 po/sl.po  |   7 +-
 po/sq.po  |   7 +-
 po/sr.po  |   7 +-
 po/s...@latin.po|   7 +-
 po/sv.po  |   7 +-
 po/ta.po  |   7 +-
 po/te.po  |   7 +-
 po/th.po  |   7 +-
 po/tr.po  |   7 +-
 po/uk.po  |   7 +-
 po/ur.po  |   7 +-
 po/vi.po  |   7 +-
 po/vi_VN.po   |   7 +-
 po/zh_CN.po   |   7 +-
 po/zh_TW.po   |   7 +-
 po/zu.po  |   7 +-
 src/bhyve/bhyve_command.c | 215 ++
 src/bhyve/bhyve_command.h |   5 +-
 src/bhyve/bhyve_domain.c  |   5 ++
 src/bhyve/bhyve_domain.h  |   1 +
 src/bhyve/bhyve_driver.c  |   2 +-
 src/bhyve/bhyve_process.c |  13 ++-
 84 files changed, 768 insertions(+), 103 deletions(-)

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv4 2/3] Generated PO files for 'bhyve: Support /domain/bootloader'

2014-10-26 Thread Conrad Meyer
Sponsored by:   EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 po/af.po   | 7 ++-
 po/am.po   | 7 ++-
 po/ar.po   | 7 ++-
 po/as.po   | 7 ++-
 po/be.po   | 7 ++-
 po/bg.po   | 7 ++-
 po/bn.po   | 7 ++-
 po/bn_IN.po| 7 ++-
 po/bo.po   | 7 ++-
 po/bs.po   | 7 ++-
 po/ca.po   | 7 ++-
 po/cs.po   | 7 ++-
 po/cy.po   | 7 ++-
 po/da.po   | 7 ++-
 po/de.po   | 7 ++-
 po/el.po   | 7 ++-
 po/en_GB.po| 7 ++-
 po/es.po   | 7 ++-
 po/et.po   | 7 ++-
 po/eu_ES.po| 7 ++-
 po/fa.po   | 7 ++-
 po/fi.po   | 7 ++-
 po/fr.po   | 7 ++-
 po/gl.po   | 7 ++-
 po/gu.po   | 7 ++-
 po/he.po   | 7 ++-
 po/hi.po   | 7 ++-
 po/hr.po   | 7 ++-
 po/hu.po   | 7 ++-
 po/hy.po   | 7 ++-
 po/id.po   | 7 ++-
 po/is.po   | 7 ++-
 po/it.po   | 7 ++-
 po/ja.po   | 7 ++-
 po/ka.po   | 7 ++-
 po/kn.po   | 7 ++-
 po/ko.po   | 7 ++-
 po/ku.po   | 7 ++-
 po/libvirt.pot | 3 ++-
 po/lo.po   | 7 ++-
 po/lt.po   | 7 ++-
 po/lv.po   | 7 ++-
 po/mk.po   | 7 ++-
 po/ml.po   | 7 ++-
 po/mr.po   | 7 ++-
 po/ms.po   | 7 ++-
 po/my.po   | 7 ++-
 po/nb.po   | 7 ++-
 po/nl.po   | 7 ++-
 po/nn.po   | 7 ++-
 po/nso.po  | 7 ++-
 po/or.po   | 7 ++-
 po/pa.po   | 7 ++-
 po/pl.po   | 7 ++-
 po/pt.po   | 7 ++-
 po/pt_BR.po| 7 ++-
 po/ro.po   | 7 ++-
 po/ru.po   | 7 ++-
 po/si.po   | 7 ++-
 po/sk.po   | 7 ++-
 po/sl.po   | 7 ++-
 po/sq.po   | 7 ++-
 po/sr.po   | 7 ++-
 po/s...@latin.po | 7 ++-
 po/sv.po   | 7 ++-
 po/ta.po   | 7 ++-
 po/te.po   | 7 ++-
 po/th.po   | 7 ++-
 po/tr.po   | 7 ++-
 po/uk.po   | 7 ++-
 po/ur.po   | 7 ++-
 po/vi.po   | 7 ++-
 po/vi_VN.po| 7 ++-
 po/zh_CN.po| 7 ++-
 po/zh_TW.po| 7 ++-
 po/zu.po   | 7 ++-
 76 files changed, 452 insertions(+), 76 deletions(-)

diff --git a/po/af.po b/po/af.po
index 0e1374d..1ba7579 100644
--- a/po/af.po
+++ b/po/af.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
@@ -1047,6 +1051,7 @@ msgid cannot get host CPU capabilities
 msgstr 
 
 #: src/bhyve/bhyve_process.c:115 src/lxc/lxc_process.c:1179
+#: src/bhyve/bhyve_command.c:383
 #, c-format
 msgid Failed to open '%s'
 msgstr 
@@ -21872,7 +21877,7 @@ msgstr 
 msgid creation of non-raw images is not supported without qemu-img
 msgstr 
 
-#: src/storage/storage_backend_fs.c:1147
+#: src/storage/storage_backend_fs.c:1147 src/bhyve/bhyve_process.c:200
 #, c-format
 msgid cannot unlink file '%s'
 msgstr 
diff --git a/po/am.po b/po/am.po
index 8230ec8..49b2a5b 100644
--- a/po/am.po
+++ b/po/am.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
@@ -1047,6 +1051,7 @@ msgid cannot get host CPU capabilities
 msgstr 
 
 #: src/bhyve/bhyve_process.c:115 src/lxc/lxc_process.c:1179
+#: src/bhyve/bhyve_command.c:383
 #, c-format
 msgid Failed to open '%s'
 msgstr 
@@ -21872,7 +21877,7 @@ msgstr 
 msgid creation of non-raw images is not supported without qemu-img
 msgstr 
 
-#: src/storage/storage_backend_fs.c:1147
+#: src/storage/storage_backend_fs.c:1147 src/bhyve/bhyve_process.c:200
 #, c-format
 msgid cannot unlink file '%s'
 msgstr 
diff --git a/po/ar.po b/po/ar.po
index fed8f1f..68a1c01 100644
--- a/po/ar.po
+++ b/po/ar.po
@@ -854,6 +854,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
@@ -1048,6 +1052,7 @@ msgid cannot get host CPU capabilities
 msgstr 
 
 #: src/bhyve/bhyve_process.c:115 src/lxc/lxc_process.c:1179
+#: src/bhyve/bhyve_command.c:383
 #, c-format
 msgid Failed to open '%s'
 msgstr 
@@ -21873,7 +21878,7 @@ msgstr 
 msgid creation of non-raw images is not supported without qemu-img
 msgstr 
 
-#: src/storage/storage_backend_fs.c:1147
+#: src/storage/storage_backend_fs.c:1147 src/bhyve/bhyve_process.c:200
 #, c-format
 msgid cannot unlink file '%s'
 msgstr 
diff --git a/po/as.po b/po/as.po

[libvirt] [PATCHv4 1/3] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-26 Thread Conrad Meyer
We still default to bhyveloader(1) if no explicit bootloader
configuration is supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk (or a CD if one exists,
under the assumption that for a VM a CD is likely an install source).

Caveat: Assumes the HDD boots from the msdos1 partition. I think this is
a pretty reasonable assumption for a VM. (DrvBhyve with Bhyveload
already assumes that the first disk should be booted.)

I've tested both HDD and CD boot and they seem to work.

Sponsored by:   EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 docs/drvbhyve.html.in |  94 -
 docs/formatdomain.html.in |   4 +-
 po/libvirt.pot|   4 +
 src/bhyve/bhyve_command.c | 202 +-
 src/bhyve/bhyve_command.h |   5 +-
 src/bhyve/bhyve_domain.c  |   5 ++
 src/bhyve/bhyve_domain.h  |   1 +
 src/bhyve/bhyve_driver.c  |   2 +-
 src/bhyve/bhyve_process.c |  13 ++-
 9 files changed, 302 insertions(+), 28 deletions(-)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 39afdf5..ee1317e 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
tunnelled)
 h3Example config/h3
 p
 The bhyve driver in libvirt is in its early stage and under active 
development. So it supports
-only limited number of features bhyve provides. All the supported features 
could be found
-in this sample domain XML.
+only limited number of features bhyve provides.
 /p
 
 p
@@ -48,10 +47,21 @@ disk device were supported per-domain. However,
 up to 31 PCI devices.
 /p
 
+p
+Note: the Bhyve driver in libvirt will boot whichever device is first. If you
+want to install from CD, put the CD device first. If not, put the root HDD
+first.
+/p
+
+p
+Note: Only the SATA bus is supported. Only codecdrom/code- and
+codedisk/code-type disks are supported.
+/p
+
 pre
 lt;domain type='bhyve'gt;
-  lt;namegt;bhyvelt;/namegt;
-  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;namegt;bhyvelt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 lt;memorygt;219136lt;/memorygt;
 lt;currentMemorygt;219136lt;/currentMemorygt;
 lt;vcpugt;1lt;/vcpugt;
@@ -76,6 +86,7 @@ up to 31 PCI devices.
 lt;driver name='file' type='raw'/gt;
 lt;source file='/path/to/cdrom.iso'/gt;
 lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
   lt;/diskgt;
   lt;interface type='bridge'gt;
 lt;model type='virtio'/gt;
@@ -85,6 +96,53 @@ up to 31 PCI devices.
 lt;/domaingt;
 /pre
 
+p(The lt;diskgt; sections may be swapped in order to install from
+emcdrom.iso/em.)/p
+
+h3Example config (Linux guest)/h3
+
+p
+Note the addition of lt;bootloadergt;.
+/p
+
+pre
+lt;domain type='bhyve'gt;
+lt;namegt;linux_guestlt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;memorygt;131072lt;/memorygt;
+lt;currentMemorygt;131072lt;/currentMemorygt;
+lt;vcpugt;1lt;/vcpugt;
+lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
+lt;osgt;
+   lt;typegt;hvmlt;/typegt;
+lt;/osgt;
+lt;featuresgt;
+  lt;apic/gt;
+  lt;acpi/gt;
+lt;/featuresgt;
+lt;clock offset='utc'/gt;
+lt;on_poweroffgt;destroylt;/on_poweroffgt;
+lt;on_rebootgt;restartlt;/on_rebootgt;
+lt;on_crashgt;destroylt;/on_crashgt;
+lt;devicesgt;
+  lt;disk type='file' device='disk'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/guest_hdd.img'/gt;
+lt;target dev='hda' bus='sata'/gt;
+  lt;/diskgt;
+  lt;disk type='file' device='cdrom'gt;
+lt;driver name='file' type='raw'/gt;
+lt;source file='/path/to/cdrom.iso'/gt;
+lt;target dev='hdc' bus='sata'/gt;
+lt;readonly/gt;
+  lt;/diskgt;
+  lt;interface type='bridge'gt;
+lt;model type='virtio'/gt;
+lt;source bridge=virbr0/gt;
+  lt;/interfacegt;
+lt;/devicesgt;
+lt;/domaingt;
+/pre
 
 h2a name=usageGuest usage / management/a/h2
 
@@ -119,6 +177,14 @@ to let a guest boot or start a guest using:/p
 
 prestart --console domname/pre
 
+pbNB:/b An interactive bootloader will keep the domain from starting (and
+thus codevirsh console/code or codestart --console/code) until the
+console is opened by a client. To select a boot option and allow the domain to
+finish starting, one must use an alternative terminal client to connect to the
+null modem device. One example is:/p
+
+precu -l /dev/nmdm0B/pre
+
 h3a name=xmltonativeConverting from domain XML to Bhyve args/a/h3
 
 p
@@ -157,5 +223,25 @@ An example of domain XML device entry for that will look 
like:/p
 pPlease refer to the a href=storage.htmlStorage documentation/a for 
more details on storage
 management./p

[libvirt] [PATCHv3 0/2] Add non-FreeBSD guest support to Bhyve driver.

2014-10-24 Thread Conrad Meyer
Drvbhyve hardcodes bhyveload(8) as the host bootloader for guests.
bhyveload(8) loader only supports FreeBSD guests.

This patch adds bootloader and bootloader_args handling to
bhyve_command, so libvirt can boot non-FreeBSD guests in Bhyve.

See patch logs for further details.

Thanks,
Conrad

Changelog:
v3:
  - Based on latest git as of less than an hour ago; tested HDD booting a Linux
guest several times.
  - Added first cut at CD booting. I'm not sure grub-bhyve supports this
(was not able to to test it).
  - make 'syntax-check' clean
  - Per Roman (off-list), split up virBhyveProcessBuildLoadCmd into a few
smaller functions.
  - Also per Roman (off-list), use virCommandAddArgSet() for bootloader_args.
(Without the nasty cast, my compiler complains.)
v2:
  - Dropped hvm - xen change per Peter's feedback.


Conrad Meyer (2):
  bhyve: Support /domain/bootloader configuration for non-FreeBSD
guests.
  Generated PO files for 'bhyve: Support /domain/bootloader'

 docs/drvbhyve.html.in |  28 ++-
 docs/formatdomain.html.in |   4 +-
 po/af.po  |   5 ++
 po/am.po  |   5 ++
 po/ar.po  |   5 ++
 po/as.po  |   5 ++
 po/be.po  |   5 ++
 po/bg.po  |   5 ++
 po/bn.po  |   5 ++
 po/bn_IN.po   |   5 ++
 po/bo.po  |   5 ++
 po/bs.po  |   5 ++
 po/ca.po  |   5 ++
 po/cs.po  |   5 ++
 po/cy.po  |   5 ++
 po/da.po  |   5 ++
 po/de.po  |   5 ++
 po/el.po  |   5 ++
 po/en_GB.po   |   5 ++
 po/es.po  |   5 ++
 po/et.po  |   5 ++
 po/eu_ES.po   |   5 ++
 po/fa.po  |   5 ++
 po/fi.po  |   5 ++
 po/fr.po  |   5 ++
 po/gl.po  |   5 ++
 po/gu.po  |   5 ++
 po/he.po  |   5 ++
 po/hi.po  |   5 ++
 po/hr.po  |   5 ++
 po/hu.po  |   5 ++
 po/hy.po  |   5 ++
 po/id.po  |   5 ++
 po/is.po  |   5 ++
 po/it.po  |   5 ++
 po/ja.po  |   5 ++
 po/ka.po  |   5 ++
 po/kn.po  |   5 ++
 po/ko.po  |   5 ++
 po/ku.po  |   5 ++
 po/libvirt.pot|   5 ++
 po/lo.po  |   5 ++
 po/lt.po  |   5 ++
 po/lv.po  |   5 ++
 po/mk.po  |   5 ++
 po/ml.po  |   5 ++
 po/mr.po  |   5 ++
 po/ms.po  |   5 ++
 po/my.po  |   5 ++
 po/nb.po  |   5 ++
 po/nl.po  |   5 ++
 po/nn.po  |   5 ++
 po/nso.po |   5 ++
 po/or.po  |   5 ++
 po/pa.po  |   5 ++
 po/pl.po  |   5 ++
 po/pt.po  |   5 ++
 po/pt_BR.po   |   5 ++
 po/ro.po  |   5 ++
 po/ru.po  |   5 ++
 po/si.po  |   5 ++
 po/sk.po  |   5 ++
 po/sl.po  |   5 ++
 po/sq.po  |   5 ++
 po/sr.po  |   5 ++
 po/s...@latin.po|   5 ++
 po/sv.po  |   5 ++
 po/ta.po  |   5 ++
 po/te.po  |   5 ++
 po/th.po  |   5 ++
 po/tr.po  |   5 ++
 po/uk.po  |   5 ++
 po/ur.po  |   5 ++
 po/vi.po  |   5 ++
 po/vi_VN.po   |   5 ++
 po/zh_CN.po   |   5 ++
 po/zh_TW.po   |   5 ++
 po/zu.po  |   5 ++
 src/bhyve/bhyve_command.c | 204 ++
 src/bhyve/bhyve_driver.c  |   5 ++
 src/bhyve/bhyve_process.c |   5 ++
 src/bhyve/bhyve_utils.h   |   1 +
 82 files changed, 604 insertions(+), 23 deletions(-)

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv3 2/2] Generated PO files for 'bhyve: Support /domain/bootloader'

2014-10-24 Thread Conrad Meyer
Sponsored by:   EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 po/af.po   | 5 +
 po/am.po   | 5 +
 po/ar.po   | 5 +
 po/as.po   | 5 +
 po/be.po   | 5 +
 po/bg.po   | 5 +
 po/bn.po   | 5 +
 po/bn_IN.po| 5 +
 po/bo.po   | 5 +
 po/bs.po   | 5 +
 po/ca.po   | 5 +
 po/cs.po   | 5 +
 po/cy.po   | 5 +
 po/da.po   | 5 +
 po/de.po   | 5 +
 po/el.po   | 5 +
 po/en_GB.po| 5 +
 po/es.po   | 5 +
 po/et.po   | 5 +
 po/eu_ES.po| 5 +
 po/fa.po   | 5 +
 po/fi.po   | 5 +
 po/fr.po   | 5 +
 po/gl.po   | 5 +
 po/gu.po   | 5 +
 po/he.po   | 5 +
 po/hi.po   | 5 +
 po/hr.po   | 5 +
 po/hu.po   | 5 +
 po/hy.po   | 5 +
 po/id.po   | 5 +
 po/is.po   | 5 +
 po/it.po   | 5 +
 po/ja.po   | 5 +
 po/ka.po   | 5 +
 po/kn.po   | 5 +
 po/ko.po   | 5 +
 po/ku.po   | 5 +
 po/libvirt.pot | 1 +
 po/lo.po   | 5 +
 po/lt.po   | 5 +
 po/lv.po   | 5 +
 po/mk.po   | 5 +
 po/ml.po   | 5 +
 po/mr.po   | 5 +
 po/ms.po   | 5 +
 po/my.po   | 5 +
 po/nb.po   | 5 +
 po/nl.po   | 5 +
 po/nn.po   | 5 +
 po/nso.po  | 5 +
 po/or.po   | 5 +
 po/pa.po   | 5 +
 po/pl.po   | 5 +
 po/pt.po   | 5 +
 po/pt_BR.po| 5 +
 po/ro.po   | 5 +
 po/ru.po   | 5 +
 po/si.po   | 5 +
 po/sk.po   | 5 +
 po/sl.po   | 5 +
 po/sq.po   | 5 +
 po/sr.po   | 5 +
 po/s...@latin.po | 5 +
 po/sv.po   | 5 +
 po/ta.po   | 5 +
 po/te.po   | 5 +
 po/th.po   | 5 +
 po/tr.po   | 5 +
 po/uk.po   | 5 +
 po/ur.po   | 5 +
 po/vi.po   | 5 +
 po/vi_VN.po| 5 +
 po/zh_CN.po| 5 +
 po/zh_TW.po| 5 +
 po/zu.po   | 5 +
 76 files changed, 376 insertions(+)

diff --git a/po/af.po b/po/af.po
index 0e1374d..75b1970 100644
--- a/po/af.po
+++ b/po/af.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
@@ -1047,6 +1051,7 @@ msgid cannot get host CPU capabilities
 msgstr 
 
 #: src/bhyve/bhyve_process.c:115 src/lxc/lxc_process.c:1179
+#: src/bhyve/bhyve_command.c:383
 #, c-format
 msgid Failed to open '%s'
 msgstr 
diff --git a/po/am.po b/po/am.po
index 8230ec8..223f577 100644
--- a/po/am.po
+++ b/po/am.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
@@ -1047,6 +1051,7 @@ msgid cannot get host CPU capabilities
 msgstr 
 
 #: src/bhyve/bhyve_process.c:115 src/lxc/lxc_process.c:1179
+#: src/bhyve/bhyve_command.c:383
 #, c-format
 msgid Failed to open '%s'
 msgstr 
diff --git a/po/ar.po b/po/ar.po
index fed8f1f..4c684de 100644
--- a/po/ar.po
+++ b/po/ar.po
@@ -854,6 +854,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
@@ -1048,6 +1052,7 @@ msgid cannot get host CPU capabilities
 msgstr 
 
 #: src/bhyve/bhyve_process.c:115 src/lxc/lxc_process.c:1179
+#: src/bhyve/bhyve_command.c:383
 #, c-format
 msgid Failed to open '%s'
 msgstr 
diff --git a/po/as.po b/po/as.po
index b2bba9a..8ee3656 100644
--- a/po/as.po
+++ b/po/as.po
@@ -915,6 +915,10 @@ msgstr উৎস পথৰ অবিহনে cdrom ডিভাইচ সম
 msgid domain should have at least one disk defined
 msgstr ডমেইনৰ অন্তত এটা ডিস্ক বিৱৰিত থাকিব লাগিব
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr PCI বাচ 0 স্লট 1 ইমপ্লিচিট LPC PCI-ISA ব্ৰিজৰ বাবে সংৰক্ষিত
@@ -1108,6 +1112,7 @@ msgid cannot get host CPU capabilities
 msgstr হোস্ট CPU ৰ ক্ষমতা প্ৰাপ্ত কৰা সম্ভৱ নহয়
 
 #: src/bhyve/bhyve_process.c:115 src/lxc/lxc_process.c:1179
+#: src/bhyve/bhyve_command.c:383
 #, c-format
 msgid Failed to open '%s'
 msgstr '%s' খুলিবলৈ ব্যৰ্থ
diff --git a/po/be.po b/po/be.po
index 1f4b856..09f04b0 100644
--- a/po/be.po
+++ b/po/be.po
@@ -854,6 +854,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom

[libvirt] [PATCHv3 1/2] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-24 Thread Conrad Meyer
We still default to bhyveloader(1) if no explicit bootloader
configuration is supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk (or a CD if one exists).

Caveat: Assumes the HDD boots from the msdos1 partition. I think this is
a pretty reasonable assumption for a VM. (DrvBhyve with Bhyveload
already assumes that the first disk should be booted.)

I've tested the HDD boot and it seems to work.

Sponsored by:   EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 docs/drvbhyve.html.in |  28 ++-
 docs/formatdomain.html.in |   4 +-
 po/libvirt.pot|   4 +
 src/bhyve/bhyve_command.c | 204 ++
 src/bhyve/bhyve_driver.c  |   5 ++
 src/bhyve/bhyve_process.c |   5 ++
 src/bhyve/bhyve_utils.h   |   1 +
 7 files changed, 228 insertions(+), 23 deletions(-)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 39afdf5..6e85800 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
tunnelled)
 h3Example config/h3
 p
 The bhyve driver in libvirt is in its early stage and under active 
development. So it supports
-only limited number of features bhyve provides. All the supported features 
could be found
-in this sample domain XML.
+only limited number of features bhyve provides.
 /p
 
 p
@@ -50,8 +49,8 @@ up to 31 PCI devices.
 
 pre
 lt;domain type='bhyve'gt;
-  lt;namegt;bhyvelt;/namegt;
-  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;namegt;bhyvelt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 lt;memorygt;219136lt;/memorygt;
 lt;currentMemorygt;219136lt;/currentMemorygt;
 lt;vcpugt;1lt;/vcpugt;
@@ -157,5 +156,26 @@ An example of domain XML device entry for that will look 
like:/p
 pPlease refer to the a href=storage.htmlStorage documentation/a for 
more details on storage
 management./p
 
+h3a name=grubbhyveUsing grub2-bhyve or Alternative Bootloaders/a/h3
+
+pIt's possible to boot non-FreeBSD guests by specifying an explicit
+bootloader, e.g. codegrub-bhyve(1)/code. Arguments to the bootloader may be
+specified as well. If no arguments are given and bootloader is
+codegrub-bhyve/code, libvirt will try and boot from the first partition of
+the disk image./p
+
+pre
+  ...
+lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
+lt;bootloader_argsgt;...lt;/bootloader_argsgt;
+  ...
+/pre
+
+p(Of course, to install from a CD a user will have to supply explicit
+arguments to codegrub-bhyve/code.)/p
+
+pCaveat: codebootloader_args/code does not support any quoting.
+Filenames, etc, must not have spaces or they will be tokenized incorrectly./p
+
   /body
 /html
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0099ce7..b7b6c46 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -217,7 +217,9 @@
   a BIOS, and instead the host is responsible to kicking off the
   operating system boot. This may use a pseudo-bootloader in the
   host to provide an interface to choose a kernel for the guest.
-  An example is codepygrub/code with Xen.
+  An example is codepygrub/code with Xen. The Bhyve hypervisor
+  also uses a host bootloader, either codebhyveload/code or
+  codegrub-bhyve/code.
 /p
 
 pre
diff --git a/po/libvirt.pot b/po/libvirt.pot
index 0b44ad7..d8c9a4d 100644
--- a/po/libvirt.pot
+++ b/po/libvirt.pot
@@ -851,6 +851,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index bea4a59..fcaf077 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -26,6 +26,7 @@
 #include net/if_tap.h
 
 #include bhyve_command.h
+#include datatypes.h
 #include viralloc.h
 #include virfile.h
 #include virstring.h
@@ -294,51 +295,218 @@ virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver 
ATTRIBUTE_UNUSED,
 return cmd;
 }
 
-virCommandPtr
-virBhyveProcessBuildLoadCmd(virConnectPtr conn,
-virDomainDefPtr def)
+static virCommandPtr
+virBhyveProcessBuildBhyveloadCmd(virDomainDefPtr def, virDomainDiskDefPtr disk)
 {
 virCommandPtr cmd;
-virDomainDiskDefPtr disk;
+char **blargs;
 
-if (def-ndisks  1) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(domain should have at least one disk defined));
+cmd = virCommandNew(BHYVELOAD);
+
+if (def-os.bootloaderArgs == NULL) {
+VIR_DEBUG(%s: bhyveload with default arguments, __func__

[libvirt] [PATCH 1/2] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-23 Thread Conrad Meyer
Also, flip Bhyve /domain/os/type support from HVM to Xen. Bhyve only
supports paravirtualized guests, and 'xen' is closest to that. We still
default to bhyveloader(1) if no explicit bootloader configuration is
supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk.

Caveats:
  - We can't install from CD without explicit bootloader_args.
  - We leave a device.map file lying around in /tmp. I don't see a good
way not to do so without reworking the API somewhat.

Sponsored by:   EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 docs/drvbhyve.html.in  |  30 +-
 docs/formatdomain.html.in  |   4 +-
 po/libvirt.pot |   4 +
 src/bhyve/bhyve_capabilities.c |   2 +-
 src/bhyve/bhyve_command.c  | 107 +++--
 tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.xml |   2 +-
 tests/bhyvexml2argvdata/bhyvexml2argv-base.xml |   2 +-
 tests/bhyvexml2argvdata/bhyvexml2argv-console.xml  |   2 +-
 .../bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.xml |   2 +-
 .../bhyvexml2argv-disk-virtio.xml  |   2 +-
 tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.xml  |   2 +-
 tests/bhyvexml2argvdata/bhyvexml2argv-metadata.xml |   2 +-
 tests/bhyvexml2argvdata/bhyvexml2argv-serial.xml   |   2 +-
 .../bhyvexml2xmlout-metadata.xml   |   2 +-
 14 files changed, 139 insertions(+), 26 deletions(-)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 39afdf5..c6c79d7 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
tunnelled)
 h3Example config/h3
 p
 The bhyve driver in libvirt is in its early stage and under active 
development. So it supports
-only limited number of features bhyve provides. All the supported features 
could be found
-in this sample domain XML.
+only limited number of features bhyve provides.
 /p
 
 p
@@ -50,13 +49,13 @@ up to 31 PCI devices.
 
 pre
 lt;domain type='bhyve'gt;
-  lt;namegt;bhyvelt;/namegt;
-  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;namegt;bhyvelt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 lt;memorygt;219136lt;/memorygt;
 lt;currentMemorygt;219136lt;/currentMemorygt;
 lt;vcpugt;1lt;/vcpugt;
 lt;osgt;
-   lt;typegt;hvmlt;/typegt;
+   lt;typegt;xenlt;/typegt;
 lt;/osgt;
 lt;featuresgt;
   lt;apic/gt;
@@ -157,5 +156,26 @@ An example of domain XML device entry for that will look 
like:/p
 pPlease refer to the a href=storage.htmlStorage documentation/a for 
more details on storage
 management./p
 
+h3a name=grubbhyveUsing grub2-bhyve or Alternative Bootloaders/a/h3
+
+pIt's possible to boot non-FreeBSD guests by specifying an explicit
+bootloader, e.g. codegrub-bhyve(1)/code. Arguments to the bootloader may be
+specified as well. If no arguments are given and bootloader is
+codegrub-bhyve/code, libvirt will try and boot from the first partition of
+the disk image./p
+
+pre
+  ...
+lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
+lt;bootloader_argsgt;...lt;/bootloader_argsgt;
+  ...
+/pre
+
+p(Of course, to install from a CD a user will have to supply explicit
+arguments to codegrub-bhyve/code.)/p
+
+pCaveat: codebootloader_args/code does not support any quoting.
+Filenames, etc, must not have spaces or they will be tokenized incorrectly./p
+
   /body
 /html
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0099ce7..b7b6c46 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -217,7 +217,9 @@
   a BIOS, and instead the host is responsible to kicking off the
   operating system boot. This may use a pseudo-bootloader in the
   host to provide an interface to choose a kernel for the guest.
-  An example is codepygrub/code with Xen.
+  An example is codepygrub/code with Xen. The Bhyve hypervisor
+  also uses a host bootloader, either codebhyveload/code or
+  codegrub-bhyve/code.
 /p
 
 pre
diff --git a/po/libvirt.pot b/po/libvirt.pot
index 0b44ad7..d8c9a4d 100644
--- a/po/libvirt.pot
+++ b/po/libvirt.pot
@@ -851,6 +851,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 132ce91..b37a24f 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -85,7 +85,7 @@ virBhyveCapsBuild(void)
false

[libvirt] [PATCH 0/2] Add non-FreeBSD guest support to Bhyve driver.

2014-10-23 Thread Conrad Meyer
First-time libvirt contributor here. Apologies if I've made beginner mistakes,
etc. If something needs fixing, please let me know and I'll try and take care
of it expediently.

First, the bhyve driver expected and assumed an OS type of 'hvm'. I think this
was incorrect. Bhyve does not provide a BIOS API and instead uses a host
bootloader to paravirtualize guests.

This patch changes the OS type Bhyve expects to 'xen' and updates tests to
match.

Second, drvbhyve hardcodes bhyveload(8) as the host bootloader for guests.
bhyveload(8) loader only supports FreeBSD guests.

This patch adds bootloader and bootloader_args handling to bhyve_command,
so libvirt can boot non-FreeBSD guests in Bhyve.

See patch logs for further details.

Thanks,
Conrad


Conrad Meyer (2):
  bhyve: Support /domain/bootloader configuration for non-FreeBSD
guests.
  Generated PO files for 'bhyve: Support /domain/bootloader'

 docs/drvbhyve.html.in  |  30 +-
 docs/formatdomain.html.in  |   4 +-
 po/af.po   |   4 +
 po/am.po   |   4 +
 po/ar.po   |   4 +
 po/as.po   |   4 +
 po/be.po   |   4 +
 po/bg.po   |   4 +
 po/bn.po   |   4 +
 po/bn_IN.po|   4 +
 po/bo.po   |   4 +
 po/bs.po   |   4 +
 po/ca.po   |   4 +
 po/cs.po   |   4 +
 po/cy.po   |   4 +
 po/da.po   |   4 +
 po/de.po   |   4 +
 po/el.po   |   4 +
 po/en_GB.po|   4 +
 po/es.po   |   4 +
 po/et.po   |   4 +
 po/eu_ES.po|   4 +
 po/fa.po   |   4 +
 po/fi.po   |   4 +
 po/fr.po   |   4 +
 po/gl.po   |   4 +
 po/gu.po   |   4 +
 po/he.po   |   4 +
 po/hi.po   |   4 +
 po/hr.po   |   4 +
 po/hu.po   |   4 +
 po/hy.po   |   4 +
 po/id.po   |   4 +
 po/is.po   |   4 +
 po/it.po   |   4 +
 po/ja.po   |   4 +
 po/ka.po   |   4 +
 po/kn.po   |   4 +
 po/ko.po   |   4 +
 po/ku.po   |   4 +
 po/libvirt.pot |   4 +
 po/lo.po   |   4 +
 po/lt.po   |   4 +
 po/lv.po   |   4 +
 po/mk.po   |   4 +
 po/ml.po   |   4 +
 po/mr.po   |   4 +
 po/ms.po   |   4 +
 po/my.po   |   4 +
 po/nb.po   |   4 +
 po/nl.po   |   4 +
 po/nn.po   |   4 +
 po/nso.po  |   4 +
 po/or.po   |   4 +
 po/pa.po   |   4 +
 po/pl.po   |   4 +
 po/pt.po   |   4 +
 po/pt_BR.po|   4 +
 po/ro.po   |   4 +
 po/ru.po   |   4 +
 po/si.po   |   4 +
 po/sk.po   |   4 +
 po/sl.po   |   4 +
 po/sq.po   |   4 +
 po/sr.po   |   4 +
 po/s...@latin.po |   4 +
 po/sv.po   |   4 +
 po/ta.po   |   4

[libvirt] [PATCH 2/2] Generated PO files for 'bhyve: Support /domain/bootloader'

2014-10-23 Thread Conrad Meyer
Sponsored by:   EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 po/af.po   | 4 
 po/am.po   | 4 
 po/ar.po   | 4 
 po/as.po   | 4 
 po/be.po   | 4 
 po/bg.po   | 4 
 po/bn.po   | 4 
 po/bn_IN.po| 4 
 po/bo.po   | 4 
 po/bs.po   | 4 
 po/ca.po   | 4 
 po/cs.po   | 4 
 po/cy.po   | 4 
 po/da.po   | 4 
 po/de.po   | 4 
 po/el.po   | 4 
 po/en_GB.po| 4 
 po/es.po   | 4 
 po/et.po   | 4 
 po/eu_ES.po| 4 
 po/fa.po   | 4 
 po/fi.po   | 4 
 po/fr.po   | 4 
 po/gl.po   | 4 
 po/gu.po   | 4 
 po/he.po   | 4 
 po/hi.po   | 4 
 po/hr.po   | 4 
 po/hu.po   | 4 
 po/hy.po   | 4 
 po/id.po   | 4 
 po/is.po   | 4 
 po/it.po   | 4 
 po/ja.po   | 4 
 po/ka.po   | 4 
 po/kn.po   | 4 
 po/ko.po   | 4 
 po/ku.po   | 4 
 po/lo.po   | 4 
 po/lt.po   | 4 
 po/lv.po   | 4 
 po/mk.po   | 4 
 po/ml.po   | 4 
 po/mr.po   | 4 
 po/ms.po   | 4 
 po/my.po   | 4 
 po/nb.po   | 4 
 po/nl.po   | 4 
 po/nn.po   | 4 
 po/nso.po  | 4 
 po/or.po   | 4 
 po/pa.po   | 4 
 po/pl.po   | 4 
 po/pt.po   | 4 
 po/pt_BR.po| 4 
 po/ro.po   | 4 
 po/ru.po   | 4 
 po/si.po   | 4 
 po/sk.po   | 4 
 po/sl.po   | 4 
 po/sq.po   | 4 
 po/sr.po   | 4 
 po/s...@latin.po | 4 
 po/sv.po   | 4 
 po/ta.po   | 4 
 po/te.po   | 4 
 po/th.po   | 4 
 po/tr.po   | 4 
 po/uk.po   | 4 
 po/ur.po   | 4 
 po/vi.po   | 4 
 po/vi_VN.po| 4 
 po/zh_CN.po| 4 
 po/zh_TW.po| 4 
 po/zu.po   | 4 
 75 files changed, 300 insertions(+)

diff --git a/po/af.po b/po/af.po
index 0e1374d..6e54827 100644
--- a/po/af.po
+++ b/po/af.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/am.po b/po/am.po
index 8230ec8..c664b6b 100644
--- a/po/am.po
+++ b/po/am.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/ar.po b/po/ar.po
index fed8f1f..3745c56 100644
--- a/po/ar.po
+++ b/po/ar.po
@@ -854,6 +854,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/as.po b/po/as.po
index b2bba9a..1e8ecad 100644
--- a/po/as.po
+++ b/po/as.po
@@ -915,6 +915,10 @@ msgstr উৎস পথৰ অবিহনে cdrom ডিভাইচ সম
 msgid domain should have at least one disk defined
 msgstr ডমেইনৰ অন্তত এটা ডিস্ক বিৱৰিত থাকিব লাগিব
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr PCI বাচ 0 স্লট 1 ইমপ্লিচিট LPC PCI-ISA ব্ৰিজৰ বাবে সংৰক্ষিত
diff --git a/po/be.po b/po/be.po
index 1f4b856..3b5ff79 100644
--- a/po/be.po
+++ b/po/be.po
@@ -854,6 +854,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/bg.po b/po/bg.po
index 05d9e5d..0d75cb5 100644
--- a/po/bg.po
+++ b/po/bg.po
@@ -855,6 +855,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/bn.po b/po/bn.po
index ab15fc4..3c8cf38 100644
--- a/po/bn.po
+++ b/po/bn.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/bn_IN.po b/po/bn_IN.po
index 88dd968

[libvirt] [PATCHv2 1/2] bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

2014-10-23 Thread Conrad Meyer
We still default to bhyveloader(1) if no explicit bootloader
configuration is supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk.

Caveats:
- We can't install from CD without explicit bootloader_args.
- We leave a device.map file lying around in /tmp. I don't see a good
  way not to do so without reworking the API somewhat.

Sponsored by:   EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 docs/drvbhyve.html.in |  28 ++--
 docs/formatdomain.html.in |   4 +-
 po/libvirt.pot|   4 ++
 src/bhyve/bhyve_command.c | 107 +-
 4 files changed, 128 insertions(+), 15 deletions(-)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 39afdf5..6e85800 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -37,8 +37,7 @@ bhyve+ssh://r...@example.com/system (remote access, SSH 
tunnelled)
 h3Example config/h3
 p
 The bhyve driver in libvirt is in its early stage and under active 
development. So it supports
-only limited number of features bhyve provides. All the supported features 
could be found
-in this sample domain XML.
+only limited number of features bhyve provides.
 /p
 
 p
@@ -50,8 +49,8 @@ up to 31 PCI devices.
 
 pre
 lt;domain type='bhyve'gt;
-  lt;namegt;bhyvelt;/namegt;
-  lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
+lt;namegt;bhyvelt;/namegt;
+lt;uuidgt;df3be7e7-a104-11e3-aeb0-50e5492bd3dclt;/uuidgt;
 lt;memorygt;219136lt;/memorygt;
 lt;currentMemorygt;219136lt;/currentMemorygt;
 lt;vcpugt;1lt;/vcpugt;
@@ -157,5 +156,26 @@ An example of domain XML device entry for that will look 
like:/p
 pPlease refer to the a href=storage.htmlStorage documentation/a for 
more details on storage
 management./p
 
+h3a name=grubbhyveUsing grub2-bhyve or Alternative Bootloaders/a/h3
+
+pIt's possible to boot non-FreeBSD guests by specifying an explicit
+bootloader, e.g. codegrub-bhyve(1)/code. Arguments to the bootloader may be
+specified as well. If no arguments are given and bootloader is
+codegrub-bhyve/code, libvirt will try and boot from the first partition of
+the disk image./p
+
+pre
+  ...
+lt;bootloadergt;/usr/local/sbin/grub-bhyvelt;/bootloadergt;
+lt;bootloader_argsgt;...lt;/bootloader_argsgt;
+  ...
+/pre
+
+p(Of course, to install from a CD a user will have to supply explicit
+arguments to codegrub-bhyve/code.)/p
+
+pCaveat: codebootloader_args/code does not support any quoting.
+Filenames, etc, must not have spaces or they will be tokenized incorrectly./p
+
   /body
 /html
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0099ce7..b7b6c46 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -217,7 +217,9 @@
   a BIOS, and instead the host is responsible to kicking off the
   operating system boot. This may use a pseudo-bootloader in the
   host to provide an interface to choose a kernel for the guest.
-  An example is codepygrub/code with Xen.
+  An example is codepygrub/code with Xen. The Bhyve hypervisor
+  also uses a host bootloader, either codebhyveload/code or
+  codegrub-bhyve/code.
 /p
 
 pre
diff --git a/po/libvirt.pot b/po/libvirt.pot
index 0b44ad7..d8c9a4d 100644
--- a/po/libvirt.pot
+++ b/po/libvirt.pot
@@ -851,6 +851,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index bea4a59..99956ae 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -300,6 +300,7 @@ virBhyveProcessBuildLoadCmd(virConnectPtr conn,
 {
 virCommandPtr cmd;
 virDomainDiskDefPtr disk;
+bool bhyveload, grub_bhyve;
 
 if (def-ndisks  1) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
@@ -326,19 +327,105 @@ virBhyveProcessBuildLoadCmd(virConnectPtr conn,
 return NULL;
 }
 
-cmd = virCommandNew(BHYVELOAD);
+if (def-os.bootloader == NULL) {
+bhyveload = true;
+grub_bhyve = false;
+cmd = virCommandNew(BHYVELOAD);
+} else {
+bhyveload = false;
+if (strstr(def-os.bootloader, grub-bhyve) == 0)
+grub_bhyve = true;
+cmd = virCommandNew(def-os.bootloader);
+}
 
-/* Memory */
-virCommandAddArg(cmd, -m);
-virCommandAddArgFormat(cmd, %llu,
-   VIR_DIV_UP(def-mem.max_balloon, 1024));
+if (bhyveload  def-os.bootloaderArgs == NULL) {
+VIR_DEBUG(%s: bhyveload with default arguments, __func__);
+
+/* Memory (MB) */
+virCommandAddArg(cmd, -m

[libvirt] [PATCHv2 0/2] Add non-FreeBSD guest support to Bhyve driver.

2014-10-23 Thread Conrad Meyer
Drvbhyve hardcodes bhyveload(8) as the host bootloader for guests.
bhyveload(8) loader only supports FreeBSD guests.

This patch adds bootloader and bootloader_args handling to
bhyve_command, so libvirt can boot non-FreeBSD guests in Bhyve.

See patch logs for further details.

Thanks,
Conrad

Changelog:
v2:
  - Dropped hvm - xen change per Peter's feedback.

Conrad Meyer (2):
  bhyve: Support /domain/bootloader configuration for non-FreeBSD
guests.
  Generated PO files for 'bhyve: Support /domain/bootloader'

 docs/drvbhyve.html.in |  28 ++--
 docs/formatdomain.html.in |   4 +-
 po/af.po  |   4 ++
 po/am.po  |   4 ++
 po/ar.po  |   4 ++
 po/as.po  |   4 ++
 po/be.po  |   4 ++
 po/bg.po  |   4 ++
 po/bn.po  |   4 ++
 po/bn_IN.po   |   4 ++
 po/bo.po  |   4 ++
 po/bs.po  |   4 ++
 po/ca.po  |   4 ++
 po/cs.po  |   4 ++
 po/cy.po  |   4 ++
 po/da.po  |   4 ++
 po/de.po  |   4 ++
 po/el.po  |   4 ++
 po/en_GB.po   |   4 ++
 po/es.po  |   4 ++
 po/et.po  |   4 ++
 po/eu_ES.po   |   4 ++
 po/fa.po  |   4 ++
 po/fi.po  |   4 ++
 po/fr.po  |   4 ++
 po/gl.po  |   4 ++
 po/gu.po  |   4 ++
 po/he.po  |   4 ++
 po/hi.po  |   4 ++
 po/hr.po  |   4 ++
 po/hu.po  |   4 ++
 po/hy.po  |   4 ++
 po/id.po  |   4 ++
 po/is.po  |   4 ++
 po/it.po  |   4 ++
 po/ja.po  |   4 ++
 po/ka.po  |   4 ++
 po/kn.po  |   4 ++
 po/ko.po  |   4 ++
 po/ku.po  |   4 ++
 po/libvirt.pot|   4 ++
 po/lo.po  |   4 ++
 po/lt.po  |   4 ++
 po/lv.po  |   4 ++
 po/mk.po  |   4 ++
 po/ml.po  |   4 ++
 po/mr.po  |   4 ++
 po/ms.po  |   4 ++
 po/my.po  |   4 ++
 po/nb.po  |   4 ++
 po/nl.po  |   4 ++
 po/nn.po  |   4 ++
 po/nso.po |   4 ++
 po/or.po  |   4 ++
 po/pa.po  |   4 ++
 po/pl.po  |   4 ++
 po/pt.po  |   4 ++
 po/pt_BR.po   |   4 ++
 po/ro.po  |   4 ++
 po/ru.po  |   4 ++
 po/si.po  |   4 ++
 po/sk.po  |   4 ++
 po/sl.po  |   4 ++
 po/sq.po  |   4 ++
 po/sr.po  |   4 ++
 po/s...@latin.po|   4 ++
 po/sv.po  |   4 ++
 po/ta.po  |   4 ++
 po/te.po  |   4 ++
 po/th.po  |   4 ++
 po/tr.po  |   4 ++
 po/uk.po  |   4 ++
 po/ur.po  |   4 ++
 po/vi.po  |   4 ++
 po/vi_VN.po   |   4 ++
 po/zh_CN.po   |   4 ++
 po/zh_TW.po   |   4 ++
 po/zu.po  |   4 ++
 src/bhyve/bhyve_command.c | 107 +-
 79 files changed, 428 insertions(+), 15 deletions(-)

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv2 2/2] Generated PO files for 'bhyve: Support /domain/bootloader'

2014-10-23 Thread Conrad Meyer
Sponsored by:   EMC / Isilon storage division

Signed-off-by: Conrad Meyer conrad.me...@isilon.com
---
 po/af.po   | 4 
 po/am.po   | 4 
 po/ar.po   | 4 
 po/as.po   | 4 
 po/be.po   | 4 
 po/bg.po   | 4 
 po/bn.po   | 4 
 po/bn_IN.po| 4 
 po/bo.po   | 4 
 po/bs.po   | 4 
 po/ca.po   | 4 
 po/cs.po   | 4 
 po/cy.po   | 4 
 po/da.po   | 4 
 po/de.po   | 4 
 po/el.po   | 4 
 po/en_GB.po| 4 
 po/es.po   | 4 
 po/et.po   | 4 
 po/eu_ES.po| 4 
 po/fa.po   | 4 
 po/fi.po   | 4 
 po/fr.po   | 4 
 po/gl.po   | 4 
 po/gu.po   | 4 
 po/he.po   | 4 
 po/hi.po   | 4 
 po/hr.po   | 4 
 po/hu.po   | 4 
 po/hy.po   | 4 
 po/id.po   | 4 
 po/is.po   | 4 
 po/it.po   | 4 
 po/ja.po   | 4 
 po/ka.po   | 4 
 po/kn.po   | 4 
 po/ko.po   | 4 
 po/ku.po   | 4 
 po/lo.po   | 4 
 po/lt.po   | 4 
 po/lv.po   | 4 
 po/mk.po   | 4 
 po/ml.po   | 4 
 po/mr.po   | 4 
 po/ms.po   | 4 
 po/my.po   | 4 
 po/nb.po   | 4 
 po/nl.po   | 4 
 po/nn.po   | 4 
 po/nso.po  | 4 
 po/or.po   | 4 
 po/pa.po   | 4 
 po/pl.po   | 4 
 po/pt.po   | 4 
 po/pt_BR.po| 4 
 po/ro.po   | 4 
 po/ru.po   | 4 
 po/si.po   | 4 
 po/sk.po   | 4 
 po/sl.po   | 4 
 po/sq.po   | 4 
 po/sr.po   | 4 
 po/s...@latin.po | 4 
 po/sv.po   | 4 
 po/ta.po   | 4 
 po/te.po   | 4 
 po/th.po   | 4 
 po/tr.po   | 4 
 po/uk.po   | 4 
 po/ur.po   | 4 
 po/vi.po   | 4 
 po/vi_VN.po| 4 
 po/zh_CN.po| 4 
 po/zh_TW.po| 4 
 po/zu.po   | 4 
 75 files changed, 300 insertions(+)

diff --git a/po/af.po b/po/af.po
index 0e1374d..6e54827 100644
--- a/po/af.po
+++ b/po/af.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/am.po b/po/am.po
index 8230ec8..c664b6b 100644
--- a/po/am.po
+++ b/po/am.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/ar.po b/po/ar.po
index fed8f1f..3745c56 100644
--- a/po/ar.po
+++ b/po/ar.po
@@ -854,6 +854,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/as.po b/po/as.po
index b2bba9a..1e8ecad 100644
--- a/po/as.po
+++ b/po/as.po
@@ -915,6 +915,10 @@ msgstr উৎস পথৰ অবিহনে cdrom ডিভাইচ সম
 msgid domain should have at least one disk defined
 msgstr ডমেইনৰ অন্তত এটা ডিস্ক বিৱৰিত থাকিব লাগিব
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr PCI বাচ 0 স্লট 1 ইমপ্লিচিট LPC PCI-ISA ব্ৰিজৰ বাবে সংৰক্ষিত
diff --git a/po/be.po b/po/be.po
index 1f4b856..3b5ff79 100644
--- a/po/be.po
+++ b/po/be.po
@@ -854,6 +854,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/bg.po b/po/bg.po
index 05d9e5d..0d75cb5 100644
--- a/po/bg.po
+++ b/po/bg.po
@@ -855,6 +855,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/bn.po b/po/bn.po
index ab15fc4..3c8cf38 100644
--- a/po/bn.po
+++ b/po/bn.po
@@ -853,6 +853,10 @@ msgstr 
 msgid domain should have at least one disk defined
 msgstr 
 
+#: src/bhyve/bhyve_command.c:407
+msgid Custom loader requires explicit %s configuration
+msgstr 
+
 #: src/bhyve/bhyve_device.c:50
 msgid PCI bus 0 slot 1 is reserved for the implicit LPC PCI-ISA bridge
 msgstr 
diff --git a/po/bn_IN.po b/po/bn_IN.po
index 88dd968