diff mbox

[v2,02/45] msix: add VMSTATE_MSIX_TEST

Message ID 1438043577-28636-3-git-send-email-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 28, 2015, 12:32 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@gmail.com>

ivshmem is going to use MSIX state conditionally.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/pci/msix.h | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Paolo Bonzini July 29, 2015, 7:41 a.m. UTC | #1
On 28/07/2015 02:32, Marc-André Lureau wrote:
> From: Marc-André Lureau <marcandre.lureau@gmail.com>
> 
> ivshmem is going to use MSIX state conditionally.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/pci/msix.h | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h
> index 954d82b..72e5f93 100644
> --- a/include/hw/pci/msix.h
> +++ b/include/hw/pci/msix.h
> @@ -46,12 +46,16 @@ void msix_unset_vector_notifiers(PCIDevice *dev);
>  
>  extern const VMStateDescription vmstate_msix;
>  
> -#define VMSTATE_MSIX(_field, _state) {                               \
> -    .name       = (stringify(_field)),                               \
> -    .size       = sizeof(PCIDevice),                                 \
> -    .vmsd       = &vmstate_msix,                                     \
> -    .flags      = VMS_STRUCT,                                        \
> -    .offset     = vmstate_offset_value(_state, _field, PCIDevice),   \
> +#define VMSTATE_MSIX_TEST(_field, _state, _test) {                   \
> +    .name         = (stringify(_field)),                             \
> +    .size         = sizeof(PCIDevice),                               \
> +    .vmsd         = &vmstate_msix,                                   \
> +    .flags        = VMS_STRUCT,                                      \
> +    .offset       = vmstate_offset_value(_state, _field, PCIDevice), \
> +    .field_exists = (_test)                                          \
>  }
>  
> +#define VMSTATE_MSIX(_f, _s)                                         \
> +    VMSTATE_MSIX_TEST(_f, _s, NULL)
> +
>  #endif
> 

Why can't it be saved unconditionally?

Paolo
Marc-André Lureau July 29, 2015, 8:28 a.m. UTC | #2
Hi

On Wed, Jul 29, 2015 at 9:41 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Why can't it be saved unconditionally?


It can, it's just that in some case (msi=0) it's unused.
Paolo Bonzini July 29, 2015, 8:31 a.m. UTC | #3
On 29/07/2015 10:28, Marc-André Lureau wrote:
>> Why can't it be saved unconditionally?
> 
> It can, it's just that in some case (msi=0) it's unused.

I think what we've been doing (e.g. hw/scsi/megasas.c) is to just always
save it.

Paolo
Marc-André Lureau July 29, 2015, 10:14 a.m. UTC | #4
Hi

On Wed, Jul 29, 2015 at 10:31 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> I think what we've been doing (e.g. hw/scsi/megasas.c) is to just always
> save it.

I don't mind, I guess I just wanted to have a similar dump as the
existing save():

    if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
        msix_save(pci_dev, f);
...
Paolo Bonzini July 29, 2015, 10:50 a.m. UTC | #5
On 29/07/2015 12:14, Marc-André Lureau wrote:
> I don't mind, I guess I just wanted to have a similar dump as the
> existing save():
> 
>     if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
>         msix_save(pci_dev, f);

Ah, okay then.

Paolo
diff mbox

Patch

diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h
index 954d82b..72e5f93 100644
--- a/include/hw/pci/msix.h
+++ b/include/hw/pci/msix.h
@@ -46,12 +46,16 @@  void msix_unset_vector_notifiers(PCIDevice *dev);
 
 extern const VMStateDescription vmstate_msix;
 
-#define VMSTATE_MSIX(_field, _state) {                               \
-    .name       = (stringify(_field)),                               \
-    .size       = sizeof(PCIDevice),                                 \
-    .vmsd       = &vmstate_msix,                                     \
-    .flags      = VMS_STRUCT,                                        \
-    .offset     = vmstate_offset_value(_state, _field, PCIDevice),   \
+#define VMSTATE_MSIX_TEST(_field, _state, _test) {                   \
+    .name         = (stringify(_field)),                             \
+    .size         = sizeof(PCIDevice),                               \
+    .vmsd         = &vmstate_msix,                                   \
+    .flags        = VMS_STRUCT,                                      \
+    .offset       = vmstate_offset_value(_state, _field, PCIDevice), \
+    .field_exists = (_test)                                          \
 }
 
+#define VMSTATE_MSIX(_f, _s)                                         \
+    VMSTATE_MSIX_TEST(_f, _s, NULL)
+
 #endif