Add virsh command 'virsh migrationpin', its usage is like
'virsh migrationpin [vm] [cpulist]'. After using this command, if
migration thread infomation have been got, pin it to given cpumap
immediately, else wait for next migraion operation and pin migration
thread after getting information.
Signed-off-by: zhengchuan<zhengchuan(a)huawei.com>
Signed-off-by: Jiang Jiacheng <jiangjiacheng(a)huawei.com>
---
tools/virsh-domain.c | 69 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a4abcb1b03..43ecd651d8 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -13814,6 +13814,69 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
}
+/*
+ * "migrationpin" command
+ */
+static const vshCmdInfo info_migrationpin[] = {
+ {.name = "help",
+ .data = N_("control domain migrationThreads affinity")
+ },
+ {.name = "desc",
+ .data = N_("Pin domain migrationThreads to host physical CPUs.")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_migrationpin[] = {
+ VIRSH_COMMON_OPT_DOMAIN_FULL(0),
+ {.name = "cpulist",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("host cpu number(s) to set")
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdMigrationPin(vshControl *ctl, const vshCmd *cmd)
+{
+ g_autoptr(virshDomain) dom = NULL;
+ const char *name = NULL;
+ const char *cpulist = NULL;
+ int maxcpu;
+ g_autofree unsigned char *cpumap = NULL;
+ int cpumaplen;
+ virshControl *priv = ctl->privData;
+
+ dom = virshCommandOptDomain(ctl, cmd, NULL);
+ if (!dom)
+ return false;
+
+ if (vshCommandOptStringReq(ctl, cmd, "domain", &name) < 0)
+ return false;
+
+ if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0)
+ return false;
+
+ maxcpu = virshNodeGetCPUCount(priv->conn);
+ if (maxcpu < 0)
+ return false;
+
+ cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu);
+ if (!cpumap)
+ return false;
+
+ if (virDomainPinMigrationThread(dom, cpumap,
+ cpumaplen) != 0)
+ return false;
+
+ vshPrintExtra(ctl, _("Pin domain %s's migration thread "
+ "to cpulist %s success.\n"), name, cpulist);
+
+ return true;
+}
+
+
const vshCmdDef domManagementCmds[] = {
{.name = "attach-device",
.handler = cmdAttachDevice,
@@ -14477,5 +14540,11 @@ const vshCmdDef domManagementCmds[] = {
.info = info_dom_fd_associate,
.flags = 0
},
+ {.name = "migrationpin",
+ .handler = cmdMigrationPin,
+ .opts = opts_migrationpin,
+ .info = info_migrationpin,
+ .flags = 0
+ },
{.name = NULL}
};
--
2.33.0