From: Markus Armbruster <armbru@redhat.com>
To: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] drive_del vs. device_del: what should come first?
Date: Wed, 02 Apr 2014 19:40:09 +0200 [thread overview]
Message-ID: <87d2gzpr46.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <533C1DC5.6050605@linux.vnet.ibm.com> (Heinz Graalfs's message of "Wed, 02 Apr 2014 16:25:09 +0200")
Heinz Graalfs <graalfs@linux.vnet.ibm.com> writes:
> On 01/04/14 17:48, Markus Armbruster wrote:
>> Heinz Graalfs <graalfs@linux.vnet.ibm.com> writes:
>>
>>> Hi Kevin,
>>>
>>> doing a
>>>
>>> virsh detach-device ...
>>>
>>> ends up in the following QEMU monitor commands:
>>>
>>> 1. device_del ...
>>> 2. drive_del ...
>>>
>>> qmp_device_del() performs the device unplug path.
>>> In case of a block device do_drive_del() tries to
>>> prevent further IO against the host device.
>>>
>>> However, bdrv_find() during drive_del() results in
>>> an error, because the device is already gone. Due to
>>> this error all the bdrv_xxx calls to quiesce the block
>>> driver as well as all other processing is skipped.
>>>
>>> Is the sequence that libvirt triggers OK?
>>> Shouldn't drive_del be executed first?
>>
>> No.
>
> OK, I see. The drive is deleted implicitly (release_drive()).
> Doing a device_del() requires another drive_add() AND device_add().
Yes. The automatic drive delete on unplug is a wart that will not be
preserved in the new interfaces we're building now.
> (Doing just a device_add() complains about the missing drive.
> A subsequent info qtree lets QEMU abort.)
Really? Got a reproducer for me?
>> drive_del is nasty. Its purpose is to revoke access to an image even
>> when the guest refuses to cooperate. To the guest, this looks like
>> hardware failure.
>
> Deleting a device during active IO is nasty and it should look like a
> hardware failure. I would expect lots of errors.
>
>>
>> If you drive_del before device_del, even a perfectly well-behaved guest
>> guest is exposed to a terminally broken device between drive_del and
>> completion of unplug.
>
> The early drive_del() would mean that no further IO would be
> possible.
A polite way to describe the effect of drive_del on the guest.
drive_del makes all attempts at actual I/O error out without any
forewarning whatsoever. If you do that to your guest, and something
breaks, you get to keep the pieces. Even if you "only" do it for a
short period of time.
>> Always try a device_del first, and only if that does not complete within
>> reasonable time, and you absolutely must revoke access to the image,
>> then whack it over the head with drive_del.
>
> What is this reasonable time?
Depends on how heavily loaded host and guest are. Suggest to measure
with a suitably thrashing guest, then shift left to taste.
> On 390 we experience problems (QEMU abort) when asynch block IO
> completes and the virtqueues are already gone. I suppose the
> bdrv_drain_all() in bdrv_close() is a little late. I don't see such
> problems with an early bdrv_drain_all() (drive_del) and an unplug
> (device_del) afterwards.
Sounds like a bug. Got a reproducer?
next prev parent reply other threads:[~2014-04-02 17:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 13:55 [Qemu-devel] drive_del vs. device_del: what should come first? Heinz Graalfs
2014-04-01 15:48 ` Markus Armbruster
2014-04-02 14:25 ` Heinz Graalfs
2014-04-02 17:40 ` Markus Armbruster [this message]
2014-04-03 15:20 ` Heinz Graalfs
2014-04-11 12:47 ` Heinz Graalfs
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=87d2gzpr46.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=graalfs@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.