From patchwork Tue Feb 6 16:30:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 10203315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C90360327 for ; Tue, 6 Feb 2018 16:32:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 349F728CBB for ; Tue, 6 Feb 2018 16:32:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 278AD28CC4; Tue, 6 Feb 2018 16:32:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B944028CBB for ; Tue, 6 Feb 2018 16:32:11 +0000 (UTC) Received: from localhost ([::1]:35654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej6AE-0000on-IL for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Feb 2018 11:32:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej69E-0008V8-JL for qemu-devel@nongnu.org; Tue, 06 Feb 2018 11:31:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej69C-0007mB-0H for qemu-devel@nongnu.org; Tue, 06 Feb 2018 11:31:08 -0500 Received: from smtp.citrix.com ([66.165.176.89]:54381) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1ej69B-0007jy-PE for qemu-devel@nongnu.org; Tue, 06 Feb 2018 11:31:05 -0500 X-IronPort-AV: E=Sophos;i="5.46,469,1511827200"; d="scan'208";a="461484159" From: Ross Lagerwall To: Juan Quintela , "Dr. David Alan Gilbert" Date: Tue, 6 Feb 2018 16:30:39 +0000 Message-ID: <20180206163039.23661-1-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.9.5 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Subject: [Qemu-devel] [PATCH] migration/xen: Check return value of qemu_fclose X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ross Lagerwall , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP QEMUFile uses buffered IO so when writing small amounts (such as the Xen device state file), the actual write call and any errors that may occur only happen as part of qemu_fclose(). Therefore, report IO errors when saving the device state under Xen by checking the return value of qemu_fclose(). Signed-off-by: Ross Lagerwall Reviewed-by: Dr. David Alan Gilbert --- migration/savevm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index b7908f6..4b9d5be 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2267,8 +2267,7 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live, qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state"); f = qemu_fopen_channel_output(QIO_CHANNEL(ioc)); ret = qemu_save_device_state(f); - qemu_fclose(f); - if (ret < 0) { + if (ret < 0 || qemu_fclose(f) < 0) { error_setg(errp, QERR_IO_ERROR); } else { /* libxl calls the QMP command "stop" before calling