From 2968e5ff3aa9e48b135ba2bab65b13f32fe6223f Mon Sep 17 00:00:00 2001 From: Fabian Freyer Date: Wed, 6 May 2020 13:35:53 +0000 Subject: [PATCH] bhyve: add support for setting fbuf resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 sub-element is valid for. Signed-off-by: Fabian Freyer Signed-off-by: Roman Bogorodskiy Reviewed-by: Daniel P. Berrangé --- 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 ```` 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 604bd6b22e..7f9ce0ca67 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 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + destroy + destroy + + + + + + + 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 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + /path/to/test.fd + + + + + + + + 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 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 219136 + 1 + + hvm + /path/to/test.fd + + + + destroy + restart + destroy + + + +
+ + + + +