diff mbox

[11/41] virtio: Introduce type field to distingish between PCI and Syborg

Message ID e8be14cc7693b7e42db3813f978f60bff25a814b.1259754427.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela Dec. 2, 2009, 12:04 p.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/syborg_virtio.c |    1 +
 hw/virtio-pci.c    |    2 +-
 hw/virtio.h        |    6 ++++++
 3 files changed, 8 insertions(+), 1 deletions(-)

Comments

Michael S. Tsirkin Dec. 2, 2009, 6:42 p.m. UTC | #1
On Wed, Dec 02, 2009 at 01:04:09PM +0100, Juan Quintela wrote:
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Let's just use binding for this.

> ---
>  hw/syborg_virtio.c |    1 +
>  hw/virtio-pci.c    |    2 +-
>  hw/virtio.h        |    6 ++++++
>  3 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
> index 6cf5a15..46ac192 100644
> --- a/hw/syborg_virtio.c
> +++ b/hw/syborg_virtio.c
> @@ -275,6 +275,7 @@ static int syborg_virtio_net_init(SysBusDevice *dev)
>      SyborgVirtIOProxy *proxy = FROM_SYSBUS(SyborgVirtIOProxy, dev);
> 
>      vdev = virtio_net_init(&dev->qdev, &proxy->nic);
> +    vdev->type = VIRTIO_SYBORG;
>      return syborg_virtio_init(proxy, vdev);
>  }
> 
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index 25b6380..a2179de 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -433,7 +433,7 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> 
>      pci_register_bar(&proxy->pci_dev, 0, size, PCI_BASE_ADDRESS_SPACE_IO,
>                             virtio_map);
> -
> +    vdev->type = VIRTIO_PCI;
>      virtio_bind_device(vdev, &virtio_pci_bindings, proxy);
>  }
> 
> diff --git a/hw/virtio.h b/hw/virtio.h
> index 15ad910..ec1ff4d 100644
> --- a/hw/virtio.h
> +++ b/hw/virtio.h
> @@ -88,6 +88,11 @@ typedef struct {
> 
>  #define VIRTIO_NO_VECTOR 0xffff
> 
> +typedef enum VirtIOType {
> +    VIRTIO_PCI,
> +    VIRTIO_SYBORG,
> +} VirtIOType;
> +
>  struct VirtIODevice
>  {
>      const char *name;
> @@ -106,6 +111,7 @@ struct VirtIODevice
>      void (*set_config)(VirtIODevice *vdev, const uint8_t *config);
>      void (*reset)(VirtIODevice *vdev);
>      VirtQueue *vq;
> +    VirtIOType type;
>      const VirtIOBindings *binding;
>      void *binding_opaque;
>      uint16_t device_id;
> -- 
> 1.6.5.2
diff mbox

Patch

diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index 6cf5a15..46ac192 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -275,6 +275,7 @@  static int syborg_virtio_net_init(SysBusDevice *dev)
     SyborgVirtIOProxy *proxy = FROM_SYSBUS(SyborgVirtIOProxy, dev);

     vdev = virtio_net_init(&dev->qdev, &proxy->nic);
+    vdev->type = VIRTIO_SYBORG;
     return syborg_virtio_init(proxy, vdev);
 }

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 25b6380..a2179de 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -433,7 +433,7 @@  static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,

     pci_register_bar(&proxy->pci_dev, 0, size, PCI_BASE_ADDRESS_SPACE_IO,
                            virtio_map);
-
+    vdev->type = VIRTIO_PCI;
     virtio_bind_device(vdev, &virtio_pci_bindings, proxy);
 }

diff --git a/hw/virtio.h b/hw/virtio.h
index 15ad910..ec1ff4d 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -88,6 +88,11 @@  typedef struct {

 #define VIRTIO_NO_VECTOR 0xffff

+typedef enum VirtIOType {
+    VIRTIO_PCI,
+    VIRTIO_SYBORG,
+} VirtIOType;
+
 struct VirtIODevice
 {
     const char *name;
@@ -106,6 +111,7 @@  struct VirtIODevice
     void (*set_config)(VirtIODevice *vdev, const uint8_t *config);
     void (*reset)(VirtIODevice *vdev);
     VirtQueue *vq;
+    VirtIOType type;
     const VirtIOBindings *binding;
     void *binding_opaque;
     uint16_t device_id;