From: Avi Kivity <avi@qumranet.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: kvm-devel@lists.sf.net, Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [PATCH] Use QEMU functions to access guest memory for virtio
Date: Wed, 26 Mar 2008 15:27:09 +0200 [thread overview]
Message-ID: <47EA4F2D.5050703@qumranet.com> (raw)
In-Reply-To: <1206481168-7185-1-git-send-email-aliguori@us.ibm.com>
Anthony Liguori wrote:
> virtio is currently pretty sloppy about accessing guest memory directly. This
> is problematic both because phys_ram_base + PA is not only valid but also
> because it requires the host and guest both be of the same endianness.
>
> This patch converts virtio to use the QEMU st/ld functions to manipulate the
> ring queues. I've tested both virtio-blk and virtio-net. I've also confirm
> that performance doesn't regress with virtio-net.
>
> We still use phys_ram_base to create the struct iovec to handle IO operations.
> I'm still trying to think of a way to eliminate that that doesn't involve an
> unnecessary copy or a full blown DMA API.
>
I don't think a full blown dma api is that horrible. You need a
function that translates a phys vectors to iovecs. A slight
complication is that the vectors can be of different sizes, but it's
still not that bad.
If we add memory hotplug later, we need to lock it out when dma is
happening, so it's best to add a dummy release function.
> This patch should make it easier to use virtio with QEMU (in the absence of
> KVM).
>
> +
> +static uint64_t vring_desc_addr(VirtQueue *vq, unsigned int i)
> +{
> + return ldq_phys(vq->vring.desc + i * 16 + 0);
> +}
>
#define s_ld_u64(phys, field, type) \
ldq_phys(phys + offsetof(field, type))
And now we don't need individual accessors, or to encode the offsets as
magic numbers.
An additional bonus is that the code is endian safe now.
If the qemu translation lookup is slow, there are ways to speed it up,
so I'm not worried about speed.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
next prev parent reply other threads:[~2008-03-26 13:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-25 21:39 [PATCH] Use QEMU functions to access guest memory for virtio Anthony Liguori
2008-03-26 13:27 ` Avi Kivity [this message]
2008-03-26 14:23 ` Anthony Liguori
2008-03-26 14:32 ` Avi Kivity
2008-03-26 14:41 ` Anthony Liguori
2008-03-29 21:49 ` Anthony Liguori
2008-03-30 10:51 ` Avi Kivity
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=47EA4F2D.5050703@qumranet.com \
--to=avi@qumranet.com \
--cc=aliguori@us.ibm.com \
--cc=aurelien@aurel32.net \
--cc=kvm-devel@lists.sf.net \
/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