In addition to the nmdm consoles, bhyve also supports a tcp console.
It's configured with:
.. -l com1,tcp=127.0.0.1:12345
Then a user could connect to the guest console port 0 by making a tcp
connection to the host's 127.0.0.1:12345.
In the domain XML this configuration is represented as:
<serial type='tcp'>
<source mode='bind' host='127.0.0.1' service='12345'/>
<target type='serial' port='0'/>
</serial>
Also, update domain capabilities to include the TCP console support.
Unfortunately, there's no way to detect that from the bhyve binary
before trying to start a VM, so there's no capability probing for this
feature.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
caps->console.supported = VIR_TRISTATE_BOOL_YES;
caps->console.type.report = true;
VIR_DOMAIN_CAPS_ENUM_SET(caps->console.type,
- VIR_DOMAIN_CHR_TYPE_NMDM);
+ VIR_DOMAIN_CHR_TYPE_NMDM,
+ VIR_DOMAIN_CHR_TYPE_TCP);
return 0;
}
static int
bhyveBuildConsoleArgStr(const virDomainDef *def, virCommand *cmd)
{
+ size_t i = 0;
virDomainChrDef *chr = NULL;
if (!def->nserials)
return 0;
- chr = def->serials[0];
+ for (i = 0; i < def->nserials; i++) {
+ chr = def->serials[i];
- if (chr->source->type != VIR_DOMAIN_CHR_TYPE_NMDM) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("only nmdm console types are supported"));
- return -1;
- }
+ /* bhyve supports only two ports: com1 and com2 */
+ if (chr->target.port > 2) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("only two serial ports are supported"));
+ return -1;
+ }
- /* bhyve supports only two ports: com1 and com2 */
- if (chr->target.port > 2) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("only two serial ports are supported"));
- return -1;
- }
+ virCommandAddArg(cmd, "-l");
- virCommandAddArg(cmd, "-l");
- virCommandAddArgFormat(cmd, "com%d,%s",
- chr->target.port + 1, chr->source->data.file.path);
+ switch (chr->source->type) {
+ case VIR_DOMAIN_CHR_TYPE_NMDM:
+ virCommandAddArgFormat(cmd, "com%d,%s",
+ chr->target.port + 1, chr->source->data.file.path);
+ break;
+ case VIR_DOMAIN_CHR_TYPE_TCP:
+ virCommandAddArgFormat(cmd, "com%d,tcp=%s:%s",
+ chr->target.port + 1,
+ chr->source->data.tcp.host,
+ chr->source->data.tcp.service);
+ break;
+ default:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("only nmdm and tcp console types are supported"));
+ return -1;
+ }
+ }
return 0;
}
--- /dev/null
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 1:0,lpc \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:b1:42:eb \
+-l com1,tcp=127.0.0.1:12345 \
+bhyve
--- /dev/null
+bhyveload \
+-m 214 \
+-d /tmp/freebsd.img \
+bhyve
--- /dev/null
+<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>
+ <interface type='bridge'>
+ <mac address='52:54:00:b1:42:eb'/>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <serial type='tcp'>
+ <source mode='connect' host='127.0.0.1' service='12345'/>
+ <protocol type="raw"/>
+ </serial>
+ </devices>
+</domain>
DO_TEST_FAILURE("virtio-rnd-transitional");
driver.bhyvecaps &= ~BHYVE_CAP_VIRTIO_RND;
DO_TEST_FAILURE("virtio-rnd");
+ DO_TEST("serial-tcp");
/* Address allocation tests */
DO_TEST("addr-single-sata-disk");
--- /dev/null
+<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='isa' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+ </controller>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <interface type='bridge'>
+ <mac address='52:54:00:b1:42:eb'/>
+ <source bridge='virbr0'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <serial type='tcp'>
+ <source mode='connect' host='127.0.0.1' service='12345'/>
+ <protocol type='raw'/>
+ <target port='0'/>
+ </serial>
+ <console type='tcp'>
+ <source mode='connect' host='127.0.0.1' service='12345'/>
+ <protocol type='raw'/>
+ <target type='serial' port='0'/>
+ </console>
+ </devices>
+</domain>
DO_TEST_DIFFERENT("isa-controller");
DO_TEST_DIFFERENT("fs-9p");
DO_TEST_DIFFERENT("virtio-rnd");
+ DO_TEST_DIFFERENT("serial-tcp");
/* Address allocation tests */
DO_TEST_DIFFERENT("addr-single-sata-disk");
<hostdev supported='no'/>
<console supported='yes'>
<enum name='type'>
+ <value>tcp</value>
<value>nmdm</value>
</enum>
</console>
<hostdev supported='no'/>
<console supported='yes'>
<enum name='type'>
+ <value>tcp</value>
<value>nmdm</value>
</enum>
</console>
<hostdev supported='no'/>
<console supported='yes'>
<enum name='type'>
+ <value>tcp</value>
<value>nmdm</value>
</enum>
</console>