From: zhengchuan <zhengchuan(a)huawei.com>
Firstly, we need to get multifd pids, add
virDomainMigrateGetMigrationMultiFdPids() for migration pin.
Signed-off-by:zhengchuan<zhengchuan@huawei.com>
---
include/libvirt/libvirt-domain.h | 2 ++
src/driver-hypervisor.h | 5 ++++
src/libvirt-domain.c | 40 ++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 1 +
src/qemu/qemu_domain.c | 2 ++
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_driver.c | 33 ++++++++++++++++++++++++++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 17 +++++++++++++-
src/remote_protocol-structs | 15 ++++++++++++
10 files changed, 117 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 76744eb0f1..cca35c1be1 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -6474,4 +6474,6 @@ int virDomainStartDirtyRateCalc(virDomainPtr domain,
char *virDomainMigrateGetMigrationPids(virDomainPtr domain,
unsigned int flags);
+char *virDomainMigrateGetMigrationMultiFdPids(virDomainPtr domain,
+ unsigned int flags);
#endif /* LIBVIRT_DOMAIN_H */
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 1d7f606c59..cb1d4241af 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1450,6 +1450,10 @@ typedef char *
(*virDrvDomainMigrateGetMigrationPids)(virDomainPtr domain,
unsigned int flags);
+typedef char *
+(*virDrvDomainMigrateGetMigrationMultiFdPids)(virDomainPtr domain,
+ unsigned int flags);
+
typedef struct _virHypervisorDriver virHypervisorDriver;
/**
@@ -1723,4 +1727,5 @@ struct _virHypervisorDriver {
virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc;
virDrvDomainPinMigrationThread domainPinMigrationThread;
virDrvDomainMigrateGetMigrationPids domainMigrateGetMigrationPids;
+ virDrvDomainMigrateGetMigrationMultiFdPids domainMigrateGetMigrationMultiFdPids;
};
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index d35a8237ae..c36e3ba9d6 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -14012,6 +14012,46 @@ virDomainMigrateGetMigrationPids(virDomainPtr domain,
return NULL;
}
+
+/*
+ * virDomainMigrateGetMigrationMultiFdPids:
+ * @domain: pointer to domain object
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Get multifd thread pid.
+ *
+ * Returns the multifd1 and multifd2 pids which must be freed by the caller, or
+ * NULL if there was an error.
+ *
+ * Since: 9.1.0
+ */
+char *
+virDomainMigrateGetMigrationMultiFdPids(virDomainPtr domain,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+ VIR_DOMAIN_DEBUG(domain, "MultiFd pids flags=0x%x", flags);
+ virResetLastError();
+ virCheckDomainReturn(domain, NULL);
+ conn = domain->conn;
+
+ virCheckReadOnlyGoto(domain->conn->flags, error);
+
+ if (conn->driver->domainMigrateGetMigrationMultiFdPids) {
+ char *ret;
+ ret = conn->driver->domainMigrateGetMigrationMultiFdPids(domain, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(domain->conn);
+ return NULL;
+}
+
/**
* virDomainPinMigrationThread:
* @domain: a domain object
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 61561f2367..e31081354f 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -931,6 +931,7 @@ LIBVIRT_9.1.0 {
global:
virDomainPinMigrationThread;
virDomainMigrateGetMigrationPids;
+ virDomainMigrateGetMigrationMultiFdPids;
} LIBVIRT_8.5.0;
# .... define new API here using predicted next version number ....
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index de90cf42f9..4ab7771a59 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1830,6 +1830,8 @@ qemuDomainObjPrivateFree(void *data)
g_free(priv->origname);
g_free(priv->migrationPids);
g_free(priv->migrationThreadPinList);
+ g_free(priv->migrationMultiFdPids);
+ priv->migrationMultiFdCount = 0;
virChrdevFree(priv->devs);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 5aa4eb5840..36984e2bb1 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -141,6 +141,8 @@ struct _qemuDomainObjPrivate {
unsigned short migrationPort;
char *migrationPids;
char *migrationThreadPinList;
+ char *migrationMultiFdPids;
+ unsigned int migrationMultiFdCount;
int preMigrationState;
unsigned long long preMigrationMemlock; /* Original RLIMIT_MEMLOCK in case
it was changed for the current
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7ae81f459f..92049c5bcd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20678,6 +20678,38 @@ qemuDomainMigrateGetMigrationPids(virDomainPtr dom,
return ret;
}
+
+static char *
+qemuDomainMigrateGetMigrationMultiFdPids(virDomainPtr dom,
+ unsigned int flags)
+{
+ char *ret = NULL;
+ virDomainObj *vm = NULL;
+ qemuDomainObjPrivate *priv = NULL;
+
+ virCheckFlags(0, NULL);
+
+ vm = qemuDomainObjFromDomain(dom);
+ if (!vm)
+ goto cleanup;
+
+ if (virDomainMigrateGetMigrationMultiFdPidsEnsureACL(dom->conn, vm->def) <
0)
+ goto cleanup;
+
+ priv = vm->privateData;
+
+ if (priv->migrationMultiFdPids) {
+ ret = g_strdup(priv->migrationMultiFdPids);
+ if (!ret)
+ VIR_ERROR(_("failed to strdup MultiFdPids"));
+ }
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
static int
qemuDomainPinMigrationThread(virDomainPtr dom,
unsigned char *cpumap,
@@ -21019,6 +21051,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
.domainSetLaunchSecurityState = qemuDomainSetLaunchSecurityState, /* 8.0.0 */
.domainPinMigrationThread = qemuDomainPinMigrationThread, /* 9.1.0 */
.domainMigrateGetMigrationPids = qemuDomainMigrateGetMigrationPids, /* 9.1.0 */
+ .domainMigrateGetMigrationMultiFdPids = qemuDomainMigrateGetMigrationMultiFdPids, /*
9.1.0 */
};
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 1c7cac6b29..f6ec3fb85e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8653,6 +8653,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainSetLaunchSecurityState = remoteDomainSetLaunchSecurityState, /* 8.0.0 */
.domainPinMigrationThread = remoteDomainPinMigrationThread, /* 9.1.0 */
.domainMigrateGetMigrationPids = remoteDomainMigrateGetMigrationPids, /* 9.1.0 */
+ .domainMigrateGetMigrationMultiFdPids = remoteDomainMigrateGetMigrationMultiFdPids,
/* 9.1.0 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index f86172b636..e83bc297cd 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2542,6 +2542,15 @@ struct remote_domain_migrate_get_migration_pids_ret {
remote_nonnull_string migrationPids;
};
+struct remote_domain_migrate_get_migration_multi_fd_pids_args {
+ remote_nonnull_domain dom;
+ unsigned int flags;
+};
+
+struct remote_domain_migrate_get_migration_multi_fd_pids_ret {
+ remote_nonnull_string migrationMultiFdPids;
+};
+
struct remote_domain_migrate_set_max_speed_args {
remote_nonnull_domain dom;
unsigned hyper bandwidth;
@@ -6987,5 +6996,11 @@ enum remote_procedure {
* @generate: both
* @acl: domain:write
*/
- REMOTE_PROC_DOMAIN_PIN_MIGRATION_THREAD = 444
+ REMOTE_PROC_DOMAIN_PIN_MIGRATION_THREAD = 444,
+
+ /**
+ * @generate: both
+ * @acl: domain:migrate
+ */
+ REMOTE_PROC_DOMAIN_MIGRATE_GET_MIGRATION_MULTI_FD_PIDS = 445
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 9ef27913f1..a6cedb7682 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -3279,6 +3279,20 @@ struct remote_domain_migrate_get_migration_pids_args {
struct remote_domain_migrate_get_migration_pids_ret {
remote_nonnull_string migrationPids;
};
+struct remote_domain_migrate_get_migration_pids_args {
+ remote_nonnull_domain dom;
+ u_int flags;
+};
+struct remote_domain_migrate_get_migration_pids_ret {
+ remote_nonnull_string migrationPids;
+};
+struct remote_domain_migrate_get_migration_multi_fd_pids_args {
+ remote_nonnull_domain dom;
+ u_int flags;
+};
+struct remote_domain_migrate_get_migration_multi_fd_pids_ret {
+ remote_nonnull_string m igrationMultiFdPids;
+};
enum remote_procedure {
REMOTE_PROC_CONNECT_OPEN = 1,
REMOTE_PROC_CONNECT_CLOSE = 2,
@@ -3724,4 +3738,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS = 442,
REMOTE_PROC_DOMAIN_MIGRATE_GET_MIGRATION_PIDS = 443,
REMOTE_PROC_DOMAIN_PIN_MIGRATION_THREAD = 444,
+ REMOTE_PROC_DOMAIN_MIGRATE_GET_MIGRATION_MULTI_FD_PIDS = 445,
};
--
2.33.0