[libvirt PATCH] xenconfig: Add feature gfx_passthru

Artur Puzio contact at puzio.waw.pl
Wed May 13 11:56:52 UTC 2020


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


On 12.05.2020 15:47, Artur Puzio wrote:
> On 08.05.2020 18:41, Jim Fehlig wrote:
>> On 4/30/20 6:07 AM, Artur Puzio wrote:
>>> gfx_passthru xl.cfg option enables GPU specific quirks required for
>>> working
>>> Intel GPU passthru. Qemu (used for device model by xen) will refuse
>>> to start
>>> a VM when an IGD is passed, but this option was not set in Xen.
>>
>> Do we really need to expose this setting to the user? I'm not really
>> sure what to think about it after reading the xl.cfg(5) man page. It
>> starts with
>>
>>   gfx_passthru=BOOLEAN|"STRING"
>>
>> The setting can be a boolean or a string - nice. And it really seems
>> specific to Intel graphics cards. The man page claims that a value of
>> 1 "Enables graphics device PCI passthrough and autodetects the type of
>> device which is being used.". It also says "Note that some graphics
>> cards (AMD/ATI cards, for example) do not necessarily require the
>> gfx_passthru option".
>>
>> Can't libxl just enable this itself if there's a PCI passthrough
>> device and it's detected as type igd?
>>
>> Regards,
>> Jim
>
> Hi, sorry for slowish response.
>
> Setting gfx_passthru to 1 as in this patch enables the autodetection
> routines (it's equivalent to gfx_passthru=1 from xl.cfg). Currently
> libxl handles only IGD. If there is no IGD specified at creation and
> gfx_passthru is 1, autodetection routines will report an error
> preventing domain creation. Relevant libxl code:
>
> libxl_dm.c:1746
>
>         if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) {
>             enum libxl_gfx_passthru_kind gfx_passthru_kind =
>                             libxl__detect_gfx_passthru_kind(gc,
> guest_config);
>             switch (gfx_passthru_kind) {
>             case LIBXL_GFX_PASSTHRU_KIND_IGD:
>                 machinearg = GCSPRINTF("%s,igd-passthru=on", machinearg);
>                 break;
>             case LIBXL_GFX_PASSTHRU_KIND_DEFAULT:
>                 LOGD(ERROR, guest_domid, "unable to detect required
> gfx_passthru_kind");
>                 return ERROR_FAIL;
>             default:
>                 LOGD(ERROR, guest_domid, "invalid value for
> gfx_passthru_kind");
>                 return ERROR_INVAL;
>             }
>         }
>
> libxl contains a function for checking if IGD is present. After some
> testing I will send another version of this patch that will enable
> gfx_passthru if there is a IGD attached.
>
> Artur

I have checked possible ways for detection and reusing existing libxl
functions is not possible. Most of relevant functions (including
libxl__detect_gfx_passthru_kind & libxl__is_igd_vga_passthru) use
libxl__gc (libxl garbage collector). AFAIK no libvirt code uses
libxl__gc. We probably shouldn't start doing that(?) Also
libxl__detect_gfx_passthru_kind is static.

So the only way would be to reimplement detection if IGD is attached.
Even if it would work the same as libxl detection, it would probably
stop in the future... I think just exposing the option to the user is
much, much easier and future proof.

Artur

>>
>>>
>>> Signed-off-by: Artur Puzio <contact at puzio.waw.pl>
>>> ---
>>>   docs/formatdomain.html.in     |  7 +++++++
>>>   docs/schemas/domaincommon.rng |  5 +++++
>>>   src/conf/domain_conf.c        |  4 ++++
>>>   src/conf/domain_conf.h        |  1 +
>>>   src/libxl/libxl_conf.c        | 13 +++++++++++++
>>>   5 files changed, 30 insertions(+)
>>>
>>> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
>>> index 91d6f6c0d3..5307844a23 100644
>>> --- a/docs/formatdomain.html.in
>>> +++ b/docs/formatdomain.html.in
>>> @@ -2064,6 +2064,7 @@
>>>     <xen>
>>>       <e820_host state='on'/>
>>>       <passthrough state='on' mode='share_pt'/>
>>> +    <gfx_passthru state='on'/>
>>>     </xen>
>>>     <pvspinlock state='on'/>
>>>     <gic version='2'/>
>>> @@ -2270,6 +2271,12 @@
>>>             <td>on, off; mode - optional string sync_pt or share_pt</td>
>>>             <td><span class="since">6.3.0</span></td>
>>>           </tr>
>>> +        <tr>
>>> +          <td>gfx_passthru</td>
>>> +          <td>Enable Intel GPU specific quirks. Required and allowed
>>> only when passing an IGD.</td>
>>> +          <td>on, off</td>
>>> +          <td><span class="since">6.3.0</span></td>
>>> +        </tr>
>>>         </table>
>>>         </dd>
>>>         <dt><code>pmu</code></dt>
>>> diff --git a/docs/schemas/domaincommon.rng
>>> b/docs/schemas/domaincommon.rng
>>> index 9d60b090f3..7d8ea879a1 100644
>>> --- a/docs/schemas/domaincommon.rng
>>> +++ b/docs/schemas/domaincommon.rng
>>> @@ -6409,6 +6409,11 @@
>>>               </optional>
>>>             </element>
>>>           </optional>
>>> +        <optional>
>>> +          <element name="gfx_passthru">
>>> +            <ref name="featurestate"/>
>>> +          </element>
>>> +        </optional>
>>>         </interleave>
>>>       </element>
>>>     </define>
>>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>>> index 8a87586936..75f72ff64c 100644
>>> --- a/src/conf/domain_conf.c
>>> +++ b/src/conf/domain_conf.c
>>> @@ -214,6 +214,7 @@ VIR_ENUM_IMPL(virDomainXen,
>>>                 VIR_DOMAIN_XEN_LAST,
>>>                 "e820_host",
>>>                 "passthrough",
>>> +              "gfx_passthru"
>>>   );
>>>     VIR_ENUM_IMPL(virDomainXenPassthroughMode,
>>> @@ -19649,6 +19650,7 @@ virDomainFeaturesDefParse(virDomainDefPtr def,
>>>                 switch ((virDomainXen) feature) {
>>>                   case VIR_DOMAIN_XEN_E820_HOST:
>>> +                case VIR_DOMAIN_XEN_GFX_PASSTHRU:
>>>                       break;
>>>                 case VIR_DOMAIN_XEN_PASSTHROUGH:
>>> @@ -23579,6 +23581,7 @@
>>> virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
>>>               }
>>>               switch ((virDomainXen) i) {
>>>               case VIR_DOMAIN_XEN_E820_HOST:
>>> +            case VIR_DOMAIN_XEN_GFX_PASSTHRU:
>>>                   break;
>>>                 case VIR_DOMAIN_XEN_PASSTHROUGH:
>>> @@ -29235,6 +29238,7 @@ virDomainDefFormatFeatures(virBufferPtr buf,
>>>                     switch ((virDomainXen) j) {
>>>                   case VIR_DOMAIN_XEN_E820_HOST:
>>> +                case VIR_DOMAIN_XEN_GFX_PASSTHRU:
>>>                       virBufferAddLit(&childBuf, "/>\n");
>>>                       break;
>>>                   case VIR_DOMAIN_XEN_PASSTHROUGH:
>>> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
>>> index 4afd8f04bc..f28f0741ac 100644
>>> --- a/src/conf/domain_conf.h
>>> +++ b/src/conf/domain_conf.h
>>> @@ -1867,6 +1867,7 @@ typedef enum {
>>>   typedef enum {
>>>       VIR_DOMAIN_XEN_E820_HOST = 0,
>>>       VIR_DOMAIN_XEN_PASSTHROUGH,
>>> +    VIR_DOMAIN_XEN_GFX_PASSTHRU,
>>>         VIR_DOMAIN_XEN_LAST
>>>   } virDomainXen;
>>> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
>>> index 458dfc2399..a5605f6200 100644
>>> --- a/src/libxl/libxl_conf.c
>>> +++ b/src/libxl/libxl_conf.c
>>> @@ -679,6 +679,19 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
>>>               return -1;
>>>           }
>>>   #endif
>>> +        if (def->features[VIR_DOMAIN_FEATURE_XEN] ==
>>> VIR_TRISTATE_SWITCH_ON) {
>>> +            switch ((virTristateSwitch)
>>> def->xen_features[VIR_DOMAIN_XEN_GFX_PASSTHRU]) {
>>> +                case VIR_TRISTATE_SWITCH_ON:
>>> +                    libxl_defbool_set(&b_info->u.hvm.gfx_passthru,
>>> true);
>>> +                    break;
>>> +                case VIR_TRISTATE_SWITCH_OFF:
>>> +                    libxl_defbool_set(&b_info->u.hvm.gfx_passthru,
>>> false);
>>> +                    break;
>>> +                case VIR_TRISTATE_SWITCH_ABSENT:
>>> +                case VIR_TRISTATE_SWITCH_LAST:
>>> +                    break;
>>> +            }
>>> +        }
>>>       } else if (pvh) {
>>>           b_info->cmdline = g_strdup(def->os.cmdline);
>>>           b_info->kernel = g_strdup(def->os.kernel);
>>>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEO6ZYTXOQH2Fi5VSz2HdiIEz/5y8FAl674H8ACgkQ2HdiIEz/
5y/JBg//cxAc7VQ8iiY+Z+dNTGQPbU+uXmc1stToZQqxvVmJwI9KyMNT2uxPgpV4
jjL8B8RQ7IVlx9q11x9bXW4gwJ8FM63F1JsIzmBeLLyaFD+6KLnqpfZE0lCa5BYb
vZ8N+uSKda8yyCsssR5NJ47I6IwlDpTSK3dcMWmCxM389fbyHeKhCUi0pGCGpNEe
PTlPapqwdMzIOdQNEfJewZ/EtDOr/uw2aAZaywyiuDNtGVN+9eEwiuGUUm0tM9Za
k66F5c6gFqpwXYpYVl3jKC3O8oadkcOncYIy3CZ/2I3V6odRUAARsFmEm+zg9Yvl
hSyG7j0WBAUbH+uot7tmDyfnhskje4YFSOKbycILcOFPgtWkvVy3COPzxUz4MOSj
8hMd+9nBnEQXK5ZYkcX1KeDR0REcV7b5C9r7Rm3fJkZybjF62+G/aaoD0GP7sQtZ
4na5taIed/k/aHhu9x/T1Q1QsQOZ/B4NcStG6hh5vO5GkrUPG3fJBAykwFw/Gv/H
2+pG3Z2iOSSP4xtES+jCnQ1bajDX/Wo5xmHpi6FUTGpeR7ObXxL38UrLrrs/pB6y
gaYDvOo+itY3hIKnHb9EmRfU/4Gm43xsBe/xp36LRSZRF3Q27SBzy061oQHI9ZYP
h4zvHLu8FN/0XBP+kq+fomkmEWVjgYpH0SVGvb/k8ealHCdZKW0=
=az2+
-----END PGP SIGNATURE-----





More information about the libvir-list mailing list