Patchwork [01/19] blockdev: preserve readonly and snapshot states across media changes

login
register
mail settings
Submitter Kevin Wolf
Date Sept. 24, 2012, 2:26 p.m.
Message ID <1348496808-8159-2-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/186429/
State New
Headers show

Comments

Kevin Wolf - Sept. 24, 2012, 2:26 p.m.
From: Kevin Shanahan <kmshanah@disenchant.net>

If readonly=on is given at device creation time, the ->readonly flag
needs to be set in the block driver state for this device so that
readonly-ness is preserved across media changes (qmp change command).
Similarly, to preserve the snapshot property requires ->open_flags to
be correct.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 blockdev.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Patch

diff --git a/blockdev.c b/blockdev.c
index 7c83baa..e5d450f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -527,6 +527,8 @@  DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
                      if_name[type], mediastr, unit_id);
     }
     dinfo->bdrv = bdrv_new(dinfo->id);
+    dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
+    dinfo->bdrv->read_only = ro;
     dinfo->devaddr = devaddr;
     dinfo->type = type;
     dinfo->bus = bus_id;