@@ -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;
}
@@ -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);
@@ -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)
@@ -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) {
@@ -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:
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 <lcapitulino@redhat.com> --- 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(-)