From nobody Fri May 17 06:43:20 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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=1661264254; cv=none; d=zohomail.com; s=zohoarc; b=LNVSDnvU5VhpG9D8mbZDlnQagMBR77VW1rmMCDu0cwPVecSHPgY/NPRfYpFvPbYuyzkAGLWXwAYLw/FEWnGJQr8zdmAtrSo4uGBpxLBEqnzEBufohEBW8FxZvNj3NtouRTw8kZOn9Wdz7Afn4Z/Yu+kKpbdBaZIXcvIopV1y8Lk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661264254; 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=mJBV3MKZ3LjV8F0RXKglvnSgv70qLJ4kF0eYpOW044Q=; b=McCoBfmTFINqO4QYn2uWDGYS7h5vWILGH0oG9rufsOEhvTiG32QYsaQqKtYN8uYPWsj2pApoRjqvfn4Upe1UW6JRnQj1NyqauefyvWJ7J38BRVHGNGw7EKgxwV7qMTQngZ4e/zP7EaykM8r9OOARcsK5jl8EWMFnLOE+IJfltqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1661264254147600.0480283575889; Tue, 23 Aug 2022 07:17:34 -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-659-NlJFpJIlPYmExaIx37_ywQ-1; Tue, 23 Aug 2022 10:17:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96A0881DA56; Tue, 23 Aug 2022 14:15:58 +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 177EC2026D64; Tue, 23 Aug 2022 14:15:58 +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 24D6A1946A47; Tue, 23 Aug 2022 14:15:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7F8691946A40 for ; Tue, 23 Aug 2022 14:15:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 54E9618EA8; Tue, 23 Aug 2022 14:15:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9B53945D9 for ; Tue, 23 Aug 2022 14:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661264253; 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=mJBV3MKZ3LjV8F0RXKglvnSgv70qLJ4kF0eYpOW044Q=; b=JJIrf9zyxIFV168Y07qhuBTImQVtyqufn69Ib6CHC4V4nOgRwWbmpQUI2KawsOkB/sVqMa Oaioy9enGstervUbc2TNZ9QIHNanmQEFI1fcHa/uOhuQHketzC45sfsb/uNkwIdonLdFXb OD0C5PrN1w9fXu6FR4t7hEq6rGux0lc= X-MC-Unique: NlJFpJIlPYmExaIx37_ywQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] virhostcpu: Fix build with clang and newest kernel headers Date: Tue, 23 Aug 2022 16:15:54 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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.78 on 10.11.54.4 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: 1661264254784100001 Content-Type: text/plain; charset="utf-8" The most recent environment e.g. present in our Fedora Rawhide builds fail to build the tree with clang with the following error: ../src/util/virhostcpu.c:1291:25: error: field 'header' with variable sized= type 'struct kvm_msrs' not at the end of a struct or class is a GNU extens= ion [-Werror,-Wgnu-variable-sized-type-not-at-end] struct kvm_msrs header; ^ The problem seems to be that clang doesn't like the new way the 'entries' field in struct kvm_msrs is declared. To work around the issue we can simply allocate the variable dynamically and use the 'entries' member as it was intended to to access the members. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/util/virhostcpu.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 54d0166b85..c1e8dc8078 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1287,25 +1287,22 @@ virHostCPUGetMSRFromKVM(unsigned long index, uint64_t *result) { VIR_AUTOCLOSE fd =3D -1; - struct { - struct kvm_msrs header; - struct kvm_msr_entry entry; - } msr =3D { - .header =3D { .nmsrs =3D 1 }, - .entry =3D { .index =3D index }, - }; + g_autofree struct kvm_msrs *msr =3D g_malloc0(sizeof(struct kvm_msrs) + + sizeof(struct kvm_msr_entr= y)); + msr->nmsrs =3D 1; + msr->entries[0].index =3D index; if ((fd =3D open(KVM_DEVICE, O_RDONLY)) < 0) { virReportSystemError(errno, _("Unable to open %s"), KVM_DEVICE); return -1; } - if (ioctl(fd, KVM_GET_MSRS, &msr) < 0) { + if (ioctl(fd, KVM_GET_MSRS, msr) < 0) { VIR_DEBUG("Cannot get MSR 0x%lx from KVM", index); return 1; } - *result =3D msr.entry.data; + *result =3D msr->entries[0].data; return 0; } --=20 2.37.1