From patchwork Fri Apr 19 06:13:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1087946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44lm0Q3FJsz9s3l for ; Fri, 19 Apr 2019 16:14:46 +1000 (AEST) Received: from localhost ([127.0.0.1]:51822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMnM-00056h-8S for incoming@patchwork.ozlabs.org; Fri, 19 Apr 2019 02:14:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMma-00055c-M8 for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:13:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHMmZ-0004kP-7s for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:13:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHMmY-0004jx-WA for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:13:55 -0400 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 3ED9E368E6; Fri, 19 Apr 2019 06:13:54 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC7B9600C1; Fri, 19 Apr 2019 06:13:53 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2019 03:13:33 -0300 Message-Id: <20190419061349.17094-2-ehabkost@redhat.com> In-Reply-To: <20190419061349.17094-1-ehabkost@redhat.com> References: <20190419061349.17094-1-ehabkost@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.30]); Fri, 19 Apr 2019 06:13:54 +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 01/17] hw: add compat machines for 4.1 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: Peter Maydell , Igor Mammedov , Cornelia Huck , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cornelia Huck Add 4.1 machine types for arm/i440fx/q35/s390x/spapr. Signed-off-by: Cornelia Huck Message-Id: <20190411102025.22559-1-cohuck@redhat.com> Acked-by: Greg Kurz Acked-by: David Gibson Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 3 +++ include/hw/i386/pc.h | 3 +++ hw/arm/virt.c | 9 ++++++++- hw/core/machine.c | 3 +++ hw/i386/pc.c | 3 +++ hw/i386/pc_piix.c | 14 +++++++++++++- hw/i386/pc_q35.c | 13 ++++++++++++- hw/ppc/spapr.c | 15 +++++++++++++-- hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++- 9 files changed, 71 insertions(+), 6 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index e231860666..fe1885cbff 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -293,6 +293,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) +extern GlobalProperty hw_compat_4_0[]; +extern const size_t hw_compat_4_0_len; + extern GlobalProperty hw_compat_3_1[]; extern const size_t hw_compat_3_1_len; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index ca65ef18af..43df7230a2 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -293,6 +293,9 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); int e820_get_num_entries(void); bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); +extern GlobalProperty pc_compat_4_0[]; +extern const size_t pc_compat_4_0_len; + extern GlobalProperty pc_compat_3_1[]; extern const size_t pc_compat_3_1_len; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ce2664a30b..16ba67f7a7 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1978,10 +1978,17 @@ static void machvirt_machine_init(void) } type_init(machvirt_machine_init); +static void virt_machine_4_1_options(MachineClass *mc) +{ +} +DEFINE_VIRT_MACHINE_AS_LATEST(4, 1) + static void virt_machine_4_0_options(MachineClass *mc) { + virt_machine_4_1_options(mc); + compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len); } -DEFINE_VIRT_MACHINE_AS_LATEST(4, 0) +DEFINE_VIRT_MACHINE(4, 0) static void virt_machine_3_1_options(MachineClass *mc) { diff --git a/hw/core/machine.c b/hw/core/machine.c index 743fef2898..5d046a43e3 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -24,6 +24,9 @@ #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +GlobalProperty hw_compat_4_0[] = {}; +const size_t hw_compat_4_0_len = G_N_ELEMENTS(hw_compat_4_0); + GlobalProperty hw_compat_3_1[] = { { "pcie-root-port", "x-speed", "2_5" }, { "pcie-root-port", "x-width", "1" }, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f2c15bf1f2..d98b737b8f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -115,6 +115,9 @@ struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX}; /* Physical Address of PVH entry point read from kernel ELF NOTE */ static size_t pvh_start_addr; +GlobalProperty pc_compat_4_0[] = {}; +const size_t pc_compat_4_0_len = G_N_ELEMENTS(pc_compat_4_0); + GlobalProperty pc_compat_3_1[] = { { "intel-iommu", "dma-drain", "off" }, { "Opteron_G3" "-" TYPE_X86_CPU, "rdtscp", "off" }, diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 8ad8e885c6..2a7700b564 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -428,13 +428,25 @@ static void pc_i440fx_machine_options(MachineClass *m) machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); } -static void pc_i440fx_4_0_machine_options(MachineClass *m) +static void pc_i440fx_4_1_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->alias = "pc"; m->is_default = 1; } +DEFINE_I440FX_MACHINE(v4_1, "pc-i440fx-4.1", NULL, + pc_i440fx_4_1_machine_options); + +static void pc_i440fx_4_0_machine_options(MachineClass *m) +{ + pc_i440fx_4_1_machine_options(m); + m->alias = NULL; + m->is_default = 0; + compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len); + compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len); +} + DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL, pc_i440fx_4_0_machine_options); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 372c6b73be..37dd350511 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -365,12 +365,23 @@ static void pc_q35_machine_options(MachineClass *m) m->max_cpus = 288; } -static void pc_q35_4_0_machine_options(MachineClass *m) +static void pc_q35_4_1_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->alias = "q35"; } +DEFINE_Q35_MACHINE(v4_1, "pc-q35-4.1", NULL, + pc_q35_4_1_machine_options); + +static void pc_q35_4_0_machine_options(MachineClass *m) +{ + pc_q35_4_1_machine_options(m); + m->alias = NULL; + compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len); + compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len); +} + DEFINE_Q35_MACHINE(v4_0, "pc-q35-4.0", NULL, pc_q35_4_0_machine_options); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b52b82d298..8438741ec2 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4344,15 +4344,26 @@ static const TypeInfo spapr_machine_info = { } \ type_init(spapr_machine_register_##suffix) +/* + * pseries-4.1 + */ +static void spapr_machine_4_1_class_options(MachineClass *mc) +{ + /* Defaults for the latest behaviour inherited from the base class */ +} + +DEFINE_SPAPR_MACHINE(4_1, "4.1", true); + /* * pseries-4.0 */ static void spapr_machine_4_0_class_options(MachineClass *mc) { - /* Defaults for the latest behaviour inherited from the base class */ + spapr_machine_4_1_class_options(mc); + compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len); } -DEFINE_SPAPR_MACHINE(4_0, "4.0", true); +DEFINE_SPAPR_MACHINE(4_0, "4.0", false); /* * pseries-3.1 diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index d11069b860..02470e78c7 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -646,14 +646,26 @@ bool css_migration_enabled(void) } \ type_init(ccw_machine_register_##suffix) +static void ccw_machine_4_1_instance_options(MachineState *machine) +{ +} + +static void ccw_machine_4_1_class_options(MachineClass *mc) +{ +} +DEFINE_CCW_MACHINE(4_1, "4.1", true); + static void ccw_machine_4_0_instance_options(MachineState *machine) { + ccw_machine_4_1_instance_options(machine); } static void ccw_machine_4_0_class_options(MachineClass *mc) { + ccw_machine_4_1_class_options(mc); + compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len); } -DEFINE_CCW_MACHINE(4_0, "4.0", true); +DEFINE_CCW_MACHINE(4_0, "4.0", false); static void ccw_machine_3_1_instance_options(MachineState *machine) { From patchwork Fri Apr 19 06:13:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1087947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44lm0S3vNgz9s3Z for ; Fri, 19 Apr 2019 16:14:48 +1000 (AEST) Received: from localhost ([127.0.0.1]:51824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMnO-000582-Dr for incoming@patchwork.ozlabs.org; Fri, 19 Apr 2019 02:14:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMmc-00055k-26 for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:13:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHMmb-0004l9-4n for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:13:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50586) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHMma-0004kq-VQ for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:13:57 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 3504283F3A; Fri, 19 Apr 2019 06:13:56 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id B02735D9C5; Fri, 19 Apr 2019 06:13:55 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2019 03:13:34 -0300 Message-Id: <20190419061349.17094-3-ehabkost@redhat.com> In-Reply-To: <20190419061349.17094-1-ehabkost@redhat.com> References: <20190419061349.17094-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 19 Apr 2019 06:13:56 +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 02/17] vl.c: make find_default_machine() local 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: Peter Maydell , Igor Mammedov , Wei Yang , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang Function find_default_machine() is introduced by commit 2c8cffa599b7 "vl: make find_default_machine externally visible", and it was used outside of vl.c until commit a904410af5f1 "pc_sysfw: remove the rom_only property". Commit a904410af5f1 "pc_sysfw: remove the rom_only property" removed the only user of find_default_machine() outside vl.c, but neglected to make it static. Do that now. Signed-off-by: Wei Yang Message-Id: <20190405064121.23662-2-richardw.yang@linux.intel.com> Reviewed-by: Markus Armbruster Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 1 - vl.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index fe1885cbff..6f7916f88f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -57,7 +57,6 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, #define MACHINE_CLASS(klass) \ OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE) -MachineClass *find_default_machine(void); extern MachineState *current_machine; void machine_run_board_init(MachineState *machine); diff --git a/vl.c b/vl.c index c696ad2a13..9d6a519d74 100644 --- a/vl.c +++ b/vl.c @@ -1488,7 +1488,7 @@ static MachineClass *find_machine(const char *name) return mc; } -MachineClass *find_default_machine(void) +static MachineClass *find_default_machine(void) { GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false); MachineClass *mc = NULL; From patchwork Fri Apr 19 06:13:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1087949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44lm3s0JJlz9s3Z for ; Fri, 19 Apr 2019 16:17:45 +1000 (AEST) Received: from localhost ([127.0.0.1]:51871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMqE-0007Z5-TL for incoming@patchwork.ozlabs.org; Fri, 19 Apr 2019 02:17:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMme-00057j-9F for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHMmd-0004mM-7N for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHMmc-0004lz-V0 for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:13:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E5A581229; Fri, 19 Apr 2019 06:13:58 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id B45185C21F; Fri, 19 Apr 2019 06:13:57 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2019 03:13:35 -0300 Message-Id: <20190419061349.17094-4-ehabkost@redhat.com> In-Reply-To: <20190419061349.17094-1-ehabkost@redhat.com> References: <20190419061349.17094-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 19 Apr 2019 06:13:58 +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 03/17] vl.c: allocate TYPE_MACHINE list once during bootup 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: Peter Maydell , Igor Mammedov , Wei Yang , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang Now all the functions used to select machine is local and the call flow looks like below: select_machine() find_default_machine() machine_parse() find_machine() All these related function will need a GSList for TYPE_MACHINE. Currently we allocate this list each time we use it, while this is not necessary to do so because we don't need to modify this. This patch make the TYPE_MACHINE list allocation in select_machine and pass this to its child for use. Signed-off-by: Wei Yang Reviewed-by: Markus Armbruster Message-Id: <20190405064121.23662-3-richardw.yang@linux.intel.com> Signed-off-by: Eduardo Habkost --- vl.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/vl.c b/vl.c index 9d6a519d74..62f2656ccf 100644 --- a/vl.c +++ b/vl.c @@ -1465,9 +1465,9 @@ static int usb_parse(const char *cmdline) MachineState *current_machine; -static MachineClass *find_machine(const char *name) +static MachineClass *find_machine(const char *name, GSList *machines) { - GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false); + GSList *el; MachineClass *mc = NULL; for (el = machines; el; el = el->next) { @@ -1484,13 +1484,12 @@ static MachineClass *find_machine(const char *name) } } - g_slist_free(machines); return mc; } -static MachineClass *find_default_machine(void) +static MachineClass *find_default_machine(GSList *machines) { - GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false); + GSList *el; MachineClass *mc = NULL; for (el = machines; el; el = el->next) { @@ -1502,7 +1501,6 @@ static MachineClass *find_default_machine(void) } } - g_slist_free(machines); return mc; } @@ -2585,16 +2583,15 @@ static gint machine_class_cmp(gconstpointer a, gconstpointer b) object_class_get_name(OBJECT_CLASS(mc1))); } - static MachineClass *machine_parse(const char *name) +static MachineClass *machine_parse(const char *name, GSList *machines) { MachineClass *mc = NULL; - GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false); + GSList *el; if (name) { - mc = find_machine(name); + mc = find_machine(name, machines); } if (mc) { - g_slist_free(machines); return mc; } if (name && !is_help_option(name)) { @@ -2614,7 +2611,6 @@ static gint machine_class_cmp(gconstpointer a, gconstpointer b) } } - g_slist_free(machines); exit(!name || !is_help_option(name)); } @@ -2706,7 +2702,8 @@ static const QEMUOption *lookup_opt(int argc, char **argv, static MachineClass *select_machine(void) { - MachineClass *machine_class = find_default_machine(); + GSList *machines = object_class_get_list(TYPE_MACHINE, false); + MachineClass *machine_class = find_default_machine(machines); const char *optarg; QemuOpts *opts; Location loc; @@ -2718,7 +2715,7 @@ static MachineClass *select_machine(void) optarg = qemu_opt_get(opts, "type"); if (optarg) { - machine_class = machine_parse(optarg); + machine_class = machine_parse(optarg, machines); } if (!machine_class) { @@ -2728,6 +2725,7 @@ static MachineClass *select_machine(void) } loc_pop(&loc); + g_slist_free(machines); return machine_class; } From patchwork Fri Apr 19 06:13:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1087948 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44lm0Y028dz9s3Z for ; Fri, 19 Apr 2019 16:14:53 +1000 (AEST) Received: from localhost ([127.0.0.1]:51826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMnS-0005Bq-TR for incoming@patchwork.ozlabs.org; Fri, 19 Apr 2019 02:14:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMmf-00059a-VO for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHMmf-0004n1-2T for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHMme-0004me-TA for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:01 -0400 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 21CBF3004149; Fri, 19 Apr 2019 06:14:00 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6F83600C1; Fri, 19 Apr 2019 06:13:59 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2019 03:13:36 -0300 Message-Id: <20190419061349.17094-5-ehabkost@redhat.com> In-Reply-To: <20190419061349.17094-1-ehabkost@redhat.com> References: <20190419061349.17094-1-ehabkost@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.46]); Fri, 19 Apr 2019 06:14:00 +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 04/17] vl: Clean up after previous commit 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: Peter Maydell , Igor Mammedov , Markus Armbruster , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Markus Armbruster Since the previous commit, find_machine() and find_default_machine() don't have to deallocate on return. This permits further simplifications. Signed-off-by: Markus Armbruster Reviewed-by: Wei Yang Message-Id: <20190405064121.23662-4-richardw.yang@linux.intel.com> Signed-off-by: Eduardo Habkost --- vl.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/vl.c b/vl.c index 62f2656ccf..cb0f3f5856 100644 --- a/vl.c +++ b/vl.c @@ -1468,40 +1468,31 @@ MachineState *current_machine; static MachineClass *find_machine(const char *name, GSList *machines) { GSList *el; - MachineClass *mc = NULL; for (el = machines; el; el = el->next) { - MachineClass *temp = el->data; + MachineClass *mc = el->data; - if (!strcmp(temp->name, name)) { - mc = temp; - break; - } - if (temp->alias && - !strcmp(temp->alias, name)) { - mc = temp; - break; + if (!strcmp(mc->name, name) || !g_strcmp0(mc->alias, name)) { + return mc; } } - return mc; + return NULL; } static MachineClass *find_default_machine(GSList *machines) { GSList *el; - MachineClass *mc = NULL; for (el = machines; el; el = el->next) { - MachineClass *temp = el->data; + MachineClass *mc = el->data; - if (temp->is_default) { - mc = temp; - break; + if (mc->is_default) { + return mc; } } - return mc; + return NULL; } MachineInfoList *qmp_query_machines(Error **errp) From patchwork Fri Apr 19 06:13:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1087952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44lm480T5Nz9s3Z for ; Fri, 19 Apr 2019 16:18:00 +1000 (AEST) Received: from localhost ([127.0.0.1]:51883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMqT-0007is-Vv for incoming@patchwork.ozlabs.org; Fri, 19 Apr 2019 02:17:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMmj-0005DJ-Lt for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHMmh-0004pH-NW for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40354) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHMmh-0004os-5V for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:03 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 02777883BA; Fri, 19 Apr 2019 06:14:02 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8594F60852; Fri, 19 Apr 2019 06:14:01 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2019 03:13:37 -0300 Message-Id: <20190419061349.17094-6-ehabkost@redhat.com> In-Reply-To: <20190419061349.17094-1-ehabkost@redhat.com> References: <20190419061349.17094-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 19 Apr 2019 06:14:02 +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 05/17] vl: Simplify machine_parse() 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: Peter Maydell , Igor Mammedov , Markus Armbruster , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Markus Armbruster Exploit that argument @name is nerver null. Check is_help_option() first, because that's what we do elsewhere. If we (foolishly!) defined a machine named "help", -machine help would now print help instead of selecting the machine named "help". Signed-off-by: Markus Armbruster Reviewed-by: Wei Yang Message-Id: <20190405064121.23662-5-richardw.yang@linux.intel.com> Signed-off-by: Eduardo Habkost --- vl.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/vl.c b/vl.c index cb0f3f5856..d88638c54c 100644 --- a/vl.c +++ b/vl.c @@ -2576,19 +2576,10 @@ static gint machine_class_cmp(gconstpointer a, gconstpointer b) static MachineClass *machine_parse(const char *name, GSList *machines) { - MachineClass *mc = NULL; + MachineClass *mc; GSList *el; - if (name) { - mc = find_machine(name, machines); - } - if (mc) { - return mc; - } - if (name && !is_help_option(name)) { - error_report("unsupported machine type"); - error_printf("Use -machine help to list supported machines\n"); - } else { + if (is_help_option(name)) { printf("Supported machines are:\n"); machines = g_slist_sort(machines, machine_class_cmp); for (el = machines; el; el = el->next) { @@ -2600,9 +2591,16 @@ static MachineClass *machine_parse(const char *name, GSList *machines) mc->is_default ? " (default)" : "", mc->deprecation_reason ? " (deprecated)" : ""); } + exit(0); } - exit(!name || !is_help_option(name)); + mc = find_machine(name, machines); + if (!mc) { + error_report("unsupported machine type"); + error_printf("Use -machine help to list supported machines\n"); + exit(1); + } + return mc; } void qemu_add_exit_notifier(Notifier *notify) From patchwork Fri Apr 19 06:13:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1087951 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44lm3z6pR5z9s3l for ; Fri, 19 Apr 2019 16:17:51 +1000 (AEST) Received: from localhost ([127.0.0.1]:51881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMqL-0007fK-SJ for incoming@patchwork.ozlabs.org; Fri, 19 Apr 2019 02:17:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHMnD-0005eF-GG for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHMnC-000509-94 for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34616) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHMnC-0004zn-1j for qemu-devel@nongnu.org; Fri, 19 Apr 2019 02:14:34 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53D1A3082B69; Fri, 19 Apr 2019 06:14:33 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC4715C21F; Fri, 19 Apr 2019 06:14:32 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2019 03:13:38 -0300 Message-Id: <20190419061349.17094-7-ehabkost@redhat.com> In-Reply-To: <20190419061349.17094-1-ehabkost@redhat.com> References: <20190419061349.17094-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 19 Apr 2019 06:14:33 +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 06/17] cpu: Rename parse_cpu_model() to parse_cpu_option() 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: Peter Maydell , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The "model[,option...]" string parsed by the function is not just a CPU model. Rename the function and its argument to indicate it expects the full "-cpu" option to be provided. Signed-off-by: Eduardo Habkost Message-Id: <20190417025944.16154-2-ehabkost@redhat.com> Reviewed-by: David Gibson Reviewed-by: Markus Armbruster Reviewed-by: Igor Mammedov Signed-off-by: Eduardo Habkost --- include/qom/cpu.h | 6 +++--- bsd-user/main.c | 2 +- exec.c | 4 ++-- linux-user/main.c | 2 +- vl.c | 18 +++++++++--------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 1d6099e5d4..d28c690b27 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -689,15 +689,15 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model); CPUState *cpu_create(const char *typename); /** - * parse_cpu_model: - * @cpu_model: The model string including optional parameters. + * parse_cpu_option: + * @cpu_option: The -cpu option including optional parameters. * * processes optional parameters and registers them as global properties * * Returns: type of CPU to create or prints error and terminates process * if an error occurred. */ -const char *parse_cpu_model(const char *cpu_model); +const char *parse_cpu_option(const char *cpu_option); /** * cpu_has_work: diff --git a/bsd-user/main.c b/bsd-user/main.c index 0d3156974c..a6c055f5fb 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -903,7 +903,7 @@ int main(int argc, char **argv) /* init tcg before creating CPUs and to get qemu_host_page_size */ tcg_exec_init(0); - cpu_type = parse_cpu_model(cpu_model); + cpu_type = parse_cpu_option(cpu_model); cpu = cpu_create(cpu_type); env = cpu->env_ptr; #if defined(TARGET_SPARC) || defined(TARGET_PPC) diff --git a/exec.c b/exec.c index 6ab62f4eee..840677f15f 100644 --- a/exec.c +++ b/exec.c @@ -982,14 +982,14 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) #endif } -const char *parse_cpu_model(const char *cpu_model) +const char *parse_cpu_option(const char *cpu_option) { ObjectClass *oc; CPUClass *cc; gchar **model_pieces; const char *cpu_type; - model_pieces = g_strsplit(cpu_model, ",", 2); + model_pieces = g_strsplit(cpu_option, ",", 2); oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]); if (oc == NULL) { diff --git a/linux-user/main.c b/linux-user/main.c index a0aba9cb1e..20e0f51cfa 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -660,7 +660,7 @@ int main(int argc, char **argv, char **envp) if (cpu_model == NULL) { cpu_model = cpu_get_model(get_elf_eflags(execfd)); } - cpu_type = parse_cpu_model(cpu_model); + cpu_type = parse_cpu_option(cpu_model); /* init tcg before creating CPUs and to get qemu_host_page_size */ tcg_exec_init(0); diff --git a/vl.c b/vl.c index d88638c54c..34cdb8cece 100644 --- a/vl.c +++ b/vl.c @@ -2989,7 +2989,7 @@ int main(int argc, char **argv, char **envp) const char *optarg; const char *loadvm = NULL; MachineClass *machine_class; - const char *cpu_model; + const char *cpu_option; const char *vga_model = NULL; const char *qtest_chrdev = NULL; const char *qtest_log = NULL; @@ -3068,7 +3068,7 @@ int main(int argc, char **argv, char **envp) QLIST_INIT (&vm_change_state_head); os_setup_early_signal_handling(); - cpu_model = NULL; + cpu_option = NULL; snapshot = 0; nb_nics = 0; @@ -3120,7 +3120,7 @@ int main(int argc, char **argv, char **envp) switch(popt->index) { case QEMU_OPTION_cpu: /* hw initialization will check this */ - cpu_model = optarg; + cpu_option = optarg; break; case QEMU_OPTION_hda: case QEMU_OPTION_hdb: @@ -4037,8 +4037,8 @@ int main(int argc, char **argv, char **envp) qemu_set_hw_version(machine_class->hw_version); } - if (cpu_model && is_help_option(cpu_model)) { - list_cpus(stdout, &fprintf, cpu_model); + if (cpu_option && is_help_option(cpu_option)) { + list_cpus(stdout, &fprintf, cpu_option); exit(0); } @@ -4286,9 +4286,9 @@ int main(int argc, char **argv, char **envp) * Global properties get set up by qdev_prop_register_global(), * called from user_register_global_props(), and certain option * desugaring. Also in CPU feature desugaring (buried in - * parse_cpu_model()), which happens below this point, but may + * parse_cpu_option()), which happens below this point, but may * only target the CPU type, which can only be created after - * parse_cpu_model() returned the type. + * parse_cpu_option() returned the type. * * Machine compat properties: object_set_machine_compat_props(). * Accelerator compat props: object_set_accelerator_compat_props(), @@ -4452,8 +4452,8 @@ int main(int argc, char **argv, char **envp) /* parse features once if machine provides default cpu_type */ current_machine->cpu_type = machine_class->default_cpu_type; - if (cpu_model) { - current_machine->cpu_type = parse_cpu_model(cpu_model); + if (cpu_option) { + current_machine->cpu_type = parse_cpu_option(cpu_option); } parse_numa_opts(current_machine);