mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00

Add multifd setup/cleanup functions and an associated VFIOMultifd data structure that will contain most of the receive-side data together with its init/cleanup methods. Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/c0520523053b1087787152ddf2163257d3030be0.1741124640.git.maciej.szmigiero@oracle.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
83 lines
1.8 KiB
C
83 lines
1.8 KiB
C
/*
|
|
* Multifd VFIO migration
|
|
*
|
|
* Copyright (C) 2024,2025 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.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "hw/vfio/vfio-common.h"
|
|
#include "migration/misc.h"
|
|
#include "qapi/error.h"
|
|
#include "qemu/error-report.h"
|
|
#include "qemu/lockable.h"
|
|
#include "qemu/main-loop.h"
|
|
#include "qemu/thread.h"
|
|
#include "migration/qemu-file.h"
|
|
#include "migration-multifd.h"
|
|
#include "trace.h"
|
|
|
|
#define VFIO_DEVICE_STATE_CONFIG_STATE (1)
|
|
|
|
#define VFIO_DEVICE_STATE_PACKET_VER_CURRENT (0)
|
|
|
|
typedef struct VFIODeviceStatePacket {
|
|
uint32_t version;
|
|
uint32_t idx;
|
|
uint32_t flags;
|
|
uint8_t data[0];
|
|
} QEMU_PACKED VFIODeviceStatePacket;
|
|
|
|
typedef struct VFIOMultifd {
|
|
} VFIOMultifd;
|
|
|
|
static VFIOMultifd *vfio_multifd_new(void)
|
|
{
|
|
VFIOMultifd *multifd = g_new(VFIOMultifd, 1);
|
|
|
|
return multifd;
|
|
}
|
|
|
|
static void vfio_multifd_free(VFIOMultifd *multifd)
|
|
{
|
|
g_free(multifd);
|
|
}
|
|
|
|
void vfio_multifd_cleanup(VFIODevice *vbasedev)
|
|
{
|
|
VFIOMigration *migration = vbasedev->migration;
|
|
|
|
g_clear_pointer(&migration->multifd, vfio_multifd_free);
|
|
}
|
|
|
|
bool vfio_multifd_transfer_supported(void)
|
|
{
|
|
return multifd_device_state_supported() &&
|
|
migrate_send_switchover_start();
|
|
}
|
|
|
|
bool vfio_multifd_transfer_enabled(VFIODevice *vbasedev)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool vfio_multifd_setup(VFIODevice *vbasedev, bool alloc_multifd, Error **errp)
|
|
{
|
|
VFIOMigration *migration = vbasedev->migration;
|
|
|
|
if (!vfio_multifd_transfer_enabled(vbasedev)) {
|
|
/* Nothing further to check or do */
|
|
return true;
|
|
}
|
|
|
|
if (alloc_multifd) {
|
|
assert(!migration->multifd);
|
|
migration->multifd = vfio_multifd_new();
|
|
}
|
|
|
|
return true;
|
|
}
|