[libvirt PATCH v3 0/6] Add support for 'blob' to virtio video device

Add support to libvirt for the 'blob' option for virtio video devices in qemu. Also do a little preparatory refactoring of the video device xml parsing code. I sent this series out a couple months ago but didn't get any review. Sending out again after rebasing to current master branch. changes in v3: - rebased to latest master Changes in v2: - Added some basic documentation - add a qemu capability - Make sure that the /dev/udmabuf device is accessible to qemu (cgroups, etc) Jonathon Jongsma (6): conf: Refactor video model parsing conf: switch to virXMLProp* functions conf: use enum variable for video type conf: add support for 'blob' in virtio video device qemu: Add capability for virtio-gpu.blob qemu: Implement 'blob' support for virtio gpu docs/formatdomain.rst | 6 + src/conf/domain_conf.c | 133 +++++++++--------- src/conf/domain_conf.h | 3 +- src/conf/domain_validate.c | 13 +- src/conf/schemas/domaincommon.rng | 5 + src/libxl/libxl_conf.c | 10 ++ src/libxl/libxl_domain.c | 11 ++ src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_cgroup.c | 22 ++- src/qemu/qemu_command.c | 3 + src/qemu/qemu_domain.h | 1 + src/qemu/qemu_monitor_json.c | 16 ++- src/qemu/qemu_namespace.c | 22 +++ src/qemu/qemu_process.c | 7 + src/qemu/qemu_validate.c | 9 ++ .../caps_6.1.0.x86_64.xml | 1 + .../caps_6.2.0.aarch64.xml | 1 + .../qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 1 + .../caps_6.2.0.x86_64.xml | 1 + .../caps_7.0.0.aarch64.xml | 1 + .../qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + .../caps_7.0.0.x86_64.xml | 1 + .../caps_7.1.0.x86_64.xml | 1 + .../video-virtio-blob-absent.args | 34 +++++ .../video-virtio-blob-absent.xml | 33 +++++ .../video-virtio-blob-off.args | 34 +++++ .../video-virtio-blob-off.xml | 33 +++++ .../video-virtio-blob-on.args | 34 +++++ .../qemuxml2argvdata/video-virtio-blob-on.xml | 33 +++++ .../video-virtio-vga-blob-on.args | 34 +++++ .../video-virtio-vga-blob-on.xml | 33 +++++ tests/qemuxml2argvtest.c | 12 ++ .../video-virtio-blob-absent.xml | 41 ++++++ .../video-virtio-blob-off.xml | 41 ++++++ .../video-virtio-blob-on.xml | 41 ++++++ .../video-virtio-vga-blob-on.xml | 41 ++++++ tests/qemuxml2xmltest.c | 12 ++ 38 files changed, 647 insertions(+), 81 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-vga-blob-on.xml -- 2.35.1

Factor out a separate function to parse out the <model> element for video devices. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/conf/domain_conf.c | 95 ++++++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 298ae183ce..2f7d7db527 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14107,17 +14107,13 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node, return g_steal_pointer(&def); } -static virDomainVideoDef * -virDomainVideoDefParseXML(virDomainXMLOption *xmlopt, - xmlNodePtr node, - xmlXPathContextPtr ctxt, - unsigned int flags) +static int +virDomainVideoModelDefParseXML(virDomainVideoDef *def, + xmlNodePtr node, + xmlXPathContextPtr ctxt) { - g_autoptr(virDomainVideoDef) def = NULL; - xmlNodePtr driver; xmlNodePtr accel_node; xmlNodePtr res_node; - VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree char *type = NULL; g_autofree char *heads = NULL; g_autofree char *vram = NULL; @@ -14126,81 +14122,108 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *vgamem = NULL; g_autofree char *primary = NULL; - if (!(def = virDomainVideoDefNew(xmlopt))) - return NULL; - + VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node = node; - if ((primary = virXPathString("string(./model/@primary)", ctxt)) != NULL) + if ((primary = virXPathString("string(./@primary)", ctxt)) != NULL) ignore_value(virStringParseYesNo(primary, &def->primary)); - if ((accel_node = virXPathNode("./model/acceleration", ctxt)) && + if ((accel_node = virXPathNode("./acceleration", ctxt)) && (def->accel = virDomainVideoAccelDefParseXML(accel_node)) == NULL) - return NULL; + return -1; - if ((res_node = virXPathNode("./model/resolution", ctxt)) && + if ((res_node = virXPathNode("./resolution", ctxt)) && (def->res = virDomainVideoResolutionDefParseXML(res_node)) == NULL) - return NULL; + return -1; - if ((driver = virXPathNode("./driver", ctxt))) { - if (virXMLPropEnum(driver, "name", - virDomainVideoBackendTypeFromString, - VIR_XML_PROP_NONZERO, &def->backend) < 0) - return NULL; - if (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0) - return NULL; - } - if ((type = virXPathString("string(./model/@type)", ctxt))) { + + if ((type = virXPathString("string(./@type)", ctxt))) { if ((def->type = virDomainVideoTypeFromString(type)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown video model '%s'"), type); - return NULL; + return -1; } } else { def->type = VIR_DOMAIN_VIDEO_TYPE_DEFAULT; } - if ((ram = virXPathString("string(./model/@ram)", ctxt))) { + if ((ram = virXPathString("string(./@ram)", ctxt))) { if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video ram '%s'"), ram); - return NULL; + return -1; } } - if ((vram = virXPathString("string(./model/@vram)", ctxt))) { + if ((vram = virXPathString("string(./@vram)", ctxt))) { if (virStrToLong_uip(vram, NULL, 10, &def->vram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram '%s'"), vram); - return NULL; + return -1; } } - if ((vram64 = virXPathString("string(./model/@vram64)", ctxt))) { + if ((vram64 = virXPathString("string(./@vram64)", ctxt))) { if (virStrToLong_uip(vram64, NULL, 10, &def->vram64) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram64 '%s'"), vram64); - return NULL; + return -1; } } - if ((vgamem = virXPathString("string(./model/@vgamem)", ctxt))) { + if ((vgamem = virXPathString("string(./@vgamem)", ctxt))) { if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vgamem '%s'"), vgamem); - return NULL; + return -1; } } - if ((heads = virXPathString("string(./model/@heads)", ctxt))) { + if ((heads = virXPathString("string(./@heads)", ctxt))) { if (virStrToLong_uip(heads, NULL, 10, &def->heads) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse video heads '%s'"), heads); - return NULL; + return -1; } } + return 0; +} + +static virDomainVideoDef * +virDomainVideoDefParseXML(virDomainXMLOption *xmlopt, + xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) +{ + g_autoptr(virDomainVideoDef) def = NULL; + xmlNodePtr driver; + xmlNodePtr model; + + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + if (!(def = virDomainVideoDefNew(xmlopt))) + return NULL; + + ctxt->node = node; + + if ((model = virXPathNode("./model", ctxt))) { + if (virDomainVideoModelDefParseXML(def, model, ctxt) < 0) + return NULL; + } else { + def->type = VIR_DOMAIN_VIDEO_TYPE_DEFAULT; + } + + if ((driver = virXPathNode("./driver", ctxt))) { + if (virXMLPropEnum(driver, "name", + virDomainVideoBackendTypeFromString, + VIR_XML_PROP_NONZERO, &def->backend) < 0) + return NULL; + if (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0) + return NULL; + } + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0) return NULL; -- 2.35.1

In virDomainVideoModelDefParseXML(), use the virXMLProp* functions rather than reimplementing them with virXPath* functions. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/conf/domain_conf.c | 78 +++++++++++++----------------------------- 1 file changed, 23 insertions(+), 55 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2f7d7db527..e725d71e15 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14114,19 +14114,15 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def, { xmlNodePtr accel_node; xmlNodePtr res_node; - g_autofree char *type = NULL; - g_autofree char *heads = NULL; - g_autofree char *vram = NULL; - g_autofree char *vram64 = NULL; - g_autofree char *ram = NULL; - g_autofree char *vgamem = NULL; - g_autofree char *primary = NULL; + virDomainVideoType type; + virTristateBool primary; + int rc = 0; VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node = node; - if ((primary = virXPathString("string(./@primary)", ctxt)) != NULL) - ignore_value(virStringParseYesNo(primary, &def->primary)); + if (virXMLPropTristateBool(node, "primary", VIR_XML_PROP_NONE, &primary) >= 0) + def->primary = (primary == VIR_TRISTATE_BOOL_YES); if ((accel_node = virXPathNode("./acceleration", ctxt)) && (def->accel = virDomainVideoAccelDefParseXML(accel_node)) == NULL) @@ -14136,57 +14132,29 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def, (def->res = virDomainVideoResolutionDefParseXML(res_node)) == NULL) return -1; + if (virXMLPropEnumDefault(node, "type", + virDomainVideoTypeFromString, + VIR_XML_PROP_NONE, &type, + VIR_DOMAIN_VIDEO_TYPE_DEFAULT) < 0) + return -1; + def->type = type; + if (virXMLPropUInt(node, "ram", 10, VIR_XML_PROP_NONE, &def->ram) < 0) + return -1; - if ((type = virXPathString("string(./@type)", ctxt))) { - if ((def->type = virDomainVideoTypeFromString(type)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown video model '%s'"), type); - return -1; - } - } else { - def->type = VIR_DOMAIN_VIDEO_TYPE_DEFAULT; - } - - if ((ram = virXPathString("string(./@ram)", ctxt))) { - if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse video ram '%s'"), ram); - return -1; - } - } - - if ((vram = virXPathString("string(./@vram)", ctxt))) { - if (virStrToLong_uip(vram, NULL, 10, &def->vram) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse video vram '%s'"), vram); - return -1; - } - } + if (virXMLPropUInt(node, "vram", 10, VIR_XML_PROP_NONE, &def->vram) < 0) + return -1; - if ((vram64 = virXPathString("string(./@vram64)", ctxt))) { - if (virStrToLong_uip(vram64, NULL, 10, &def->vram64) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse video vram64 '%s'"), vram64); - return -1; - } - } + if (virXMLPropUInt(node, "vram64", 10, VIR_XML_PROP_NONE, &def->vram64) < 0) + return -1; - if ((vgamem = virXPathString("string(./@vgamem)", ctxt))) { - if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse video vgamem '%s'"), vgamem); - return -1; - } - } + if (virXMLPropUInt(node, "vgamem", 10, VIR_XML_PROP_NONE, &def->vgamem) < 0) + return -1; - if ((heads = virXPathString("string(./@heads)", ctxt))) { - if (virStrToLong_uip(heads, NULL, 10, &def->heads) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse video heads '%s'"), heads); - return -1; - } - } + if ((rc = virXMLPropUInt(node, "heads", 10, VIR_XML_PROP_NONE, &def->heads)) < 0) + return -1; + else if (rc == 0) + def->heads = 1; return 0; } -- 2.35.1

Rather than storing the video type as an integer, use the proper enum type within the struct. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/conf/domain_conf.c | 4 +--- src/conf/domain_conf.h | 2 +- src/libxl/libxl_conf.c | 10 ++++++++++ src/libxl/libxl_domain.c | 11 +++++++++++ src/qemu/qemu_monitor_json.c | 16 +++++++++++++++- src/qemu/qemu_process.c | 7 +++++++ 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e725d71e15..60c27ddd34 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14114,7 +14114,6 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def, { xmlNodePtr accel_node; xmlNodePtr res_node; - virDomainVideoType type; virTristateBool primary; int rc = 0; @@ -14134,10 +14133,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def, if (virXMLPropEnumDefault(node, "type", virDomainVideoTypeFromString, - VIR_XML_PROP_NONE, &type, + VIR_XML_PROP_NONE, &def->type, VIR_DOMAIN_VIDEO_TYPE_DEFAULT) < 0) return -1; - def->type = type; if (virXMLPropUInt(node, "ram", 10, VIR_XML_PROP_NONE, &def->ram) < 0) return -1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8a48646160..acd0588e9b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1754,7 +1754,7 @@ struct _virDomainVideoDriverDef { struct _virDomainVideoDef { virObject *privateData; - int type; /* enum virDomainVideoType */ + virDomainVideoType type; unsigned int ram; /* kibibytes (multiples of 1024) */ unsigned int vram; /* kibibytes (multiples of 1024) */ unsigned int vram64; /* kibibytes (multiples of 1024) */ diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index e5fe209718..85aaea7df3 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -2363,6 +2363,16 @@ libxlMakeVideo(virDomainDef *def, libxl_domain_config *d_config) } break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + case VIR_DOMAIN_VIDEO_TYPE_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("video type %s is not supported by libxl"), diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index dbe44f4ffc..82e1f1748f 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -324,6 +324,17 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev, if (dev->data.video->vram == 0) dev->data.video->vram = 128 * 1024; break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + case VIR_DOMAIN_VIDEO_TYPE_LAST: + break; } } } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index d9f93bd2fa..7e752a1762 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1898,9 +1898,16 @@ qemuMonitorJSONUpdateVideoMemorySize(qemuMonitor *mon, } video->vram = prop.val.ul * 1024; break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: case VIR_DOMAIN_VIDEO_TYPE_XEN: case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: break; } @@ -1938,11 +1945,18 @@ qemuMonitorJSONUpdateVideoVram64Size(qemuMonitor *mon, video->vram64 = prop.val.ul * 1024; } break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_VGA: - case VIR_DOMAIN_VIDEO_TYPE_VMVGA: case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: case VIR_DOMAIN_VIDEO_TYPE_XEN: case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: break; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2b16298942..be8340f24c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3094,9 +3094,16 @@ qemuProcessUpdateVideoRamSize(virQEMUDriver *driver, goto error; } break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: case VIR_DOMAIN_VIDEO_TYPE_XEN: case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: break; } -- 2.35.1

Add the ability to enable blob resources for the virtio video device. This will accelerate the display path due to less or no copying of pixel data. Blob resource support can be enabled with e.g.: <video> <model type='virtio' blob='on'/> </video> Some additional background information about blob resources: https://lists.freedesktop.org/archives/dri-devel/2020-August/275972.html https://www.kraxel.org/blog/2021/05/virtio-gpu-qemu-graphics-update/ Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2032406 Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- docs/formatdomain.rst | 6 ++++++ src/conf/domain_conf.c | 6 ++++++ src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 13 ++++++++++--- src/conf/schemas/domaincommon.rng | 5 +++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 993c65e50b..2161cc7e30 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -6198,6 +6198,12 @@ A video device. :since:`since 1.3.3` ) extends secondary bar and makes it addressable as 64bit memory. + :since:`Since 8.2.0`, devices with type "virtio" have an optional ``blob`` + attribute that can be set to "on" or "off". Setting ``blob`` to "on" will + enable the use of blob resources in the device. This can accelerate the + display path by reducing or eliminating copying of pixel data between the + guest and host. + :since:`Since 5.9.0` , the ``model`` element may also have an optional ``resolution`` sub-element. The ``resolution`` element has attributes ``x`` and ``y`` to set the minimum resolution for the video device. This diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60c27ddd34..ae86f455bd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14154,6 +14154,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def, else if (rc == 0) def->heads = 1; + if (virXMLPropTristateSwitch(node, "blob", VIR_XML_PROP_NONE, &def->blob) < 0) + return -1; + return 0; } @@ -26075,6 +26078,9 @@ virDomainVideoDefFormat(virBuffer *buf, virBufferAsprintf(buf, " heads='%u'", def->heads); if (def->primary) virBufferAddLit(buf, " primary='yes'"); + if (def->blob != VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " blob='%s'", + virTristateSwitchTypeToString(def->blob)); if (def->accel || def->res) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index acd0588e9b..afa6db2403 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1763,6 +1763,7 @@ struct _virDomainVideoDef { bool primary; virDomainVideoAccelDef *accel; virDomainVideoResolutionDef *res; + virTristateSwitch blob; virDomainVideoDriverDef *driver; virDomainDeviceInfo info; virDomainVirtioOptions *virtio; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 18eb8d697d..da0ff06570 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -226,9 +226,16 @@ virDomainVideoDefValidate(const virDomainVideoDef *video, } } - if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0)) - return -1; + if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0) + return -1; + if (video->blob != VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("video type '%s' does not support blob resources"), + virDomainVideoTypeToString(video->type)); + return -1; + } + } return 0; } diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 2544864eb4..16b3fd9c53 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4251,6 +4251,11 @@ <ref name="virYesNo"/> </attribute> </optional> + <optional> + <attribute name="blob"> + <ref name="virOnOff"/> + </attribute> + </optional> <optional> <element name="acceleration"> <optional> -- 2.35.1

On Wed, May 11, 2022 at 12:26 AM Jonathon Jongsma <jjongsma@redhat.com> wrote:
Add the ability to enable blob resources for the virtio video device. This will accelerate the display path due to less or no copying of pixel data.
Blob resource support can be enabled with e.g.:
<video> <model type='virtio' blob='on'/> </video>
Some additional background information about blob resources: https://lists.freedesktop.org/archives/dri-devel/2020-August/275972.html https://www.kraxel.org/blog/2021/05/virtio-gpu-qemu-graphics-update/
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2032406
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- docs/formatdomain.rst | 6 ++++++ src/conf/domain_conf.c | 6 ++++++ src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 13 ++++++++++--- src/conf/schemas/domaincommon.rng | 5 +++++ 5 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 993c65e50b..2161cc7e30 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -6198,6 +6198,12 @@ A video device. :since:`since 1.3.3` ) extends secondary bar and makes it addressable as 64bit memory.
+ :since:`Since 8.2.0`, devices with type "virtio" have an optional ``blob``
Since 8.4.0 for libvirt. And please mention the QEMU version 6.1.0
+ attribute that can be set to "on" or "off". Setting ``blob`` to "on" will + enable the use of blob resources in the device. This can accelerate the + display path by reducing or eliminating copying of pixel data between the + guest and host. + :since:`Since 5.9.0` , the ``model`` element may also have an optional ``resolution`` sub-element. The ``resolution`` element has attributes ``x`` and ``y`` to set the minimum resolution for the video device. This diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60c27ddd34..ae86f455bd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14154,6 +14154,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def, else if (rc == 0) def->heads = 1;
+ if (virXMLPropTristateSwitch(node, "blob", VIR_XML_PROP_NONE, &def->blob) < 0) + return -1; + return 0; }
@@ -26075,6 +26078,9 @@ virDomainVideoDefFormat(virBuffer *buf, virBufferAsprintf(buf, " heads='%u'", def->heads); if (def->primary) virBufferAddLit(buf, " primary='yes'"); + if (def->blob != VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " blob='%s'", + virTristateSwitchTypeToString(def->blob)); if (def->accel || def->res) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index acd0588e9b..afa6db2403 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1763,6 +1763,7 @@ struct _virDomainVideoDef { bool primary; virDomainVideoAccelDef *accel; virDomainVideoResolutionDef *res; + virTristateSwitch blob; virDomainVideoDriverDef *driver; virDomainDeviceInfo info; virDomainVirtioOptions *virtio; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 18eb8d697d..da0ff06570 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -226,9 +226,16 @@ virDomainVideoDefValidate(const virDomainVideoDef *video, } }
- if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0)) - return -1; + if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0) + return -1; + if (video->blob != VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("video type '%s' does not support blob resources"), + virDomainVideoTypeToString(video->type)); + return -1; + } + }
return 0; } diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 2544864eb4..16b3fd9c53 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4251,6 +4251,11 @@ <ref name="virYesNo"/> </attribute> </optional> + <optional> + <attribute name="blob"> + <ref name="virOnOff"/> + </attribute> + </optional> <optional> <element name="acceleration"> <optional> -- 2.35.1

On 5/11/22 9:56 AM, Han Han wrote:
On Wed, May 11, 2022 at 12:26 AM Jonathon Jongsma <jjongsma@redhat.com <mailto:jjongsma@redhat.com>> wrote:
Add the ability to enable blob resources for the virtio video device. This will accelerate the display path due to less or no copying of pixel data.
Blob resource support can be enabled with e.g.:
<video> <model type='virtio' blob='on'/> </video>
Some additional background information about blob resources: https://lists.freedesktop.org/archives/dri-devel/2020-August/275972.html <https://lists.freedesktop.org/archives/dri-devel/2020-August/275972.html> https://www.kraxel.org/blog/2021/05/virtio-gpu-qemu-graphics-update/ <https://www.kraxel.org/blog/2021/05/virtio-gpu-qemu-graphics-update/>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2032406 <https://bugzilla.redhat.com/show_bug.cgi?id=2032406>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com <mailto:jjongsma@redhat.com>> --- docs/formatdomain.rst | 6 ++++++ src/conf/domain_conf.c | 6 ++++++ src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 13 ++++++++++--- src/conf/schemas/domaincommon.rng | 5 +++++ 5 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 993c65e50b..2161cc7e30 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -6198,6 +6198,12 @@ A video device. :since:`since 1.3.3` ) extends secondary bar and makes it addressable as 64bit memory.
+ :since:`Since 8.2.0`, devices with type "virtio" have an optional ``blob``
Since 8.4.0 for libvirt.
Oops. Didn't catch that in the rebase.
And please mention the QEMU version 6.1.0
There are a lot of libvirt features that require minimum versions of qemu, but it doesn't look like we generally specify these qemu version requirements in the libvirt documentation. Not sure if I should add it here...
+ attribute that can be set to "on" or "off". Setting ``blob`` to "on" will + enable the use of blob resources in the device. This can accelerate the + display path by reducing or eliminating copying of pixel data between the + guest and host. + :since:`Since 5.9.0` , the ``model`` element may also have an optional ``resolution`` sub-element. The ``resolution`` element has attributes ``x`` and ``y`` to set the minimum resolution for the video device. This diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60c27ddd34..ae86f455bd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14154,6 +14154,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def, else if (rc == 0) def->heads = 1;
+ if (virXMLPropTristateSwitch(node, "blob", VIR_XML_PROP_NONE, &def->blob) < 0) + return -1; + return 0; }
@@ -26075,6 +26078,9 @@ virDomainVideoDefFormat(virBuffer *buf, virBufferAsprintf(buf, " heads='%u'", def->heads); if (def->primary) virBufferAddLit(buf, " primary='yes'"); + if (def->blob != VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " blob='%s'", + virTristateSwitchTypeToString(def->blob)); if (def->accel || def->res) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index acd0588e9b..afa6db2403 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1763,6 +1763,7 @@ struct _virDomainVideoDef { bool primary; virDomainVideoAccelDef *accel; virDomainVideoResolutionDef *res; + virTristateSwitch blob; virDomainVideoDriverDef *driver; virDomainDeviceInfo info; virDomainVirtioOptions *virtio; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 18eb8d697d..da0ff06570 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -226,9 +226,16 @@ virDomainVideoDefValidate(const virDomainVideoDef *video, } }
- if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0)) - return -1; + if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0) + return -1; + if (video->blob != VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("video type '%s' does not support blob resources"), + virDomainVideoTypeToString(video->type)); + return -1; + } + }
return 0; } diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 2544864eb4..16b3fd9c53 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4251,6 +4251,11 @@ <ref name="virYesNo"/> </attribute> </optional> + <optional> + <attribute name="blob"> + <ref name="virOnOff"/> + </attribute> + </optional> <optional> <element name="acceleration"> <optional> -- 2.35.1

On Thu, May 12, 2022 at 2:28 AM Jonathon Jongsma <jjongsma@redhat.com> wrote:
On 5/11/22 9:56 AM, Han Han wrote:
On Wed, May 11, 2022 at 12:26 AM Jonathon Jongsma <jjongsma@redhat.com <mailto:jjongsma@redhat.com>> wrote:
Add the ability to enable blob resources for the virtio video device. This will accelerate the display path due to less or no copying of
pixel
data.
Blob resource support can be enabled with e.g.:
<video> <model type='virtio' blob='on'/> </video>
Some additional background information about blob resources:
https://lists.freedesktop.org/archives/dri-devel/2020-August/275972.html
<
https://lists.freedesktop.org/archives/dri-devel/2020-August/275972.html>
https://www.kraxel.org/blog/2021/05/virtio-gpu-qemu-graphics-update/ <
https://www.kraxel.org/blog/2021/05/virtio-gpu-qemu-graphics-update/>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2032406 <https://bugzilla.redhat.com/show_bug.cgi?id=2032406>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com <mailto:jjongsma@redhat.com>> --- docs/formatdomain.rst | 6 ++++++ src/conf/domain_conf.c | 6 ++++++ src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 13 ++++++++++--- src/conf/schemas/domaincommon.rng | 5 +++++ 5 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 993c65e50b..2161cc7e30 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -6198,6 +6198,12 @@ A video device. :since:`since 1.3.3` ) extends secondary bar and makes it addressable as 64bit memory.
+ :since:`Since 8.2.0`, devices with type "virtio" have an optional ``blob``
Since 8.4.0 for libvirt.
Oops. Didn't catch that in the rebase.
And please mention the QEMU version 6.1.0
There are a lot of libvirt features that require minimum versions of qemu, but it doesn't look like we generally specify these qemu version requirements in the libvirt documentation. Not sure if I should add it here...
Generally, the minimal required QEMU version is 3.1.0( https://libvirt.org/drvqemu.html): "The libvirt KVM/QEMU driver can manage any QEMU emulator from version 3.1.0 or later" That's to say, a user can use 3.1.0<=QEMU<6.2.0 with current libvirt. So it's better to mention the required QEMU version for 'blob' to help users resolved the unsupported error.
+ attribute that can be set to "on" or "off". Setting ``blob`` to "on" will + enable the use of blob resources in the device. This can accelerate the + display path by reducing or eliminating copying of pixel data between the + guest and host. + :since:`Since 5.9.0` , the ``model`` element may also have an optional ``resolution`` sub-element. The ``resolution`` element has attributes ``x`` and ``y`` to set the minimum resolution for the video device.
This
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60c27ddd34..ae86f455bd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14154,6 +14154,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def, else if (rc == 0) def->heads = 1;
+ if (virXMLPropTristateSwitch(node, "blob", VIR_XML_PROP_NONE, &def->blob) < 0) + return -1; + return 0; }
@@ -26075,6 +26078,9 @@ virDomainVideoDefFormat(virBuffer *buf, virBufferAsprintf(buf, " heads='%u'", def->heads); if (def->primary) virBufferAddLit(buf, " primary='yes'"); + if (def->blob != VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " blob='%s'", + virTristateSwitchTypeToString(def->blob)); if (def->accel || def->res) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index acd0588e9b..afa6db2403 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1763,6 +1763,7 @@ struct _virDomainVideoDef { bool primary; virDomainVideoAccelDef *accel; virDomainVideoResolutionDef *res; + virTristateSwitch blob; virDomainVideoDriverDef *driver; virDomainDeviceInfo info; virDomainVirtioOptions *virtio; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 18eb8d697d..da0ff06570 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -226,9 +226,16 @@ virDomainVideoDefValidate(const virDomainVideoDef *video, } }
- if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0)) - return -1; + if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0) + return -1; + if (video->blob != VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("video type '%s' does not support blob resources"), + virDomainVideoTypeToString(video->type)); + return -1; + } + }
return 0; } diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 2544864eb4..16b3fd9c53 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4251,6 +4251,11 @@ <ref name="virYesNo"/> </attribute> </optional> + <optional> + <attribute name="blob"> + <ref name="virOnOff"/> + </attribute> + </optional> <optional> <element name="acceleration"> <optional> -- 2.35.1

On Wed, May 11, 2022 at 13:28:02 -0500, Jonathon Jongsma wrote:
On 5/11/22 9:56 AM, Han Han wrote:
On Wed, May 11, 2022 at 12:26 AM Jonathon Jongsma <jjongsma@redhat.com <mailto:jjongsma@redhat.com>> wrote:
[...]
Since 8.4.0 for libvirt.
Oops. Didn't catch that in the rebase.
And please mention the QEMU version 6.1.0
There are a lot of libvirt features that require minimum versions of qemu, but it doesn't look like we generally specify these qemu version requirements in the libvirt documentation. Not sure if I should add it here...
We mention the required qemu version in many cases, so it definitely will not be an outlier. Usually it's when either it's important, a recent addition or somebody cares about adding it.

Capability to determine whether this qemu supports the 'blob' option for virtio-gpu. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml | 1 + 10 files changed, 11 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 4a03f4794b..72cd4366c8 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -675,6 +675,7 @@ VIR_ENUM_IMPL(virQEMUCaps, /* 430 */ "chardev.qemu-vdagent", /* QEMU_CAPS_CHARDEV_QEMU_VDAGENT */ + "virtio-gpu.blob", /* QEMU_CAPS_VIRTIO_GPU_BLOB */ ); @@ -1542,6 +1543,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioGpu[] = { { "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, NULL }, { "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL }, { "acpi-index", QEMU_CAPS_ACPI_INDEX, NULL }, + { "blob", QEMU_CAPS_VIRTIO_GPU_BLOB, NULL }, }; static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsICH9[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index baddb059b2..23f792072e 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -650,6 +650,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 430 */ QEMU_CAPS_CHARDEV_QEMU_VDAGENT, /* -chardev qemu-vdagent */ + QEMU_CAPS_VIRTIO_GPU_BLOB, /* -device virtio-gpu-*.blob= */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml index 7127e5d18a..833b5bf5e6 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -237,6 +237,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='virtio-gpu.blob'/> <version>6001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml index e45682a648..5fb63224da 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml @@ -202,6 +202,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='virtio-gpu.blob'/> <version>6001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700244</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml index 9c9d9aa08e..f1682edb09 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml @@ -197,6 +197,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='virtio-gpu.blob'/> <version>6002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900244</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml index 5eae115b28..b6b9eb5778 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml @@ -239,6 +239,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='virtio-gpu.blob'/> <version>6002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100244</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml index c20b360e01..2d85043cac 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml @@ -210,6 +210,7 @@ <flag name='virtio-iommu.boot-bypass'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='virtio-gpu.blob'/> <version>6002092</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml index 945227b7f4..9e72521fee 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml @@ -214,6 +214,7 @@ <flag name='virtio-iommu.boot-bypass'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='virtio-gpu.blob'/> <version>7000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml index 48fef44c9a..322fd2e8dc 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -243,6 +243,7 @@ <flag name='virtio-iommu.boot-bypass'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='virtio-gpu.blob'/> <version>7000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml index 332d9a1ac3..04d7961b58 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml @@ -243,6 +243,7 @@ <flag name='virtio-iommu.boot-bypass'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='virtio-gpu.blob'/> <version>7000050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100244</microcodeVersion> -- 2.35.1

This can improve performance for some guests since it reduces copying of display data between host and guest. Requires udmabuf on the host. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_cgroup.c | 22 ++++++---- src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.h | 1 + src/qemu/qemu_namespace.c | 22 ++++++++++ src/qemu/qemu_validate.c | 9 ++++ .../video-virtio-blob-absent.args | 34 +++++++++++++++ .../video-virtio-blob-absent.xml | 33 +++++++++++++++ .../video-virtio-blob-off.args | 34 +++++++++++++++ .../video-virtio-blob-off.xml | 33 +++++++++++++++ .../video-virtio-blob-on.args | 34 +++++++++++++++ .../qemuxml2argvdata/video-virtio-blob-on.xml | 33 +++++++++++++++ .../video-virtio-vga-blob-on.args | 34 +++++++++++++++ .../video-virtio-vga-blob-on.xml | 33 +++++++++++++++ tests/qemuxml2argvtest.c | 12 ++++++ .../video-virtio-blob-absent.xml | 41 +++++++++++++++++++ .../video-virtio-blob-off.xml | 41 +++++++++++++++++++ .../video-virtio-blob-on.xml | 41 +++++++++++++++++++ .../video-virtio-vga-blob-on.xml | 41 +++++++++++++++++++ tests/qemuxml2xmltest.c | 12 ++++++ 19 files changed, 506 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-vga-blob-on.xml diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index aa0c927578..659d81042a 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -557,16 +557,24 @@ qemuSetupVideoCgroup(virDomainObj *vm, { qemuDomainObjPrivate *priv = vm->privateData; virDomainVideoAccelDef *accel = def->accel; + int ret; - if (!accel) - return 0; - - if (!accel->rendernode || - !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) + if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) return 0; - return qemuCgroupAllowDevicePath(vm, accel->rendernode, - VIR_CGROUP_DEVICE_RW, false); + if (accel && accel->rendernode) { + ret = qemuCgroupAllowDevicePath(vm, accel->rendernode, + VIR_CGROUP_DEVICE_RW, false); + if (ret != 0) + return ret; + } + if (def->blob == VIR_TRISTATE_SWITCH_ON) { + ret = qemuCgroupAllowDevicePath(vm, QEMU_DEV_UDMABUF, + VIR_CGROUP_DEVICE_RW, false); + if (ret != 0) + return ret; + } + return 0; } static int diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8eac8edd79..898941d935 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4904,6 +4904,9 @@ qemuBuildDeviceVideoCmd(virCommand *cmd, "p:vgamem", video->vram * 1024, NULL) < 0) return -1; + } else if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (virJSONValueObjectAdd(&props, "T:blob", video->blob, NULL) < 0) + return -1; } if (video->res) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index c7125722e0..714cbb7d44 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -85,6 +85,7 @@ struct _qemuDomainUnpluggingDevice { #define QEMU_DEV_VFIO "/dev/vfio/vfio" #define QEMU_DEV_SEV "/dev/sev" #define QEMU_DEVICE_MAPPER_CONTROL_PATH "/dev/mapper/control" +#define QEMU_DEV_UDMABUF "/dev/udmabuf" #define QEMU_DOMAIN_AES_IV_LEN 16 /* 16 bytes for 128 bit random */ diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 23681b14a4..6e28023281 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -485,6 +485,25 @@ qemuDomainSetupAllGraphics(virDomainObj *vm, } +static int +qemuDomainSetupAllVideos(virDomainObj *vm, + GSList **paths) +{ + size_t i; + + VIR_DEBUG("Setting up video devices"); + for (i = 0; i < vm->def->nvideos; i++) { + virDomainVideoDef *video = vm->def->videos[i]; + if (video->blob == VIR_TRISTATE_SWITCH_ON) { + *paths = g_slist_prepend(*paths, g_strdup(QEMU_DEV_UDMABUF)); + break; + } + } + + return 0; +} + + static int qemuDomainSetupInput(virDomainInputDef *input, GSList **paths) @@ -654,6 +673,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfig *cfg, if (qemuDomainSetupAllGraphics(vm, &paths) < 0) return -1; + if (qemuDomainSetupAllVideos(vm, &paths) < 0) + return -1; + if (qemuDomainSetupAllInputs(vm, &paths) < 0) return -1; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 094ebce9c6..5bbd26673b 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2592,6 +2592,15 @@ qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video, } } + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (video->blob != VIR_TRISTATE_SWITCH_ABSENT && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_BLOB)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("this QEMU does not support 'blob' for virtio-gpu devices")); + return -1; + } + } + if (qemuValidateDomainVirtioOptions(video->virtio, qemuCaps) < 0) return -1; diff --git a/tests/qemuxml2argvdata/video-virtio-blob-absent.args b/tests/qemuxml2argvdata/video-virtio-blob-absent.args new file mode 100644 index 0000000000..012f8e50b9 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-absent.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,usb=off,dump-guest-core=off \ +-accel tcg \ +-m 1024 \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-usb \ +-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,cache=none \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-device virtio-gpu-pci,id=video0,max_outputs=1,bus=pci.0,addr=0x2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/video-virtio-blob-absent.xml b/tests/qemuxml2argvdata/video-virtio-blob-absent.xml new file mode 100644 index 0000000000..a9354d77a2 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-absent.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <video> + <model type='virtio' heads='1'/> + </video> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/video-virtio-blob-off.args b/tests/qemuxml2argvdata/video-virtio-blob-off.args new file mode 100644 index 0000000000..9af5227dd7 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-off.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,usb=off,dump-guest-core=off \ +-accel tcg \ +-m 1024 \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-usb \ +-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,cache=none \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-device virtio-gpu-pci,id=video0,max_outputs=1,blob=off,bus=pci.0,addr=0x2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/video-virtio-blob-off.xml b/tests/qemuxml2argvdata/video-virtio-blob-off.xml new file mode 100644 index 0000000000..7b51762e9a --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-off.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <video> + <model type='virtio' heads='1' blob='off'/> + </video> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/video-virtio-blob-on.args b/tests/qemuxml2argvdata/video-virtio-blob-on.args new file mode 100644 index 0000000000..e09f5a6aed --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-on.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,usb=off,dump-guest-core=off \ +-accel tcg \ +-m 1024 \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-usb \ +-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,cache=none \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-device virtio-gpu-pci,id=video0,max_outputs=1,blob=on,bus=pci.0,addr=0x2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/video-virtio-blob-on.xml b/tests/qemuxml2argvdata/video-virtio-blob-on.xml new file mode 100644 index 0000000000..187347fac0 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-on.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <video> + <model type='virtio' heads='1' blob="on"/> + </video> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/video-virtio-vga-blob-on.args b/tests/qemuxml2argvdata/video-virtio-vga-blob-on.args new file mode 100644 index 0000000000..eeef2ee821 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-vga-blob-on.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,usb=off,dump-guest-core=off \ +-accel tcg \ +-m 1024 \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-usb \ +-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,cache=none \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-device virtio-vga,id=video0,max_outputs=1,blob=on,bus=pci.0,addr=0x2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml b/tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml new file mode 100644 index 0000000000..00aed31d28 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <video> + <model type='virtio' primary="yes" heads='1' blob="on"/> + </video> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1d6e03490d..b2de8ef44f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2437,6 +2437,18 @@ mymain(void) DO_TEST("video-virtio-vga", QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_VIRTIO_VGA); + DO_TEST("video-virtio-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-vga-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_VGA, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-off", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-absent", + QEMU_CAPS_DEVICE_VIRTIO_GPU); DO_TEST_CAPS_LATEST("video-virtio-vga-gpu-gl"); DO_TEST_CAPS_LATEST("video-bochs-display-device"); DO_TEST_CAPS_LATEST("video-ramfb-display-device"); diff --git a/tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml b/tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml new file mode 100644 index 0000000000..827ed19153 --- /dev/null +++ b/tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <video> + <model type='virtio' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/video-virtio-blob-off.xml b/tests/qemuxml2xmloutdata/video-virtio-blob-off.xml new file mode 100644 index 0000000000..5742687d6a --- /dev/null +++ b/tests/qemuxml2xmloutdata/video-virtio-blob-off.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <video> + <model type='virtio' heads='1' primary='yes' blob='off'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/video-virtio-blob-on.xml b/tests/qemuxml2xmloutdata/video-virtio-blob-on.xml new file mode 100644 index 0000000000..649c4e5e4c --- /dev/null +++ b/tests/qemuxml2xmloutdata/video-virtio-blob-on.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <video> + <model type='virtio' heads='1' primary='yes' blob='on'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/video-virtio-vga-blob-on.xml b/tests/qemuxml2xmloutdata/video-virtio-vga-blob-on.xml new file mode 100644 index 0000000000..649c4e5e4c --- /dev/null +++ b/tests/qemuxml2xmloutdata/video-virtio-vga-blob-on.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <video> + <model type='virtio' heads='1' primary='yes' blob='on'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 518842112e..3d31a1480f 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1278,6 +1278,18 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW); DO_TEST("video-none-device", QEMU_CAPS_VNC); DO_TEST_CAPS_LATEST("video-virtio-vga-gpu-gl"); + DO_TEST("video-virtio-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-vga-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_VGA, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-off", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-absent", + QEMU_CAPS_DEVICE_VIRTIO_GPU); DO_TEST_CAPS_LATEST("intel-iommu"); DO_TEST_CAPS_LATEST("intel-iommu-caching-mode"); -- 2.35.1

On Tue, May 10, 2022 at 11:24:31 -0500, Jonathon Jongsma wrote:
This can improve performance for some guests since it reduces copying of display data between host and guest. Requires udmabuf on the host.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_cgroup.c | 22 ++++++---- src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.h | 1 + src/qemu/qemu_namespace.c | 22 ++++++++++ src/qemu/qemu_validate.c | 9 ++++ .../video-virtio-blob-absent.args | 34 +++++++++++++++ .../video-virtio-blob-absent.xml | 33 +++++++++++++++ .../video-virtio-blob-off.args | 34 +++++++++++++++ .../video-virtio-blob-off.xml | 33 +++++++++++++++ .../video-virtio-blob-on.args | 34 +++++++++++++++ .../qemuxml2argvdata/video-virtio-blob-on.xml | 33 +++++++++++++++ .../video-virtio-vga-blob-on.args | 34 +++++++++++++++ .../video-virtio-vga-blob-on.xml | 33 +++++++++++++++ tests/qemuxml2argvtest.c | 12 ++++++ .../video-virtio-blob-absent.xml | 41 +++++++++++++++++++ .../video-virtio-blob-off.xml | 41 +++++++++++++++++++ .../video-virtio-blob-on.xml | 41 +++++++++++++++++++ .../video-virtio-vga-blob-on.xml | 41 +++++++++++++++++++ tests/qemuxml2xmltest.c | 12 ++++++ 19 files changed, 506 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-vga-blob-on.xml
[...]
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1d6e03490d..b2de8ef44f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2437,6 +2437,18 @@ mymain(void) DO_TEST("video-virtio-vga", QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_VIRTIO_VGA); + DO_TEST("video-virtio-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-vga-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_VGA, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-off", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-absent", + QEMU_CAPS_DEVICE_VIRTIO_GPU); DO_TEST_CAPS_LATEST("video-virtio-vga-gpu-gl"); DO_TEST_CAPS_LATEST("video-bochs-display-device"); DO_TEST_CAPS_LATEST("video-ramfb-display-device");
[...]
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 518842112e..3d31a1480f 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1278,6 +1278,18 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW); DO_TEST("video-none-device", QEMU_CAPS_VNC); DO_TEST_CAPS_LATEST("video-virtio-vga-gpu-gl"); + DO_TEST("video-virtio-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-vga-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_VGA, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-off", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-absent", + QEMU_CAPS_DEVICE_VIRTIO_GPU);
Please make sure to preferrably use DO_TEST_CAPS_LATEST or DO_TEST_CAPS_VER for positive test cases, unless there's a very specific need to test with a certain flag combination. I can have a closer look at this series later once I finish the other stuff I planned to review.

On 5/11/22 7:06 AM, Peter Krempa wrote:
On Tue, May 10, 2022 at 11:24:31 -0500, Jonathon Jongsma wrote:
This can improve performance for some guests since it reduces copying of display data between host and guest. Requires udmabuf on the host.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_cgroup.c | 22 ++++++---- src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.h | 1 + src/qemu/qemu_namespace.c | 22 ++++++++++ src/qemu/qemu_validate.c | 9 ++++ .../video-virtio-blob-absent.args | 34 +++++++++++++++ .../video-virtio-blob-absent.xml | 33 +++++++++++++++ .../video-virtio-blob-off.args | 34 +++++++++++++++ .../video-virtio-blob-off.xml | 33 +++++++++++++++ .../video-virtio-blob-on.args | 34 +++++++++++++++ .../qemuxml2argvdata/video-virtio-blob-on.xml | 33 +++++++++++++++ .../video-virtio-vga-blob-on.args | 34 +++++++++++++++ .../video-virtio-vga-blob-on.xml | 33 +++++++++++++++ tests/qemuxml2argvtest.c | 12 ++++++ .../video-virtio-blob-absent.xml | 41 +++++++++++++++++++ .../video-virtio-blob-off.xml | 41 +++++++++++++++++++ .../video-virtio-blob-on.xml | 41 +++++++++++++++++++ .../video-virtio-vga-blob-on.xml | 41 +++++++++++++++++++ tests/qemuxml2xmltest.c | 12 ++++++ 19 files changed, 506 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-vga-blob-on.xml
[...]
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1d6e03490d..b2de8ef44f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2437,6 +2437,18 @@ mymain(void) DO_TEST("video-virtio-vga", QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_VIRTIO_VGA); + DO_TEST("video-virtio-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-vga-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_VGA, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-off", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-absent", + QEMU_CAPS_DEVICE_VIRTIO_GPU); DO_TEST_CAPS_LATEST("video-virtio-vga-gpu-gl"); DO_TEST_CAPS_LATEST("video-bochs-display-device"); DO_TEST_CAPS_LATEST("video-ramfb-display-device");
[...]
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 518842112e..3d31a1480f 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1278,6 +1278,18 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW); DO_TEST("video-none-device", QEMU_CAPS_VNC); DO_TEST_CAPS_LATEST("video-virtio-vga-gpu-gl"); + DO_TEST("video-virtio-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-vga-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_VGA, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-off", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-absent", + QEMU_CAPS_DEVICE_VIRTIO_GPU);
Please make sure to preferrably use DO_TEST_CAPS_LATEST or DO_TEST_CAPS_VER for positive test cases, unless there's a very specific need to test with a certain flag combination.
I can have a closer look at this series later once I finish the other stuff I planned to review.
Do you still plan to take a look at this Peter, or should I post a new version with these changes and the doc changes suggested by Han Han? Jonathon
participants (3)
-
Han Han
-
Jonathon Jongsma
-
Peter Krempa