From nobody Thu Apr 18 05:03:26 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com 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 1641872623772721.926443765015; Mon, 10 Jan 2022 19:43:43 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-jSN-SdPwPSi0S1vio5Z73w-1; Mon, 10 Jan 2022 22:43:34 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D647102C84E; Tue, 11 Jan 2022 03:43:28 +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 AAC605F4E1; Tue, 11 Jan 2022 03:43:26 +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 912841809CB8; Tue, 11 Jan 2022 03:43:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20B3hLtH006239 for ; Mon, 10 Jan 2022 22:43:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 78798C0809B; Tue, 11 Jan 2022 03:43:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73BBFC08090 for ; Tue, 11 Jan 2022 03:43:21 +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 58FF3811E76 for ; Tue, 11 Jan 2022 03:43:21 +0000 (UTC) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-459-hNG59SrlOhGLPghujTtzOg-1; Mon, 10 Jan 2022 22:43:19 -0500 Received: by mail-pl1-f175.google.com with SMTP id l15so15145711pls.7 for ; Mon, 10 Jan 2022 19:43:18 -0800 (PST) Received: from anisinha-lenovo.ba.nuagenetworks.net ([115.96.198.102]) by smtp.googlemail.com with ESMTPSA id j16sm7803464pfu.216.2022.01.10.19.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jan 2022 19:43:17 -0800 (PST) X-MC-Unique: jSN-SdPwPSi0S1vio5Z73w-1 X-MC-Unique: hNG59SrlOhGLPghujTtzOg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=00MjCynoqsuIHJPNyARbzaWq0qq3XO6G26mEMlL3IoU=; b=NVoOjYynM0bXbQIBdWbTl+CDUB2oET+840qtJXh8RG6dMq9JfWO5ZTGJgaRLW7uOJ1 bMUIovzgQ7mrl/vzQXaLWkYMzeSH8j3Gjqm/GfD0Z0gi0wORo/KTMGk3uZPQPmihyZea AA/fJFr2WTnkyK6TGAoFZwbnH1SDUHtMsKvUSbsFbb0GviWnA7DLnbyZvUOEeXwJryx+ 4XbVxOO73teY5nFqqPOR/9LwLTZZBRn1iKW1Z6RJR8qV0meD5mZq9N2fiUEgkppAmp7S 9CqrBkgnBYWWoZn23VI7zdC+gWjpHeDRUtic+vRVbdijFQeO7r7UdKK9FWv102DM+nOU 5iYg== X-Gm-Message-State: AOAM5337fEOpj5m92kEXyZoPtNRklDIkCgIjXalyzzyFDoDHPzPlwaPO f5VGSCRgLI9vg2uDYQBOHxzEGFgh5NNoJWQv X-Google-Smtp-Source: ABdhPJyl4xcFqfK0m2uiMyxqhQX+WWbGd0QMQrp0eVTtHehML0XrtpoNfbbPhPYUMKv7lmDT83rxzg== X-Received: by 2002:a17:90a:de01:: with SMTP id m1mr1042566pjv.215.1641872597413; Mon, 10 Jan 2022 19:43:17 -0800 (PST) From: Ani Sinha To: libvir-list@redhat.com Subject: [PATCH v2] report error when virProcessGetStatInfo() is unable to parse data Date: Tue, 11 Jan 2022 09:12:26 +0530 Message-Id: <20220111034226.365320-1-ani@anisinha.ca> MIME-Version: 1.0 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 2.85 on 10.11.54.8 X-loop: libvir-list@redhat.com Cc: Ani Sinha 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1641872624124100001 Content-Type: text/plain; charset="utf-8" Currently virProcessGetStatInfo() always returns success and only logs error when it is unable to parse the data. Make this function actually report the error and return a negative value in this error scenario. Fix the callers so that they do not override the error generated. Signed-off-by: Ani Sinha --- src/ch/ch_driver.c | 2 -- src/qemu/qemu_driver.c | 7 +------ src/util/virprocess.c | 6 +++++- 3 files changed, 6 insertions(+), 9 deletions(-) changelog: v2: fixed the callers diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 53e0872207..3cbc668489 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -1073,8 +1073,6 @@ chDomainHelperGetVcpus(virDomainObj *vm, if (virProcessGetStatInfo(&vcpuinfo->cpuTime, &vcpuinfo->cpu, NULL, vm->pid, vcpupid) < 0) { - virReportSystemError(errno, "%s", - _("cannot get vCPU placement & pCPU = time")); return -1; } } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4974450333..015ffb2ce7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1359,8 +1359,6 @@ qemuDomainHelperGetVcpus(virDomainObj *vm, if (virProcessGetStatInfo(&vcpuinfo->cpuTime, &vcpuinfo->cpu, NULL, vm->pid, vcpupid) < 0) { - virReportSystemError(errno, "%s", - _("cannot get vCPU placement & pCPU t= ime")); return -1; } } @@ -2521,8 +2519,6 @@ qemuDomainGetInfo(virDomainPtr dom, if (virDomainObjIsActive(vm)) { if (virProcessGetStatInfo(&(info->cpuTime), NULL, NULL, vm->pid, 0) < 0) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("cannot read cputime for domain")); goto cleanup; } } @@ -10530,8 +10526,7 @@ qemuDomainMemoryStatsInternal(virQEMUDriver *driver, } =20 if (virProcessGetStatInfo(NULL, NULL, &rss, vm->pid, 0) < 0) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("cannot get RSS for domain")); + return -1; } else { stats[ret].tag =3D VIR_DOMAIN_MEMORY_STAT_RSS; stats[ret].val =3D rss; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index c74bd16fe6..b9f498d5d8 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1783,7 +1783,11 @@ virProcessGetStatInfo(unsigned long long *cpuTime, virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_STIME], NULL, 10, &sy= stime) < 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) { - VIR_WARN("cannot parse process status data"); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse process status data for pid '%d/%d'= "), + (int) pid, (int) tid); + + return -1; } =20 /* We got jiffies --=20 2.25.1