From nobody Wed Nov 27 12:34:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699350651; cv=none; d=zohomail.com; s=zohoarc; b=D9V7au8mOHRIZXM++07Xz3ztFy27IpYbAQBIZDmZrj7z5fSHpV3uoQVrF8EllfEJKKzwZO6Zxdtox75S5CrYVMH8rZJ8U3y4IiZY+3hp0MMmHNWC0ZH4JNlhkuFzWdXuC+fcKAQT8l+OpcQmf0/4444bpwpagmOs1dsO/q1NTRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699350651; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lSp5s88JqE53+iDjE9NMtQoVBixzW55KFUTn7dS46ns=; b=bTUlEdOuaZeH8JQnBBho8RgsCfxbP8+2yJDwMUMQYiGJHHJQUqwsADZzNQZa/m56bRA1PSeK7ZUShbsITfyalfU4DJ9srsMuh7efDDd5lKdPZ6sFmta+6Y2PGO1/VroxCkB+hT7eoHvYM3kPbeMLF5fi5E1ss3fAL6EiSftv+s0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699350651522516.636428563073; Tue, 7 Nov 2023 01:50:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Iid-0005hd-42; Tue, 07 Nov 2023 04:49:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0Iib-0005hD-VF for qemu-devel@nongnu.org; Tue, 07 Nov 2023 04:49:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0Iia-0006Wd-Gk for qemu-devel@nongnu.org; Tue, 07 Nov 2023 04:49:57 -0500 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-622-MDA83HpHPUWHRwrCJxuJyA-1; Tue, 07 Nov 2023 04:49:28 -0500 Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-581e2609a5dso7569267eaf.0 for ; Tue, 07 Nov 2023 01:49:28 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id c5-20020a4ad8c5000000b0057b38a94f38sm1898827oov.12.2023.11.07.01.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699350595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lSp5s88JqE53+iDjE9NMtQoVBixzW55KFUTn7dS46ns=; b=LLm+/0fJhcLZ4TZfGdcPmd00vvu+ddc7gOA5HCn25WAhImNcvrzjMW4aw66q4+SWzoH48k 3GBcg9myMcXy2pi9MY2jUDg+SxYE03b8eUaNihYiJ/ekz5rtEIMl2Fe2tb4+cvEIvMJfHl TllbDzWdpNLKF95IyqemYjagW0Iri78= X-MC-Unique: MDA83HpHPUWHRwrCJxuJyA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699350567; x=1699955367; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lSp5s88JqE53+iDjE9NMtQoVBixzW55KFUTn7dS46ns=; b=PbLC1CbxF6vROmL+1Je88HK9Ys+7Pk7Rvk25x6EuL2OnSe7XgkTUyEDO1+BKr91SBT +qM1HB6K06I7YxqsWod6UFamh3H5HAI4hlu6YP6uuYphZ6TPAEn6/F4XWevzTLTYGScM zvu0dnKVpKSRDXDVCase/jSZ2EtW1mv3ewLWQA6MpzvCUjSUvwmi895mm8Mrj0+qFabe Ri5X6utj0GHUAo7bZdiMV55omyUYteK1gieLqbQlHn25+gfyhah5JSxCqCuEhy7oknsZ sogIgmDILfEnEgG1ikLhnSb7gp5B9DTBgD9RFE1mB3DHatW8echw3PnBWgM00wAJX9T0 qWRA== X-Gm-Message-State: AOJu0YzPOBB2l7JgoakiX6XXhki/0wLF/85WhkU0uJi2U7KFeU47/Lbe ImocxF2a/F1MG1s5bCtS4DYafrwJ6d3rxul5RjYL7QoMQP/sBYxUi6WbQSccMBGPtt3sV0VPGv3 mwAd7IMx7TWapXXefmRVGrpaX/DySZ0oR4sRDzSqPJihYcwRBh80cyhHicx38Sh9VnYtF X-Received: by 2002:a05:6820:1a08:b0:56c:d297:164c with SMTP id bq8-20020a0568201a0800b0056cd297164cmr36842215oob.4.1699350567799; Tue, 07 Nov 2023 01:49:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IENaIS9ovKdllFytI+yEPFYxBqgWKM5cVBIIzHYrq7obj2WNYQm5/VN3ExxF82c9tTYleQHfA== X-Received: by 2002:a05:6820:1a08:b0:56c:d297:164c with SMTP id bq8-20020a0568201a0800b0056cd297164cmr36842201oob.4.1699350567500; Tue, 07 Nov 2023 01:49:27 -0800 (PST) Date: Tue, 7 Nov 2023 04:49:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Paolo Bonzini , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Thomas Huth , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: [PATCH RFC 1/2] osdep: add getloadavg Message-ID: <1e64d2a47b63ba7d7f49a23c02c2be91ff5c15fe.1699350487.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699350652420100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" getloadavg is supported on Linux, BSDs, Solaris. Following man page: RETURN VALUE If the load average was unobtainable, -1 is returned; otherwise, the number of samples actually retrieved is returned. accordingly, make stub for systems which don't support this function return= -1 for consistency. Signed-off-by: Michael S. Tsirkin --- include/qemu/osdep.h | 10 ++++++++++ meson.build | 1 + 2 files changed, 11 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 475a1c62ff..d30ba73eda 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -779,6 +779,16 @@ static inline int platform_does_not_support_system(con= st char *command) } #endif /* !HAVE_SYSTEM_FUNCTION */ =20 +/** + * If the load average was unobtainable, -1 is returned + */ +#ifndef HAVE_GETLOADAVG_FUNCTION +static inline int getloadavg(double loadavg[], int nelem) +{ + return -1; +} +#endif /* !HAVE_GETLOADAVG_FUNCTION */ + #ifdef __cplusplus } #endif diff --git a/meson.build b/meson.build index dcef8b1e79..7f333cb80e 100644 --- a/meson.build +++ b/meson.build @@ -2254,6 +2254,7 @@ config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR'= , glib_has_gslice) config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependenci= es: util)) config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul')) config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', pre= fix: '#include ')) +config_host_data.set('HAVE_GETLOADAVG_FUNCTION', cc.has_function('getloada= vg', prefix: '#include ')) if rbd.found() config_host_data.set('HAVE_RBD_NAMESPACE_EXISTS', cc.has_function('rbd_namespace_exists', --=20 MST