From nobody Thu Apr 18 12:11:04 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 1641558271744140.94057496037044; Fri, 7 Jan 2022 04:24:31 -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-513-kT6BBsnfMKGhbrPVR758Dg-1; Fri, 07 Jan 2022 07:24:27 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6806081CD1D; Fri, 7 Jan 2022 12:24:21 +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 1DDBA7E2EB; Fri, 7 Jan 2022 12:24:20 +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 01E6F1809CB8; Fri, 7 Jan 2022 12:24:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 207COH5G022747 for ; Fri, 7 Jan 2022 07:24:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id E18EF2180156; Fri, 7 Jan 2022 12:24:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8E4A217B401 for ; Fri, 7 Jan 2022 12:24:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 059163C1462B for ; Fri, 7 Jan 2022 12:24:11 +0000 (UTC) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-4_LPF81FP0-g5Qj_VmPeVQ-1; Fri, 07 Jan 2022 07:24:09 -0500 Received: by mail-pj1-f54.google.com with SMTP id iy13so5068981pjb.5 for ; Fri, 07 Jan 2022 04:24:09 -0800 (PST) Received: from anisinha-lenovo.ba.nuagenetworks.net ([203.212.245.248]) by smtp.googlemail.com with ESMTPSA id k23sm868222pji.3.2022.01.07.04.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 04:24:07 -0800 (PST) X-MC-Unique: kT6BBsnfMKGhbrPVR758Dg-1 X-MC-Unique: 4_LPF81FP0-g5Qj_VmPeVQ-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=i4862oCGoWkr0qzEojYIMT5guadE8Xnk4s27cwiCpYcSUl76PUFbCWhLnsj1UNR4+e 0Qi7rFcp+y9spAmZsgfaCW2FqQHfHW1zf1uAh/SvYfL1UmGCbnS0Al319UXwcPGuZP4O ocPpAZbtEzp6c8jnzo3fx7pDmyXbbd1E2ExGyxKRrVPDT3573hVDAc+hOskG2ncP2nvk 4iZmOf5/bpCrL48SEY5GlPrdprl8xr2pzuSHfevdN36e/HZkVJRzGxrSbsVhffQfBeFF SykU60wVeEmSf7wzo24lX4PczEM8CnmMVivjJvnb36qmUIKHV0ZFWUqPfwnCWQ7KskCU 89RQ== X-Gm-Message-State: AOAM531VHn2MmV7vW8ZwN7EBf8qZVmLbCSsb4mE3wKCZMPa2N0ryRLX7 Svy4GP54oYX/najvKsrtolyKWYWNzNUZ07NH X-Google-Smtp-Source: ABdhPJzITtmIvABIvokHegD1maqjGx51svxPTOF6ctlAKiPPwwBtXkJVufUEx9IBO/jffmGA3N+rJQ== X-Received: by 2002:a17:90b:380c:: with SMTP id mq12mr15678869pjb.142.1641558247951; Fri, 07 Jan 2022 04:24:07 -0800 (PST) From: Ani Sinha To: libvir-list@redhat.com Subject: [PATCH v2] report error when virProcessGetStatInfo() is unable to parse data Date: Fri, 7 Jan 2022 17:53:53 +0530 Message-Id: <20220107122353.234388-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.78 on 10.11.54.6 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.12 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: 1641558273858100001 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