From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: [PATCH v6 3/4] vfio: vfio-pci device assignment driver Date: Fri, 05 Oct 2012 12:23:27 -0600 Message-ID: <1349461407.2112.28.camel@bling.home> References: <20120926171430.17208.46888.stgit@bling.home> <20120926171931.17208.43947.stgit@bling.home> <1349457070.2112.21.camel@bling.home> <1349458424.2112.25.camel@bling.home> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: aliguori@us.ibm.com, kvm@vger.kernel.org, aik@ozlabs.ru, jan.kiszka@siemens.com, qemu-devel@nongnu.org, avi@redhat.com To: Blue Swirl Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org On Fri, 2012-10-05 at 18:05 +0000, Blue Swirl wrote: > On Fri, Oct 5, 2012 at 5:33 PM, Alex Williamson > wrote: > > On Fri, 2012-10-05 at 17:22 +0000, Blue Swirl wrote: > >> On Fri, Oct 5, 2012 at 5:11 PM, Alex Williamson > >> wrote: > >> > On Fri, 2012-10-05 at 16:54 +0000, Blue Swirl wrote: > >> >> On Wed, Sep 26, 2012 at 5:19 PM, Alex Williamson > >> >> 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