From: Phung Te Ha Subject: pci device hotplug, race accessing xenstore Date: Tue, 13 Oct 2009 12:13:00 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1620214983==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: horms@verge.net.au List-Id: xen-devel@lists.xenproject.org --===============1620214983== Content-Type: multipart/alternative; boundary=000e0cd3580ab69a570475d5d5e2 --000e0cd3580ab69a570475d5d5e2 Content-Type: text/plain; charset=ISO-8859-1 Hello Simon, I took the source as per you message: http://marc.info/?l=xen-devel&m=124748015304566&w=4 compiled and run it on an Intel-DQ35JO, Fedora-10. When I try to pass pci device through at boot time in configuration file, there's a race between xend and qemu accessing xenstore. Xend waits in signalDeviceModel(...) for qemu to declare 'running' then write to the dm-command pipe the devices to be passed-through. On the qemu side, it poses a watch on /local/domain/0/device-model/2/command and expects the dm-command from there, by calling xs_watch(...). xs_watch(...) causes xenstored to run do_watch(...) and at the end, run add_event(...) with the following comment: /* We fire once up front: simplifies clients and restart. */ The problem shows when xend is faster, detecting qemu 'running' state, and calls xstransact.Store adn writes to the command pipe, before qemu can call main_loop_wait(...) and run one empty loop on the command pipe. This write causes xenstored to run a fires_watch, thus another add_event(...). The problem shows in qemu log by an extra dm-command, using wrong parameter and fails to initialize, for instance: ... xs_read_watch: msg type 15 body /local/domain/0/device-model/3/command read_message: msg type reply pci-ins dm-command: hot insert pass-through pci dev read_message: msg type reply 0000:00:1b.0@100 register_real_device: Assigning real physical device 00:1b.0 ... pt_register_regions: IO region registered (size=0x00004000 base_addr=0x90420004) pt_msi_setup: msi mapped with pirq ff register_real_device: Real physical device 00:1b.0 registered successfuly! IRQ type = MSI-INTx read_message: msg type reply OK read_message: msg type reply OK xs_read_watch: msg type 15 body /local/domain/0/device-model/3/command read_message: msg type reply pci-ins dm-command: hot insert pass-through pci dev read_message: msg type reply 0x20 hot add pci devfn -1 exceed. read_message: msg type reply OK ... On the xend side: ... (bdf_str, vdevfn)) VmError: Cannot pass-through PCI function '0000:00:1b.0@100'. Device model reported an error: no free hotplug devfn [2009-10-13 10:45:10 4174] ERROR (XendDomainInfo:471) VM start failed Traceback (most recent call last): ... Thank you. Phung-Te --000e0cd3580ab69a570475d5d5e2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello Simon,

I took the source as per you message: http://marc.in= fo/?l=3Dxen-devel&m=3D124748015304566&w=3D4

compiled and= run it on an Intel-DQ35JO, Fedora-10.

When I try to pass pci device through at boot time in configuration fil= e, there's a race between xend and qemu accessing xenstore.

Xend= waits in signalDeviceModel(...) for qemu to declare 'running' then= write to the dm-command pipe the devices to be passed-through.

On the qemu side, it poses a watch on=A0 /local/domain/0/device-model/2= /command and expects the dm-command from there, by calling xs_watch(...). x= s_watch(...) causes xenstored to run do_watch(...) and at the end, run add_= event(...) with the following comment:
=A0=A0=A0=A0=A0 =A0=A0=A0 /* We fire once up front: simplifies clients and = restart. */


The problem shows when xend is faster, detecting qem= u 'running' state, and calls xstransact.Store adn writes to the com= mand pipe, before qemu can call main_loop_wait(...) and run one empty loop = on the command pipe. This write causes xenstored to run a fires_watch, thus= another add_event(...).
The problem shows in qemu log by an extra dm-command, using wrong parameter= and fails to initialize, for instance:

...
xs_read_watch: msg ty= pe 15 body /local/domain/0/device-model/3/command
read_message: msg type= reply pci-ins
dm-command: hot insert pass-through pci dev
read_message: msg type repl= y 0000:00:1b.0@100
register_real_device: Assigning real physical device = 00:1b.0 ...
pt_register_regions: IO region registered (size=3D0x00004000= base_addr=3D0x90420004)
pt_msi_setup: msi mapped with pirq ff
register_real_device: Real physica= l device 00:1b.0 registered successfuly!
IRQ type =3D MSI-INTx
read_m= essage: msg type reply OK
read_message: msg type reply OK
xs_read_wat= ch: msg type 15 body /local/domain/0/device-model/3/command
read_message: msg type reply pci-ins
dm-command: hot insert pass-through= pci dev
read_message: msg type reply 0x20
hot add pci devfn -1 exce= ed.
read_message: msg type reply OK
...

On the xend side:

...
=A0=A0=A0 (bdf_str, vdevfn))
VmError: Cannot pass-through PCI= function '0000:00:1b.0@100'. Device model reported an error: no fr= ee hotplug devfn
[2009-10-13 10:45:10 4174] ERROR (XendDomainInfo:471) V= M start failed
Traceback (most recent call last):
...


Thank you.

Phun= g-Te



--000e0cd3580ab69a570475d5d5e2-- --===============1620214983== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1620214983==--