From patchwork Tue Jun 23 10:44:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitris Aragiorgis X-Patchwork-Id: 487575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 977C01401AD for ; Tue, 23 Jun 2015 20:46:08 +1000 (AEST) Received: from localhost ([::1]:44479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7LiP-00076t-7B for incoming@patchwork.ozlabs.org; Tue, 23 Jun 2015 06:46:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7Lhu-0006VP-6m for qemu-devel@nongnu.org; Tue, 23 Jun 2015 06:45:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7Lht-00060K-2j for qemu-devel@nongnu.org; Tue, 23 Jun 2015 06:45:34 -0400 Received: from mx0.arrikto.com ([2a01:7e00::f03c:91ff:fe6e:d7ab]:55808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7Lhp-0005n7-Ej; Tue, 23 Jun 2015 06:45:29 -0400 Received: from troi.arr-srv (mail.arr-srv [192.168.98.4]) by mx0.arrikto.com (Postfix) with ESMTP id 49B54A090; Tue, 23 Jun 2015 13:45:26 +0300 (EEST) Received: from lenovo.loc (unknown [192.168.94.120]) by troi.arr-srv (Postfix) with ESMTPSA id DBD3029F; Tue, 23 Jun 2015 13:45:25 +0300 (EEST) From: Dimitris Aragiorgis To: qemu-devel@nongnu.org Date: Tue, 23 Jun 2015 13:44:57 +0300 Message-Id: <1435056300-14924-3-git-send-email-dimara@arrikto.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1435056300-14924-1-git-send-email-dimara@arrikto.com> References: <1435056300-14924-1-git-send-email-dimara@arrikto.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:7e00::f03c:91ff:fe6e:d7ab Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v5 2/5] Fix migration in case of scsi-generic 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 During migration, QEMU uses fsync()/fdatasync() on the open file descriptor for read-write block devices to flush data just before stopping the VM. However, fsync() on a scsi-generic device returns -EINVAL which causes the migration to fail. This patch skips flushing data in case of an SG device, since submitting SCSI commands directly via an SG character device (e.g. /dev/sg0) bypasses the page cache completely, anyway. Note that fsync() not only flushes the page cache but also the disk cache. The scsi-generic device never sends flushes, and for migration it assumes that the same SCSI device is used by the destination host, so it does not issue any SCSI SYNCHRONIZE CACHE (10) command. Finally, remove the bdrv_is_sg() test from iscsi_co_flush() since this is now redundant (we flush the underlying protocol at the end of bdrv_co_flush() which, with this patch, we never reach). Signed-off-by: Dimitris Aragiorgis Reviewed-by: Stefan Hajnoczi --- block/io.c | 3 ++- block/iscsi.c | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/block/io.c b/block/io.c index bb4f787..f45a3ad 100644 --- a/block/io.c +++ b/block/io.c @@ -2255,7 +2255,8 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs) { int ret; - if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) { + if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs) || + bdrv_is_sg(bs)) { return 0; } diff --git a/block/iscsi.c b/block/iscsi.c index 000528c..62e422e 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -627,10 +627,6 @@ static int coroutine_fn iscsi_co_flush(BlockDriverState *bs) IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; - if (bdrv_is_sg(bs)) { - return 0; - } - if (!iscsilun->force_next_flush) { return 0; }