Skip to contentSkip to conversation

virtio-gpu: pci support bits.

PATCH Superseded Gerd Hoffmann 1 participant 4 messages Jun 10, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover virtio-gpu: pci support bits.

Hi,

Here is the code to add virtio-pci support for the virtio-gpu. This series depends on the vga pull request sent earlier today the the virtio-1.0 patch series sent last week.

vgabios support is not included yet as this depends on not-yet merged changes in seabios.

This series with dependencies, a few more pending vga bits and some hacks to simplify testing (vgabios update, masquerade virtio-vga as stdvga so testing with libvirt works) are available from
https://www.kraxel.org/cgit/qemu/log/?h=rebase/vga-wip

Gerd Hoffmann (3):
virtio-gpu-pci: add virtio pci support
virtio-vga: add virtio gpu device with vga compatibility
virtio-vga: add '-vga virtio' support

 default-configs/x86_64-softmmu.mak |   1 +
 hw/display/Makefile.objs           |   2 +
 hw/display/vga-pci.c               |   8 +-
 hw/display/vga_int.h               |   6 ++
 hw/display/virtio-gpu-pci.c        |  68 +++++++++++++++
 hw/display/virtio-vga.c            | 174 +++++++++++++++++++++++++++++++++++++
 hw/isa/isa-bus.c                   |   3 +
 hw/pci/pci.c                       |   2 +
 hw/virtio/virtio-pci.h             |  14 +++
 include/sysemu/sysemu.h            |   2 +-
 qemu-options.hx                    |   4 +-
 vl.c                               |  13 +++
 12 files changed, 291 insertions(+), 6 deletions(-)
 create mode 100644 hw/display/virtio-gpu-pci.c
 create mode 100644 hw/display/virtio-vga.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/3 virtio-gpu-pci: add virtio pci support

This patch adds virtio-gpu-pci, which is the pci proxy for the virtio gpu device. With this patch in place virtio-gpu is functional. You need a linux guest with a virtio-gpu driver though, and output will appear pretty late in boot, once the kernel initialized drm and fbcon.

Written by Dave Airlie and Gerd Hoffmann.

---
 hw/display/Makefile.objs    |  1 +
 hw/display/virtio-gpu-pci.c | 68 +++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pci.h      | 14 ++++++++++
 3 files changed, 83 insertions(+)
 create mode 100644 hw/display/virtio-gpu-pci.c
hw/display/Makefile.objs +1 -0
index 61c80f3..26284a1 100644
@@ -36,3 +36,4 @@ obj-$(CONFIG_VGA) += vga.o
 common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o
 
 obj-$(CONFIG_VIRTIO) += virtio-gpu.o
+obj-$(CONFIG_VIRTIO_PCI) += virtio-gpu-pci.o
hw/display/virtio-gpu-pci.c new file +68 -0

68 lines not on this page · raw message

hw/virtio/virtio-pci.h +14 -0
index d962125..96025ca 100644
@@ -25,6 +25,7 @@
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-9p.h"
 #include "hw/virtio/virtio-input.h"
+#include "hw/virtio/virtio-gpu.h"
 #ifdef CONFIG_VIRTFS
 #include "hw/9pfs/virtio-9p.h"
 #endif
@@ -42,6 +43,7 @@ typedef struct VHostSCSIPCI VHostSCSIPCI;
 typedef struct VirtIORngPCI VirtIORngPCI;
 typedef struct VirtIOInputPCI VirtIOInputPCI;
 typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI;
+typedef struct VirtIOGPUPCI VirtIOGPUPCI;
 
 /* virtio-pci-bus */
 
@@ -261,6 +263,18 @@ struct VirtIOInputHIDPCI {
     VirtIOInputHID vdev;
 };
 
+/*
+ * virtio-gpu-pci: This extends VirtioPCIProxy.
+ */
+#define TYPE_VIRTIO_GPU_PCI "virtio-gpu-pci"
+#define VIRTIO_GPU_PCI(obj) \
+        OBJECT_CHECK(VirtIOGPUPCI, (obj), TYPE_VIRTIO_GPU_PCI)
+
+struct VirtIOGPUPCI {
+    VirtIOPCIProxy parent_obj;
+    VirtIOGPU vdev;
+};
+
 /* Virtio ABI version, if we increment this, we break the guest driver. */
 #define VIRTIO_PCI_ABI_VERSION          0
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/3 virtio-vga: add virtio gpu device with vga compatibility

In reply to Gerd Hoffmann

This patch adds a virtio-vga device. It is simliar to virtio-gpu-pci, but it also adds in vga compatibility, so guests without native virtio-gpu support can drive the device in vga mode. It is compatible with stdvga.

Written by Dave Airlie and Gerd Hoffmann.

---
 default-configs/x86_64-softmmu.mak |   1 +
 hw/display/Makefile.objs           |   1 +
 hw/display/vga-pci.c               |   8 +-
 hw/display/vga_int.h               |   6 ++
 hw/display/virtio-vga.c            | 174 +++++++++++++++++++++++++++++++++++++
 5 files changed, 186 insertions(+), 4 deletions(-)
 create mode 100644 hw/display/virtio-vga.c
default-configs/x86_64-softmmu.mak +1 -0
index 2f2955b..62575eb 100644
@@ -7,6 +7,7 @@ CONFIG_QXL=$(CONFIG_SPICE)
 CONFIG_VGA_ISA=y
 CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
+CONFIG_VIRTIO_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
hw/display/Makefile.objs +1 -0
index 26284a1..dd8ea76 100644
@@ -37,3 +37,4 @@ common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o
 
 obj-$(CONFIG_VIRTIO) += virtio-gpu.o
 obj-$(CONFIG_VIRTIO_PCI) += virtio-gpu-pci.o
+obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
hw/display/vga-pci.c +4 -4
index 0ed44c7..1dfa331 100644
@@ -204,10 +204,10 @@ static const MemoryRegionOps pci_vga_qext_ops = {
     .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
-static void pci_std_vga_mmio_region_init(VGACommonState *s,
-                                         MemoryRegion *parent,
-                                         MemoryRegion *subs,
-                                         bool qext)
+void pci_std_vga_mmio_region_init(VGACommonState *s,
+                                  MemoryRegion *parent,
+                                  MemoryRegion *subs,
+                                  bool qext)
 {
     memory_region_init_io(&subs[0], NULL, &pci_vga_ioport_ops, s,
                           "vga ioports remapped", PCI_VGA_IOPORT_SIZE);
hw/display/vga_int.h +6 -0
index fcfcc5f..40ba6a4 100644
@@ -219,4 +219,10 @@ extern const uint8_t gr_mask[16];
 
 extern const MemoryRegionOps vga_mem_ops;
 
+/* vga-pci.c */
+void pci_std_vga_mmio_region_init(VGACommonState *s,
+                                  MemoryRegion *parent,
+                                  MemoryRegion *subs,
+                                  bool qext);
+
 #endif
hw/display/virtio-vga.c new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/3 virtio-vga: add '-vga virtio' support

In reply to Gerd Hoffmann

Some convinience fluff: Add support for '-vga virtio', also add virtio-vga to the list of vga cards so '-device virtio-vga' will turn off the default vga.

Written by Dave Airlie and Gerd Hoffmann.

---
 hw/isa/isa-bus.c        |  3 +++
 hw/pci/pci.c            |  2 ++
 include/sysemu/sysemu.h |  2 +-
 qemu-options.hx         |  4 +++-
 vl.c                    | 13 +++++++++++++
 5 files changed, 22 insertions(+), 2 deletions(-)
hw/isa/isa-bus.c +3 -0
index ec8e7de..43e0cd8 100644
@@ -179,6 +179,9 @@ ISADevice *isa_vga_init(ISABus *bus)
     case VGA_VMWARE:
         fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __func__);
         return NULL;
+    case VGA_VIRTIO:
+        fprintf(stderr, "%s: virtio-vga: no PCI bus\n", __func__);
+        return NULL;
     case VGA_NONE:
     default:
         return NULL;
hw/pci/pci.c +2 -0
index 750f3da..2158043 100644
@@ -1698,6 +1698,8 @@ PCIDevice *pci_vga_init(PCIBus *bus)
         return pci_create_simple(bus, -1, "VGA");
     case VGA_VMWARE:
         return pci_create_simple(bus, -1, "vmware-svga");
+    case VGA_VIRTIO:
+        return pci_create_simple(bus, -1, "virtio-vga");
     case VGA_NONE:
     default: /* Other non-PCI types. Checking for unsupported types is already
                 done in vl.c. */
include/sysemu/sysemu.h +1 -1
index 853d90a..7beb926 100644
@@ -104,7 +104,7 @@ extern int autostart;
 
 typedef enum {
     VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
-    VGA_TCX, VGA_CG3, VGA_DEVICE
+    VGA_TCX, VGA_CG3, VGA_DEVICE, VGA_VIRTIO,
 } VGAInterfaceType;
 
 extern int vga_interface_type;
qemu-options.hx +3 -1
index 4be98f7..ab617c3 100644
@@ -1103,7 +1103,7 @@ Rotate graphical output some deg left (only PXA LCD).
 ETEXI
 
 DEF("vga", HAS_ARG, QEMU_OPTION_vga,
-    "-vga [std|cirrus|vmware|qxl|xenfb|tcx|cg3|none]\n"
+    "-vga [std|cirrus|vmware|qxl|xenfb|tcx|cg3|virtio|none]\n"
     "                select video card type\n", QEMU_ARCH_ALL)
 STEXI
 @item -vga @var{type}
@@ -1136,6 +1136,8 @@ fixed resolution of 1024x768.
 (sun4m only) Sun cgthree framebuffer. This is a simple 8-bit framebuffer
 for sun4m machines available in both 1024x768 (OpenBIOS) and 1152x900 (OBP)
 resolutions aimed at people wishing to run older Solaris versions.
+@item virtio
+Virtio VGA card.
 @item none
 Disable VGA card.
 @end table
vl.c +13 -0
index d4b2d03..80ae8da 100644
@@ -231,6 +231,7 @@ static struct {
     { .driver = "isa-cirrus-vga",       .flag = &default_vga       },
     { .driver = "vmware-svga",          .flag = &default_vga       },
     { .driver = "qxl-vga",              .flag = &default_vga       },
+    { .driver = "virtio-vga",           .flag = &default_vga       },
 };
 
 static QemuOptsList qemu_rtc_opts = {
@@ -1865,6 +1866,11 @@ static bool cg3_vga_available(void)
     return object_class_by_name("cgthree");
 }
 
+static bool virtio_vga_available(void)
+{
+    return object_class_by_name("virtio-vga");
+}
+
 static void select_vgahw (const char *p)
 {
     const char *opts;
@@ -1891,6 +1897,13 @@ static void select_vgahw (const char *p)
             fprintf(stderr, "Error: VMWare SVGA not available\n");
             exit(0);
         }
+    } else if (strstart(p, "virtio", &opts)) {
+        if (virtio_vga_available()) {
+            vga_interface_type = VGA_VIRTIO;
+        } else {
+            fprintf(stderr, "Error: Virtio VGA not available\n");
+            exit(0);
+        }
     } else if (strstart(p, "xenfb", &opts)) {
         vga_interface_type = VGA_XENFB;
     } else if (strstart(p, "qxl", &opts)) {
Signature · 1 line
1.8.3.1