From nobody Sat May 4 10:15:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1515061456108299.3867404537348; Thu, 4 Jan 2018 02:24:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52188C047B80; Thu, 4 Jan 2018 10:24:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF370608E0; Thu, 4 Jan 2018 10:24:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DB46718033D9; Thu, 4 Jan 2018 10:24:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w04AOBAf031732 for ; Thu, 4 Jan 2018 05:24:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id A29C95DA2A; Thu, 4 Jan 2018 10:24:11 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C6005DA60 for ; Thu, 4 Jan 2018 10:24:09 +0000 (UTC) Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.217.80.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97800C057EC4 for ; Thu, 4 Jan 2018 10:24:07 +0000 (UTC) Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id A643F27B260CFF8E862C for ; Thu, 4 Jan 2018 18:24:05 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w04ANrEV077014 for ; Thu, 4 Jan 2018 18:23:53 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018010418240144-644515 ; Thu, 4 Jan 2018 18:24:01 +0800 From: Yi Wang To: libvir-list@redhat.com Date: Thu, 4 Jan 2018 05:46:32 -0500 Message-Id: <1515062792-16289-1-git-send-email-wang.yi59@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-01-04 18:24:01, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-01-04 18:23:42, Serialize complete at 2018-01-04 18:23:42 X-MAIL: mse01.zte.com.cn w04ANrEV077014 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 04 Jan 2018 10:24:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 04 Jan 2018 10:24:08 +0000 (UTC) for IP:'63.217.80.70' DOMAIN:'mxhk.zte.com.cn' HELO:'mxhk.zte.com.cn' FROM:'wang.yi59@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -2.311 (RCVD_IN_DNSWL_MED, SPF_PASS, T_RP_MATCHES_RCVD) 63.217.80.70 mxhk.zte.com.cn 63.217.80.70 mxhk.zte.com.cn X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: wang.yi59@zte.com.cn, Liu.Jianjun3@zte.com.cn, xu.xi8@zte.com.cn Subject: [libvirt] [PATCH] [PATCH] vcpupin: add clear feature X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 04 Jan 2018 10:24:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We can't clear vcpupin settings of XML once we did vcpupin command, this is not convenient under some condition such as migration. This patch introduces clear feature, which can clear vcpuin setting of XML. Signed-off-by: Yi Wang Signed-off-by: Xi Xu --- include/libvirt/libvirt-domain.h | 1 + src/qemu/qemu_driver.c | 24 +++++++++++++++++++----- tools/virsh-domain.c | 5 ++++- tools/virsh.pod | 1 + 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4048acf..7b171df 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1837,6 +1837,7 @@ typedef enum { VIR_DOMAIN_VCPU_MAXIMUM =3D (1 << 2), /* Max rather than current count= */ VIR_DOMAIN_VCPU_GUEST =3D (1 << 3), /* Modify state of the cpu in th= e guest */ VIR_DOMAIN_VCPU_HOTPLUGGABLE =3D (1 << 4), /* Make vcpus added hot(un)= pluggable */ + VIR_DOMAIN_VCPU_CLEAR =3D (1 << 5), /* Clear vcpus pin info */ } virDomainVcpuFlags; =20 int virDomainSetVcpus (virDomainPtr domain, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 97b194b..9e8759f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5001,7 +5001,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, int vcpu, virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg, - virBitmapPtr cpumap) + virBitmapPtr cpumap, bool clear) { virBitmapPtr tmpmap =3D NULL; virDomainVcpuDefPtr vcpuinfo; @@ -5049,7 +5049,12 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, } =20 virBitmapFree(vcpuinfo->cpumask); - vcpuinfo->cpumask =3D tmpmap; + if (clear) { + virBitmapFree(tmpmap); + vcpuinfo->cpumask =3D NULL; + } else { + vcpuinfo->cpumask =3D tmpmap; + } tmpmap =3D NULL; =20 if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) @@ -5093,9 +5098,11 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, virBitmapPtr pcpumap =3D NULL; virDomainVcpuDefPtr vcpuinfo =3D NULL; virQEMUDriverConfigPtr cfg =3D NULL; + bool clear =3D false; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | - VIR_DOMAIN_AFFECT_CONFIG, -1); + VIR_DOMAIN_AFFECT_CONFIG | + VIR_DOMAIN_VCPU_CLEAR, -1); =20 cfg =3D virQEMUDriverGetConfig(driver); =20 @@ -5111,6 +5118,8 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) goto endjob; =20 + clear =3D !!(flags & VIR_DOMAIN_VCPU_CLEAR); + if ((def && def->virtType =3D=3D VIR_DOMAIN_VIRT_QEMU) || (persistentDef && persistentDef->virtType =3D=3D VIR_DOMAIN_VIRT_Q= EMU)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", @@ -5136,12 +5145,17 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, } =20 if (def && - qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumap) < 0) + qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumap, clear) = < 0) goto endjob; =20 if (persistentDef) { virBitmapFree(vcpuinfo->cpumask); - vcpuinfo->cpumask =3D pcpumap; + if (clear) { + virBitmapFree(pcpumap); + vcpuinfo->cpumask =3D NULL; + } else { + vcpuinfo->cpumask =3D pcpumap; + } pcpumap =3D NULL; =20 ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, persiste= ntDef); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 93cb020..4bad9e7 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6860,7 +6860,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, unsigned char *cpumap =3D NULL; virBitmapPtr map =3D NULL; =20 - if (cpulist[0] =3D=3D 'r') { + if (cpulist[0] =3D=3D 'r' || STREQ("clear", cpulist)) { if (!(map =3D virBitmapNew(maxcpu))) return NULL; virBitmapSetAll(map); @@ -6938,6 +6938,9 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 + if (STREQ(cpulist, "clear")) + flags |=3D VIR_DOMAIN_VCPU_CLEAR; + /* Pin mode: pinning specified vcpu to specified physical cpus*/ if (!(cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) goto cleanup; diff --git a/tools/virsh.pod b/tools/virsh.pod index 69cc423..caaa230 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2857,6 +2857,7 @@ I is a list of physical CPU numbers. Its syn= tax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2'= ) can also be allowed. The '-' denotes the range and the '^' denotes exclusive. For pinning the I to all physical cpus specify 'r' as a I. +For clearing pinning info, specify 'clear' as a I. If I<--live> is specified, affect a running guest. If I<--config> is specified, affect the next boot of a persistent guest. If I<--current> is specified, affect the current guest state. --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list