From patchwork Fri Feb 15 17:46:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 220823 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 68F402C0085 for ; Sat, 16 Feb 2013 06:17:16 +1100 (EST) Received: from localhost ([::1]:52778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6POa-0006bm-KB for incoming@patchwork.ozlabs.org; Fri, 15 Feb 2013 12:48:24 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6PO3-0005aS-Uy for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:48:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6PNr-0004DA-Op for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:47:51 -0500 Received: from mail-ve0-f182.google.com ([209.85.128.182]:41630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6PNr-0004D3-JL for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:47:39 -0500 Received: by mail-ve0-f182.google.com with SMTP id ox1so3336934veb.41 for ; Fri, 15 Feb 2013 09:47:39 -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=ilHvVtH3hDxVrsJvM1VpJqkqdnbsmQIH5ny0Q04jryQ=; b=uImDRDUoGHMqDHR7hl84S1cRBMSJigAtVGhq60E+lqlAyrvTOK+YJfoeyg/C0uPLm1 5JhEDjH9yU/l6KJSDxP4LmabupAd2SPjumKoRAZ0CPCIfliUxAvFavAkow4zB5j9hH4M UrQ8yp+MqI7EJBFO1t2p+92uY0GxBAeQhJ8Boy74+S812osgI5vgoQtPsv3Wyqwe8sG6 UtCq+0YSJXeBR1kTRX/Bob76IyCIaKXC5fCrZ33q0e6QU2wkgGydGAsMgsEkGNuYrd2d u+Jc9n8nJIDoWp5YUESY0JVrv+IRSeKFxMBnJI/sxpxOX3rX/FNsprQ/arDRvI5LN2D3 VwSQ== X-Received: by 10.52.23.18 with SMTP id i18mr3823651vdf.46.1360950459121; Fri, 15 Feb 2013 09:47:39 -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.37 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 15 Feb 2013 09:47:38 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 15 Feb 2013 18:46:40 +0100 Message-Id: <1360950433-17106-9-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.128.182 Cc: owasserm@redhat.com, chegu_vinod@hp.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 08/41] qemu-file: temporarily expose qemu_file_set_error and qemu_fflush 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 Right now, migration cannot entirely rely on QEMUFile's automatic drop of I/O after an error, because it does its "real" I/O outside the put_buffer callback. To fix this until buffering is gone, expose qemu_file_set_error which we will use in buffered_flush. Similarly, buffered_flush is not a complete flush because some data may still reside in the QEMUFile's own buffer. This somewhat complicates the process of closing the migration thread. Again, when buffering is gone buffered_flush will disappear and calling qemu_fflush will not be needed; in the meanwhile, we expose the function for use in migration.c. Signed-off-by: Paolo Bonzini Reviewed-by: Orit Wasserman Reviewed-by: Juan Quintela --- include/migration/qemu-file.h | 2 ++ savevm.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index 46fc11d..5e0c287 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -82,6 +82,7 @@ QEMUFile *qemu_popen_cmd(const char *command, const char *mode); int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); int64_t qemu_ftell(QEMUFile *f); +void qemu_fflush(QEMUFile *f); void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); void qemu_put_byte(QEMUFile *f, int v); @@ -113,6 +114,7 @@ int qemu_file_rate_limit(QEMUFile *f); int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); int64_t qemu_file_get_rate_limit(QEMUFile *f); int qemu_file_get_error(QEMUFile *f); +void qemu_file_set_error(QEMUFile *f, int ret); static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) { diff --git a/savevm.c b/savevm.c index a1690b4..e10a045 100644 --- a/savevm.c +++ b/savevm.c @@ -443,7 +443,7 @@ int qemu_file_get_error(QEMUFile *f) return f->last_error; } -static void qemu_file_set_error(QEMUFile *f, int ret) +void qemu_file_set_error(QEMUFile *f, int ret) { if (f->last_error == 0) { f->last_error = ret; @@ -453,7 +453,7 @@ static void qemu_file_set_error(QEMUFile *f, int ret) /** Flushes QEMUFile buffer * */ -static void qemu_fflush(QEMUFile *f) +void qemu_fflush(QEMUFile *f) { int ret = 0;