From patchwork Mon Jun 6 20:05:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9159105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2539D60759 for ; Mon, 6 Jun 2016 20:09:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16DEF20072 for ; Mon, 6 Jun 2016 20:09:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BC0224B44; Mon, 6 Jun 2016 20:09:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91EB520072 for ; Mon, 6 Jun 2016 20:09:38 +0000 (UTC) Received: from localhost ([::1]:45395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA0q9-0006Sl-Jc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 16:09:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA0ml-000415-2k for qemu-devel@nongnu.org; Mon, 06 Jun 2016 16:06:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bA0mj-00070N-Tt for qemu-devel@nongnu.org; Mon, 06 Jun 2016 16:06:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA0mj-00070H-Nc for qemu-devel@nongnu.org; Mon, 06 Jun 2016 16:06:05 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FC17C0828C2; Mon, 6 Jun 2016 20:06:05 +0000 (UTC) Received: from localhost (vpn1-7-84.gru2.redhat.com [10.97.7.84]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u56K630N002574; Mon, 6 Jun 2016 16:06:04 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2016 17:05:43 -0300 Message-Id: <1465243543-889-7-git-send-email-ehabkost@redhat.com> In-Reply-To: <1465243543-889-1-git-send-email-ehabkost@redhat.com> References: <1465243543-889-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 06 Jun 2016 20:06:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 6/6] target-i386: Return runnability information on 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: libvir-list@redhat.com, Igor Mammedov , Jiri Denemark , =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fill the "unavailable-features" field on the x86 implementation of query-cpu-definitions. Cc: Jiri Denemark Cc: libvir-list@redhat.com Signed-off-by: Eduardo Habkost --- Changes v1 -> v2: * Updated to the new schema: no @runnable field, and always report @unavailable-features as present --- target-i386/cpu.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index b8519ba..65d1ffc 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2054,6 +2054,45 @@ static void x86_cpu_report_filtered_features(X86CPU *cpu) } } +/* Check for missing features that may prevent the CPU class from + * running using the current machine and accelerator. + */ +static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, + strList **missing_feats) +{ + X86CPU *xc; + FeatureWord w; + + if (xcc->kvm_required && !kvm_enabled()) { + strList *new = g_new0(strList, 1); + new->value = g_strdup("kvm");; + *missing_feats = new; + return; + } + + xc = X86_CPU(object_new(object_class_get_name(OBJECT_CLASS(xcc)))); + if (x86_cpu_filter_features(xc)) { + for (w = 0; w < FEATURE_WORDS; w++) { + FeatureWordInfo *fi = &feature_word_info[w]; + uint32_t filtered = xc->filtered_features[w]; + int i; + for (i = 0; i < 32; i++) { + if (filtered & (1UL << i)) { + char **parts = g_strsplit(fi->feat_names[i], "|", 2); + strList *new = g_new0(strList, 1); + new->value = g_strdup(parts[0]); + feat2prop(new->value); + new->next = *missing_feats; + *missing_feats = new; + g_strfreev(parts); + } + } + } + } + + object_unref(OBJECT(xc)); +} + /* Print all cpuid feature names in featureset */ static void listflags(FILE *f, fprintf_function print, const char **featureset) @@ -2146,6 +2185,8 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) info = g_malloc0(sizeof(*info)); info->name = x86_cpu_class_get_model_name(cc); + x86_cpu_class_check_missing_features(cc, &info->unavailable_features); + info->has_unavailable_features = true; entry = g_malloc0(sizeof(*entry)); entry->value = info;