qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Close the BlockDriverState when guest eject the media


From: Markus Armbruster
Subject: Re: [Qemu-devel] Close the BlockDriverState when guest eject the media
Date: Mon, 27 Oct 2014 09:21:48 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 10/21/2014 12:10 AM, Gonglei wrote:
>
>>>>> There is a problem.
>>>>>
>>>>> 1. Qemu receive the "eject" command.
>>>>> 2. Runs "eject_request_cb" when an eject request is issued from
>>>>> the monitor, the tray
>>>>> is closed, and the medium is locked. But the drive is not closed.
>>>>> 3. Guest agree with opening tray and qemu will call bdrv_eject to
>>>>> complete. The drive is
>>>>> still not close.
>>>>>
>>>>> So the result of the monitor command "eject" is not to remove the
>>>>> medium in this situation.
>>>>
>>>> Now I understand, thanks for explaining.
>>>>
>>>> But I think libvirt can actually work correctly with what qemu offers
>>>> today. qemu returns an error if the medium cannot be removed with the
>>>> 'eject' command and it only sends an eject request to the guest.
>
> This whole area of interaction is messy, and this is not the first time
> someone has tried to improve it.  Is qemu actually issuing an error
> message in this case, and is it distinguishable from other errors?

0. Guest has a medium the guest locked into its CD-ROM drive:

    (qemu) info block cd

    cd: r7.iso (raw, read-only)
        Removable device: locked, tray closed

   Using HMP because QMP's query-block dumps a lot of detail on us that
   isn't relevant here.

1. eject it

    { "execute": "eject", "arguments": { "device": "cd" } }

   Fails, but notifies guest:

    {"error": {"class": "GenericError", "desc": "Device 'cd' is
    locked"}}

   Tray stayed put:

    cd: r7.iso (raw, read-only)
        Removable device: locked, tray closed

   Guest reacts to the notification and duly ejects:

    {"timestamp": {"seconds": 1414396646, "microseconds": 494175}, "event": 
"DEVICE_TRAY_MOVED", "data": {"device": "cd", "tray-open": true}}

   Tray is now open:

    cd: r7.iso (raw, read-only)
        Removable device: not locked, tray open

   I actually stopped the guest around the eject command to reliably
   capture tray status between eject and the guest's reaction.

2. eject it again

    { "execute": "eject", "arguments": { "device": "cd" } }
    {"return": {}}

   Medium is now gone:

    cd: [not inserted]
        Removable device: not locked, tray open

The first eject fails with GenericError, same as other errors such as
"Device '%s' is not removable".

I feel reporting an error in the "locked" case is actually
inappropriate, because asking the guest is exactly what the command is
supposed to do then.  I doubt we can change the existing commands, but
we can do better in the new QMP commands I mentioned upthread.

I figure a new command should return a value to distinguish the two
success cases "I opened the tray" and "I asked the guest to open the
tray".

Until such new commands are available, I'm afraid all you can do is
keying on event DEVICE_TRAY_MOVED.

[...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]