Received: from eggs.gnu.org ([2001:4830:134:3::10]:33405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYPxs-0004Om-Jm for qemu-devel@nongnu.org; Thu, 10 Apr 2014 21:09:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYPxm-0005uu-EH for qemu-devel@nongnu.org; Thu, 10 Apr 2014 21:09:08 -0400 Date: Fri, 11 Apr 2014 09:09:07 +0800 From: Fam Zheng Message-ID: <20140411010907.GB19717@T430.nay.redhat.com> References: <1397151385-16730-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1397151385-16730-1-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH] block-commit: speed is an optional parameter List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi , qemu-stable@nongnu.org On Thu, 04/10 19:36, Max Reitz wrote: > As speed is an optional parameter for the QMP block-commit command, it > should be set to 0 if not given (as it is undefined if has_speed is > false), that is, the speed should not be limited. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > --- > This patch was previously part of the "qemu-img: Implement commit like > QMP" series, but as this is a general bugfix, it has been separated. > --- Reviewed-by: Fam Zheng The (generated) caller qmp_marshal_input_block_commit() actually leaves speed uninitialized, so we're not safe without this patch: int qmp_marshal_input_block_commit(Monitor *mon, const QDict *qdict, QObject **ret) { Error *local_err = NULL; Error **errp = &local_err; QDict *args = (QDict *)qdict; QmpInputVisitor *mi; QapiDeallocVisitor *md; Visitor *v; char * device = NULL; bool has_base = false; char * base = NULL; char * top = NULL; bool has_speed = false; int64_t speed; I'm wondering what the reason is to initialize pointers (like base and device) while leaving int64_t values uninitilized in the code generator? Fam > blockdev.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/blockdev.c b/blockdev.c > index c3422a1..5dd01ea 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1876,6 +1876,10 @@ void qmp_block_commit(const char *device, > */ > BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT; > > + if (!has_speed) { > + speed = 0; > + } > + > /* drain all i/o before commits */ > bdrv_drain_all(); > > -- > 1.9.1 > >