From nobody Sun Apr 28 22:51:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1582645580; cv=none; d=zohomail.com; s=zohoarc; b=c5ShPDv2+ALFmky225X9OPIIej1Bq1nUw61ARUBycOmO8eXJAR1ej4HMVV0eZQljmqOcbIfq+Gd+UwlPJ2DDQWxNGvVSsNhy+iZmu33biIrRavFN4ACyXxbP8v7UjYSuwCcegImzsiHTMcKIv8LzOPrreTUeGQ9X554SVV+g5FY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582645580; 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=NgKJoeYrouJQKpKSgIxkmeUQy28X3n2EwwToWqmjoUc=; b=R0geZwFTE3TxeInedPSme+87Vuj6VJ6yqXc01TjB5kyau0MdbC6YfzkNB40YPIn96jgAnZRu87D/ALgDBAW+DE/Ixg3EE2hf5AFkRspsY0H5Hiv5fmIhRjOfrgcZvYRqtTsEMfNIBiazErnhqB+olyfaDabCn5djADKf1ZSm28o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1582645580130754.1426276772426; Tue, 25 Feb 2020 07:46:20 -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-181-OvSwcP8LPCeSFyDzwxhZZw-1; Tue, 25 Feb 2020 10:46:13 -0500 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 B41C58017CC; Tue, 25 Feb 2020 15:46:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41F475DA60; Tue, 25 Feb 2020 15:46:04 +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 763518B2D7; Tue, 25 Feb 2020 15:46:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01PFk1tY017440 for ; Tue, 25 Feb 2020 10:46:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 011681001DD8; Tue, 25 Feb 2020 15:46:01 +0000 (UTC) Received: from orkuz.int.mamuti.net (ovpn-204-207.brq.redhat.com [10.40.204.207]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C68F91001DC2 for ; Tue, 25 Feb 2020 15:45:57 +0000 (UTC) Received: by orkuz.int.mamuti.net (Postfix, from userid 500) id 0EBA02A3764; Tue, 25 Feb 2020 16:45:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582645579; 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=NgKJoeYrouJQKpKSgIxkmeUQy28X3n2EwwToWqmjoUc=; b=N+ukIHhsUbzhZ3ClVkqLzAv6MAz79JWMfpV81P9l7IxRodnunLip1uKV94jjXp4qdewK/W yQy2YeMUSQL4nIVo6LpdnPUJXoWfcSWhSbp7N7SiB92Gyr1SZkx0UUgtuJXpraJYixna/l XvmyISOrsfZId9LmkwyT/8HNiPeYbw0= X-MC-Unique: OvSwcP8LPCeSFyDzwxhZZw-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: Do not set default CPU for archs without CPU driver Date: Tue, 25 Feb 2020 16:45:50 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 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" Whenever there is a guest CPU configured in domain XML, we will call some CPU driver APIs to validate the CPU definition and check its compatibility with the hypervisor. Thus domains with guest CPU specification can only be started if the guest architecture is supported by the CPU driver. But we would add a default CPU to any domain as long as QEMU reports it causing failures to start any domain on affected architectures. https://bugzilla.redhat.com/show_bug.cgi?id=3D1805755 Signed-off-by: Jiri Denemark Reviewed-by: Daniel P. Berrang=C3=A9 --- src/cpu/cpu.c | 24 ++++++++++++++++++++++++ src/cpu/cpu.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_domain.c | 3 +++ 4 files changed, 31 insertions(+) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index ae3a0acc10..6d6191fe4e 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -1096,3 +1096,27 @@ virCPUDataAddFeature(virCPUDataPtr cpuData, =20 return driver->dataAddFeature(cpuData, name); } + + +/** + * virCPUArchIsSupported: + * + * @arch: CPU architecture + * + * Returns true if the architecture is supported by any CPU driver. + */ +bool +virCPUArchIsSupported(virArch arch) +{ + size_t i; + size_t j; + + for (i =3D 0; i < G_N_ELEMENTS(drivers); i++) { + for (j =3D 0; j < drivers[i]->narch; j++) { + if (arch =3D=3D drivers[i]->arch[j]) + return true; + } + } + + return false; +} diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 2e8b8923ae..f779d2be17 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -265,6 +265,9 @@ int virCPUDataAddFeature(virCPUDataPtr cpuData, const char *name); =20 +bool +virCPUArchIsSupported(virArch arch); + /* virCPUDataFormat and virCPUDataParse are implemented for unit tests onl= y and * have no real-life usage */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9d172d3bd0..e27b6f29bc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1309,6 +1309,7 @@ virStoragePoolObjVolumeListExport; # cpu/cpu.h cpuDecode; cpuEncode; +virCPUArchIsSupported; virCPUBaseline; virCPUCheckFeature; virCPUCompare; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 446a517df9..7d274a4fa5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4576,6 +4576,9 @@ qemuDomainDefSetDefaultCPU(virDomainDefPtr def, def->cpu->model)) return 0; =20 + if (!virCPUArchIsSupported(def->os.arch)) + return 0; + /* Default CPU model info from QEMU is usable for TCG only except for * x86, s390, and ppc64. */ if (!ARCH_IS_X86(def->os.arch) && --=20 2.25.1