diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 50a5e88408..604bd6b22e 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=:port,w=width,h=height */ + + virDomainVideoDefPtr video = NULL; + virDomainGraphicsDefPtr graphics = NULL; + char **params = NULL; + char *param = NULL, *separator = NULL; + size_t nparams = 0; + size_t 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 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + destroy + destroy + + + + + + + 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 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + destroy + destroy + + + + + + + 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 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + destroy + destroy + + + + + + + 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 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + destroy + destroy + + + + + + + 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 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + destroy + destroy + + + + + + + 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);