From nobody Tue May 7 06:32:52 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566305555; cv=none; d=zoho.com; s=zohoarc; b=BPjhslNM/W1b/CcUOVt45mNbIxFwo5Xy7PkWfkcpgY9Qrfobh7EUBVV7sg8Sj/yCwRnpacQK/TdPcyafrP5qy7DeIJte5awTpiTfLuoyLwKzO5aWc+U+QMe15HtG8Rwd1ndIAY8Z6uAs0IWFQEZUOzqRbifxUopBns/7AOmGgCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566305555; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=gU734YnBUAyV//C2HEk2f0XwwFPohygQSEWCOC7LjVg=; b=glhMVWdPfroplqHlqqR8lwZ+/dmjiTjfZt7SCgk/N5hFLEgbof05FDiA2ADWU15GgK8goCCyBM+nGH9jkunUCJO2LjzwaVfGBxc1c9l2lZxlVRGV4x1nkRCU9pLRBJ+1rxbdiEYksd8K23IyN0dHbglzYFPzdo4nzL6csLi0V6g= ARC-Authentication-Results: i=1; mx.zoho.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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1566305555864193.52852598767493; Tue, 20 Aug 2019 05:52:35 -0700 (PDT) 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 867CD300BEAE; Tue, 20 Aug 2019 12:52:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D9771DE; Tue, 20 Aug 2019 12:52:34 +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 1E5DB2551C; Tue, 20 Aug 2019 12:52:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7KCpT7L022839 for ; Tue, 20 Aug 2019 08:51:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 15A5D1F8; Tue, 20 Aug 2019 12:51:29 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 938783DA5 for ; Tue, 20 Aug 2019 12:51:27 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 20 Aug 2019 14:51:22 +0200 Message-Id: <654c7b956eceadc1f59610232890a6454ced34f7.1566305450.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] vircgroupv2: fix parsing multiple values in single file 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: , 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.45]); Tue, 20 Aug 2019 12:52:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Our virStrToLong* helpers converts string to integers where it wraps strtol standard function. After the conversion happens and there are some remaining invalid characters our helpers will fail if the second argument is NULL. We need to pass pointer to string in cases where there are multiple values in a single file. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1741825 Signed-off-by: Pavel Hrdina Reviewed-by: Jiri Denemark --- src/util/vircgroupv2.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index e36c36685b..59ef2e6397 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -673,7 +673,7 @@ virCgroupV2GetBlkioWeight(virCgroupPtr group, tmp =3D value; } =20 - if (virStrToLong_ui(tmp, NULL, 10, weight) < 0) { + if (virStrToLong_ui(tmp, &tmp, 10, weight) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse '%s' as an integer"), tmp); @@ -869,7 +869,7 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group, =20 if (!str) { *weight =3D 0; - } else if (virStrToLong_ui(str, NULL, 10, weight) < 0) { + } else if (virStrToLong_ui(str, &str, 10, weight) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse '%s' as an integer"), str); @@ -939,7 +939,7 @@ virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group, =20 if (STREQLEN(tmp, "max", 3)) { *riops =3D 0; - } else if (virStrToLong_ui(tmp, NULL, 10, riops) < 0) { + } else if (virStrToLong_ui(tmp, &tmp, 10, riops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse '%s' as an integer"), str); @@ -1010,7 +1010,7 @@ virCgroupV2GetBlkioDeviceWriteIops(virCgroupPtr group, =20 if (STREQLEN(tmp, "max", 3)) { *wiops =3D 0; - } else if (virStrToLong_ui(tmp, NULL, 10, wiops) < 0) { + } else if (virStrToLong_ui(tmp, &tmp, 10, wiops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse '%s' as an integer"), str); @@ -1081,7 +1081,7 @@ virCgroupV2GetBlkioDeviceReadBps(virCgroupPtr group, =20 if (STREQLEN(tmp, "max", 3)) { *rbps =3D 0; - } else if (virStrToLong_ull(tmp, NULL, 10, rbps) < 0) { + } else if (virStrToLong_ull(tmp, &tmp, 10, rbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse '%s' as an integer"), str); @@ -1152,7 +1152,7 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group, =20 if (STREQLEN(tmp, "max", 3)) { *wbps =3D 0; - } else if (virStrToLong_ull(tmp, NULL, 10, wbps) < 0) { + } else if (virStrToLong_ull(tmp, &tmp, 10, wbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse '%s' as an integer"), str); @@ -1535,7 +1535,7 @@ virCgroupV2GetCpuCfsPeriod(virCgroupPtr group, return -1; } =20 - if (virStrToLong_ull(tmp, NULL, 10, cfs_period) < 0) { + if (virStrToLong_ull(tmp, &tmp, 10, cfs_period) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to parse value '%s' from cpu.max."), str); return -1; @@ -1585,7 +1585,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group, if (STREQLEN(str, "max", 3)) *cfs_quota =3D ULLONG_MAX / 1000; =20 - if (virStrToLong_ll(str, NULL, 10, cfs_quota) < 0) { + if (virStrToLong_ll(str, &str, 10, cfs_quota) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to parse value '%s' from cpu.max."), str); return -1; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 06:32:52 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566305506; cv=none; d=zoho.com; s=zohoarc; b=PIbSRlSjQJLOEt6S5d+1XPIDR91W2FFIwbrDGwh/48A1fPFTjdngx2JmewbCj2ssn/X6n7MvuGkIqOhgRUJLwkdembaowb9inbP0+Ui860tkKDV6brYtHk+572RNQxjtOAODQ5rBNipbE6pj/kZIXoEj1CnaR0cTOOM6fHzgrhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566305506; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=d4fmUDXs2h3S9IH9rCTCNDcIvOTLBMnUP64yJZSXbfI=; b=oKcqk7Mv6FkmDmI+7wvHj5UAyqAGp6tlADXTdahEYldm2GAKptz4zqH4JZwCnzkFzSO0p1+t5SFCm9eWJxr56PtD/RzDTwtuBHeWQo9A7BFSMUsKD45/taxgDJ0VvMVnyNUlTmu8a3kJnTaTFfUbcC2LsVj7WXSR7rZn0hXGWOU= ARC-Authentication-Results: i=1; mx.zoho.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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1566305506529144.49276904249814; Tue, 20 Aug 2019 05:51:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F07918C8910; Tue, 20 Aug 2019 12:51:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D55939C3; Tue, 20 Aug 2019 12:51:43 +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 CA2D12551C; Tue, 20 Aug 2019 12:51:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7KCpTv4022846 for ; Tue, 20 Aug 2019 08:51:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id DA0603DA5; Tue, 20 Aug 2019 12:51:29 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 631721F8 for ; Tue, 20 Aug 2019 12:51:29 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 20 Aug 2019 14:51:23 +0200 Message-Id: <57263ddd6493d4452d16e07daec65448fb21f436.1566305450.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] vircgroupv2: fix virCgroupV2GetCpuCfsQuota for "max" value 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Tue, 20 Aug 2019 12:51:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If the first value in cpu.max is "max" return from function. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1741837 Signed-off-by: Pavel Hrdina Reviewed-by: Jiri Denemark --- src/util/vircgroupv2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 59ef2e6397..c62ee0d933 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -1582,8 +1582,10 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group, return -1; } =20 - if (STREQLEN(str, "max", 3)) + if (STREQLEN(str, "max", 3)) { *cfs_quota =3D ULLONG_MAX / 1000; + return 0; + } =20 if (virStrToLong_ll(str, &str, 10, cfs_quota) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list