mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
bhyve: support parsing fbuf PCI device
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> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
54c207a13d
commit
cdd31d72ed
@ -4,7 +4,7 @@
|
|||||||
* Copyright (C) 2006-2016 Red Hat, Inc.
|
* Copyright (C) 2006-2016 Red Hat, Inc.
|
||||||
* Copyright (C) 2006 Daniel P. Berrange
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
* Copyright (c) 2011 NetApp, Inc.
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -553,6 +553,93 @@ bhyveParsePCINet(virDomainDefPtr def,
|
|||||||
return -1;
|
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;
|
||||||
|
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
|
static int
|
||||||
bhyveParseBhyvePCIArg(virDomainDefPtr def,
|
bhyveParseBhyvePCIArg(virDomainDefPtr def,
|
||||||
virDomainXMLOptionPtr xmlopt,
|
virDomainXMLOptionPtr xmlopt,
|
||||||
@ -615,6 +702,8 @@ bhyveParseBhyvePCIArg(virDomainDefPtr def,
|
|||||||
else if (STREQ(emulation, "e1000"))
|
else if (STREQ(emulation, "e1000"))
|
||||||
bhyveParsePCINet(def, xmlopt, caps, bus, slot, function,
|
bhyveParsePCINet(def, xmlopt, caps, bus, slot, function,
|
||||||
VIR_DOMAIN_NET_MODEL_E1000, conf);
|
VIR_DOMAIN_NET_MODEL_E1000, conf);
|
||||||
|
else if (STREQ(emulation, "fbuf"))
|
||||||
|
bhyveParsePCIFbuf(def, xmlopt, caps, bus, slot, function, conf);
|
||||||
|
|
||||||
VIR_FREE(emulation);
|
VIR_FREE(emulation);
|
||||||
VIR_FREE(slotdef);
|
VIR_FREE(slotdef);
|
||||||
|
@ -418,6 +418,7 @@ virDomainGraphicsAuthConnectedTypeFromString;
|
|||||||
virDomainGraphicsAuthConnectedTypeToString;
|
virDomainGraphicsAuthConnectedTypeToString;
|
||||||
virDomainGraphicsDefFree;
|
virDomainGraphicsDefFree;
|
||||||
virDomainGraphicsDefHasOpenGL;
|
virDomainGraphicsDefHasOpenGL;
|
||||||
|
virDomainGraphicsDefNew;
|
||||||
virDomainGraphicsGetListen;
|
virDomainGraphicsGetListen;
|
||||||
virDomainGraphicsGetRenderNode;
|
virDomainGraphicsGetRenderNode;
|
||||||
virDomainGraphicsListenAppendAddress;
|
virDomainGraphicsListenAppendAddress;
|
||||||
|
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args
Normal file
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.args
Normal file
@ -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
|
22
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml
Normal file
22
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-listen.xml
Normal file
@ -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>
|
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args
Normal file
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.args
Normal file
@ -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
|
22
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml
Normal file
22
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-io.xml
Normal file
@ -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>
|
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args
Normal file
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.args
Normal file
@ -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
|
23
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml
Normal file
23
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-off.xml
Normal file
@ -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>
|
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args
Normal file
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.args
Normal file
@ -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
|
23
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml
Normal file
23
tests/bhyveargv2xmldata/bhyveargv2xml-vnc-vga-on.xml
Normal file
@ -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>
|
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args
Normal file
10
tests/bhyveargv2xmldata/bhyveargv2xml-vnc.args
Normal file
@ -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
|
22
tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml
Normal file
22
tests/bhyveargv2xmldata/bhyveargv2xml-vnc.xml
Normal file
@ -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>
|
@ -181,6 +181,11 @@ mymain(void)
|
|||||||
DO_TEST_FAIL("bhyveload-memsize-fail");
|
DO_TEST_FAIL("bhyveload-memsize-fail");
|
||||||
DO_TEST("bhyveload-bootorder");
|
DO_TEST("bhyveload-bootorder");
|
||||||
DO_TEST_FAIL("extraargs");
|
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.caps);
|
||||||
virObjectUnref(driver.xmlopt);
|
virObjectUnref(driver.xmlopt);
|
||||||
|
Loading…
Reference in New Issue
Block a user