Add 'migrationpin' to migration parameters to provide another method
to set the cpulist required for migration thread pin. 'migrationpin'
can only be set before migration and won't effect if 'virsh migrationpin'
is set.
Signed-off-by: zhengchuan<zhengchuan@huawei.com>
Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
---
include/libvirt/libvirt-domain.h | 10 ++++++++++
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_migration.c | 2 ++
src/qemu/qemu_migration.h | 33 ++++++++++++++++----------------
src/qemu/qemu_migration_params.c | 21 ++++++++++++++++++++
src/qemu/qemu_migration_params.h | 5 +++++
7 files changed, 57 insertions(+), 16 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index b6c01016d8..5a203d97dc 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1367,6 +1367,16 @@ typedef enum {
*/
# define VIR_MIGRATE_PARAM_TLS_DESTINATION "tls.destination"
+/**
+ * VIR_MIGRATE_PARAM_MIGRATIONPIN:
+ *
+ * virDomainMigrate* params field: the pin of migration threads for
+ * migration as VIR_TYPED_PARAM_STRING.
+ *
+ * Since: 9.1.0
+ */
+# define VIR_MIGRATE_PARAM_MIGRATIONPIN "migration.pin"
+
/* Domain migration. */
virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
unsigned long flags, const char *dname,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 3d497dd5d0..04e89bae95 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1903,6 +1903,7 @@ qemuDomainObjPrivateFree(void *data)
virObjectUnref(priv->monConfig);
g_free(priv->lockState);
g_free(priv->origname);
+ g_free(priv->migrationThreadPinList);
virChrdevFree(priv->devs);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index af986b5423..f52f2c9957 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -146,6 +146,7 @@ struct _qemuDomainObjPrivate {
int nbdPort; /* Port used for migration with NBD */
int migThreadCount;
qemuDomainMigThreadInfo **migThreadsInfo;
+ char *migrationThreadPinList;
unsigned short migrationPort;
int preMigrationState;
unsigned long long preMigrationMemlock; /* Original RLIMIT_MEMLOCK in case
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 0cea055eec..1fb091255f 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4891,6 +4891,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
priv->migMaxBandwidth * 1024 * 1024) < 0)
goto error;
+ qemuMigrationMigrationParamsToVM(migParams, vm);
+
if (qemuMigrationParamsApply(vm, VIR_ASYNC_JOB_MIGRATION_OUT,
migParams, flags) < 0)
goto error;
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index d21b6f67e8..f416462c9d 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -66,28 +66,29 @@
/* All supported migration parameters and their types. */
#define QEMU_MIGRATION_PARAMETERS \
- VIR_MIGRATE_PARAM_URI, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_DEST_XML, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_BANDWIDTH, VIR_TYPED_PARAM_ULLONG, \
- VIR_MIGRATE_PARAM_GRAPHICS_URI, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_LISTEN_ADDRESS, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_MIGRATE_DISKS, VIR_TYPED_PARAM_STRING | \
- VIR_TYPED_PARAM_MULTIPLE, \
- VIR_MIGRATE_PARAM_DISKS_PORT, VIR_TYPED_PARAM_INT, \
- VIR_MIGRATE_PARAM_COMPRESSION, VIR_TYPED_PARAM_STRING | \
- VIR_TYPED_PARAM_MULTIPLE, \
+ VIR_MIGRATE_PARAM_URI, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_DEST_XML, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_BANDWIDTH, VIR_TYPED_PARAM_ULLONG, \
+ VIR_MIGRATE_PARAM_GRAPHICS_URI, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_LISTEN_ADDRESS, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS, VIR_TYPED_PARAM_STRING | \
+ VIR_TYPED_PARAM_MULTIPLE, \
+ VIR_MIGRATE_PARAM_DISKS_PORT, VIR_TYPED_PARAM_INT, \
+ VIR_MIGRATE_PARAM_COMPRESSION, VIR_TYPED_PARAM_STRING | \
+ VIR_TYPED_PARAM_MULTIPLE, \
VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, VIR_TYPED_PARAM_INT, \
VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, VIR_TYPED_PARAM_INT, \
VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, VIR_TYPED_PARAM_INT, \
VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, VIR_TYPED_PARAM_ULLONG, \
- VIR_MIGRATE_PARAM_PERSIST_XML, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_PERSIST_XML, VIR_TYPED_PARAM_STRING, \
VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL, VIR_TYPED_PARAM_INT, \
VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT, VIR_TYPED_PARAM_INT, \
- VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY, VIR_TYPED_PARAM_ULLONG, \
- VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS, VIR_TYPED_PARAM_INT, \
- VIR_MIGRATE_PARAM_TLS_DESTINATION, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_DISKS_URI, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY, VIR_TYPED_PARAM_ULLONG, \
+ VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS, VIR_TYPED_PARAM_INT, \
+ VIR_MIGRATE_PARAM_TLS_DESTINATION, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_DISKS_URI, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_MIGRATIONPIN, VIR_TYPED_PARAM_STRING, \
NULL
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 43bed2e618..7852f3e295 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -114,6 +114,7 @@ VIR_ENUM_IMPL(qemuMigrationParam,
"xbzrle-cache-size",
"max-postcopy-bandwidth",
"multifd-channels",
+ "migrationpin",
);
typedef struct _qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOnItem;
@@ -228,6 +229,10 @@ static const qemuMigrationParamsTPMapItem qemuMigrationParamsTPMap[] = {
{.typedParam = VIR_MIGRATE_PARAM_TLS_DESTINATION,
.param = QEMU_MIGRATION_PARAM_TLS_HOSTNAME,
.party = QEMU_MIGRATION_SOURCE},
+
+ {.typedParam = VIR_MIGRATE_PARAM_MIGRATIONPIN,
+ .param = QEMU_MIGRATION_PARAM_MIGRATIONPIN,
+ .party = QEMU_MIGRATION_SOURCE},
};
static const qemuMigrationParamInfoItem qemuMigrationParamInfo[] = {
@@ -271,6 +276,9 @@ static const qemuMigrationParamInfoItem qemuMigrationParamInfo[] = {
[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS] = {
.type = QEMU_MIGRATION_PARAM_TYPE_INT,
},
+ [QEMU_MIGRATION_PARAM_MIGRATIONPIN] = {
+ .type = QEMU_MIGRATION_PARAM_TYPE_STRING,
+ },
};
G_STATIC_ASSERT(G_N_ELEMENTS(qemuMigrationParamInfo) == QEMU_MIGRATION_PARAM_LAST);
@@ -798,6 +806,10 @@ qemuMigrationParamsToJSON(qemuMigrationParams *migParams,
if (!pv->set)
continue;
+ if (i == QEMU_MIGRATION_PARAM_MIGRATIONPIN) {
+ continue;
+ }
+
if (postcopyResume && !qemuMigrationParamInfo[i].applyOnPostcopyResume)
continue;
@@ -1559,3 +1571,12 @@ qemuMigrationParamsGetMigThreadCount(qemuMigrationParams *migParams,
return nmigthreads;
}
+
+void
+qemuMigrationMigrationParamsToVM(const qemuMigrationParams *migParams, const virDomainObj *vm)
+{
+ if (migParams && migParams->params[QEMU_MIGRATION_PARAM_MIGRATIONPIN].set) {
+ qemuDomainObjPrivate *priv = vm->privateData;
+ priv->migrationThreadPinList = g_strdup(migParams->params[QEMU_MIGRATION_PARAM_MIGRATIONPIN].value.s);
+ }
+}
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 975b6691d4..d8321cace8 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -59,6 +59,7 @@ typedef enum {
QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE,
QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH,
QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS,
+ QEMU_MIGRATION_PARAM_MIGRATIONPIN,
QEMU_MIGRATION_PARAM_LAST
} qemuMigrationParam;
@@ -170,3 +171,7 @@ qemuMigrationParamsGetTLSHostname(qemuMigrationParams *migParams);
int
qemuMigrationParamsGetMigThreadCount(qemuMigrationParams *migParams,
unsigned long migflags);
+
+void
+qemuMigrationMigrationParamsToVM(const qemuMigrationParams *migParams,
+ const virDomainObj *vm);
--
2.33.0
© 2016 - 2024 Red Hat, Inc.