Projects
home:dongzhihai
qemu
_service:tar_scm:vhost-implement-migration-stat...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:vhost-implement-migration-state-notifier-for-vdpa-de.patch of Package qemu
From 3ef6dc341d6921a95564e9089f41ddbd79cd2a94 Mon Sep 17 00:00:00 2001 From: libai <libai12@huawei.com> Date: Mon, 4 Dec 2023 15:55:53 +0800 Subject: [PATCH] vhost: implement migration state notifier for vdpa device Register migration state notifier to support triggered by migration exceptions Signed-off-by: libai <libai12@huawei.com> --- hw/virtio/vdpa-dev-mig.c | 29 +++++++++++++++++++++++++++++ include/hw/virtio/vdpa-dev.h | 1 + 2 files changed, 30 insertions(+) diff --git a/hw/virtio/vdpa-dev-mig.c b/hw/virtio/vdpa-dev-mig.c index 1872f11f3f..9b47e3ed45 100644 --- a/hw/virtio/vdpa-dev-mig.c +++ b/hw/virtio/vdpa-dev-mig.c @@ -23,6 +23,7 @@ #include "hw/virtio/virtio-bus.h" #include "migration/register.h" #include "migration/migration.h" +#include "migration/misc.h" #include "qemu/error-report.h" #include "hw/virtio/vdpa-dev-mig.h" #include "migration/qemu-file-types.h" @@ -354,6 +355,31 @@ static SaveVMHandlers savevm_vdpa_handlers = { .load_setup = vdpa_load_setup, }; +static void vdpa_migration_state_notifier(Notifier *notifier, void *data) +{ + MigrationState *s = data; + VhostVdpaDevice *vdev = container_of(notifier, + VhostVdpaDevice, + migration_state); + struct vhost_dev *hdev = &vdev->dev; + int ret; + + switch (s->state) { + case MIGRATION_STATUS_CANCELLING: + case MIGRATION_STATUS_CANCELLED: + case MIGRATION_STATUS_FAILED: + ret = vhost_vdpa_set_mig_state(hdev, VDPA_DEVICE_CANCEL); + if (ret) { + error_report("Failed to set state CANCEL\n"); + } + + break; + case MIGRATION_STATUS_COMPLETED: + default: + break; + } +} + void vdpa_migration_register(VhostVdpaDevice *vdev) { vdev->vmstate = qdev_add_vm_change_state_handler(DEVICE(vdev), @@ -361,10 +387,13 @@ void vdpa_migration_register(VhostVdpaDevice *vdev) DEVICE(vdev)); register_savevm_live("vdpa", -1, 1, &savevm_vdpa_handlers, DEVICE(vdev)); + vdev->migration_state.notify = vdpa_migration_state_notifier; + migration_add_notifier(&vdev->migration_state, vdpa_migration_state_notifier); } void vdpa_migration_unregister(VhostVdpaDevice *vdev) { + migration_remove_notifier(&vdev->migration_state); unregister_savevm(VMSTATE_IF(&vdev->parent_obj.parent_obj), "vdpa", DEVICE(vdev)); qemu_del_vm_change_state_handler(vdev->vmstate); } diff --git a/include/hw/virtio/vdpa-dev.h b/include/hw/virtio/vdpa-dev.h index 43cbcef81b..20f50c76c6 100644 --- a/include/hw/virtio/vdpa-dev.h +++ b/include/hw/virtio/vdpa-dev.h @@ -39,6 +39,7 @@ struct VhostVdpaDevice { bool started; int (*post_init)(VhostVdpaDevice *v, Error **errp); VMChangeStateEntry *vmstate; + Notifier migration_state; }; #endif -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2