qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio: correctly initialize vm_running
@ 2011-05-18  5:57 Jason Wang
  2011-05-18  8:54 ` Michael S. Tsirkin
  2011-06-01  9:55 ` Michael S. Tsirkin
  0 siblings, 2 replies; 5+ messages in thread
From: Jason Wang @ 2011-05-18  5:57 UTC (permalink / raw)
  To: qemu-devel, mst

Current vm_running was not explicitly initialized and its value was changed by
vm state notifier, this may confuse the virtio device being hotplugged such as
virtio-net with vhost backend as it may think the vm was not running. Solve this
by initialize this value explicitly in virtio_common_init().

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/hw/virtio.c b/hw/virtio.c
index 6e8814c..27d7e50 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -789,6 +789,7 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
     vdev->queue_sel = 0;
     vdev->config_vector = VIRTIO_NO_VECTOR;
     vdev->vq = qemu_mallocz(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
+    vdev->vm_running = vm_running;
     for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
         vdev->vq[i].vector = VIRTIO_NO_VECTOR;
         vdev->vq[i].vdev = vdev;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] virtio: correctly initialize vm_running
  2011-05-18  5:57 [Qemu-devel] [PATCH] virtio: correctly initialize vm_running Jason Wang
@ 2011-05-18  8:54 ` Michael S. Tsirkin
  2011-05-23  5:57   ` Jason Wang
  2011-06-01  9:55 ` Michael S. Tsirkin
  1 sibling, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2011-05-18  8:54 UTC (permalink / raw)
  To: Jason Wang; +Cc: qemu-devel

On Wed, May 18, 2011 at 01:57:37PM +0800, Jason Wang wrote:
> Current vm_running was not explicitly initialized and its value was changed by
> vm state notifier, this may confuse the virtio device being hotplugged such as
> virtio-net with vhost backend as it may think the vm was not running. Solve this
> by initialize this value explicitly in virtio_common_init().
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>

I think a slightly cleaner way would be to invoke
virtio_vmstate_change after it is registered,
have that update the vm_running field.


> ---
>  0 files changed, 0 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/virtio.c b/hw/virtio.c
> index 6e8814c..27d7e50 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -789,6 +789,7 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
>      vdev->queue_sel = 0;
>      vdev->config_vector = VIRTIO_NO_VECTOR;
>      vdev->vq = qemu_mallocz(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
> +    vdev->vm_running = vm_running;
>      for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
>          vdev->vq[i].vector = VIRTIO_NO_VECTOR;
>          vdev->vq[i].vdev = vdev;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] virtio: correctly initialize vm_running
  2011-05-18  8:54 ` Michael S. Tsirkin
@ 2011-05-23  5:57   ` Jason Wang
  2011-05-23 11:01     ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Wang @ 2011-05-23  5:57 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel

On 05/18/2011 04:54 PM, Michael S. Tsirkin wrote:
> On Wed, May 18, 2011 at 01:57:37PM +0800, Jason Wang wrote:
>> Current vm_running was not explicitly initialized and its value was changed by
>> vm state notifier, this may confuse the virtio device being hotplugged such as
>> virtio-net with vhost backend as it may think the vm was not running. Solve this
>> by initialize this value explicitly in virtio_common_init().
>>
>> Signed-off-by: Jason Wang<jasowang@redhat.com>
> I think a slightly cleaner way would be to invoke
> virtio_vmstate_change after it is registered,
> have that update the vm_running field.
>

Do you mean call it in virtio_common_init() directly? But the bindings 
are not initialized then. Or is there anything I missed?

>> ---
>>   0 files changed, 0 insertions(+), 0 deletions(-)
>>
>> diff --git a/hw/virtio.c b/hw/virtio.c
>> index 6e8814c..27d7e50 100644
>> --- a/hw/virtio.c
>> +++ b/hw/virtio.c
>> @@ -789,6 +789,7 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
>>       vdev->queue_sel = 0;
>>       vdev->config_vector = VIRTIO_NO_VECTOR;
>>       vdev->vq = qemu_mallocz(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
>> +    vdev->vm_running = vm_running;
>>       for(i = 0; i<  VIRTIO_PCI_QUEUE_MAX; i++) {
>>           vdev->vq[i].vector = VIRTIO_NO_VECTOR;
>>           vdev->vq[i].vdev = vdev;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] virtio: correctly initialize vm_running
  2011-05-23  5:57   ` Jason Wang
@ 2011-05-23 11:01     ` Michael S. Tsirkin
  0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2011-05-23 11:01 UTC (permalink / raw)
  To: Jason Wang; +Cc: qemu-devel

On Mon, May 23, 2011 at 01:57:57PM +0800, Jason Wang wrote:
> On 05/18/2011 04:54 PM, Michael S. Tsirkin wrote:
> >On Wed, May 18, 2011 at 01:57:37PM +0800, Jason Wang wrote:
> >>Current vm_running was not explicitly initialized and its value was changed by
> >>vm state notifier, this may confuse the virtio device being hotplugged such as
> >>virtio-net with vhost backend as it may think the vm was not running. Solve this
> >>by initialize this value explicitly in virtio_common_init().
> >>
> >>Signed-off-by: Jason Wang<jasowang@redhat.com>
> >I think a slightly cleaner way would be to invoke
> >virtio_vmstate_change after it is registered,
> >have that update the vm_running field.
> >
> 
> Do you mean call it in virtio_common_init() directly? But the
> bindings are not initialized then. Or is there anything I missed?

My idea was that when we register a callback, it can
immediately be invoked with the current vm state.

But this has other implications so would have to be
tested more. So I think your patch is a good start.

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> >>---
> >>  0 files changed, 0 insertions(+), 0 deletions(-)
> >>
> >>diff --git a/hw/virtio.c b/hw/virtio.c
> >>index 6e8814c..27d7e50 100644
> >>--- a/hw/virtio.c
> >>+++ b/hw/virtio.c
> >>@@ -789,6 +789,7 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
> >>      vdev->queue_sel = 0;
> >>      vdev->config_vector = VIRTIO_NO_VECTOR;
> >>      vdev->vq = qemu_mallocz(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
> >>+    vdev->vm_running = vm_running;
> >>      for(i = 0; i<  VIRTIO_PCI_QUEUE_MAX; i++) {
> >>          vdev->vq[i].vector = VIRTIO_NO_VECTOR;
> >>          vdev->vq[i].vdev = vdev;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] virtio: correctly initialize vm_running
  2011-05-18  5:57 [Qemu-devel] [PATCH] virtio: correctly initialize vm_running Jason Wang
  2011-05-18  8:54 ` Michael S. Tsirkin
@ 2011-06-01  9:55 ` Michael S. Tsirkin
  1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2011-06-01  9:55 UTC (permalink / raw)
  To: Jason Wang; +Cc: qemu-devel

On Wed, May 18, 2011 at 01:57:37PM +0800, Jason Wang wrote:
> Current vm_running was not explicitly initialized and its value was changed by
> vm state notifier, this may confuse the virtio device being hotplugged such as
> virtio-net with vhost backend as it may think the vm was not running. Solve this
> by initialize this value explicitly in virtio_common_init().
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>

Applied, thanks

> ---
>  0 files changed, 0 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/virtio.c b/hw/virtio.c
> index 6e8814c..27d7e50 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -789,6 +789,7 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
>      vdev->queue_sel = 0;
>      vdev->config_vector = VIRTIO_NO_VECTOR;
>      vdev->vq = qemu_mallocz(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
> +    vdev->vm_running = vm_running;
>      for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
>          vdev->vq[i].vector = VIRTIO_NO_VECTOR;
>          vdev->vq[i].vdev = vdev;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-06-01  9:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-18  5:57 [Qemu-devel] [PATCH] virtio: correctly initialize vm_running Jason Wang
2011-05-18  8:54 ` Michael S. Tsirkin
2011-05-23  5:57   ` Jason Wang
2011-05-23 11:01     ` Michael S. Tsirkin
2011-06-01  9:55 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).