qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Harper <ryanh@us.ibm.com>
To: Wen Congyang <wency@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Isaku Yamahata <yamahata@valinux.co.jp>,
	Ryan Harper <ryanh@us.ibm.com>, Gerd Hoffmann <kraxel@redhat.com>,
	William Dauchy <wdauchy@gmail.com>
Subject: Re: [Qemu-devel] [PATCH] `qdev_free` when unplug a pci device
Date: Wed, 9 Mar 2011 00:12:30 -0600	[thread overview]
Message-ID: <20110309061230.GP23238@us.ibm.com> (raw)
In-Reply-To: <4D770A51.6050509@cn.fujitsu.com>

* Wen Congyang <wency@cn.fujitsu.com> [2011-03-08 23:09]:
> At 03/09/2011 12:08 PM, Ryan Harper Write:
> > * Wen Congyang <wency@cn.fujitsu.com> [2011-02-27 20:56]:
> >> Hi Markus Armbruster
> >>
> >> At 02/23/2011 04:30 PM, Markus Armbruster Write:
> >>> Isaku Yamahata <yamahata@valinux.co.jp> writes:
> >>>
> >>
> >> <snip>
> >>
> >>>
> >>> I don't think this patch is correct.  Let me explain.
> >>>
> >>> Device hot unplug is *not* guaranteed to succeed.
> >>>
> >>> For some buses, such as USB, it always succeeds immediately, i.e. when
> >>> the device_del monitor command finishes, the device is gone.  Live is
> >>> good.
> >>>
> >>> But for PCI, device_del merely initiates the ACPI unplug rain dance.  It
> >>> doesn't wait for the dance to complete.  Why?  The dance can take an
> >>> unpredictable amount of time, including forever.
> >>>
> >>> Problem: Subsequent device_add can fail if it reuses the qdev ID or PCI
> >>> slot, and the unplug has not yet completed (race condition), or it
> >>> failed.  Yes, Virginia, PCI hotplug *can* fail.
> >>>
> >>> When unplug succeeds, the qdev is automatically destroyed.
> >>> pciej_write() does that for PIIX4.  Looks like pcie_cap_slot_event()
> >>> does it for PCIE.
> >>
> >> I got a similar problem.  When I unplug a pci device by hand, it works
> >> as expected, and I can hotplug it again. But when I use a srcipt to
> >> do the same thing, sometimes it failed. I think I may find another bug.
> >>
> >> Steps to reproduce this bug:
> >> 1. cat ./test-e1000.sh # RHEL6RC is domain name
> >>    #! /bin/bash
> >>
> >>    while true; do
> >>            virsh attach-interface RHEL6RC network default --mac 52:54:00:1f:db:c7 --model e1000
> >>            if [[ $? -ne 0 ]]; then
> >>                    break
> >>            fi
> >>            virsh detach-interface RHEL6RC network --mac 52:54:00:1f:db:c7
> >>            if [[ $? -ne 0 ]]; then
> >>                    break
> >>            fi
> >>            sleep 5
> > 
> > How do you know that the guest has responded at this point before you
> > attempt to attach again at the top of the loop.  Any attach/detach
> > requires the guest to respond to the request and it may not respond at
> > all.
> 
> When I attach/detach interface by hand, it works fine: I can see the new interface
> when I attach it, and it disapears when I detached it.

The point is that since the attach and detach require guest
participation, this interface isn't reliable.  You have a sleep 5 in
your loop, hoping to wait long enough for the guest to respond, but
after a number of iterations in your loop it fails, you can bump the
sleep to to 3600 seconds and the guest *still* might not respond...


-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh@us.ibm.com

  reply	other threads:[~2011-03-09  6:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22 17:36 [Qemu-devel] [PATCH] `qdev_free` when unplug a pci device William Dauchy
2011-02-23  2:50 ` Isaku Yamahata
2011-02-23  8:30   ` Markus Armbruster
2011-02-23  9:32     ` William Dauchy
2011-02-28  2:52     ` Wen Congyang
2011-03-01  4:11       ` Isaku Yamahata
2011-03-01  6:58         ` Wen Congyang
2011-03-01  7:13           ` Isaku Yamahata
2011-03-01  7:32             ` Wen Congyang
2011-03-01  9:49               ` Isaku Yamahata
2011-03-09  4:08       ` Ryan Harper
2011-03-09  5:04         ` Wen Congyang
2011-03-09  6:12           ` Ryan Harper [this message]
2011-03-09  7:19             ` Wen Congyang
2011-03-10  4:31               ` Ryan Harper
2011-03-10  5:28                 ` Wen Congyang

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=20110309061230.GP23238@us.ibm.com \
    --to=ryanh@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wdauchy@gmail.com \
    --cc=wency@cn.fujitsu.com \
    --cc=yamahata@valinux.co.jp \
    /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).