From nobody Mon Feb 9 23:57:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1672751698; cv=none; d=zohomail.com; s=zohoarc; b=ft9kt6kEmtSWaZhnYL7+sBLVJEUX5LmjfEfV/nowfT6x4dypfxrLcbidMdBt0eVWKFPOt5+iZDU8G6LR8KSiSAkzPreUTDkikWOr7rMobhE0ffc+bF52wleBBx+i5fC3VSzHIStk+la3g4im5nWNxFtpa8leyyCYyp8Grx/Y43g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672751698; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b+3+mPw3ILNp9QbWIcwGpLnW1l1NWmOCaCg7FQuxDx8=; b=IcQC04RguxRKELJSRLDBxmRAeHOkDJMKStxEglTEfmVplo22rXog2A5rUJWcR4uHDrfzCmdB+w86TBwT0zQDHIcF9bA7OpDpmWA1so4/LgoqibYCGWsPgaVcRsQ/ATd41SHpWphMg6TW9pWTBsw7YsnBVskMksaU4oc7RJk3F6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672751698739826.9774196846853; Tue, 3 Jan 2023 05:14:58 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-NlzKqhZ1POi7dGYxj_IEkA-1; Tue, 03 Jan 2023 08:14:53 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 84680889059; Tue, 3 Jan 2023 13:14:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BD5014171BA; Tue, 3 Jan 2023 13:14:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 56B4519465B1; Tue, 3 Jan 2023 13:14:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A661D1946588 for ; Tue, 3 Jan 2023 13:14:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 96CFD4085723; Tue, 3 Jan 2023 13:14:41 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C6DF40C10FA for ; Tue, 3 Jan 2023 13:14:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D18F3811F5E for ; Tue, 3 Jan 2023 13:14:41 +0000 (UTC) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-237-ipS2-vDfPDiLGxVxGiSyNg-1; Tue, 03 Jan 2023 08:14:36 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NmY4n09gfzJpZv for ; Tue, 3 Jan 2023 21:10:33 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 3 Jan 2023 21:14:31 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672751697; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=b+3+mPw3ILNp9QbWIcwGpLnW1l1NWmOCaCg7FQuxDx8=; b=RmvnCBdkYpQAx4INAxTD/3B26Hot+BlN7PYbNYgYkTqlUNp1wBSnS+YsLXqKWQ7FT2Xizi Se5XxkxEjKpazsv7irMcHyPYT4FYYquYGhp3YLYkFm5gQxrQvDOydAY5PBNqTVnqP9NywP 5V3lQCfAu+Zv7rQngSOc+MEFh25ajrE= X-MC-Unique: NlzKqhZ1POi7dGYxj_IEkA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ipS2-vDfPDiLGxVxGiSyNg-1 From: Jiang Jiacheng To: Subject: [PATCH 03/12] migration/migration-pin: support migration thread pin by virsh command Date: Tue, 3 Jan 2023 21:08:22 +0800 Message-ID: <20230103130831.1828670-4-jiangjiacheng@huawei.com> In-Reply-To: <20230103130831.1828670-1-jiangjiacheng@huawei.com> References: <20230103130831.1828670-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yubihong@huawei.com, zhengchuan@huawei.com, linyilu@huawei.com, jiangjiacheng@huawei.com, xiexiangyou@huawei.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672751700647100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiang Jiacheng --- tools/virsh-domain.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 2d162cf8c0..e17c526850 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13760,6 +13760,69 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd = *cmd) } =20 =20 +/* + * "migrationpin" command + */ +static const vshCmdInfo info_migrationpin[] =3D { + {.name =3D "help", + .data =3D N_("control domain migrationThreads affinity") + }, + {.name =3D "desc", + .data =3D N_("Pin domain migrationThreads to host physical CPUs.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_migrationpin[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "cpulist", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("host cpu number(s) to set") + }, + {.name =3D NULL} +}; + +static bool +cmdMigrationPin(vshControl *ctl, const vshCmd *cmd) +{ + g_autoptr(virshDomain) dom =3D NULL; + const char *name =3D NULL; + const char *cpulist =3D NULL; + int maxcpu; + g_autofree unsigned char *cpumap =3D NULL; + int cpumaplen; + virshControl *priv =3D ctl->privData; + + dom =3D 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 =3D virshNodeGetCPUCount(priv->conn); + if (maxcpu < 0) + return false; + + cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu); + if (!cpumap) + return false; + + if (virDomainPinMigrationThread(dom, cpumap, + cpumaplen) !=3D 0) + return false; + + vshPrintExtra(ctl, _("Pin domain %s's migration thread " + "to cpulist %s success.\n"), name, cpulist); + + return true; +} + + const vshCmdDef domManagementCmds[] =3D { {.name =3D "attach-device", .handler =3D cmdAttachDevice, @@ -14417,5 +14480,11 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_domdirtyrate_calc, .flags =3D 0 }, + {.name =3D "migrationpin", + .handler =3D cmdMigrationPin, + .opts =3D opts_migrationpin, + .info =3D info_migrationpin, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.33.0