computing-offload/generic_vdpa/qemu/0010-vdpa-implement-vdpa-device-migration.patch
jiangdongxu fac818adb1 vdpa: change libvirt/qemu/kernel base version and docs
Change-Id: I574115f5e44e56ac2baaad71eeab6b9fd7149747
2024-10-15 17:39:52 +08:00

76 lines
2.4 KiB
Diff

From 18d0ef617a9dcca1efc71ea9cb8e0fd5719f81ce Mon Sep 17 00:00:00 2001
From: libai <libai12@huawei.com>
Date: Mon, 4 Dec 2023 15:59:56 +0800
Subject: [PATCH 10/16] vdpa: implement vdpa device migration
Integrate the live migration code, call the registered live
migration function, and open the vdpa live migration prototype
Signed-off-by: libai <libai12@huawei.com>
---
hw/virtio/vdpa-dev.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
index f22d5d5..6af78a4 100644
--- a/hw/virtio/vdpa-dev.c
+++ b/hw/virtio/vdpa-dev.c
@@ -28,6 +28,8 @@
#include "hw/virtio/vdpa-dev.h"
#include "sysemu/sysemu.h"
#include "sysemu/runstate.h"
+#include "hw/virtio/vdpa-dev-mig.h"
+#include "migration/migration.h"
static void
vhost_vdpa_device_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
@@ -154,6 +156,8 @@ static void vhost_vdpa_device_realize(DeviceState *dev, Error **errp)
vhost_vdpa_device_dummy_handle_output);
}
+ vdpa_migration_register(v);
+
return;
free_config:
@@ -173,6 +177,7 @@ static void vhost_vdpa_device_unrealize(DeviceState *dev)
VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
int i;
+ vdpa_migration_unregister(s);
virtio_set_status(vdev, 0);
for (i = 0; i < s->num_queues; i++) {
@@ -308,6 +313,7 @@ static void vhost_vdpa_device_stop(VirtIODevice *vdev)
static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status)
{
VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
+ MigrationState *ms = migrate_get_current();
bool should_start = virtio_device_started(vdev, status);
Error *local_err = NULL;
int ret;
@@ -320,6 +326,11 @@ static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status)
return;
}
+ if (ms->state == RUN_STATE_PAUSED ||
+ ms->state == RUN_STATE_RESTORE_VM) {
+ return;
+ }
+
if (should_start) {
ret = vhost_vdpa_device_start(vdev, &local_err);
if (ret < 0) {
@@ -338,7 +349,7 @@ static Property vhost_vdpa_device_properties[] = {
static const VMStateDescription vmstate_vhost_vdpa_device = {
.name = "vhost-vdpa-device",
- .unmigratable = 1,
+ .unmigratable = 0,
.minimum_version_id = 1,
.version_id = 1,
.fields = (VMStateField[]) {
--
2.46.0.windows.1