All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] qemu: virtio save/load bindings
@ 2009-05-25 13:34 ` Michael S. Tsirkin
  0 siblings, 0 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2009-05-25 13:34 UTC (permalink / raw)
  To: Paul Brook, Avi Kivity, qemu-devel, Carsten Otte, kvm, Rusty Russell, vi

Implement bindings for virtio save/load. Use them in virtio pci.

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

Is anyone working to fill in load/save bindings so that saving virtio
devices works? Here's a trivial patch to do this (this one is on top of my
MSI-X patchset).
Comments?

 hw/virtio-pci.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 hw/virtio.c     |   31 ++++++++++++++-----------------
 hw/virtio.h     |    4 ++++
 3 files changed, 66 insertions(+), 18 deletions(-)

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 294f4c7..589fbb1 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -105,6 +105,48 @@ static void virtio_pci_notify(void *opaque, uint16_t vector)
         qemu_set_irq(proxy->pci_dev.irq[0], proxy->vdev->isr & 1);
 }
 
+static void virtio_pci_save_config(void * opaque, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    pci_device_save(&proxy->pci_dev, f);
+    msix_save(&proxy->pci_dev, f);
+    if (msix_present(&proxy->pci_dev))
+        qemu_put_be16(f, proxy->vdev->config_vector);
+}
+
+static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    if (msix_present(&proxy->pci_dev))
+        qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n));
+}
+
+static int virtio_pci_load_config(void * opaque, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    int ret;
+    ret = pci_device_load(&proxy->pci_dev, f);
+    if (ret)
+        return ret;
+    ret = msix_load(&proxy->pci_dev, f);
+    if (ret)
+        return ret;
+    if (msix_present(&proxy->pci_dev))
+        qemu_get_be16s(f, &proxy->vdev->config_vector);
+    return 0;
+}
+
+static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    uint16_t vector;
+    if (!msix_present(&proxy->pci_dev))
+        return 0;
+    qemu_get_be16s(f, &vector);
+    virtio_queue_set_vector(proxy->vdev, n, vector);
+    return 0;
+}
+
 static void virtio_pci_reset(void *opaque)
 {
     VirtIOPCIProxy *proxy = opaque;
@@ -317,7 +359,12 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
 }
 
 static const VirtIOBindings virtio_pci_bindings = {
-    .notify = virtio_pci_notify
+    .notify = virtio_pci_notify,
+    .save_config = virtio_pci_save_config,
+    .load_config = virtio_pci_load_config,
+    .save_config = virtio_pci_save_config,
+    .save_queue = virtio_pci_save_queue,
+    .load_queue = virtio_pci_load_queue,
 };
 
 static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
diff --git a/hw/virtio.c b/hw/virtio.c
index 63ffcff..b773dff 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
 {
     int i;
 
-    /* FIXME: load/save binding.  */
-    //pci_device_save(&vdev->pci_dev, f);
-    //msix_save(&vdev->pci_dev, f);
+    if (vdev->binding->save_config)
+        vdev->binding->save_config(vdev->binding_opaque, f);
 
     qemu_put_8s(f, &vdev->status);
     qemu_put_8s(f, &vdev->isr);
@@ -596,19 +595,20 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
         qemu_put_be32(f, vdev->vq[i].vring.num);
         qemu_put_be64(f, vdev->vq[i].pa);
         qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
-        if (vdev->nvectors)
-            qemu_put_be16s(f, &vdev->vq[i].vector);
+        if (vdev->binding->save_queue)
+            vdev->binding->save_queue(vdev->binding_opaque, i, f);
     }
 }
 
 int virtio_load(VirtIODevice *vdev, QEMUFile *f)
 {
-    int num, i;
+    int num, i, ret;
 
-    /* FIXME: load/save binding.  */
-    //pci_device_load(&vdev->pci_dev, f);
-    //r = msix_load(&vdev->pci_dev, f);
-    //pci_resize_io_region(&vdev->pci_dev, 1, msix_bar_size(&vdev->pci_dev));
+    if (vdev->binding->load_config) {
+        ret = vdev->binding->load_config(vdev->binding_opaque, f);
+        if (ret)
+            return ret;
+    }
 
     qemu_get_8s(f, &vdev->status);
     qemu_get_8s(f, &vdev->isr);
@@ -617,10 +617,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
     vdev->config_len = qemu_get_be32(f);
     qemu_get_buffer(f, vdev->config, vdev->config_len);
 
-    if (vdev->nvectors) {
-        qemu_get_be16s(f, &vdev->config_vector);
-        //msix_vector_use(&vdev->pci_dev, vdev->config_vector);
-    }
     num = qemu_get_be32(f);
 
     for (i = 0; i < num; i++) {
@@ -631,9 +627,10 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
         if (vdev->vq[i].pa) {
             virtqueue_init(&vdev->vq[i]);
         }
-        if (vdev->nvectors) {
-            qemu_get_be16s(f, &vdev->vq[i].vector);
-            //msix_vector_use(&vdev->pci_dev, vdev->config_vector);
+        if (vdev->binding->load_queue) {
+            ret = vdev->binding->load_queue(vdev->binding_opaque, i, f);
+            if (ret)
+                return ret;
         }
     }
 
diff --git a/hw/virtio.h b/hw/virtio.h
index 04a3c3d..ce05517 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -72,6 +72,10 @@ typedef struct VirtQueueElement
 
 typedef struct {
     void (*notify)(void * opaque, uint16_t vector);
+    void (*save_config)(void * opaque, QEMUFile *f);
+    void (*save_queue)(void * opaque, int n, QEMUFile *f);
+    int (*load_config)(void * opaque, QEMUFile *f);
+    int (*load_queue)(void * opaque, int n, QEMUFile *f);
 } VirtIOBindings;
 
 #define VIRTIO_PCI_QUEUE_MAX 16
-- 
1.6.3.1.56.g79e1.dirty

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

* [Qemu-devel] [PATCH] qemu: virtio save/load bindings
@ 2009-05-25 13:34 ` Michael S. Tsirkin
  0 siblings, 0 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2009-05-25 13:34 UTC (permalink / raw)
  To: Paul Brook, Avi Kivity, qemu-devel, Carsten Otte, kvm,
	Rusty Russell, virtualization, Christian Borntraeger, Blue Swirl,
	Anthony Liguori

Implement bindings for virtio save/load. Use them in virtio pci.

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

Is anyone working to fill in load/save bindings so that saving virtio
devices works? Here's a trivial patch to do this (this one is on top of my
MSI-X patchset).
Comments?

 hw/virtio-pci.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 hw/virtio.c     |   31 ++++++++++++++-----------------
 hw/virtio.h     |    4 ++++
 3 files changed, 66 insertions(+), 18 deletions(-)

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 294f4c7..589fbb1 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -105,6 +105,48 @@ static void virtio_pci_notify(void *opaque, uint16_t vector)
         qemu_set_irq(proxy->pci_dev.irq[0], proxy->vdev->isr & 1);
 }
 
+static void virtio_pci_save_config(void * opaque, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    pci_device_save(&proxy->pci_dev, f);
+    msix_save(&proxy->pci_dev, f);
+    if (msix_present(&proxy->pci_dev))
+        qemu_put_be16(f, proxy->vdev->config_vector);
+}
+
+static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    if (msix_present(&proxy->pci_dev))
+        qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n));
+}
+
+static int virtio_pci_load_config(void * opaque, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    int ret;
+    ret = pci_device_load(&proxy->pci_dev, f);
+    if (ret)
+        return ret;
+    ret = msix_load(&proxy->pci_dev, f);
+    if (ret)
+        return ret;
+    if (msix_present(&proxy->pci_dev))
+        qemu_get_be16s(f, &proxy->vdev->config_vector);
+    return 0;
+}
+
+static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    uint16_t vector;
+    if (!msix_present(&proxy->pci_dev))
+        return 0;
+    qemu_get_be16s(f, &vector);
+    virtio_queue_set_vector(proxy->vdev, n, vector);
+    return 0;
+}
+
 static void virtio_pci_reset(void *opaque)
 {
     VirtIOPCIProxy *proxy = opaque;
@@ -317,7 +359,12 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
 }
 
 static const VirtIOBindings virtio_pci_bindings = {
-    .notify = virtio_pci_notify
+    .notify = virtio_pci_notify,
+    .save_config = virtio_pci_save_config,
+    .load_config = virtio_pci_load_config,
+    .save_config = virtio_pci_save_config,
+    .save_queue = virtio_pci_save_queue,
+    .load_queue = virtio_pci_load_queue,
 };
 
 static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
diff --git a/hw/virtio.c b/hw/virtio.c
index 63ffcff..b773dff 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
 {
     int i;
 
-    /* FIXME: load/save binding.  */
-    //pci_device_save(&vdev->pci_dev, f);
-    //msix_save(&vdev->pci_dev, f);
+    if (vdev->binding->save_config)
+        vdev->binding->save_config(vdev->binding_opaque, f);
 
     qemu_put_8s(f, &vdev->status);
     qemu_put_8s(f, &vdev->isr);
@@ -596,19 +595,20 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
         qemu_put_be32(f, vdev->vq[i].vring.num);
         qemu_put_be64(f, vdev->vq[i].pa);
         qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
-        if (vdev->nvectors)
-            qemu_put_be16s(f, &vdev->vq[i].vector);
+        if (vdev->binding->save_queue)
+            vdev->binding->save_queue(vdev->binding_opaque, i, f);
     }
 }
 
 int virtio_load(VirtIODevice *vdev, QEMUFile *f)
 {
-    int num, i;
+    int num, i, ret;
 
-    /* FIXME: load/save binding.  */
-    //pci_device_load(&vdev->pci_dev, f);
-    //r = msix_load(&vdev->pci_dev, f);
-    //pci_resize_io_region(&vdev->pci_dev, 1, msix_bar_size(&vdev->pci_dev));
+    if (vdev->binding->load_config) {
+        ret = vdev->binding->load_config(vdev->binding_opaque, f);
+        if (ret)
+            return ret;
+    }
 
     qemu_get_8s(f, &vdev->status);
     qemu_get_8s(f, &vdev->isr);
@@ -617,10 +617,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
     vdev->config_len = qemu_get_be32(f);
     qemu_get_buffer(f, vdev->config, vdev->config_len);
 
-    if (vdev->nvectors) {
-        qemu_get_be16s(f, &vdev->config_vector);
-        //msix_vector_use(&vdev->pci_dev, vdev->config_vector);
-    }
     num = qemu_get_be32(f);
 
     for (i = 0; i < num; i++) {
@@ -631,9 +627,10 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
         if (vdev->vq[i].pa) {
             virtqueue_init(&vdev->vq[i]);
         }
-        if (vdev->nvectors) {
-            qemu_get_be16s(f, &vdev->vq[i].vector);
-            //msix_vector_use(&vdev->pci_dev, vdev->config_vector);
+        if (vdev->binding->load_queue) {
+            ret = vdev->binding->load_queue(vdev->binding_opaque, i, f);
+            if (ret)
+                return ret;
         }
     }
 
diff --git a/hw/virtio.h b/hw/virtio.h
index 04a3c3d..ce05517 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -72,6 +72,10 @@ typedef struct VirtQueueElement
 
 typedef struct {
     void (*notify)(void * opaque, uint16_t vector);
+    void (*save_config)(void * opaque, QEMUFile *f);
+    void (*save_queue)(void * opaque, int n, QEMUFile *f);
+    int (*load_config)(void * opaque, QEMUFile *f);
+    int (*load_queue)(void * opaque, int n, QEMUFile *f);
 } VirtIOBindings;
 
 #define VIRTIO_PCI_QUEUE_MAX 16
-- 
1.6.3.1.56.g79e1.dirty

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

* Re: [PATCH] qemu: virtio save/load bindings
  2009-05-25 13:34 ` [Qemu-devel] " Michael S. Tsirkin
@ 2009-05-26  8:34   ` Anthony Liguori
  -1 siblings, 0 replies; 12+ messages in thread
From: Anthony Liguori @ 2009-05-26  8:34 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Paul Brook, Avi Kivity, qemu-devel, Carsten Otte, kvm,
	Rusty Russell, virtualization, Christian Borntraeger, Blue Swirl

Michael S. Tsirkin wrote:
> Implement bindings for virtio save/load. Use them in virtio pci.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Is anyone working to fill in load/save bindings so that saving virtio
> devices works? Here's a trivial patch to do this (this one is on top of my
> MSI-X patchset).
> Comments?
>
>  hw/virtio-pci.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  hw/virtio.c     |   31 ++++++++++++++-----------------
>  hw/virtio.h     |    4 ++++
>  3 files changed, 66 insertions(+), 18 deletions(-)
>
>  static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> diff --git a/hw/virtio.c b/hw/virtio.c
> index 63ffcff..b773dff 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
>  {
>      int i;
>  
> -    /* FIXME: load/save binding.  */
> -    //pci_device_save(&vdev->pci_dev, f);
> -    //msix_save(&vdev->pci_dev, f);
>   

qdev regressed save/restore?  What else is broken right now from the 
qdev commit?

I'm beginning to think committing in the state it was in was a mistake.  
Paul, can you put together a TODO so that we know all of the things that 
have regressed so we can get things back into shape?

Regards,

Anthony Liguori


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

* [Qemu-devel] Re: [PATCH] qemu: virtio save/load bindings
@ 2009-05-26  8:34   ` Anthony Liguori
  0 siblings, 0 replies; 12+ messages in thread
From: Anthony Liguori @ 2009-05-26  8:34 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Carsten Otte, kvm, Rusty Russell, qemu-devel, virtualization,
	Blue Swirl, Christian Borntraeger, Paul Brook, Avi Kivity

Michael S. Tsirkin wrote:
> Implement bindings for virtio save/load. Use them in virtio pci.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Is anyone working to fill in load/save bindings so that saving virtio
> devices works? Here's a trivial patch to do this (this one is on top of my
> MSI-X patchset).
> Comments?
>
>  hw/virtio-pci.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  hw/virtio.c     |   31 ++++++++++++++-----------------
>  hw/virtio.h     |    4 ++++
>  3 files changed, 66 insertions(+), 18 deletions(-)
>
>  static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> diff --git a/hw/virtio.c b/hw/virtio.c
> index 63ffcff..b773dff 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
>  {
>      int i;
>  
> -    /* FIXME: load/save binding.  */
> -    //pci_device_save(&vdev->pci_dev, f);
> -    //msix_save(&vdev->pci_dev, f);
>   

qdev regressed save/restore?  What else is broken right now from the 
qdev commit?

I'm beginning to think committing in the state it was in was a mistake.  
Paul, can you put together a TODO so that we know all of the things that 
have regressed so we can get things back into shape?

Regards,

Anthony Liguori

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

* Re: [PATCH] qemu: virtio save/load bindings
  2009-05-25 13:34 ` [Qemu-devel] " Michael S. Tsirkin
  (?)
@ 2009-05-26  8:34 ` Anthony Liguori
  -1 siblings, 0 replies; 12+ messages in thread
From: Anthony Liguori @ 2009-05-26  8:34 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Carsten Otte, kvm, qemu-devel, virtualization, Blue Swirl,
	Christian Borntraeger, Paul Brook, Avi Kivity

Michael S. Tsirkin wrote:
> Implement bindings for virtio save/load. Use them in virtio pci.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Is anyone working to fill in load/save bindings so that saving virtio
> devices works? Here's a trivial patch to do this (this one is on top of my
> MSI-X patchset).
> Comments?
>
>  hw/virtio-pci.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  hw/virtio.c     |   31 ++++++++++++++-----------------
>  hw/virtio.h     |    4 ++++
>  3 files changed, 66 insertions(+), 18 deletions(-)
>
>  static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> diff --git a/hw/virtio.c b/hw/virtio.c
> index 63ffcff..b773dff 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
>  {
>      int i;
>  
> -    /* FIXME: load/save binding.  */
> -    //pci_device_save(&vdev->pci_dev, f);
> -    //msix_save(&vdev->pci_dev, f);
>   

qdev regressed save/restore?  What else is broken right now from the 
qdev commit?

I'm beginning to think committing in the state it was in was a mistake.  
Paul, can you put together a TODO so that we know all of the things that 
have regressed so we can get things back into shape?

Regards,

Anthony Liguori

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

* Re: [PATCH] qemu: virtio save/load bindings
  2009-05-26  8:34   ` [Qemu-devel] " Anthony Liguori
@ 2009-05-26 10:20     ` Paul Brook
  -1 siblings, 0 replies; 12+ messages in thread
From: Paul Brook @ 2009-05-26 10:20 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: Michael S. Tsirkin, Avi Kivity, qemu-devel, Carsten Otte, kvm,
	Rusty Russell, virtualization, Christian Borntraeger, Blue Swirl

> > -    /* FIXME: load/save binding.  */
> > -    //pci_device_save(&vdev->pci_dev, f);
> > -    //msix_save(&vdev->pci_dev, f);
>
> qdev regressed save/restore?  What else is broken right now from the
> qdev commit?
>
> I'm beginning to think committing in the state it was in was a mistake.
> Paul, can you put together a TODO so that we know all of the things that
> have regressed so we can get things back into shape?

Sorry, this one apparently slipped past. I#'d intended to fix it, but 
apparently never ported that bit of the patch.

Paul

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

* [Qemu-devel] Re: [PATCH] qemu: virtio save/load bindings
@ 2009-05-26 10:20     ` Paul Brook
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Brook @ 2009-05-26 10:20 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: Carsten Otte, kvm, Michael S. Tsirkin, Rusty Russell, qemu-devel,
	virtualization, Blue Swirl, Christian Borntraeger, Avi Kivity

> > -    /* FIXME: load/save binding.  */
> > -    //pci_device_save(&vdev->pci_dev, f);
> > -    //msix_save(&vdev->pci_dev, f);
>
> qdev regressed save/restore?  What else is broken right now from the
> qdev commit?
>
> I'm beginning to think committing in the state it was in was a mistake.
> Paul, can you put together a TODO so that we know all of the things that
> have regressed so we can get things back into shape?

Sorry, this one apparently slipped past. I#'d intended to fix it, but 
apparently never ported that bit of the patch.

Paul

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

* Re: [PATCH] qemu: virtio save/load bindings
  2009-05-26  8:34   ` [Qemu-devel] " Anthony Liguori
  (?)
  (?)
@ 2009-05-26 10:20   ` Paul Brook
  -1 siblings, 0 replies; 12+ messages in thread
From: Paul Brook @ 2009-05-26 10:20 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: Carsten Otte, kvm, Michael S. Tsirkin, qemu-devel,
	virtualization, Blue Swirl, Christian Borntraeger, Avi Kivity

> > -    /* FIXME: load/save binding.  */
> > -    //pci_device_save(&vdev->pci_dev, f);
> > -    //msix_save(&vdev->pci_dev, f);
>
> qdev regressed save/restore?  What else is broken right now from the
> qdev commit?
>
> I'm beginning to think committing in the state it was in was a mistake.
> Paul, can you put together a TODO so that we know all of the things that
> have regressed so we can get things back into shape?

Sorry, this one apparently slipped past. I#'d intended to fix it, but 
apparently never ported that bit of the patch.

Paul

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

* Re: [Qemu-devel] Re: [PATCH] qemu: virtio save/load bindings
  2009-05-26  8:34   ` [Qemu-devel] " Anthony Liguori
@ 2009-06-03 10:31     ` Avi Kivity
  -1 siblings, 0 replies; 12+ messages in thread
From: Avi Kivity @ 2009-06-03 10:31 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: Michael S. Tsirkin, Carsten Otte, kvm, Rusty Russell, qemu-devel,
	virtualization, Blue Swirl, Christian Borntraeger, Paul Brook

Anthony Liguori wrote:
> Michael S. Tsirkin wrote:
>> Implement bindings for virtio save/load. Use them in virtio pci.
>>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>>
>> Is anyone working to fill in load/save bindings so that saving virtio
>> devices works? Here's a trivial patch to do this (this one is on top 
>> of my
>> MSI-X patchset).
>> Comments?
>>
>>  hw/virtio-pci.c |   49 
>> ++++++++++++++++++++++++++++++++++++++++++++++++-
>>  hw/virtio.c     |   31 ++++++++++++++-----------------
>>  hw/virtio.h     |    4 ++++
>>  3 files changed, 66 insertions(+), 18 deletions(-)
>>
>>  static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
>> diff --git a/hw/virtio.c b/hw/virtio.c
>> index 63ffcff..b773dff 100644
>> --- a/hw/virtio.c
>> +++ b/hw/virtio.c
>> @@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
>>  {
>>      int i;
>>  
>> -    /* FIXME: load/save binding.  */
>> -    //pci_device_save(&vdev->pci_dev, f);
>> -    //msix_save(&vdev->pci_dev, f);
>>   
>
> qdev regressed save/restore?  What else is broken right now from the 
> qdev commit?
>
> I'm beginning to think committing in the state it was in was a 
> mistake.  Paul, can you put together a TODO so that we know all of the 
> things that have regressed so we can get things back into shape?
>

virtio is still broken.  Anthony, are you planning to commit this patch?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


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

* Re: [Qemu-devel] Re: [PATCH] qemu: virtio save/load bindings
@ 2009-06-03 10:31     ` Avi Kivity
  0 siblings, 0 replies; 12+ messages in thread
From: Avi Kivity @ 2009-06-03 10:31 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: Carsten Otte, kvm, Michael S. Tsirkin, Rusty Russell, qemu-devel,
	virtualization, Blue Swirl, Christian Borntraeger, Paul Brook

Anthony Liguori wrote:
> Michael S. Tsirkin wrote:
>> Implement bindings for virtio save/load. Use them in virtio pci.
>>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>>
>> Is anyone working to fill in load/save bindings so that saving virtio
>> devices works? Here's a trivial patch to do this (this one is on top 
>> of my
>> MSI-X patchset).
>> Comments?
>>
>>  hw/virtio-pci.c |   49 
>> ++++++++++++++++++++++++++++++++++++++++++++++++-
>>  hw/virtio.c     |   31 ++++++++++++++-----------------
>>  hw/virtio.h     |    4 ++++
>>  3 files changed, 66 insertions(+), 18 deletions(-)
>>
>>  static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
>> diff --git a/hw/virtio.c b/hw/virtio.c
>> index 63ffcff..b773dff 100644
>> --- a/hw/virtio.c
>> +++ b/hw/virtio.c
>> @@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
>>  {
>>      int i;
>>  
>> -    /* FIXME: load/save binding.  */
>> -    //pci_device_save(&vdev->pci_dev, f);
>> -    //msix_save(&vdev->pci_dev, f);
>>   
>
> qdev regressed save/restore?  What else is broken right now from the 
> qdev commit?
>
> I'm beginning to think committing in the state it was in was a 
> mistake.  Paul, can you put together a TODO so that we know all of the 
> things that have regressed so we can get things back into shape?
>

virtio is still broken.  Anthony, are you planning to commit this patch?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.

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

* Re: [Qemu-devel] Re: [PATCH] qemu: virtio save/load bindings
  2009-05-26  8:34   ` [Qemu-devel] " Anthony Liguori
                     ` (2 preceding siblings ...)
  (?)
@ 2009-06-03 10:31   ` Avi Kivity
  -1 siblings, 0 replies; 12+ messages in thread
From: Avi Kivity @ 2009-06-03 10:31 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: Carsten Otte, kvm, Michael S. Tsirkin, qemu-devel,
	virtualization, Blue Swirl, Christian Borntraeger, Paul Brook

Anthony Liguori wrote:
> Michael S. Tsirkin wrote:
>> Implement bindings for virtio save/load. Use them in virtio pci.
>>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>>
>> Is anyone working to fill in load/save bindings so that saving virtio
>> devices works? Here's a trivial patch to do this (this one is on top 
>> of my
>> MSI-X patchset).
>> Comments?
>>
>>  hw/virtio-pci.c |   49 
>> ++++++++++++++++++++++++++++++++++++++++++++++++-
>>  hw/virtio.c     |   31 ++++++++++++++-----------------
>>  hw/virtio.h     |    4 ++++
>>  3 files changed, 66 insertions(+), 18 deletions(-)
>>
>>  static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
>> diff --git a/hw/virtio.c b/hw/virtio.c
>> index 63ffcff..b773dff 100644
>> --- a/hw/virtio.c
>> +++ b/hw/virtio.c
>> @@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
>>  {
>>      int i;
>>  
>> -    /* FIXME: load/save binding.  */
>> -    //pci_device_save(&vdev->pci_dev, f);
>> -    //msix_save(&vdev->pci_dev, f);
>>   
>
> qdev regressed save/restore?  What else is broken right now from the 
> qdev commit?
>
> I'm beginning to think committing in the state it was in was a 
> mistake.  Paul, can you put together a TODO so that we know all of the 
> things that have regressed so we can get things back into shape?
>

virtio is still broken.  Anthony, are you planning to commit this patch?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.

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

* [PATCH] qemu: virtio save/load bindings
@ 2009-05-25 13:34 Michael S. Tsirkin
  0 siblings, 0 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2009-05-25 13:34 UTC (permalink / raw)
  To: Paul Brook, Avi Kivity, qemu-devel, Carsten Otte, kvm, Rusty Russell

Implement bindings for virtio save/load. Use them in virtio pci.

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

Is anyone working to fill in load/save bindings so that saving virtio
devices works? Here's a trivial patch to do this (this one is on top of my
MSI-X patchset).
Comments?

 hw/virtio-pci.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 hw/virtio.c     |   31 ++++++++++++++-----------------
 hw/virtio.h     |    4 ++++
 3 files changed, 66 insertions(+), 18 deletions(-)

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 294f4c7..589fbb1 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -105,6 +105,48 @@ static void virtio_pci_notify(void *opaque, uint16_t vector)
         qemu_set_irq(proxy->pci_dev.irq[0], proxy->vdev->isr & 1);
 }
 
+static void virtio_pci_save_config(void * opaque, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    pci_device_save(&proxy->pci_dev, f);
+    msix_save(&proxy->pci_dev, f);
+    if (msix_present(&proxy->pci_dev))
+        qemu_put_be16(f, proxy->vdev->config_vector);
+}
+
+static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    if (msix_present(&proxy->pci_dev))
+        qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n));
+}
+
+static int virtio_pci_load_config(void * opaque, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    int ret;
+    ret = pci_device_load(&proxy->pci_dev, f);
+    if (ret)
+        return ret;
+    ret = msix_load(&proxy->pci_dev, f);
+    if (ret)
+        return ret;
+    if (msix_present(&proxy->pci_dev))
+        qemu_get_be16s(f, &proxy->vdev->config_vector);
+    return 0;
+}
+
+static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
+{
+    VirtIOPCIProxy *proxy = opaque;
+    uint16_t vector;
+    if (!msix_present(&proxy->pci_dev))
+        return 0;
+    qemu_get_be16s(f, &vector);
+    virtio_queue_set_vector(proxy->vdev, n, vector);
+    return 0;
+}
+
 static void virtio_pci_reset(void *opaque)
 {
     VirtIOPCIProxy *proxy = opaque;
@@ -317,7 +359,12 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
 }
 
 static const VirtIOBindings virtio_pci_bindings = {
-    .notify = virtio_pci_notify
+    .notify = virtio_pci_notify,
+    .save_config = virtio_pci_save_config,
+    .load_config = virtio_pci_load_config,
+    .save_config = virtio_pci_save_config,
+    .save_queue = virtio_pci_save_queue,
+    .load_queue = virtio_pci_load_queue,
 };
 
 static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
diff --git a/hw/virtio.c b/hw/virtio.c
index 63ffcff..b773dff 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -568,9 +568,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
 {
     int i;
 
-    /* FIXME: load/save binding.  */
-    //pci_device_save(&vdev->pci_dev, f);
-    //msix_save(&vdev->pci_dev, f);
+    if (vdev->binding->save_config)
+        vdev->binding->save_config(vdev->binding_opaque, f);
 
     qemu_put_8s(f, &vdev->status);
     qemu_put_8s(f, &vdev->isr);
@@ -596,19 +595,20 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
         qemu_put_be32(f, vdev->vq[i].vring.num);
         qemu_put_be64(f, vdev->vq[i].pa);
         qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
-        if (vdev->nvectors)
-            qemu_put_be16s(f, &vdev->vq[i].vector);
+        if (vdev->binding->save_queue)
+            vdev->binding->save_queue(vdev->binding_opaque, i, f);
     }
 }
 
 int virtio_load(VirtIODevice *vdev, QEMUFile *f)
 {
-    int num, i;
+    int num, i, ret;
 
-    /* FIXME: load/save binding.  */
-    //pci_device_load(&vdev->pci_dev, f);
-    //r = msix_load(&vdev->pci_dev, f);
-    //pci_resize_io_region(&vdev->pci_dev, 1, msix_bar_size(&vdev->pci_dev));
+    if (vdev->binding->load_config) {
+        ret = vdev->binding->load_config(vdev->binding_opaque, f);
+        if (ret)
+            return ret;
+    }
 
     qemu_get_8s(f, &vdev->status);
     qemu_get_8s(f, &vdev->isr);
@@ -617,10 +617,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
     vdev->config_len = qemu_get_be32(f);
     qemu_get_buffer(f, vdev->config, vdev->config_len);
 
-    if (vdev->nvectors) {
-        qemu_get_be16s(f, &vdev->config_vector);
-        //msix_vector_use(&vdev->pci_dev, vdev->config_vector);
-    }
     num = qemu_get_be32(f);
 
     for (i = 0; i < num; i++) {
@@ -631,9 +627,10 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
         if (vdev->vq[i].pa) {
             virtqueue_init(&vdev->vq[i]);
         }
-        if (vdev->nvectors) {
-            qemu_get_be16s(f, &vdev->vq[i].vector);
-            //msix_vector_use(&vdev->pci_dev, vdev->config_vector);
+        if (vdev->binding->load_queue) {
+            ret = vdev->binding->load_queue(vdev->binding_opaque, i, f);
+            if (ret)
+                return ret;
         }
     }
 
diff --git a/hw/virtio.h b/hw/virtio.h
index 04a3c3d..ce05517 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -72,6 +72,10 @@ typedef struct VirtQueueElement
 
 typedef struct {
     void (*notify)(void * opaque, uint16_t vector);
+    void (*save_config)(void * opaque, QEMUFile *f);
+    void (*save_queue)(void * opaque, int n, QEMUFile *f);
+    int (*load_config)(void * opaque, QEMUFile *f);
+    int (*load_queue)(void * opaque, int n, QEMUFile *f);
 } VirtIOBindings;
 
 #define VIRTIO_PCI_QUEUE_MAX 16
-- 
1.6.3.1.56.g79e1.dirty

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

end of thread, other threads:[~2009-06-03 10:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-25 13:34 [PATCH] qemu: virtio save/load bindings Michael S. Tsirkin
2009-05-25 13:34 ` [Qemu-devel] " Michael S. Tsirkin
2009-05-26  8:34 ` Anthony Liguori
2009-05-26  8:34 ` Anthony Liguori
2009-05-26  8:34   ` [Qemu-devel] " Anthony Liguori
2009-05-26 10:20   ` Paul Brook
2009-05-26 10:20     ` [Qemu-devel] " Paul Brook
2009-05-26 10:20   ` Paul Brook
2009-06-03 10:31   ` [Qemu-devel] " Avi Kivity
2009-06-03 10:31   ` Avi Kivity
2009-06-03 10:31     ` Avi Kivity
2009-05-25 13:34 Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.