Patchwork [16/60] blockdev: preserve readonly and snapshot states across media changes

login
register
mail settings
Submitter Michael Tokarev
Date Feb. 4, 2013, 10:40 a.m.
Message ID <1359974470-17044-17-git-send-email-mjt@msgid.tls.msk.ru>
Download mbox | patch
Permalink /patch/217921/
State New
Headers show

Comments

Michael Tokarev - Feb. 4, 2013, 10:40 a.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>
(cherry picked from commit 80dd1aae3657a902d262f5d20a7a3c655b23705e)

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 blockdev.c |    2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/blockdev.c b/blockdev.c
index 67895b2..2455e21 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -529,6 +529,8 @@  DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
                      devname, 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;