Skip to contentSkip to conversation

Add live migration support in the PVRDMA device

PATCH In review Sukrit Bhatnagar 3 participants 14 messages Aug 28, 2019 – Sep 4, 2019

lore
Share & tools
lore
#0 lore raw

cover Add live migration support in the PVRDMA device

This series enables the migration of various GIDs used by the device. This is in addition to the successful migration of PCI and MSIX states as well as various DMA addresses and ring page information.

We have a setup having two hosts and two VMs running atop them. Migrations are performed over the local network.

We also have performed various ping-pong tests (ibv_rc_pingpong) in the guest(s) after adding GID migration support and this is the current status:
- ping-pong to localhost succeeds, when performed before starting the migration and after the completion of migration.
- ping-pong to a peer succeeds, both before and after migration as above, provided that both VMs are running on/migrated to the same host. So, if two VMs were started on two different hosts, and one of them was migrated to the other host, the ping-pong was successful. Similarly, if two VMs are migrated to the same host, then after migration, the ping-pong was successful.
- ping-pong to a peer on the remote host is not working as of now.

Our next goal is to achieve successful migration with live traffic.

This is the same as the RFC v3 series posted earlier:
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04752.html
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04753.html
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04754.html

Sukrit Bhatnagar (2):
hw/pvrdma: make DSR mapping idempotent in load_dsr() hw/pvrdma: add live migration support

 hw/rdma/vmw/pvrdma_main.c | 94 +++++++++++++++++++++++++++++++++++----
 1 file changed, 86 insertions(+), 8 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/2 hw/pvrdma: make DSR mapping idempotent in load_dsr()

Map to DSR only when there is no mapping done already i.e., when dev->dsr_info.dsr is NULL. This allows the rest of mappings and ring inits to be done by calling load_dsr() when DSR has already been mapped to, somewhere else.

Move free_dsr() out of load_dsr() and call it before the latter as and when needed. This aids the case where load_dsr() is called having DSR mapping already done, but the rest of map and init operations are pending, and prevents an unmap of the DSR.

Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
 hw/rdma/vmw/pvrdma_main.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
hw/rdma/vmw/pvrdma_main.c +9 -8
index adcf79cd63..6c90db96f9 100644
@@ -172,15 +172,15 @@ static int load_dsr(PVRDMADev *dev)
     DSRInfo *dsr_info;
     struct pvrdma_device_shared_region *dsr;
 
-    free_dsr(dev);
-
-    /* Map to DSR */
-    dev->dsr_info.dsr = rdma_pci_dma_map(pci_dev, dev->dsr_info.dma,
-                              sizeof(struct pvrdma_device_shared_region));
     if (!dev->dsr_info.dsr) {
-        rdma_error_report("Failed to map to DSR");
-        rc = -ENOMEM;
-        goto out;
+        /* Map to DSR */
+        dev->dsr_info.dsr = rdma_pci_dma_map(pci_dev, dev->dsr_info.dma,
+                                  sizeof(struct pvrdma_device_shared_region));
+        if (!dev->dsr_info.dsr) {
+            rdma_error_report("Failed to map to DSR");
+            rc = -ENOMEM;
+            goto out;
+        }
     }
 
     /* Shortcuts */
@@ -402,6 +402,7 @@ static void pvrdma_regs_write(void *opaque, hwaddr addr, uint64_t val,
     case PVRDMA_REG_DSRHIGH:
         trace_pvrdma_regs_write(addr, val, "DSRHIGH", "");
         dev->dsr_info.dma |= val << 32;
+        free_dsr(dev);
         load_dsr(dev);
         init_dsr_dev_caps(dev);
         break;
Signature · 1 line
2.21.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH v1 1/2] hw/pvrdma: make DSR mapping idempotent in load_dsr()

Quoted 46 lines · Sukrit Bhatnagar

Map to DSR only when there is no mapping done already i.e., when dev->dsr_info.dsr is NULL. This allows the rest of mappings and ring inits to be done by calling load_dsr() when DSR has already been mapped to, somewhere else.

Move free_dsr() out of load_dsr() and call it before the latter as and when needed. This aids the case where load_dsr() is called having DSR mapping already done, but the rest of map and init operations are pending, and prevents an unmap of the DSR.

Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
 hw/rdma/vmw/pvrdma_main.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
hw/rdma/vmw/pvrdma_main.c +8 -8
index adcf79cd63..6c90db96f9 100644
@@ -172,15 +172,15 @@ static int load_dsr(PVRDMADev *dev)
     DSRInfo *dsr_info;
     struct pvrdma_device_shared_region *dsr;
 
-    free_dsr(dev);
-
-    /* Map to DSR */
-    dev->dsr_info.dsr = rdma_pci_dma_map(pci_dev, dev->dsr_info.dma,
-                              sizeof(struct pvrdma_device_shared_region));
     if (!dev->dsr_info.dsr) {
-        rdma_error_report("Failed to map to DSR");
-        rc = -ENOMEM;
-        goto out;
+        /* Map to DSR */
+        dev->dsr_info.dsr = rdma_pci_dma_map(pci_dev, dev->dsr_info.dma,
+                                  sizeof(struct pvrdma_device_shared_region));
+        if (!dev->dsr_info.dsr) {
+            rdma_error_report("Failed to map to DSR");
+            rc = -ENOMEM;
+            goto out;
+        }
     }
 
     /* Shortcuts */

hw/rdma/vmw/pvrdma_main.c static void pvrdma_regs_write(void *opaque, hwaddr addr, uint64_t val, · line 408

Quoted 7 lines
hw/rdma/vmw/pvrdma_main.c +1 -0
@@ -402,6 +402,7 @@ static void pvrdma_regs_write(void *opaque, hwaddr addr, uint64_t val,
     case PVRDMA_REG_DSRHIGH:
         trace_pvrdma_regs_write(addr, val, "DSRHIGH", "");
         dev->dsr_info.dma |= val << 32;
+        free_dsr(dev);
         load_dsr(dev);
         init_dsr_dev_caps(dev);
         break;

LGTM, thanks.

Quoted 4 lines
Signature · 1 line
2.21.0
Reviewed-by on v1 1/2
#3 lore raw

Re: [Qemu-devel] [PATCH v1 1/2] hw/pvrdma: make DSR mapping idempotent in load_dsr()

In reply to Sukrit Bhatnagar
Quoted 46 lines · Sukrit Bhatnagar

Map to DSR only when there is no mapping done already i.e., when dev->dsr_info.dsr is NULL. This allows the rest of mappings and ring inits to be done by calling load_dsr() when DSR has already been mapped to, somewhere else.

Move free_dsr() out of load_dsr() and call it before the latter as and when needed. This aids the case where load_dsr() is called having DSR mapping already done, but the rest of map and init operations are pending, and prevents an unmap of the DSR.

Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
  hw/rdma/vmw/pvrdma_main.c | 17 +++++++++--------
  1 file changed, 9 insertions(+), 8 deletions(-)
hw/rdma/vmw/pvrdma_main.c +8 -8
index adcf79cd63..6c90db96f9 100644
@@ -172,15 +172,15 @@ static int load_dsr(PVRDMADev *dev)
      DSRInfo *dsr_info;
      struct pvrdma_device_shared_region *dsr;
 
-    free_dsr(dev);
-
-    /* Map to DSR */
-    dev->dsr_info.dsr = rdma_pci_dma_map(pci_dev, dev->dsr_info.dma,
-                              sizeof(struct pvrdma_device_shared_region));
      if (!dev->dsr_info.dsr) {
-        rdma_error_report("Failed to map to DSR");
-        rc = -ENOMEM;
-        goto out;
+        /* Map to DSR */
+        dev->dsr_info.dsr = rdma_pci_dma_map(pci_dev, dev->dsr_info.dma,
+                                  sizeof(struct pvrdma_device_shared_region));
+        if (!dev->dsr_info.dsr) {
+            rdma_error_report("Failed to map to DSR");
+            rc = -ENOMEM;
+            goto out;
+        }
      }
 
      /* Shortcuts */

hw/rdma/vmw/pvrdma_main.c static void pvrdma_regs_write(void *opaque, hwaddr addr, uint64_t val, · line 408

Quoted 7 lines
hw/rdma/vmw/pvrdma_main.c +1 -0
@@ -402,6 +402,7 @@ static void pvrdma_regs_write(void *opaque, hwaddr addr, uint64_t val,
      case PVRDMA_REG_DSRHIGH:
          trace_pvrdma_regs_write(addr, val, "DSRHIGH", "");
          dev->dsr_info.dma |= val << 32;
+        free_dsr(dev);
          load_dsr(dev);
          init_dsr_dev_caps(dev);
          break;

Thanks,
Marcel

#4 lore raw

PATCH 2/2 hw/pvrdma: add live migration support

In reply to Sukrit Bhatnagar

vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table.

pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host.

pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations.

Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
 hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
hw/rdma/vmw/pvrdma_main.c +77 -0
index 6c90db96f9..6f8b56dea3 100644
@@ -28,6 +28,7 @@
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "hw/rdma/rdma.h"
+#include "migration/register.h"
 
 #include "../rdma_rm.h"
 #include "../rdma_backend.h"
@@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
     pvrdma_fini(pci_dev);
 }
 
+static int pvrdma_post_save(void *opaque)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+
+    for (i = 0; i < MAX_GIDS; i++) {
+
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+        rc = rdma_backend_del_gid(&dev->backend_dev,
+                                   dev->backend_eth_device_name,
+                                   &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int pvrdma_post_load(void *opaque, int version_id)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
+    DSRInfo *dsr_info = &dev->dsr_info;
+
+    dsr_info->dsr = rdma_pci_dma_map(pci_dev, dsr_info->dma,
+                                sizeof(struct pvrdma_device_shared_region));
+    if (!dsr_info->dsr) {
+        rdma_error_report("Failed to map to DSR");
+        return -ENOMEM;
+    }
+
+    for (i = 0; i < MAX_GIDS; i++) {
+
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+
+        rc = rdma_backend_add_gid(&dev->backend_dev,
+                                  dev->backend_eth_device_name,
+                                  &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return load_dsr(dev);
+}
+
+static const VMStateDescription vmstate_pvrdma_gids = {
+    .name = "pvrdma-gids",
+    .fields = (VMStateField[]) {
+            VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_pvrdma = {
+    .name = PVRDMA_HW_NAME,
+    .post_save = pvrdma_post_save,
+    .post_load = pvrdma_post_load,
+    .fields = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev),
+            VMSTATE_MSIX(parent_obj, PVRDMADev),
+            VMSTATE_UINT64(dsr_info.dma, PVRDMADev),
+            VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev,
+                                 MAX_PORT_GIDS, 0, vmstate_pvrdma_gids,
+                                 RdmaRmGid),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
 static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 {
     int rc = 0;
@@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void *data)
 
     dc->desc = "RDMA Device";
     dc->props = pvrdma_dev_properties;
+    dc->vmsd = &vmstate_pvrdma;
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 
     ir->print_statistics = pvrdma_print_statistics;
Signature · 1 line
2.21.0
#5 lore raw

Re: [Qemu-devel] [PATCH v1 2/2] hw/pvrdma: add live migration support

Quoted 10 lines · Sukrit Bhatnagar

vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table.

pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host.

pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations.

I think it worth to mention that the dma address is kept in driver/device shared memory (dsr->dma) which is migrated as part of memory migration and it is out of the scope of this change and so we do not need to save/load the dma address during migration.

Also you should specifically comment that this migration-support does not includes QP migration. This means that support for life migration *during* traffic is not yet supported.

Quoted 21 lines
Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
 hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
hw/rdma/vmw/pvrdma_main.c +1 -0
index 6c90db96f9..6f8b56dea3 100644
@@ -28,6 +28,7 @@
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "hw/rdma/rdma.h"
+#include "migration/register.h"
 
 #include "../rdma_rm.h"
 #include "../rdma_backend.h"

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 603

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +7 -0
@@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
     pvrdma_fini(pci_dev);
 }
 
+static int pvrdma_post_save(void *opaque)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

Empty line is redundant here.

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 611

Quoted 8 lines
hw/rdma/vmw/pvrdma_main.c +8 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+        rc = rdma_backend_del_gid(&dev->backend_dev,
+                                   dev->backend_eth_device_name,
+                                   &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;

Some error report will help here i guess.

Quoted 12 lines
hw/rdma/vmw/pvrdma_main.c +12 -0
+        }
+    }
+
+    return 0;
+}
+
+static int pvrdma_post_load(void *opaque, int version_id)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
+    DSRInfo *dsr_info = &dev->dsr_info;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 633

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+
+    dsr_info->dsr = rdma_pci_dma_map(pci_dev, dsr_info->dma,
+                                sizeof(struct pvrdma_device_shared_region));
+    if (!dsr_info->dsr) {
+        rdma_error_report("Failed to map to DSR");
+        return -ENOMEM;
+    }
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

Empty line is redundant here.

Quoted 53 lines
hw/rdma/vmw/pvrdma_main.c +39 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+
+        rc = rdma_backend_add_gid(&dev->backend_dev,
+                                  dev->backend_eth_device_name,
+                                  &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return load_dsr(dev);
+}
+
+static const VMStateDescription vmstate_pvrdma_gids = {
+    .name = "pvrdma-gids",
+    .fields = (VMStateField[]) {
+            VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_pvrdma = {
+    .name = PVRDMA_HW_NAME,
+    .post_save = pvrdma_post_save,
+    .post_load = pvrdma_post_load,
+    .fields = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev),
+            VMSTATE_MSIX(parent_obj, PVRDMADev),
+            VMSTATE_UINT64(dsr_info.dma, PVRDMADev),
+            VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev,
+                                 MAX_PORT_GIDS, 0, vmstate_pvrdma_gids,
+                                 RdmaRmGid),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
 static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 {
     int rc = 0;
@@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void *data)
 
     dc->desc = "RDMA Device";
     dc->props = pvrdma_dev_properties;
+    dc->vmsd = &vmstate_pvrdma;
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 
     ir->print_statistics = pvrdma_print_statistics;
Signature · 1 line
2.21.0
#6 lore raw

Re: [Qemu-devel] [PATCH v1 2/2] hw/pvrdma: add live migration support

Quoted 65 lines · Yuval Shaia
Quoted 10 lines · Sukrit Bhatnagar

vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table.

pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host.

pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations.

I think it worth to mention that the dma address is kept in driver/device shared memory (dsr->dma) which is migrated as part of memory migration and it is out of the scope of this change and so we do not need to save/load the dma address during migration.

Also you should specifically comment that this migration-support does not includes QP migration. This means that support for life migration *during* traffic is not yet supported.

Quoted 21 lines
Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
 hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
hw/rdma/vmw/pvrdma_main.c +1 -0
index 6c90db96f9..6f8b56dea3 100644
@@ -28,6 +28,7 @@
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "hw/rdma/rdma.h"
+#include "migration/register.h"
 
 #include "../rdma_rm.h"
 #include "../rdma_backend.h"

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 603

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +7 -0
@@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
     pvrdma_fini(pci_dev);
 }
 
+static int pvrdma_post_save(void *opaque)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

Empty line is redundant here.

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 611

Quoted 8 lines
hw/rdma/vmw/pvrdma_main.c +8 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+        rc = rdma_backend_del_gid(&dev->backend_dev,
+                                   dev->backend_eth_device_name,
+                                   &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
Quoted 1 line

Some error report will help here i guess.

rdma_backend_del_gid() already generates an error report when rc isn't 0.

Adding another statement for the same seems redundant.

Quoted 25 lines
Quoted 12 lines
hw/rdma/vmw/pvrdma_main.c +12 -0
+        }
+    }
+
+    return 0;
+}
+
+static int pvrdma_post_load(void *opaque, int version_id)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
+    DSRInfo *dsr_info = &dev->dsr_info;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 633

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+
+    dsr_info->dsr = rdma_pci_dma_map(pci_dev, dsr_info->dma,
+                                sizeof(struct pvrdma_device_shared_region));
+    if (!dsr_info->dsr) {
+        rdma_error_report("Failed to map to DSR");
+        return -ENOMEM;
+    }
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

Empty line is redundant here.

Quoted 13 lines

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 646

Quoted 13 lines
hw/rdma/vmw/pvrdma_main.c +13 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+
+        rc = rdma_backend_add_gid(&dev->backend_dev,
+                                  dev->backend_eth_device_name,
+                                  &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return load_dsr(dev);

Now that I will move load_dsr() before the del_gid loop, I can use goto jumps on exit/error paths, so that I can undo load_dsr if any del_gid fails.

Quoted 40 lines
Quoted 40 lines
hw/rdma/vmw/pvrdma_main.c +26 -1
+}
+
+static const VMStateDescription vmstate_pvrdma_gids = {
+    .name = "pvrdma-gids",
+    .fields = (VMStateField[]) {
+            VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_pvrdma = {
+    .name = PVRDMA_HW_NAME,
+    .post_save = pvrdma_post_save,
+    .post_load = pvrdma_post_load,
+    .fields = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev),
+            VMSTATE_MSIX(parent_obj, PVRDMADev),
+            VMSTATE_UINT64(dsr_info.dma, PVRDMADev),
+            VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev,
+                                 MAX_PORT_GIDS, 0, vmstate_pvrdma_gids,
+                                 RdmaRmGid),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
 static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 {
     int rc = 0;
@@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void *data)
 
     dc->desc = "RDMA Device";
     dc->props = pvrdma_dev_properties;
+    dc->vmsd = &vmstate_pvrdma;
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 
     ir->print_statistics = pvrdma_print_statistics;
--

2.21.0

#7 lore raw

Re: [Qemu-devel] [PATCH v1 2/2] hw/pvrdma: add live migration support

Quoted 66 lines · Sukrit Bhatnagar
Quoted 65 lines · Yuval Shaia
Quoted 10 lines · Sukrit Bhatnagar

vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table.

pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host.

pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations.

I think it worth to mention that the dma address is kept in driver/device shared memory (dsr->dma) which is migrated as part of memory migration and it is out of the scope of this change and so we do not need to save/load the dma address during migration.

Also you should specifically comment that this migration-support does not includes QP migration. This means that support for life migration *during* traffic is not yet supported.

Quoted 21 lines
Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
 hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
hw/rdma/vmw/pvrdma_main.c +1 -0
index 6c90db96f9..6f8b56dea3 100644
@@ -28,6 +28,7 @@
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "hw/rdma/rdma.h"
+#include "migration/register.h"
 
 #include "../rdma_rm.h"
 #include "../rdma_backend.h"

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 603

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +7 -0
@@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
     pvrdma_fini(pci_dev);
 }
 
+static int pvrdma_post_save(void *opaque)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

Empty line is redundant here.

Quoted 8 lines
hw/rdma/vmw/pvrdma_main.c +8 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+        rc = rdma_backend_del_gid(&dev->backend_dev,
+                                   dev->backend_eth_device_name,
+                                   &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
Quoted 6 lines
Quoted 1 line

Some error report will help here i guess.

rdma_backend_del_gid() already generates an error report when rc isn't 0.

Adding another statement for the same seems redundant.

Sure, make sense.

Quoted 26 lines
Quoted 26 lines
Quoted 13 lines
hw/rdma/vmw/pvrdma_main.c +12 -0
+        }
+    }
+
+    return 0;
+}
+
+static int pvrdma_post_load(void *opaque, int version_id)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
+    DSRInfo *dsr_info = &dev->dsr_info;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 633

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+
+    dsr_info->dsr = rdma_pci_dma_map(pci_dev, dsr_info->dma,
+                                sizeof(struct pvrdma_device_shared_region));
+    if (!dsr_info->dsr) {
+        rdma_error_report("Failed to map to DSR");
+        return -ENOMEM;
+    }
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

Empty line is redundant here.

Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
hw/rdma/vmw/pvrdma_main.c +5 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+
+        rc = rdma_backend_add_gid(&dev->backend_dev,
Quoted 8 lines

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 646

Quoted 8 lines
hw/rdma/vmw/pvrdma_main.c +8 -0
+                                  dev->backend_eth_device_name,
+                                  &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return load_dsr(dev);

Now that I will move load_dsr() before the del_gid loop,

You probably meant before add_gid loop.

Quoted 2 lines

I can use goto jumps on exit/error paths, so that I can undo load_dsr if any del_gid fails.

Yeah, it will be easier to undo load_dsr than add_gid.

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
hw/rdma/vmw/pvrdma_main.c +26 -1
+}
+
+static const VMStateDescription vmstate_pvrdma_gids = {
+    .name = "pvrdma-gids",
+    .fields = (VMStateField[]) {
+            VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_pvrdma = {
+    .name = PVRDMA_HW_NAME,
+    .post_save = pvrdma_post_save,
+    .post_load = pvrdma_post_load,
+    .fields = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev),
+            VMSTATE_MSIX(parent_obj, PVRDMADev),
+            VMSTATE_UINT64(dsr_info.dma, PVRDMADev),
+            VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev,
+                                 MAX_PORT_GIDS, 0, vmstate_pvrdma_gids,
+                                 RdmaRmGid),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
 static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 {
     int rc = 0;
@@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void *data)
 
     dc->desc = "RDMA Device";
     dc->props = pvrdma_dev_properties;
+    dc->vmsd = &vmstate_pvrdma;
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 
     ir->print_statistics = pvrdma_print_statistics;
--

2.21.0

#8 lore raw

Re: [Qemu-devel] [PATCH v1 2/2] hw/pvrdma: add live migration support

In reply to Sukrit Bhatnagar
Quoted 74 lines · Sukrit Bhatnagar

vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table.

pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host.

pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations.

Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
 hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
hw/rdma/vmw/pvrdma_main.c +41 -0
index 6c90db96f9..6f8b56dea3 100644
@@ -28,6 +28,7 @@
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "hw/rdma/rdma.h"
+#include "migration/register.h"
 
 #include "../rdma_rm.h"
 #include "../rdma_backend.h"
@@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
     pvrdma_fini(pci_dev);
 }
 
+static int pvrdma_post_save(void *opaque)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+
+    for (i = 0; i < MAX_GIDS; i++) {
+
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+        rc = rdma_backend_del_gid(&dev->backend_dev,
+                                   dev->backend_eth_device_name,
+                                   &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int pvrdma_post_load(void *opaque, int version_id)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
+    DSRInfo *dsr_info = &dev->dsr_info;
+
+    dsr_info->dsr = rdma_pci_dma_map(pci_dev, dsr_info->dma,
+                                sizeof(struct pvrdma_device_shared_region));
+    if (!dsr_info->dsr) {
+        rdma_error_report("Failed to map to DSR");
+        return -ENOMEM;
+    }
+
+    for (i = 0; i < MAX_GIDS; i++) {
+
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 646

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+
+        rc = rdma_backend_add_gid(&dev->backend_dev,
+                                  dev->backend_eth_device_name,
+                                  &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return load_dsr(dev);

This check is better performed before any gid manipulation on the host because no one will undo it if load_dsr fails.

Quoted 40 lines
hw/rdma/vmw/pvrdma_main.c +26 -0
+}
+
+static const VMStateDescription vmstate_pvrdma_gids = {
+    .name = "pvrdma-gids",
+    .fields = (VMStateField[]) {
+            VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_pvrdma = {
+    .name = PVRDMA_HW_NAME,
+    .post_save = pvrdma_post_save,
+    .post_load = pvrdma_post_load,
+    .fields = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev),
+            VMSTATE_MSIX(parent_obj, PVRDMADev),
+            VMSTATE_UINT64(dsr_info.dma, PVRDMADev),
+            VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev,
+                                 MAX_PORT_GIDS, 0, vmstate_pvrdma_gids,
+                                 RdmaRmGid),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
 static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 {
     int rc = 0;
@@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void *data)
 
     dc->desc = "RDMA Device";
     dc->props = pvrdma_dev_properties;
+    dc->vmsd = &vmstate_pvrdma;
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 
     ir->print_statistics = pvrdma_print_statistics;
Signature · 1 line
2.21.0
#9 lore raw

Re: [Qemu-devel] [PATCH v1 2/2] hw/pvrdma: add live migration support

In reply to Sukrit Bhatnagar
Quoted 31 lines · Sukrit Bhatnagar

vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table.

pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host.

pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations.

Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
  hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++
  1 file changed, 77 insertions(+)
hw/rdma/vmw/pvrdma_main.c +1 -0
index 6c90db96f9..6f8b56dea3 100644
@@ -28,6 +28,7 @@
  #include "sysemu/sysemu.h"
  #include "monitor/monitor.h"
  #include "hw/rdma/rdma.h"
+#include "migration/register.h"
 
  #include "../rdma_rm.h"
  #include "../rdma_backend.h"

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 603

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +7 -0
@@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
      pvrdma_fini(pci_dev);
  }
 
+static int pvrdma_post_save(void *opaque)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

No need for the extra line

Quoted 20 lines
hw/rdma/vmw/pvrdma_main.c +20 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+        rc = rdma_backend_del_gid(&dev->backend_dev,
+                                   dev->backend_eth_device_name,
+                                   &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int pvrdma_post_load(void *opaque, int version_id)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
+    DSRInfo *dsr_info = &dev->dsr_info;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 633

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+
+    dsr_info->dsr = rdma_pci_dma_map(pci_dev, dsr_info->dma,
+                                sizeof(struct pvrdma_device_shared_region));
+    if (!dsr_info->dsr) {
+        rdma_error_report("Failed to map to DSR");
+        return -ENOMEM;
+    }
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

The same here

Quoted 9 lines
hw/rdma/vmw/pvrdma_main.c +9 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+
+        rc = rdma_backend_add_gid(&dev->backend_dev,
+                                  dev->backend_eth_device_name,
+                                  &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 652

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+        }
+    }
+
+    return load_dsr(dev);
+}
+
+static const VMStateDescription vmstate_pvrdma_gids = {
+    .name = "pvrdma-gids",
+    .fields = (VMStateField[]) {
+            VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0),

Is 16 the array length? If yes, do we have same macro definition?

Quoted 23 lines
hw/rdma/vmw/pvrdma_main.c +19 -0
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_pvrdma = {
+    .name = PVRDMA_HW_NAME,
+    .post_save = pvrdma_post_save,
+    .post_load = pvrdma_post_load,
+    .fields = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev),
+            VMSTATE_MSIX(parent_obj, PVRDMADev),
+            VMSTATE_UINT64(dsr_info.dma, PVRDMADev),
+            VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev,
+                                 MAX_PORT_GIDS, 0, vmstate_pvrdma_gids,
+                                 RdmaRmGid),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
  static void pvrdma_realize(PCIDevice *pdev, Error **errp)
  {
      int rc = 0;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_class_init(ObjectClass *klass, void *data) · line 770

Quoted 7 lines
hw/rdma/vmw/pvrdma_main.c +1 -0
@@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void *data)
 
      dc->desc = "RDMA Device";
      dc->props = pvrdma_dev_properties;
+    dc->vmsd = &vmstate_pvrdma;
      set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 
      ir->print_statistics = pvrdma_print_statistics;

Very simple an elegant.
If I understand correctly the live migration of a pvrdma device with no active workloads works with this patch, right?
If yes, I think we should consider merging this code already. Yuval, do you agree?

Thanks,
Marcel

#10 lore raw

Re: [Qemu-devel] [PATCH v1 2/2] hw/pvrdma: add live migration support

Quoted 123 lines · Marcel Apfelbaum
Quoted 30 lines · Sukrit Bhatnagar

vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table.

pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host.

pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations.

Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
  hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++
  1 file changed, 77 insertions(+)
hw/rdma/vmw/pvrdma_main.c +1 -0
index 6c90db96f9..6f8b56dea3 100644
@@ -28,6 +28,7 @@
  #include "sysemu/sysemu.h"
  #include "monitor/monitor.h"
  #include "hw/rdma/rdma.h"
+#include "migration/register.h"
  #include "../rdma_rm.h"
  #include "../rdma_backend.h"

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 602

Quoted 9 lines
hw/rdma/vmw/pvrdma_main.c +7 -0
@@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
      pvrdma_fini(pci_dev);
  }
+static int pvrdma_post_save(void *opaque)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

No need for the extra line

Quoted 20 lines
hw/rdma/vmw/pvrdma_main.c +20 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+        rc = rdma_backend_del_gid(&dev->backend_dev,
+                                   dev->backend_eth_device_name,
+                                   &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int pvrdma_post_load(void *opaque, int version_id)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
+    DSRInfo *dsr_info = &dev->dsr_info;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 633

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+
+    dsr_info->dsr = rdma_pci_dma_map(pci_dev, dsr_info->dma,
+                                sizeof(struct pvrdma_device_shared_region));
+    if (!dsr_info->dsr) {
+        rdma_error_report("Failed to map to DSR");
+        return -ENOMEM;
+    }
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

The same here

Quoted 9 lines
hw/rdma/vmw/pvrdma_main.c +9 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+
+        rc = rdma_backend_add_gid(&dev->backend_dev,
+                                  dev->backend_eth_device_name,
+                                  &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 652

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+        }
+    }
+
+    return load_dsr(dev);
+}
+
+static const VMStateDescription vmstate_pvrdma_gids = {
+    .name = "pvrdma-gids",
+    .fields = (VMStateField[]) {
+            VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0),

Is 16 the array length? If yes, do we have same macro definition?

Quoted 24 lines
hw/rdma/vmw/pvrdma_main.c +19 -0
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_pvrdma = {
+    .name = PVRDMA_HW_NAME,
+    .post_save = pvrdma_post_save,
+    .post_load = pvrdma_post_load,
+    .fields = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev),
+            VMSTATE_MSIX(parent_obj, PVRDMADev),
+            VMSTATE_UINT64(dsr_info.dma, PVRDMADev),
+            VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev,
+                                 MAX_PORT_GIDS, 0, vmstate_pvrdma_gids,
+                                 RdmaRmGid),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
  static void pvrdma_realize(PCIDevice *pdev, Error **errp)
  {
      int rc = 0;
@@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void *data)
      dc->desc = "RDMA Device";
Quoted 8 lines

hw/rdma/vmw/pvrdma_main.c static void pvrdma_class_init(ObjectClass *klass, void *data) · line 770

Quoted 4 lines
hw/rdma/vmw/pvrdma_main.c +1 -0
      dc->props = pvrdma_dev_properties;
+    dc->vmsd = &vmstate_pvrdma;
      set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
      ir->print_statistics = pvrdma_print_statistics;

Very simple an elegant.
If I understand correctly the live migration of a pvrdma device with no active workloads works with this patch, right?

And no QPs also.

Quoted 2 lines

If yes, I think we should consider merging this code already. Yuval, do you agree?

Sure i do!
Even with the limitation, this is huge enhancement that can be used right away.

But first suggested some fixes, let's see v2.

Quoted 5 lines

Thanks,
Marcel

#11 lore raw

Re: [Qemu-devel] [PATCH v1 2/2] hw/pvrdma: add live migration support

In reply to Marcel Apfelbaum
Quoted 93 lines · Marcel Apfelbaum
Quoted 31 lines · Sukrit Bhatnagar

vmstate_pvrdma describes the PCI and MSIX states as well as the dma address for dsr and the gid table of device. vmstate_pvrdma_gids describes each gid in the gid table.

pvrdma_post_save() does the job of unregistering gid entries from the backend device in the source host.

pvrdma_post_load() maps to dsr using the loaded dma address, registers each loaded gid into the backend device, and finally calls load_dsr() to perform other mappings and ring init operations.

Cc Marcel Apfelbaum <[email protected]>
Cc Yuval Shaia <[email protected]>
---
  hw/rdma/vmw/pvrdma_main.c | 77 +++++++++++++++++++++++++++++++++++++++
  1 file changed, 77 insertions(+)
hw/rdma/vmw/pvrdma_main.c +1 -0
index 6c90db96f9..6f8b56dea3 100644
@@ -28,6 +28,7 @@
  #include "sysemu/sysemu.h"
  #include "monitor/monitor.h"
  #include "hw/rdma/rdma.h"
+#include "migration/register.h"
 
  #include "../rdma_rm.h"
  #include "../rdma_backend.h"

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 603

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +7 -0
@@ -593,6 +594,81 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
      pvrdma_fini(pci_dev);
  }
 
+static int pvrdma_post_save(void *opaque)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

No need for the extra line

Quoted 20 lines
hw/rdma/vmw/pvrdma_main.c +20 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+        rc = rdma_backend_del_gid(&dev->backend_dev,
+                                   dev->backend_eth_device_name,
+                                   &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int pvrdma_post_load(void *opaque, int version_id)
+{
+    int i, rc;
+    PVRDMADev *dev = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
+    DSRInfo *dsr_info = &dev->dsr_info;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 633

Quoted 10 lines
hw/rdma/vmw/pvrdma_main.c +10 -0
+
+    dsr_info->dsr = rdma_pci_dma_map(pci_dev, dsr_info->dma,
+                                sizeof(struct pvrdma_device_shared_region));
+    if (!dsr_info->dsr) {
+        rdma_error_report("Failed to map to DSR");
+        return -ENOMEM;
+    }
+
+    for (i = 0; i < MAX_GIDS; i++) {
+

The same here

Quoted 13 lines
hw/rdma/vmw/pvrdma_main.c +13 -0
+        if (!dev->rdma_dev_res.port.gid_tbl[i].gid.global.interface_id) {
+            continue;
+        }
+
+        rc = rdma_backend_add_gid(&dev->backend_dev,
+                                  dev->backend_eth_device_name,
+                                  &dev->rdma_dev_res.port.gid_tbl[i].gid);
+        if (rc) {
+            return -EINVAL;
+        }
+    }
+
+    return load_dsr(dev);
Quoted 8 lines

hw/rdma/vmw/pvrdma_main.c static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) · line 652

Quoted 6 lines
hw/rdma/vmw/pvrdma_main.c +6 -0
+}
+
+static const VMStateDescription vmstate_pvrdma_gids = {
+    .name = "pvrdma-gids",
+    .fields = (VMStateField[]) {
+            VMSTATE_UINT8_ARRAY_V(gid.raw, RdmaRmGid, 16, 0),

Is 16 the array length? If yes, do we have same macro definition?

16 here represents the number of bytes in a GID.
This comes from the verbs definition of ibv_gid

union ibv_gid {
    uint8_t         raw[16];
    struct {
        __be64  subnet_prefix;
        __be64  interface_id;
    } global;
};

I suppose there is no macro for this but we can declare our own (something like IBV_GID_SIZE).

Quoted 29 lines
Quoted 29 lines
hw/rdma/vmw/pvrdma_main.c +20 -0
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_pvrdma = {
+    .name = PVRDMA_HW_NAME,
+    .post_save = pvrdma_post_save,
+    .post_load = pvrdma_post_load,
+    .fields = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(parent_obj, PVRDMADev),
+            VMSTATE_MSIX(parent_obj, PVRDMADev),
+            VMSTATE_UINT64(dsr_info.dma, PVRDMADev),
+            VMSTATE_STRUCT_ARRAY(rdma_dev_res.port.gid_tbl, PVRDMADev,
+                                 MAX_PORT_GIDS, 0, vmstate_pvrdma_gids,
+                                 RdmaRmGid),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
  static void pvrdma_realize(PCIDevice *pdev, Error **errp)
  {
      int rc = 0;
@@ -688,6 +764,7 @@ static void pvrdma_class_init(ObjectClass *klass, void *data)
 
      dc->desc = "RDMA Device";
      dc->props = pvrdma_dev_properties;
+    dc->vmsd = &vmstate_pvrdma;
      set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 
Quoted 5 lines

hw/rdma/vmw/pvrdma_main.c static void pvrdma_class_init(ObjectClass *klass, void *data) · line 770

Quoted 1 line
hw/rdma/vmw/pvrdma_main.c +0 -0
      ir->print_statistics = pvrdma_print_statistics;

Very simple an elegant.
If I understand correctly the live migration of a pvrdma device with no active workloads works with this patch, right?

Yes.

Quoted 7 lines

If yes, I think we should consider merging this code already. Yuval, do you agree?

Thanks,
Marcel

#12 lore raw
In reply to Sukrit Bhatnagar
Quoted 7 lines · Sukrit Bhatnagar

This series enables the migration of various GIDs used by the device. This is in addition to the successful migration of PCI and MSIX states as well as various DMA addresses and ring page information.

We have a setup having two hosts and two VMs running atop them. Migrations are performed over the local network.

Quoted 8 lines

We also have performed various ping-pong tests (ibv_rc_pingpong) in the guest(s) after adding GID migration support and this is the current status:
- ping-pong to localhost succeeds, when performed before starting the migration and after the completion of migration.
- ping-pong to a peer succeeds, both before and after migration as above, provided that both VMs are running on/migrated to the same host. So, if two VMs were started on two different hosts, and one of them was migrated to the other host, the ping-pong was successful.

This limitation looks to me like wrongly configured network. This patch-set should enable any migration.

After our last meeting, please confirm.

In addition, i don't see why non-VM peer (i.e. Bare-metal) is not supported. Can you run a test and update with the results?

Quoted 23 lines

Similarly, if two VMs are migrated to the same host, then after migration, the ping-pong was successful.
- ping-pong to a peer on the remote host is not working as of now.

Our next goal is to achieve successful migration with live traffic.

This is the same as the RFC v3 series posted earlier:
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04752.html
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04753.html
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04754.html

Sukrit Bhatnagar (2):
hw/pvrdma: make DSR mapping idempotent in load_dsr() hw/pvrdma: add live migration support

 hw/rdma/vmw/pvrdma_main.c | 94 +++++++++++++++++++++++++++++++++++----
 1 file changed, 86 insertions(+), 8 deletions(-)
Signature · 1 line
2.21.0
#13 lore raw
In reply to Sukrit Bhatnagar

Hi Sukrit,

Quoted 19 lines · Sukrit Bhatnagar

This series enables the migration of various GIDs used by the device. This is in addition to the successful migration of PCI and MSIX states as well as various DMA addresses and ring page information.

We have a setup having two hosts and two VMs running atop them. Migrations are performed over the local network.

We also have performed various ping-pong tests (ibv_rc_pingpong) in the guest(s) after adding GID migration support and this is the current status:
- ping-pong to localhost succeeds, when performed before starting the migration and after the completion of migration.
- ping-pong to a peer succeeds, both before and after migration as above, provided that both VMs are running on/migrated to the same host. So, if two VMs were started on two different hosts, and one of them was migrated to the other host, the ping-pong was successful. Similarly, if two VMs are migrated to the same host, then after migration, the ping-pong was successful.
- ping-pong to a peer on the remote host is not working as of now.

Quoted 2 lines

Our next goal is to achieve successful migration with live traffic.

Nice work!
I am sorry for the GSOC program interruption and congrats on your decision to continue the project!

Thanks,
Marcel

Quoted 13 lines

This is the same as the RFC v3 series posted earlier:
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04752.html
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04753.html
https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04754.html

Sukrit Bhatnagar (2):
hw/pvrdma: make DSR mapping idempotent in load_dsr() hw/pvrdma: add live migration support

  hw/rdma/vmw/pvrdma_main.c | 94 +++++++++++++++++++++++++++++++++++----
  1 file changed, 86 insertions(+), 8 deletions(-)