qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC 01/10] block: bdrv_eject(): Add 'force' parameter


From: Luiz Capitulino
Subject: [Qemu-devel] [RFC 01/10] block: bdrv_eject(): Add 'force' parameter
Date: Fri, 3 Jun 2011 16:03:53 -0300

It's purpose is to skip the media locked test. This is going to be used
by the blockdev-tray-open QMP command.

Signed-off-by: Luiz Capitulino <address@hidden>
---
 block.c        |    4 ++--
 block.h        |    2 +-
 block/raw.c    |    2 +-
 hw/ide/atapi.c |    2 +-
 hw/scsi-disk.c |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/block.c b/block.c
index effa86f..a3d0556 100644
--- a/block.c
+++ b/block.c
@@ -2752,12 +2752,12 @@ int bdrv_media_changed(BlockDriverState *bs)
 /**
  * If eject_flag is TRUE, eject the media. Otherwise, close the tray
  */
-int bdrv_eject(BlockDriverState *bs, int eject_flag)
+int bdrv_eject(BlockDriverState *bs, int eject_flag, int force)
 {
     BlockDriver *drv = bs->drv;
     int ret;
 
-    if (bs->locked) {
+    if (bs->locked && !force) {
         return -EBUSY;
     }
 
diff --git a/block.h b/block.h
index da7d39c..131812c 100644
--- a/block.h
+++ b/block.h
@@ -186,7 +186,7 @@ int bdrv_is_inserted(BlockDriverState *bs);
 int bdrv_media_changed(BlockDriverState *bs);
 int bdrv_is_locked(BlockDriverState *bs);
 void bdrv_set_locked(BlockDriverState *bs, int locked);
-int bdrv_eject(BlockDriverState *bs, int eject_flag);
+int bdrv_eject(BlockDriverState *bs, int eject_flag, int force);
 void bdrv_set_change_cb(BlockDriverState *bs,
                         void (*change_cb)(void *opaque, int reason),
                         void *opaque);
diff --git a/block/raw.c b/block/raw.c
index b0f72d6..0e23c7c 100644
--- a/block/raw.c
+++ b/block/raw.c
@@ -77,7 +77,7 @@ static int raw_is_inserted(BlockDriverState *bs)
 
 static int raw_eject(BlockDriverState *bs, int eject_flag)
 {
-    return bdrv_eject(bs->file, eject_flag);
+    return bdrv_eject(bs->file, eject_flag, 0);
 }
 
 static int raw_set_locked(BlockDriverState *bs, int locked)
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index fe2fb0b..8af6e23 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -897,7 +897,7 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
     eject = (buf[4] >> 1) & 1;
 
     if (eject) {
-        err = bdrv_eject(s->bs, !start);
+        err = bdrv_eject(s->bs, !start, 0);
     }
 
     switch (err) {
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a8c7372..d3f982e 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -872,7 +872,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, 
uint8_t *outbuf)
     case START_STOP:
         if (s->drive_kind == SCSI_CD && (req->cmd.buf[4] & 2)) {
             /* load/eject medium */
-            bdrv_eject(s->bs, !(req->cmd.buf[4] & 1));
+            bdrv_eject(s->bs, !(req->cmd.buf[4] & 1), 0);
         }
        break;
     case ALLOW_MEDIUM_REMOVAL:
-- 
1.7.4.4




reply via email to

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