Re: [libvirt PATCH] xenconfig: Add feature gfx_passthru

2020-05-14 Thread Artur Puzio
On 14.05.2020 03:41, Marek Marczykowski-Górecki wrote:
> On Wed, May 13, 2020 at 01:56:52PM +0200, Artur Puzio wrote:
>>
>> 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?
>> 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.
> Existing strategies:
> 1. libxl__is_igd_vga_passthru checks for Intel device (0x8086 vendor) with
> VGA class (0x03). This should be easy to duplicate using libvirt
> API, like virPCIDeviceReadID(dev, "vendor") and same for "class".
>
> 2. qemu uses a different approach and checks for device being
> :00:02.0. Again, simple to duplicate into libvirt.
>
> As we can see above, there are already two approaches, and it isn't
> exactly clear which should be used. In fact, I think if those two
> strategies won't match at some point, the domain may fail to start,
> because qemu refuses to start with IGD attached (according to its
> definition) but without the option enabled.
>
> Looking at the libxl code, the only thing that option is used for, is to
> add it to the qemu command line (Artur, have I missed anything?).

It's also used in libxl_pci.c:2449 in func:
libxl__grant_vga_iomem_permission. This check is not really necessary as
libxl__grant_vga_iomem_permission already grants VGA IO memory
permissions only if it finds a VGA class device.

>  In that case, I think ideal solution would be to patch it at the qemu
> level, to enable the option automatically. I believe this is exactly
> the case for KVM case (vfio-pci). But I think that's non-trivial
> approach in Xen path (if it would be easy, I think we wouldn't have this
> option in the first place). For example the option makes qemu choose a
> different PCI bridge configuration, which is I think done before
> checking if IGD is attached. So, while there maybe a technical reason
> for having this option in qmeu (instead of auto-detection), I don't
> really see why user needs to provide it manually.
>
> Since libxl already has a function to detect IGD, then adding
> autodetection there would be a better idea. I don't know what libxl
> maintainers would prefer, but I guess either of "not failing if
> gfx_passthru=1 but IGD isn't detected" or adding "gfx_passthru=auto".
I will go ahead and contact libxl maintainers if they would agree to
some autodetection solution. Maybe in the mean time we could expose this
option to the user in case he want's to disable/enable the autodetection
explicitly? When Xen will have some autodetection we could change the
default.
> BTW Here is the discussion when the option was added to qemu:
> https://lists.nongnu.org/archive/html/qemu-devel/2015-01/msg02756.html
> It may be quite helpful to understand what is it about, but also why
> (for example I see mentions of some specific Windows drivers).
>



signature.asc
Description: OpenPGP digital signature


Re: [libvirt PATCH] xenconfig: Add feature gfx_passthru

2020-05-13 Thread Artur Puzio


-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 
>>> ---
>>>   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 @@
>>>             on, off; mode - optional string sync_pt or 
>>>share_pt
>>>             6.3.0
>>>           
>>> +        
>>> +          gfx_passthru
>>> +        

Re: [libvirt PATCH] xenconfig: Add feature gfx_passthru

2020-05-12 Thread Artur Puzio
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

>
>>
>> Signed-off-by: Artur Puzio 
>> ---
>>   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 @@
>>     on, off; mode - optional string sync_pt or share_pt
>>     6.3.0
>>   
>> +    
>> +  gfx_passthru
>> +  Enable Intel GPU specific quirks. Required and allowed
>> only when passing an IGD.
>> +  on, off
>> +  6.3.0
>> +    
>>     
>>     
>>     pmu
>> 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 @@
>>   
>>     
>>   
>> +    
>> +  
>> +    
>> +  
>> +    
>>     
>>   
>>     
>> 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_PASS

Re: [libvirt PATCH v2] libxl: vga.kind none when no device specified

2020-05-07 Thread Artur Puzio
Added Signed-off-by line

Artur Puzio

On 07.05.2020 13:24, Artur Puzio wrote:
> When no video device is specified in config we should set both
> hvm.nographic to 1 and hvm.vga.kind to NONE.
>
> Without hvm.vga.kind=LIBXL_VGA_INTERFACE_TYPE_NONE both -nographic and
> -device 'cirrus-vga' are on qemu cmdline.
>
> Signed-off-by: Artur Puzio 
> ---
>  src/libxl/libxl_conf.c   | 1 +
>  tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json | 3 +++
>  tests/libxlxml2domconfigdata/fullvirt-cpuid.json | 3 +++
>  3 files changed, 7 insertions(+)
>
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 458dfc2399..a0059fc2a7 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -2404,6 +2404,7 @@ libxlMakeVideo(virDomainDefPtr def, libxl_domain_config 
> *d_config)
>  b_info->video_memkb = def->videos[0]->vram;
>  } else {
>  libxl_defbool_set(_info->u.hvm.nographic, 1);
> +b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_NONE;
>  }
>  
>  return 0;
> diff --git a/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json 
> b/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
> index e804389fea..f16b4a971a 100644
> --- a/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
> +++ b/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
> @@ -20,6 +20,9 @@
>  "acpi": "True",
>  "acpi_firmware": "/path/to/slic.dat",
>  "nographic": "True",
> +"vga": {
> +"kind": "none"
> +},
>  "vnc": {
>  "enable": "False"
>  },
> diff --git a/tests/libxlxml2domconfigdata/fullvirt-cpuid.json 
> b/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
> index d46b464642..ddc423bca7 100644
> --- a/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
> +++ b/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
> @@ -27,6 +27,9 @@
>  "apic": "True",
>  "acpi": "True",
>  "nographic": "True",
> +"vga": {
> +"kind": "none"
> +},
>  "vnc": {
>  "enable": "False"
>  },



signature.asc
Description: OpenPGP digital signature


[libvirt PATCH v2] libxl: vga.kind none when no device specified

2020-05-07 Thread Artur Puzio
When no video device is specified in config we should set both
hvm.nographic to 1 and hvm.vga.kind to NONE.

Without hvm.vga.kind=LIBXL_VGA_INTERFACE_TYPE_NONE both -nographic and
-device 'cirrus-vga' are on qemu cmdline.

Signed-off-by: Artur Puzio 
---
 src/libxl/libxl_conf.c   | 1 +
 tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json | 3 +++
 tests/libxlxml2domconfigdata/fullvirt-cpuid.json | 3 +++
 3 files changed, 7 insertions(+)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 458dfc2399..a0059fc2a7 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -2404,6 +2404,7 @@ libxlMakeVideo(virDomainDefPtr def, libxl_domain_config 
*d_config)
 b_info->video_memkb = def->videos[0]->vram;
 } else {
 libxl_defbool_set(_info->u.hvm.nographic, 1);
+b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_NONE;
 }
 
 return 0;
diff --git a/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json 
b/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
index e804389fea..f16b4a971a 100644
--- a/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
+++ b/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
@@ -20,6 +20,9 @@
 "acpi": "True",
 "acpi_firmware": "/path/to/slic.dat",
 "nographic": "True",
+"vga": {
+"kind": "none"
+},
 "vnc": {
 "enable": "False"
 },
diff --git a/tests/libxlxml2domconfigdata/fullvirt-cpuid.json 
b/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
index d46b464642..ddc423bca7 100644
--- a/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
+++ b/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
@@ -27,6 +27,9 @@
 "apic": "True",
 "acpi": "True",
 "nographic": "True",
+"vga": {
+"kind": "none"
+},
 "vnc": {
 "enable": "False"
 },
-- 
2.26.2




[libvirt PATCH] libxl: vga.kind none when no device specified

2020-04-30 Thread Artur Puzio
When no video device is specified in config we should set both
hvm.nographic to 1 and hvm.vga.kind to NONE.

Without hvm.vga.kind=LIBXL_VGA_INTERFACE_TYPE_NONE both -nographic and
-device 'cirrus-vga' are on qemu cmdline.
---
 src/libxl/libxl_conf.c   | 1 +
 tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json | 3 +++
 tests/libxlxml2domconfigdata/fullvirt-cpuid.json | 3 +++
 3 files changed, 7 insertions(+)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 458dfc2399..a0059fc2a7 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -2404,6 +2404,7 @@ libxlMakeVideo(virDomainDefPtr def, libxl_domain_config 
*d_config)
 b_info->video_memkb = def->videos[0]->vram;
 } else {
 libxl_defbool_set(_info->u.hvm.nographic, 1);
+b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_NONE;
 }
 
 return 0;
diff --git a/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json 
b/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
index e804389fea..f16b4a971a 100644
--- a/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
+++ b/tests/libxlxml2domconfigdata/fullvirt-acpi-slic.json
@@ -20,6 +20,9 @@
 "acpi": "True",
 "acpi_firmware": "/path/to/slic.dat",
 "nographic": "True",
+"vga": {
+"kind": "none"
+},
 "vnc": {
 "enable": "False"
 },
diff --git a/tests/libxlxml2domconfigdata/fullvirt-cpuid.json 
b/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
index d46b464642..ddc423bca7 100644
--- a/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
+++ b/tests/libxlxml2domconfigdata/fullvirt-cpuid.json
@@ -27,6 +27,9 @@
 "apic": "True",
 "acpi": "True",
 "nographic": "True",
+"vga": {
+"kind": "none"
+},
 "vnc": {
 "enable": "False"
 },
-- 
2.26.2




[libvirt PATCH] xenconfig: Add feature gfx_passthru

2020-04-30 Thread Artur Puzio
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.

Signed-off-by: Artur Puzio 
---
 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 @@
   on, off; mode - optional string sync_pt or share_pt
   6.3.0
 
+
+  gfx_passthru
+  Enable Intel GPU specific quirks. Required and allowed only when 
passing an IGD.
+  on, off
+  6.3.0
+
   
   
   pmu
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 @@
 
   
 
+
+  
+
+  
+
   
 
   
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(, "/>\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(_info->u.hvm.gfx_passthru, true);
+break;
+case VIR_TRISTATE_SWITCH_OFF:
+libxl_defbool_set(_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);
-- 
2.26.2