qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: aayush gupta <aayushgupta.84@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Query regarding IO paths in QEMU
Date: Wed, 1 May 2013 11:30:00 +0200	[thread overview]
Message-ID: <20130501093000.GA21804@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAFBtnvRN6ESwHAihXEBwxK_pMiM06B87kvKG1wjPAqksJFq=wg@mail.gmail.com>

On Mon, Apr 29, 2013 at 10:02:34AM -0700, aayush gupta wrote:
> I am trying to understand the IO paths in QEMU (which I understand emulates
> IO for KVM) to have a better idea of how it works and get a clear picture
> of how I can trap all read/write requests being issued by the VM in the
> QEMU block layer for a project that I am working on.
> 
> For example, lets say that we use QCOW2 image format for VMs. Looking into
> the code, I was able to track the requests as follows:
> 
> bdrv_read() -> bdrv_rw_co() -> bdrv_rw_co_entry() -> bdrv_co_do_readv() ->
> this calls into driver specific functions

Emulated devices typically use bdrv_aio_readv() instead of the
synchronous bdrv_read() function.  bdrv_read() would block the guest
until the disk operation completes.

The model is:

Storage controllers (IDE, SCSI, virtio, etc) are emulated by QEMU in
hw/.  The storage controller has a pointer to a BlockDriverState, which
is the block device.

BlockDriverStates can form a tree.  For example, a qcow2 file actually
involves a raw file BlockDriverState and the qcow2 format
BlockDriverState.  The storage controller has a pointer to the qcow2
format BlockDriverState.  The qcow2 code invokes I/O operations on its
bs->file field, which will be the raw file BlockDriverState.

This abstraction makes it possible to use qcow2 on top of a Sheepdog
volume, for example.

Also, take a look at docs/tracing.txt.  There are pre-defined trace
events for block I/O operations.  This may be enough to instrument what
you need.

Stefan

  reply	other threads:[~2013-05-01  9:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29 17:02 [Qemu-devel] Query regarding IO paths in QEMU aayush gupta
2013-05-01  9:30 ` Stefan Hajnoczi [this message]
2013-05-06 21:36   ` aayush gupta
2013-05-09  5:51     ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130501093000.GA21804@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=aayushgupta.84@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).