Patchwork [10/11] ide: Reject readonly drives unless CD-ROM

login
register
mail settings
Submitter Markus Armbruster
Date June 30, 2010, 11:55 a.m.
Message ID <1277898942-6501-11-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/57395/
State New
Headers show

Comments

Markus Armbruster - June 30, 2010, 11:55 a.m.
drive_init() doesn't permit option readonly for if=ide, but that's
worthless: we get it via if=none and -device.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ide/core.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/ide/core.c b/hw/ide/core.c
index a0eb1fa..73eae20 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2617,6 +2617,11 @@  int ide_init_drive(IDEState *s, BlockDriverState *bs,
     if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) {
         s->drive_kind = IDE_CD;
         bdrv_set_change_cb(bs, cdrom_change_cb, s);
+    } else {
+        if (bdrv_is_read_only(bs)) {
+            error_report("Can't use a read-only drive");
+            return -1;
+        }
     }
     if (serial) {
         strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str));