qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pci/pci_expander_bridge: migrate state of pxb/pxb-pcie devic


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH] pci/pci_expander_bridge: migrate state of pxb/pxb-pcie devices.
Date: Sat, 13 Aug 2022 19:23:58 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1

[add migration maintainers]

On 8/11/22 19:49, Andrey Ryabinin wrote:
pxb/pxb-pcie/pxb-cxl devices currently doesn't have vmstate description
So the state of device is not preserved during migration and
guest can notice that as change of PCI_COMMAND_* registers state.

The diff of lspci output before and after migration:

  00:03.0 Host bridge [0600]: Red Hat, Inc. QEMU PCIe Expander bridge 
[1b36:000b]
          Subsystem: Red Hat, Inc QEMU PCIe Expander bridge [1af4:1100]
  -       Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- 
Stepping- SERR+ FastB2B- DisINTx-
  +       Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- 
Stepping- SERR- FastB2B- DisINTx-
          Status: Cap- 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- 
<MAbort- >SERR- <PERR- INTx-

Add VMStateDescription to pxb devices so their state is transferred
during migrations. For saving migration compatibility add
'x-config-reg-migration-enabled' property to pxb devices and disable
it for all released machine types.

Signed-off-by: Andrey Ryabinin <arbn@yandex-team.com>
---
  hw/core/machine.c                   |  3 +++
  hw/pci-bridge/pci_expander_bridge.c | 24 ++++++++++++++++++++++++
  include/hw/pci/pci_bridge.h         |  1 +
  3 files changed, 28 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index a673302ccec..071853469e2 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -43,6 +43,9 @@
  GlobalProperty hw_compat_7_0[] = {
      { "arm-gicv3-common", "force-8-bit-prio", "on" },
      { "nvme-ns", "eui64-default", "on"},
+    { "pxb", "x-config-reg-migration-enabled", "off" },
+    { "pxb-cxl", "x-config-reg-migration-enabled", "off" },
+    { "pxb-pcie", "x-config-reg-migration-enabled", "off" },


Seems that it's too late for 7.1, rc2 is out and rc3 is coming soon. And that's 
not a degradation.

Up to maintainers, but I think we'd better start new hw_compat_7_1 for this 
thing.


  };
  const size_t hw_compat_7_0_len = G_N_ELEMENTS(hw_compat_7_0);
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index c9e817aa586..a3680d4d045 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -23,6 +23,7 @@
  #include "qemu/error-report.h"
  #include "qemu/module.h"
  #include "sysemu/numa.h"
+#include "migration/vmstate.h"
  #include "hw/boards.h"
  #include "qom/object.h"
@@ -404,9 +405,29 @@ static Property pxb_dev_properties[] = {
      DEFINE_PROP_UINT8("bus_nr", PXBDev, bus_nr, 0),
      DEFINE_PROP_UINT16("numa_node", PXBDev, numa_node, NUMA_NODE_UNASSIGNED),
      DEFINE_PROP_BOOL("bypass_iommu", PXBDev, bypass_iommu, false),
+    DEFINE_PROP_BOOL("x-config-reg-migration-enabled", PXBDev,
+                     migratable, true),

With it, do we create a user-visible property? If so, is it possible to avoid 
it?

      DEFINE_PROP_END_OF_LIST(),
  };
+static bool pxb_vmstate_needed(void *opaque)
+{
+    PXBDev *pxb = opaque;
+
+    return pxb->migratable;
+}
+
+static const VMStateDescription vmstate_pxb_device = {
+    .name = "pxb-pci",
+    .needed = pxb_vmstate_needed,
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_PCI_DEVICE(parent_obj, PXBDev),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
  static void pxb_dev_class_init(ObjectClass *klass, void *data)
  {
      DeviceClass *dc = DEVICE_CLASS(klass);
@@ -422,6 +443,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void 
*data)
      device_class_set_props(dc, pxb_dev_properties);
      dc->hotpluggable = false;
      set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
+    dc->vmsd = &vmstate_pxb_device;
  }
static const TypeInfo pxb_dev_info = {
@@ -460,6 +482,7 @@ static void pxb_pcie_dev_class_init(ObjectClass *klass, 
void *data)
      device_class_set_props(dc, pxb_dev_properties);
      dc->hotpluggable = false;
      set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
+    dc->vmsd = &vmstate_pxb_device;
  }
static const TypeInfo pxb_pcie_dev_info = {
@@ -504,6 +527,7 @@ static void pxb_cxl_dev_class_init(ObjectClass *klass, void 
*data)
      /* Host bridges aren't hotpluggable. FIXME: spec reference */
      dc->hotpluggable = false;
      dc->reset = pxb_dev_reset;
+    dc->vmsd = &vmstate_pxb_device;
  }
static const TypeInfo pxb_cxl_dev_info = {
diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h
index ba4bafac7c2..404dc02e36e 100644
--- a/include/hw/pci/pci_bridge.h
+++ b/include/hw/pci/pci_bridge.h
@@ -91,6 +91,7 @@ struct PXBDev {
      uint8_t bus_nr;
      uint16_t numa_node;
      bool bypass_iommu;
+    bool migratable;
      struct cxl_dev {
          CXLHost *cxl_host_bridge; /* Pointer to a CXLHost */
      } cxl;


--
Best regards,
Vladimir



reply via email to

[Prev in Thread] Current Thread [Next in Thread]