From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG9ce-0007AR-5V for qemu-devel@nongnu.org; Mon, 24 Sep 2012 10:27:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TG9cc-00076r-5h for qemu-devel@nongnu.org; Mon, 24 Sep 2012 10:26:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG9cb-00076m-TU for qemu-devel@nongnu.org; Mon, 24 Sep 2012 10:26:54 -0400 From: Kevin Wolf Date: Mon, 24 Sep 2012 16:26:30 +0200 Message-Id: <1348496808-8159-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1348496808-8159-1-git-send-email-kwolf@redhat.com> References: <1348496808-8159-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 01/19] blockdev: preserve readonly and snapshot states across media changes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Kevin Shanahan 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 --- blockdev.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) 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; -- 1.7.6.5