aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2011-09-06 18:58:46 +0200
committerKevin Wolf <kwolf@redhat.com>2011-09-12 15:17:20 +0200
commitf107639a6ff0c8d02f6a2dfdfce3a9d9f1e2eb27 (patch)
tree0c5368f533034b7e1adbd02be5dcff6367cf3a94 /block.c
parentfdec4404ddfaf9e121bef84eac1303a8a0e47d75 (diff)
block: Drop medium lock tracking, ask device models instead
Requires new BlockDevOps member is_medium_locked(). Implement for IDE and SCSI CD-ROMs. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/block.c b/block.c
index 7408fa9dc2..1e4be7301b 100644
--- a/block.c
+++ b/block.c
@@ -818,6 +818,14 @@ static void bdrv_dev_resize_cb(BlockDriverState *bs)
}
}
+bool bdrv_dev_is_medium_locked(BlockDriverState *bs)
+{
+ if (bs->dev_ops && bs->dev_ops->is_medium_locked) {
+ return bs->dev_ops->is_medium_locked(bs->dev_opaque);
+ }
+ return false;
+}
+
/*
* Run consistency checks on an image
*
@@ -1890,7 +1898,7 @@ void bdrv_info(Monitor *mon, QObject **ret_data)
bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': 'unknown', "
"'removable': %i, 'locked': %i }",
bs->device_name, bs->removable,
- bs->locked);
+ bdrv_dev_is_medium_locked(bs));
if (bs->drv) {
QObject *obj;
@@ -3060,11 +3068,6 @@ void bdrv_eject(BlockDriverState *bs, int eject_flag)
}
}
-int bdrv_is_locked(BlockDriverState *bs)
-{
- return bs->locked;
-}
-
/**
* Lock or unlock the media (if it is locked, the user won't be able
* to eject it manually).
@@ -3075,7 +3078,6 @@ void bdrv_set_locked(BlockDriverState *bs, int locked)
trace_bdrv_set_locked(bs, locked);
- bs->locked = locked;
if (drv && drv->bdrv_set_locked) {
drv->bdrv_set_locked(bs, locked);
}