From nobody Fri May 10 02:11:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1650039123; cv=none; d=zohomail.com; s=zohoarc; b=UVjpdTOeqFY6XoPKkMg28H2b9Wt8X1KgN1uZ9zp+Xk8L26AYLGw3Xw30HNuYDeRHOH53BcVR5/u5DOFPVWyvNzNY2skOHH0J6+q5sd752evmhWBH8uc1U4ia31VW/icSjSIJ+t80eklSU9OOWvsp/Xy0G4sJW+QYlwTpS6j1y+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650039123; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Sezwy1Sgq/cPEd6W1tTJCbZkZ11Pi75pJYcGqTNS/rQ=; b=MtNf49qeeKAV9Nh9CpsaxXElUkec6qrrCDUMTrUVwEF6QF5auWJgjWPfw7mAP10KJv1tshqaBYkVnT03IYHweD46w3yarA46/pRutWmdpqJXnnzirAu/9sbHt7s2sHJkGCN1Jm3VY+fNj1AnyU+62jDbJFgxLNB/N6hIIalCocw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1650039123359303.2954350137305; Fri, 15 Apr 2022 09:12:03 -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-346-1bmjIYggNWOh6KDaZGTmDw-1; Fri, 15 Apr 2022 12:11:58 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB5FD857E3B; Fri, 15 Apr 2022 16:11:42 +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 40F884423B2; Fri, 15 Apr 2022 16:11:39 +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 3BBF519451F0; Fri, 15 Apr 2022 16:11:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1F8CB19451EF for ; Fri, 15 Apr 2022 16:11:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DACA9111CB81; Fri, 15 Apr 2022 16:11:36 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.192.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B8E7111CD42 for ; Fri, 15 Apr 2022 16:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650039122; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Sezwy1Sgq/cPEd6W1tTJCbZkZ11Pi75pJYcGqTNS/rQ=; b=KEmvatmTFJ3CRBTsp/+Mjs+5SFnrbojyKIEIGWTnu+rviiGgmC8iWrh7rZAzosXf9f4TNJ B57WH91p3b92E44eGes4YkMrnUuF6dasDo/Ef8PCFYgf8QPPtVqWAl9QU8J8Zu82W1mhly 2wDjPGoFK8tkNZZHOiVlzn6hkfHui1w= X-MC-Unique: 1bmjIYggNWOh6KDaZGTmDw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH] util: Fix stubs for virProcessGet{Stat,Sched}Info() Date: Fri, 15 Apr 2022 18:11:30 +0200 Message-Id: <20220415161130.545257-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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 2.85 on 10.11.54.9 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1650039126089100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Commit d73852c49962 moved the original QEMU-specific helpers to the utils module, which resulted in build failures on non-Unix platforms due to the unconditional use of Unix-only symbols such as _SC_CLK_TCK. To deal with that situation, commit d7c64453aa0e made the helpers Linux-only and added stubs for other platforms that, when called, would always fail with ENOSYS. However the original helpers had been carefully written so that, while they would only be able to produce useful output on Linux, they would still succeed on the other Unix platforms where we build the QEMU driver. Restore the original behavior so that calling APIs such as virDomainGetInfo() can once again work on FreeBSD and macOS. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/298 Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- Test pipeline: https://gitlab.com/abologna/libvirt/-/pipelines/517776953 src/util/virprocess.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index b559a4257e..36d7df050a 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1875,23 +1875,34 @@ virProcessGetSchedInfo(unsigned long long *cpuWait, =20 #else int -virProcessGetStatInfo(unsigned long long *cpuTime G_GNUC_UNUSED, - int *lastCpu G_GNUC_UNUSED, - long *vm_rss G_GNUC_UNUSED, +virProcessGetStatInfo(unsigned long long *cpuTime, + int *lastCpu, + long *vm_rss, pid_t pid G_GNUC_UNUSED, pid_t tid G_GNUC_UNUSED) { - errno =3D ENOSYS; - return -1; + /* We don't have a way to collect this information on non-Linux + * platforms, so just report neutral values */ + if (cpuTime) + *cpuTime =3D 0; + if (lastCpu) + *lastCpu =3D 0; + if (vm_rss) + *vm_rss =3D 0; + + return 0; } =20 int -virProcessGetSchedInfo(unsigned long long *cpuWait G_GNUC_UNUSED, +virProcessGetSchedInfo(unsigned long long *cpuWait, pid_t pid G_GNUC_UNUSED, pid_t tid G_GNUC_UNUSED) { - virReportSystemError(ENOSYS, "%s", - _("scheduler information is not supported on this= platform")); - return -1; + /* We don't have a way to collect this information on non-Linux + * platforms, so just report neutral values */ + if (cpuWait) + *cpuWait =3D 0; + + return 0; } #endif /* __linux__ */ --=20 2.35.1