Skip to contentSkip to conversation

virtio-gpu: pci support bits.

PATCH New Gerd Hoffmann 1 participant 7 messages Jun 12, 2015 Kbuild

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/6 virtio-gpu: fix error message

In reply to Gerd Hoffmann

iov limit was raised, but the error message still has the old limit ...

---
 hw/display/virtio-gpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/virtio-gpu.c +1 -1
index 4b10ca1..8c109b7 100644
@@ -534,7 +534,7 @@ int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,
 
     if (ab->nr_entries > 16384) {
         qemu_log_mask(LOG_GUEST_ERROR,
-                      "%s: nr_entries is too big (%d > 1024)\n",
+                      "%s: nr_entries is too big (%d > 16384)\n",
                       __func__, ab->nr_entries);
         return -1;
     }
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v2 2/6 virtio-gpu-pci: add virtio pci support

In reply to Gerd Hoffmann

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
#5 lore raw

PATCH v2 5/6 virtio-vga: add vgabios configuration

In reply to Gerd Hoffmann

Add seavgabios configuration for virtio-vga,
hook up the new vgabios in the makefiles.

---
 Makefile               | 2 +-
 roms/Makefile          | 2 +-
 roms/config.vga-virtio | 6 ++++++
 3 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 roms/config.vga-virtio
Makefile +1 -1
index 2d52536..3f97904 100644
@@ -342,7 +342,7 @@ bepo    cz
 
 ifdef INSTALL_BLOBS
 BLOBS=bios.bin bios-256k.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
-vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin \
+vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
 acpi-dsdt.aml q35-acpi-dsdt.aml \
 ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
 pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
roms/Makefile +1 -1
index 610b534..c76cd5b 100644
@@ -1,5 +1,5 @@
 
-vgabios_variants := stdvga cirrus vmware qxl isavga
+vgabios_variants := stdvga cirrus vmware qxl isavga virtio
 vgabios_targets  := $(subst -isavga,,$(patsubst %,vgabios-%.bin,$(vgabios_variants)))
 pxerom_variants  := e1000 eepro100 ne2k_pci pcnet rtl8139 virtio
 pxerom_targets   := 8086100e 80861209 10500940 10222000 10ec8139 1af41000
roms/config.vga-virtio new file +6 -0
new file mode 100644
index 0000000..aa7a15b
@@ -0,0 +1,6 @@
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_BOCHS=y
+CONFIG_VGA_PCI=y
+CONFIG_OVERRIDE_PCI_ID=y
+CONFIG_VGA_VID=0x1af4
+CONFIG_VGA_DID=0x1050
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v2 3/6 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            | 175 +++++++++++++++++++++++++++++++++++++
 5 files changed, 187 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 +175 -0

175 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#0 lore raw

v2 cover virtio-gpu: pci support bits.

Hi,

Here is the code to add virtio-pci support for the virtio-gpu. This time it goes on top of master, all dependencies are merged upstream meanwhile. Yea! The only missing bit to make this fully functional is the seabios update which is needed for a working vgabios.

I plan to send a pull req early next week for patches 1-5.

Patch 6 carries a vgabios binary, for testing convinience. Note that rebuilding this from the current roms/seabios submodule (rel-1.8.1) will *not* work, you'll need the upcoming 1.8.2 seabios release for that. Seabios update pull request for this will follow after 1.8.2 is released, and it will add the vgabios properly.

Gerd Hoffmann (6):
virtio-gpu: fix error message
virtio-gpu-pci: add virtio pci support
virtio-vga: add virtio gpu device with vga compatibility
virtio-vga: add '-vga virtio' support
virtio-vga: add vgabios configuration [testing-only] virtio-vga: add vgabios binary

 Makefile                           |   2 +-
 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-gpu.c            |   2 +-
 hw/display/virtio-vga.c            | 175 +++++++++++++++++++++++++++++++++++++
 hw/isa/isa-bus.c                   |   3 +
 hw/pci/pci.c                       |   2 +
 hw/virtio/virtio-pci.h             |  14 +++
 include/sysemu/sysemu.h            |   2 +-
 pc-bios/vgabios-virtio.bin         | Bin 0 -> 38912 bytes
 qemu-options.hx                    |   4 +-
 roms/Makefile                      |   2 +-
 roms/config.vga-virtio             |   6 ++
 vl.c                               |  13 +++
 17 files changed, 301 insertions(+), 9 deletions(-)
 create mode 100644 hw/display/virtio-gpu-pci.c
 create mode 100644 hw/display/virtio-vga.c
 create mode 100644 pc-bios/vgabios-virtio.bin
 create mode 100644 roms/config.vga-virtio
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v2 4/6 virtio-vga: add '-vga virtio' support

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 1d281f6..c6221d4 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 9542095..2201e27 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 = {
@@ -1884,6 +1885,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;
@@ -1910,6 +1916,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
#6 lore raw

PATCH v2 6/6 virtio-vga: add vgabios binary

In reply to Gerd Hoffmann

Add prebuilt vgabios-virtio.bin binary.

---
 pc-bios/vgabios-virtio.bin | Bin 0 -> 38912 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/vgabios-virtio.bin
pc-bios/vgabios-virtio.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ef283a2137e17cf5e818eb347a7b5ab77cb8aeef
GIT binary patch
Signature · 1 line
1.8.3.1