qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: aliguori@us.ibm.com, kvm@vger.kernel.org, aik@ozlabs.ru,
	jan.kiszka@siemens.com, qemu-devel@nongnu.org, avi@redhat.com
Subject: Re: [Qemu-devel] [PATCH v6 3/4] vfio: vfio-pci device assignment driver
Date: Fri, 05 Oct 2012 12:23:27 -0600	[thread overview]
Message-ID: <1349461407.2112.28.camel@bling.home> (raw)
In-Reply-To: <CAAu8pHvqE-fbWTszWkL9+0=mJOzc=LzDxJaMERv8mKt3SxC=uw@mail.gmail.com>

On Fri, 2012-10-05 at 18:05 +0000, Blue Swirl wrote:
> On Fri, Oct 5, 2012 at 5:33 PM, Alex Williamson
> <alex.williamson@redhat.com> wrote:
> > On Fri, 2012-10-05 at 17:22 +0000, Blue Swirl wrote:
> >> On Fri, Oct 5, 2012 at 5:11 PM, Alex Williamson
> >> <alex.williamson@redhat.com> wrote:
> >> > On Fri, 2012-10-05 at 16:54 +0000, Blue Swirl wrote:
> >> >> On Wed, Sep 26, 2012 at 5:19 PM, Alex Williamson
> >> >> <alex.williamson@redhat.com> wrote:
> >> >> > +
> >> >> > +typedef struct QEMU_PACKED VFIOIRQSetFD {
> >> >> > +    struct vfio_irq_set irq_set;
> >> >> > +    int32_t fd;
> >> >> > +} VFIOIRQSetFD;
> >> >>
> >> >> I'm now getting this error from Clang:
> >> >>
> >> >> /src/qemu/hw/vfio_pci.c:126:25: error: field 'irq_set' with variable
> >> >> sized type 'struct vfio_irq_set' not at the end of a struct or class
> >> >> is a GNU extension [-Werror,-Wgnu]
> >> >>     struct vfio_irq_set irq_set;
> >> >>
> >> >> Does the kernel really use the fd field, isn't it implicit from the
> >> >> ioctl fd or are they different?
> >> >
> >> > The kernel side is defined as:
> >> >
> >> > struct vfio_irq_set {
> >> >         __u32   argsz;
> >> >         __u32   flags;
> >> >         __u32   index;
> >> >         __u32   start;
> >> >         __u32   count;
> >> >         __u8    data[];
> >> > };
> >>
> >> Then the kernel only expects vfio_irq_set structure, not VFIOIRQSetFD,
> >> so you should use &irq_set_fd.irq_set instead of &irq_set_fd for the
> >> ioctl(). Then VFIOIRQSetFD can be rearranged to have fd field first,
> >> also QEMU_PACKED is not necessary.
> >
> > Sorry, I was unclear.  The kernel sees fd as data[0], that's the point
> > of the structure, so re-arranging it makes it useless.  Thanks,
> 
> I see. The example in GCC shows how to statically initialize flexible
> array members properly but it does not seem to work:
> http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

That's not going to like that the data type is actually different for
this use case.

> Also, Clang does not like that syntax either.
> 
> Maybe it's best to use g_malloc with room for the extra int.

:(  Ok, I'll write a patch to make it dynamically allocated.  Thanks,

Alex

  reply	other threads:[~2012-10-05 18:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26 17:19 [Qemu-devel] [PATCH v6 0/4] VFIO-based PCI device assignment Alex Williamson
2012-09-26 17:19 ` [Qemu-devel] [PATCH v6 1/4] Update kernel header script to include vfio Alex Williamson
2012-09-26 17:19 ` [Qemu-devel] [PATCH v6 2/4] Update Linux kernel headers Alex Williamson
2012-09-26 17:19 ` [Qemu-devel] [PATCH v6 3/4] vfio: vfio-pci device assignment driver Alex Williamson
2012-10-01 17:22   ` Alex Barcelo
2012-10-05 16:54   ` Blue Swirl
2012-10-05 17:11     ` Alex Williamson
2012-10-05 17:22       ` Blue Swirl
2012-10-05 17:33         ` Alex Williamson
2012-10-05 18:05           ` Blue Swirl
2012-10-05 18:23             ` Alex Williamson [this message]
2012-09-26 17:19 ` [Qemu-devel] [PATCH v6 4/4] vfio: Enable vfio-pci and mark supported Alex Williamson
2012-10-01 16:06 ` [Qemu-devel] [PATCH v6 0/4] VFIO-based PCI device assignment Anthony Liguori

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=1349461407.2112.28.camel@bling.home \
    --to=alex.williamson@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --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).