Skip to contentSkip to conversation

hw: vfio: some trivial fix

PATCH Applied Li Qiang 5 participants 12 messages May 21, 2019 – May 22, 2019

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

v2 cover hw: vfio: some trivial fix

These patchset fix some trivial issues,
The first patch makes the code more QOMConventions. The second decouples VMStateDescription's name with QOM TypeInfo's name.
The third fixes a typo.
The fourth reduce duplicated code.

Change since v1:
Add more commit message.

Li Qiang (4):
vfio: pci: make "vfio-pci-nohotplug" as MACRO
hw: vfio: drop TYPE_FOO MACRO in VMStateDescription
vfio: platform: fix a typo
pci: msix: move 'MSIX_CAP_LENGTH' to header file

 hw/pci/msix.c           | 2 --
 hw/vfio/amd-xgbe.c      | 2 +-
 hw/vfio/ap.c            | 2 +-
 hw/vfio/calxeda-xgmac.c | 2 +-
 hw/vfio/ccw.c           | 2 +-
 hw/vfio/pci.c           | 8 ++++----
 hw/vfio/platform.c      | 6 +++---
 include/hw/pci/msix.h   | 2 ++
 8 files changed, 13 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/4 vfio: pci: make "vfio-pci-nohotplug" as MACRO

The QOMConventions recommends we should use TYPE_FOO for a TypeInfo's name. Though "vfio-pci-nohotplug" is not used in other parts, for consistency we should make this change.

---
 hw/vfio/pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/vfio/pci.c +4 -2
index 8cecb53d5c..08729e5875 100644
@@ -40,6 +40,8 @@
 #define TYPE_VFIO_PCI "vfio-pci"
 #define PCI_VFIO(obj)    OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI)
 
+#define TYPE_VIFO_PCI_NOHOTPLUG "vfio-pci-nohotplug"
+
 static void vfio_disable_interrupts(VFIOPCIDevice *vdev);
 static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled);
 
@@ -3304,8 +3306,8 @@ static void vfio_pci_nohotplug_dev_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo vfio_pci_nohotplug_dev_info = {
-    .name = "vfio-pci-nohotplug",
-    .parent = "vfio-pci",
+    .name = TYPE_VIFO_PCI_NOHOTPLUG,
+    .parent = TYPE_VFIO_PCI,
     .instance_size = sizeof(VFIOPCIDevice),
     .class_init = vfio_pci_nohotplug_dev_class_init,
 };
Signature · 1 line
2.17.1
#2 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 1/4] vfio: pci: make "vfio-pci-nohotplug" as MACRO

Quoted 25 lines · Li Qiang

The QOMConventions recommends we should use TYPE_FOO for a TypeInfo's name. Though "vfio-pci-nohotplug" is not used in other parts, for consistency we should make this change.

---
  hw/vfio/pci.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
hw/vfio/pci.c +2 -0
index 8cecb53d5c..08729e5875 100644
@@ -40,6 +40,8 @@
  #define TYPE_VFIO_PCI "vfio-pci"
  #define PCI_VFIO(obj)    OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI)
 
+#define TYPE_VIFO_PCI_NOHOTPLUG "vfio-pci-nohotplug"
+
  static void vfio_disable_interrupts(VFIOPCIDevice *vdev);
  static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled);
 

hw/vfio/pci.c static void vfio_pci_nohotplug_dev_class_init(ObjectClass *klass, void *data) · line 3313

Quoted 10 lines
hw/vfio/pci.c +2 -2
@@ -3304,8 +3306,8 @@ static void vfio_pci_nohotplug_dev_class_init(ObjectClass *klass, void *data)
  }
 
  static const TypeInfo vfio_pci_nohotplug_dev_info = {
-    .name = "vfio-pci-nohotplug",
-    .parent = "vfio-pci",
+    .name = TYPE_VIFO_PCI_NOHOTPLUG,
+    .parent = TYPE_VFIO_PCI,
      .instance_size = sizeof(VFIOPCIDevice),
      .class_init = vfio_pci_nohotplug_dev_class_init,
  };

Applied to my trivial-patches branch.

Thanks,
Laurent

author
#3 lore raw

PATCH v2 2/4 hw: vfio: drop TYPE_FOO MACRO in VMStateDescription

In reply to Li Qiang

It's recommended that VMStateDescription names are decoupled from QOM type names as the latter may freely change without consideration of migration compatibility.

---
 hw/vfio/amd-xgbe.c      | 2 +-
 hw/vfio/ap.c            | 2 +-
 hw/vfio/calxeda-xgmac.c | 2 +-
 hw/vfio/ccw.c           | 2 +-
 hw/vfio/platform.c      | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
hw/vfio/amd-xgbe.c +1 -1
index ee64a3b4a2..1b06c0f3ea 100644
@@ -26,7 +26,7 @@ static void amd_xgbe_realize(DeviceState *dev, Error **errp)
 }
 
 static const VMStateDescription vfio_platform_amd_xgbe_vmstate = {
-    .name = TYPE_VFIO_AMD_XGBE,
+    .name = "vfio-amd-xgbe",
     .unmigratable = 1,
 };
 
hw/vfio/ap.c +1 -1
index d8b79ebe53..564751650f 100644
@@ -155,7 +155,7 @@ static void vfio_ap_reset(DeviceState *dev)
 }
 
 static const VMStateDescription vfio_ap_vmstate = {
-    .name = VFIO_AP_DEVICE_TYPE,
+    .name = "vfio-ap",
     .unmigratable = 1,
 };
 
hw/vfio/calxeda-xgmac.c +1 -1
index e7767c4b02..6cc608b6ca 100644
@@ -26,7 +26,7 @@ static void calxeda_xgmac_realize(DeviceState *dev, Error **errp)
 }
 
 static const VMStateDescription vfio_platform_calxeda_xgmac_vmstate = {
-    .name = TYPE_VFIO_CALXEDA_XGMAC,
+    .name = "vfio-calxeda-xgmac",
     .unmigratable = 1,
 };
 
hw/vfio/ccw.c +1 -1
index 31dd3a2a87..d9e39552e2 100644
@@ -468,7 +468,7 @@ static Property vfio_ccw_properties[] = {
 };
 
 static const VMStateDescription vfio_ccw_vmstate = {
-    .name = TYPE_VFIO_CCW,
+    .name = "vfio-ccw",
     .unmigratable = 1,
 };
 
hw/vfio/platform.c +1 -1
index 398db38f14..e59a0234dd 100644
@@ -697,7 +697,7 @@ out:
 }
 
 static const VMStateDescription vfio_platform_vmstate = {
-    .name = TYPE_VFIO_PLATFORM,
+    .name = "vfio-platform",
     .unmigratable = 1,
 };
 
Signature · 1 line
2.17.1
#4 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 2/4] hw: vfio: drop TYPE_FOO MACRO in VMStateDescription

Quoted 74 lines · Li Qiang

It's recommended that VMStateDescription names are decoupled from QOM type names as the latter may freely change without consideration of migration compatibility.

---
  hw/vfio/amd-xgbe.c      | 2 +-
  hw/vfio/ap.c            | 2 +-
  hw/vfio/calxeda-xgmac.c | 2 +-
  hw/vfio/ccw.c           | 2 +-
  hw/vfio/platform.c      | 2 +-
  5 files changed, 5 insertions(+), 5 deletions(-)
hw/vfio/amd-xgbe.c +1 -1
index ee64a3b4a2..1b06c0f3ea 100644
@@ -26,7 +26,7 @@ static void amd_xgbe_realize(DeviceState *dev, Error **errp)
  }
 
  static const VMStateDescription vfio_platform_amd_xgbe_vmstate = {
-    .name = TYPE_VFIO_AMD_XGBE,
+    .name = "vfio-amd-xgbe",
      .unmigratable = 1,
  };
 
hw/vfio/ap.c +1 -1
index d8b79ebe53..564751650f 100644
@@ -155,7 +155,7 @@ static void vfio_ap_reset(DeviceState *dev)
  }
 
  static const VMStateDescription vfio_ap_vmstate = {
-    .name = VFIO_AP_DEVICE_TYPE,
+    .name = "vfio-ap",
      .unmigratable = 1,
  };
 
hw/vfio/calxeda-xgmac.c +1 -1
index e7767c4b02..6cc608b6ca 100644
@@ -26,7 +26,7 @@ static void calxeda_xgmac_realize(DeviceState *dev, Error **errp)
  }
 
  static const VMStateDescription vfio_platform_calxeda_xgmac_vmstate = {
-    .name = TYPE_VFIO_CALXEDA_XGMAC,
+    .name = "vfio-calxeda-xgmac",
      .unmigratable = 1,
  };
 
hw/vfio/ccw.c +1 -1
index 31dd3a2a87..d9e39552e2 100644
@@ -468,7 +468,7 @@ static Property vfio_ccw_properties[] = {
  };
 
  static const VMStateDescription vfio_ccw_vmstate = {
-    .name = TYPE_VFIO_CCW,
+    .name = "vfio-ccw",
      .unmigratable = 1,
  };
 
hw/vfio/platform.c +0 -0
index 398db38f14..e59a0234dd 100644

hw/vfio/platform.c out: · line 703

Quoted 8 lines
hw/vfio/platform.c +1 -1
@@ -697,7 +697,7 @@ out:
  }
 
  static const VMStateDescription vfio_platform_vmstate = {
-    .name = TYPE_VFIO_PLATFORM,
+    .name = "vfio-platform",
      .unmigratable = 1,
  };
 

Applied to my trivial-patches branch.

Thanks,
Laurent

author
#5 lore raw

PATCH v2 3/4 vfio: platform: fix a typo

In reply to Li Qiang

'eventd' should be 'eventfd'.

---
 hw/vfio/platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/vfio/platform.c +2 -2
index e59a0234dd..d52d6552e0 100644
@@ -72,7 +72,7 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
         g_free(intp->interrupt);
         g_free(intp);
         error_setg_errno(errp, -ret,
-                         "failed to initialize trigger eventd notifier");
+                         "failed to initialize trigger eventfd notifier");
         return NULL;
     }
     if (vfio_irq_is_automasked(intp)) {
@@ -84,7 +84,7 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
             g_free(intp->unmask);
             g_free(intp);
             error_setg_errno(errp, -ret,
-                             "failed to initialize resample eventd notifier");
+                             "failed to initialize resample eventfd notifier");
             return NULL;
         }
     }
Signature · 1 line
2.17.1
#6 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 3/4] vfio: platform: fix a typo

Quoted 23 lines · Li Qiang

'eventd' should be 'eventfd'.

---
  hw/vfio/platform.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/vfio/platform.c +1 -1
index e59a0234dd..d52d6552e0 100644
@@ -72,7 +72,7 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
          g_free(intp->interrupt);
          g_free(intp);
          error_setg_errno(errp, -ret,
-                         "failed to initialize trigger eventd notifier");
+                         "failed to initialize trigger eventfd notifier");
          return NULL;
      }
      if (vfio_irq_is_automasked(intp)) {

hw/vfio/platform.c static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, · line 90

Quoted 8 lines
hw/vfio/platform.c +1 -1
@@ -84,7 +84,7 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
              g_free(intp->unmask);
              g_free(intp);
              error_setg_errno(errp, -ret,
-                             "failed to initialize resample eventd notifier");
+                             "failed to initialize resample eventfd notifier");
              return NULL;
          }
      }

Applied to my trivial-patches branch.

Thanks,
Laurent

author
#7 lore raw

PATCH v2 4/4 pci: msix: move 'MSIX_CAP_LENGTH' to header file

In reply to Li Qiang

'MSIX_CAP_LENGTH' is defined in two .c file. Move it to hw/pci/msix.h file to reduce duplicated code.

---
 hw/pci/msix.c         | 2 --
 hw/vfio/pci.c         | 2 --
 include/hw/pci/msix.h | 2 ++
 3 files changed, 2 insertions(+), 4 deletions(-)
hw/pci/msix.c +0 -2
index 4e336416a7..d39dcf32e8 100644
@@ -24,8 +24,6 @@
 #include "qapi/error.h"
 #include "trace.h"
 
-#define MSIX_CAP_LENGTH 12
-
 /* MSI enable bit and maskall bit are in byte 1 in FLAGS register */
 #define MSIX_CONTROL_OFFSET (PCI_MSIX_FLAGS + 1)
 #define MSIX_ENABLE_MASK (PCI_MSIX_FLAGS_ENABLE >> 8)
hw/vfio/pci.c +0 -2
index 08729e5875..8e555db12e 100644
@@ -35,8 +35,6 @@
 #include "trace.h"
 #include "qapi/error.h"
 
-#define MSIX_CAP_LENGTH 12
-
 #define TYPE_VFIO_PCI "vfio-pci"
 #define PCI_VFIO(obj)    OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI)
 
include/hw/pci/msix.h +2 -0
index 1f27658d35..08acfa836e 100644
@@ -4,6 +4,8 @@
 #include "qemu-common.h"
 #include "hw/pci/pci.h"
 
+#define MSIX_CAP_LENGTH 12
+
 void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
 MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector);
 int msix_init(PCIDevice *dev, unsigned short nentries,
Signature · 1 line
2.17.1
#8 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 4/4] pci: msix: move 'MSIX_CAP_LENGTH' to header file

Quoted 43 lines · Li Qiang

'MSIX_CAP_LENGTH' is defined in two .c file. Move it to hw/pci/msix.h file to reduce duplicated code.

---
  hw/pci/msix.c         | 2 --
  hw/vfio/pci.c         | 2 --
  include/hw/pci/msix.h | 2 ++
  3 files changed, 2 insertions(+), 4 deletions(-)
hw/pci/msix.c +0 -2
index 4e336416a7..d39dcf32e8 100644
@@ -24,8 +24,6 @@
  #include "qapi/error.h"
  #include "trace.h"
 
-#define MSIX_CAP_LENGTH 12
-
  /* MSI enable bit and maskall bit are in byte 1 in FLAGS register */
  #define MSIX_CONTROL_OFFSET (PCI_MSIX_FLAGS + 1)
  #define MSIX_ENABLE_MASK (PCI_MSIX_FLAGS_ENABLE >> 8)
hw/vfio/pci.c +0 -2
index 08729e5875..8e555db12e 100644
@@ -35,8 +35,6 @@
  #include "trace.h"
  #include "qapi/error.h"
 
-#define MSIX_CAP_LENGTH 12
-
  #define TYPE_VFIO_PCI "vfio-pci"
  #define PCI_VFIO(obj)    OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI)
 
include/hw/pci/msix.h +0 -0
index 1f27658d35..08acfa836e 100644

include/hw/pci/msix.h line 11

Quoted 8 lines
include/hw/pci/msix.h +2 -0
@@ -4,6 +4,8 @@
  #include "qemu-common.h"
  #include "hw/pci/pci.h"
 
+#define MSIX_CAP_LENGTH 12
+
  void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
  MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector);
  int msix_init(PCIDevice *dev, unsigned short nentries,

Applied to my trivial-patches branch.

Thanks,
Laurent

Acked-by on the v2 series
#9 lore raw
In reply to Li Qiang
Quoted 9 lines · On Tue, 21 May 2019 08:15:39 -0700 Li Qiang <[email protected]> wrote:

These patchset fix some trivial issues,
The first patch makes the code more QOMConventions. The second decouples VMStateDescription's name with QOM TypeInfo's name.
The third fixes a typo.
The fourth reduce duplicated code.

Change since v1:
Add more commit message.

Thank you for making this series 'trivial' by providing explanation and justification for each change. If trivial wants to include this, for series:

Reviewed-by on the v2 series
#10 lore raw
In reply to Li Qiang
Quoted 7 lines · Li Qiang

These patchset fix some trivial issues,
The first patch makes the code more QOMConventions. The second decouples VMStateDescription's name with QOM TypeInfo's name.
The third fixes a typo.
The fourth reduce duplicated code.

Quoted 8 lines

Change since v1:
Add more commit message.

Li Qiang (4):
vfio: pci: make "vfio-pci-nohotplug" as MACRO
hw: vfio: drop TYPE_FOO MACRO in VMStateDescription
vfio: platform: fix a typo
pci: msix: move 'MSIX_CAP_LENGTH' to header file

Series:

Reviewed-by on the v2 series
#11 lore raw
In reply to Li Qiang

Hi,

Quoted 9 lines · Li Qiang

These patchset fix some trivial issues,
The first patch makes the code more QOMConventions. The second decouples VMStateDescription's name with QOM TypeInfo's name.
The third fixes a typo.
The fourth reduce duplicated code.

Change since v1:
Add more commit message.

Thanks

Eric

Quoted 17 lines

Li Qiang (4):
vfio: pci: make "vfio-pci-nohotplug" as MACRO
hw: vfio: drop TYPE_FOO MACRO in VMStateDescription
vfio: platform: fix a typo
pci: msix: move 'MSIX_CAP_LENGTH' to header file

 hw/pci/msix.c           | 2 --
 hw/vfio/amd-xgbe.c      | 2 +-
 hw/vfio/ap.c            | 2 +-
 hw/vfio/calxeda-xgmac.c | 2 +-
 hw/vfio/ccw.c           | 2 +-
 hw/vfio/pci.c           | 8 ++++----
 hw/vfio/platform.c      | 6 +++---
 include/hw/pci/msix.h   | 2 ++
 8 files changed, 13 insertions(+), 13 deletions(-)