Received: from eggs.gnu.org ([2001:4830:134:3::10]:48546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXAtF-0004yD-07 for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXAt8-0001vL-RY for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:18:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXAt8-0001ux-Hw for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:18:50 -0400 From: Stefan Hajnoczi Date: Fri, 18 Oct 2013 16:18:31 +0200 Message-Id: <1382105915-27735-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1382105915-27735-1-git-send-email-stefanha@redhat.com> References: <1382105915-27735-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 3/7] blockdev: fix cdrom read_only flag List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Fam Zheng , Stefan Hajnoczi , Anthony Liguori From: Fam Zheng Since 0ebd24e0, cdrom doesn't have read-only on by default, which will error out when using an read only image. Fix it by setting the default value when parsing opts. Reported-by: Edivaldo de Araujo Pereira Signed-off-by: Fam Zheng Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- blockdev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 4f76e28..b260477 100644 --- a/blockdev.c +++ b/blockdev.c @@ -625,7 +625,8 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) int cyls, heads, secs, translation; int max_devs, bus_id, unit_id, index; const char *devaddr; - bool read_only, copy_on_read; + bool read_only = false; + bool copy_on_read; Error *local_err = NULL; /* Change legacy command line options into QMP ones */ @@ -701,7 +702,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) media = MEDIA_DISK; } else if (!strcmp(value, "cdrom")) { media = MEDIA_CDROM; - qdict_put(bs_opts, "read-only", qstring_from_str("on")); + read_only = true; } else { error_report("'%s' invalid media", value); goto fail; @@ -709,7 +710,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) } /* copy-on-read is disabled with a warning for read-only devices */ - read_only = qemu_opt_get_bool(legacy_opts, "read-only", false); + read_only |= qemu_opt_get_bool(legacy_opts, "read-only", false); copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false); if (read_only && copy_on_read) { -- 1.8.3.1