From nobody Sun Feb 8 18:32:42 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686556557; cv=none; d=zohomail.com; s=zohoarc; b=T8+1hWWds0wOF/yHMcVrWUdbqTBZIWYsdSWkEC3DWD+8oxn4nEDDc1CYkqnnkHGECL/Mof4Kxr2GHQ8XSWm/uvZ1/E+5MleAz5Q/lujsH6Td07ntWJYD8AulH+DymudOIpIPfyDKslrHewYLfHtdpF7wq+AG1DAQTrGQz/Y9ZPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686556557; 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; bh=PuakEZx2OVhWq6FJ49FvD5B9uiepHVSh0PL+4nhu/7w=; b=S/Zd5QAJpFRDycvwSgwuXr3sQlex+1M1KY5NYOzj1eW2KjHT4IObSvEF5dJN8d8T2WK9nk9K2R6YuqQyLIZ/a9hLUb0Ww/ogYGRjIeSIHje+1NW24g4ex35n4mCTFpdetiPtqF3NTMzTNTOcXSbwm8JcST7xoyKJW+3RF5Lik7c= 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=pass header.from= (p=none dis=none) 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 1686556557243797.6785530686645; Mon, 12 Jun 2023 00:55:57 -0700 (PDT) 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-39--YA5M3WuNdiDnjskgvu02w-1; Mon, 12 Jun 2023 03:55:52 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6EC9805B2E; Mon, 12 Jun 2023 07:55:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE68D202F344; Mon, 12 Jun 2023 07:55:48 +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 E93DB19466DF; Mon, 12 Jun 2023 07:55:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 802CA19465A3 for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3CF962166B26; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 356232166B25 for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 167AE801585 for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-8wPSZLOuMOaqHx7fGiqzmw-1; Mon, 12 Jun 2023 03:55:42 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-97455ea1c14so365551966b.2 for ; Mon, 12 Jun 2023 00:55:42 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id kt5-20020a170906aac500b00978868cb24csm4920863ejb.144.2023.06.12.00.55.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 00:55:40 -0700 (PDT) Received: from wheatley.. (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 6E5D911B85752 for ; Mon, 12 Jun 2023 09:55:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686556556; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=PuakEZx2OVhWq6FJ49FvD5B9uiepHVSh0PL+4nhu/7w=; b=V20DhcMJLP+waqO9KQQ/7C3uqfTQPNI5F+1RePsnb708AluYI0eEhkCVONOTSe9z6IqJ0N 5NLWlUAklZqfJdpkS9L4XG2gzhnq3oZNGShEibUgFcZm2CyAOi1RNd850zVV7LL6tanCrk HYM3VRFfbOcO4p89y94LhXUByDcinWE= X-MC-Unique: -YA5M3WuNdiDnjskgvu02w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 8wPSZLOuMOaqHx7fGiqzmw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686556541; x=1689148541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PuakEZx2OVhWq6FJ49FvD5B9uiepHVSh0PL+4nhu/7w=; b=K/w4q7CB90SRXX2bSH2AATqNPEBNA/hXhTlrnMbZk85LfG1Evk5iSFOm4X2wFEg+fF lwI7jvqpDqrPEOHJwl4VsOK1a+WXCxqZyyMBc3IEp9F4B0vrJ9eYa0gEO0IuilyGYr6K DI0iDz63MNE0VbZRPhSeHos09NuRn7thDGvSiAdh/xD1y8HwbTf2YCaof1/cawpUcUeJ 3TkSs/KjjaIiO2/svVCYeZt+H72szjhog8fNT2tNLTgPIi0EuB7XqU+LgcWzSpnlqnjr JvWM0jgtSbpi3uLQSndHkbXV04ldmlkjhq50e4+YlRAvZIlwbk1FAgclTiGi/IeDLgHT pcMg== X-Gm-Message-State: AC+VfDwo9wBU1dB1Sd0/9HFUk845QzS7l5VrhMUYrEzFl5lwjIjM1Kwk +Nk1//yydfpVWDzjVvV52CNwVd4L+Zs3szzXZt3kzXGO+V2ZPVlN3HYjNi8WoZ6AytLiZC/C42A 0iGnrTtCZNL537qpz3rs1A3VI6pB6a/gmolSxpWC/NlYPWulaRiFREMYZlNQP6PGbWQuVwDezHP jYB2pXuQ== X-Received: by 2002:a17:907:6288:b0:974:1c90:4c02 with SMTP id nd8-20020a170907628800b009741c904c02mr7309370ejc.5.1686556541571; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QxwsmcpBi1cFDwKmMOzcK0NcJVAlNdSsngMcd+3D8PO0XpDF+GSkKYY/YXE4Wzx6Duuez1w== X-Received: by 2002:a17:907:6288:b0:974:1c90:4c02 with SMTP id nd8-20020a170907628800b009741c904c02mr7309358ejc.5.1686556541229; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 1/4] util: Parse RSS into ullp Date: Mon, 12 Jun 2023 09:55:34 +0200 Message-ID: <526bf8cbed388b10f355f2abe2e1be851d1365de.1686556413.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1686556558694100003 Content-Type: text/plain; charset="utf-8"; x-default="true" It is used to fill an unsigned long long anyway and if it is negative than there is really an issue somewhere. Signed-off-by: Martin Kletzander --- src/qemu/qemu_driver.c | 2 +- src/util/virprocess.c | 17 ++++++++++------- src/util/virprocess.h | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 56f4cd619715..857fbfb7992c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9937,7 +9937,7 @@ qemuDomainMemoryStatsInternal(virDomainObj *vm, =20 { int ret =3D -1; - long rss; + unsigned long long rss; =20 if (virDomainObjCheckActive(vm) < 0) return -1; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index d12fe4f7171f..a9f249413ce1 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -23,6 +23,7 @@ #include =20 #include +#include #include #ifndef WIN32 # include @@ -1739,7 +1740,7 @@ virProcessGetStatInfo(unsigned long long *cpuTime, unsigned long long *userTime, unsigned long long *sysTime, int *lastCpu, - long *vm_rss, + unsigned long long *vm_rss, pid_t pid, pid_t tid) { @@ -1748,14 +1749,16 @@ virProcessGetStatInfo(unsigned long long *cpuTime, unsigned long long stime =3D 0; const unsigned long long jiff2nsec =3D 1000ull * 1000ull * 1000ull / (unsigned long long) sysconf(_SC_= CLK_TCK); - long rss =3D 0; + long pagesize =3D virGetSystemPageSizeKB(); + unsigned long long rss =3D 0; int cpu =3D 0; =20 if (!proc_stat || virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_UTIME], NULL, 10, &ut= ime) < 0 || virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_STIME], NULL, 10, &st= ime) < 0 || - virStrToLong_l(proc_stat[VIR_PROCESS_STAT_RSS], NULL, 10, &rss) < = 0 || - virStrToLong_i(proc_stat[VIR_PROCESS_STAT_PROCESSOR], NULL, 10, &c= pu) < 0) { + virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_RSS], NULL, 10, &rss)= < 0 || + virStrToLong_i(proc_stat[VIR_PROCESS_STAT_PROCESSOR], NULL, 10, &c= pu) < 0 || + rss > ULLONG_MAX / pagesize) { VIR_WARN("cannot parse process status data"); } =20 @@ -1771,10 +1774,10 @@ virProcessGetStatInfo(unsigned long long *cpuTime, *lastCpu =3D cpu; =20 if (vm_rss) - *vm_rss =3D rss * virGetSystemPageSizeKB(); + *vm_rss =3D rss * pagesize; =20 =20 - VIR_DEBUG("Got status for %d/%d user=3D%llu sys=3D%llu cpu=3D%d rss=3D= %ld", + VIR_DEBUG("Got status for %d/%d user=3D%llu sys=3D%llu cpu=3D%d rss=3D= %lld", (int) pid, tid, utime, stime, cpu, rss); =20 return 0; @@ -1851,7 +1854,7 @@ virProcessGetStatInfo(unsigned long long *cpuTime, unsigned long long *userTime, unsigned long long *sysTime, int *lastCpu, - long *vm_rss, + unsigned long long *vm_rss, pid_t pid G_GNUC_UNUSED, pid_t tid G_GNUC_UNUSED) { diff --git a/src/util/virprocess.h b/src/util/virprocess.h index 4e216788389f..c18f87e80ec9 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -198,7 +198,7 @@ int virProcessGetStatInfo(unsigned long long *cpuTime, unsigned long long *userTime, unsigned long long *sysTime, int *lastCpu, - long *vm_rss, + unsigned long long *vm_rss, pid_t pid, pid_t tid); int virProcessGetSchedInfo(unsigned long long *cpuWait, --=20 2.41.0