Received: from eggs.gnu.org ([2001:4830:134:3::10]:60372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VW0wW-00030U-Fl for qemu-devel@nongnu.org; Tue, 15 Oct 2013 05:29:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VW0wQ-00088u-1G for qemu-devel@nongnu.org; Tue, 15 Oct 2013 05:29:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VW0wP-00088d-Op for qemu-devel@nongnu.org; Tue, 15 Oct 2013 05:29:25 -0400 Date: Tue, 15 Oct 2013 17:29:22 +0800 From: Fam Zheng Message-ID: <20131015092922.GA6157@T430s.nay.redhat.com> References: <1381800446-3937-1-git-send-email-famz@redhat.com> <20131015091348.GB3039@dhcp-200-207.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131015091348.GB3039@dhcp-200-207.str.redhat.com> Subject: Re: [Qemu-devel] [PATCH] blockdev: fix cdrom read_only flag Reply-To: famz@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, stefanha@redhat.com, edivaldoapereira@yahoo.com.br On Tue, 10/15 11:13, Kevin Wolf wrote: > Am 15.10.2013 um 03:27 hat Fam Zheng geschrieben: > > 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 > > --- > > blockdev.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/blockdev.c b/blockdev.c > > index 4f76e28..7f5ef4a 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", read_only); > > I believe we must move this line to above the media=... handling for > compatibility with old versions. Or actually, using |= instead of = may > be enough. > > The reason is this command line: > > -drive file=test.iso,media=cdrom,readonly=off > > Which, "obviously", means that a read-only CD-ROM device should be > created. > Oh, I didn't notice readony=off means a read-only CD-ROM before... Fam