All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	quintela@redhat.com, dbaryshkov@gmail.com,
	stefano.stabellini@eu.citrix.com, qemu-devel@nongnu.org,
	lcapitulino@redhat.com, amit.shah@redhat.com
Subject: Re: [Qemu-devel] [PATCH 44/55] spitz tosa: Simplify "drive is suitable for microdrive" test
Date: Tue, 09 Aug 2011 13:56:12 +0200	[thread overview]
Message-ID: <m339hadcir.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <4E40E2A0.9050405@redhat.com> (Kevin Wolf's message of "Tue, 09 Aug 2011 09:32:48 +0200")

Kevin Wolf <kwolf@redhat.com> writes:

> Am 09.08.2011 06:32, schrieb andrzej zaborowski:
>> On 4 August 2011 10:02, Kevin Wolf <kwolf@redhat.com> wrote:
>>> Am 03.08.2011 22:20, schrieb andrzej zaborowski:
>>>> On 3 August 2011 20:24, Markus Armbruster <armbru@redhat.com> wrote:
>>>>> andrzej zaborowski <balrogg@gmail.com> writes:
>>>>>> On 3 August 2011 18:38, Markus Armbruster <armbru@redhat.com> wrote:
>>>>>>> andrzej zaborowski <balrogg@gmail.com> writes:
>>>>>>>>                                                      2. if the
>>>>>>>> underlaying storage can disappear for any other reason if that's
>>>>>>>> possible to check.
>>>>>>>
>>>>>>> bdrv_is_removable() *isn't* such a check.
>>>>>>
>>>>>> Obviously I wasn't claiming it is, just that it might be useful, but
>>>>>> not necessrily possible.  After all pretty much any storage can be
>>>>>> "ejected" with enough force, depending on how far you want to go.
>>>>>>
>>>>>>>>> What's wrong with that again?  All sounds sensible to me.
>>>>>>>>
>>>>>>>> I'm not claiming otherwise, just double-checking this is what you want.
>>>>>>
>>>>>> So first you said you had a problem with _is_removable, and then you
>>>>>> said nothing was wrong with the implementation you outlined, plase
>>>>>> make up your mind.
>>>>>
>>>>> I don't appreciate you quoting me out of context like that.
>>>>
>>>> I got quite annoyed when you started putting words in my mouth by
>>>> saying I said anything about CD-ROM.. the code in spitz/tosa is not
>>>> concerned with CD-ROMs even if downstream it boils down to that, it is
>>>> concerned with whether the device is removable or not, and that's what
>>>> the check does.  It doesn't help readability or anything by inlining
>>>> that check.  If you're trying to check for A then don't spell it out
>>>> as B, be explicit.  It's not a big deal but I just don't see the
>>>> point, sorry.
>>>>
>>>>>
>>>>> The sentence you quoted was in the middle of my attempt to get you to
>>>>> explain what you're trying to accomplish there.
>>>>
>>>> I already said about 3 times what it's trying to acomplish.  You also
>>>> have used the word "removable" so I'm sure you know what it means and
>>>> don't need further explanation.  But let's define it this way: if a
>>>> GUI is going to display an "eject" button next to a drive in the qemu
>>>> device tree, that's a removable device.  CD-ROM is an example of that.
>>>>  An IDE HDD is an example of something that's not going to have that
>>>> button (I assume).
>>>
>>> But this is a property of the device, not of the backend. This means
>>> that it belongs in the device emulation and not in block.c.
>> 
>> By device do you mean hw/ide/microdrive.c?
>
> I mean just anything in hw/. I'm not familiar with how these devices
> work internally, so if hw/ide/microdrive.c is the right place, fine.

We have way too many things we call "device", or "driver"...  Let me try
to dispell the confusion.

Machines spitz, borzoi, terrier (hw/spitz.c) have a spitz microdrive
device.  Machine tosa (hw/tosa.c) has a tosa microdrive device.

Like all block devices, they consist of a frontend and a backend.

Our block device backend abstraction is BlockDriverState.  Internally, a
block device backend is the block layer sitting on top of an optional
BlockDriver.  No block driver is interpreted as no medium.

Monitor command "eject" drops the block driver.

Monitor command "change" first drops the block driver, then attaches a
new one.

A BlockDriver may support removable media.  Host device block drivers
do, the others don't.  Doesn't affect monitor commands eject and change
at all, because these *drop* the block driver.

A block device frontend is attached to a backend on initialization.  In
other words, a backend may exist alone, but a frontend is always
attached to a backend.

A block device frontend may support removable media.  If it does,
monitor commands eject and change work while the frontend is attached.
They always work while no frontend is attached.

Note: we got *two* different "removables" here, frontend and backend.
It is possible to back a removable frontend, say ide-cd, with a
non-removable backend, say file.  The opposite is also possible (whether
it's wise is a different question).

The frontend code is in hw/ide/microdrive.c.  It does *not* support
removable media.  Monitor commands eject and change refuse to touch this
device.

The property "monitor command eject is applicable to the device" is a
property of the frontend, because the frontend and only the frontend
decide whether eject is okay.

The property 'GUI shall display an "eject" button next to a drive in the
qemu device tree' is just the same.

Kevin wrote "this is a property of the device, not of the backend.  This
means that it belongs in the device emulation and not in block.c."
Kevin is correct.  The code is also correct: microdrive.c defines a
non-removable device (by not implementing callback change_media_cb()).
Therefore, monitor commands eject and change will not touch microdrives.

The checks in spitz_microdrive_attach() and tosa_microdrive_attach() do
*not* contribute to that.  All they accomplish is silently refrain from
creating the device if the user created the first IDE drive
(if=ide,index=0) with media=cd.  No more, no less.

I have no opinion on whether that's useful.

If you want to keep it, take my PATCH 44/55 as is.

If you want to create the drive regardless of media=cd, tell me, and
I'll do exactly that in my respin.

>> I'm not saying it belongs
>> in block.c, but logically it belongs in the same place as
>> bdrv_is_inserted, bdrv_is_locked, bdrv_eject etc. no?  So it is a
>> property of whatever "media" is property of.
>
> Depends. As long as you're talking about purely virtual device state, I
> would say yes, they belong there, too. However, we have things like
> CD-ROM passthrough where bdrv_is_inserted etc. are supposed to return
> the status of the physical host device. These are host state and need to
> be in the block layer.

bdrv_is_inserted() is about the backend's media.  At least it is after
my PATCH 21/55 cleans up the mess I made in commit 4be9762a.

bdrv_eject() is a function frontends supporting removable media call to
notify backends of medium eject/load.  If the backend happens to use a
host device block driver, it'll eject/load the physical medium.

Likewise, bdrv_set_locked() is a function frontends supporting removable
media call to notify backends of medium lock/unlock.  If the backend
happens to use a host device block driver, it'll lock/unlock the
physical medium.

bdrv_is_locked() is about the frontend's media lock.  To make this more
obvious, my PATCH 29/55 replaces it by bdrv_dev_is_medium_locked().  It
does *not* query the backend's lock (which may not even exist!) set by
bdrv_set_locked().

  reply	other threads:[~2011-08-09 14:02 UTC|newest]

Thread overview: 145+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 16:23 [Qemu-devel] [PATCH 00/55] Block layer cleanup & fixes Markus Armbruster
2011-07-20 16:23 ` [Qemu-devel] [PATCH 01/55] blockdev: Make eject fail for non-removable drives even with -f Markus Armbruster
2011-07-25 12:27   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 02/55] block: Reset device model callbacks on detach Markus Armbruster
2011-07-25 12:27   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 03/55] block: Attach non-qdev devices as well Markus Armbruster
2011-07-20 16:23 ` [Qemu-devel] [PATCH 04/55] block: Generalize change_cb() to BlockDevOps Markus Armbruster
2011-07-25 12:30   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 05/55] block: Split change_cb() into change_media_cb(), resize_cb() Markus Armbruster
2011-07-25 12:31   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 06/55] block/raw-win32: Drop disabled code for removable host devices Markus Armbruster
2011-07-25 12:32   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 07/55] block: Make BlockDriver method bdrv_set_locked() return void Markus Armbruster
     [not found]   ` <20110721111134.787a83af@doriath>
2011-07-21 15:07     ` Markus Armbruster
2011-07-21 16:34       ` Luiz Capitulino
2011-07-22 14:36       ` Kevin Wolf
2011-07-20 16:23 ` [Qemu-devel] [PATCH 08/55] block: Make BlockDriver method bdrv_eject() " Markus Armbruster
2011-07-22 14:41   ` Kevin Wolf
2011-07-22 15:04     ` Markus Armbruster
2011-07-20 16:23 ` [Qemu-devel] [PATCH 09/55] block: Don't let locked flag prevent medium load Markus Armbruster
2011-07-22 14:51   ` Kevin Wolf
2011-07-22 15:33     ` Markus Armbruster
2011-07-20 16:23 ` [Qemu-devel] [PATCH 10/55] ide: Update command code definitions as per ACS-2 Table B.2 Markus Armbruster
2011-07-25 12:34   ` Christoph Hellwig
2011-07-25 17:15     ` Markus Armbruster
2011-07-20 16:23 ` [Qemu-devel] [PATCH 11/55] ide: Clean up case label indentation in ide_exec_cmd() Markus Armbruster
2011-07-25 12:34   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 12/55] ide: Fix ATA command READ to set ATAPI signature for CD-ROM Markus Armbruster
2011-07-26 11:57   ` Christoph Hellwig
2011-07-26 13:33     ` Markus Armbruster
2011-07-20 16:23 ` [Qemu-devel] [PATCH 13/55] ide: Use a table to declare which drive kinds accept each command Markus Armbruster
2011-07-26 11:58   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 14/55] ide: Reject ATA commands specific to drive kinds Markus Armbruster
2011-07-26 11:58   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 15/55] ide/atapi: Clean up misleading name in cmd_start_stop_unit() Markus Armbruster
2011-07-26 11:59   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 16/55] ide/atapi: Track tray open/close state Markus Armbruster
2011-07-26 11:59   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 17/55] ide/atapi: Switch from BlockDriverState's tray_open to own Markus Armbruster
2011-07-26 12:00   ` Christoph Hellwig
2011-07-26 13:36     ` Markus Armbruster
2011-07-20 16:23 ` [Qemu-devel] [PATCH 18/55] scsi-disk: Reject CD-specific SCSI commands to disks Markus Armbruster
2011-07-26 12:02   ` Christoph Hellwig
2011-07-26 13:36     ` Markus Armbruster
2011-07-29  8:41       ` Markus Armbruster
2011-07-20 16:23 ` [Qemu-devel] [PATCH 19/55] scsi-disk: Factor out scsi_disk_emulate_start_stop() Markus Armbruster
2011-07-26 12:03   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 20/55] scsi-disk: Track tray open/close state Markus Armbruster
2011-07-26 12:03   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 21/55] block: Revert entanglement of bdrv_is_inserted() with tray status Markus Armbruster
2011-07-26 12:10   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 22/55] block: Drop tray status tracking, no longer used Markus Armbruster
2011-07-26 12:11   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 23/55] block: Show whether the guest ejected the medium in info block Markus Armbruster
     [not found]   ` <20110721112232.28405a1c@doriath>
2011-07-21 15:08     ` Markus Armbruster
2011-07-21 16:38       ` Luiz Capitulino
2011-07-21 17:30         ` Luiz Capitulino
2011-07-20 16:23 ` [Qemu-devel] [PATCH 24/55] ide/atapi: Track tray locked state Markus Armbruster
2011-07-26 12:13   ` Christoph Hellwig
2011-07-20 16:23 ` [Qemu-devel] [PATCH 25/55] ide/atapi: Switch from BlockDriverState's locked to own tray_locked Markus Armbruster
2011-07-26 12:14   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 26/55] scsi-disk: Track tray locked state Markus Armbruster
2011-07-26 12:14   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 27/55] scsi-disk: Switch from BlockDriverState's locked to own tray_locked Markus Armbruster
2011-07-26 12:14   ` Christoph Hellwig
2011-07-26 13:38     ` Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 28/55] block: Leave enforcing tray lock to device models Markus Armbruster
     [not found]   ` <20110721113051.4ea99b04@doriath>
2011-07-21 15:16     ` Markus Armbruster
2011-07-21 16:40       ` Luiz Capitulino
2011-07-20 16:24 ` [Qemu-devel] [PATCH 29/55] block: Drop medium lock tracking, ask device models instead Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 30/55] block: Rename bdrv_set_locked() to bdrv_lock_medium() Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 31/55] ide: Provide IDEDeviceInfo method exit() Markus Armbruster
2011-07-26 12:16   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 32/55] ide/atapi: Don't fail eject when tray is already open Markus Armbruster
2011-07-26 12:16   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 33/55] ide/atapi: Avoid physical/virtual tray state mismatch Markus Armbruster
2011-07-26 12:17   ` Christoph Hellwig
2011-07-26 13:43     ` Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 34/55] scsi-disk: Fix START_STOP to fail when it can't eject Markus Armbruster
2011-07-26 12:17   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 35/55] scsi-disk: Avoid physical/virtual tray state mismatch Markus Armbruster
2011-07-26 12:17   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 36/55] ide: Give vmstate structs internal linkage where possible Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 37/55] ide/atapi: Preserve tray state on migration Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 38/55] scsi-disk: " Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 39/55] block/raw: Fix to forward method bdrv_media_changed() Markus Armbruster
2011-07-26 12:18   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 40/55] block: Leave tracking media change to device models Markus Armbruster
2011-07-26 12:19   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 41/55] fdc: Make media change detection more robust Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 42/55] block: Clean up bdrv_flush_all() Markus Armbruster
2011-07-26 12:19   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 43/55] savevm: Include writable devices with removable media Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 44/55] spitz tosa: Simplify "drive is suitable for microdrive" test Markus Armbruster
2011-07-30  2:24   ` andrzej zaborowski
2011-08-01 12:33     ` Markus Armbruster
2011-08-01 13:04       ` Peter Maydell
2011-08-03  8:12         ` Markus Armbruster
2011-08-03 12:05           ` andrzej zaborowski
2011-08-03 13:28             ` Markus Armbruster
2011-08-03 13:37               ` andrzej zaborowski
2011-08-03 16:38                 ` Markus Armbruster
2011-08-03 17:26                   ` andrzej zaborowski
2011-08-03 18:24                     ` Markus Armbruster
2011-08-03 20:20                       ` andrzej zaborowski
2011-08-04  8:02                         ` Kevin Wolf
2011-08-09  4:32                           ` andrzej zaborowski
2011-08-09  7:32                             ` Kevin Wolf
2011-08-09 11:56                               ` Markus Armbruster [this message]
2011-08-09 12:10                                 ` Kevin Wolf
2011-08-09 12:36                                   ` Markus Armbruster
2011-08-09 12:46                                     ` Kevin Wolf
2011-08-04  9:36                         ` Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 45/55] block: Clean up remaining users of "removable" Markus Armbruster
2011-07-21 17:33   ` Luiz Capitulino
2011-07-26 13:03   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 46/55] block: Drop BlockDriverState member removable Markus Armbruster
2011-07-26 13:03   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 47/55] block: Move BlockConf & friends from block_int.h to block.h Markus Armbruster
2011-07-26 13:04   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 48/55] hw: Trim superfluous #include "block_int.h" Markus Armbruster
2011-07-26 13:04   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 49/55] block: Declare qemu_blockalign() in block.h, not block_int.h Markus Armbruster
2011-07-26 13:05   ` Christoph Hellwig
2011-07-26 14:10     ` Markus Armbruster
2011-07-29  8:56     ` Markus Armbruster
2011-07-29 13:11       ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 50/55] block: New bdrv_set_buffer_alignment() Markus Armbruster
2011-07-26 13:06   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 51/55] block: Reset buffer alignment on detach Markus Armbruster
2011-07-26 13:06   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 52/55] block: Move BlockDriverAIOCB & friends from block_int.h to block.h Markus Armbruster
2011-07-26 13:07   ` Christoph Hellwig
2011-07-26 14:11     ` Markus Armbruster
2011-07-20 16:24 ` [Qemu-devel] [PATCH 53/55] nbd: Clean up use of block_int.h Markus Armbruster
2011-07-26 13:07   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 54/55] block: New change_media_cb() parameter load Markus Armbruster
2011-07-26 13:08   ` Christoph Hellwig
2011-07-20 16:24 ` [Qemu-devel] [PATCH 55/55] ide/atapi scsi-disk: Make monitor eject -f, then change work Markus Armbruster
2011-07-26 13:08   ` Christoph Hellwig
2011-07-23  3:15 ` [Qemu-devel] [PATCH 00/55] Block layer cleanup & fixes Amit Shah
2011-07-25 15:33   ` Markus Armbruster
2011-07-26  5:33     ` Amit Shah
2011-07-28  8:12 ` Kevin Wolf
2011-07-28  9:34 ` Amit Shah

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=m339hadcir.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=dbaryshkov@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefano.stabellini@eu.citrix.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 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.