From nobody Sat Feb 7 08:27:26 2026 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 154202963569964.54218395890291; Mon, 12 Nov 2018 05:33:55 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B1683082E4F; Mon, 12 Nov 2018 13:33:53 +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 54423600D6; Mon, 12 Nov 2018 13:33:53 +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 EF1C6181A968; Mon, 12 Nov 2018 13:33:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXiN2019908 for ; Mon, 12 Nov 2018 08:33:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C500101E597; Mon, 12 Nov 2018 13:33:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E9F0101963F; Mon, 12 Nov 2018 13:33:44 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 CFA8F3082A34; Mon, 12 Nov 2018 13:33:42 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:42 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:41 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041281" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:40 +0800 Message-Id: <1542029508-25671-10-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:43 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 09/17] util: Refactor virResctrlAllocSetID to set allocation ID 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 12 Nov 2018 13:33:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Refactor virResctrlAllocSetID. In new code the error of id overwriting is reported promptly. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/util/virresctrl.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 3216abe..4e4831c 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1361,17 +1361,32 @@ virResctrlAllocForeachMemory(virResctrlAllocPtr all= oc, } =20 =20 -int -virResctrlAllocSetID(virResctrlAllocPtr alloc, - const char *id) +static int +virResctrlSetID(char **resctrlid, + const char *id) { if (!id) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Resctrl allocation 'id' cannot be NULL")); + _("New resctrl 'id' cannot be NULL")); + return -1; + } + + if (*resctrlid) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Attempt to overwrite resctrlid=3D'%s' with id=3D= '%s'"), + *resctrlid, id); return -1; } =20 - return VIR_STRDUP(alloc->id, id); + return VIR_STRDUP(*resctrlid, id); +} + + +int +virResctrlAllocSetID(virResctrlAllocPtr alloc, + const char *id) +{ + return virResctrlSetID(&alloc->id, id); } =20 =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list