]> git.proxmox.com Git - mirror_qemu.git/commitdiff
blockdev: preserve readonly and snapshot states across media changes
authorKevin Shanahan <kmshanah@disenchant.net>
Thu, 20 Sep 2012 23:20:22 +0000 (08:50 +0930)
committerKevin Wolf <kwolf@redhat.com>
Mon, 24 Sep 2012 13:15:11 +0000 (15:15 +0200)
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

index 7c83baa353ca11e10af5d6b241aec219d94ff11d..e5d450f0bb9ac199c4524b66752d60a17994dde6 100644 (file)
@@ -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;