qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 1/3] scsi-disk: close drive on START_STOP


From: Alexey Kardashevskiy
Subject: [Qemu-devel] [PATCH 1/3] scsi-disk: close drive on START_STOP
Date: Wed, 4 Dec 2013 15:55:23 +1100

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 adds a block device removal on the SCSI device stop.

Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
 hw/scsi/scsi-disk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 74e6a14..08b6135 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1283,6 +1283,9 @@ static int scsi_disk_emulate_start_stop(SCSIDiskReq *r)
         if (s->tray_open != !start) {
             bdrv_eject(s->qdev.conf.bs, !start);
             s->tray_open = !start;
+            if (!start) {
+                bdrv_close(s->qdev.conf.bs);
+            }
         }
     }
     return 0;
-- 
1.8.4.rc4




reply via email to

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