From 36295c0cc955fee9afc7b0fb70822c8e1e030b87 Mon Sep 17 00:00:00 2001
From: zhengchuan <zhengchuan@huawei.com>
Date: Wed, 14 Dec 2022 11:07:58 +0800
Subject: [PATCH 1/6] migration/migration-pin:add some migration/multiFd params

add migration/multiFd params.

Signed-off-by:zhengchuan<zhengchuan@huawei.com>
---
 src/conf/domain_conf.c   |  9 +++++++++
 src/conf/domain_conf.h   | 12 ++++++++++++
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_domain.c   |  6 ++++++
 src/qemu/qemu_domain.h   |  4 ++++
 src/util/vircgroup.c     |  3 +++
 src/util/vircgroup.h     |  1 +
 7 files changed, 36 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8b1ca76d39..1689d92c51 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -32617,3 +32617,12 @@ virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev)
         hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
         hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
 }
+
+void
+virDomainMigrationIDDefFree(virDomainMigrationIDDefPtr def)
+{
+    if (!def)
+        return;
+    virBitmapFree(def->cpumask);
+    VIR_FREE(def);
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c0a323d465..98fa323679 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -27,6 +27,7 @@
 #include <libxml/xpath.h>
 
 #include "internal.h"
+#include "viralloc.h"
 #include "virconftypes.h"
 #include "capabilities.h"
 #include "virstorageencryption.h"
@@ -3775,3 +3776,14 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *hostdev)
 bool
 virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev)
     ATTRIBUTE_NONNULL(1);
+
+typedef struct _virDomainMigrationIDDef virDomainMigrationIDDef;
+typedef virDomainMigrationIDDef *virDomainMigrationIDDefPtr;
+struct _virDomainMigrationIDDef {
+    bool autofill;
+    int thread_id;
+    virBitmapPtr cpumask;
+    virDomainThreadSchedParam sched;
+};
+
+void virDomainMigrationIDDefFree(virDomainMigrationIDDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 14ad7ecde3..f30eb7ffb5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -492,6 +492,7 @@ virDomainMemoryModelTypeToString;
 virDomainMemoryRemove;
 virDomainMemorySourceTypeFromString;
 virDomainMemorySourceTypeToString;
+virDomainMigrationIDDefFree;
 virDomainNetAllocateActualDevice;
 virDomainNetAppendIPAddress;
 virDomainNetARPInterfaces;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b2ac1d37cc..71d034fa42 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2322,6 +2322,12 @@ qemuDomainObjPrivateFree(void *data)
     qemuDomainObjFreeJob(priv);
     VIR_FREE(priv->lockState);
     VIR_FREE(priv->origname);
+    VIR_FREE(priv->migrationPids);
+    virBitmapFree(priv->pcpumap);
+
+    VIR_FREE(priv->migrationMultiFdPids);
+    priv->migrationMultiFdPids = NULL;
+    priv->migrationMultiFdCount = 0;
 
     virChrdevFree(priv->devs);
 
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 164fb36f0c..38a842ebf6 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -332,8 +332,11 @@ struct _qemuDomainObjPrivate {
     unsigned long migMaxBandwidth;
     char *origname;
     int nbdPort; /* Port used for migration with NBD */
+    char *migrationPids;
     unsigned short migrationPort;
     int preMigrationState;
+    char *migrationMultiFdPids;
+    unsigned int migrationMultiFdCount;
 
     virChrdevsPtr devs;
 
@@ -354,6 +357,7 @@ struct _qemuDomainObjPrivate {
     /* Bitmaps below hold data from the auto NUMA feature */
     virBitmapPtr autoNodeset;
     virBitmapPtr autoCpuset;
+    virBitmapPtr pcpumap;
 
     bool signalIOError; /* true if the domain condition should be signalled on
                            I/O error */
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index f52a8cc843..b075dd1ecb 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -969,6 +969,9 @@ virCgroupNewThread(virCgroupPtr domain,
     case VIR_CGROUP_THREAD_IOTHREAD:
         name = g_strdup_printf("iothread%d", id);
         break;
+    case VIR_CGROUP_THREAD_MIGRATION_THREAD:
+        name = g_strdup_printf("migthread%d", id);
+        break;
     case VIR_CGROUP_THREAD_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected name value %d"), nameval);
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 1dcd0688f1..5639f36c1f 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -54,6 +54,7 @@ typedef enum {
     VIR_CGROUP_THREAD_VCPU = 0,
     VIR_CGROUP_THREAD_EMULATOR,
     VIR_CGROUP_THREAD_IOTHREAD,
+    VIR_CGROUP_THREAD_MIGRATION_THREAD,
 
     VIR_CGROUP_THREAD_LAST
 } virCgroupThreadName;
-- 
2.25.1

