Hi, I want to switch video card live between two HVMs. My simplest idea is that when the HVM has the permission to access passthrough video card, and another HVM will be paused. If switch from A to B, execute commands : xm pause A ; xm pci-detach A 00:00:02.0 ; xm pci-attach B 00:00:02.0 ; xm unpause B. I have a try, but failed. The pseudo-code is as below. Can you give me some ideas? Any suggestions will be thankful. Execute “xm pci-detach Domain 00:00:02.0”: 1. Raise sci interrupt to unplug the device. If OSPM doesn’t handle the unplug process, and then invoke acpi_php_writeb to power off the device. 2. Modify power_off_php_devfn function: int power_off_php_devfn(int php_devfn) { If(php_devfn == 0x10) // Intel integrated graphics { p = & dpci_infos.php_devs[php_devfn]; // save the two-tuples : (php_dev, domid) save_php_device_by_domid(p,domid); // hide the device from bus and dpci_infos pci_hide_device(& p->pt_dev->dev); memset(p,0x00,sizeof(struct php_dev)); return 0; } return unregister_real_device(php_devfn); } Execute “xm pci-attach Domain 00:00:02.0”: 1. Modify power_on_php_devfn function: int power_off_php_devfn(int devfn) { …. while(devfn == 0x10) // Intel integrated graphics { if( ! get_php_device_by_domid(p,domid) ) // get saved php_dev struct break; // cannot get , create new one //restore the php device to bus and dpci_infos restore_php_device(p,devfn); // restore dpci_infos.php_devs[devfn] dpci_infos->e_bus->devices[devfn] = p-> pt_dev->dev; return 0; } if (!dpci_infos.pci_access) {…} pt_dev = register_real_device(..); return 0; } This plan hides the VGA device from HVM and never destroys it. Both mmio and pio maps are reserved. When finishing “xm unpause B”, it seems working well observed by Dom0 serial port login. But the screen is black and cannot receive any signal. I am confusing. Video BIOS should be reloaded? Or need raise some interrupt to flush screen? Thanks & Regards, Yujiageng _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
I would be interested in learning if this is a successful strategy as well. If you could please share with the list any methods on how you may get this to work, that would be great. I am assuming that your dom0 would be headless and not use the graphics card, right? Roger ________________________________ From: xen-devel-bounces@lists.xensource.com on behalf of ??? Sent: Fri 6/4/2010 5:29 AM To: yuri.schaeffer@os3.nl; allen.m.kay@intel.com Cc: xen-devel@lists.xensource.com Subject: [Xen-devel] How to switch VGA passthrough live Hi, I want to switch video card live between two HVMs. My simplest idea is that when the HVM has the permission to access passthrough video card, and another HVM will be paused. If switch from A to B, execute commands : xm pause A ; xm pci-detach A 00:00:02.0 ; xm pci-attach B 00:00:02.0 ; xm unpause B. I have a try, but failed. The pseudo-code is as below. Can you give me some ideas? Any suggestions will be thankful. Execute "xm pci-detach Domain 00:00:02.0": 1. Raise sci interrupt to unplug the device. If OSPM doesn''t handle the unplug process, and then invoke acpi_php_writeb to power off the device. 2. Modify power_off_php_devfn function: int power_off_php_devfn(int php_devfn) { If(php_devfn == 0x10) // Intel integrated graphics { p = & dpci_infos.php_devs[php_devfn]; // save the two-tuples : (php_dev, domid) save_php_device_by_domid(p,domid); // hide the device from bus and dpci_infos pci_hide_device(& p->pt_dev->dev); memset(p,0x00,sizeof(struct php_dev)); return 0; } return unregister_real_device(php_devfn); } Execute "xm pci-attach Domain 00:00:02.0": 1. Modify power_on_php_devfn function: int power_off_php_devfn(int devfn) { .... while(devfn == 0x10) // Intel integrated graphics { if( ! get_php_device_by_domid(p,domid) ) // get saved php_dev struct break; // cannot get , create new one //restore the php device to bus and dpci_infos restore_php_device(p,devfn); // restore dpci_infos.php_devs[devfn] dpci_infos->e_bus->devices[devfn] = p-> pt_dev->dev; return 0; } if (!dpci_infos.pci_access) {...} pt_dev = register_real_device(..); return 0; } This plan hides the VGA device from HVM and never destroys it. Both mmio and pio maps are reserved. When finishing "xm unpause B", it seems working well observed by Dom0 serial port login. But the screen is black and cannot receive any signal. I am confusing. Video BIOS should be reloaded? Or need raise some interrupt to flush screen? Thanks & Regards, Yujiageng _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Stefano Stabellini
2010-Jun-04 15:32 UTC
Re: [Xen-devel] How to switch VGA passthrough live
On Fri, 4 Jun 2010, 于佳耕 wrote:> > Hi, > > I want to switch video card live between two HVMs. My simplest idea is that when the HVM has the permission to access > passthrough video card, and another HVM will be paused. If switch from A to B, execute commands : > > xm pause A ; > > xm pci-detach A 00:00:02.0 ; > > xm pci-attach B 00:00:02.0 ; > > xm unpause B. > > > > I have a try, but failed. The pseudo-code is as below. Can you give me some ideas? Any suggestions will be thankful. >pci-detach needs cooperation from the guest, how the guest is supposed to handle the acpi interrupt if it is paused? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hmm, you are right. I have found that WinXP and Win7 could not handle the VGA remove sci interrupt. Please try to execute "xm pci-detach Domain 00:00:02.0". So I directly invoke acpi_php_writeb to handle VGA remove event. 2010/6/4 Stefano Stabellini <stefano.stabellini@eu.citrix.com>> On Fri, 4 Jun 2010, 于佳耕 wrote: > > > > Hi, > > > > I want to switch video card live between two HVMs. My simplest idea is > that when the HVM has the permission to access > > passthrough video card, and another HVM will be paused. If switch from A > to B, execute commands : > > > > xm pause A ; > > > > xm pci-detach A 00:00:02.0 ; > > > > xm pci-attach B 00:00:02.0 ; > > > > xm unpause B. > > > > > > > > I have a try, but failed. The pseudo-code is as below. Can you give me > some ideas? Any suggestions will be thankful. > > > > pci-detach needs cooperation from the guest, how the guest is supposed > to handle the acpi interrupt if it is paused? >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
At very beginning, I want to take destroy-and-recreate method to implement VGA live switch. After reading code and doing some experiments, I find both of two ways can hide the VGA device. And then we can assign VGA device to another HVM during its creating process. 1. Invoke pci_hide_device function, which set pci_dev->bus->devices[0x10] to NULL 2. dpci_infos.php_devs[0x10].valid =1 And the qemu-hw gets the knowledge of passthrough pci devices from the PCIBus and dpci_infos structures. These two structures reserve the context of each pt pci devce, such as its irqs、write function、read function、mmio maps、pio maps… So I have a simple idea that we can assign which domain to use VGA screen by saving/restoring VGA device infos of these two structures. My experiment result as below: [root@localhost ~]# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 1786 4 r----- 67.2 PHY_HVMDomain 1 2048 4 -b---- 219.1 [root@localhost ~]# xm pci-list 1 VSlt VFn domain bus slot func 0x02 0x0 0x0000 0x00 0x02 0x0 0x05 0x0 0x0000 0x00 0x1a 0x0 0x06 0x0 0x0000 0x00 0x1a 0x1 0x07 0x0 0x0000 0x00 0x1a 0x2 0x08 0x0 0x0000 0x00 0x1a 0x7 [root@localhost ~]# xm pause 1 [root@localhost ~]# xm pci-detach 1 00:00:02.0 [root@localhost ~]# xm pci-list 1 VSlt VFn domain bus slot func 0x05 0x0 0x0000 0x00 0x1a 0x0 0x06 0x0 0x0000 0x00 0x1a 0x1 0x07 0x0 0x0000 0x00 0x1a 0x2 0x08 0x0 0x0000 0x00 0x1a 0x7 [root@localhost ~]# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 1786 4 r----- 68.9 PHY_HVMDomain 1 2048 4 --p--- 223.3 [root@localhost ~]# xm pci-attach 1 00:00:02.0 [root@localhost ~]# xm unpause 1 [root@localhost ~]# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 1786 4 r----- 69.6 PHY_HVMDomain 1 2048 4 -b---- 224.3 [root@localhost ~]# xm pci-list 1 VSlt VFn domain bus slot func 0x02 0x0 0x0000 0x00 0x02 0x0 0x05 0x0 0x0000 0x00 0x1a 0x0 0x06 0x0 0x0000 0x00 0x1a 0x1 0x07 0x0 0x0000 0x00 0x1a 0x2 0x08 0x0 0x0000 0x00 0x1a 0x7 [root@localhost ~]# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 1786 4 r----- 70.3 PHY_HVMDomain 1 2048 4 -b---- 225.6 [root@localhost ~]# When unpausing PHY_HVMDomain, it seems working well. But the screen is black and cannot receive any signals. I am sure that this strategy missed something important, especially on video BIOS. Could you give me some ideas? 2010/6/4 Roger Cruz <roger.cruz@virtualcomputer.com>> I would be interested in learning if this is a successful strategy as > well. If you could please share with the list any methods on how you may > get this to work, that would be great. I am assuming that your dom0 would > be headless and not use the graphics card, right? > > Roger > > ------------------------------ > *From:* xen-devel-bounces@lists.xensource.com on behalf of 于佳耕 > *Sent:* Fri 6/4/2010 5:29 AM > *To:* yuri.schaeffer@os3.nl; allen.m.kay@intel.com > *Cc:* xen-devel@lists.xensource.com > *Subject:* [Xen-devel] How to switch VGA passthrough live > > Hi, > > > > I want to switch video card live between two HVMs. My simplest idea is that > when the HVM has the permission to access passthrough video card, and > another HVM will be paused. If switch from A to B, execute commands : > > > > xm pause A ; > > xm pci-detach A 00:00:02.0 ; > > xm pci-attach B 00:00:02.0 ; > > xm unpause B. > > > > I have a try, but failed. The pseudo-code is as below. Can you give me some > ideas? Any suggestions will be thankful. > > > > Execute “xm pci-detach Domain 00:00:02.0”: > > 1. Raise sci interrupt to unplug the device. If OSPM doesn’t handle > the unplug process, and then invoke acpi_php_writeb to power off the device. > > 2. Modify power_off_php_devfn function: > > int power_off_php_devfn(int php_devfn) > > { > > If(php_devfn == 0x10) // Intel integrated graphics > > { > > p = & dpci_infos.php_devs[php_devfn]; > > > > // save the two-tuples : (php_dev, domid) > > save_php_device_by_domid(p,domid); > > > > // hide the device from bus and dpci_infos > > pci_hide_device(& p->pt_dev->dev); > > memset(p,0x00,sizeof(struct php_dev)); > > > > return 0; > > } > > return unregister_real_device(php_devfn); > > } > > > > Execute “xm pci-attach Domain 00:00:02.0”: > > 1. Modify power_on_php_devfn function: > > int power_off_php_devfn(int devfn) > > { > > …. > > while(devfn == 0x10) // Intel integrated graphics > > { > > if( ! get_php_device_by_domid(p,domid) ) // get saved > php_dev struct > > break; // > cannot get , create new one > > > > //restore the php device to bus and dpci_infos > > restore_php_device(p,devfn); // restore > dpci_infos.php_devs[devfn] > > dpci_infos->e_bus->devices[devfn] = p-> pt_dev->dev; > > > > return 0; > > } > > > > if (!dpci_infos.pci_access) > > {…} > > pt_dev = register_real_device(..); > > return 0; > > } > > > > This plan hides the VGA device from HVM and never destroys it. Both mmio > and pio maps are reserved. When finishing “xm unpause B”, it seems working > well observed by Dom0 serial port login. But the screen is black and cannot > receive any signal. I am confusing. Video BIOS should be reloaded? Or need > raise some interrupt to flush screen? > > > > > > Thanks & Regards, > Yujiageng >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hi, I tried that in the past and is was working fine but you have to put the guest into S3 (acpi suspend to RAM) first, then we don''t have to wait for any ACPI hotplug ack (you could remove some code in qemu for that). Jean On Fri, Jun 04, 2010 at 10:29:43AM +0100, 于佳耕 wrote:> Hi, > > I want to switch video card live between two HVMs. My simplest idea is that when the HVM has the permission to access passthrough video card, and another HVM will be paused. If switch from A to B, execute commands : > > xm pause A ; > xm pci-detach A 00:00:02.0 ; > xm pci-attach B 00:00:02.0 ; > xm unpause B. > > I have a try, but failed. The pseudo-code is as below. Can you give me some ideas? Any suggestions will be thankful. > > Execute “xm pci-detach Domain 00:00:02.0”: > > 1. Raise sci interrupt to unplug the device. If OSPM doesn’t handle the unplug process, and then invoke acpi_php_writeb to power off the device. > > 2. Modify power_off_php_devfn function: > int power_off_php_devfn(int php_devfn) > { > If(php_devfn == 0x10) // Intel integrated graphics > { > p = & dpci_infos.php_devs[php_devfn]; > > // save the two-tuples : (php_dev, domid) > save_php_device_by_domid(p,domid); > > // hide the device from bus and dpci_infos > pci_hide_device(& p->pt_dev->dev); > memset(p,0x00,sizeof(struct php_dev)); > > return 0; > } > > return unregister_real_device(php_devfn); > > } > > Execute “xm pci-attach Domain 00:00:02.0”: > > 1. Modify power_on_php_devfn function: > > int power_off_php_devfn(int devfn) > > { > > …. > > while(devfn == 0x10) // Intel integrated graphics > > { > > if( ! get_php_device_by_domid(p,domid) ) // get saved php_dev struct > > break; // cannot get , create new one > > > > //restore the php device to bus and dpci_infos > > restore_php_device(p,devfn); // restore dpci_infos.php_devs[devfn] > > dpci_infos->e_bus->devices[devfn] = p-> pt_dev->dev; > > > > return 0; > > } > > > > if (!dpci_infos.pci_access) > > {…} > > pt_dev = register_real_device(..); > > return 0; > > } > > This plan hides the VGA device from HVM and never destroys it. Both mmio and pio maps are reserved. When finishing “xm unpause B”, it seems working well observed by Dom0 serial port login. But the screen is black and cannot receive any signal. I am confusing. Video BIOS should be reloaded? Or need raise some interrupt to flush screen? > > > Thanks & Regards, > Yujiageng> _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Windows is really bad at doing vga hotplug, your guest will crash/freez/BSOD. Windows 7 might do something a bit more sensible but I''m note sure. Jean On Fri, Jun 04, 2010 at 05:19:09PM +0100, 于佳耕 wrote:> Hmm, you are right. I have found that WinXP and Win7 could not handle the VGA remove sci interrupt. Please try to execute "xm pci-detach Domain 00:00:02.0". So I directly invoke acpi_php_writeb to handle VGA remove event. > > 2010/6/4 Stefano Stabellini <stefano.stabellini@eu.citrix.com<mailto:stefano.stabellini@eu.citrix.com>> > On Fri, 4 Jun 2010, 于佳耕 wrote: > > > > Hi, > > > > I want to switch video card live between two HVMs. My simplest idea is that when the HVM has the permission to access > > passthrough video card, and another HVM will be paused. If switch from A to B, execute commands : > > > > xm pause A ; > > > > xm pci-detach A 00:00:02.0 ; > > > > xm pci-attach B 00:00:02.0 ; > > > > xm unpause B. > > > > > > > > I have a try, but failed. The pseudo-code is as below. Can you give me some ideas? Any suggestions will be thankful. > > > > pci-detach needs cooperation from the guest, how the guest is supposed > to handle the acpi interrupt if it is paused? >> _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Here is a patch for xen-4 (ioemu). Jean P.S.: Please don''t forget to CC the mailing list when you reply. Your messages could be useful for other people. Thanks. --- diff --git a/xen-vl-extra.c b/xen-vl-extra.c index 206ac65..bafc5a4 100644 --- a/xen-vl-extra.c +++ b/xen-vl-extra.c @@ -111,13 +111,18 @@ void do_pci_del(char *devname) devfn = bdf_to_devfn(devname); - if (devfn < 0) + if (devfn < 0 && devfn == 0x10) fprintf(logfile, "Device \"%s\" is not used by a hotplug device.\n", devname_cpy); else acpi_php_del(devfn); free(devname_cpy); + if (devfn == 0x10) + { + power_off_php_devfn(devfn); + xenstore_record_dm_state("pci-removed"); + } } void do_pci_add(char *devname) On Mon, Jun 07, 2010 at 02:54:00AM +0100, 于佳耕 wrote:> > It seems a complex work. Could you give the old patch, and I try to port it on Xen4.0. > > 2010/6/5 Jean Guyader <jean.guyader@eu.citrix.com<mailto:jean.guyader@eu.citrix.com>> > > Hi, > > I tried that in the past and is was working fine but you have to put the > guest into S3 (acpi suspend to RAM) first, then we don''t have to wait for > any ACPI hotplug ack (you could remove some code in qemu for that). > > Jean > > On Fri, Jun 04, 2010 at 10:29:43AM +0100, 于佳耕 wrote: > > Hi, > > > > I want to switch video card live between two HVMs. My simplest idea is that when the HVM has the permission to access passthrough video card, and another HVM will be paused. If switch from A to B, execute commands : > > > > xm pause A ; > > xm pci-detach A 00:00:02.0 ; > > xm pci-attach B 00:00:02.0 ; > > xm unpause B. > > > > I have a try, but failed. The pseudo-code is as below. Can you give me some ideas? Any suggestions will be thankful. > > > > Execute “xm pci-detach Domain 00:00:02.0”: > > > > 1. Raise sci interrupt to unplug the device. If OSPM doesn’t handle the unplug process, and then invoke acpi_php_writeb to power off the device. > > > > 2. Modify power_off_php_devfn function: > > int power_off_php_devfn(int php_devfn) > > { > > If(php_devfn == 0x10) // Intel integrated graphics > > { > > p = & dpci_infos.php_devs[php_devfn]; > > > > // save the two-tuples : (php_dev, domid) > > save_php_device_by_domid(p,domid); > > > > // hide the device from bus and dpci_infos > > pci_hide_device(& p->pt_dev->dev); > > memset(p,0x00,sizeof(struct php_dev)); > > > > return 0; > > } > > > > return unregister_real_device(php_devfn); > > > > } > > > > Execute “xm pci-attach Domain 00:00:02.0”: > > > > 1. Modify power_on_php_devfn function: > > > > int power_off_php_devfn(int devfn) > > > > { > > > > …. > > > > while(devfn == 0x10) // Intel integrated graphics > > > > { > > > > if( ! get_php_device_by_domid(p,domid) ) // get saved php_dev struct > > > > break; // cannot get , create new one > > > > > > > > //restore the php device to bus and dpci_infos > > > > restore_php_device(p,devfn); // restore dpci_infos.php_devs[devfn] > > > > dpci_infos->e_bus->devices[devfn] = p-> pt_dev->dev; > > > > > > > > return 0; > > > > } > > > > > > > > if (!dpci_infos.pci_access) > > > > {…} > > > > pt_dev = register_real_device(..); > > > > return 0; > > > > } > > > > This plan hides the VGA device from HVM and never destroys it. Both mmio and pio maps are reserved. When finishing “xm unpause B”, it seems working well observed by Dom0 serial port login. But the screen is black and cannot receive any signal. I am confusing. Video BIOS should be reloaded? Or need raise some interrupt to flush screen? > > > > > > Thanks & Regards, > > Yujiageng > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xensource.com<mailto:Xen-devel@lists.xensource.com> > > http://lists.xensource.com/xen-devel > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Thanks for your reminding. This method will pass sci interrupt and straightly invoke power_off_php_devfn function. It solves two problems: 1. Detach VGA passthrough device from HVM-1 2. Assign VGA passthrough device to a new HVM-2 during its creating process The limit of this method is that we cannot assign VGA dev back to HVM-1. I did some research and tried to find the reason. When unregistering a real device at power_off_php_devfn function, all the mmio/pio maps and irqs related to the dev are destroyed. The output of Xen is as below: Xm pci-detach 00:00:02.0 (XEN) domctl.c:1001:d0 memory_map:remove: gfn=f1000 mfn=fe800 nr_mfns=400 (XEN) domctl.c:1001:d0 memory_map:remove: gfn=e0000 mfn=d0000 nr_mfns=10000 (XEN) domctl.c:1071:d0 ioport_map:remove f_gport=c2d0 f_mport=ec90 np=8 (XEN) domctl.c:1071:d0 ioport_map:remove f_gport=3b0 f_mport=3b0 np=c (XEN) domctl.c:1071:d0 ioport_map:remove f_gport=3c0 f_mport=3c0 np=20 (XEN) domctl.c:1001:d0 memory_map:remove: gfn=a0 mfn=a0 nr_mfns=20 On the contrary, if we register a new VGA device using power_on_php_devfn function, the output of Xen is: Xm pci-attach 00:00:02.0 (XEN) domctl.c:1047:d0 ioport_map:add f_gport=3b0 f_mport=3b0 np=c (XEN) domctl.c:1047:d0 ioport_map:add f_gport=3c0 f_mport=3c0 np=20 (XEN) domctl.c:991:d0 memory_map:add: gfn=a0 mfn=a0 nr_mfns=20 In conclusion, part of VGA initial work has done during video BIOS staring. Only invoking power_on_php_devfn function cannot rebuild full context of VGA dev. I also trace power_off_php_devfn function, and find that the screen will be shutdown as long as invoking pci_hide_device. Could anybody know why? Maybe we can implement pci_unhide_device function to switch passthrough dev between HVM domains. Thanks & Regards Yujiageng 2010/6/7 Jean Guyader <jean.guyader@eu.citrix.com>> > Here is a patch for xen-4 (ioemu). > > Jean > > P.S.: Please don''t forget to CC the mailing list when you reply. > Your messages could be useful for other people. Thanks. > > --- > > diff --git a/xen-vl-extra.c b/xen-vl-extra.c > index 206ac65..bafc5a4 100644 > --- a/xen-vl-extra.c > +++ b/xen-vl-extra.c > @@ -111,13 +111,18 @@ void do_pci_del(char *devname) > > devfn = bdf_to_devfn(devname); > > - if (devfn < 0) > + if (devfn < 0 && devfn == 0x10) > fprintf(logfile, "Device \"%s\" is not used by a hotplug device.\n", > devname_cpy); > else > acpi_php_del(devfn); > > free(devname_cpy); > + if (devfn == 0x10) > + { > + power_off_php_devfn(devfn); > + xenstore_record_dm_state("pci-removed"); > + } > } > > void do_pci_add(char *devname) > > On Mon, Jun 07, 2010 at 02:54:00AM +0100, 于佳耕 wrote: > > > > It seems a complex work. Could you give the old patch, and I try to port it on Xen4.0. > > > > 2010/6/5 Jean Guyader <jean.guyader@eu.citrix.com<mailto:jean.guyader@eu.citrix.com>> > > > > Hi, > > > > I tried that in the past and is was working fine but you have to put the > > guest into S3 (acpi suspend to RAM) first, then we don''t have to wait for > > any ACPI hotplug ack (you could remove some code in qemu for that). > > > > Jean > > > > On Fri, Jun 04, 2010 at 10:29:43AM +0100, 于佳耕 wrote: > > > Hi, > > > > > > I want to switch video card live between two HVMs. My simplest idea is that when the HVM has the permission to access passthrough video card, and another HVM will be paused. If switch from A to B, execute commands : > > > > > > xm pause A ; > > > xm pci-detach A 00:00:02.0 ; > > > xm pci-attach B 00:00:02.0 ; > > > xm unpause B. > > > > > > I have a try, but failed. The pseudo-code is as below. Can you give me some ideas? Any suggestions will be thankful. > > > > > > Execute "xm pci-detach Domain 00:00:02.0": > > > > > > 1. Raise sci interrupt to unplug the device. If OSPM doesn''t handle the unplug process, and then invoke acpi_php_writeb to power off the device. > > > > > > 2. Modify power_off_php_devfn function: > > > int power_off_php_devfn(int php_devfn) > > > { > > > If(php_devfn == 0x10) // Intel integrated graphics > > > { > > > p = & dpci_infos.php_devs[php_devfn]; > > > > > > // save the two-tuples : (php_dev, domid) > > > save_php_device_by_domid(p,domid); > > > > > > // hide the device from bus and dpci_infos > > > pci_hide_device(& p->pt_dev->dev); > > > memset(p,0x00,sizeof(struct php_dev)); > > > > > > return 0; > > > } > > > > > > return unregister_real_device(php_devfn); > > > > > > } > > > > > > Execute "xm pci-attach Domain 00:00:02.0": > > > > > > 1. Modify power_on_php_devfn function: > > > > > > int power_off_php_devfn(int devfn) > > > > > > { > > > > > > .... > > > > > > while(devfn == 0x10) // Intel integrated graphics > > > > > > { > > > > > > if( ! get_php_device_by_domid(p,domid) ) // get saved php_dev struct > > > > > > break; // cannot get , create new one > > > > > > > > > > > > //restore the php device to bus and dpci_infos > > > > > > restore_php_device(p,devfn); // restore dpci_infos.php_devs[devfn] > > > > > > dpci_infos->e_bus->devices[devfn] = p-> pt_dev->dev; > > > > > > > > > > > > return 0; > > > > > > } > > > > > > > > > > > > if (!dpci_infos.pci_access) > > > > > > {...} > > > > > > pt_dev = register_real_device(..); > > > > > > return 0; > > > > > > } > > > > > > This plan hides the VGA device from HVM and never destroys it. Both mmio and pio maps are reserved. When finishing "xm unpause B", it seems working well observed by Dom0 serial port login. But the screen is black and cannot receive any signal. I am confusing. Video BIOS should be reloaded? Or need raise some interrupt to flush screen? > > > > > > > > > Thanks & Regards, > > > Yujiageng > > > > > _______________________________________________ > > > Xen-devel mailing list > > > Xen-devel@lists.xensource.com<mailto:Xen-devel@lists.xensource.com> > > > http://lists.xensource.com/xen-devel > > > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel