All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pci/pci_expander_bridge: migrate state of pxb/pxb-pcie devices.
@ 2022-08-11 16:49 Andrey Ryabinin
  2022-08-13 16:23 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 3+ messages in thread
From: Andrey Ryabinin @ 2022-08-11 16:49 UTC (permalink / raw)
  To: Eduardo Habkost, Marcel Apfelbaum, Philippe Mathieu-Daudé,
	Yanan Wang, Michael S. Tsirkin
  Cc: qemu-devel, yc-core, Andrey Ryabinin

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" },
 };
 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),
     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;
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pci/pci_expander_bridge: migrate state of pxb/pxb-pcie devices.
  2022-08-11 16:49 [PATCH] pci/pci_expander_bridge: migrate state of pxb/pxb-pcie devices Andrey Ryabinin
@ 2022-08-13 16:23 ` Vladimir Sementsov-Ogievskiy
  2022-08-18 13:04   ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2022-08-13 16:23 UTC (permalink / raw)
  To: Andrey Ryabinin, Eduardo Habkost, Marcel Apfelbaum,
	Philippe Mathieu-Daudé,
	Yanan Wang, Michael S. Tsirkin, Dr. David Alan Gilbert, quintela
  Cc: qemu-devel, yc-core

[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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pci/pci_expander_bridge: migrate state of pxb/pxb-pcie devices.
  2022-08-13 16:23 ` Vladimir Sementsov-Ogievskiy
@ 2022-08-18 13:04   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2022-08-18 13:04 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Andrey Ryabinin, Eduardo Habkost, Marcel Apfelbaum,
	Philippe Mathieu-Daudé,
	Yanan Wang, Michael S. Tsirkin, quintela, qemu-devel, yc-core

* Vladimir Sementsov-Ogievskiy (vsementsov@yandex-team.ru) wrote:
> [add migration maintainers]

Thanks,

> 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-

Do you notice any other symptoms other than that minor diff?

> > 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.

Yeh

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

Yep.


Dave
> 
> >   };
> >   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
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-18 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-11 16:49 [PATCH] pci/pci_expander_bridge: migrate state of pxb/pxb-pcie devices Andrey Ryabinin
2022-08-13 16:23 ` Vladimir Sementsov-Ogievskiy
2022-08-18 13:04   ` Dr. David Alan Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.