[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] About the host page cache inside the qemu

From: Dunrong Huang
Subject: Re: [Qemu-discuss] About the host page cache inside the qemu
Date: Thu, 24 Oct 2013 13:34:18 +0800

On Thu, Oct 24, 2013 at 11:36 AM, Yaodong Yang <address@hidden> wrote:
Hi all,

I read the slides "An Update Overview of the QEMU Storage Stack", which indicate that if caching mode=none, the host page cache is off and guest disk write cache is on. My question is where the implementation is inside the qemu. How to control the io to a virtual disk image( a raw disk on top of the ext4 in the host filesysytem)

My understanding is the ios from qemu are sent to the host linux system call, the virtual disk is basically a normal file in the host filesystem, how the qemu can perform the ios to this file bypassing the host page cache.
From the file block/raw-posix.c
static void raw_parse_flags(int bdrv_flags, int *open_flags)
    /* Use O_DSYNC for write-through caching, no flags for write-back caching,
     * and O_DIRECT for no caching. */
    if ((bdrv_flags & BDRV_O_NOCACHE)) {
        *open_flags |= O_DIRECT;
You can take a look at manpage for open, which says:
O_DIRECT (Since Linux 2.4.10)
         Try to minimize cache effects of the I/O to and from this file.  In general this will degrade performance, but it is useful in special situations,  such  as
         when  applications  do  their  own  caching.  File I/O is done directly to/from user space buffers.  The I/O is synchronous, that is, at the completion of a
         read(2) or write(2), data is guaranteed to have been transferred.  See NOTES below for further discussion.

         A semantically similar (but deprecated) interface for block devices is described in raw(8).

Thanks a lot!


Best Regards,

Dunrong Huang 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]