From: Kevin Shanahan Date: Thu, 20 Sep 2012 23:20:22 +0000 (+0930) Subject: blockdev: preserve readonly and snapshot states across media changes X-Git-Tag: v1.2.1~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=513cdda198bac6c40e8847c8e8136ec974b67da7;p=thirdparty%2Fqemu.git blockdev: preserve readonly and snapshot states across media changes 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 Signed-off-by: Kevin Wolf (cherry picked from commit 80dd1aae3657a902d262f5d20a7a3c655b23705e) Signed-off-by: Michael Roth --- diff --git a/blockdev.c b/blockdev.c index 7c83baa353c..e5d450f0bb9 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;