diff mbox

[v4,4/9] MSI-X state save/load invocations moved to PCI Device save/load callbacks to avoid code duplication in MSI-X-enabled devices that support live migration

Message ID 1331845748-6026-5-git-send-email-dmitry.fleytman@ravellosystems.com
State New
Headers show

Commit Message

Dmitry Fleytman March 15, 2012, 9:09 p.m. UTC
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Yan Vugenfirer <yan@daynix.com>
---
 hw/pci.c        |    5 +++++
 hw/virtio-pci.c |    2 --
 2 files changed, 5 insertions(+), 2 deletions(-)

Comments

Michael S. Tsirkin March 15, 2012, 11 p.m. UTC | #1
On Thu, Mar 15, 2012 at 11:09:03PM +0200, Dmitry Fleytman wrote:
> Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
> Signed-off-by: Yan Vugenfirer <yan@daynix.com>

I'm working on a higher level API that will
handle all capabilities. For now, pls just put
these calls in your device.


> ---
>  hw/pci.c        |    5 +++++
>  hw/virtio-pci.c |    2 --
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index bf046bf..9146d3f 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -31,6 +31,7 @@
>  #include "loader.h"
>  #include "range.h"
>  #include "qmp-commands.h"
> +#include "msix.h"
>  
>  //#define DEBUG_PCI
>  #ifdef DEBUG_PCI
> @@ -387,6 +388,8 @@ static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
>          pci_set_irq_state(s, i, irq_state[i]);
>      }
>  
> +    msix_load(s, f);
> +
>      return 0;
>  }
>  
> @@ -398,6 +401,8 @@ static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
>      for (i = 0; i < PCI_NUM_PINS; ++i) {
>          qemu_put_be32(f, pci_irq_state(s, i));
>      }
> +
> +    msix_save(s, f);
>  }
>  
>  static VMStateInfo vmstate_info_pci_irq_state = {
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index a0fb7c1..2f3cb1f 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -110,7 +110,6 @@ 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);
>  }
> @@ -130,7 +129,6 @@ static int virtio_pci_load_config(void * opaque, QEMUFile *f)
>      if (ret) {
>          return ret;
>      }
> -    msix_load(&proxy->pci_dev, f);
>      if (msix_present(&proxy->pci_dev)) {
>          qemu_get_be16s(f, &proxy->vdev->config_vector);
>      } else {
> -- 
> 1.7.7.6
Dmitry Fleytman March 16, 2012, 9:18 a.m. UTC | #2
Michael,

Great. I believe higher level API if what really needed here.
I'll revert this patch and move msix_load/store invocations into the
device code.

Thanks.

On Fri, Mar 16, 2012 at 1:00 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Thu, Mar 15, 2012 at 11:09:03PM +0200, Dmitry Fleytman wrote:
>> Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
>> Signed-off-by: Yan Vugenfirer <yan@daynix.com>
>
> I'm working on a higher level API that will
> handle all capabilities. For now, pls just put
> these calls in your device.
>
>
>> ---
>>  hw/pci.c        |    5 +++++
>>  hw/virtio-pci.c |    2 --
>>  2 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/pci.c b/hw/pci.c
>> index bf046bf..9146d3f 100644
>> --- a/hw/pci.c
>> +++ b/hw/pci.c
>> @@ -31,6 +31,7 @@
>>  #include "loader.h"
>>  #include "range.h"
>>  #include "qmp-commands.h"
>> +#include "msix.h"
>>
>>  //#define DEBUG_PCI
>>  #ifdef DEBUG_PCI
>> @@ -387,6 +388,8 @@ static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
>>          pci_set_irq_state(s, i, irq_state[i]);
>>      }
>>
>> +    msix_load(s, f);
>> +
>>      return 0;
>>  }
>>
>> @@ -398,6 +401,8 @@ static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
>>      for (i = 0; i < PCI_NUM_PINS; ++i) {
>>          qemu_put_be32(f, pci_irq_state(s, i));
>>      }
>> +
>> +    msix_save(s, f);
>>  }
>>
>>  static VMStateInfo vmstate_info_pci_irq_state = {
>> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
>> index a0fb7c1..2f3cb1f 100644
>> --- a/hw/virtio-pci.c
>> +++ b/hw/virtio-pci.c
>> @@ -110,7 +110,6 @@ 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);
>>  }
>> @@ -130,7 +129,6 @@ static int virtio_pci_load_config(void * opaque, QEMUFile *f)
>>      if (ret) {
>>          return ret;
>>      }
>> -    msix_load(&proxy->pci_dev, f);
>>      if (msix_present(&proxy->pci_dev)) {
>>          qemu_get_be16s(f, &proxy->vdev->config_vector);
>>      } else {
>> --
>> 1.7.7.6
diff mbox

Patch

diff --git a/hw/pci.c b/hw/pci.c
index bf046bf..9146d3f 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -31,6 +31,7 @@ 
 #include "loader.h"
 #include "range.h"
 #include "qmp-commands.h"
+#include "msix.h"
 
 //#define DEBUG_PCI
 #ifdef DEBUG_PCI
@@ -387,6 +388,8 @@  static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
         pci_set_irq_state(s, i, irq_state[i]);
     }
 
+    msix_load(s, f);
+
     return 0;
 }
 
@@ -398,6 +401,8 @@  static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
     for (i = 0; i < PCI_NUM_PINS; ++i) {
         qemu_put_be32(f, pci_irq_state(s, i));
     }
+
+    msix_save(s, f);
 }
 
 static VMStateInfo vmstate_info_pci_irq_state = {
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index a0fb7c1..2f3cb1f 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -110,7 +110,6 @@  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);
 }
@@ -130,7 +129,6 @@  static int virtio_pci_load_config(void * opaque, QEMUFile *f)
     if (ret) {
         return ret;
     }
-    msix_load(&proxy->pci_dev, f);
     if (msix_present(&proxy->pci_dev)) {
         qemu_get_be16s(f, &proxy->vdev->config_vector);
     } else {