mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
vfio queue:
* Allow cpr-reboot for vfio -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmXtrhMACgkQUaNDx8/7 7KFCgw/7BEdbP4e32/+D0Mk1+oeiulgGvo/kPtg7waWACrijWxG5K5/c0kcFnhte OnpDfObnF7l2GjKU61SAluTocWcVbb8A61Tt5+ta5xxPQGp5XCXF7aIkb/DQQDq/ yU7pQCmqMMSgo+siR6yb+g/2t71dYlMyCbW3LU5/oGQkFtsSXjWHqnTut+wFeuRT Vd62vHcZqHWG2epoyEnW3HCVMrZ8Dl+PLGkORV55P6uEzZuKwgoCTmR2m5/NLkdU SF4ZnZzruqkc1dsRh+vYFglQ6GttzWz1VBJg8GJTwrXAJ7C7JSTS25fNRNNhRkJl 2/DZbdMyyJWJmrv9AXwWEEJ+bSSbM3uM76hqgMFVUlyz9y8FXduwf4MIkZjl0Jg5 phJb3Awxxxd61I3vWhi9lZKS/RHQ5anA+rBt/4RxdnzqZ3mDcoBhiEjNaGp1Yghv QbkOSUmY8aBFdeqaw4UqpL2l6mlN/idAOIyq7ADp0S2/eNftw/FGBEu+KP5C/IZF vReB36qWws9go9w8aDdyK/1bB9vMI3fo/AA8Y4Cnr22tEbgctfygl2jmmyHZUFDI R8/NESzv17G2/g7OowCqG0qrOWW+UTDcDCkOlVFlLABiij9aNUYV631cQ379K7tR mFo10BlTcXV83XkA9iM9qqIIVNoYm5uJRva+oEaBncRIAGiYTF4= =kiGc -----END PGP SIGNATURE----- Merge tag 'pull-vfio-20240310' of https://github.com/legoater/qemu into staging vfio queue: * Allow cpr-reboot for vfio # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmXtrhMACgkQUaNDx8/7 # 7KFCgw/7BEdbP4e32/+D0Mk1+oeiulgGvo/kPtg7waWACrijWxG5K5/c0kcFnhte # OnpDfObnF7l2GjKU61SAluTocWcVbb8A61Tt5+ta5xxPQGp5XCXF7aIkb/DQQDq/ # yU7pQCmqMMSgo+siR6yb+g/2t71dYlMyCbW3LU5/oGQkFtsSXjWHqnTut+wFeuRT # Vd62vHcZqHWG2epoyEnW3HCVMrZ8Dl+PLGkORV55P6uEzZuKwgoCTmR2m5/NLkdU # SF4ZnZzruqkc1dsRh+vYFglQ6GttzWz1VBJg8GJTwrXAJ7C7JSTS25fNRNNhRkJl # 2/DZbdMyyJWJmrv9AXwWEEJ+bSSbM3uM76hqgMFVUlyz9y8FXduwf4MIkZjl0Jg5 # phJb3Awxxxd61I3vWhi9lZKS/RHQ5anA+rBt/4RxdnzqZ3mDcoBhiEjNaGp1Yghv # QbkOSUmY8aBFdeqaw4UqpL2l6mlN/idAOIyq7ADp0S2/eNftw/FGBEu+KP5C/IZF # vReB36qWws9go9w8aDdyK/1bB9vMI3fo/AA8Y4Cnr22tEbgctfygl2jmmyHZUFDI # R8/NESzv17G2/g7OowCqG0qrOWW+UTDcDCkOlVFlLABiij9aNUYV631cQ379K7tR # mFo10BlTcXV83XkA9iM9qqIIVNoYm5uJRva+oEaBncRIAGiYTF4= # =kiGc # -----END PGP SIGNATURE----- # gpg: Signature made Sun 10 Mar 2024 12:56:51 GMT # gpg: using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1 # gpg: Good signature from "Cédric Le Goater <clg@kaod.org>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: A0F6 6548 F048 95EB FE6B 0B60 51A3 43C7 CFFB ECA1 * tag 'pull-vfio-20240310' of https://github.com/legoater/qemu: vfio: allow cpr-reboot migration if suspended vfio: register container for cpr Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
67ff703c97
8 changed files with 62 additions and 3 deletions
|
@ -128,7 +128,7 @@ int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **errp)
|
|||
error_setg(&multiple_devices_migration_blocker,
|
||||
"Multiple VFIO devices migration is supported only if all of "
|
||||
"them support P2P migration");
|
||||
ret = migrate_add_blocker(&multiple_devices_migration_blocker, errp);
|
||||
ret = migrate_add_blocker_normal(&multiple_devices_migration_blocker, errp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -621,10 +621,15 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
|||
goto free_container_exit;
|
||||
}
|
||||
|
||||
ret = vfio_cpr_register_container(bcontainer, errp);
|
||||
if (ret) {
|
||||
goto free_container_exit;
|
||||
}
|
||||
|
||||
ret = vfio_ram_block_discard_disable(container, true);
|
||||
if (ret) {
|
||||
error_setg_errno(errp, -ret, "Cannot set discarding of RAM broken");
|
||||
goto free_container_exit;
|
||||
goto unregister_container_exit;
|
||||
}
|
||||
|
||||
assert(bcontainer->ops->setup);
|
||||
|
@ -667,6 +672,9 @@ listener_release_exit:
|
|||
enable_discards_exit:
|
||||
vfio_ram_block_discard_disable(container, false);
|
||||
|
||||
unregister_container_exit:
|
||||
vfio_cpr_unregister_container(bcontainer);
|
||||
|
||||
free_container_exit:
|
||||
g_free(container);
|
||||
|
||||
|
@ -710,6 +718,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
|
|||
vfio_container_destroy(bcontainer);
|
||||
|
||||
trace_vfio_disconnect_container(container->fd);
|
||||
vfio_cpr_unregister_container(bcontainer);
|
||||
close(container->fd);
|
||||
g_free(container);
|
||||
|
||||
|
|
39
hw/vfio/cpr.c
Normal file
39
hw/vfio/cpr.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2024 Oracle and/or its affiliates.
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/vfio/vfio-common.h"
|
||||
#include "migration/misc.h"
|
||||
#include "qapi/error.h"
|
||||
#include "sysemu/runstate.h"
|
||||
|
||||
static int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier,
|
||||
MigrationEvent *e, Error **errp)
|
||||
{
|
||||
if (e->type == MIG_EVENT_PRECOPY_SETUP &&
|
||||
!runstate_check(RUN_STATE_SUSPENDED) && !vm_get_suspended()) {
|
||||
|
||||
error_setg(errp,
|
||||
"VFIO device only supports cpr-reboot for runstate suspended");
|
||||
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **errp)
|
||||
{
|
||||
migration_add_notifier_mode(&bcontainer->cpr_reboot_notifier,
|
||||
vfio_cpr_reboot_notifier,
|
||||
MIG_MODE_CPR_REBOOT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer)
|
||||
{
|
||||
migration_remove_notifier(&bcontainer->cpr_reboot_notifier);
|
||||
}
|
|
@ -411,6 +411,11 @@ found_container:
|
|||
goto err_listener_register;
|
||||
}
|
||||
|
||||
ret = vfio_cpr_register_container(bcontainer, errp);
|
||||
if (ret) {
|
||||
goto err_listener_register;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: examine RAM_BLOCK_DISCARD stuff, should we do group level
|
||||
* for discarding incompatibility check as well?
|
||||
|
@ -461,6 +466,7 @@ static void iommufd_cdev_detach(VFIODevice *vbasedev)
|
|||
iommufd_cdev_ram_block_discard_disable(false);
|
||||
}
|
||||
|
||||
vfio_cpr_unregister_container(bcontainer);
|
||||
iommufd_cdev_detach_container(vbasedev, container);
|
||||
iommufd_cdev_container_destroy(container);
|
||||
vfio_put_address_space(space);
|
||||
|
|
|
@ -5,6 +5,7 @@ vfio_ss.add(files(
|
|||
'container-base.c',
|
||||
'container.c',
|
||||
'migration.c',
|
||||
'cpr.c',
|
||||
))
|
||||
vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
|
||||
vfio_ss.add(when: 'CONFIG_IOMMUFD', if_true: files(
|
||||
|
|
|
@ -889,7 +889,7 @@ static int vfio_block_migration(VFIODevice *vbasedev, Error *err, Error **errp)
|
|||
vbasedev->migration_blocker = error_copy(err);
|
||||
error_free(err);
|
||||
|
||||
return migrate_add_blocker(&vbasedev->migration_blocker, errp);
|
||||
return migrate_add_blocker_normal(&vbasedev->migration_blocker, errp);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
|
@ -205,6 +205,9 @@ void vfio_detach_device(VFIODevice *vbasedev);
|
|||
int vfio_kvm_device_add_fd(int fd, Error **errp);
|
||||
int vfio_kvm_device_del_fd(int fd, Error **errp);
|
||||
|
||||
int vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **errp);
|
||||
void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer);
|
||||
|
||||
extern const MemoryRegionOps vfio_region_ops;
|
||||
typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList;
|
||||
typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList;
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef struct VFIOContainerBase {
|
|||
QLIST_ENTRY(VFIOContainerBase) next;
|
||||
QLIST_HEAD(, VFIODevice) device_list;
|
||||
GList *iova_ranges;
|
||||
NotifierWithReturn cpr_reboot_notifier;
|
||||
} VFIOContainerBase;
|
||||
|
||||
typedef struct VFIOGuestIOMMU {
|
||||
|
|
Loading…
Reference in a new issue