From: Greg Kurz <gkurz@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: kwolf@redhat.com, peter.maydell@linaro.org,
thuth@linux.vnet.ibm.com, mst@redhat.com, marc.zyngier@arm.com,
rusty@rustcorp.com.au, agraf@suse.de, qemu-devel@nongnu.org,
anthony@codemonkey.ws, cornelia.huck@de.ibm.com,
pbonzini@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v5 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio
Date: Tue, 25 Feb 2014 16:59:36 +0100 [thread overview]
Message-ID: <20140225165936.2f4e9e0f@bahia.local> (raw)
In-Reply-To: <20140225152121.GA2374@stefanha-thinkpad.redhat.com>
On Tue, 25 Feb 2014 16:21:21 +0100
Stefan Hajnoczi <stefanha@redhat.com> wrote:
> On Fri, Feb 21, 2014 at 12:28:11PM +0100, Greg Kurz wrote:
> > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > index aeabf3a..4fd6ac2 100644
> > --- a/hw/virtio/virtio.c
> > +++ b/hw/virtio/virtio.c
> > @@ -19,6 +19,9 @@
> > #include "hw/virtio/virtio.h"
> > #include "qemu/atomic.h"
> > #include "hw/virtio/virtio-bus.h"
> > +#include "hw/virtio/virtio-access.h"
> > +
> > +bool virtio_byteswap;
> >
> > /*
> > * The alignment to use between consumer and producer parts of vring.
> > @@ -546,6 +549,9 @@ void virtio_reset(void *opaque)
> >
> > virtio_set_status(vdev, 0);
> >
> > + /* We assume all devices are the same endian. */
> > + virtio_byteswap = virtio_get_byteswap();
> > +
> > if (k->reset) {
> > k->reset(vdev);
> > }
>
> In the previous version it was pointed out that the global is nasty.
>
> A cleaner solution is a per-VirtIODevice enum device_endian value which
> gets passed to lduw_phys_internal()/stl_phys_internal()/etc.
>
> Now the same code can be used for:
> 1. Host == guest-endian
> 2. Host != guest-endian
> 3. "Everything is little-endian" (VIRTIO 1.0)
>
> Keeping it per-device means we can have both legacy and VIRTIO 1.0
> devices in a guest.
>
> That's better than hacking in a global now and having to undo it when
> VIRTIO 1.0 support gets merged.
>
> Stefan
>
Stefan,
I was unsure whether people wanted that global (nasty indeed) to be kicked
out of the picture right now or later. Things are clearer now. :)
I will come back with something more appropriate.
Thanks for your time.
Regards.
--
Gregory Kurz kurzgreg@fr.ibm.com
gkurz@linux.vnet.ibm.com
Software Engineer @ IBM/Meiosys http://www.ibm.com
Tel +33 (0)562 165 496
"Anarchy is about taking complete responsibility for yourself."
Alan Moore.
next prev parent reply other threads:[~2014-02-25 16:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-21 11:28 [Qemu-devel] [PATCH v5 0/8] virtio endian-ambivalent target fixes Greg Kurz
2014-02-21 11:28 ` [Qemu-devel] [PATCH v5 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio Greg Kurz
2014-02-25 15:21 ` Stefan Hajnoczi
2014-02-25 15:59 ` Greg Kurz [this message]
2014-02-21 11:28 ` [Qemu-devel] [PATCH v5 2/8] virtio: allow byte swapping for vring and config access Greg Kurz
2014-02-21 11:28 ` [Qemu-devel] [PATCH v5 3/8] virtio-net: use virtio wrappers to access headers Greg Kurz
2014-02-21 11:28 ` [Qemu-devel] [PATCH v5 4/8] virtio-balloon: use virtio wrappers to access page frame numbers Greg Kurz
2014-02-21 11:28 ` [Qemu-devel] [PATCH v5 5/8] virtio-blk: use virtio wrappers to access headers Greg Kurz
2014-02-21 11:28 ` [Qemu-devel] [PATCH v5 6/8] virtio-scsi: " Greg Kurz
2014-02-21 11:28 ` [Qemu-devel] [PATCH v5 7/8] virtio-serial-bus: " Greg Kurz
2014-02-21 11:29 ` [Qemu-devel] [PATCH v5 8/8] virtio-9p: " Greg Kurz
2014-02-25 15:22 ` [Qemu-devel] [PATCH v5 0/8] virtio endian-ambivalent target fixes 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=20140225165936.2f4e9e0f@bahia.local \
--to=gkurz@linux.vnet.ibm.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=anthony@codemonkey.ws \
--cc=cornelia.huck@de.ibm.com \
--cc=kwolf@redhat.com \
--cc=marc.zyngier@arm.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rusty@rustcorp.com.au \
--cc=stefanha@redhat.com \
--cc=thuth@linux.vnet.ibm.com \
/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).