[PATCH v2 1/2] conf: add support for 'edid' attribute to video model

Mark Cave-Ayland posted 2 patches 1 month ago
There is a newer version of this series
[PATCH v2 1/2] conf: add support for 'edid' attribute to video model
Posted by Mark Cave-Ayland 1 month ago
Add the ability to enable/disable exposing the EDID information to the guest.
The edid attribute can specified in the domain XML as below:

    <video>
        <model type='virtio' edid='off'/>
    </video>

If the edid attribute is unspecified, it is not generated so that the
virtualisation platform will continue to use its default.

The edid attribute is only valid for the vga, boch and virtio display models
and is currently only implemented for the QEMU driver.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 docs/formatdomain.rst             |  8 ++++++++
 src/conf/domain_conf.c            |  5 +++++
 src/conf/domain_conf.h            |  1 +
 src/conf/domain_validate.c        | 11 +++++++++++
 src/conf/schemas/domaincommon.rng |  5 +++++
 src/qemu/qemu_command.c           |  3 +++
 6 files changed, 33 insertions(+)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index d3c04d8b2a..e66db10abe 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -7110,6 +7110,14 @@ A video device.
    sub-element is valid for model types "vga", "qxl", "bochs", "gop",
    and "virtio".
 
+   :since:`Since 11.7.0` (QEMU driver only), the ``model`` element may have an
+   optional ``edid`` attribute that can be set to "on" or "off". If the ``edid``
+   attribute is not specified then the device will use its default value.
+   Otherwise setting ``edid`` to "on" will expose the device EDID blob to the
+   guest, whilst setting it to "off" will hide the device EDID blob from the
+   guest. The ``edid`` attribute is only valid for model types "vga", "bochs",
+   and "virtio".
+
 ``acceleration``
    Configure if video acceleration should be enabled.
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cb096f2e1e..9939d83513 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13547,6 +13547,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def,
     if (virXMLPropTristateSwitch(node, "blob", VIR_XML_PROP_NONE, &def->blob) < 0)
         return -1;
 
+    if (virXMLPropTristateSwitch(node, "edid", VIR_XML_PROP_NONE, &def->edid) < 0)
+        return -1;
+
     return 0;
 }
 
@@ -26657,6 +26660,8 @@ virDomainVideoDefFormat(virBuffer *buf,
         virBufferAddLit(buf, " primary='yes'");
     if (def->blob != VIR_TRISTATE_SWITCH_ABSENT)
         virBufferAsprintf(buf, " blob='%s'", virTristateSwitchTypeToString(def->blob));
+    if (def->edid != VIR_TRISTATE_SWITCH_ABSENT)
+        virBufferAsprintf(buf, " edid='%s'", virTristateSwitchTypeToString(def->edid));
     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 984e5bfc76..eca820892e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1895,6 +1895,7 @@ struct _virDomainVideoDef {
     virDomainDeviceInfo info;
     virDomainVirtioOptions *virtio;
     virDomainVideoBackendType backend;
+    virTristateSwitch edid;
 };
 
 /* graphics console modes */
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 40edecef83..60a2e46b7e 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -231,6 +231,17 @@ virDomainVideoDefValidate(const virDomainVideoDef *video,
         }
     }
 
+    if ((video->type != VIR_DOMAIN_VIDEO_TYPE_BOCHS) &&
+        (video->type != VIR_DOMAIN_VIDEO_TYPE_VGA) &&
+        (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO)) {
+            if (video->edid != VIR_TRISTATE_SWITCH_ABSENT) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("video type '%1$s' does not support edid"),
+                               virDomainVideoTypeToString(video->type));
+                return -1;
+            }
+    }
+
     return 0;
 }
 
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 9782dca147..e369fb6e81 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -4812,6 +4812,11 @@
                 <ref name="virOnOff"/>
               </attribute>
             </optional>
+            <optional>
+              <attribute name="edid">
+                <ref name="virOnOff"/>
+              </attribute>
+            </optional>
             <optional>
               <element name="acceleration">
                 <optional>
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4e4f1e87eb..e8de386f30 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4739,6 +4739,9 @@ qemuBuildDeviceVideoCmd(virCommand *cmd,
             return -1;
     }
 
+    if (virJSONValueObjectAdd(&props, "T:edid", video->edid, NULL) < 0)
+        return -1;
+
     if (video->res) {
         if (virJSONValueObjectAdd(&props,
                                   "p:xres", video->res->x,
-- 
2.43.0
Re: [PATCH v2 1/2] conf: add support for 'edid' attribute to video model
Posted by Peter Krempa via Devel 1 month ago
On Mon, Aug 04, 2025 at 15:07:19 +0100, Mark Cave-Ayland wrote:
> Add the ability to enable/disable exposing the EDID information to the guest.
> The edid attribute can specified in the domain XML as below:
> 
>     <video>
>         <model type='virtio' edid='off'/>
>     </video>
> 
> If the edid attribute is unspecified, it is not generated so that the
> virtualisation platform will continue to use its default.
> 
> The edid attribute is only valid for the vga, boch and virtio display models
> and is currently only implemented for the QEMU driver.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
>  docs/formatdomain.rst             |  8 ++++++++
>  src/conf/domain_conf.c            |  5 +++++
>  src/conf/domain_conf.h            |  1 +
>  src/conf/domain_validate.c        | 11 +++++++++++
>  src/conf/schemas/domaincommon.rng |  5 +++++
>  src/qemu/qemu_command.c           |  3 +++
>  6 files changed, 33 insertions(+)
> 
> diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
> index d3c04d8b2a..e66db10abe 100644
> --- a/docs/formatdomain.rst
> +++ b/docs/formatdomain.rst
> @@ -7110,6 +7110,14 @@ A video device.
>     sub-element is valid for model types "vga", "qxl", "bochs", "gop",
>     and "virtio".
>  
> +   :since:`Since 11.7.0` (QEMU driver only), the ``model`` element may have an
> +   optional ``edid`` attribute that can be set to "on" or "off". If the ``edid``
> +   attribute is not specified then the device will use its default value.
> +   Otherwise setting ``edid`` to "on" will expose the device EDID blob to the
> +   guest, whilst setting it to "off" will hide the device EDID blob from the
> +   guest. The ``edid`` attribute is only valid for model types "vga", "bochs",
> +   and "virtio".

Preferrably use the backticks (verbatim markup) also for all the models
and values (on/off/virtio/vga ...).

> +
>  ``acceleration``
>     Configure if video acceleration should be enabled.

This patch is also still missing the ABI stability check that the config
didn't chagne e.g. during migration.

ABI checks for video devices are done in
virDomainVideoDefCheckABIStability.
Re: [PATCH v2 1/2] conf: add support for 'edid' attribute to video model
Posted by Mark Cave-Ayland 1 month ago
On 06/08/2025 15:10, Peter Krempa wrote:

> On Mon, Aug 04, 2025 at 15:07:19 +0100, Mark Cave-Ayland wrote:
>> Add the ability to enable/disable exposing the EDID information to the guest.
>> The edid attribute can specified in the domain XML as below:
>>
>>      <video>
>>          <model type='virtio' edid='off'/>
>>      </video>
>>
>> If the edid attribute is unspecified, it is not generated so that the
>> virtualisation platform will continue to use its default.
>>
>> The edid attribute is only valid for the vga, boch and virtio display models
>> and is currently only implemented for the QEMU driver.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>> ---
>>   docs/formatdomain.rst             |  8 ++++++++
>>   src/conf/domain_conf.c            |  5 +++++
>>   src/conf/domain_conf.h            |  1 +
>>   src/conf/domain_validate.c        | 11 +++++++++++
>>   src/conf/schemas/domaincommon.rng |  5 +++++
>>   src/qemu/qemu_command.c           |  3 +++
>>   6 files changed, 33 insertions(+)
>>
>> diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
>> index d3c04d8b2a..e66db10abe 100644
>> --- a/docs/formatdomain.rst
>> +++ b/docs/formatdomain.rst
>> @@ -7110,6 +7110,14 @@ A video device.
>>      sub-element is valid for model types "vga", "qxl", "bochs", "gop",
>>      and "virtio".
>>   
>> +   :since:`Since 11.7.0` (QEMU driver only), the ``model`` element may have an
>> +   optional ``edid`` attribute that can be set to "on" or "off". If the ``edid``
>> +   attribute is not specified then the device will use its default value.
>> +   Otherwise setting ``edid`` to "on" will expose the device EDID blob to the
>> +   guest, whilst setting it to "off" will hide the device EDID blob from the
>> +   guest. The ``edid`` attribute is only valid for model types "vga", "bochs",
>> +   and "virtio".
> 
> Preferrably use the backticks (verbatim markup) also for all the models
> and values (on/off/virtio/vga ...).

No problem, will fix in the next version.

>> +
>>   ``acceleration``
>>      Configure if video acceleration should be enabled.
> 
> This patch is also still missing the ABI stability check that the config
> didn't chagne e.g. during migration.
> 
> ABI checks for video devices are done in
> virDomainVideoDefCheckABIStability.

I'll make sure that this is also added.


ATB,

Mark.