Received: from eggs.gnu.org ([2001:4830:134:3::10]:47414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoY6T-0002rN-CP for qemu-devel@nongnu.org; Thu, 05 Dec 2013 07:32:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoY6N-00061v-8D for qemu-devel@nongnu.org; Thu, 05 Dec 2013 07:32:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoY6N-00061g-11 for qemu-devel@nongnu.org; Thu, 05 Dec 2013 07:32:19 -0500 From: Markus Armbruster References: <1386132925-16728-1-git-send-email-aik@ozlabs.ru> <1386132925-16728-2-git-send-email-aik@ozlabs.ru> <529EEE9F.50007@redhat.com> <87d2ldklji.fsf@blackfin.pond.sub.org> Date: Thu, 05 Dec 2013 13:29:34 +0100 In-Reply-To: <87d2ldklji.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Wed, 04 Dec 2013 10:33:37 +0100") Message-ID: <878uvzo501.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/3] scsi-disk: close drive on START_STOP List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org Markus Armbruster writes: > Paolo Bonzini writes: > >> Il 04/12/2013 05:55, Alexey Kardashevskiy ha scritto: >>> Normally the user is expected to eject DVD if it is not locked by >>> the guest. eject_device() makes few checks and calls bdrv_close() >>> if DVD is not in use. >>> >>> However it is still possible to eject DVD even if it is in use. >>> For that, QEMU sets "eject requested" flag, the guest reads it, issues >>> ALLOW_MEDIUM_REMOVAL(enable=1) and START_STOP(start=0). But in this case, >>> bdrv_close() is not called anywhere so it remains "inserted" in QEMU's >>> terms. >> >> This is expected behavior, and matches what IDE does. >> >> Markus, can you confirm? > > Confirmed. See commit 4be9762. > > Alexey, monitor commands eject does two things: it first opens the tray, > and if that works, it removes the medium. > > If the tray is locked closed, it tells the device model that eject was > requested. Works just like the physical eject button. > > With -f, it then rips out the medium. This is similar to opening the > tray with a unbent paperclip. Let's ignore this case. > > The scsi-cd device model tells the guest about the eject request. A > well-behaved guest will then command the device to unlock and open the > tray. > > The guest uses the same commands on behalf of its applications, > e.g. /usr/bin/eject. > > Your patch changes behavior of "eject /dev/sr0 && eject -t /dev/sr0": > you no longer get the same medium back. You normally do with real > hardware. Alexey asked me for details on IRC. $ qemu -nodefaults -monitor stdio -S -machine accel=kvm -m 512 -display vnc=:0 -device cirrus-vga -drive if=none,id=disk,file=test.qcow2 -device ide-hd,drive=disk,bus=ide.0 -drive if=none,id=cd,file=f16.iso -device ide-cd,drive=cd,bus=ide.1 QEMU 1.7.50 monitor - type 'help' for more information (qemu) info block cd cd: f16.iso (raw) Removable device: not locked, tray closed Boot the guest (Fedora 16, no X) (qemu) c The guest locked the tray: (qemu) info block cd cd: f16.iso (raw) Removable device: locked, tray closed In the guest, log in as root on the console, and run # eject /dev/sr0 Makes the guest open the tray: (qemu) info block cd cd: f16.iso (raw) Removable device: locked, tray open In the guest, run # eject -t /dev/sr0 Makes the guest close the tray: (qemu) info block cd cd: f16.iso (raw) Removable device: locked, tray closed Verify the guest can access the medium: # mount -r /dev/sr0 /mnt > The somewhat unfortunate consequence is that monitor command eject can > only remove the medium when the tray is not locked.