mirror of https://github.com/xemu-project/xemu.git
migration: Move migrate_caps_check() to options.c
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
This commit is contained in:
parent
17cba690cd
commit
7760870645
|
@ -136,39 +136,6 @@ enum mig_rp_message_type {
|
||||||
MIG_RP_MSG_MAX
|
MIG_RP_MSG_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Migration capabilities set */
|
|
||||||
struct MigrateCapsSet {
|
|
||||||
int size; /* Capability set size */
|
|
||||||
MigrationCapability caps[]; /* Variadic array of capabilities */
|
|
||||||
};
|
|
||||||
typedef struct MigrateCapsSet MigrateCapsSet;
|
|
||||||
|
|
||||||
/* Define and initialize MigrateCapsSet */
|
|
||||||
#define INITIALIZE_MIGRATE_CAPS_SET(_name, ...) \
|
|
||||||
MigrateCapsSet _name = { \
|
|
||||||
.size = sizeof((int []) { __VA_ARGS__ }) / sizeof(int), \
|
|
||||||
.caps = { __VA_ARGS__ } \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Background-snapshot compatibility check list */
|
|
||||||
static const
|
|
||||||
INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snapshot,
|
|
||||||
MIGRATION_CAPABILITY_POSTCOPY_RAM,
|
|
||||||
MIGRATION_CAPABILITY_DIRTY_BITMAPS,
|
|
||||||
MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME,
|
|
||||||
MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE,
|
|
||||||
MIGRATION_CAPABILITY_RETURN_PATH,
|
|
||||||
MIGRATION_CAPABILITY_MULTIFD,
|
|
||||||
MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER,
|
|
||||||
MIGRATION_CAPABILITY_AUTO_CONVERGE,
|
|
||||||
MIGRATION_CAPABILITY_RELEASE_RAM,
|
|
||||||
MIGRATION_CAPABILITY_RDMA_PIN_ALL,
|
|
||||||
MIGRATION_CAPABILITY_COMPRESS,
|
|
||||||
MIGRATION_CAPABILITY_XBZRLE,
|
|
||||||
MIGRATION_CAPABILITY_X_COLO,
|
|
||||||
MIGRATION_CAPABILITY_VALIDATE_UUID,
|
|
||||||
MIGRATION_CAPABILITY_ZERO_COPY_SEND);
|
|
||||||
|
|
||||||
/* When we add fault tolerance, we could have several
|
/* When we add fault tolerance, we could have several
|
||||||
migrations at once. For now we don't need to add
|
migrations at once. For now we don't need to add
|
||||||
dynamic creation of migration */
|
dynamic creation of migration */
|
||||||
|
@ -1235,163 +1202,6 @@ static void fill_source_migration_info(MigrationInfo *info)
|
||||||
info->status = state;
|
info->status = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum WriteTrackingSupport {
|
|
||||||
WT_SUPPORT_UNKNOWN = 0,
|
|
||||||
WT_SUPPORT_ABSENT,
|
|
||||||
WT_SUPPORT_AVAILABLE,
|
|
||||||
WT_SUPPORT_COMPATIBLE
|
|
||||||
} WriteTrackingSupport;
|
|
||||||
|
|
||||||
static
|
|
||||||
WriteTrackingSupport migrate_query_write_tracking(void)
|
|
||||||
{
|
|
||||||
/* Check if kernel supports required UFFD features */
|
|
||||||
if (!ram_write_tracking_available()) {
|
|
||||||
return WT_SUPPORT_ABSENT;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Check if current memory configuration is
|
|
||||||
* compatible with required UFFD features.
|
|
||||||
*/
|
|
||||||
if (!ram_write_tracking_compatible()) {
|
|
||||||
return WT_SUPPORT_AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return WT_SUPPORT_COMPATIBLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @migration_caps_check - check capability compatibility
|
|
||||||
*
|
|
||||||
* @old_caps: old capability list
|
|
||||||
* @new_caps: new capability list
|
|
||||||
* @errp: set *errp if the check failed, with reason
|
|
||||||
*
|
|
||||||
* Returns true if check passed, otherwise false.
|
|
||||||
*/
|
|
||||||
static bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)
|
|
||||||
{
|
|
||||||
MigrationIncomingState *mis = migration_incoming_get_current();
|
|
||||||
|
|
||||||
#ifndef CONFIG_LIVE_BLOCK_MIGRATION
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_BLOCK]) {
|
|
||||||
error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i) "
|
|
||||||
"block migration");
|
|
||||||
error_append_hint(errp, "Use drive_mirror+NBD instead.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONFIG_REPLICATION
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_X_COLO]) {
|
|
||||||
error_setg(errp, "QEMU compiled without replication module"
|
|
||||||
" can't enable COLO");
|
|
||||||
error_append_hint(errp, "Please enable replication before COLO.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
|
|
||||||
/* This check is reasonably expensive, so only when it's being
|
|
||||||
* set the first time, also it's only the destination that needs
|
|
||||||
* special support.
|
|
||||||
*/
|
|
||||||
if (!old_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM] &&
|
|
||||||
runstate_check(RUN_STATE_INMIGRATE) &&
|
|
||||||
!postcopy_ram_supported_by_host(mis)) {
|
|
||||||
/* postcopy_ram_supported_by_host will have emitted a more
|
|
||||||
* detailed message
|
|
||||||
*/
|
|
||||||
error_setg(errp, "Postcopy is not supported");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED]) {
|
|
||||||
error_setg(errp, "Postcopy is not compatible with ignore-shared");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT]) {
|
|
||||||
WriteTrackingSupport wt_support;
|
|
||||||
int idx;
|
|
||||||
/*
|
|
||||||
* Check if 'background-snapshot' capability is supported by
|
|
||||||
* host kernel and compatible with guest memory configuration.
|
|
||||||
*/
|
|
||||||
wt_support = migrate_query_write_tracking();
|
|
||||||
if (wt_support < WT_SUPPORT_AVAILABLE) {
|
|
||||||
error_setg(errp, "Background-snapshot is not supported by host kernel");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (wt_support < WT_SUPPORT_COMPATIBLE) {
|
|
||||||
error_setg(errp, "Background-snapshot is not compatible "
|
|
||||||
"with guest memory configuration");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if there are any migration capabilities
|
|
||||||
* incompatible with 'background-snapshot'.
|
|
||||||
*/
|
|
||||||
for (idx = 0; idx < check_caps_background_snapshot.size; idx++) {
|
|
||||||
int incomp_cap = check_caps_background_snapshot.caps[idx];
|
|
||||||
if (new_caps[incomp_cap]) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Background-snapshot is not compatible with %s",
|
|
||||||
MigrationCapability_str(incomp_cap));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_LINUX
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
|
|
||||||
(!new_caps[MIGRATION_CAPABILITY_MULTIFD] ||
|
|
||||||
new_caps[MIGRATION_CAPABILITY_COMPRESS] ||
|
|
||||||
new_caps[MIGRATION_CAPABILITY_XBZRLE] ||
|
|
||||||
migrate_multifd_compression() ||
|
|
||||||
migrate_use_tls())) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Zero copy only available for non-compressed non-TLS multifd migration");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Zero copy currently only available on Linux");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]) {
|
|
||||||
if (!new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
|
|
||||||
error_setg(errp, "Postcopy preempt requires postcopy-ram");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Preempt mode requires urgent pages to be sent in separate
|
|
||||||
* channel, OTOH compression logic will disorder all pages into
|
|
||||||
* different compression channels, which is not compatible with the
|
|
||||||
* preempt assumptions on channel assignments.
|
|
||||||
*/
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) {
|
|
||||||
error_setg(errp, "Postcopy preempt not compatible with compress");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) {
|
|
||||||
if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) {
|
|
||||||
error_setg(errp, "Multifd is not compatible with compress");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void fill_destination_migration_info(MigrationInfo *info)
|
static void fill_destination_migration_info(MigrationInfo *info)
|
||||||
{
|
{
|
||||||
MigrationIncomingState *mis = migration_incoming_get_current();
|
MigrationIncomingState *mis = migration_incoming_get_current();
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
#include "qapi/error.h"
|
||||||
|
#include "sysemu/runstate.h"
|
||||||
#include "migration.h"
|
#include "migration.h"
|
||||||
|
#include "ram.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
bool migrate_auto_converge(void)
|
bool migrate_auto_converge(void)
|
||||||
|
@ -198,3 +201,192 @@ bool migrate_zero_copy_send(void)
|
||||||
|
|
||||||
return s->capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND];
|
return s->capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND];
|
||||||
}
|
}
|
||||||
|
typedef enum WriteTrackingSupport {
|
||||||
|
WT_SUPPORT_UNKNOWN = 0,
|
||||||
|
WT_SUPPORT_ABSENT,
|
||||||
|
WT_SUPPORT_AVAILABLE,
|
||||||
|
WT_SUPPORT_COMPATIBLE
|
||||||
|
} WriteTrackingSupport;
|
||||||
|
|
||||||
|
static
|
||||||
|
WriteTrackingSupport migrate_query_write_tracking(void)
|
||||||
|
{
|
||||||
|
/* Check if kernel supports required UFFD features */
|
||||||
|
if (!ram_write_tracking_available()) {
|
||||||
|
return WT_SUPPORT_ABSENT;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Check if current memory configuration is
|
||||||
|
* compatible with required UFFD features.
|
||||||
|
*/
|
||||||
|
if (!ram_write_tracking_compatible()) {
|
||||||
|
return WT_SUPPORT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return WT_SUPPORT_COMPATIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Migration capabilities set */
|
||||||
|
struct MigrateCapsSet {
|
||||||
|
int size; /* Capability set size */
|
||||||
|
MigrationCapability caps[]; /* Variadic array of capabilities */
|
||||||
|
};
|
||||||
|
typedef struct MigrateCapsSet MigrateCapsSet;
|
||||||
|
|
||||||
|
/* Define and initialize MigrateCapsSet */
|
||||||
|
#define INITIALIZE_MIGRATE_CAPS_SET(_name, ...) \
|
||||||
|
MigrateCapsSet _name = { \
|
||||||
|
.size = sizeof((int []) { __VA_ARGS__ }) / sizeof(int), \
|
||||||
|
.caps = { __VA_ARGS__ } \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Background-snapshot compatibility check list */
|
||||||
|
static const
|
||||||
|
INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snapshot,
|
||||||
|
MIGRATION_CAPABILITY_POSTCOPY_RAM,
|
||||||
|
MIGRATION_CAPABILITY_DIRTY_BITMAPS,
|
||||||
|
MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME,
|
||||||
|
MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE,
|
||||||
|
MIGRATION_CAPABILITY_RETURN_PATH,
|
||||||
|
MIGRATION_CAPABILITY_MULTIFD,
|
||||||
|
MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER,
|
||||||
|
MIGRATION_CAPABILITY_AUTO_CONVERGE,
|
||||||
|
MIGRATION_CAPABILITY_RELEASE_RAM,
|
||||||
|
MIGRATION_CAPABILITY_RDMA_PIN_ALL,
|
||||||
|
MIGRATION_CAPABILITY_COMPRESS,
|
||||||
|
MIGRATION_CAPABILITY_XBZRLE,
|
||||||
|
MIGRATION_CAPABILITY_X_COLO,
|
||||||
|
MIGRATION_CAPABILITY_VALIDATE_UUID,
|
||||||
|
MIGRATION_CAPABILITY_ZERO_COPY_SEND);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @migration_caps_check - check capability compatibility
|
||||||
|
*
|
||||||
|
* @old_caps: old capability list
|
||||||
|
* @new_caps: new capability list
|
||||||
|
* @errp: set *errp if the check failed, with reason
|
||||||
|
*
|
||||||
|
* Returns true if check passed, otherwise false.
|
||||||
|
*/
|
||||||
|
bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)
|
||||||
|
{
|
||||||
|
MigrationIncomingState *mis = migration_incoming_get_current();
|
||||||
|
|
||||||
|
#ifndef CONFIG_LIVE_BLOCK_MIGRATION
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_BLOCK]) {
|
||||||
|
error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i) "
|
||||||
|
"block migration");
|
||||||
|
error_append_hint(errp, "Use drive_mirror+NBD instead.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_REPLICATION
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_X_COLO]) {
|
||||||
|
error_setg(errp, "QEMU compiled without replication module"
|
||||||
|
" can't enable COLO");
|
||||||
|
error_append_hint(errp, "Please enable replication before COLO.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
|
||||||
|
/* This check is reasonably expensive, so only when it's being
|
||||||
|
* set the first time, also it's only the destination that needs
|
||||||
|
* special support.
|
||||||
|
*/
|
||||||
|
if (!old_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM] &&
|
||||||
|
runstate_check(RUN_STATE_INMIGRATE) &&
|
||||||
|
!postcopy_ram_supported_by_host(mis)) {
|
||||||
|
/* postcopy_ram_supported_by_host will have emitted a more
|
||||||
|
* detailed message
|
||||||
|
*/
|
||||||
|
error_setg(errp, "Postcopy is not supported");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED]) {
|
||||||
|
error_setg(errp, "Postcopy is not compatible with ignore-shared");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT]) {
|
||||||
|
WriteTrackingSupport wt_support;
|
||||||
|
int idx;
|
||||||
|
/*
|
||||||
|
* Check if 'background-snapshot' capability is supported by
|
||||||
|
* host kernel and compatible with guest memory configuration.
|
||||||
|
*/
|
||||||
|
wt_support = migrate_query_write_tracking();
|
||||||
|
if (wt_support < WT_SUPPORT_AVAILABLE) {
|
||||||
|
error_setg(errp, "Background-snapshot is not supported by host kernel");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (wt_support < WT_SUPPORT_COMPATIBLE) {
|
||||||
|
error_setg(errp, "Background-snapshot is not compatible "
|
||||||
|
"with guest memory configuration");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if there are any migration capabilities
|
||||||
|
* incompatible with 'background-snapshot'.
|
||||||
|
*/
|
||||||
|
for (idx = 0; idx < check_caps_background_snapshot.size; idx++) {
|
||||||
|
int incomp_cap = check_caps_background_snapshot.caps[idx];
|
||||||
|
if (new_caps[incomp_cap]) {
|
||||||
|
error_setg(errp,
|
||||||
|
"Background-snapshot is not compatible with %s",
|
||||||
|
MigrationCapability_str(incomp_cap));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_LINUX
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
|
||||||
|
(!new_caps[MIGRATION_CAPABILITY_MULTIFD] ||
|
||||||
|
new_caps[MIGRATION_CAPABILITY_COMPRESS] ||
|
||||||
|
new_caps[MIGRATION_CAPABILITY_XBZRLE] ||
|
||||||
|
migrate_multifd_compression() ||
|
||||||
|
migrate_use_tls())) {
|
||||||
|
error_setg(errp,
|
||||||
|
"Zero copy only available for non-compressed non-TLS multifd migration");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) {
|
||||||
|
error_setg(errp,
|
||||||
|
"Zero copy currently only available on Linux");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]) {
|
||||||
|
if (!new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
|
||||||
|
error_setg(errp, "Postcopy preempt requires postcopy-ram");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Preempt mode requires urgent pages to be sent in separate
|
||||||
|
* channel, OTOH compression logic will disorder all pages into
|
||||||
|
* different compression channels, which is not compatible with the
|
||||||
|
* preempt assumptions on channel assignments.
|
||||||
|
*/
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) {
|
||||||
|
error_setg(errp, "Postcopy preempt not compatible with compress");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) {
|
||||||
|
if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) {
|
||||||
|
error_setg(errp, "Multifd is not compatible with compress");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -38,4 +38,8 @@ bool migrate_xbzrle(void);
|
||||||
bool migrate_zero_blocks(void);
|
bool migrate_zero_blocks(void);
|
||||||
bool migrate_zero_copy_send(void);
|
bool migrate_zero_copy_send(void);
|
||||||
|
|
||||||
|
/* capabilities helpers */
|
||||||
|
|
||||||
|
bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue