[libvirt] [PATCH 1/6] qemu: add virtio video device

Ján Tomko jtomko at redhat.com
Mon Nov 23 17:34:28 UTC 2015


On Fri, Nov 20, 2015 at 04:30:40PM +0100, Marc-André Lureau wrote:
> qemu 2.5 provides virtio video device. Similarly to other devices,
> it can be used with -vga virtio or -device virtio-vga for primary
> devices, or -device virtio-gpu for non-vga devices.
> 

This adds virtio-vga but not virtio-gpu. It would be nice to say
so in the commit message.

There is a public bug filed for this functionality that would also be
nice to include in the commit message.
https://bugzilla.redhat.com/show_bug.cgi?id=1195176


> Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
> ---
>  docs/formatdomain.html.in                    |  5 +++--
>  docs/schemas/domaincommon.rng                |  1 +
>  src/conf/domain_conf.c                       |  3 ++-
>  src/conf/domain_conf.h                       |  1 +

The .xml test file could be squashed in with the parser changes and
added to qemuxml2xmltest as well.

>  src/qemu/qemu_capabilities.c                 | 11 +++++++++++
>  src/qemu/qemu_capabilities.h                 |  3 +++
>  src/qemu/qemu_command.c                      | 19 +++++++++++++++----
>  tests/qemucapabilitiesdata/caps_2.4.0-1.caps |  3 +++
>  8 files changed, 39 insertions(+), 7 deletions(-)

Similarly to qemu command line builder and the qemuxml2argvtest
addition.

> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index e5e0167..df29fa1 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -5153,8 +5153,9 @@ qemu-kvm -net nic,model=? /dev/null
>          <p>
>            The <code>model</code> element has a mandatory <code>type</code>
>            attribute which takes the value "vga", "cirrus", "vmvga", "xen",
> -          "vbox", or "qxl" (<span class="since">since 0.8.6</span>) depending
> -          on the hypervisor features available.
> +          "vbox", "qxl" (<span class="since">since 0.8.6</span>) or
> +          "virtio" (<span class="since">since 1.2.22</span>)
> +          depending on the hypervisor features available.

The next planned version is 1.3.0.

>          </p>
>          <p>
>            You can provide the amount of video memory in kibibytes (blocks of
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 994face..228f062 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -2921,6 +2921,7 @@
>                  <value>vmvga</value>
>                  <value>xen</value>
>                  <value>vbox</value>
> +                <value>virtio</value>
>                </choice>
>              </attribute>
>              <group>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 0ac7dbf..15413dc 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -532,7 +532,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
>                "xen",
>                "vbox",
>                "qxl",
> -              "parallels")
> +              "parallels",
> +              "virtio")
>  

This is for QEMUs without -device support, I hope nobody would bother
backporting the feature to such ancient QEMUs.

>  VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
>                "mouse",
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 8d43ee6..c26c56d 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -1374,6 +1374,7 @@ typedef enum {
>      VIR_DOMAIN_VIDEO_TYPE_VBOX,
>      VIR_DOMAIN_VIDEO_TYPE_QXL,
>      VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
> +    VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
>  
>      VIR_DOMAIN_VIDEO_TYPE_LAST
>  } virDomainVideoType;
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 2813212..357980b 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -301,6 +301,9 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
>                "gic-version",
>  
>                "incoming-defer", /* 200 */
> +              "vga-virtio",
> +              "virtio-gpu",
> +              "virtio-vga",
>      );
>  
>  
> @@ -1117,6 +1120,8 @@ virQEMUCapsComputeCmdFlags(const char *help,
>          const char *nl = strstr(p, "\n");
>          if (strstr(p, "|qxl"))
>              virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_QXL);
> +        if (strstr(p, "|virtio"))
> +            virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_VIRTIO);

The -help output is only parsed for QEMUs older than 1.2.0, this
capability can be dropped too.

>          if ((p = strstr(p, "|none")) && p < nl)
>              virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_NONE);
>      }

> @@ -1543,6 +1548,9 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
>      { "virtio-net-ccw", QEMU_CAPS_DEVICE_VIRTIO_NET },
>      { "virtio-net-s390", QEMU_CAPS_DEVICE_VIRTIO_NET },
>      { "virtio-net-device", QEMU_CAPS_DEVICE_VIRTIO_NET },
> +    { "virtio-gpu-pci", QEMU_CAPS_DEVICE_VIRTIO_GPU },
> +    { "virtio-gpu-device", QEMU_CAPS_DEVICE_VIRTIO_GPU },
> +    { "virtio-vga", QEMU_CAPS_DEVICE_VIRTIO_VGA },
>  };
>  
>  static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
> @@ -2399,6 +2407,9 @@ virQEMUCapsProbeQMPObjects(virQEMUCapsPtr qemuCaps,
>      /* If qemu supports newer -device qxl it supports -vga qxl as well */
>      if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL))
>          virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_QXL);
> +    /* If qemu supports newer -device virtio-gpu-pci it supports -vga virtio as well */

Actually, -vga virtio was added one commit later than virtio-vga.
Either way, just one capability should be enough.

(Also, we will never use -vga virtio - we prefer the -device syntax for
primary video since QEMU 1.6.0, see QEMU_CAPS_DEVICE_VIDEO_PRIMARY).

> +    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU))
> +        virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_VIRTIO);
>  
>      return 0;
>  }
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index e3e40e5..cbe28ae 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -327,6 +327,9 @@ typedef enum {
>  
>      /* 200 */
>      QEMU_CAPS_INCOMING_DEFER, /* -incoming defer and migrate_incoming */
> +    QEMU_CAPS_VGA_VIRTIO, /* The 'virtio' arg for '-vga' */
> +    QEMU_CAPS_DEVICE_VIRTIO_GPU, /* -device virtio-gpu-* */
> +    QEMU_CAPS_DEVICE_VIRTIO_VGA, /* -device virtio-vga */
>  
>      QEMU_CAPS_LAST /* this must always be the last item */
>  } virQEMUCapsFlags;
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index ef5ef93..787e3bb 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -104,7 +104,8 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
>                "", /* no arg needed for xen */
>                "", /* don't support vbox */
>                "qxl",
> -              "" /* don't support parallels */);
> +              "", /* don't support parallels */
> +              "virtio");

Changing this to an empty string (since it is not supported for QEMUs
< 1.6.0) would remove the need for the specific error message below [1].


>  VIR_ENUM_DECL(qemuDeviceVideo)
>  
> @@ -115,7 +116,8 @@ VIR_ENUM_IMPL(qemuDeviceVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
>                "", /* no device for xen */
>                "", /* don't support vbox */
>                "qxl-vga",
> -              "" /* don't support parallels */);
> +              "", /* don't support parallels */
> +              "virtio-vga");
>  
>  VIR_ENUM_DECL(qemuSoundCodec)
>  
> @@ -10496,8 +10498,10 @@ qemuBuildCommandLine(virConnectPtr conn,
>               (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
>                   virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA)) ||
>               (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_QXL &&
> -                 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA)))
> -           ) {
> +                 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA)) ||
> +             (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
> +                 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_VGA)))
> +            ) {
>              for (i = 0; i < def->nvideos; i++) {
>                  char *str;
>                  virCommandAddArg(cmd, "-device");
> @@ -10518,6 +10522,13 @@ qemuBuildCommandLine(virConnectPtr conn,
>                      goto error;
>                  }
>  
> +                if ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) &&
> +                    !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VIRTIO)) {
> +                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                                   _("This QEMU does not support virtio graphics adapters"));
> +                    goto error;
> +                }
> +

See [1], this can be handled by the generic error below.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20151123/89c8bdd1/attachment-0001.sig>


More information about the libvir-list mailing list