From patchwork Fri Feb 15 17:46:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 220810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1A7992C0085 for ; Sat, 16 Feb 2013 05:55:50 +1100 (EST) Received: from localhost ([::1]:51861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6QRo-00068M-BB for incoming@patchwork.ozlabs.org; Fri, 15 Feb 2013 13:55:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6POH-0006Dr-8M for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:48:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6PNy-0004G4-FZ for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:48:02 -0500 Received: from mail-vc0-f175.google.com ([209.85.220.175]:62929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6PNy-0004Fr-9q for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:47:46 -0500 Received: by mail-vc0-f175.google.com with SMTP id fw7so2333615vcb.6 for ; Fri, 15 Feb 2013 09:47:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=hJmsUKds1YVYR9HUy/73LMQIs8D70EHXi++Wzjgwz5c=; b=xWGPmBIV9XyeL4zgtYdhlB1tq9y9xsOSa53wDZm8m6nFCcb+NFkKgynq7RIXUVaCxj eZG/Ir8B8nhC+pWqWPDK+nBhCw3VrECbde0ckhLe8xvfORQ6C0wbe7lJLqKjUw3QKcgy K+2cnDUjd+Sfn6z+8kBjuK3XJA0kPGumhkXW7u3JziniQaKSpLcm4xCvLk8TNO9eAg96 wM5KX6Y6m89ye7FcCxamOtbylfqmOTbtQvFDcYXFHXnvWicD5XL+0jHZHLcCP6FGveNA 2XicZvAUkCkxLpo2OHkFaoeVaqJtD+VdVAFUQw1p8zJc22mAaD5ELHxvCXbSQhUcWBaw 93Rw== X-Received: by 10.221.9.136 with SMTP id ow8mr4218614vcb.58.1360950463248; Fri, 15 Feb 2013 09:47:43 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id yu12sm65402142vec.6.2013.02.15.09.47.41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 15 Feb 2013 09:47:42 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 15 Feb 2013 18:46:42 +0100 Message-Id: <1360950433-17106-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360950433-17106-1-git-send-email-pbonzini@redhat.com> References: <1360950433-17106-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.175 Cc: owasserm@redhat.com, chegu_vinod@hp.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 10/41] migration: use qemu_file_set_error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Remove the return value of buffered_flush, pass it via the error code of s->file. Once this is done, the error can be retrieved simply via migrate_fd_close's call to qemu_fclose. Signed-off-by: Paolo Bonzini Reviewed-by: Orit Wasserman Reviewed-by: Juan Quintela --- migration.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-) diff --git a/migration.c b/migration.c index 609bd7c..6834d61 100644 --- a/migration.c +++ b/migration.c @@ -518,7 +518,7 @@ int64_t migrate_xbzrle_cache_size(void) /* migration thread support */ -static ssize_t buffered_flush(MigrationState *s) +static void buffered_flush(MigrationState *s) { size_t offset = 0; ssize_t ret = 0; @@ -545,9 +545,8 @@ static ssize_t buffered_flush(MigrationState *s) s->buffer_size -= offset; if (ret < 0) { - return ret; + qemu_file_set_error(s->file, ret); } - return offset; } static int buffered_put_buffer(void *opaque, const uint8_t *buf, @@ -586,25 +585,15 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, static int buffered_close(void *opaque) { MigrationState *s = opaque; - ssize_t ret = 0; - int ret2; DPRINTF("closing\n"); s->xfer_limit = INT_MAX; while (!qemu_file_get_error(s->file) && s->buffer_size) { - ret = buffered_flush(s); - if (ret < 0) { - break; - } - } - - ret2 = migrate_fd_close(s); - if (ret >= 0) { - ret = ret2; + buffered_flush(s); } s->complete = true; - return ret; + return migrate_fd_close(s); } static int buffered_get_fd(void *opaque) @@ -741,7 +730,8 @@ static void *buffered_file_thread(void *opaque) /* usleep expects microseconds */ g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); } - ret = buffered_flush(s); + buffered_flush(s); + ret = qemu_file_get_error(s->file); } if (ret < 0) {