From: Roman Bogorodskiy Date: Mon, 22 Dec 2025 17:23:41 +0000 (+0100) Subject: bhyve: command: handle arm64 console X-Git-Tag: v12.0.0-rc1~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90df4b6795c1e6add8a2be0b969276533e065b85;p=thirdparty%2Flibvirt.git bhyve: command: handle arm64 console Console device handling in bhyve is different for amd64 and arm64. On amd64, it's configured as an LPC device, and multiple consoles are supported. On arm64, only a single console can be configured, and the syntax is different: -o console=/dev/nmdmguest0A Update the bhyve command generation accordingly. Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 989af05f05..76bc3359e6 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -172,34 +172,53 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommand *cmd) if (!def->nserials) return 0; - for (i = 0; i < def->nserials; i++) { - chr = def->serials[i]; + if (ARCH_IS_X86(def->os.arch)) { + for (i = 0; i < def->nserials; i++) { + chr = def->serials[i]; - /* bhyve supports 4 ports: com1, com2, com3, com4 */ - if (chr->target.port > 3) { + /* bhyve supports 4 ports: com1, com2, com3, com4 */ + if (chr->target.port > 3) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only four serial ports are supported")); + return -1; + } + + virCommandAddArg(cmd, "-l"); + + 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; + } + } + } else if (ARCH_IS_ARM(def->os.arch)) { + if (def->nserials > 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only four serial ports are supported")); + _("Only one console is supported on arm64")); return -1; } - virCommandAddArg(cmd, "-l"); - - 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: + chr = def->serials[0]; + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_NMDM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only 'nmdm' and 'tcp' console types are supported")); + _("Only 'nmdm' console type is supported on arm64")); return -1; } + + virCommandAddArg(cmd, "-o"); + virCommandAddArgFormat(cmd, "console=%s", + chr->source->data.file.path); } return 0; diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.args b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.args new file mode 100644 index 0000000000..73d0005faf --- /dev/null +++ b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.args @@ -0,0 +1,11 @@ +bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \ +-s 2:0,virtio-blk,/tmp/freebsd.img \ +-o console=/dev/nmdm0A \ +bhyve diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.ldargs b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.ldargs new file mode 100644 index 0000000000..264ae48441 --- /dev/null +++ b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.ldargs @@ -0,0 +1,7 @@ +timeout \ +--foreground \ +--verbose \ +-k 20s 300s bhyveload \ +-m 214 \ +-d /tmp/freebsd.img \ +bhyve diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.xml b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.xml new file mode 100644 index 0000000000..dd599b5133 --- /dev/null +++ b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.xml @@ -0,0 +1,26 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + + + + + + +
+ + + + + +
+ + + + + + diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 7c63a3b9f9..78e2638658 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -335,6 +335,7 @@ mymain(void) driver.caps = virBhyveCapsBuild(); DO_TEST("base"); + DO_TEST("console"); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt);