From nobody Wed May 8 02:15:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499068708920188.48479740379992; Mon, 3 Jul 2017 00:58:28 -0700 (PDT) Received: from localhost ([::1]:32902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRwFX-0003w3-AR for importer@patchew.org; Mon, 03 Jul 2017 03:58:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRw8O-0007iN-Jx for qemu-devel@nongnu.org; Mon, 03 Jul 2017 03:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dRw8J-0006Cf-LT for qemu-devel@nongnu.org; Mon, 03 Jul 2017 03:51:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52591) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dRw8J-0006Ak-At for qemu-devel@nongnu.org; Mon, 03 Jul 2017 03:50:59 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v637nYit125581 for ; Mon, 3 Jul 2017 03:50:57 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bf1f24sxg-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 03 Jul 2017 03:50:56 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Jul 2017 08:50:54 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 3 Jul 2017 08:50:52 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v637oqCe40173620; Mon, 3 Jul 2017 07:50:52 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 659594C04E; Mon, 3 Jul 2017 08:48:44 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36BD24C046; Mon, 3 Jul 2017 08:48:44 +0100 (BST) Received: from bradbury.boeblingen.de.ibm.com (unknown [9.152.222.92]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 3 Jul 2017 08:48:44 +0100 (BST) From: Viktor Mihajlovski To: qemu-devel@nongnu.org Date: Mon, 3 Jul 2017 09:50:51 +0200 X-Mailer: git-send-email 1.9.1 X-TM-AS-GCONF: 00 x-cbid: 17070307-0020-0000-0000-000003979A88 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070307-0021-0000-0000-0000421AFF52 Message-Id: <1499068251-6164-1-git-send-email-mihajlov@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-03_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1707030130 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2] s390: return unavailable features via query-cpu-definitions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: borntraeger@de.ibm.com, jjherne@linux.vnet.ibm.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The response for query-cpu-definitions didn't include the unavailable-features field, which is used by libvirt to figure out whether a certain cpu model is usable on the host. The unavailable features are now computed by obtaining the host CPU model and comparing it against the known CPU models. The comparison takes into account the generation, the GA level and the feature bitmaps. In the case of a CPU generation/GA level mismatch a feature called "type" is reported to be missing. As a result, the output of virsh domcapabilities would change from something like ... z10EC-base z9EC-base z196.2-base z900-base z990 ... to ... z10EC-base z9EC-base z196.2-base z900-base z990 ... Signed-off-by: Viktor Mihajlovski --- target/s390x/cpu_models.c | 58 +++++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 63903c2..51440ff 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -283,14 +283,50 @@ void s390_cpu_list(FILE *f, fprintf_function print) } } =20 +static S390CPUModel *get_max_cpu_model(Error **errp); + #ifndef CONFIG_USER_ONLY +static void list_add_feat(const char *name, void *opaque); + +static void check_unavailable_features(const S390CPUModel *max_model, + const S390CPUModel *model, + strList **unavailable) +{ + S390FeatBitmap missing; + + /* check general model compatibility */ + if (max_model->def->gen < model->def->gen || + (max_model->def->gen =3D=3D model->def->gen && + max_model->def->ec_ga < model->def->ec_ga)) { + list_add_feat("type", unavailable); + } + + /* detect missing features if any to properly report them */ + bitmap_andnot(missing, model->features, max_model->features, + S390_FEAT_MAX); + if (!bitmap_empty(missing, S390_FEAT_MAX)) { + s390_feat_bitmap_to_ascii(missing, + unavailable, + list_add_feat); + } +} + +struct CpuDefinitionInfoListData { + CpuDefinitionInfoList *list; + Error **errp; +}; + static void create_cpu_model_list(ObjectClass *klass, void *opaque) { - CpuDefinitionInfoList **cpu_list =3D opaque; + struct CpuDefinitionInfoListData *cpu_list_data =3D opaque; + CpuDefinitionInfoList **cpu_list =3D &cpu_list_data->list; CpuDefinitionInfoList *entry; CpuDefinitionInfo *info; char *name =3D g_strdup(object_class_get_name(klass)); S390CPUClass *scc =3D S390_CPU_CLASS(klass); + Object *obj; + S390CPU *sc; + S390CPUModel *scm; =20 /* strip off the -s390-cpu */ g_strrstr(name, "-" TYPE_S390_CPU)[0] =3D 0; @@ -300,21 +336,33 @@ static void create_cpu_model_list(ObjectClass *klass,= void *opaque) info->migration_safe =3D scc->is_migration_safe; info->q_static =3D scc->is_static; info->q_typename =3D g_strdup(object_class_get_name(klass)); - + /* check for unavailable features */ + obj =3D object_new(object_class_get_name(klass)); + sc =3D S390_CPU(obj); + scm =3D get_max_cpu_model(cpu_list_data->errp); + if (scm && sc->model) { + info->has_unavailable_features =3D true; + check_unavailable_features(scm, sc->model, &info->unavailable_feat= ures); + } =20 entry =3D g_malloc0(sizeof(*entry)); entry->value =3D info; entry->next =3D *cpu_list; *cpu_list =3D entry; + object_unref(obj); } =20 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) { - CpuDefinitionInfoList *list =3D NULL; + struct CpuDefinitionInfoListData list_data =3D { + .list =3D NULL, + .errp =3D errp, + }; =20 - object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, &lis= t); + object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, + &list_data); =20 - return list; + return list_data.list; } =20 static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *i= nfo, --=20 1.9.1