qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] virtio: make bindings typesafe


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH] virtio: make bindings typesafe
Date: Mon, 17 Dec 2012 18:55:46 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

Am 17.12.2012 16:45, schrieb Michael S. Tsirkin:
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index 3ea4140..63ae888 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -98,34 +98,34 @@ bool virtio_is_big_endian(void);
>  
>  /* virtio device */
>  
> -static void virtio_pci_notify(void *opaque, uint16_t vector)
> +static void virtio_pci_notify(DeviceState *d, uint16_t vector)
>  {
> -    VirtIOPCIProxy *proxy = opaque;
> +    VirtIOPCIProxy *proxy = container_of(d, VirtIOPCIProxy, pci_dev.qdev);

Nack. This is going the wrong direction QOM-wise and you among all
others know that from PCI host bridges!

A core issue being addressed here is that virtio devices are modelled
neither in the regular qdev way nor the QOM way. They don't inherit
correctly and use their own set of common-init functions - one side
effect of Fred's series was to make them first-class QOM citizens. QOM
like qdev doesn't support multi-inheritence, so the discussed approach
Fred is trying to implement is to have both a VirtioDevice as base class
for Virtio{Block,...}Device and PCIDevice/SysBusDevice/... as base class
for a virtio bridge device with a virtio-bus, on which only virtio is
spoken and pure VirtioDevices can sit (which as you say have device IDs
but not all PCI properties).
What remained under discussion AFAIU was how to expose this modelling
construct to the user - Peter aiming to expose this to the user and me
proposing to hide this (for PCI) as an internal implementation detail.

Whether DeviceState or a new VirtioDevice or something else is being
used in the API is a different issue that I don't really mind.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]