libvirt/src/qemu/qemu_migration_params.h
Jiri Denemark 8d693d79c4 qemu: Enable postcopy-preempt migration capability
During post-copy migration (once it actually switches to post-copy mode)
dirty memory pages are continued to be migrated iteratively, while the
destination can explicitly request a specific page to be migrated before
the iterative process gets to it (which happens when a guest wants to
read a page that was not migrated yet). Without the postcopy-preempt
capability enabled such pages need to wait until all other pages already
queued are transferred. Enabling this capability will instruct the
hypervisor to create a separate migration channel for explicitly
requested pages so that they can preempt the queue.

The only requirement for the feature to work is running a migration over
a protocol that supports multiple connections. In other words, we can't
pre-create the connection and pass its file descriptor to QEMU (i.e.,
using MIGRATION_DEST_CONNECT_SOCKET), but we have to let QEMU open the
connections itself (using MIGRATION_DEST_SOCKET). This change is applied
to all post-copy migrations even if postcopy-preempt is not supported to
avoid making the code even uglier than it is now. There's no real
difference between the two methods with modern QEMU (which can properly
report connection failures) anyway.

This capability is enabled for all post-copy migration as long as the
capability is supported on both sides of migration.

https://issues.redhat.com/browse/RHEL-7100

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2024-01-08 22:41:23 +01:00

174 lines
5.4 KiB
C

/*
* qemu_migration_params.h: QEMU migration parameters handling
*
* Copyright (C) 2006-2018 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "internal.h"
#include "virbuffer.h"
#include "qemu_conf.h"
#include "virenum.h"
typedef enum {
QEMU_MIGRATION_CAP_XBZRLE,
QEMU_MIGRATION_CAP_AUTO_CONVERGE,
QEMU_MIGRATION_CAP_RDMA_PIN_ALL,
QEMU_MIGRATION_CAP_EVENTS,
QEMU_MIGRATION_CAP_POSTCOPY,
QEMU_MIGRATION_CAP_COMPRESS,
QEMU_MIGRATION_CAP_PAUSE_BEFORE_SWITCHOVER,
QEMU_MIGRATION_CAP_LATE_BLOCK_ACTIVATE,
QEMU_MIGRATION_CAP_MULTIFD,
QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS,
QEMU_MIGRATION_CAP_RETURN_PATH,
QEMU_MIGRATION_CAP_ZERO_COPY_SEND,
QEMU_MIGRATION_CAP_POSTCOPY_PREEMPT,
QEMU_MIGRATION_CAP_LAST
} qemuMigrationCapability;
VIR_ENUM_DECL(qemuMigrationCapability);
typedef enum {
QEMU_MIGRATION_PARAM_COMPRESS_LEVEL,
QEMU_MIGRATION_PARAM_COMPRESS_THREADS,
QEMU_MIGRATION_PARAM_DECOMPRESS_THREADS,
QEMU_MIGRATION_PARAM_THROTTLE_INITIAL,
QEMU_MIGRATION_PARAM_THROTTLE_INCREMENT,
QEMU_MIGRATION_PARAM_TLS_CREDS,
QEMU_MIGRATION_PARAM_TLS_HOSTNAME,
QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
QEMU_MIGRATION_PARAM_DOWNTIME_LIMIT,
QEMU_MIGRATION_PARAM_BLOCK_INCREMENTAL,
QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE,
QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH,
QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS,
QEMU_MIGRATION_PARAM_MULTIFD_COMPRESSION,
QEMU_MIGRATION_PARAM_MULTIFD_ZLIB_LEVEL,
QEMU_MIGRATION_PARAM_MULTIFD_ZSTD_LEVEL,
QEMU_MIGRATION_PARAM_LAST
} qemuMigrationParam;
typedef struct _qemuMigrationParams qemuMigrationParams;
typedef enum {
QEMU_MIGRATION_SOURCE = (1 << 0),
QEMU_MIGRATION_DESTINATION = (1 << 1),
} qemuMigrationParty;
virBitmap *
qemuMigrationParamsGetAlwaysOnCaps(qemuMigrationParty party);
qemuMigrationParams *
qemuMigrationParamsFromFlags(virTypedParameterPtr params,
int nparams,
unsigned int flags,
qemuMigrationParty party);
int
qemuMigrationParamsDump(qemuMigrationParams *migParams,
virTypedParameterPtr *params,
int *nparams,
int *maxparams,
unsigned int *flags);
qemuMigrationParams *
qemuMigrationParamsNew(void);
void
qemuMigrationParamsFree(qemuMigrationParams *migParams);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationParams, qemuMigrationParamsFree);
int
qemuMigrationParamsApply(virDomainObj *vm,
int asyncJob,
qemuMigrationParams *migParams,
unsigned int apiFlags);
int
qemuMigrationParamsEnableTLS(virQEMUDriver *driver,
virDomainObj *vm,
bool tlsListen,
int asyncJob,
char **tlsAlias,
const char *hostname,
qemuMigrationParams *migParams);
int
qemuMigrationParamsDisableTLS(virDomainObj *vm,
qemuMigrationParams *migParams);
bool
qemuMigrationParamsTLSHostnameIsSet(qemuMigrationParams *migParams);
int
qemuMigrationParamsFetch(virDomainObj *vm,
int asyncJob,
qemuMigrationParams **migParams);
int
qemuMigrationParamsSetULL(qemuMigrationParams *migParams,
qemuMigrationParam param,
unsigned long long value);
int
qemuMigrationParamsGetULL(qemuMigrationParams *migParams,
qemuMigrationParam param,
unsigned long long *value);
void
qemuMigrationParamsSetBlockDirtyBitmapMapping(qemuMigrationParams *migParams,
virJSONValue **params);
int
qemuMigrationParamsCheck(virDomainObj *vm,
int asyncJob,
qemuMigrationParams *migParams,
virBitmap *remoteSupported,
virBitmap *remoteAuto);
void
qemuMigrationParamsReset(virDomainObj *vm,
int asyncJob,
qemuMigrationParams *origParams,
unsigned int apiFlags);
void
qemuMigrationParamsFormat(virBuffer *buf,
qemuMigrationParams *migParams);
int
qemuMigrationParamsParse(xmlXPathContextPtr ctxt,
qemuMigrationParams **migParams);
int
qemuMigrationCapsCheck(virDomainObj *vm,
int asyncJob,
bool reconnect);
bool
qemuMigrationCapsGet(virDomainObj *vm,
qemuMigrationCapability cap);
const char *
qemuMigrationParamsGetTLSHostname(qemuMigrationParams *migParams);