diff mbox

[07/12] virtio: introduce virtio_queue_del()

Message ID 1356690724-37891-8-git-send-email-jasowang@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jason Wang Dec. 28, 2012, 10:31 a.m. UTC
Some device (such as virtio-net) needs the ability to destroy or re-order the
virtqueues, this patch adds a helper to do this.

Signed-off-by: Jason Wang <jasowang>
---
 hw/virtio.c |    9 +++++++++
 hw/virtio.h |    2 ++
 2 files changed, 11 insertions(+), 0 deletions(-)

Comments

Michael S. Tsirkin Jan. 8, 2013, 7:14 a.m. UTC | #1
On Fri, Dec 28, 2012 at 06:31:59PM +0800, Jason Wang wrote:
> Some device (such as virtio-net) needs the ability to destroy or re-order the
> virtqueues, this patch adds a helper to do this.
> 
> Signed-off-by: Jason Wang <jasowang>

Actually del_queue unlike what the subject says :)

> ---
>  hw/virtio.c |    9 +++++++++
>  hw/virtio.h |    2 ++
>  2 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/virtio.c b/hw/virtio.c
> index f40a8c5..bc3c9c3 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -700,6 +700,15 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
>      return &vdev->vq[i];
>  }
>  
> +void virtio_del_queue(VirtIODevice *vdev, int n)
> +{
> +    if (n < 0 || n >= VIRTIO_PCI_QUEUE_MAX) {
> +        abort();
> +    }
> +
> +    vdev->vq[n].vring.num = 0;
> +}
> +
>  void virtio_irq(VirtQueue *vq)
>  {
>      trace_virtio_irq(vq);
> diff --git a/hw/virtio.h b/hw/virtio.h
> index 7c17f7b..f6cb0f9 100644
> --- a/hw/virtio.h
> +++ b/hw/virtio.h
> @@ -138,6 +138,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
>                              void (*handle_output)(VirtIODevice *,
>                                                    VirtQueue *));
>  
> +void virtio_del_queue(VirtIODevice *vdev, int n);
> +
>  void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
>                      unsigned int len);
>  void virtqueue_flush(VirtQueue *vq, unsigned int count);
> -- 
> 1.7.1
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jason Wang Jan. 8, 2013, 9:28 a.m. UTC | #2
On 01/08/2013 03:14 PM, Michael S. Tsirkin wrote:
> On Fri, Dec 28, 2012 at 06:31:59PM +0800, Jason Wang wrote:
>> Some device (such as virtio-net) needs the ability to destroy or re-order the
>> virtqueues, this patch adds a helper to do this.
>>
>> Signed-off-by: Jason Wang <jasowang>
> Actually del_queue unlike what the subject says :)

Oh, yes, will correct this.
>
>> ---
>>  hw/virtio.c |    9 +++++++++
>>  hw/virtio.h |    2 ++
>>  2 files changed, 11 insertions(+), 0 deletions(-)
>>
>> diff --git a/hw/virtio.c b/hw/virtio.c
>> index f40a8c5..bc3c9c3 100644
>> --- a/hw/virtio.c
>> +++ b/hw/virtio.c
>> @@ -700,6 +700,15 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
>>      return &vdev->vq[i];
>>  }
>>  
>> +void virtio_del_queue(VirtIODevice *vdev, int n)
>> +{
>> +    if (n < 0 || n >= VIRTIO_PCI_QUEUE_MAX) {
>> +        abort();
>> +    }
>> +
>> +    vdev->vq[n].vring.num = 0;
>> +}
>> +
>>  void virtio_irq(VirtQueue *vq)
>>  {
>>      trace_virtio_irq(vq);
>> diff --git a/hw/virtio.h b/hw/virtio.h
>> index 7c17f7b..f6cb0f9 100644
>> --- a/hw/virtio.h
>> +++ b/hw/virtio.h
>> @@ -138,6 +138,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
>>                              void (*handle_output)(VirtIODevice *,
>>                                                    VirtQueue *));
>>  
>> +void virtio_del_queue(VirtIODevice *vdev, int n);
>> +
>>  void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
>>                      unsigned int len);
>>  void virtqueue_flush(VirtQueue *vq, unsigned int count);
>> -- 
>> 1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/hw/virtio.c b/hw/virtio.c
index f40a8c5..bc3c9c3 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -700,6 +700,15 @@  VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
     return &vdev->vq[i];
 }
 
+void virtio_del_queue(VirtIODevice *vdev, int n)
+{
+    if (n < 0 || n >= VIRTIO_PCI_QUEUE_MAX) {
+        abort();
+    }
+
+    vdev->vq[n].vring.num = 0;
+}
+
 void virtio_irq(VirtQueue *vq)
 {
     trace_virtio_irq(vq);
diff --git a/hw/virtio.h b/hw/virtio.h
index 7c17f7b..f6cb0f9 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -138,6 +138,8 @@  VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
                             void (*handle_output)(VirtIODevice *,
                                                   VirtQueue *));
 
+void virtio_del_queue(VirtIODevice *vdev, int n);
+
 void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
                     unsigned int len);
 void virtqueue_flush(VirtQueue *vq, unsigned int count);