[PATCH v2 0/4] bhyve: framebuffer resolution and VNC password

Changes from v2: No functional changes, only rebase. Fabian Freyer (4): bhyve: support parsing fbuf PCI device bhyve: add support for setting fbuf resolution bhyve: probe for VNC password capability bhyve: add VNC password support NEWS.rst | 12 ++ docs/formatdomain.rst | 3 +- src/bhyve/bhyve_capabilities.c | 16 ++- src/bhyve/bhyve_capabilities.h | 1 + src/bhyve/bhyve_command.c | 36 ++++-- src/bhyve/bhyve_parse_command.c | 116 +++++++++++++++++- src/libvirt_private.syms | 1 + .../bhyveargv2xml-vnc-listen.args | 10 ++ .../bhyveargv2xml-vnc-listen.xml | 22 ++++ .../bhyveargv2xml-vnc-password.args | 10 ++ .../bhyveargv2xml-vnc-password.xml | 22 ++++ .../bhyveargv2xml-vnc-resolution.args | 10 ++ .../bhyveargv2xml-vnc-resolution.xml | 24 ++++ .../bhyveargv2xml-vnc-vga-io.args | 10 ++ .../bhyveargv2xml-vnc-vga-io.xml | 22 ++++ .../bhyveargv2xml-vnc-vga-off.args | 10 ++ .../bhyveargv2xml-vnc-vga-off.xml | 23 ++++ .../bhyveargv2xml-vnc-vga-on.args | 10 ++ .../bhyveargv2xml-vnc-vga-on.xml | 23 ++++ .../bhyveargv2xmldata/bhyveargv2xml-vnc.args | 10 ++ tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml | 22 ++++ tests/bhyveargv2xmltest.c | 9 +- .../bhyvexml2argv-vnc-password-comma.xml | 26 ++++ .../bhyvexml2argv-vnc-password.args | 12 ++ .../bhyvexml2argv-vnc-password.ldargs | 1 + .../bhyvexml2argv-vnc-password.xml | 26 ++++ .../bhyvexml2argv-vnc-resolution.args | 10 ++ .../bhyvexml2argv-vnc-resolution.ldargs | 1 + .../bhyvexml2argv-vnc-resolution.xml | 20 +++ tests/bhyvexml2argvtest.c | 9 +- .../bhyvexml2xmlout-vnc-password.xml | 44 +++++++ .../bhyvexml2xmlout-vnc-resolution.xml | 31 +++++ tests/bhyvexml2xmltest.c | 2 + 33 files changed, 588 insertions(+), 16 deletions(-) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password-comma.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-password.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-resolution.xml -- 2.27.0

From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Add a new helper function, bhyveParsePCIFbuf, to parse the bhyve-argv parameters for a frame-buffer device to <graphics/> and <video/> definitions. For now, only the listen address, port, and vga mode are detected. Unsupported parameters are silently skipped. This involves upgrading the private API to expose the virDomainGraphicsDefNew helper function, which is used by bhyveParsePCIFbuf. Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- src/bhyve/bhyve_parse_command.c | 91 ++++++++++++++++++- src/libvirt_private.syms | 1 + .../bhyveargv2xml-vnc-listen.args | 10 ++ .../bhyveargv2xml-vnc-listen.xml | 22 +++++ .../bhyveargv2xml-vnc-vga-io.args | 10 ++ .../bhyveargv2xml-vnc-vga-io.xml | 22 +++++ .../bhyveargv2xml-vnc-vga-off.args | 10 ++ .../bhyveargv2xml-vnc-vga-off.xml | 23 +++++ .../bhyveargv2xml-vnc-vga-on.args | 10 ++ .../bhyveargv2xml-vnc-vga-on.xml | 23 +++++ .../bhyveargv2xmldata/bhyveargv2xml-vnc.args | 10 ++ tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml | 22 +++++ tests/bhyveargv2xmltest.c | 5 + 13 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 50a5e88408..388c565317 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -4,7 +4,7 @@ * Copyright (C) 2006-2016 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * Copyright (c) 2011 NetApp, Inc. - * Copyright (C) 2016 Fabian Freyer + * Copyright (C) 2020 Fabian Freyer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -553,6 +553,93 @@ bhyveParsePCINet(virDomainDefPtr def, return -1; } +static int +bhyveParsePCIFbuf(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, + unsigned caps G_GNUC_UNUSED, + unsigned bus, + unsigned slot, + unsigned function, + const char *config) +{ + /* -s slot,fbuf,wait,vga=on|io|off,rfb=<ip>:port,w=width,h=height */ + + virDomainVideoDefPtr video = NULL; + virDomainGraphicsDefPtr graphics = NULL; + char **params = NULL; + char *param = NULL, *separator = NULL; + size_t nparams = 0; + unsigned int i = 0; + + if (!(video = virDomainVideoDefNew(xmlopt))) + goto cleanup; + + if (!(graphics = virDomainGraphicsDefNew(xmlopt))) + goto cleanup; + + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; + video->info.addr.pci.bus = bus; + video->info.addr.pci.slot = slot; + video->info.addr.pci.function = function; + + if (!config) + goto error; + + if (!(params = virStringSplitCount(config, ",", 0, &nparams))) + goto error; + + for (i = 0; i < nparams; i++) { + param = params[i]; + if (!video->driver && VIR_ALLOC(video->driver) < 0) + goto error; + + if (STREQ(param, "vga=on")) + video->driver->vgaconf = VIR_DOMAIN_VIDEO_VGACONF_ON; + + if (STREQ(param, "vga=io")) + video->driver->vgaconf = VIR_DOMAIN_VIDEO_VGACONF_IO; + + if (STREQ(param, "vga=off")) + video->driver->vgaconf = VIR_DOMAIN_VIDEO_VGACONF_OFF; + + if (STRPREFIX(param, "rfb=") || STRPREFIX(param, "tcp=")) { + /* fortunately, this is the same length as "tcp=" */ + param += strlen("rfb="); + + if (!(separator = strchr(param, ':'))) + goto error; + + *separator = '\0'; + + if (separator != param) + virDomainGraphicsListenAppendAddress(graphics, param); + else + /* Default to 127.0.0.1, just like bhyve does */ + virDomainGraphicsListenAppendAddress(graphics, "127.0.0.1"); + + param = ++separator; + if (virStrToLong_i(param, NULL, 10, &graphics->data.vnc.port)) + goto error; + } + } + + cleanup: + if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0) + goto error; + + if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < 0) + goto error; + + g_strfreev(params); + return 0; + + error: + virDomainVideoDefFree(video); + virDomainGraphicsDefFree(graphics); + g_strfreev(params); + return -1; +} + static int bhyveParseBhyvePCIArg(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, @@ -615,6 +702,8 @@ bhyveParseBhyvePCIArg(virDomainDefPtr def, else if (STREQ(emulation, "e1000")) bhyveParsePCINet(def, xmlopt, caps, bus, slot, function, VIR_DOMAIN_NET_MODEL_E1000, conf); + else if (STREQ(emulation, "fbuf")) + bhyveParsePCIFbuf(def, xmlopt, caps, bus, slot, function, conf); VIR_FREE(emulation); VIR_FREE(slotdef); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bdbe3431b8..96bc7cccb7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -418,6 +418,7 @@ virDomainGraphicsAuthConnectedTypeFromString; virDomainGraphicsAuthConnectedTypeToString; virDomainGraphicsDefFree; virDomainGraphicsDefHasOpenGL; +virDomainGraphicsDefNew; virDomainGraphicsGetListen; virDomainGraphicsGetRenderNode; virDomainGraphicsListenAppendAddress; diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args new file mode 100644 index 0000000000..b97b64a0dc --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 2:0,fbuf,tcp=1.2.3.4:5900 \ +-s 1,lpc bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml new file mode 100644 index 0000000000..4ab17aef81 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml @@ -0,0 +1,22 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <graphics type='vnc' port='5900' autoport='no' listen='1.2.3.4'> + <listen type='address' address='1.2.3.4'/> + </graphics> + <video> + <model type='default' heads='1'/> + </video> + </devices> +</domain> diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args new file mode 100644 index 0000000000..f4c0067b79 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 2:0,fbuf,tcp=:5900,vga=io \ +-s 1,lpc bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml new file mode 100644 index 0000000000..1e2f3d6938 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml @@ -0,0 +1,22 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <graphics type='vnc' port='5900' autoport='no' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='default' heads='1'/> + </video> + </devices> +</domain> diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args new file mode 100644 index 0000000000..4bd5ed1027 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 2:0,fbuf,tcp=:5900,vga=off \ +-s 1,lpc bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml new file mode 100644 index 0000000000..3c9c76e5aa --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml @@ -0,0 +1,23 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <graphics type='vnc' port='5900' autoport='no' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <driver vgaconf='off'/> + <model type='default' heads='1'/> + </video> + </devices> +</domain> diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args new file mode 100644 index 0000000000..d17f347a39 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 2:0,fbuf,tcp=:5900,vga=on \ +-s 1,lpc bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml new file mode 100644 index 0000000000..b83772c47a --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml @@ -0,0 +1,23 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <graphics type='vnc' port='5900' autoport='no' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <driver vgaconf='on'/> + <model type='default' heads='1'/> + </video> + </devices> +</domain> diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args new file mode 100644 index 0000000000..fd4178f0a8 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 2:0,fbuf,tcp=:5900 \ +-s 1,lpc bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml new file mode 100644 index 0000000000..1e2f3d6938 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml @@ -0,0 +1,22 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <graphics type='vnc' port='5900' autoport='no' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='default' heads='1'/> + </video> + </devices> +</domain> diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c index 2a497f48e8..0c0383f593 100644 --- a/tests/bhyveargv2xmltest.c +++ b/tests/bhyveargv2xmltest.c @@ -181,6 +181,11 @@ mymain(void) DO_TEST_FAIL("bhyveload-memsize-fail"); DO_TEST("bhyveload-bootorder"); DO_TEST_FAIL("extraargs"); + DO_TEST("vnc"); + DO_TEST("vnc-listen"); + DO_TEST("vnc-vga-on"); + DO_TEST("vnc-vga-off"); + DO_TEST("vnc-vga-io"); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); -- 2.27.0

On Tue, Sep 22, 2020 at 04:28:48PM +0400, Roman Bogorodskiy wrote:
From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Add a new helper function, bhyveParsePCIFbuf, to parse the bhyve-argv parameters for a frame-buffer device to <graphics/> and <video/> definitions.
For now, only the listen address, port, and vga mode are detected. Unsupported parameters are silently skipped.
This involves upgrading the private API to expose the virDomainGraphicsDefNew helper function, which is used by bhyveParsePCIFbuf.
Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- src/bhyve/bhyve_parse_command.c | 91 ++++++++++++++++++- src/libvirt_private.syms | 1 + .../bhyveargv2xml-vnc-listen.args | 10 ++ .../bhyveargv2xml-vnc-listen.xml | 22 +++++ .../bhyveargv2xml-vnc-vga-io.args | 10 ++ .../bhyveargv2xml-vnc-vga-io.xml | 22 +++++ .../bhyveargv2xml-vnc-vga-off.args | 10 ++ .../bhyveargv2xml-vnc-vga-off.xml | 23 +++++ .../bhyveargv2xml-vnc-vga-on.args | 10 ++ .../bhyveargv2xml-vnc-vga-on.xml | 23 +++++ .../bhyveargv2xmldata/bhyveargv2xml-vnc.args | 10 ++ tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml | 22 +++++ tests/bhyveargv2xmltest.c | 5 + 13 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Roman Bogorodskiy wrote:
From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Add a new helper function, bhyveParsePCIFbuf, to parse the bhyve-argv parameters for a frame-buffer device to <graphics/> and <video/> definitions.
For now, only the listen address, port, and vga mode are detected. Unsupported parameters are silently skipped.
This involves upgrading the private API to expose the virDomainGraphicsDefNew helper function, which is used by bhyveParsePCIFbuf.
Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- src/bhyve/bhyve_parse_command.c | 91 ++++++++++++++++++- src/libvirt_private.syms | 1 + .../bhyveargv2xml-vnc-listen.args | 10 ++ .../bhyveargv2xml-vnc-listen.xml | 22 +++++ .../bhyveargv2xml-vnc-vga-io.args | 10 ++ .../bhyveargv2xml-vnc-vga-io.xml | 22 +++++ .../bhyveargv2xml-vnc-vga-off.args | 10 ++ .../bhyveargv2xml-vnc-vga-off.xml | 23 +++++ .../bhyveargv2xml-vnc-vga-on.args | 10 ++ .../bhyveargv2xml-vnc-vga-on.xml | 23 +++++ .../bhyveargv2xmldata/bhyveargv2xml-vnc.args | 10 ++ tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml | 22 +++++ tests/bhyveargv2xmltest.c | 5 + 13 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml
diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 50a5e88408..388c565317 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -4,7 +4,7 @@ * Copyright (C) 2006-2016 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * Copyright (c) 2011 NetApp, Inc. - * Copyright (C) 2016 Fabian Freyer + * Copyright (C) 2020 Fabian Freyer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -553,6 +553,93 @@ bhyveParsePCINet(virDomainDefPtr def, return -1; }
+static int +bhyveParsePCIFbuf(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, + unsigned caps G_GNUC_UNUSED, + unsigned bus, + unsigned slot, + unsigned function, + const char *config) +{ + /* -s slot,fbuf,wait,vga=on|io|off,rfb=<ip>:port,w=width,h=height */ + + virDomainVideoDefPtr video = NULL; + virDomainGraphicsDefPtr graphics = NULL; + char **params = NULL; + char *param = NULL, *separator = NULL; + size_t nparams = 0; + unsigned int i = 0;
Interesting, some of the CI jobs complain that this should be "size_t" (which I'll fix before merging), and some don't (including my local environment). Wondering if that's caused by different sed versions or something else.
+ + if (!(video = virDomainVideoDefNew(xmlopt))) + goto cleanup; + + if (!(graphics = virDomainGraphicsDefNew(xmlopt))) + goto cleanup; + + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; + video->info.addr.pci.bus = bus; + video->info.addr.pci.slot = slot; + video->info.addr.pci.function = function;
Roman Bogorodskiy

On a Tuesday in 2020, Roman Bogorodskiy wrote:
+static int +bhyveParsePCIFbuf(virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, + unsigned caps G_GNUC_UNUSED, + unsigned bus, + unsigned slot, + unsigned function, + const char *config) +{ + /* -s slot,fbuf,wait,vga=on|io|off,rfb=<ip>:port,w=width,h=height */ + + virDomainVideoDefPtr video = NULL; + virDomainGraphicsDefPtr graphics = NULL; + char **params = NULL; + char *param = NULL, *separator = NULL; + size_t nparams = 0; + unsigned int i = 0;
Interesting, some of the CI jobs complain that this should be "size_t" (which I'll fix before merging), and some don't (including my local environment). Wondering if that's caused by different sed versions or something else.
Looking at .gitlab-ci.yml: We have a 'codestyle' job which specifically runs syntax-check: meson test -C build --suite syntax-check --no-rebuild || And it's also run by the centos-7 job (which is special due to an old git version): ninja -C build test The other jobs execute: ninja -C build dist Which apparently does not include syntax-check. A different sed version might be the culprit - we use it to build the list of different checks in build-aux/meson.build: rc = run_command( 'sed', '-n', 's/^\\(sc_[a-zA-Z0-9_-]*\\):.*/\\1/p', meson.current_source_dir() / 'syntax-check.mk', check: true, ) Jano

From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> The resolution of the VNC framebuffer can now be set via the resolution definition introduced in 5.9.0. Also, add "gop" to the list of model types the <resolution/> sub-element is valid for. Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- NEWS.rst | 5 +++ docs/formatdomain.rst | 3 +- src/bhyve/bhyve_command.c | 3 ++ src/bhyve/bhyve_parse_command.c | 20 ++++++++++++ .../bhyveargv2xml-vnc-resolution.args | 10 ++++++ .../bhyveargv2xml-vnc-resolution.xml | 24 ++++++++++++++ tests/bhyveargv2xmltest.c | 1 + .../bhyvexml2argv-vnc-resolution.args | 10 ++++++ .../bhyvexml2argv-vnc-resolution.ldargs | 1 + .../bhyvexml2argv-vnc-resolution.xml | 20 ++++++++++++ tests/bhyvexml2argvtest.c | 1 + .../bhyvexml2xmlout-vnc-resolution.xml | 31 +++++++++++++++++++ tests/bhyvexml2xmltest.c | 1 + 13 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-resolution.xml diff --git a/NEWS.rst b/NEWS.rst index 685c5e2225..bb48f5bd43 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -20,6 +20,11 @@ v6.8.0 (unreleased) attribute of the device's ``<source>`` element can be used to disable the filtering and allow all guest writes to the configuration space. + * bhyve: Support setting the framebuffer resolution + + Libvirt can now set the framebuffer's "w" and "h" parameters + using the ``resolution`` element. + * **Improvements** * qemu: Allow migration over UNIX sockets diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index d5930a4ac1..888db5ea29 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -5822,7 +5822,8 @@ A video device. :since:`Since 5.9.0` , the ``model`` element may also have an optional ``resolution`` sub-element. The ``resolution`` element has attributes ``x`` and ``y`` to set the minimum resolution for the video device. This - sub-element is valid for model types "vga", "qxl", "bochs", and "virtio". + sub-element is valid for model types "vga", "qxl", "bochs", "gop", + and "virtio". ``acceleration`` Configure if video acceleration should be enabled. diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 4df5baabdf..176a339d5a 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -468,6 +468,9 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, return -1; } + if (video->res) + virBufferAsprintf(&opt, ",w=%d,h=%d", video->res->x, video->res->y); + if (video->driver) virBufferAsprintf(&opt, ",vga=%s", virDomainVideoVGAConfTypeToString(video->driver->vgaconf)); diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 388c565317..c6abdfacf3 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -621,6 +621,26 @@ bhyveParsePCIFbuf(virDomainDefPtr def, if (virStrToLong_i(param, NULL, 10, &graphics->data.vnc.port)) goto error; } + + if (STRPREFIX(param, "w=")) { + param += strlen("w="); + + if (video->res == NULL) + video->res = g_new0(virDomainVideoResolutionDef, 1); + + if (virStrToLong_uip(param, NULL, 10, &video->res->x)) + goto error; + } + + if (STRPREFIX(param, "h=")) { + param += strlen("h="); + + if (video->res == NULL) + video->res = g_new0(virDomainVideoResolutionDef, 1); + + if (virStrToLong_uip(param, NULL, 10, &video->res->y)) + goto error; + } } cleanup: diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.args b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.args new file mode 100644 index 0000000000..e5e2c0f2e8 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 2:0,fbuf,tcp=127.0.0.1:5904,w=1920,h=1080 \ +-s 1,lpc bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.xml new file mode 100644 index 0000000000..f8fa0ed1ce --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.xml @@ -0,0 +1,24 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='default' heads='1'> + <resolution x='1920' y='1080'/> + </model> + </video> + </devices> +</domain> diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c index 0c0383f593..4bf39d50dc 100644 --- a/tests/bhyveargv2xmltest.c +++ b/tests/bhyveargv2xmltest.c @@ -186,6 +186,7 @@ mymain(void) DO_TEST("vnc-vga-on"); DO_TEST("vnc-vga-off"); DO_TEST("vnc-vga-io"); + DO_TEST("vnc-resolution"); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.args new file mode 100644 index 0000000000..5e54da6ed7 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 1:0,lpc \ +-s 2:0,fbuf,tcp=127.0.0.1:5904,w=1920,h=1080 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.ldargs new file mode 100644 index 0000000000..421376db9e --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.ldargs @@ -0,0 +1 @@ +dummy diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.xml new file mode 100644 index 0000000000..637a121fb7 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.xml @@ -0,0 +1,20 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + <loader readonly="yes" type="pflash">/path/to/test.fd</loader> + </os> + <devices> + <video> + <model type='gop' heads='1' primary='yes'> + <resolution x="1920" y="1080"/> + </model> + </video> + <graphics type='vnc' port='5904'> + <listen type='address' address='127.0.0.1'/> + </graphics> + </devices> +</domain> diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 2167cd6310..d4c4275702 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -197,6 +197,7 @@ mymain(void) DO_TEST("vnc-vgaconf-off"); DO_TEST("vnc-vgaconf-io"); DO_TEST("vnc-autoport"); + DO_TEST("vnc-resolution"); DO_TEST("cputopology"); DO_TEST_FAILURE("cputopology-nvcpu-mismatch"); DO_TEST("commandline"); diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-resolution.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-resolution.xml new file mode 100644 index 0000000000..79843531da --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-resolution.xml @@ -0,0 +1,31 @@ +<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> + <loader readonly='yes' type='pflash'>/path/to/test.fd</loader> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <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> + <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='gop' heads='1' primary='yes'> + <resolution x='1920' y='1080'/> + </model> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + </devices> +</domain> diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 3bf2187250..b266e8b934 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -106,6 +106,7 @@ mymain(void) DO_TEST_DIFFERENT("vnc-vgaconf-off"); DO_TEST_DIFFERENT("vnc-vgaconf-io"); DO_TEST_DIFFERENT("vnc-autoport"); + DO_TEST_DIFFERENT("vnc-resolution"); DO_TEST_DIFFERENT("commandline"); DO_TEST_DIFFERENT("msrs"); DO_TEST_DIFFERENT("sound"); -- 2.27.0

On Tue, Sep 22, 2020 at 04:28:49PM +0400, Roman Bogorodskiy wrote:
From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
The resolution of the VNC framebuffer can now be set via the resolution definition introduced in 5.9.0.
Also, add "gop" to the list of model types the <resolution/> sub-element is valid for.
Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- NEWS.rst | 5 +++ docs/formatdomain.rst | 3 +- src/bhyve/bhyve_command.c | 3 ++ src/bhyve/bhyve_parse_command.c | 20 ++++++++++++ .../bhyveargv2xml-vnc-resolution.args | 10 ++++++ .../bhyveargv2xml-vnc-resolution.xml | 24 ++++++++++++++ tests/bhyveargv2xmltest.c | 1 + .../bhyvexml2argv-vnc-resolution.args | 10 ++++++ .../bhyvexml2argv-vnc-resolution.ldargs | 1 + .../bhyvexml2argv-vnc-resolution.xml | 20 ++++++++++++ tests/bhyvexml2argvtest.c | 1 + .../bhyvexml2xmlout-vnc-resolution.xml | 31 +++++++++++++++++++ tests/bhyvexml2xmltest.c | 1 + 13 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-resolution.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-resolution.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-resolution.xml
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Introduces the BHYVE_CAP_VNC_PASSWORD capability, which is probed by parsing the error message from the bhyve command. When it is not supported, bhyve -s 0,fbuf,password= will return an error message. Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- src/bhyve/bhyve_capabilities.c | 16 +++++++++++++++- src/bhyve/bhyve_capabilities.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 36f3985335..523a31e287 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -3,7 +3,7 @@ * * Copyright (C) 2014 Roman Bogorodskiy * Copyright (C) 2014 Semihalf - * Copyright (C) 2016 Fabian Freyer + * Copyright (C) 2020 Fabian Freyer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -334,6 +334,17 @@ bhyveProbeCapsSoundHda(unsigned int *caps, char *binary) } +static int +bhyveProbeCapsVNCPassword(unsigned int *caps, char *binary) +{ + return bhyveProbeCapsDeviceHelper(caps, binary, + "-s", + "0,fbuf,password=", + "Invalid fbuf emulation \"password\"", + BHYVE_CAP_VNC_PASSWORD); +} + + int virBhyveProbeCaps(unsigned int *caps) { @@ -365,6 +376,9 @@ virBhyveProbeCaps(unsigned int *caps) if ((ret = bhyveProbeCapsSoundHda(caps, binary))) goto out; + if ((ret = bhyveProbeCapsVNCPassword(caps, binary))) + goto out; + out: VIR_FREE(binary); return ret; diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index 1ac9ff4283..b2a16b0189 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -50,6 +50,7 @@ typedef enum { BHYVE_CAP_XHCI = 1 << 5, BHYVE_CAP_CPUTOPOLOGY = 1 << 6, BHYVE_CAP_SOUND_HDA = 1 << 7, + BHYVE_CAP_VNC_PASSWORD = 1 << 8, } virBhyveCapsFlags; int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps); -- 2.27.0

On Tue, Sep 22, 2020 at 04:28:50PM +0400, Roman Bogorodskiy wrote:
From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Introduces the BHYVE_CAP_VNC_PASSWORD capability, which is probed by parsing the error message from the bhyve command. When it is not supported, bhyve -s 0,fbuf,password= will return an error message.
Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- src/bhyve/bhyve_capabilities.c | 16 +++++++++++++++- src/bhyve/bhyve_capabilities.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Support setting a password for the VNC framebuffer using the passwd attribute on the <graphics/> element, if the driver has the BHYVE_CAP_VNC_PASSWORD capability. Note that virsh domxml-from-native does not output the password in the generated XML, as VIR_DOMAIN_DEF_FORMAT_SECURE is not set when formatting the domain definition. Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- NEWS.rst | 7 +++ src/bhyve/bhyve_command.c | 33 +++++++++----- src/bhyve/bhyve_parse_command.c | 5 +++ .../bhyveargv2xml-vnc-password.args | 10 +++++ .../bhyveargv2xml-vnc-password.xml | 22 ++++++++++ tests/bhyveargv2xmltest.c | 3 +- .../bhyvexml2argv-vnc-password-comma.xml | 26 +++++++++++ .../bhyvexml2argv-vnc-password.args | 12 +++++ .../bhyvexml2argv-vnc-password.ldargs | 1 + .../bhyvexml2argv-vnc-password.xml | 26 +++++++++++ tests/bhyvexml2argvtest.c | 8 +++- .../bhyvexml2xmlout-vnc-password.xml | 44 +++++++++++++++++++ tests/bhyvexml2xmltest.c | 1 + 13 files changed, 185 insertions(+), 13 deletions(-) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password-comma.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-password.xml diff --git a/NEWS.rst b/NEWS.rst index bb48f5bd43..c949cb941b 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -25,6 +25,13 @@ v6.8.0 (unreleased) Libvirt can now set the framebuffer's "w" and "h" parameters using the ``resolution`` element. + * bhyve: Support VNC password authentication + + Libvirt can now probe whether the bhyve binary supports + VNC password authentication. In case it does, a VNC password + can now be passed using the ``passwd`` attribute on + the ``<graphics>`` element. + * **Improvements** * qemu: Allow migration over UNIX sockets diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 176a339d5a..1b48438168 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -424,17 +424,6 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, return -1; } - if (graphics->data.vnc.auth.passwd) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("vnc password auth not supported")); - return -1; - } else { - /* Bhyve doesn't support VNC Auth yet, so print a warning about - * unauthenticated VNC sessions */ - VIR_WARN("%s", _("Security warning: currently VNC auth is not" - " supported.")); - } - if (glisten->address) { escapeAddr = strchr(glisten->address, ':') != NULL; if (escapeAddr) @@ -468,6 +457,28 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, return -1; } + if (graphics->data.vnc.auth.passwd) { + if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_VNC_PASSWORD)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VNC Passwort authentication not supported " + "by bhyve")); + return -1; + } + + if (strchr(graphics->data.vnc.auth.passwd, ',')) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Password may not contain ',' character")); + return -1; + } + + virBufferAsprintf(&opt, ",password=%s", graphics->data.vnc.auth.passwd); + } else { + if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_VNC_PASSWORD)) + VIR_WARN("%s", _("Security warning: VNC auth is not supported.")); + else + VIR_WARN("%s", _("Security warning: VNC is used without authentication.")); + } + if (video->res) virBufferAsprintf(&opt, ",w=%d,h=%d", video->res->x, video->res->y); diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index c6abdfacf3..05cb8eb7d6 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -641,6 +641,11 @@ bhyveParsePCIFbuf(virDomainDefPtr def, if (virStrToLong_uip(param, NULL, 10, &video->res->y)) goto error; } + + if (STRPREFIX(param, "password=")) { + param += strlen("password="); + graphics->data.vnc.auth.passwd = g_strdup(param); + } } cleanup: diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.args b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.args new file mode 100644 index 0000000000..c16e970795 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 4:0,fbuf,tcp=127.0.0.1:5904,password=s3cr3t \ +-s 1,lpc bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.xml new file mode 100644 index 0000000000..456a1ee9e3 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.xml @@ -0,0 +1,22 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1' passwd='s3cr3t'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='default' heads='1'/> + </video> + </devices> +</domain> diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c index 4bf39d50dc..2c1ffc75f3 100644 --- a/tests/bhyveargv2xmltest.c +++ b/tests/bhyveargv2xmltest.c @@ -76,7 +76,7 @@ testCompareXMLToArgvFiles(const char *xmlfile, return -1; } - if (vmdef && !(actualxml = virDomainDefFormat(vmdef, driver.xmlopt, 0))) + if (vmdef && !(actualxml = virDomainDefFormat(vmdef, driver.xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE))) return -1; if (vmdef && virTestCompareToFile(actualxml, xmlfile) < 0) @@ -187,6 +187,7 @@ mymain(void) DO_TEST("vnc-vga-off"); DO_TEST("vnc-vga-io"); DO_TEST("vnc-resolution"); + DO_TEST("vnc-password"); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password-comma.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password-comma.xml new file mode 100644 index 0000000000..76dd36f72a --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password-comma.xml @@ -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> + <loader readonly="yes" type="pflash">/path/to/test.fd</loader> + </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'> + <model type='virtio'/> + <source bridge="virbr0"/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + <graphics type='vnc' port='5904' passwd="in,valid"> + <listen type='address' address='127.0.0.1'/> + </graphics> + </devices> +</domain> diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.args new file mode 100644 index 0000000000..b3b1c244be --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.args @@ -0,0 +1,12 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-l bootrom,/path/to/test.fd \ +-s 1:0,lpc \ +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \ +-s 4:0,fbuf,tcp=127.0.0.1:5904,password=s3cr3t bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.ldargs new file mode 100644 index 0000000000..421376db9e --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.ldargs @@ -0,0 +1 @@ +dummy diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.xml new file mode 100644 index 0000000000..97925a74fc --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.xml @@ -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> + <loader readonly="yes" type="pflash">/path/to/test.fd</loader> + </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'> + <model type='virtio'/> + <source bridge="virbr0"/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + <graphics type='vnc' port='5904' passwd="s3cr3t"> + <listen type='address' address='127.0.0.1'/> + </graphics> + </devices> +</domain> diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index d4c4275702..def2acc15c 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -166,7 +166,8 @@ mymain(void) driver.bhyvecaps = BHYVE_CAP_RTC_UTC | BHYVE_CAP_AHCI32SLOT | \ BHYVE_CAP_NET_E1000 | BHYVE_CAP_LPC_BOOTROM | \ BHYVE_CAP_FBUF | BHYVE_CAP_XHCI | \ - BHYVE_CAP_CPUTOPOLOGY | BHYVE_CAP_SOUND_HDA; + BHYVE_CAP_CPUTOPOLOGY | BHYVE_CAP_SOUND_HDA | \ + BHYVE_CAP_VNC_PASSWORD; DO_TEST("base"); DO_TEST("wired"); @@ -198,6 +199,8 @@ mymain(void) DO_TEST("vnc-vgaconf-io"); DO_TEST("vnc-autoport"); DO_TEST("vnc-resolution"); + DO_TEST("vnc-password"); + DO_TEST_FAILURE("vnc-password-comma"); DO_TEST("cputopology"); DO_TEST_FAILURE("cputopology-nvcpu-mismatch"); DO_TEST("commandline"); @@ -250,6 +253,9 @@ mymain(void) driver.bhyvecaps &= ~BHYVE_CAP_SOUND_HDA; DO_TEST_FAILURE("sound"); + driver.bhyvecaps &= ~BHYVE_CAP_VNC_PASSWORD; + DO_TEST_FAILURE("vnc-password"); + virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); virPortAllocatorRangeFree(driver.remotePorts); diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-password.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-password.xml new file mode 100644 index 0000000000..6786e10ab9 --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-password.xml @@ -0,0 +1,44 @@ +<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> + <loader readonly='yes' type='pflash'>/path/to/test.fd</loader> + <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:00:00:00'/> + <source bridge='virbr0'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1' passwd='s3cr3t'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='gop' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </video> + </devices> +</domain> diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index b266e8b934..8808d5a8fa 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -107,6 +107,7 @@ mymain(void) DO_TEST_DIFFERENT("vnc-vgaconf-io"); DO_TEST_DIFFERENT("vnc-autoport"); DO_TEST_DIFFERENT("vnc-resolution"); + DO_TEST_DIFFERENT("vnc-password"); DO_TEST_DIFFERENT("commandline"); DO_TEST_DIFFERENT("msrs"); DO_TEST_DIFFERENT("sound"); -- 2.27.0

On Tue, Sep 22, 2020 at 04:28:51PM +0400, Roman Bogorodskiy wrote:
From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Support setting a password for the VNC framebuffer using the passwd attribute on the <graphics/> element, if the driver has the BHYVE_CAP_VNC_PASSWORD capability.
Note that virsh domxml-from-native does not output the password in the generated XML, as VIR_DOMAIN_DEF_FORMAT_SECURE is not set when formatting the domain definition.
Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- NEWS.rst | 7 +++ src/bhyve/bhyve_command.c | 33 +++++++++----- src/bhyve/bhyve_parse_command.c | 5 +++ .../bhyveargv2xml-vnc-password.args | 10 +++++ .../bhyveargv2xml-vnc-password.xml | 22 ++++++++++ tests/bhyveargv2xmltest.c | 3 +- .../bhyvexml2argv-vnc-password-comma.xml | 26 +++++++++++ .../bhyvexml2argv-vnc-password.args | 12 +++++ .../bhyvexml2argv-vnc-password.ldargs | 1 + .../bhyvexml2argv-vnc-password.xml | 26 +++++++++++ tests/bhyvexml2argvtest.c | 8 +++- .../bhyvexml2xmlout-vnc-password.xml | 44 +++++++++++++++++++ tests/bhyvexml2xmltest.c | 1 + 13 files changed, 185 insertions(+), 13 deletions(-) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vnc-password.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password-comma.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-password.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-password.xml
diff --git a/NEWS.rst b/NEWS.rst index bb48f5bd43..c949cb941b 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -25,6 +25,13 @@ v6.8.0 (unreleased) Libvirt can now set the framebuffer's "w" and "h" parameters using the ``resolution`` element.
+ * bhyve: Support VNC password authentication + + Libvirt can now probe whether the bhyve binary supports + VNC password authentication. In case it does, a VNC password + can now be passed using the ``passwd`` attribute on + the ``<graphics>`` element. + * **Improvements**
* qemu: Allow migration over UNIX sockets diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 176a339d5a..1b48438168 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -424,17 +424,6 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, return -1; }
- if (graphics->data.vnc.auth.passwd) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("vnc password auth not supported")); - return -1; - } else { - /* Bhyve doesn't support VNC Auth yet, so print a warning about - * unauthenticated VNC sessions */ - VIR_WARN("%s", _("Security warning: currently VNC auth is not" - " supported.")); - } - if (glisten->address) { escapeAddr = strchr(glisten->address, ':') != NULL; if (escapeAddr) @@ -468,6 +457,28 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, return -1; }
+ if (graphics->data.vnc.auth.passwd) { + if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_VNC_PASSWORD)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VNC Passwort authentication not supported "
s/Passwort/Password/
+ "by bhyve")); + return -1; + } + + if (strchr(graphics->data.vnc.auth.passwd, ',')) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Password may not contain ',' character")); + return -1; + } + + virBufferAsprintf(&opt, ",password=%s", graphics->data.vnc.auth.passwd); + } else { + if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_VNC_PASSWORD)) + VIR_WARN("%s", _("Security warning: VNC auth is not supported.")); + else + VIR_WARN("%s", _("Security warning: VNC is used without authentication.")); + } + if (video->res) virBufferAsprintf(&opt, ",w=%d,h=%d", video->res->x, video->res->y);
With typo fixed: Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (3)
-
Daniel P. Berrangé
-
Ján Tomko
-
Roman Bogorodskiy