From nobody Mon Feb 9 23:15:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524266017537600.2956723827716; Fri, 20 Apr 2018 16:13:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB9EEC047B62; Fri, 20 Apr 2018 23:13:35 +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 7B14D6017F; Fri, 20 Apr 2018 23:13:35 +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 E5B1E180596F; Fri, 20 Apr 2018 23:13:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3KND356008857 for ; Fri, 20 Apr 2018 19:13:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D60B10B0F2B; Fri, 20 Apr 2018 23:13:03 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6C8510B0F25; Fri, 20 Apr 2018 23:13:01 +0000 (UTC) From: Laszlo Ersek To: qemu-devel@nongnu.org, libvir-list@redhat.com Date: Sat, 21 Apr 2018 01:12:45 +0200 Message-Id: <20180420231246.23130-3-lersek@redhat.com> In-Reply-To: <20180420231246.23130-1-lersek@redhat.com> References: <20180420231246.23130-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Thomas Huth , Gerd Hoffmann , Paolo Bonzini , David Gibson Subject: [libvirt] [qemu RFC v3 2/3] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 20 Apr 2018 23:13:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that we have @SysEmuTarget, it makes sense to restict @TargetInfo.@arch to valid sysemu targets at the schema level. Cc: "Daniel P. Berrange" Cc: David Gibson Cc: Eric Blake Cc: Gerd Hoffmann Cc: Kashyap Chamarthy Cc: Markus Armbruster Cc: Paolo Bonzini Cc: Thomas Huth Signed-off-by: Laszlo Ersek --- Notes: RFCv3: =20 - The patch is new in this version. [Markus] qapi/misc.json | 6 ++++-- arch_init.c | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index 5636f4a14997..3b4fbc534089 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -5,6 +5,8 @@ # =3D Miscellanea ## =20 +{ 'include': 'common.json' } + ## # @qmp_capabilities: # @@ -2449,12 +2451,12 @@ # # Information describing the QEMU target. # -# @arch: the target architecture (eg "x86_64", "i386", etc) +# @arch: the target architecture # # Since: 1.2.0 ## { 'struct': 'TargetInfo', - 'data': { 'arch': 'str' } } + 'data': { 'arch': 'SysEmuTarget' } } =20 ## # @query-target: diff --git a/arch_init.c b/arch_init.c index 6ee07478bd11..4367f30291f8 100644 --- a/arch_init.c +++ b/arch_init.c @@ -29,6 +29,7 @@ #include "hw/pci/pci.h" #include "hw/audio/soundhw.h" #include "qapi/qapi-commands-misc.h" +#include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "hw/acpi/acpi.h" @@ -111,8 +112,23 @@ int xen_available(void) TargetInfo *qmp_query_target(Error **errp) { TargetInfo *info =3D g_malloc0(sizeof(*info)); + Error *local_err =3D NULL; =20 - info->arch =3D g_strdup(TARGET_NAME); + /* + * The fallback enum value is irrelevant here (TARGET_NAME is a + * macro and can never be NULL), so simply pass zero. Also, the + * lookup should never fail -- if it fails, then @SysEmuTarget needs + * extending. Catch that with an assertion, but also handle it + * gracefully, in case someone adventurous disables assertions. + */ + info->arch =3D qapi_enum_parse(&SysEmuTarget_lookup, TARGET_NAME, 0, + &local_err); + g_assert(!local_err); + if (local_err) { + error_propagate(errp, local_err); + qapi_free_TargetInfo(info); + return NULL; + } =20 return info; } --=20 2.14.1.3.gb7cf6e02401b -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list