]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: add virtio-console support
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sat, 28 Mar 2026 13:36:21 +0000 (14:36 +0100)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Sat, 2 May 2026 08:31:38 +0000 (10:31 +0200)
Bhyve supports virtio-console devices using the following syntax:

 -s 2:0,virtio-console,org.qemu.guest_agent.0=/path/to/unix/socket,other.port=/other/socket,...

There are two details about that to consider.

The first one is that only up to 16 ports per console is supported. This
is different from the default (31), so update the code to manually add
the virtio-serial controllers with 16 ports. For the existing
controllers, make sure to set max ports to 16 or error out if ports
count greater than 16 was specified.

The second one is that bhyve does not clean up UNIX sockets for these
devices. So update virBhyveProcessStop() to remove leftover sockets.

Not adding capabilities probing as the virtio-console device is
available on all supported FreeBSD versions and on all supported arches.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
29 files changed:
src/bhyve/bhyve_command.c
src/bhyve/bhyve_device.c
src/bhyve/bhyve_domain.c
src/bhyve/bhyve_process.c
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.args [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.args [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.args [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-invalid-name.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-invalid-path.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.args [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-too-many-ports.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.args [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.xml [new file with mode: 0644]
tests/bhyvexml2argvtest.c
tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-2-virtio-console-mixed-addr.xml [new file with mode: 0644]
tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-addr.xml [new file with mode: 0644]
tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-controllers.xml [new file with mode: 0644]
tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-multiple-controllers.xml [new file with mode: 0644]
tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console.xml [new file with mode: 0644]
tests/bhyvexml2xmltest.c

index 931d7dd551c73ef805962884697afcc120d7e06f..8671644cc8e0e941ae7efe692d9a4a5c6acf308f 100644 (file)
@@ -490,6 +490,43 @@ bhyveBuildNVMeControllerArgStr(const virDomainDef *def,
     return 0;
 }
 
+static int
+bhyveBuildVirtioSerialControllerArgStr(const virDomainDef *def,
+                                       virDomainControllerDef *controller,
+                                       struct _bhyveConn *driver G_GNUC_UNUSED,
+                                       virCommand *cmd)
+{
+    g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
+    size_t i;
+
+    for (i = 0; i < def->nchannels; i++) {
+        virDomainChrDef *channel = def->channels[i];
+
+        if (channel->info.addr.vioserial.controller != controller->idx)
+            continue;
+
+        if (channel->source->type != VIR_DOMAIN_CHR_TYPE_UNIX)
+            continue;
+
+        if (channel->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO)
+            continue;
+
+        virBufferAsprintf(&opt,
+                          ",%s=%s",
+                          channel->target.name,
+                          channel->source->data.nix.path);
+    }
+
+    if (virBufferUse(&opt) > 0) {
+        virCommandAddArg(cmd, "-s");
+        virCommandAddArgFormat(cmd, "%d:0,virtio-console%s",
+                               controller->info.addr.pci.slot,
+                               virBufferContentAndReset(&opt));
+    }
+
+    return 0;
+}
+
 static int
 bhyveBuildVirtIODiskArgStr(const virDomainDef *def G_GNUC_UNUSED,
                            virDomainDiskDef *disk,
@@ -606,9 +643,12 @@ bhyveBuildControllerArgStr(const virDomainDef *def,
         if (bhyveBuildNVMeControllerArgStr(def, controller, driver, cmd) < 0)
             return -1;
         break;
+    case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
+        if (bhyveBuildVirtioSerialControllerArgStr(def, controller, driver, cmd) < 0)
+            return -1;
+        break;
     case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
     case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
-    case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
     case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
     case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
     case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
index 54511383bb34a0330b362ac0913ab03530149858..cf3a9fa4fb2b71be8bb9a40201ea327602d93c85 100644 (file)
 
 VIR_LOG_INIT("bhyve.bhyve_device");
 
+
+static int
+bhyveDomainAssignVirtioSerialAddresses(virDomainDef *def)
+{
+    int ret = -1;
+    size_t i;
+    virDomainVirtioSerialAddrSet *addrs = NULL;
+
+    if (!(addrs = virDomainVirtioSerialAddrSetCreateFromDomain(def)))
+        goto cleanup;
+
+    VIR_DEBUG("Finished reserving existing ports");
+
+    for (i = 0; i < def->nchannels; i++) {
+        virDomainChrDef *chr = def->channels[i];
+        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
+            chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
+            !virDomainVirtioSerialAddrIsComplete(&chr->info) &&
+            virDomainVirtioSerialAddrAutoAssignFromCache(def, addrs,
+                                                         &chr->info, false) < 0)
+            goto cleanup;
+    }
+
+    ret = 0;
+
+ cleanup:
+    virDomainVirtioSerialAddrSetFree(addrs);
+    return ret;
+}
+
 static int
 bhyveCollectPCIAddress(virDomainDef *def G_GNUC_UNUSED,
                        virDomainDeviceDef *device G_GNUC_UNUSED,
@@ -39,7 +69,8 @@ bhyveCollectPCIAddress(virDomainDef *def G_GNUC_UNUSED,
 {
     virDomainPCIAddressSet *addrs = NULL;
     virPCIDeviceAddress *addr = NULL;
-    if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE)
+
+    if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
         return 0;
 
     addrs = opaque;
@@ -116,6 +147,7 @@ bhyveAssignDevicePCISlots(virDomainDef *def,
             (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) ||
             (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_NVME) ||
             (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) ||
+            (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) ||
             ((def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) &&
              (def->controllers[i]->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI)) ||
             def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA) {
@@ -242,5 +274,11 @@ int bhyveDomainAssignPCIAddresses(virDomainDef *def,
 
 int bhyveDomainAssignAddresses(virDomainDef *def, virDomainObj *obj)
 {
-    return bhyveDomainAssignPCIAddresses(def, obj);
+    if (bhyveDomainAssignVirtioSerialAddresses(def) < 0)
+        return -1;
+
+    if (bhyveDomainAssignPCIAddresses(def, obj) < 0)
+        return -1;
+
+    return 0;
 }
index 170f6edc56e62905503a687bc2f9c16798d655b3..484f7b9d6e45cb0ffe3de0903c06d0475a26b4fd 100644 (file)
@@ -29,6 +29,7 @@
 #include "viralloc.h"
 #include "virfile.h"
 #include "virlog.h"
+#include "virstring.h"
 #include "virutil.h"
 
 #define VIR_FROM_THIS VIR_FROM_BHYVE
@@ -89,6 +90,11 @@ bhyveDomainDefPostParse(virDomainDef *def,
 {
     struct _bhyveConn *driver = opaque;
     g_autoptr(virCaps) caps = bhyveDriverGetCapabilities(driver);
+    size_t i;
+    size_t virtio_channels = 0;
+    size_t virtio_serial_controllers = 0;
+    size_t virtio_serial_existing_controllers = 0;
+    size_t virtio_serial_controllers_to_create = 0;
     if (!caps)
         return -1;
 
@@ -141,6 +147,27 @@ bhyveDomainDefPostParse(virDomainDef *def,
         def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_ROM;
     }
 
+    for (i = 0; i < def->nchannels; i++)
+        if (def->channels[i]->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO)
+            virtio_channels++;
+
+    for (i = 0; i < def->ncontrollers; i++)
+        if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
+            virtio_serial_existing_controllers++;
+
+    /* bhyve supports 16 ports per virtio-console device */
+    virtio_serial_controllers = (virtio_channels / 16) + (virtio_channels % 16 != 0);
+    if (virtio_serial_controllers > virtio_serial_existing_controllers) {
+        virtio_serial_controllers_to_create = virtio_serial_controllers - virtio_serial_existing_controllers;
+
+        for (i = 0; i < virtio_serial_controllers_to_create; i++) {
+            virDomainControllerDef *cont;
+
+            cont = virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL, -1, -1);
+            cont->opts.vioserial.ports = 16;
+        }
+    }
+
     return 0;
 }
 
@@ -225,6 +252,10 @@ bhyveDomainDeviceDefPostParse(virDomainDeviceDef *dev,
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("pci-root and pcie-root controllers should have index 0"));
             return -1;
+        } else if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) {
+            /* bhyve supports 16 ports per controller */
+            if (cont->opts.vioserial.ports == -1)
+                cont->opts.vioserial.ports = 16;
         }
     }
 
@@ -287,13 +318,21 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                              void *parseOpaque G_GNUC_UNUSED)
 {
     switch (dev->type) {
-    case VIR_DOMAIN_DEVICE_CONTROLLER:
-        if (dev->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA &&
-            dev->data.controller->idx != 0) {
+    case VIR_DOMAIN_DEVICE_CONTROLLER: {
+        virDomainControllerDef *controller = dev->data.controller;
+
+        if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA &&
+            controller->idx != 0) {
             return -1;
+        } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) {
+            if (controller->opts.vioserial.ports > 16) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("Bhyve virtio-serial controller supports up to 16 ports"));
+                return -1;
+            }
         }
         break;
-
+    }
     case VIR_DOMAIN_DEVICE_RNG:
         if (dev->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO) {
             if (dev->data.rng->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM) {
@@ -314,9 +353,9 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         }
         break;
 
-    case VIR_DOMAIN_DEVICE_CHR:
-        if (dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
-            virDomainChrDef *chr = dev->data.chr;
+    case VIR_DOMAIN_DEVICE_CHR: {
+        virDomainChrDef *chr = dev->data.chr;
+        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
             if (chr->source->type != VIR_DOMAIN_CHR_TYPE_NMDM &&
                 chr->source->type != VIR_DOMAIN_CHR_TYPE_TCP) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -341,9 +380,24 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                     return -1;
                 }
             }
+        } else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
+                   chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
+                   chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
+            if (virStringHasChars(chr->target.name, ",")) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("Commas (',') are not allowed in channel names"));
+                    return -1;
+            }
+            if (chr->source->data.nix.path) {
+                if (virStringHasChars(chr->source->data.nix.path, ",")) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("Commas (',') are not allowed in UNIX socket paths"));
+                    return -1;
+                }
+            }
         }
         break;
-
+    }
     case VIR_DOMAIN_DEVICE_DISK: {
         virDomainDiskDef *disk = dev->data.disk;
 
index 842ff0d6fc4c0672dd98824c84f80d9849de7f9c..6078d995cd30757d8a5a3d808b53abf82645a2bb 100644 (file)
@@ -516,6 +516,7 @@ virBhyveProcessStop(struct _bhyveConn *driver,
                     virDomainShutoffReason reason)
 {
     int ret = 0;
+    size_t i = 0;
     g_autoptr(virCommand) cmd = NULL;
     bhyveDomainObjPrivate *priv = vm->privateData;
 
@@ -558,6 +559,19 @@ virBhyveProcessStop(struct _bhyveConn *driver,
         }
     }
 
+    /* UNIX sockets cleanup */
+    for (i = 0; i < vm->def->nchannels; i++) {
+        virDomainChrDef *channel = vm->def->channels[i];
+
+        if (channel->source->type != VIR_DOMAIN_CHR_TYPE_UNIX)
+            continue;
+        if (channel->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO)
+            continue;
+
+        if (virFileExists(channel->source->data.nix.path))
+            virFileRemove(channel->source->data.nix.path, 0, 0);
+    }
+
     virCloseCallbacksDomainRemove(vm, NULL, bhyveProcessAutoDestroy);
 
     virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.args b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.args
new file mode 100644 (file)
index 0000000..0942e75
--- /dev/null
@@ -0,0 +1,10 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 2:0,virtio-console,org.qemu.guest_agent.0=/var/run/libvirt/bhyve/bhyve.agent,org.qemu.guest_agent.1=/var/run/libvirt/bhyve/bhyve.agent-2 \
+-s 3:0,ahci,hd:/tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.ldargs b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.ldargs
new file mode 100644 (file)
index 0000000..5905f4b
--- /dev/null
@@ -0,0 +1,4 @@
+bhyveload \
+-m 214 \
+-d /tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-2-virtio-console-mixed-addr.xml
new file mode 100644 (file)
index 0000000..7df5749
--- /dev/null
@@ -0,0 +1,26 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-2'/>
+      <target type='virtio' name='org.qemu.guest_agent.1'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.args b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.args
new file mode 100644 (file)
index 0000000..b44c7b4
--- /dev/null
@@ -0,0 +1,10 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 1:0,ahci,hd:/tmp/freebsd.img \
+-s 2:0,virtio-console,org.qemu.guest_agent.0=/var/run/libvirt/bhyve/bhyve.agent \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.ldargs b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.ldargs
new file mode 100644 (file)
index 0000000..5905f4b
--- /dev/null
@@ -0,0 +1,4 @@
+bhyveload \
+-m 214 \
+-d /tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-addr.xml
new file mode 100644 (file)
index 0000000..519fec6
--- /dev/null
@@ -0,0 +1,25 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.args b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.args
new file mode 100644 (file)
index 0000000..939e5d6
--- /dev/null
@@ -0,0 +1,11 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 2:0,virtio-console,org.qemu.guest_agent.1=/var/run/libvirt/bhyve/bhyve.agent-1 \
+-s 3:0,virtio-console,org.qemu.guest_agent.2=/var/run/libvirt/bhyve/bhyve.agent-2 \
+-s 4:0,ahci,hd:/tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.ldargs b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.ldargs
new file mode 100644 (file)
index 0000000..5905f4b
--- /dev/null
@@ -0,0 +1,4 @@
+bhyveload \
+-m 214 \
+-d /tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-controllers.xml
new file mode 100644 (file)
index 0000000..2d82add
--- /dev/null
@@ -0,0 +1,31 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='virtio-serial' index='0' ports='4'>
+    </controller>
+    <controller type='virtio-serial' index='1'>
+    </controller>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-1'/>
+      <target type='virtio' name='org.qemu.guest_agent.1'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-2'/>
+      <target type='virtio' name='org.qemu.guest_agent.2'/>
+      <address type='virtio-serial' controller='1' bus='0' port='1'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-invalid-name.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-invalid-name.xml
new file mode 100644 (file)
index 0000000..d108115
--- /dev/null
@@ -0,0 +1,21 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent'/>
+      <target type='virtio' name='org.qemu.guest_agent,0'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-invalid-path.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-invalid-path.xml
new file mode 100644 (file)
index 0000000..c17e2c5
--- /dev/null
@@ -0,0 +1,21 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve,agent'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.args b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.args
new file mode 100644 (file)
index 0000000..e3d6b6d
--- /dev/null
@@ -0,0 +1,11 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 2:0,virtio-console,org.qemu.guest_agent.1=/var/run/libvirt/bhyve/bhyve.agent-1,org.qemu.guest_agent.2=/var/run/libvirt/bhyve/bhyve.agent-2,org.qemu.guest_agent.3=/var/run/libvirt/bhyve/bhyve.agent-3,org.qemu.guest_agent.4=/var/run/libvirt/bhyve/bhyve.agent-4,org.qemu.guest_agent.5=/var/run/libvirt/bhyve/bhyve.agent-5,org.qemu.guest_agent.6=/var/run/libvirt/bhyve/bhyve.agent-6,org.qemu.guest_agent.7=/var/run/libvirt/bhyve/bhyve.agent-7,org.qemu.guest_agent.8=/var/run/libvirt/bhyve/bhyve.agent-8,org.qemu.guest_agent.9=/var/run/libvirt/bhyve/bhyve.agent-9,org.qemu.guest_agent.10=/var/run/libvirt/bhyve/bhyve.agent-10,org.qemu.guest_agent.11=/var/run/libvirt/bhyve/bhyve.agent-11,org.qemu.guest_agent.12=/var/run/libvirt/bhyve/bhyve.agent-12,org.qemu.guest_agent.13=/var/run/libvirt/bhyve/bhyve.agent-13,org.qemu.guest_agent.14=/var/run/libvirt/bhyve/bhyve.agent-14,org.qemu.guest_agent.15=/var/run/libvirt/bhyve/bhyve.agent-15 \
+-s 3:0,virtio-console,org.qemu.guest_agent.16=/var/run/libvirt/bhyve/bhyve.agent-16,org.qemu.guest_agent.17=/var/run/libvirt/bhyve/bhyve.agent-17,org.qemu.guest_agent.18=/var/run/libvirt/bhyve/bhyve.agent-18 \
+-s 4:0,ahci,hd:/tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.ldargs b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.ldargs
new file mode 100644 (file)
index 0000000..5905f4b
--- /dev/null
@@ -0,0 +1,4 @@
+bhyveload \
+-m 214 \
+-d /tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-multiple-controllers.xml
new file mode 100644 (file)
index 0000000..b8dc39e
--- /dev/null
@@ -0,0 +1,89 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-1'/>
+      <target type='virtio' name='org.qemu.guest_agent.1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-2'/>
+      <target type='virtio' name='org.qemu.guest_agent.2'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-3'/>
+      <target type='virtio' name='org.qemu.guest_agent.3'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-4'/>
+      <target type='virtio' name='org.qemu.guest_agent.4'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-5'/>
+      <target type='virtio' name='org.qemu.guest_agent.5'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-6'/>
+      <target type='virtio' name='org.qemu.guest_agent.6'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-7'/>
+      <target type='virtio' name='org.qemu.guest_agent.7'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-8'/>
+      <target type='virtio' name='org.qemu.guest_agent.8'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-9'/>
+      <target type='virtio' name='org.qemu.guest_agent.9'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-10'/>
+      <target type='virtio' name='org.qemu.guest_agent.10'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-11'/>
+      <target type='virtio' name='org.qemu.guest_agent.11'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-12'/>
+      <target type='virtio' name='org.qemu.guest_agent.12'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-13'/>
+      <target type='virtio' name='org.qemu.guest_agent.13'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-14'/>
+      <target type='virtio' name='org.qemu.guest_agent.14'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-15'/>
+      <target type='virtio' name='org.qemu.guest_agent.15'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-16'/>
+      <target type='virtio' name='org.qemu.guest_agent.16'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-17'/>
+      <target type='virtio' name='org.qemu.guest_agent.17'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-18'/>
+      <target type='virtio' name='org.qemu.guest_agent.18'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-too-many-ports.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console-too-many-ports.xml
new file mode 100644 (file)
index 0000000..04ec8ab
--- /dev/null
@@ -0,0 +1,25 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='virtio-serial' index='0' ports='17'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.args b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.args
new file mode 100644 (file)
index 0000000..66f4905
--- /dev/null
@@ -0,0 +1,10 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 2:0,virtio-console,org.qemu.guest_agent.0=/var/run/libvirt/bhyve/bhyve.agent \
+-s 3:0,ahci,hd:/tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.ldargs b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.ldargs
new file mode 100644 (file)
index 0000000..5905f4b
--- /dev/null
@@ -0,0 +1,4 @@
+bhyveload \
+-m 214 \
+-d /tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-virtio-console.xml
new file mode 100644 (file)
index 0000000..f717884
--- /dev/null
@@ -0,0 +1,21 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+    </channel>
+  </devices>
+</domain>
index 71c67ba2a2a2fd3d52d3ede26e3495516f91e186..eb2c1d33b8ece5ce3c9458562246b03f46d3e22c 100644 (file)
@@ -293,6 +293,14 @@ mymain(void)
     DO_TEST_FAILURE("blkiotune-invalid-device");
     DO_TEST_FAILURE("blkiotune-multiple-devices");
     DO_TEST_FAILURE("blkiotune-weight");
+    DO_TEST("virtio-console");
+    DO_TEST("virtio-console-addr");
+    DO_TEST("2-virtio-console-mixed-addr");
+    DO_TEST("virtio-console-multiple-controllers");
+    DO_TEST("virtio-console-controllers");
+    DO_TEST_FAILURE("virtio-console-too-many-ports");
+    DO_TEST_FAILURE("virtio-console-invalid-name");
+    DO_TEST_FAILURE("virtio-console-invalid-path");
 
     /* Address allocation tests */
     DO_TEST("addr-single-sata-disk");
diff --git a/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-2-virtio-console-mixed-addr.xml b/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-2-virtio-console-mixed-addr.xml
new file mode 100644 (file)
index 0000000..7243d95
--- /dev/null
@@ -0,0 +1,40 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='virtio-serial' index='0' ports='16'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </controller>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-2'/>
+      <target type='virtio' name='org.qemu.guest_agent.1'/>
+      <address type='virtio-serial' controller='0' bus='0' port='2'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-addr.xml b/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-addr.xml
new file mode 100644 (file)
index 0000000..0873583
--- /dev/null
@@ -0,0 +1,35 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='virtio-serial' index='0' ports='16'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-controllers.xml b/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-controllers.xml
new file mode 100644 (file)
index 0000000..1fd1e1d
--- /dev/null
@@ -0,0 +1,43 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='virtio-serial' index='0' ports='4'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <controller type='virtio-serial' index='1' ports='16'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </controller>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-1'/>
+      <target type='virtio' name='org.qemu.guest_agent.1'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-2'/>
+      <target type='virtio' name='org.qemu.guest_agent.2'/>
+      <address type='virtio-serial' controller='1' bus='0' port='1'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-multiple-controllers.xml b/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console-multiple-controllers.xml
new file mode 100644 (file)
index 0000000..241828e
--- /dev/null
@@ -0,0 +1,123 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='virtio-serial' index='0' ports='16'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <controller type='virtio-serial' index='1' ports='16'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </controller>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </controller>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-1'/>
+      <target type='virtio' name='org.qemu.guest_agent.1'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-2'/>
+      <target type='virtio' name='org.qemu.guest_agent.2'/>
+      <address type='virtio-serial' controller='0' bus='0' port='2'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-3'/>
+      <target type='virtio' name='org.qemu.guest_agent.3'/>
+      <address type='virtio-serial' controller='0' bus='0' port='3'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-4'/>
+      <target type='virtio' name='org.qemu.guest_agent.4'/>
+      <address type='virtio-serial' controller='0' bus='0' port='4'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-5'/>
+      <target type='virtio' name='org.qemu.guest_agent.5'/>
+      <address type='virtio-serial' controller='0' bus='0' port='5'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-6'/>
+      <target type='virtio' name='org.qemu.guest_agent.6'/>
+      <address type='virtio-serial' controller='0' bus='0' port='6'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-7'/>
+      <target type='virtio' name='org.qemu.guest_agent.7'/>
+      <address type='virtio-serial' controller='0' bus='0' port='7'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-8'/>
+      <target type='virtio' name='org.qemu.guest_agent.8'/>
+      <address type='virtio-serial' controller='0' bus='0' port='8'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-9'/>
+      <target type='virtio' name='org.qemu.guest_agent.9'/>
+      <address type='virtio-serial' controller='0' bus='0' port='9'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-10'/>
+      <target type='virtio' name='org.qemu.guest_agent.10'/>
+      <address type='virtio-serial' controller='0' bus='0' port='10'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-11'/>
+      <target type='virtio' name='org.qemu.guest_agent.11'/>
+      <address type='virtio-serial' controller='0' bus='0' port='11'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-12'/>
+      <target type='virtio' name='org.qemu.guest_agent.12'/>
+      <address type='virtio-serial' controller='0' bus='0' port='12'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-13'/>
+      <target type='virtio' name='org.qemu.guest_agent.13'/>
+      <address type='virtio-serial' controller='0' bus='0' port='13'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-14'/>
+      <target type='virtio' name='org.qemu.guest_agent.14'/>
+      <address type='virtio-serial' controller='0' bus='0' port='14'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-15'/>
+      <target type='virtio' name='org.qemu.guest_agent.15'/>
+      <address type='virtio-serial' controller='0' bus='0' port='15'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-16'/>
+      <target type='virtio' name='org.qemu.guest_agent.16'/>
+      <address type='virtio-serial' controller='1' bus='0' port='1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-17'/>
+      <target type='virtio' name='org.qemu.guest_agent.17'/>
+      <address type='virtio-serial' controller='1' bus='0' port='2'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent-18'/>
+      <target type='virtio' name='org.qemu.guest_agent.18'/>
+      <address type='virtio-serial' controller='1' bus='0' port='3'/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console.xml b/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-virtio-console.xml
new file mode 100644 (file)
index 0000000..ec82054
--- /dev/null
@@ -0,0 +1,35 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='virtio-serial' index='0' ports='16'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </controller>
+    <channel type='unix'>
+      <source mode='bind' path='/var/run/libvirt/bhyve/bhyve.agent'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+  </devices>
+</domain>
index 9fa8a9765dd368ea362fc6f2b724ad2883b37684..120bdd42e5a811397dd17be6a4dd234091aa8c74 100644 (file)
@@ -137,6 +137,14 @@ mymain(void)
     DO_TEST_FAILURE("blkiotune-invalid-device");
     DO_TEST_FAILURE("blkiotune-weight");
     DO_TEST_FAILURE("blkiotune-multiple-devices");
+    DO_TEST_DIFFERENT("virtio-console");
+    DO_TEST_DIFFERENT("virtio-console-addr");
+    DO_TEST_DIFFERENT("2-virtio-console-mixed-addr");
+    DO_TEST_DIFFERENT("virtio-console-multiple-controllers");
+    DO_TEST_DIFFERENT("virtio-console-controllers");
+    DO_TEST_FAILURE("virtio-console-too-many-ports");
+    DO_TEST_FAILURE("virtio-console-invalid-name");
+    DO_TEST_FAILURE("virtio-console-invalid-path");
 
     /* Address allocation tests */
     DO_TEST_DIFFERENT("addr-single-sata-disk");