Implementing qxl-virtio on QEMU
The following patches makes provides video support to non PCI architectures, please review!
PATCH 1/4 qxl: create a qxl common struct!
From: Fabiano Fidêncio <[email protected]>
This commit is creating a QXLDevice struct, entirely based on PCIQXLDevice struct, but separating parts that will be shared between PCIQXLDevice and VirtIOQXLDevice. All functions were changed to support the new QXLDevice struct.
--- hw/qxl-logger.c | 16 +- hw/qxl-render.c | 29 ++-- hw/qxl.c | 436 ++++++++++++++++++++++++++++--------------------------- hw/qxl.h | 110 ++++++++------ 4 files changed, 303 insertions(+), 288 deletions(-)
hw/qxl-logger.c +8 -8
@@ -100,7 +100,7 @@ static const char *qxl_v2n(const char *n[], size_t l, int v) }#define qxl_name (_list, _value) qxl_v2n(_list, ARRAY_SIZE(_list), _value) -static int qxl_log_image (PCIQXLDevice *qxl,QXLPHYSICAL addr,int group_id) +static int qxl_log_image (QXLDevice *qxl,QXLPHYSICAL addr,int group_id) {QXLImage *image;QXLImageDescriptor *desc;
@@ -134,7 +134,7 @@ static void qxl_log_rect(QXLRect *rect) rect->left, rect->top); } -static int qxl_log_cmd_draw_copy (PCIQXLDevice *qxl,QXLCopy *copy, +static int qxl_log_cmd_draw_copy (QXLDevice *qxl,QXLCopy *copy,int group_id) {int ret;
@@ -151,7 +151,7 @@ static int qxl_log_cmd_draw_copy(PCIQXLDevice *qxl, QXLCopy *copy,return 0 ; } -static int qxl_log_cmd_draw (PCIQXLDevice *qxl,QXLDrawable *draw,int group_id) +static int qxl_log_cmd_draw (QXLDevice *qxl,QXLDrawable *draw,int group_id) { fprintf(stderr, ": surface_id %d type %s effect %s", draw->surface_id,
@@ -165,7 +165,7 @@ static int qxl_log_cmd_draw(PCIQXLDevice *qxl, QXLDrawable *draw, int group_id)return 0 ; } -static int qxl_log_cmd_draw_compat (PCIQXLDevice *qxl,QXLCompatDrawable *draw, +static int qxl_log_cmd_draw_compat (QXLDevice *qxl,QXLCompatDrawable *draw,int group_id) { fprintf(stderr, ": type %s effect %s",
@@ -184,7 +184,7 @@ static int qxl_log_cmd_draw_compat(PCIQXLDevice *qxl, QXLCompatDrawable *draw,return 0 ; } -static void qxl_log_cmd_surface (PCIQXLDevice *qxl,QXLSurfaceCmd *cmd) +static void qxl_log_cmd_surface (QXLDevice *qxl,QXLSurfaceCmd *cmd) { fprintf(stderr, ": %s id %d", qxl_name(qxl_surface_cmd, cmd->type),
@@ -202,7 +202,7 @@ static void qxl_log_cmd_surface(PCIQXLDevice *qxl, QXLSurfaceCmd *cmd) } } -int qxl_log_cmd_cursor (PCIQXLDevice *qxl,QXLCursorCmd *cmd,int group_id) +int qxl_log_cmd_cursor (QXLDevice *qxl,QXLCursorCmd *cmd,int group_id) {QXLCursor *cursor;
@@ -233,13 +233,13 @@ int qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id)return 0 ; } -int qxl_log_command (PCIQXLDevice *qxl,const char *ring,QXLCommandExt *ext) +int qxl_log_command (QXLDevice *qxl,const char *ring,QXLCommandExt *ext) {bool compat = ext->flags &QXL_COMMAND_FLAG_COMPAT ;void *data;int ret; -if (!qxl->cmdlog) { +if (!qxl->pci.cmdlog) {return 0 ; } fprintf(stderr, "%" PRId64 " qxl-%d/%s:", qemu_get_clock_ns(vm_clock),
hw/qxl-render.c +15 -14
@@ -21,18 +21,18 @@#include "qxl.h" -static void qxl_blit (PCIQXLDevice *qxl,QXLRect *rect) +static void qxl_blit (QXLDevice *qxl,QXLRect *rect) {uint8_t *src; -uint8_t *dst = qxl->vga.ds->surface->data; +uint8_t *dst = qxl->pci.vga.ds->surface->data;int len, i; -if (is_buffer_shared (qxl->vga.ds->surface)) { +if (is_buffer_shared (qxl->pci.vga.ds->surface)) {return ; }if (!qxl->guest_primary.data) {trace_qxl_render_blit_guest_primary_initialized (); - qxl->guest_primary.data =memory_region_get_ram_ptr (&qxl->vga.vram); + qxl->guest_primary.data =memory_region_get_ram_ptr (&qxl->pci.vga.vram); }trace_qxl_render_blit (qxl->guest_primary.qxl_stride, rect->left, rect->right, rect->top, rect->bottom);
@@ -57,7 +57,7 @@ static void qxl_blit(PCIQXLDevice *qxl, QXLRect *rect) } } -void qxl_render_resize (PCIQXLDevice *qxl) +void qxl_render_resize (QXLDevice *qxl) {QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
@@ -87,7 +87,7 @@ void qxl_render_resize(PCIQXLDevice *qxl) } } -static void qxl_set_rect_to_surface (PCIQXLDevice *qxl,QXLRect *area) +static void qxl_set_rect_to_surface (QXLDevice *qxl,QXLRect *area) { area->left =0 ; area->right = qxl->guest_primary.surface.width;
@@ -95,15 +95,16 @@ static void qxl_set_rect_to_surface(PCIQXLDevice *qxl, QXLRect *area) area->bottom = qxl->guest_primary.surface.height; } -static void qxl_render_update_area_unlocked (PCIQXLDevice *qxl) +static void qxl_render_update_area_unlocked (QXLDevice *qxl) { -VGACommonState *vga = &qxl->vga; +VGACommonState *vga = &qxl->pci.vga;int i;DisplaySurface *surface = vga->ds->surface;if (qxl->guest_primary.resized) { qxl->guest_primary.resized =0 ; - qxl->guest_primary.data =memory_region_get_ram_ptr (&qxl->vga.vram); + qxl->guest_primary.data = +memory_region_get_ram_ptr (&qxl->pci.vga.vram);qxl_set_rect_to_surface (qxl, &qxl->dirty[0 ]); qxl->num_dirty_rects =1 ; trace_qxl_render_guest_primary_resized(
@@ -148,7 +149,7 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)* callbacks are called by spice_server thread, defering to bh called from the * io thread. */ -void qxl_render_update (PCIQXLDevice *qxl) +void qxl_render_update (QXLDevice *qxl) {QXLCookie *cookie;
@@ -172,14 +173,14 @@ void qxl_render_update(PCIQXLDevice *qxl)void qxl_render_update_area_bh (void *opaque) { -PCIQXLDevice *qxl = opaque; +QXLDevice *qxl = opaque;qemu_mutex_lock (&qxl->ssd.lock);qxl_render_update_area_unlocked (qxl);qemu_mutex_unlock (&qxl->ssd.lock); } -void qxl_render_update_area_done (PCIQXLDevice *qxl,QXLCookie *cookie) +void qxl_render_update_area_done (QXLDevice *qxl,QXLCookie *cookie) {qemu_mutex_lock (&qxl->ssd.lock);trace_qxl_render_update_area_done (cookie);
@@ -189,7 +190,7 @@ void qxl_render_update_area_done(PCIQXLDevice *qxl, QXLCookie *cookie)g_free (cookie); } -static QEMUCursor *qxl_cursor (PCIQXLDevice *qxl,QXLCursor *cursor) +static QEMUCursor *qxl_cursor (QXLDevice *qxl,QXLCursor *cursor) {QEMUCursor *c;uint8_t *image, *mask;
@@ -228,7 +229,7 @@ fail:/* called from spice server thread context only */ -int qxl_render_cursor (PCIQXLDevice *qxl,QXLCommandExt *ext) +int qxl_render_cursor (QXLDevice *qxl,QXLCommandExt *ext) {QXLCursorCmd *cmd =qxl_phys2virt (qxl, ext->cmd.data, ext->group_id);QXLCursor *cursor;
hw/qxl.c +219 -217
1,176 lines not on this page · raw message
hw/qxl.h +61 -49
161 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 1/4] qxl: create a qxl common struct!
Quoted 16 lines · Erlon Cruz
From: Fabiano Fidêncio <[email protected]>
This commit is creating a QXLDevice struct, entirely based on PCIQXLDevice struct, but separating parts that will be shared between PCIQXLDevice and VirtIOQXLDevice. All functions were changed to support the new QXLDevice struct.
hw/qxl.h +0
-1@@ -25,19 +25,44 @@ enum qxl_mode {#define QXL_NUM_DIRTY_RECTS 64 typedef struct PCIQXLDevice { - PCIDevice pci;
hw/qxl.h enum qxl_mode { · line 32
Quoted 10 lines
hw/qxl.h +5
-5-SimpleSpiceDisplay ssd; -int id; -uint32_t debug; -uint32_t guestdebug; -uint32_t cmdlog; +PCIDevice pci; +int generation; +uint32_t revision; +uint32_t guestdebug; +uint32_t cmdlog;
Please avoid whitespace changes like this which make it harder to see the actual changes.
hw/qxl.h enum qxl_mode { · line 60
Quoted 2 lines
hw/qxl.h +2
-0+typedef struct QXLDevice { + PCIQXLDevice pci;
This is wrong, QXLDevice should only carry the shared parts.
Data structures should be this way:
struct QXLDevice {
/* any shared fields go here */
};
struct PCIQXLDevice {
PCIDevice pci; /* must be first because of qdev */
QXLDevice qxl; /* common stuff */
/* pci-specifiec fields (pci bars etc) go here */
};
struct VirtioQXLDevice {
VirtIODevice vdev;
QXLDevice qxl;
/* virtio-specific fields go here */
};
If some function got a struct QXLDevice passed in and you need access to PCIQXLDevice or VirtioQXLDevice you can use the container_of macro.
See hw/usb/hcd-ohci.c for an example, ohci emulation exists in pci and sysbus variants and thus is structed in a simliar way.
cheers,
Gerd
PATCH 2/4 qxl: split qxl functions in common and pci files
In reply to Erlon CruzFrom: Fabiano Fidêncio <[email protected]>
This commit splits qxl functions into common functions (located in qxl.c) and pci-specific functions (located in qxl-pci.c). All prototypes are being kept in qxl.h, as common MACROS and inline functions. Moreover, this commit is exposing a lot of APIs, don't know if it's the correct way to do it, but it was the only way that we saw to do it.
--- hw/i386/Makefile.objs | 2 +- hw/qxl-pci.c | 1607 +++++++++++++++++++++++++++++++++++++++++++++ hw/qxl.c | 1733 +------------------------------------------------ hw/qxl.h | 120 ++++ 4 files changed, 1763 insertions(+), 1699 deletions(-) create mode 100644 hw/qxl-pci.c
hw/i386/Makefile.objs +1 -1
@@ -10,6 +10,6 @@ obj-$(CONFIG_XEN) += xen_platform.o xen_apic.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.o obj-y += kvm/ -obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o +obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o qxl-pci.o obj-y := $(addprefix ../,$(obj-y))
hw/qxl-pci.c new file +1607 -0
1,607 lines not on this page · raw message
hw/qxl.c +35 -1698
1,386 lines not on this page · raw message
hw/qxl.h +120 -0
120 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.4.1
Part of the diff is not shown here. View the raw message.
Re: [Qemu-devel] [PATCH 2/4] qxl: split qxl functions in common and pci files
Quoted 8 lines · Erlon Cruz
From: Fabiano Fidêncio <[email protected]>
This commit splits qxl functions into common functions (located in
qxl.c) and pci-specific functions (located inqxl-pci.c). All prototypes are being kept inqxl.h, as common MACROS and inline functions. Moreover, this commit is exposing a lot of APIs, don't know if it's the correct way to do it, but it was the only way that we saw to do it.
Try enabling rename detection for this one (git format-patch -M).
Quoted 5 lines
hw/qxl.h +0
-0
hw/qxl.h typedef struct QXLDevice { · line 151
Quoted 9 lines
hw/qxl.h +6
-0@@ -143,6 +143,44 @@ typedef struct QXLDevice { } \ }while (0 ) +/* +* NOTE: SPICE_RING_PROD_ITEM accesses memory on the pci bar and as +* such can be changed by the guest, so to avoid a guest trigerrable +* abort we just qxl_set_guest_bug and set the return to NULL. Still +* it may happen as a result of emulator bug as well. +*/
Why these are here and not in qxl-pci.c?
hw/qxl.h void qxl_spice_oom(QXLDevice *qxl); · line 200
Quoted 2 lines
hw/qxl.h +2
-0+void init_qxl_rom (QXLDevice *d); +void init_qxl_ram (QXLDevice *d);
Same question.
hw/qxl.h void qxl_spice_oom(QXLDevice *qxl); · line 214
Quoted 11 lines
hw/qxl.h +11
-0+void interface_get_init_info (QXLInstance *sin,QXLDevInitInfo *info); +int interface_get_command (QXLInstance *sin,struct QXLCommandExt *ext); +int interface_req_cmd_notification (QXLInstance *sin); +void interface_release_resource (QXLInstance *sin,struct QXLReleaseInfoExt ext); +int interface_get_cursor_command (QXLInstance *sin,struct QXLCommandExt *ext); +int interface_req_cursor_notification (QXLInstance *sin); +void interface_notify_update (QXLInstance *sin,uint32_t update_id); +int interface_flush_resources (QXLInstance *sin); +void interface_update_area_complete (QXLInstance *sin,uint32_t surface_id,QXLRect *dirty,uint32_t num_updated_rects); +void interface_async_complete (QXLInstance *sin,uint64_t cookie_token); +ram_addr_t qxl_rom_size (void );
Same question.
I'd expect at least some of these having a virtio-specific implementation. interface_get_command() for example, which gets a qxl command from the ring ...
cheers,
Gerd
PATCH 3/4 qxl: implement VirtIO QXL (dummy) device support
In reply to Erlon CruzFrom: Fabiano Fidêncio <[email protected]>
This commit introduces the devices stubs that use Virtio infrastructure to transport QXL commands.
--- hw/i386/Makefile.objs | 2 +- hw/pci.h | 1 + hw/qxl-virtio.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/virtio-pci.c | 4 +- hw/virtio-pci.h | 2 + hw/virtio.h | 2 + qemu-config.c | 13 +++++++ qemu-options.hx | 7 ++++ vl.c | 15 +++++++- 9 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 hw/qxl-virtio.c
hw/i386/Makefile.objs +1 -1
@@ -10,6 +10,6 @@ obj-$(CONFIG_XEN) += xen_platform.o xen_apic.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.o obj-y += kvm/ -obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o qxl-pci.o +obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o qxl-pci.o qxl-virtio.o obj-y := $(addprefix ../,$(obj-y))
hw/pci.h +1 -0
@@ -76,6 +76,7 @@#define PCI_DEVICE_ID_VIRTIO_BALLOON 0x1002#define PCI_DEVICE_ID_VIRTIO_CONSOLE 0x1003#define PCI_DEVICE_ID_VIRTIO_SCSI 0x1004 +#define PCI_DEVICE_ID_VIRTIO_QXL 0x1005#define FMT_PCIBUS PRIx64
hw/qxl-virtio.c new file +93 -0
93 lines not on this page · raw message
hw/virtio-pci.c +2 -2
@@ -221,7 +221,7 @@ assign_error:error_report ("%s: failed. Fallback to a userspace (slower)." , __func__); } -static void virtio_pci_stop_ioeventfd (VirtIOPCIProxy *proxy) +void virtio_pci_stop_ioeventfd (VirtIOPCIProxy *proxy) {int r;int n;
@@ -779,7 +779,7 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev)return 0 ; } -static void virtio_exit_pci (PCIDevice *pci_dev) +void virtio_exit_pci (PCIDevice *pci_dev) {VirtIOPCIProxy *proxy =DO_UPCAST (VirtIOPCIProxy, pci_dev, pci_dev);
hw/virtio-pci.h +2 -0
@@ -53,6 +53,8 @@ typedef struct {void virtio_init_pci (VirtIOPCIProxy *proxy,VirtIODevice *vdev);void virtio_pci_reset (DeviceState *d); +void virtio_pci_stop_ioeventfd (VirtIOPCIProxy *proxy); +void virtio_exit_pci (PCIDevice *pci_dev);/* Virtio ABI version, if we increment this, we break the guest driver. */ #define VIRTIO_PCI_ABI_VERSION 0
hw/virtio.h +2 -0
@@ -200,6 +200,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *serial);VirtIODevice *virtio_balloon_init (DeviceState *dev);typedef struct VirtIOSCSIConf VirtIOSCSIConf ;VirtIODevice *virtio_scsi_init (DeviceState *dev,VirtIOSCSIConf *conf); +VirtIODevice *virtio_qxl_init (DeviceState *dev);#ifdef CONFIG_LINUX VirtIODevice *virtio_9p_init (DeviceState *dev,V9fsConf *conf);#endif
@@ -210,6 +211,7 @@ void virtio_blk_exit(VirtIODevice *vdev);void virtio_serial_exit (VirtIODevice *vdev);void virtio_balloon_exit (VirtIODevice *vdev);void virtio_scsi_exit (VirtIODevice *vdev); +void virtio_qxl_exit (VirtIODevice *vdev);#define DEFINE_VIRTIO_COMMON_FEATURES (_state, _field) \ DEFINE_PROP_BIT("indirect_desc", _state, _field, \
qemu-config.c +13 -0
@@ -643,6 +643,18 @@ QemuOptsList qemu_boot_opts = { }, }; +QemuOptsList qemu_virtio_qxl_opts = { + .name ="virtio-qxl" , + .head =QTAILQ_HEAD_INITIALIZER (qemu_virtio_qxl_opts.head), + .desc = { +/* +* no elements => accepty any +* sanity checking will happen later when setting device properties +*/ + {/* end of list */ } + }, +}; +static QemuOptsList *vm_config_groups[32 ] = { &qemu_drive_opts, &qemu_chardev_opts,
@@ -659,6 +671,7 @@ static QemuOptsList *vm_config_groups[32] = { &qemu_boot_opts, &qemu_iscsi_opts, &qemu_sandbox_opts, + &qemu_virtio_qxl_opts, NULL, };
qemu-options.hx +7 -0
@@ -569,6 +569,13 @@ ETEXI DEFHEADING() +DEFHEADING(QXL VirtIO option:) + +DEF("virtio-qxl", 0, QEMU_OPTION_virtio_qxl, "-virtio-qxl\n", +QEMU_ARCH_ALL) + +DEFHEADING() + DEFHEADING(File system options:) DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
vl.c +14 -1
@@ -233,6 +233,7 @@ int boot_menu;uint8_t *boot_splash_filedata;int boot_splash_filedata_size;uint8_t qemu_extra_params_fw[2 ]; +int virtio_qxl_enabled =0 ;typedef struct FWBootEntry FWBootEntry ;
@@ -2951,6 +2952,18 @@ int main(int argc, char **argv, char **envp)qemu_opt_set (device,"mount_tag" ,"v_synth" );break ; } +case QEMU_OPTION_virtio_qxl: { +QemuOpts *device; + + virtio_qxl_enabled =1 ; + vga_model ="none" ; + default_vga =0 ; + device =qemu_opts_create (qemu_find_opts ("device" ),NULL ,0 , +NULL ); +qemu_opt_set (device,"driver" ,"virtio-qxl-pci" ); +break ; + + }case QEMU_OPTION_serial:add_device_config (DEV_SERIAL , optarg); default_serial =0 ;
@@ -3692,7 +3705,7 @@ int main(int argc, char **argv, char **envp) }#endif #ifdef CONFIG_SPICE -if (using_spice && !qxl_enabled) { +if (using_spice && !qxl_enabled && !virtio_qxl_enabled) {qemu_spice_display_init (ds); }#endif
Signature · 1 line
1.7.4.1
PATCH 4/4 qxl: introducing virtio-qxl
In reply to Erlon CruzFrom: Fabiano Fidêncio <[email protected]>
The VirtioQXL device is a graphical video device that makes possible to use of SPICE protocol over virtio transport.
QXL commands are generated in the guest xf86 driver and pushed to host through in a single VQ. The commands are copied to device memory and then consumed by spice server. The SPICE command rings (Cursor,release and Command) are used as they are, i.e., like with the commands, the ring elements and its control fields are push/poped from guest to host. After consuming an element, the host updates the guest's ring. As with the PCI QXL driver, the spice server send rendering (QXL) commands to the spice client which actually render them. So far the driver has no VGA functionality.
To enable the VirtIOQXL device, use '-virtio-qxl'. Video output will be shown only after start some graphical application. As there will be no early boot messages output, is helpful to redirect the serial console to stdout (-serial stdio, plus passing a kernel parameter 'console=ttyS0'
Issues:
We need to increase virtio ring from 1024 to 8192 elements. Please, any tip to fix it is welcome :)
--- hw/ppc/Makefile.objs | 2 +- hw/qxl-pci.c | 1 + hw/qxl-render.c | 37 ++-- hw/qxl-virtio.c | 588 +++++++++++++++++++++++++++++++++++++++++++++++++- hw/qxl-virtio.h | 61 ++++++ hw/qxl.c | 111 +++++++--- hw/qxl.h | 76 ++++++-- hw/spapr.c | 3 +- hw/virtio.h | 2 +- qemu-config.c | 9 +- qemu-options.hx | 2 +- sysemu.h | 1 + vl.c | 12 +- 13 files changed, 831 insertions(+), 74 deletions(-) create mode 100644 hw/qxl-virtio.h
hw/ppc/Makefile.objs +1 -1
@@ -21,7 +21,7 @@ obj-y += virtex_ml507.o # PowerPC OpenPIC obj-y += openpic.o obj-$(CONFIG_FDT) += ../device_tree.o - +obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o qxl-pci.o qxl-virtio.o # Xilinx PPC peripherals obj-y += xilinx_ethlite.o
hw/qxl-pci.c +1 -0
@@ -1253,6 +1253,7 @@ static int qxl_init_common(QXLDevice *qxl)qemu_mutex_init (&qxl->async_lock); qxl->current_async =QXL_UNDEFINED_IO ; qxl->pci.guest_bug =0 ; + qxl->transport =QXL_TRANSPORT_PCI ;switch (qxl->pci.revision) {case 1 :/* spice 0.4 -- qxl-1 */
hw/qxl-render.c +23 -14
@@ -24,15 +24,19 @@static void qxl_blit (QXLDevice *qxl,QXLRect *rect) {uint8_t *src; -uint8_t *dst = qxl->pci.vga.ds->surface->data; +uint8_t *dst = (qxl->transport ==QXL_TRANSPORT_PCI ) ? + qxl->pci.vga.ds->surface->data : qxl->ssd.ds->surface->data;int len, i; -if (is_buffer_shared (qxl->pci.vga.ds->surface)) { +if (qxl->transport ==QXL_TRANSPORT_PCI && +is_buffer_shared (qxl->pci.vga.ds->surface)) {return ; }if (!qxl->guest_primary.data) {trace_qxl_render_blit_guest_primary_initialized (); - qxl->guest_primary.data =memory_region_get_ram_ptr (&qxl->pci.vga.vram); + qxl->guest_primary.data = (qxl->transport ==QXL_TRANSPORT_PCI ) ? +memory_region_get_ram_ptr (&qxl->pci.vga.vram) : + qxl->virtio.ram_ptr; }trace_qxl_render_blit (qxl->guest_primary.qxl_stride, rect->left, rect->right, rect->top, rect->bottom);
@@ -97,14 +101,15 @@ static void qxl_set_rect_to_surface(QXLDevice *qxl, QXLRect *area)static void qxl_render_update_area_unlocked (QXLDevice *qxl) { -VGACommonState *vga = &qxl->pci.vga;int i; -DisplaySurface *surface = vga->ds->surface; +DisplayState *ds = (qxl->transport ==QXL_TRANSPORT_PCI ) ? + qxl->pci.vga.ds : qxl->ssd.ds; +DisplaySurface *surface = ds->surface;if (qxl->guest_primary.resized) { qxl->guest_primary.resized =0 ; - qxl->guest_primary.data = -memory_region_get_ram_ptr (&qxl->pci.vga.vram); + qxl->guest_primary.data = (qxl->transport ==QXL_TRANSPORT_PCI ) ? +memory_region_get_ram_ptr (&qxl->pci.vga.vram) : qxl->virtio.ram_ptr;qxl_set_rect_to_surface (qxl, &qxl->dirty[0 ]); qxl->num_dirty_rects =1 ; trace_qxl_render_guest_primary_resized(
@@ -117,25 +122,25 @@ static void qxl_render_update_area_unlocked(QXLDevice *qxl)if (surface->width != qxl->guest_primary.surface.width || surface->height != qxl->guest_primary.surface.height) {if (qxl->guest_primary.qxl_stride >0 ) { -qemu_free_displaysurface (vga->ds); +qemu_free_displaysurface (ds);qemu_create_displaysurface_from (qxl->guest_primary.surface.width, qxl->guest_primary.surface.height, qxl->guest_primary.bits_pp, qxl->guest_primary.abs_stride, qxl->guest_primary.data); }else { -qemu_resize_displaysurface (vga->ds, +qemu_resize_displaysurface (ds, qxl->guest_primary.surface.width, qxl->guest_primary.surface.height); } -dpy_resize (vga->ds); +dpy_resize (ds); }for (i =0 ; i < qxl->num_dirty_rects; i++) {if (qemu_spice_rect_is_empty (qxl->dirty+i)) {break ; }qxl_blit (qxl, qxl->dirty+i); -dpy_update (vga->ds, +dpy_update (ds, qxl->dirty[i].left, qxl->dirty[i].top, qxl->dirty[i].right - qxl->dirty[i].left, qxl->dirty[i].bottom - qxl->dirty[i].top);
@@ -155,7 +160,7 @@ void qxl_render_update(QXLDevice *qxl)qemu_mutex_lock (&qxl->ssd.lock); -if (!runstate_is_running () || !qxl->guest_primary.commands) { +if (qxl->transport ==QXL_TRANSPORT_PCI && ((!runstate_is_running () || !qxl->guest_primary.commands))) {qxl_render_update_area_unlocked (qxl);qemu_mutex_unlock (&qxl->ssd.lock);return ;
@@ -231,7 +236,9 @@ fail:/* called from spice server thread context only */ int qxl_render_cursor (QXLDevice *qxl,QXLCommandExt *ext) { -QXLCursorCmd *cmd =qxl_phys2virt (qxl, ext->cmd.data, ext->group_id); +QXLCursorCmd *cmd = (qxl->transport ==QXL_TRANSPORT_PCI ) ? +qxl_phys2virt (qxl, ext->cmd.data, ext->group_id) : + (QXLCursorCmd *)ext->cmd.data;QXLCursor *cursor;QEMUCursor *c;
@@ -250,7 +257,9 @@ int qxl_render_cursor(QXLDevice *qxl, QXLCommandExt *ext) }switch (cmd->type) {case QXL_CURSOR_SET : - cursor =qxl_phys2virt (qxl, cmd->u.set.shape, ext->group_id); + cursor = (qxl->transport ==QXL_TRANSPORT_PCI ) ? +qxl_phys2virt (qxl, cmd->u.set.shape, ext->group_id) : + (QXLCursor *)cmd->u.set.shape;if (!cursor) {return 1 ; }
hw/qxl-virtio.c +583 -5
611 lines not on this page · raw message
hw/qxl-virtio.h new file +61 -0
61 lines not on this page · raw message
hw/qxl.c +81 -30
225 lines not on this page · raw message
hw/qxl.h +61 -15
138 lines not on this page · raw message
hw/spapr.c +2 -1
@@ -769,7 +769,8 @@ static void ppc_spapr_init(ram_addr_t ram_size,if (usb_enabled) {pci_create_simple (QLIST_FIRST (&spapr->phbs)->host_state.bus,-1 ,"pci-ohci" ); -if (spapr->has_graphics) { +if (spapr->has_graphics || virtio_qxl_enabled) { +printf ("Starting USB inputs\n" );usbdevice_create ("keyboard" );usbdevice_create ("mouse" ); }
hw/virtio.h +1 -1
@@ -77,7 +77,7 @@ static inline target_phys_addr_t vring_align(target_phys_addr_t addr,typedef struct VirtQueue VirtQueue ; -#define VIRTQUEUE_MAX_SIZE 1024 +#define VIRTQUEUE_MAX_SIZE 8192 typedef struct VirtQueueElement {
qemu-config.c +5 -4
@@ -645,12 +645,13 @@ QemuOptsList qemu_boot_opts = {QemuOptsList qemu_virtio_qxl_opts = { .name ="virtio-qxl" , + .implied_opt_name ="ram_size_mb" , .head =QTAILQ_HEAD_INITIALIZER (qemu_virtio_qxl_opts.head), .desc = { -/* -* no elements => accepty any -* sanity checking will happen later when setting device properties -*/ + { + .name ="ram_size_mb" , + .type =QEMU_OPT_NUMBER , + }, {/* end of list */ } }, };
qemu-options.hx +1 -1
@@ -571,7 +571,7 @@ DEFHEADING() DEFHEADING(QXL VirtIO option:) -DEF("virtio-qxl", 0, QEMU_OPTION_virtio_qxl, "-virtio-qxl\n", +DEF("virtio-qxl", HAS_ARG, QEMU_OPTION_virtio_qxl, "-virtio-qxl ram_size_mb=XXX\n", QEMU_ARCH_ALL) DEFHEADING()
sysemu.h +1 -0
@@ -120,6 +120,7 @@ extern int win2k_install_hack;extern int alt_grab;extern int ctrl_grab;extern int usb_enabled; +extern int virtio_qxl_enabled;extern int smp_cpus;extern int max_cpus;extern int cursor_hide;
vl.c +10 -2
@@ -234,6 +234,7 @@ uint8_t *boot_splash_filedata;int boot_splash_filedata_size;uint8_t qemu_extra_params_fw[2 ];int virtio_qxl_enabled =0 ; +uint64_t virtio_qxl_ram =0 ;typedef struct FWBootEntry FWBootEntry ;
@@ -2958,11 +2959,18 @@ int main(int argc, char **argv, char **envp) virtio_qxl_enabled =1 ; vga_model ="none" ; default_vga =0 ; - device =qemu_opts_create (qemu_find_opts ("device" ),NULL ,0 , + device =qemu_opts_create (qemu_find_opts ("device" ), +NULL , +0 ,NULL );qemu_opt_set (device,"driver" ,"virtio-qxl-pci" ); -break ; + olist =qemu_find_opts ("virtio-qxl" ); + opts =qemu_opts_parse (olist, optarg,1 ); + virtio_qxl_ram =qemu_opt_get_number (opts, +"ram_size_mb" , +64 ); +break ; }case QEMU_OPTION_serial:add_device_config (DEV_SERIAL , optarg);
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 4/4] qxl: introducing virtio-qxl
Hi,
Quoted 1 line
To enable the VirtIOQXL device, use '-virtio-qxl'. Video output will be
Please don't add a new option. 'qemu -vga none -device virtio-qxl' should work these days. You could also make virtio-qxl a valid choice for '-vga' for convenience.
cheers,
Gerd
Quoted 1 line · Erlon Cruz
The following patches makes provides video support to non PCI architectures, please review!
Can you give an overview on the virtio-qxl virtual hardware design?
thanks,
Gerd
Quoted 4 lines · Gerd Hoffmann
Quoted 1 line · Erlon Cruz
The following patches makes provides video support to non PCI architectures, please review!
Can you give an overview on the virtio-qxl virtual hardware design?
Self-reply-ing. There is a paper on it (got link @ irc):
Well. The design is *way* too close to the original, non-virtio qxl device. The reason is code reuse according to the paper. I think it would be *much* better to just take a fresh start. Reasons:
First the qxl device carries a bunch of legacy stuff for compatibility with old guests & guest drivers. When designing a new device I'd like to throw away as much as possible of this stuff.
Second you'll need a kernel driver to drive the virtio queues. The linux graphics world is moving to kernel drivers (aka kms) anyway, so this shouldn't be a big issue. You'll also get a framebuffer console then, so you can see the linux boot messages quite early. That is a nice thing, especially without vga compatibility.
More hints:
On memory management: spice does *not* require device memory. spice has "memory slots". They are a thin layer to allow the spice server library dereference pointers in qxl commands. qxl allows guests to register memory slots for the qxl device memory. That is a qxl restriction though, not a spice restriction. Letting the virtio-qxl kms driver allocate a big memory block at boot, then register that as memory slot and store qxl commands, cmd data + surfaces there is no problem, spice server can handle that just fine. No copying needed. You could also setup memory slot(s) for *all* guest ram, then kmalloc() memory as needed.
Don't use spice rings at all. Use virtio rings instead. I think we need these:
(1) spice rendering commands (replaces QXLCommandRing).
(2) spice cursor commands (replaces QXLCursorRing).
(3) resource release (replaces QXLReleaseRing).
(4) device setup ring (replace QXL_IO_*).
(5) device event ring (spice server notifications go here, replacing QXL_INTERRUPT_*).
Don't use QXLRom. The mode table in qxlrom is historical baggage anyway and should be dropped. Most of the other stuff is related to the qxl device too and can be dropped. Anything remaining can be queried by the guest using a virtio request on the device setup ring.
Don't use QXLRam. Arguments for QXL_IO_* ops are there, this can be stuffed into the virtio request buffer instead.
cheers,
Gerd