xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jean Guyader <jean.guyader@eu.citrix.com>
To: 于佳耕 <yujiageng734@gmail.com>
Cc: xen-devel@lists.xensource.com, Jean Guyader <Jean.Guyader@citrix.com>
Subject: Re: How to switch VGA passthrough live
Date: Mon, 7 Jun 2010 10:13:13 +0100	[thread overview]
Message-ID: <20100607091313.GA31058@angi.xci-test.com> (raw)
In-Reply-To: <AANLkTikw8sf6h3P21xD7Lj2Fc6AdzcOiPFZVm9gXdfhT@mail.gmail.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
> 
> 

  parent reply	other threads:[~2010-06-07  9:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04  9:29 How to switch VGA passthrough live 于佳耕
2010-06-04 14:57 ` Roger Cruz
2010-06-05  4:44   ` 于佳耕
2010-06-04 15:32 ` Stefano Stabellini
2010-06-04 16:19   ` 于佳耕
2010-06-05  8:44     ` Jean Guyader
2010-06-05  8:43 ` Jean Guyader
     [not found]   ` <AANLkTikw8sf6h3P21xD7Lj2Fc6AdzcOiPFZVm9gXdfhT@mail.gmail.com>
2010-06-07  9:13     ` Jean Guyader [this message]
2010-06-08  3:18       ` 于佳耕

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100607091313.GA31058@angi.xci-test.com \
    --to=jean.guyader@eu.citrix.com \
    --cc=Jean.Guyader@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=yujiageng734@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).