From nobody Tue Nov 26 14:45:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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=1573504586; cv=none; d=zoho.com; s=zohoarc; b=KDjCb43yv5aP/EVslwXihy9FSEnyOC4QbqkWqktrgfxBflmYepD5yeDDFagW1JNBDSUqoSOyxRGLzxjxCYxvIVQWw6Sj/6p9/uCUDDgGxyjF3azL1aoWK/ZcNdGfPtvzHsOyyLBn31RefFVtiLZ1ef8cZ2L5fzpQH2HmM3EmlE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573504586; h=Content-Type:Content-Transfer-Encoding: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=2/VeG7FXWJvGnURYibZk8umZpddnfSqRl1wbNVBCaA0=; b=K8sz4z8loqG29PkP1iQK5rU/VzCWuyj+HZSQssCCNMoGE4cf8r8eF0LCypWq0FrY4te/SAXmpNhJ1kWnN/4Ncd+7TZ7NslnLdHhd8G/sclziXfNLiw0Xp2YdF2HJsXxgZEbp2iFjqxhGpGRCVcurxJ9DJj9K6ujUbx5wKLAp4d8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1573504586150453.61866184154826; Mon, 11 Nov 2019 12:36:26 -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-339-CzKnWuMSNfil7OwxgBXKww-1; Mon, 11 Nov 2019 15:36:18 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 656A9800D49; Mon, 11 Nov 2019 20:36:13 +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 2AA3C60902; Mon, 11 Nov 2019 20:36:13 +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 BD9C0180202A; Mon, 11 Nov 2019 20:36:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xABKZhg4011614 for ; Mon, 11 Nov 2019 15:35:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7FB1861F36; Mon, 11 Nov 2019 20:35:43 +0000 (UTC) Received: from orkuz.int.mamuti.net (ovpn-204-85.brq.redhat.com [10.40.204.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5376F5D6D4 for ; Mon, 11 Nov 2019 20:35:40 +0000 (UTC) Received: by orkuz.int.mamuti.net (Postfix, from userid 500) id 69ED02A9ECD; Mon, 11 Nov 2019 21:35:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573504584; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2/VeG7FXWJvGnURYibZk8umZpddnfSqRl1wbNVBCaA0=; b=TsJKYYdt9qq9AS1bg7evOuIAVe4HOqVNJObZSsj9b2SRfDk7kMmh7fBK6LqIzKIgnHlAfk lm/XkkfbEsWrJJX12mJykAvRUGNJKfew0C39s3jnmFdOPzVxMnwzeh+O8ywqng3RekZ2iH cllmX7fRgTebkzwqSx7h2PQ8zZUlpKo= From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 11 Nov 2019 21:35:34 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] qemu: Drop disabled CPU features unknown to QEMU 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.13 X-MC-Unique: CzKnWuMSNfil7OwxgBXKww-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When a CPU definition wants to explicitly disable some features that are unknown to QEMU, we can safely drop them from the definition before starting QEMU. Naturally QEMU won't enable such features implicitly. Signed-off-by: Jiri Denemark --- src/qemu/qemu_process.c | 32 +++++++++++++++++++ ...-Icelake-Server-pconfig.x86_64-latest.args | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ed8666e9d1..06c9eba16c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6068,6 +6068,26 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriverPtr d= river, } =20 =20 +static bool +qemuProcessDropUnknownCPUFeatures(const char *name, + virCPUFeaturePolicy policy, + void *opaque) +{ + const char **features =3D opaque; + + if (policy !=3D VIR_CPU_FEATURE_DISABLE && + policy !=3D VIR_CPU_FEATURE_FORBID) + return true; + + if (virStringListHasString(features, name)) + return true; + + /* Features unknown to QEMU are implicitly disabled, we can just drop = them + * from the definition. */ + return false; +} + + static int qemuProcessUpdateGuestCPU(virDomainDefPtr def, virQEMUCapsPtr qemuCaps, @@ -6133,6 +6153,18 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, &def->os.arch) < 0) return -1; =20 + if (ARCH_IS_X86(def->os.arch)) { + VIR_AUTOSTRINGLIST features =3D NULL; + + if (virQEMUCapsGetCPUFeatures(qemuCaps, def->virtType, false, &fea= tures) < 0) + return -1; + + if (features && + virCPUDefFilterFeatures(def->cpu, qemuProcessDropUnknownCPUFea= tures, + features) < 0) + return -1; + } + return 0; } =20 diff --git a/tests/qemuxml2argvdata/cpu-Icelake-Server-pconfig.x86_64-lates= t.args b/tests/qemuxml2argvdata/cpu-Icelake-Server-pconfig.x86_64-latest.ar= gs index d6f5a0ad98..88d05a482a 100644 --- a/tests/qemuxml2argvdata/cpu-Icelake-Server-pconfig.x86_64-latest.args +++ b/tests/qemuxml2argvdata/cpu-Icelake-Server-pconfig.x86_64-latest.args @@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=3Dnone \ -object secret,id=3DmasterKey0,format=3Draw,\ file=3D/tmp/lib/domain--1-test/master-key.aes \ -machine pc,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ --cpu Icelake-Server,pconfig=3Doff \ +-cpu Icelake-Server \ -m 214 \ -overcommit mem-lock=3Doff \ -smp 1,sockets=3D1,cores=3D1,threads=3D1 \ --=20 2.24.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list