"Michael S. Tsirkin" <m...@redhat.com> wrote:
> On Wed, Dec 02, 2009 at 01:04:04PM +0100, Juan Quintela wrote:
>> virtio_common_init() creates a struct with the right size, DO_UPCAST
>> is the appropiate thing here
>> 
>> Signed-off-by: Juan Quintela <quint...@redhat.com>
>
> BTW why not container_of? That one does not require
> field to be at the beginning of structure.

VirtIO devices (and PCIDevices) are declared in this way:

typedef struct VirtIOBalloon
{
    VirtIODevice vdev;
    VirtQueue *ivq, *dvq;
    uint32_t num_pages;
    uint32_t actual;
} VirtIOBalloon;


I.e. the virtioDevice is always the 1st element, otherwise things don't
work.  There are code that requires it to be the 1st element.

Later, Juan.



Reply via email to