From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a436Y-0003nf-BV for qemu-devel@nongnu.org; Wed, 02 Dec 2015 03:49:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a436T-0000TS-DA for qemu-devel@nongnu.org; Wed, 02 Dec 2015 03:49:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55535) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a436T-0000TI-7x for qemu-devel@nongnu.org; Wed, 02 Dec 2015 03:49:33 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A0AB8C0CC646 for ; Wed, 2 Dec 2015 08:49:32 +0000 (UTC) Date: Wed, 2 Dec 2015 16:49:20 +0800 From: Peter Xu Message-ID: <20151202084919.GD19485@pxdev.xzpeter.org> References: <1448976530-15984-1-git-send-email-peterx@redhat.com> <1448976530-15984-10-git-send-email-peterx@redhat.com> <20151202013257.GF9399@ad.usersys.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20151202013257.GF9399@ad.usersys.redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 09/11] DumpState: adding total_size and written_size fields List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: drjones@redhat.com, lersek@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com, lcapitulino@redhat.com On Wed, Dec 02, 2015 at 09:32:57AM +0800, Fam Zheng wrote: > On Tue, 12/01 21:28, Peter Xu wrote: > > @@ -333,6 +333,8 @@ static void write_data(DumpState *s, void *buf, int length, Error **errp) > > if (ret < 0) { > > error_setg(errp, "dump: failed to save memory"); > > } > > + > > + s->written_size += length; > > If (ret < 0), the incremental is inaccurate, do we want an accurate > written_size in that case? I.e. put this in "else" branch? Yes, I think I'd better put it into an else block... Thanks. Actually even that could not be accurate, since the write() could be partly done and failed. But I hope that's good enough for dump status queries. :) > > > } > > > > /* write the memory to vmcore. 1 page per I/O. */ > > @@ -1301,6 +1303,7 @@ static void write_dump_pages(DumpState *s, Error **errp) > > goto out; > > } > > } > > + s->written_size += TARGET_PAGE_SIZE; > > The same question applies here. For kdump case, it is using "goto out" when error happens. So it seems to have no problem here? > > > } > > > > ret = write_cache(&page_desc, NULL, 0, true); > > @@ -1433,6 +1436,30 @@ bool dump_in_progress(void) > > return (state->status == DUMP_STATUS_ACTIVE); > > } > > > > +/* calculate total size of memory to be dumped (taking filter into > > + * acoount.) */ > > +static size_t dump_calculate_size(DumpState *s) > > Is size_t big enough for 64 bit guest on 32 bit host (with 4 bytes size_t)? Thanks to point out. Will use int64_t here (and also written_size and total_size). > > + size_t written_size; /* written memory size (in bytes), > > + * this could be used to calculate > > + * how many work we have > > s/many/much/ Will fix it. Thanks! Peter