qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [SeaBIOS] [PATCH 03/18] virtio: add struct vp_device


From: Kevin O'Connor
Subject: Re: [Qemu-devel] [SeaBIOS] [PATCH 03/18] virtio: add struct vp_device
Date: Mon, 29 Jun 2015 08:48:24 -0400
User-agent: Mutt/1.5.23 (2014-03-12)

On Mon, Jun 29, 2015 at 10:53:25AM +0200, Gerd Hoffmann wrote:
> For virtio 1.0 support we will need more state than just the (legacy
> mode) ioaddr for each virtio-pci device.  Prepare for that by adding
> a new struct for it.  For now it carries the ioaddr only.
> 
> Signed-off-by: Gerd Hoffmann <address@hidden>
> ---
>  src/hw/virtio-blk.c  | 20 ++++++++++----------
>  src/hw/virtio-pci.c  | 15 +++++++++------
>  src/hw/virtio-pci.h  | 46 +++++++++++++++++++++++++++-------------------
>  src/hw/virtio-ring.c |  4 ++--
>  src/hw/virtio-ring.h |  3 ++-
>  src/hw/virtio-scsi.c | 32 +++++++++++++++++---------------
>  6 files changed, 67 insertions(+), 53 deletions(-)
> 
> diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c
> index 15ac171..13cf09a 100644
> --- a/src/hw/virtio-blk.c
> +++ b/src/hw/virtio-blk.c
> @@ -25,7 +25,7 @@
>  struct virtiodrive_s {
>      struct drive_s drive;
>      struct vring_virtqueue *vq;
> -    u16 ioaddr;
> +    struct vp_device *vp;
>  };

Is there a reason to make this a pointer as opposed to just placing
the vp_device struct directly in struct virtiodrive_s?

> -u16 vp_init_simple(u16 bdf)
> +struct vp_device *vp_init_simple(u16 bdf)
>  {
> -    u16 ioaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0) &
> +    struct vp_device *vp = malloc_low(sizeof(*vp));
> +
> +    vp->ioaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0) &
>          PCI_BASE_ADDRESS_IO_MASK;

If it has to be a pointer, then the result of malloc_low() has to be
checked for NULL.  Though, I don't think malloc_low() makes sense if
it's a 32bit driver.

-Kevin



reply via email to

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