From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWUtB-0007oz-UN for qemu-devel@nongnu.org; Mon, 21 May 2012 11:51:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWUt1-00026k-CJ for qemu-devel@nongnu.org; Mon, 21 May 2012 11:51:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWUt1-00024E-4N for qemu-devel@nongnu.org; Mon, 21 May 2012 11:51:07 -0400 Message-ID: <4FBA6464.8040206@redhat.com> Date: Mon, 21 May 2012 17:51:00 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1337192134-31502-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> <1337192134-31502-3-git-send-email-morita.kazutaka@lab.ntt.co.jp> In-Reply-To: <1337192134-31502-3-git-send-email-morita.kazutaka@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1.1 2/4] sheepdog: fix return value of do_load_save_vm_state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: MORITA Kazutaka Cc: qemu-devel@nongnu.org Am 16.05.2012 20:15, schrieb MORITA Kazutaka: > bdrv_save_vmstate and bdrv_load_vmstate should return the number of > processed bytes on success. > > Signed-off-by: MORITA Kazutaka > --- > block/sheepdog.c | 8 ++++++-- > 1 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/block/sheepdog.c b/block/sheepdog.c > index 776a1cc..146a221 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -1932,7 +1932,7 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data, > int64_t pos, int size, int load) > { > int fd, create; > - int ret = 0; > + int ret = 0, done = 0; > unsigned int data_len; > uint64_t vmstate_oid; > uint32_t vdi_index; > @@ -1971,10 +1971,14 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data, > > pos += data_len; > size -= data_len; > - ret += data_len; > + done += data_len; > } > cleanup: > closesocket(fd); > + > + if (done) > + return done; Missing braces... > + > return ret; > } ...but I think if an error occurred, we should not return short reads/writes anyway, but instead return the error. Kevin