From 3a342f640299df3b350d63880399f481286a87f6 Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Wed, 18 Jun 2025 19:59:47 +0200 Subject: [PATCH] bhyve: increase number of supported consoles to 4 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Recent versions of bhyve support 4 com ports instead of just 2. Thus, allow to use 4 console devices. Also, there was a bug previously because the condition was "if (chr->target.port > 2)", but as target.port start with 0 and "com" ports start with 1, this condition allows com3 to be used. As bhyve supports 4 com ports already long enough, and all supported FreeBSD versions include this capability, do not introduce driver capability for that. Add a couple of tests for that: - A domain that uses 4 serials, 2 of type 'nmdm' and the other 2 of type 'tcp' - A domain that uses unsupported port, such as target.port=4 which translates into com5. Signed-off-by: Roman Bogorodskiy Reviewed-by: Daniel P. Berrangé --- src/bhyve/bhyve_command.c | 4 +- .../bhyvexml2argv-4-consoles.args | 15 +++++ .../bhyvexml2argv-4-consoles.ldargs | 4 ++ .../bhyvexml2argv-4-consoles.xml | 35 +++++++++++ .../bhyvexml2argv-serial-invalid-port.args | 12 ++++ .../bhyvexml2argv-serial-invalid-port.ldargs | 4 ++ .../bhyvexml2argv-serial-invalid-port.xml | 28 +++++++++ .../bhyvexml2argv-serial-tcp.xml | 2 +- tests/bhyvexml2argvtest.c | 2 + .../bhyvexml2xmlout-4-consoles.xml | 58 +++++++++++++++++++ .../bhyvexml2xmlout-serial-tcp.xml | 4 +- tests/bhyvexml2xmltest.c | 1 + 12 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-4-consoles.xml diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 89648f76cb..18f65cf757 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -168,8 +168,8 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommand *cmd) for (i = 0; i < def->nserials; i++) { chr = def->serials[i]; - /* bhyve supports only two ports: com1 and com2 */ - if (chr->target.port > 2) { + /* bhyve supports 4 ports: com1, com2, com3, com4 */ + if (chr->target.port > 3) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("only two serial ports are supported")); return -1; diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.args b/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.args new file mode 100644 index 0000000000..16c7bd7638 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.args @@ -0,0 +1,15 @@ +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,/dev/nmdmdf3be7e7-a104-11e3-aeb0-50e5492bd3dcA \ +-l com2,tcp=127.0.0.1:12345 \ +-l com3,tcp=0.0.0.0:54321 \ +-l com4,/dev/nmdm0A \ +bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.ldargs new file mode 100644 index 0000000000..5905f4b3e6 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.ldargs @@ -0,0 +1,4 @@ +bhyveload \ +-m 214 \ +-d /tmp/freebsd.img \ +bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.xml new file mode 100644 index 0000000000..c32680aa34 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-4-consoles.xml @@ -0,0 +1,35 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.args b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.args new file mode 100644 index 0000000000..8e4072d897 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.args @@ -0,0 +1,12 @@ +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 diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.ldargs new file mode 100644 index 0000000000..5905f4b3e6 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.ldargs @@ -0,0 +1,4 @@ +bhyveload \ +-m 214 \ +-d /tmp/freebsd.img \ +bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.xml new file mode 100644 index 0000000000..36ecd1a9f1 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-invalid-port.xml @@ -0,0 +1,28 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + + + + + + +
+ + + + + +
+ + + + + + + + diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-tcp.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-tcp.xml index 61c9440e44..a52b507dda 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-tcp.xml +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-tcp.xml @@ -20,7 +20,7 @@
- + diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index d1786ff165..2838b20c29 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -255,6 +255,8 @@ mymain(void) driver.bhyvecaps &= ~BHYVE_CAP_VIRTIO_RND; DO_TEST_FAILURE("virtio-rnd"); DO_TEST("serial-tcp"); + DO_TEST("4-consoles"); + DO_TEST_FAILURE("serial-invalid-port"); /* Address allocation tests */ DO_TEST("addr-single-sata-disk"); diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-4-consoles.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-4-consoles.xml new file mode 100644 index 0000000000..fba7d37a4b --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-4-consoles.xml @@ -0,0 +1,58 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + + + + +
+ + + +
+ + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-tcp.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-tcp.xml index 641efcd602..529f1e8f02 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-tcp.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-tcp.xml @@ -33,12 +33,12 @@
- + - + diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 0b858731a6..df093a5539 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -116,6 +116,7 @@ mymain(void) DO_TEST_DIFFERENT("fs-9p"); DO_TEST_DIFFERENT("virtio-rnd"); DO_TEST_DIFFERENT("serial-tcp"); + DO_TEST_DIFFERENT("4-consoles"); /* Address allocation tests */ DO_TEST_DIFFERENT("addr-single-sata-disk"); -- 2.47.2