From nobody Thu May 2 03:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629204569; cv=none; d=zohomail.com; s=zohoarc; b=QqV5JwgqyMtJcbsAGgCZuCw3eagTI98mWjP1qKom5dxCdxDVvHFKs4ktmRgt2+PQhNnX0W0Wh4EoH8SXnD1+UrTQMyD9SXTAaeeOi/QCcgGKWrJm++xHmkhTm9in5oXL+YS6OrX3sUWomAx68jYIUawYhaEJhH37e2eGljHzbuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629204569; 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=KHGIrS9qhEGsLuRFZpSC7SG03jnskQtOd3G4ZvvbG5E=; b=IdGxBSzjb6uGLlvLbUHTV9MQ4cJJAErKG4jh+mAHhYtccWHLIsLsfJMK0AUgH9HFigMGGuzLm38IIXluLnhg5LGxwiDRq5tr3r00hWmCDF7e0SXVfZPih8lnWcxmfalxRRiXhpekJMU8iV87Td5boSpezTmmG7cmdaKX7x+wHfM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629204569702179.86433739531572; Tue, 17 Aug 2021 05:49:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-MHAnRRlLN8u_3-nDpVHySw-1; Tue, 17 Aug 2021 08:49:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F8C487D543; Tue, 17 Aug 2021 12:49: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 126845D9CA; Tue, 17 Aug 2021 12:49:21 +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 D11C5181A2A5; Tue, 17 Aug 2021 12:49:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17HCka9N022220 for ; Tue, 17 Aug 2021 08:46:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 39D461B400; Tue, 17 Aug 2021 12:46:36 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD4BE6091B for ; Tue, 17 Aug 2021 12:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629204568; 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=KHGIrS9qhEGsLuRFZpSC7SG03jnskQtOd3G4ZvvbG5E=; b=c+NSiqkjWdFgiHWZZCCDeIcTAWQOzhhfpFxdJ5Znm/C4jZUxeqWjDz9pTcbqngv91xva2z laUdAduDY1JMP41ciBsLrSO1Ge0bb/6AVx0GV2caxZ8z37K4etXaWzJIPCZx3u5UEqPwS6 Zp2FCOEwtVLGjAH9kuDgvyhdH0FzI+4= X-MC-Unique: MHAnRRlLN8u_3-nDpVHySw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH] vircgroup: fix build on non-linux systems Date: Tue, 17 Aug 2021 14:46:31 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.14 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: 1629204570864100002 Content-Type: text/plain; charset="utf-8" virCgroupGetInode needs to be in '#ifdef __linux__'. Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/vircgroup.c | 70 ++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 4c9445340e..dc040a4822 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3005,6 +3005,37 @@ virCgroupControllerAvailable(int controller) return virCgroupHasController(cgroup, controller); } =20 + +/** + * virCgroupGetInode: + * + * @cgroup: the cgroup to get inode for + * + * Get the @cgroup inode and return its value to the caller. + * + * Returns inode on success, -1 on error with error message reported. + */ +int +virCgroupGetInode(virCgroup *cgroup) +{ + struct stat st; + int controller =3D virCgroupGetAnyController(cgroup); + g_autofree char *path =3D NULL; + + if (controller < 0) + return -1; + + if (virCgroupPathOfController(cgroup, controller, "", &path) < 0) + return -1; + + if (stat(path, &st) < 0) { + virReportSystemError(errno, _("failed to get stat for '%s'"), path= ); + return -1; + } + + return st.st_ino; +} + #else /* !__linux__ */ =20 bool @@ -3769,6 +3800,14 @@ virCgroupControllerAvailable(int controller G_GNUC_U= NUSED) { return false; } + +int +virCgroupGetInode(virCgroup *cgroup) +{ + virReportSystemError(ENOSYS, "%s", + _("Control groups not supported on this platform"= )); + return -1; +} #endif /* !__linux__ */ =20 =20 @@ -3973,34 +4012,3 @@ virCgroupGetCpuPeriodQuota(virCgroup *cgroup, unsign= ed long long *period, =20 return 0; } - - -/** - * virCgroupGetInode: - * - * @cgroup: the cgroup to get inode for - * - * Get the @cgroup inode and return its value to the caller. - * - * Returns inode on success, -1 on error with error message reported. - */ -int -virCgroupGetInode(virCgroup *cgroup) -{ - struct stat st; - int controller =3D virCgroupGetAnyController(cgroup); - g_autofree char *path =3D NULL; - - if (controller < 0) - return -1; - - if (virCgroupPathOfController(cgroup, controller, "", &path) < 0) - return -1; - - if (stat(path, &st) < 0) { - virReportSystemError(errno, _("failed to get stat for '%s'"), path= ); - return -1; - } - - return st.st_ino; -} --=20 2.31.1