Skip to contentSkip to conversation

libxl: Add virtio vga interface support for qemu

PATCH In review Chris Patterson 2 participants 4 messages Apr 4, 2019 – Apr 17, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libxl: Add virtio vga interface support for qemu

From: Chris Patterson <[email protected]>

To enable it, set vga="virtio".

Default videoram for virtio-vga is set to match current QEMU default with 256MB.

---
 docs/man/xl.cfg.5.pod.in    |  4 +++-
 tools/libxl/libxl.h         | 10 ++++++++++
 tools/libxl/libxl_create.c  |  9 +++++++++
 tools/libxl/libxl_dm.c      |  7 +++++++
 tools/libxl/libxl_types.idl |  1 +
 tools/xl/xl_parse.c         |  2 ++
 6 files changed, 32 insertions(+), 1 deletion(-)
docs/man/xl.cfg.5.pod.in +3 -1
index ad81af1..0d4fd49 100644
@@ -2232,6 +2232,8 @@ device-model, the default and minimum is 8 MB.
 For QXL vga, both the default and minimal are 128MB.
 If B<videoram> is set less than 128MB, an error will be triggered.
 
+For VirtIO vga, the default is 256MB.
+
 =item B<stdvga=BOOLEAN>
 
 Speficies a standard VGA card with VBE (VESA BIOS Extensions) as the
@@ -2245,7 +2247,7 @@ B<This option is deprecated, use vga="stdvga" instead>.
 =item B<vga="STRING">
 
 Selects the emulated video card.
-Options are: B<none>, B<stdvga>, B<cirrus> and B<qxl>.
+Options are: B<none>, B<stdvga>, B<cirrus>, B<qxl>, and B<virtio>.
 The default is B<cirrus>.
 
 In general, QXL should work with the Spice remote display protocol
tools/libxl/libxl.h +10 -0
index a38e5cd..b818e1a 100644
@@ -747,6 +747,16 @@ typedef struct libxl__ctx libxl_ctx;
 #define LIBXL_HAVE_QXL 1
 
 /*
+ * LIBXL_HAVE_VIRTIO_VGA
+ *
+ * If defined, then the libxl_vga_interface_type will contain another value:
+ * "VIRTIO". This value define if virtio vga is supported.
+ *
+ * If this is not defined, the virtio vga support is missed.
+ */
+#define LIBXL_HAVE_VIRTIO_VGA 1
+
+/*
  * LIBXL_HAVE_SPICE_VDAGENT
  *
  * If defined, then the libxl_spice_info structure will contain a boolean type:
tools/libxl/libxl_create.c +9 -0
index 89fe80f..d6c2b91 100644
@@ -245,6 +245,10 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
                 LOG(ERROR,"qemu upstream required for qxl vga");
                 return ERROR_INVAL;
                 break;
+            case LIBXL_VGA_INTERFACE_TYPE_VIRTIO:
+                LOG(ERROR,"qemu upstream required for virtio vga");
+                return ERROR_INVAL;
+                break;
             case LIBXL_VGA_INTERFACE_TYPE_STD:
                 if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT)
                     b_info->video_memkb = 8 * 1024;
@@ -278,6 +282,11 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
                     return ERROR_INVAL;
                 }
                 break;
+            case LIBXL_VGA_INTERFACE_TYPE_VIRTIO:
+                if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT) {
+                    b_info->video_memkb = (256 * 1024);
+                }
+                break;
             case LIBXL_VGA_INTERFACE_TYPE_STD:
                 if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT)
                     b_info->video_memkb = 16 * 1024;
tools/libxl/libxl_dm.c +7 -0
index 2f19786..2aaa359 100644
@@ -790,6 +790,8 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
             break;
         case LIBXL_VGA_INTERFACE_TYPE_QXL:
             break;
+        case LIBXL_VGA_INTERFACE_TYPE_VIRTIO:
+            break;
         default:
             LOGD(ERROR, domid, "Invalid emulated video card specified");
             return ERROR_INVAL;
@@ -1401,6 +1403,11 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                 GCSPRINTF("qxl-vga,vram_size_mb=%"PRIu64",ram_size_mb=%"PRIu64,
                 (b_info->video_memkb/2/1024), (b_info->video_memkb/2/1024) ) );
             break;
+        case LIBXL_VGA_INTERFACE_TYPE_VIRTIO:
+            flexarray_append_pair(dm_args, "-device",
+                GCSPRINTF("virtio-vga,max_hostmem=%"PRIu64,
+                (b_info->video_memkb*1024)));
+            break;
         default:
             LOGD(ERROR, guest_domid, "Invalid emulated video card specified");
             return ERROR_INVAL;
tools/libxl/libxl_types.idl +1 -0
index b685ac4..19ab799 100644
@@ -220,6 +220,7 @@ libxl_vga_interface_type = Enumeration("vga_interface_type", [
     (2, "STD"),
     (3, "NONE"),
     (4, "QXL"),
+    (5, "VIRTIO"),
     ], init_val = "LIBXL_VGA_INTERFACE_TYPE_UNKNOWN")
 
 libxl_vendor_device = Enumeration("vendor_device", [
tools/xl/xl_parse.c +2 -0
index 352cd21..33153bd 100644
@@ -2560,6 +2560,8 @@ skip_usbdev:
                 b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_NONE;
             } else if (!strcmp(buf, "qxl")) {
                 b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_QXL;
+            } else if (!strcmp(buf, "virtio")) {
+                b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_VIRTIO;
             } else {
                 fprintf(stderr, "Unknown vga \"%s\" specified\n", buf);
                 exit(1);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 2/2 libxl_dm: honor opengl flag for SDL

From: Chris Patterson <[email protected]>

It was honored in libxl__build_device_model_args_old(), but did not transition to libxl__build_device_model_args_new().

The opengl flag is useful for SDL to toggle virgl when using virtio-vga.

To accomplish this, we also switch from the short-hand "-sdl" notation to "-display sdl", which should be fine compatibility-wise as "-display sdl" is used as far back as qemu 0.15 [1].

"-display sdl,gl=on" is supported as far back as qemu 2.7 [2].

[1] https://github.com/qemu/qemu/blob/stable-0.15/qemu-options.hx#L617
[2] https://github.com/qemu/qemu/blob/stable-2.7/qemu-options.hx#L929

---
 docs/man/xl.cfg.5.pod.in | 3 +--
 tools/libxl/libxl_dm.c   | 5 ++++-
 2 files changed, 5 insertions(+), 3 deletions(-)
docs/man/xl.cfg.5.pod.in +1 -2
index 0d4fd49..a2d3988 100644
@@ -2297,8 +2297,7 @@ Simple DirectMedia Layer). The default is (0) not enabled.
 
 =item B<opengl=BOOLEAN>
 
-Enable OpenGL acceleration of the SDL display. Only effects machines
-using B<device_model_version="qemu-xen-traditional"> and only if the
+Enable OpenGL acceleration of the SDL display.  Only works if the
 device-model was compiled with OpenGL support. Default is (0) false.
 
 =item B<nographic=BOOLEAN>
tools/libxl/libxl_dm.c +4 -1
index 2aaa359..5928214 100644
@@ -1307,7 +1307,10 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
     flexarray_append_pair(dm_args, "-display", "none");
 
     if (sdl) {
-        flexarray_append(dm_args, "-sdl");
+        flexarray_append_pair(dm_args, "-display", GCSPRINTF("sdl%s",
+                              libxl_defbool_val(sdl->opengl) ?
+                              ",gl=on" : ""));
+
         if (sdl->display)
             flexarray_append_pair(dm_envs, "DISPLAY", sdl->display);
         if (sdl->xauthority)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
In reply to Chris Patterson

For anyone looking at this... while I have tested and verified that both virtio-gpu and VirGL work, it's not without some hiccup.

I have been running Ubuntu 19.04 with this config for a few days and I have had a couple VM freezes. 'xl dmesg' is spamming the following repeatedly:
(XEN) irq.c:2479: dom3: pirq 143 or emuirq -3 already mapped

Seems to be related to MSI-X for the device, but I haven't yet had a chance to dig into it. Maybe someone knows if this is to be expected given the state of things? :)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 5 lines · Chris Patterson

For anyone looking at this... while I have tested and verified that both virtio-gpu and VirGL work, it's not without some hiccup.

Quoted 8 lines

I have been running Ubuntu 19.04 with this config for a few days and I have had a couple VM freezes. 'xl dmesg' is spamming the following repeatedly:
(XEN) irq.c:2479: dom3: pirq 143 or emuirq -3 already mapped

Seems to be related to MSI-X for the device, but I haven't yet had a chance to dig into it. Maybe someone knows if this is to be expected given the state of things? :)

Adding Paul Durrant (vGPU/graphics) to the thread.

Rich

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel