diff options
author | Markus Armbruster <armbru@redhat.com> | 2011-07-20 18:23:35 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2011-08-01 12:09:11 +0200 |
commit | ea8f942fe46dd10e0946f02ab9d698fb41e958f7 (patch) | |
tree | 9544c00f6f4189dcf0e447d315eca701b3ca844e | |
parent | 927d721777e73339f73719f36eaf400ab641366c (diff) |
blockdev: Make eject fail for non-removable drives even with -f
Ejecting hard disk platters can only end in tears.
If you need to revoke access to an image, use drive_del, not eject -f.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | blockdev.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/blockdev.c b/blockdev.c index 0b8d3a4f83..a25367a9e3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -646,16 +646,13 @@ out: static int eject_device(Monitor *mon, BlockDriverState *bs, int force) { - if (!force) { - if (!bdrv_is_removable(bs)) { - qerror_report(QERR_DEVICE_NOT_REMOVABLE, - bdrv_get_device_name(bs)); - return -1; - } - if (bdrv_is_locked(bs)) { - qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); - return -1; - } + if (!bdrv_is_removable(bs)) { + qerror_report(QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs)); + return -1; + } + if (!force && bdrv_is_locked(bs)) { + qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); + return -1; } bdrv_close(bs); return 0; |