[PATCH v2] libxl: Add virtio (virtio-vga) display support

Teddy Astie posted 1 patch 16 hours ago
CHANGELOG.md                     | 2 ++
docs/man/xl.cfg.5.pod.in         | 6 +++++-
tools/libs/light/libxl_dm.c      | 3 +++
tools/libs/light/libxl_types.idl | 1 +
tools/xl/xl_parse.c              | 2 ++
5 files changed, 13 insertions(+), 1 deletion(-)
[PATCH v2] libxl: Add virtio (virtio-vga) display support
Posted by Teddy Astie 16 hours ago
Add "virtio" vga which uses the virtio-vga device provided by upstream QEMU.
It is VGA compatible and can be enlightened with virtio-gpu drivers which are
available since Linux 4.4 and as a part of KVM Windows drivers.

Signed-off-by: Teddy Astie <teddy.astie@vates.tech>
---
v2:
 - rebased CHANGELOG.md

 CHANGELOG.md                     | 2 ++
 docs/man/xl.cfg.5.pod.in         | 6 +++++-
 tools/libs/light/libxl_dm.c      | 3 +++
 tools/libs/light/libxl_types.idl | 1 +
 tools/xl/xl_parse.c              | 2 ++
 5 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3aaf598623..ed1ad61b0f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 ### Changed
 
 ### Added
+- On x86:
+  - Virtio-VGA display support for HVM guests
 
 ### Removed
  - On x86:
diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index 27c455210b..5952c36886 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -2566,6 +2566,8 @@ 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.
 
+When using virtio, this parameter is ignored.
+
 =item B<stdvga=BOOLEAN>
 
 Specifies a standard VGA card with VBE (VESA BIOS Extensions) as the
@@ -2579,7 +2581,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
@@ -2587,6 +2589,8 @@ for acceleration, and a QXL driver is necessary in the guest in that case.
 QXL can also work with the VNC protocol, but it will be like a standard
 VGA card without acceleration.
 
+virtio uses the VGA compatible variant of virtio-gpu.
+
 =item B<vnc=BOOLEAN>
 
 Allow access to the display via the VNC protocol.  This enables the
diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 511ec76a65..a561ba695a 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -1210,6 +1210,9 @@ 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", "virtio-vga");
+            break;
         default:
             LOGD(ERROR, guest_domid, "Invalid emulated video card specified");
             return ERROR_INVAL;
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index d64a573ff3..5e704ba25a 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -239,6 +239,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", [
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index af86d3186d..927adbd457 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -2863,6 +2863,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);
-- 
2.51.2



--
Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech