[PATCH v2 04/10] hw/core/boards: Remove MachineClass::smbus_no_migration_support field

Philippe Mathieu-Daudé posted 10 patches 1 month ago
Maintainers: "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Eduardo Habkost <eduardo@habkost.net>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Paolo Bonzini <pbonzini@redhat.com>, Corey Minyard <cminyard@mvista.com>, Richard Henderson <richard.henderson@linaro.org>, Jason Wang <jasowang@redhat.com>, Yi Liu <yi.l.liu@intel.com>, "Clément Mathieu--Drif" <clement.mathieu--drif@bull.com>, Sergio Lopez <slp@redhat.com>, Alexander Graf <graf@amazon.com>, Dorjoy Chowdhury <dorjoychy111@gmail.com>, Stefan Berger <stefanb@linux.vnet.ibm.com>
[PATCH v2 04/10] hw/core/boards: Remove MachineClass::smbus_no_migration_support field
Posted by Philippe Mathieu-Daudé 1 month ago
The MachineClass::smbus_no_migration_support boolean was only used
by the pc-q35-3.1 and pc-i440fx-3.1 machines, which got removed.
Remove it, along with pm_smbus_vmstate_needed().

Use the unconditional VMSTATE_BOOL() and VMSTATE_STRUCT() macros.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20260307152635.83893-5-philmd@linaro.org>
---
 include/hw/core/boards.h  |  1 -
 include/hw/i2c/pm_smbus.h |  7 -------
 hw/acpi/piix4.c           |  8 +-------
 hw/i2c/pm_smbus.c         |  7 -------
 hw/i2c/smbus_eeprom.c     |  4 +---
 hw/i2c/smbus_ich9.c       | 10 ++--------
 6 files changed, 4 insertions(+), 33 deletions(-)

diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h
index 9ad2a7d5c97..e15dbcea83b 100644
--- a/include/hw/core/boards.h
+++ b/include/hw/core/boards.h
@@ -314,7 +314,6 @@ struct MachineClass {
     bool auto_enable_numa_with_memhp;
     bool auto_enable_numa_with_memdev;
     bool ignore_boot_device_suffixes;
-    bool smbus_no_migration_support;
     bool nvdimm_supported;
     bool numa_mem_supported;
     bool auto_enable_numa;
diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h
index dafe0df4f69..62bbd45e803 100644
--- a/include/hw/i2c/pm_smbus.h
+++ b/include/hw/i2c/pm_smbus.h
@@ -44,13 +44,6 @@ typedef struct PMSMBus {
 
 void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk);
 
-/*
- * For backwards compatibility on migration, older versions don't have
- * working migration for pm_smbus, this lets us ignore the migrations
- * for older machine versions.
- */
-bool pm_smbus_vmstate_needed(void);
-
 extern const VMStateDescription pmsmb_vmstate;
 
 #endif /* PM_SMBUS_H */
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 138ac3d3940..43860d12278 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -205,11 +205,6 @@ static const VMStateDescription vmstate_cpuhp_state = {
     }
 };
 
-static bool piix4_vmstate_need_smbus(void *opaque, int version_id)
-{
-    return pm_smbus_vmstate_needed();
-}
-
 /*
  * This is a fudge to turn off the acpi_index field,
  * whose test was always broken on piix4 with 6.2 and older machine types.
@@ -238,8 +233,7 @@ static const VMStateDescription vmstate_acpi = {
         VMSTATE_UINT16(ar.pm1.evt.en, PIIX4PMState),
         VMSTATE_UINT16(ar.pm1.cnt.cnt, PIIX4PMState),
         VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState),
-        VMSTATE_STRUCT_TEST(smb, PIIX4PMState, piix4_vmstate_need_smbus, 3,
-                            pmsmb_vmstate, PMSMBus),
+        VMSTATE_STRUCT(smb, PIIX4PMState, 3, pmsmb_vmstate, PMSMBus),
         VMSTATE_TIMER_PTR(ar.tmr.timer, PIIX4PMState),
         VMSTATE_INT64(ar.tmr.overflow_time, PIIX4PMState),
         VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE),
diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index ead53d2724d..5654d516382 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -443,13 +443,6 @@ static const MemoryRegionOps pm_smbus_ops = {
     .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
-bool pm_smbus_vmstate_needed(void)
-{
-    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
-
-    return !mc->smbus_no_migration_support;
-}
-
 const VMStateDescription pmsmb_vmstate = {
     .name = "pmsmb",
     .version_id = 1,
diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
index d9ac556a0ab..693d4762205 100644
--- a/hw/i2c/smbus_eeprom.c
+++ b/hw/i2c/smbus_eeprom.c
@@ -88,11 +88,9 @@ static int eeprom_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len)
 
 static bool smbus_eeprom_vmstate_needed(void *opaque)
 {
-    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
     SMBusEEPROMDevice *eeprom = opaque;
 
-    return (eeprom->accessed || smbus_vmstate_needed(&eeprom->smbusdev)) &&
-        !mc->smbus_no_migration_support;
+    return eeprom->accessed || smbus_vmstate_needed(&eeprom->smbusdev);
 }
 
 static const VMStateDescription vmstate_smbus_eeprom = {
diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
index 956c9b59bbc..51513e73fde 100644
--- a/hw/i2c/smbus_ich9.c
+++ b/hw/i2c/smbus_ich9.c
@@ -41,20 +41,14 @@ struct ICH9SMBState {
     PMSMBus smb;
 };
 
-static bool ich9_vmstate_need_smbus(void *opaque, int version_id)
-{
-    return pm_smbus_vmstate_needed();
-}
-
 static const VMStateDescription vmstate_ich9_smbus = {
     .name = "ich9_smb",
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (const VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, ICH9SMBState),
-        VMSTATE_BOOL_TEST(irq_enabled, ICH9SMBState, ich9_vmstate_need_smbus),
-        VMSTATE_STRUCT_TEST(smb, ICH9SMBState, ich9_vmstate_need_smbus, 1,
-                            pmsmb_vmstate, PMSMBus),
+        VMSTATE_BOOL(irq_enabled, ICH9SMBState),
+        VMSTATE_STRUCT(smb, ICH9SMBState, 1, pmsmb_vmstate, PMSMBus),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
2.53.0


Re: [PATCH v2 04/10] hw/core/boards: Remove MachineClass::smbus_no_migration_support field
Posted by Zhao Liu 1 month ago
On Mon, Mar 09, 2026 at 03:50:06PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Mon,  9 Mar 2026 15:50:06 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v2 04/10] hw/core/boards: Remove
>  MachineClass::smbus_no_migration_support field
> X-Mailer: git-send-email 2.53.0
> 
> The MachineClass::smbus_no_migration_support boolean was only used
> by the pc-q35-3.1 and pc-i440fx-3.1 machines, which got removed.
> Remove it, along with pm_smbus_vmstate_needed().
> 
> Use the unconditional VMSTATE_BOOL() and VMSTATE_STRUCT() macros.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Message-Id: <20260307152635.83893-5-philmd@linaro.org>
> ---
>  include/hw/core/boards.h  |  1 -
>  include/hw/i2c/pm_smbus.h |  7 -------
>  hw/acpi/piix4.c           |  8 +-------
>  hw/i2c/pm_smbus.c         |  7 -------
>  hw/i2c/smbus_eeprom.c     |  4 +---
>  hw/i2c/smbus_ich9.c       | 10 ++--------
>  6 files changed, 4 insertions(+), 33 deletions(-)

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Re: [PATCH v2 04/10] hw/core/boards: Remove MachineClass::smbus_no_migration_support field
Posted by Corey Minyard 1 month ago
On Mon, Mar 09, 2026 at 03:50:06PM +0100, Philippe Mathieu-Daudé wrote:
> The MachineClass::smbus_no_migration_support boolean was only used
> by the pc-q35-3.1 and pc-i440fx-3.1 machines, which got removed.
> Remove it, along with pm_smbus_vmstate_needed().
> 
> Use the unconditional VMSTATE_BOOL() and VMSTATE_STRUCT() macros.

Nice.

Acked-by: Corey Minyard <corey@minyard.net>

or do you want me to handle it?

-corey

> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Message-Id: <20260307152635.83893-5-philmd@linaro.org>
> ---
>  include/hw/core/boards.h  |  1 -
>  include/hw/i2c/pm_smbus.h |  7 -------
>  hw/acpi/piix4.c           |  8 +-------
>  hw/i2c/pm_smbus.c         |  7 -------
>  hw/i2c/smbus_eeprom.c     |  4 +---
>  hw/i2c/smbus_ich9.c       | 10 ++--------
>  6 files changed, 4 insertions(+), 33 deletions(-)
> 
> diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h
> index 9ad2a7d5c97..e15dbcea83b 100644
> --- a/include/hw/core/boards.h
> +++ b/include/hw/core/boards.h
> @@ -314,7 +314,6 @@ struct MachineClass {
>      bool auto_enable_numa_with_memhp;
>      bool auto_enable_numa_with_memdev;
>      bool ignore_boot_device_suffixes;
> -    bool smbus_no_migration_support;
>      bool nvdimm_supported;
>      bool numa_mem_supported;
>      bool auto_enable_numa;
> diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h
> index dafe0df4f69..62bbd45e803 100644
> --- a/include/hw/i2c/pm_smbus.h
> +++ b/include/hw/i2c/pm_smbus.h
> @@ -44,13 +44,6 @@ typedef struct PMSMBus {
>  
>  void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk);
>  
> -/*
> - * For backwards compatibility on migration, older versions don't have
> - * working migration for pm_smbus, this lets us ignore the migrations
> - * for older machine versions.
> - */
> -bool pm_smbus_vmstate_needed(void);
> -
>  extern const VMStateDescription pmsmb_vmstate;
>  
>  #endif /* PM_SMBUS_H */
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index 138ac3d3940..43860d12278 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -205,11 +205,6 @@ static const VMStateDescription vmstate_cpuhp_state = {
>      }
>  };
>  
> -static bool piix4_vmstate_need_smbus(void *opaque, int version_id)
> -{
> -    return pm_smbus_vmstate_needed();
> -}
> -
>  /*
>   * This is a fudge to turn off the acpi_index field,
>   * whose test was always broken on piix4 with 6.2 and older machine types.
> @@ -238,8 +233,7 @@ static const VMStateDescription vmstate_acpi = {
>          VMSTATE_UINT16(ar.pm1.evt.en, PIIX4PMState),
>          VMSTATE_UINT16(ar.pm1.cnt.cnt, PIIX4PMState),
>          VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState),
> -        VMSTATE_STRUCT_TEST(smb, PIIX4PMState, piix4_vmstate_need_smbus, 3,
> -                            pmsmb_vmstate, PMSMBus),
> +        VMSTATE_STRUCT(smb, PIIX4PMState, 3, pmsmb_vmstate, PMSMBus),
>          VMSTATE_TIMER_PTR(ar.tmr.timer, PIIX4PMState),
>          VMSTATE_INT64(ar.tmr.overflow_time, PIIX4PMState),
>          VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE),
> diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
> index ead53d2724d..5654d516382 100644
> --- a/hw/i2c/pm_smbus.c
> +++ b/hw/i2c/pm_smbus.c
> @@ -443,13 +443,6 @@ static const MemoryRegionOps pm_smbus_ops = {
>      .endianness = DEVICE_LITTLE_ENDIAN,
>  };
>  
> -bool pm_smbus_vmstate_needed(void)
> -{
> -    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
> -
> -    return !mc->smbus_no_migration_support;
> -}
> -
>  const VMStateDescription pmsmb_vmstate = {
>      .name = "pmsmb",
>      .version_id = 1,
> diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
> index d9ac556a0ab..693d4762205 100644
> --- a/hw/i2c/smbus_eeprom.c
> +++ b/hw/i2c/smbus_eeprom.c
> @@ -88,11 +88,9 @@ static int eeprom_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len)
>  
>  static bool smbus_eeprom_vmstate_needed(void *opaque)
>  {
> -    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
>      SMBusEEPROMDevice *eeprom = opaque;
>  
> -    return (eeprom->accessed || smbus_vmstate_needed(&eeprom->smbusdev)) &&
> -        !mc->smbus_no_migration_support;
> +    return eeprom->accessed || smbus_vmstate_needed(&eeprom->smbusdev);
>  }
>  
>  static const VMStateDescription vmstate_smbus_eeprom = {
> diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
> index 956c9b59bbc..51513e73fde 100644
> --- a/hw/i2c/smbus_ich9.c
> +++ b/hw/i2c/smbus_ich9.c
> @@ -41,20 +41,14 @@ struct ICH9SMBState {
>      PMSMBus smb;
>  };
>  
> -static bool ich9_vmstate_need_smbus(void *opaque, int version_id)
> -{
> -    return pm_smbus_vmstate_needed();
> -}
> -
>  static const VMStateDescription vmstate_ich9_smbus = {
>      .name = "ich9_smb",
>      .version_id = 1,
>      .minimum_version_id = 1,
>      .fields = (const VMStateField[]) {
>          VMSTATE_PCI_DEVICE(dev, ICH9SMBState),
> -        VMSTATE_BOOL_TEST(irq_enabled, ICH9SMBState, ich9_vmstate_need_smbus),
> -        VMSTATE_STRUCT_TEST(smb, ICH9SMBState, ich9_vmstate_need_smbus, 1,
> -                            pmsmb_vmstate, PMSMBus),
> +        VMSTATE_BOOL(irq_enabled, ICH9SMBState),
> +        VMSTATE_STRUCT(smb, ICH9SMBState, 1, pmsmb_vmstate, PMSMBus),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> -- 
> 2.53.0
>