From nobody Sun May 19 03:38:21 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 1499101006265611.0083637299742; Mon, 3 Jul 2017 09:56:46 -0700 (PDT) Received: from localhost ([::1]:36383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dS4eR-0001vf-W4 for importer@patchew.org; Mon, 03 Jul 2017 12:56:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dS4Wb-0003UZ-Ht for qemu-devel@nongnu.org; Mon, 03 Jul 2017 12:48:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dS4WY-0008NG-9D for qemu-devel@nongnu.org; Mon, 03 Jul 2017 12:48:37 -0400 Received: from 1.mo4.mail-out.ovh.net ([178.33.248.196]:42071) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dS4WX-0008Mg-Uu for qemu-devel@nongnu.org; Mon, 03 Jul 2017 12:48:34 -0400 Received: from player159.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 53CBE81349 for ; Mon, 3 Jul 2017 18:48:32 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player159.ha.ovh.net (Postfix) with ESMTPA id B3CA14800AA; Mon, 3 Jul 2017 18:48:25 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 03 Jul 2017 18:48:25 +0200 Message-ID: <149910050540.26371.12575732020425703531.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 8457760102020847955 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedruddvgddutdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.248.196 Subject: [Qemu-devel] [PATCH] spapr: make default PHB optionnal 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: qemu-ppc@nongnu.org, Shivaprasad G Bhat , Andrea Bolognani , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The sPAPR machine always create a default PHB during initialization, even if -nodefaults was passed on the command line. This forces the user to rely on -global if she wants to set properties of the default PHB, such as numa_node. This patch introduces a new machine create-default-phb property to control whether the default PHB must be created or not. It defaults to on in order to preserve old setups (which is also the motivation to not alter the current behavior of -nodefaults). If create-default-phb is set to off, the default PHB isn't created, nor any other device usually created with it. It is mandatory to provide a PHB on the command line to be able to use PCI devices (otherwise QEMU won't start). For example, the following creates a PHB with the same mappings as the default PHB and also sets the NUMA affinity: -machine type=3Dpseries,create-default-phb=3Doff \ -numa node,nodeid=3D0 -device spapr-pci-host-bridge,index=3D0,numa_node= =3D0 Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 63 ++++++++++++++++++++++++++++++++++----------= ---- include/hw/ppc/spapr.h | 2 ++ 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ba8f57a5a054..3395bb3774b9 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2103,7 +2103,7 @@ static void ppc_spapr_init(MachineState *machine) sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(machine); const char *kernel_filename =3D machine->kernel_filename; const char *initrd_filename =3D machine->initrd_filename; - PCIHostState *phb; + PCIHostState *phb =3D NULL; int i; MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *ram =3D g_new(MemoryRegion, 1); @@ -2294,7 +2294,9 @@ static void ppc_spapr_init(MachineState *machine) /* Set up PCI */ spapr_pci_rtas_init(); =20 - phb =3D spapr_create_phb(spapr, 0); + if (spapr->create_default_phb) { + phb =3D spapr_create_phb(spapr, 0); + } =20 for (i =3D 0; i < nb_nics; i++) { NICInfo *nd =3D &nd_table[i]; @@ -2305,7 +2307,7 @@ static void ppc_spapr_init(MachineState *machine) =20 if (strcmp(nd->model, "ibmveth") =3D=3D 0) { spapr_vlan_create(spapr->vio_bus, nd); - } else { + } else if (phb) { pci_nic_init_nofail(&nd_table[i], phb->bus, nd->model, NULL); } } @@ -2314,24 +2316,26 @@ static void ppc_spapr_init(MachineState *machine) spapr_vscsi_create(spapr->vio_bus); } =20 - /* Graphics */ - if (spapr_vga_init(phb->bus, &error_fatal)) { - spapr->has_graphics =3D true; - machine->usb |=3D defaults_enabled() && !machine->usb_disabled; - } - - if (machine->usb) { - if (smc->use_ohci_by_default) { - pci_create_simple(phb->bus, -1, "pci-ohci"); - } else { - pci_create_simple(phb->bus, -1, "nec-usb-xhci"); + if (phb) { + /* Graphics */ + if (spapr_vga_init(phb->bus, &error_fatal)) { + spapr->has_graphics =3D true; + machine->usb |=3D defaults_enabled() && !machine->usb_disabled; } =20 - if (spapr->has_graphics) { - USBBus *usb_bus =3D usb_bus_find(-1); + if (machine->usb) { + if (smc->use_ohci_by_default) { + pci_create_simple(phb->bus, -1, "pci-ohci"); + } else { + pci_create_simple(phb->bus, -1, "nec-usb-xhci"); + } + + if (spapr->has_graphics) { + USBBus *usb_bus =3D usb_bus_find(-1); =20 - usb_create_simple(usb_bus, "usb-kbd"); - usb_create_simple(usb_bus, "usb-mouse"); + usb_create_simple(usb_bus, "usb-kbd"); + usb_create_simple(usb_bus, "usb-mouse"); + } } } =20 @@ -2544,12 +2548,27 @@ static void spapr_set_modern_hotplug_events(Object = *obj, bool value, spapr->use_hotplug_event_source =3D value; } =20 +static bool spapr_get_create_default_phb(Object *obj, Error **errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); + + return spapr->create_default_phb; +} + +static void spapr_set_create_default_phb(Object *obj, bool value, Error **= errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); + + spapr->create_default_phb =3D value; +} + static void spapr_machine_initfn(Object *obj) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); =20 spapr->htab_fd =3D -1; spapr->use_hotplug_event_source =3D true; + spapr->create_default_phb =3D true; object_property_add_str(obj, "kvm-type", spapr_get_kvm_type, spapr_set_kvm_type, NULL); object_property_set_description(obj, "kvm-type", @@ -2568,6 +2587,14 @@ static void spapr_machine_initfn(Object *obj) ppc_compat_add_property(obj, "max-cpu-compat", &spapr->max_compat_pvr, "Maximum permitted CPU compatibility mode", &error_fatal); + + object_property_add_bool(obj, "create-default-phb", + spapr_get_create_default_phb, + spapr_set_create_default_phb, + NULL); + object_property_set_description(obj, "create-default-phb", + "Create a default PCI Host Bridge", + NULL); } =20 static void spapr_machine_finalizefn(Object *obj) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index a184ffab0ebc..6ee914764807 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -93,6 +93,8 @@ struct sPAPRMachineState { bool use_hotplug_event_source; sPAPREventSource *event_sources; =20 + bool create_default_phb; + /* ibm,client-architecture-support option negotiation */ bool cas_reboot; bool cas_legacy_guest_workaround;