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 11:33:44 -0600 [thread overview]
Message-ID: <1349458424.2112.25.camel@bling.home> (raw)
In-Reply-To: <CAAu8pHtHwwKFw8YpEY=XB6ipBHYspotX+zEY5pDjUkOsvu_rLA@mail.gmail.com>
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,
Alex
> > Where data is the start of a variable sized array. The data type of the
> > array depends on the flags. The purpose of VFIOIRQSetFD is simply to
> > make a data type that I don't need to dynamically allocate. You can
> > find other cases for MSI and MSIX where we don't know the array size and
> > do malloc the whole structure. For this interrupt type we know there's
> > only one entry. If there's a better way to do this, let me know. VFIO
> > is only available on Linux hosts, so I have no particular reason to
> > avoid GNU extensions.
> >
> >> > +
> >> > +static int vfio_enable_intx(VFIODevice *vdev)
> >> > +{
> >> > + VFIOIRQSetFD irq_set_fd = {
> >> > + .irq_set = {
> >> > + .argsz = sizeof(irq_set_fd),
> >> > + .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER,
> >> > + .index = VFIO_PCI_INTX_IRQ_INDEX,
> >> > + .start = 0,
> >> > + .count = 1,
> >> > + },
> >>
> >> Here the field is not even initialized.
> >
> > It's initialized later...
> >
> >> > + };
> >> > + uint8_t pin = vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1);
> >> > + int ret;
> >> > +
> >> > + if (vdev->intx.disabled || !pin) {
> >> > + return 0;
> >> > + }
> >> > +
> >> > + vfio_disable_interrupts(vdev);
> >> > +
> >> > + vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */
> >> > + ret = event_notifier_init(&vdev->intx.interrupt, 0);
> >> > + if (ret) {
> >> > + error_report("vfio: Error: event_notifier_init failed\n");
> >> > + return ret;
> >> > + }
> >> > +
> >> > + irq_set_fd.fd = event_notifier_get_fd(&vdev->intx.interrupt);
> >
> > Here.
> >
> > Thanks,
> > Alex
> >
next prev parent reply other threads:[~2012-10-05 17:33 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 [this message]
2012-10-05 18:05 ` Blue Swirl
2012-10-05 18:23 ` Alex Williamson
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=1349458424.2112.25.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).