spice: add qxl device
PATCH v2 1/1 spice: add qxl device
qxl is a paravirtual graphics card. The qxl device is the bridge between the guest and the spice server (aka libspice-server). The spice server will send the rendering commands to the spice client, which will actually render them.
The spice server is also able to render locally, which is done in case the guest wants read something from video memory. Local rendering is also used to support display over vnc and sdl.
qxl is activated using "-vga qxl". qxl supports multihead, additional cards can be added via '-device qxl".
[ v2: add copyright to files ]
[ v2: use qemu-common.h for standard includes ]
[ v2: create separate qxl-vga device for primary ]
--- Makefile.target | 1 + hw/hw.h | 14 + hw/pc.c | 8 + hw/qxl-logger.c | 248 +++++++++ hw/qxl-render.c | 226 ++++++++ hw/qxl.c | 1586 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qxl.h | 112 ++++ hw/vga_int.h | 2 +- qemu-options.hx | 6 +- sysemu.h | 3 +- ui/spice-core.c | 15 + vl.c | 4 +- 12 files changed, 2221 insertions(+), 4 deletions(-) create mode 100644 hw/qxl-logger.c create mode 100644 hw/qxl-render.c create mode 100644 hw/qxl.c create mode 100644 hw/qxl.h
Makefile.target +1 -0
@@ -224,6 +224,7 @@ obj-i386-y += vmmouse.o vmport.o hpet.o applesmc.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o obj-i386-y += pc_piix.o +obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o # shared objects obj-ppc-y = ppc.o
hw/hw.h +14 -0
@@ -528,6 +528,17 @@ extern const VMStateInfo vmstate_info_unused_buffer; .start = (_start), \ } +#define VMSTATE_VBUFFER_UINT32 (_field, _state, _version, _test, _start, _field_size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ + .info = &vmstate_info_buffer, \ + .flags = VMS_VBUFFER|VMS_POINTER, \ + .offset = offsetof(_state, _field), \ + .start = (_start), \ +} +#define VMSTATE_BUFFER_UNSAFE_INFO (_field, _state, _version, _info, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \
@@ -745,6 +756,9 @@ extern const VMStateDescription vmstate_i2c_slave;#define VMSTATE_PARTIAL_VBUFFER (_f, _s, _size) \ VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size) +#define VMSTATE_PARTIAL_VBUFFER_UINT32 (_f, _s, _size) \ + VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size) +#define VMSTATE_SUB_VBUFFER (_f, _s, _start, _size) \ VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
hw/pc.c +8 -0
@@ -40,6 +40,7 @@#include "sysbus.h" #include "sysemu.h" #include "blockdev.h" +#include "ui/qemu-spice.h" /* output Bochs bios info messages */ //#define DEBUG_BIOS
@@ -991,6 +992,13 @@ void pc_vga_init(PCIBus *pci_bus)pci_vmsvga_init (pci_bus); else fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__); +#ifdef CONFIG_SPICE + }else if (qxl_enabled) { +if (pci_bus) +pci_create_simple (pci_bus,-1 ,"qxl-vga" ); +else +fprintf (stderr,"%s: qxl: no PCI bus\n" , __FUNCTION__); +#endif }else if (std_vga_enabled) {if (pci_bus) {pci_vga_init (pci_bus);
hw/qxl-logger.c new file +248 -0
248 lines not on this page · raw message
hw/qxl-render.c new file +226 -0
226 lines not on this page · raw message
hw/qxl.c new file +1586 -0
1,586 lines not on this page · raw message
hw/qxl.h new file +112 -0
112 lines not on this page · raw message
hw/vga_int.h +1 -1
@@ -106,7 +106,7 @@ typedef void (* vga_update_retrace_info_fn)(struct VGACommonState *s); typedef struct VGACommonState { uint8_t *vram_ptr; ram_addr_t vram_offset; - unsigned int vram_size; + uint32_t vram_size; uint32_t lfb_addr; uint32_t lfb_end; uint32_t map_addr;
qemu-options.hx +5 -1
@@ -751,7 +751,7 @@ Rotate graphical output 90 deg left (only PXA LCD). ETEXI DEF("vga", HAS_ARG, QEMU_OPTION_vga, - "-vga [std|cirrus|vmware|xenfb|none]\n" + "-vga [std|cirrus|vmware|qxl|xenfb|none]\n" " select video card type\n", QEMU_ARCH_ALL) STEXI @item -vga @var{type}
@@ -772,6 +772,10 @@ this option. VMWare SVGA-II compatible adapter. Use it if you have sufficiently recent XFree86/XOrg server or Windows guest with a driver for this card. +@item qxl +QXL paravirtual graphic card. It is VGA compatible (including VESA +2.0 VBE support). Works best with qxl guest drivers installed though. +Recommended choice when using the spice protocol. @item none Disable VGA card. @end table
sysemu.h +2 -1
@@ -102,7 +102,7 @@ extern int incoming_expected;extern int bios_size;typedef enum { -VGA_NONE ,VGA_STD ,VGA_CIRRUS ,VGA_VMWARE ,VGA_XENFB +VGA_NONE ,VGA_STD ,VGA_CIRRUS ,VGA_VMWARE ,VGA_XENFB ,VGA_QXL , }VGAInterfaceType ;extern int vga_interface_type;
@@ -110,6 +110,7 @@ extern int vga_interface_type;#define std_vga_enabled (vga_interface_type == VGA_STD)#define xenfb_enabled (vga_interface_type == VGA_XENFB)#define vmsvga_enabled (vga_interface_type == VGA_VMWARE) +#define qxl_enabled (vga_interface_type == VGA_QXL)extern int graphic_width;extern int graphic_height;
ui/spice-core.c +15 -0
@@ -370,6 +370,21 @@ void qemu_spice_init(void)int qemu_spice_add_interface (SpiceBaseInstance *sin) { +if (!spice_server) { +if (QTAILQ_FIRST (&qemu_spice_opts.head) !=NULL ) { +fprintf (stderr,"Oops: spice configured but not active\n" ); +exit (1 ); + } +/* +* Create a spice server instance. +* It does *not* listen on the network. +* It handles QXL local rendering only. +* +* With a command line like '-vnc :0 -vga qxl' you'll end up here. +*/ + spice_server =spice_server_new (); +spice_server_init (spice_server, &core_interface); + }return spice_server_add_interface (spice_server, sin); }
vl.c +3 -1
@@ -1411,6 +1411,8 @@ static void select_vgahw (const char *p) vga_interface_type =VGA_VMWARE ; }else if (strstart (p,"xenfb" , &opts)) { vga_interface_type =VGA_XENFB ; + }else if (strstart (p,"qxl" , &opts)) { + vga_interface_type =VGA_QXL ; }else if (!strstart (p,"none" , &opts)) { invalid_vga:fprintf (stderr,"Unknown vga type: %s\n" , p);
@@ -2945,7 +2947,7 @@ int main(int argc, char **argv, char **envp) } }#ifdef CONFIG_SPICE -if (using_spice) { +if (using_spice && !qxl_enabled) {qemu_spice_display_init (ds); }#endif
Signature · 1 line
1.7.1