xl and GFX passthrough
Hello, everybody!
I knew recently that xl doesn't yet work with GFX passthrough for HVM guest. It makes me consider that main job for GFX passthrough are going for xm toolstack. My company is very interested to use xl tool, but we need also GFX passthrough.
The issue is not very hard to solve. It just needs to teach xl to recognize 'gfx_passthru' in config file and pass it to qemu-dm. And qemu-dm will choose the specific VGA bios to load into domain's memory in case of this option.
I attached the patch, addressing this issue.
Please, consider to push it to main repository.
Thank you.
Sergey.
commit 2692d4133b93260aabb7bad438a0c288238d1295
Author: Sergey Tovpeko <[email protected]> Date: Fri Jul 9 20:33:39 2010 +0400
Pass gfx_passthru option to the device_model.
To enable gfx passthru, xl should parse 'gfx_passthru' parameter from config file, and pass it to qemu-dm.
tools/libxl/libxl.c +5 -0
@@ -1208,6 +1208,11 @@ static char ** libxl_build_device_model_args_old(libxl__gc *gc,flexarray_set (dm_args, num++,"-vcpu_avail" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"0x%x" , info->vcpu_avail)); } +if (info->gfx_passthru) { +flexarray_set (dm_args, num++,"-gfx_passthru" ); +flexarray_set (dm_args, num++,libxl__sprintf (gc,"%d" , info->gfx_passthru)); + } +for (i =0 ; i < num_vifs; i++) {if (vifs[i].nictype ==NICTYPE_IOEMU ) { char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x",
tools/libxl/libxl.idl +2 -0
@@ -96,6 +96,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("disable_migrate", bool), ("kernel", libxl_file_reference), ("cpuid", libxl_cpuid_policy_list), + ("gfx_passthru", integer), ("hvm", integer), ("u", KeyedUnion(None, "hvm", [("hvm", "%s", Struct(None,
@@ -161,6 +162,7 @@ libxl_device_model_info = Struct("device_model_info",[ ("vcpu_avail", integer, False, "vcpus actually available"), ("xen_platform_pci", integer, False, "enable/disable the xen platform pci device"), ("extra", libxl_string_list, False, "extra parameters pass directly to qemu, NULL terminated"), + ("gfx_passthru", integer), ], comment= """Device Model information.
tools/libxl/xl_cmdimpl.c +4 -0
@@ -363,6 +363,7 @@ static void init_dm_info(libxl_device_model_info *dm_info, dm_info->apic = b_info->u.hvm.apic; dm_info->vcpus = b_info->max_vcpus; dm_info->vcpu_avail = b_info->cur_vcpus; + dm_info->gfx_passthru = b_info->gfx_passthru; dm_info->stdvga =0 ; dm_info->vnc =1 ;
@@ -900,6 +901,9 @@ static void parse_config_data(const char *configfile_filename_report,xlu_cfg_replace_string (config,"kernel" , &b_info->kernel.path); +if (!xlu_cfg_get_long (config,"gfx_passthru" , &l)) + b_info->gfx_passthru = l; +if (c_info->hvm ==1 ) {if (!xlu_cfg_get_long (config,"pae" , &l)) b_info->u.hvm.pae = l;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 22 lines · Sergey Tovpeko
tools/libxl/libxl.idl +0
-0@@ -96,6 +96,7 @@ libxl_domain_build_info =Struct("domain_build_info",[
("disable_migrate", bool), ("kernel", libxl_file_reference), ("cpuid", libxl_cpuid_policy_list),tools/libxl/libxl.idl +1
-0+ ("gfx_passthru", integer), ("hvm", integer), ("u", KeyedUnion(None, "hvm", [("hvm", "%s", Struct(None,@@ -161,6 +162,7 @@ libxl_device_model_info =Struct("device_model_info",[
("vcpu_avail", integer, False, "vcpus actually
available"),
("xen_platform_pci", integer, False, "enable/disable
the xen platform pci device"),
("extra",libxl_string_list, False, "extra parameters
pass directly to qemu, NULL terminated"),
+ ("gfx_passthru", integer),
Quoted 3 lines
], comment="""Device Model information.
I think gfx_passthrough is actually a boolean, right? In that case it should be declared as "bool" in the idl.
Ian.
Quoted 5 lines · Ian Campbell
I think
gfx_passthroughis actually a boolean, right? In that case it should be declared as "bool" in the idl.
Well, the integer value of gfx_passthru had meaning in 2009, I suspect. It differentiated between IGD adapter and discrete adapter.
http://xen.1045712.n5.nabble.com/PATCH-0-2-v2-graphics-passthrough-with-VT-d-td2534811.html
At now, I didn't notice integer meaning of this variable in the code. I changed it to bool in the new patch.
Sergey.
commit 258e2a6cbccea92bd4d11cbe15963f139e8810cc
Author: Sergey Tovpeko <[email protected]> Date: Fri Jul 9 20:33:39 2010 +0400
Pass gfx_passthru option to the device_model.
To enable gfx passthru, xl should parse 'gfx_passthru' parameter from config file, and pass it to qemu-dm.
tools/libxl/libxl.c +5 -0
@@ -1208,6 +1208,11 @@ static char ** libxl_build_device_model_args_old(libxl__gc *gc,flexarray_set (dm_args, num++,"-vcpu_avail" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"0x%x" , info->vcpu_avail)); } +if (info->gfx_passthru) { +flexarray_set (dm_args, num++,"-gfx_passthru" ); +flexarray_set (dm_args, num++,libxl__sprintf (gc,"%d" , info->gfx_passthru)); + } +for (i =0 ; i < num_vifs; i++) {if (vifs[i].nictype ==NICTYPE_IOEMU ) { char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x",
tools/libxl/libxl.idl +2 -0
@@ -96,6 +96,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("disable_migrate", bool), ("kernel", libxl_file_reference), ("cpuid", libxl_cpuid_policy_list), + ("gfx_passthru", bool), ("hvm", integer), ("u", KeyedUnion(None, "hvm", [("hvm", "%s", Struct(None,
@@ -161,6 +162,7 @@ libxl_device_model_info = Struct("device_model_info",[ ("vcpu_avail", integer, False, "vcpus actually available"), ("xen_platform_pci", integer, False, "enable/disable the xen platform pci device"), ("extra", libxl_string_list, False, "extra parameters pass directly to qemu, NULL terminated"), + ("gfx_passthru", bool, False, "GFX passthrough enabled or disabled"), ], comment= """Device Model information.
tools/libxl/xl_cmdimpl.c +4 -0
@@ -363,6 +363,7 @@ static void init_dm_info(libxl_device_model_info *dm_info, dm_info->apic = b_info->u.hvm.apic; dm_info->vcpus = b_info->max_vcpus; dm_info->vcpu_avail = b_info->cur_vcpus; + dm_info->gfx_passthru = b_info->gfx_passthru; dm_info->stdvga =0 ; dm_info->vnc =1 ;
@@ -900,6 +901,9 @@ static void parse_config_data(const char *configfile_filename_report,xlu_cfg_replace_string (config,"kernel" , &b_info->kernel.path); +if (!xlu_cfg_get_long (config,"gfx_passthru" , &l)) + b_info->gfx_passthru = l; +if (c_info->hvm ==1 ) {if (!xlu_cfg_get_long (config,"pae" , &l)) b_info->u.hvm.pae = l;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · Sergey Tovpeko
Quoted 5 lines · Ian Campbell
I think
gfx_passthroughis actually a boolean, right? In that case it should be declared as "bool" in the idl.
Quoted 6 lines
Well, the integer value of
gfx_passthruhad meaning in 2009, I suspect. It differentiated between IGD adapter and discrete adapter.
http://xen.1045712.n5.nabble.com/PATCH-0-2-v2-graphics-passthrough-with-VT-d-td2534811.htmlAt now, I didn't notice integer meaning of this variable in the code. I changed it to bool in the new patch.
I just noticed that this appears to have been fixed by Daniel De Graf just a few days ago, see 22711:4f6fee3a456e, which may only be in the staging tree at http://xenbits.xen.org/staging/xen-unstable.hg since we are waiting for a test pass.
Ian.
Quoted 8 lines
I just noticed that this appears to have been fixed by Daniel De Graf just a few days ago, see 22711:4f6fee3a456e, which may only be in the staging tree at http://xenbits.xen.org/staging/xen-unstable.hg since we are waiting for a test pass.
Ian, Daniel
my patch is almost like Daniel's one. Thank you for pointing to it.
And there's one absent thing in Daniel's commit (4f6fee3a456e). To complete the gfx passthrough issue for xl we should pass this option to qemu-dm, like this :
+ if (info->gfx_passthru) {
+ flexarray_set(dm_args, num++, "-gfx_passthru");
+ flexarray_set(dm_args, num++, libxl__sprintf(gc, "%d", info->gfx_passthru));
+ }
I suppose, without it 'qemu-dm' won't know about gfx_passthru mode and won't load passthru'ed vga bios.
Daniel might plan to add this code or added it already?
Quoted 22 lines · Sergey Tovpeko
Quoted 7 lines
I just noticed that this appears to have been fixed by Daniel De Graf just a few days ago, see 22711:4f6fee3a456e, which may only be in the staging tree at http://xenbits.xen.org/staging/xen-unstable.hg since we are waiting for a test pass.
Ian, Daniel
my patch is almost like Daniel's one. Thank you for pointing to it.
And there's one absent thing in Daniel's commit (
4f6fee3a456e). To complete the gfx passthrough issue for xl we should pass this option to qemu-dm, like this :tools/libxl/libxl.c +3
-0+if (info->gfx_passthru) { +flexarray_set (dm_args, num++,"-gfx_passthru" ); + flexarray_set(dm_args, num++, libxl__sprintf(gc, "%d",
info->gfx_passthru));
+ }
Quoted 4 lines
I suppose, without it 'qemu-dm' won't know about
gfx_passthrumode and won't load passthru'ed vga bios.Daniel might plan to add this code or added it already?
Daniel's patch at <[email protected]> includes this bit but it appears to be missing from the commit in 22711:4f6fee3a456e.
IanJ: Any idea what's going on? Perhaps a missed .rej due to the move of the dm stuff to libxl_dm.c between post and application?
Ian.
Ian Campbell writes ("Re: [Xen-devel] xl and GFX passthrough"):
Quoted 5 lines
Daniel's patch at <[email protected]> includes this bit but it appears to be missing from the commit in 22711:4f6fee3a456e.
IanJ: Any idea what's going on? Perhaps a missed .rej due to the move of the dm stuff to
libxl_dm.cbetween post and application?
Very likely, sorry.
I will fix this up after rc1.
Ian.
Quoted 10 lines · I wrote:
Ian Campbell writes ("Re: [Xen-devel] xl and GFX passthrough"):
Quoted 5 lines
Daniel's patch at <[email protected]> includes this bit but it appears to be missing from the commit in 22711:4f6fee3a456e.
IanJ: Any idea what's going on? Perhaps a missed .rej due to the move of the dm stuff to
libxl_dm.cbetween post and application?Very likely, sorry.
I will fix this up after rc1.
I've applied the missing change.
Thanks,
Ian.
Sergey,
Did you get gfx_passthru to work with xl? I found the latest source still does not seems to pass gfx_passthru to qemu correctly.
By the way, how to output debug messages to xl*.log file? I tried LOG() and fprintf(stderr...) neither worked for me.
Allen
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Sergey Tovpeko
Sent: Thursday, January 13, 2011 3:18 AM
To: Ian Campbell; Daniel De Graaf
Cc: [email protected]
Subject: Re: [Xen-devel] xl and GFX passthrough
Quoted 7 lines
I just noticed that this appears to have been fixed by Daniel De Graf just a few days ago, see 22711:4f6fee3a456e, which may only be in the staging tree at http://xenbits.xen.org/staging/xen-unstable.hg since we are waiting for a test pass.
Ian, Daniel
my patch is almost like Daniel's one. Thank you for pointing to it.
And there's one absent thing in Daniel's commit (4f6fee3a456e). To complete the gfx passthrough issue for xl we should pass this option to qemu-dm, like this :
+ if (info->gfx_passthru) {
+ flexarray_set(dm_args, num++, "-gfx_passthru");
+ flexarray_set(dm_args, num++, libxl__sprintf(gc, "%d",info->gfx_passthru));
+ }
I suppose, without it 'qemu-dm' won't know about gfx_passthru mode and won't load passthru'ed vga bios.
Daniel might plan to add this code or added it already?
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Allen M
By the way, how to output debug messages to xl*.log file? I tried
LOG()and fprintf(stderr...) neither worked for me.
LOG should print to the logfile, while fprintf(stderr should just print to stderr.
Considering that when you execute xl the command is just executed directly by your instance of xl, you can probably debug your issues just using printf or gdb.
Quoted 38 lines · Allen M
Sergey,
Did you get
gfx_passthruto work with xl? I found the latest source still does not seems to passgfx_passthruto qemu correctly.By the way, how to output debug messages to xl*.log file? I tried
LOG()and fprintf(stderr...) neither worked for me.Allen
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Sergey Tovpeko
Sent: Thursday, January 13, 2011 3:18 AM
To: Ian Campbell; Daniel De Graaf
Cc: [email protected]
Subject: Re: [Xen-devel] xl and GFX passthroughQuoted 7 lines
I just noticed that this appears to have been fixed by Daniel De Graf just a few days ago, see 22711:4f6fee3a456e, which may only be in the staging tree at http://xenbits.xen.org/staging/xen-unstable.hg since we are waiting for a test pass.
Ian, Daniel
my patch is almost like Daniel's one. Thank you for pointing to it.
And there's one absent thing in Daniel's commit (
4f6fee3a456e). To complete the gfx passthrough issue for xl we should pass this option to qemu-dm, like this :tools/libxl/libxl.c +3
-0+if (info->gfx_passthru) { +flexarray_set (dm_args, num++,"-gfx_passthru" ); + flexarray_set(dm_args, num++, libxl__sprintf(gc, "%d",
info->gfx_passthru));
+ }
Quoted 5 lines
I suppose, without it 'qemu-dm' won't know about
gfx_passthrumode and won't load passthru'ed vga bios.Daniel might plan to add this code or added it already?
Actually, I hadn't noticed that gfx_passthru takes an (apparently optional) numeric parameter. This change is more correct than the one I posted, although it also needs gfx_passthru to be changed from bool to int in the IDL (assuming that -gfx_passthru 2 is still useful, I hadn't heard of it until recently).
Kay: sounds like you have this fixed in your tree, I'll let you or Ian fix it.
Signature · 2 lines
Daniel De Graaf National Security Agency