From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnnjd-00009Q-U3 for qemu-devel@nongnu.org; Mon, 10 Nov 2014 07:06:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XnnjX-00071j-M1 for qemu-devel@nongnu.org; Mon, 10 Nov 2014 07:06:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnnjX-00071d-EI for qemu-devel@nongnu.org; Mon, 10 Nov 2014 07:06:11 -0500 Date: Mon, 10 Nov 2014 13:06:04 +0100 From: Kevin Wolf Message-ID: <20141110120604.GD4158@noname.str.redhat.com> References: <4e27237d.8773.14989687829.Coremail.magazine.lihuiba@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e27237d.8773.14989687829.Coremail.magazine.lihuiba@163.com> Subject: Re: [Qemu-devel] guest sync and bdrv_co_flush List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: lihuiba Cc: qemu-devel@nongnu.org Am 07.11.2014 um 09:39 hat lihuiba geschrieben: > Hi, all > > I'm a user of qemu/kvm, and I'm wondering some internals of qemu/kvm, so I'd > better post it in > this developer's mailing list. > > To be specific, I'm wondering how data is flushed to disk. Intuitively, when > the guest issues a > SYNCHRONIZE CACHE command in the SCSI layer, qemu/kvm should call bdrv_co_flush > (), > which will eventually call the block driver's bdrv_co_flush_to_os() > and bdrv_co_flush_to_disk(). > > But from simple grep-ing, I didn't find any calling to bdrv_co_flush() is > responsible for SYNCHRONIZE > CACHE. So, can you tell me how qemu/kvm ensures guest data be written on > persistent storage? The relevant code is in hw/scsi/scsi-disk.c, in the function scsi_disk_emulate_command(), for 'case SYNCHRONIZE_CACHE:'. The call chain from there is blk_aio_flush() -> bdrv_aio_flush() -> bdrv_aio_flush_co_entry() -> bdrv_co_flush() Kevin