From nobody Sat May 4 10:55:32 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=1614259409; cv=none; d=zohomail.com; s=zohoarc; b=A26qdcy+njJkHE92rIfc7TLaCihqLgvdbk4EkxzF+fm3vkGB+7FLZ0ueyX8fgPa9VR9m84C/kl0/wk/742YlrbpSRPxX2oWhWF+rRoThMaE2pILznJ7SXe3lFz6NlBQpvXUU/ZwdFFoFnot+352O+xdVU/oxFzOXtx7P541urks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614259409; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FtTFcXAPIxUYJ0XLm0EOcILZe1rMY+xoAUI1KAq46UA=; b=I3klh8WXVoYTt9/v5fF7MM4oic64frcWGEn05ezw9ZsasKRPDVrw9g70BUD/IjZbWxXkoAVP730LPfMYVZR1OsYaDHJUi8MZWX5KYuYVqbpl6JLi6tV40mQw9GDYadz6uHcvlqf3NltOnPeC8PkC+ApcL1mRNpufGv22MHybchY= 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) header.from= 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 161425940982595.6579053747073; Thu, 25 Feb 2021 05:23:29 -0800 (PST) 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-35-Sp7PfOhWO2iXfWVWesm8Rw-1; Thu, 25 Feb 2021 08:23:25 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BDCE8107ACFE; Thu, 25 Feb 2021 13:23:19 +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 8A34868890; Thu, 25 Feb 2021 13:23:19 +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 2714518095CE; Thu, 25 Feb 2021 13:23:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11PDNGFa011842 for ; Thu, 25 Feb 2021 08:23:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id B86D260C79; Thu, 25 Feb 2021 13:23:16 +0000 (UTC) Received: from work.redhat.com (ovpn-112-204.ams2.redhat.com [10.36.112.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id B988660C6F; Thu, 25 Feb 2021 13:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614259408; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FtTFcXAPIxUYJ0XLm0EOcILZe1rMY+xoAUI1KAq46UA=; b=WguEhwdE9leqtAklLxJP8V+nqeG1oDIn3hrXk4285aRNnRQZ0tR1A6ZLVhW7ysvNR0QMpP DcoyhyF662naQgtkKveDLhjOhyYGQdSh8e81pEu0q1rW/V5IJOEMrCuk4b4/6Nj7FWvFBa JTDy9APjLN9l5FQuzolcryHOub+JiRc= X-MC-Unique: Sp7PfOhWO2iXfWVWesm8Rw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/1] qemuProcessUpdateGuestCPU: Check host cpu for forbidden features Date: Thu, 25 Feb 2021 14:23:06 +0100 Message-Id: <20210225132306.60023-2-twiederh@redhat.com> In-Reply-To: <20210225132306.60023-1-twiederh@redhat.com> References: <20210225132306.60023-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.16 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) Content-Type: text/plain; charset="utf-8" See https://bugzilla.redhat.com/show_bug.cgi?id=3D1840770 Signed-off-by: Tim Wiederhake Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_process.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index bfa742577f..cecf606312 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6149,6 +6149,33 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, if (virCPUConvertLegacy(hostarch, def->cpu) < 0) return -1; =20 + if (def->cpu->check !=3D VIR_CPU_CHECK_NONE) { + virCPUDefPtr host; + size_t i; + + host =3D virQEMUCapsGetHostModel(qemuCaps, def->virtType, + VIR_QEMU_CAPS_HOST_CPU_FULL); + + for (i =3D 0; i < def->cpu->nfeatures; ++i) { + virCPUFeatureDefPtr feature; + + if (def->cpu->features[i].policy !=3D VIR_CPU_FEATURE_FORBID) + continue; + + feature =3D virCPUDefFindFeature(host, def->cpu->features[i].n= ame); + if (!feature) + continue; + + if (feature->policy =3D=3D VIR_CPU_FEATURE_DISABLE) + continue; + + virReportError(VIR_ERR_CPU_INCOMPATIBLE, + _("Host CPU provides forbidden feature '%s'"), + def->cpu->features[i].name); + return -1; + } + } + /* nothing to update for host-passthrough / maximum */ if (def->cpu->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH && def->cpu->mode !=3D VIR_CPU_MODE_MAXIMUM) { --=20 2.26.2