spapr: bootindex support
v4 cover spapr: bootindex support
With the great help from Paolo, I am presenting yet another try of bootindex support on sPAPR, this time with some QOM fixes. Details are in the commit messages. Please, comment. Thanks.
Alexey Kardashevskiy (5):
boot: extend get_boot_devices_list() to ignore suffixes
spapr-llan: add to boot device list
spapr-vio: fix firmware names
qdev: introduce FWPathProvider interface
spapr: define interface to fix device pathname
Hervé Poussineau (1):
qom: detect bad reentrance during object_class_foreach
Paolo Bonzini (2):
qom: do not register interface "types" in the type table
vl: allow customizing the class of /machine
hw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 34 ++++++++++++++++++ hw/core/qdev.c | 18 +++++++++- hw/net/spapr_llan.c | 3 ++ hw/nvram/fw_cfg.c | 2 +- hw/ppc/spapr.c | 80 ++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_vio.c | 2 ++ include/hw/boards.h | 1 + include/hw/fw-path-provider.h | 31 +++++++++++++++++ include/sysemu/sysemu.h | 2 +- qom/object.c | 17 +++++++-- tests/Makefile | 1 + vl.c | 11 ++++-- 13 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.h
Signature · 1 line
1.8.4.rc4
PATCH v4 1/8 qom: do not register interface "types" in the type table
From: Paolo Bonzini <[email protected]>
There should be no need to look them up nor enumerate the interface "types", whose "classes" are really just vtables. Just create the types and add them to the interface list of the parent type.
--- qom/object.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
qom/object.c +10 -3
@@ -88,7 +88,7 @@ static TypeImpl *type_table_lookup(const char *name)return g_hash_table_lookup (type_table_get (), name); } -static TypeImpl *type_register_internal (const TypeInfo *info) +static TypeImpl *type_new (const TypeInfo *info) {TypeImpl *ti =g_malloc0 (sizeof (*ti));int i;
@@ -122,8 +122,15 @@ static TypeImpl *type_register_internal(const TypeInfo *info) } ti->num_interfaces = i; +return ti; +} + +static TypeImpl *type_register_internal (const TypeInfo *info) +{ +TypeImpl *ti; + ti =type_new (info); +type_table_add (ti); -return ti; }
@@ -216,7 +223,7 @@ static void type_initialize_interface(TypeImpl *ti, const char *parent) info.name =g_strdup_printf ("%s::%s" , ti->name, info.parent); info.abstract = true; - iface_impl =type_register (&info); + iface_impl =type_new (&info);type_initialize (iface_impl);g_free ((char *)info.name);
Signature · 1 line
1.8.4.rc4
PATCH v4 2/8 qom: detect bad reentrance during object_class_foreach
In reply to Alexey KardashevskiyFrom: Hervé Poussineau <[email protected]>
We should not modify the type hash table while it is being iterated on. Assert that it does not happen.
---
Changes:
v4:
* rename: @enumerating -> @enumerating_types
* @enumerating_types is static and does not require initialization to "false"
--- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+)
qom/object.c +4 -0
@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)return type_table; } +static bool enumerating_types;static void type_table_add (TypeImpl *ti) { +assert (!enumerating_types);g_hash_table_insert (type_table_get (), (void *)ti->name, ti); }
@@ -666,7 +668,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), {OCFData data = { fn, implements_type, include_abstract, opaque }; + enumerating_types = true;g_hash_table_foreach (type_table_get (), object_class_foreach_tramp, &data); + enumerating_types = false; } int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
Signature · 1 line
1.8.4.rc4
PATCH v4 3/8 boot: extend get_boot_devices_list() to ignore suffixes
In reply to Alexey KardashevskiyAs suffixes do not make sense for sPAPR's device tree and there is no way to filter them out on the BusState::get_fw_dev_path level, let's add an ability for the external caller to specify whether to apply suffixes or not.
We could handle suffixes in SLOF (ignore for now) but this would require serious rework in the node opening code in SLOF which has no obvious benefit for the currently emulated sPAPR machine.
---
Changes:
v4:
* changed commit message about not having plans in SLOF rework as it is scary :)
--- hw/nvram/fw_cfg.c | 2 +- include/sysemu/sysemu.h | 2 +- vl.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
hw/nvram/fw_cfg.c +1 -1
@@ -504,7 +504,7 @@ static void fw_cfg_machine_ready(struct Notifier *n, void *data) {size_t len;FWCfgState *s =container_of (n, FWCfgState, machine_ready); -char *bootindex =get_boot_devices_list (&len); +char *bootindex =get_boot_devices_list (&len, false);fw_cfg_add_file (s,"bootorder" , (uint8_t *)bootindex, len); }
include/sysemu/sysemu.h +1 -1
@@ -185,7 +185,7 @@ void rtc_change_mon_event(struct tm *tm);void add_boot_device_path (int32_t bootindex,DeviceState *dev,const char *suffix); -char *get_boot_devices_list (size_t *size); +char *get_boot_devices_list (size_t *size,bool ignore_suffixes);DeviceState *get_boot_device (uint32_t position);
vl.c +3 -3
@@ -1213,7 +1213,7 @@ DeviceState *get_boot_device(uint32_t position)* memory pointed by "size" is assigned total length of the array in bytes * */ -char *get_boot_devices_list (size_t *size) +char *get_boot_devices_list (size_t *size,bool ignore_suffixes) {FWBootEntry *i;size_t total =0 ;
@@ -1228,7 +1228,7 @@ char *get_boot_devices_list(size_t *size)assert (devpath); } -if (i->suffix && devpath) { +if (i->suffix && !ignore_suffixes && devpath) {size_t bootpathlen =strlen (devpath) +strlen (i->suffix) +1 ; bootpath =g_malloc (bootpathlen);
@@ -1236,7 +1236,7 @@ char *get_boot_devices_list(size_t *size)g_free (devpath); }else if (devpath) { bootpath = devpath; - }else { + }else if (!ignore_suffixes) {assert (i->suffix); bootpath =g_strdup (i->suffix); }
Signature · 1 line
1.8.4.rc4
PATCH v4 4/8 spapr-llan: add to boot device list
In reply to Alexey Kardashevskiy--- hw/net/spapr_llan.c | 3 +++ 1 file changed, 3 insertions(+)
hw/net/spapr_llan.c +3 -0
@@ -29,6 +29,7 @@#include "hw/qdev.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" +#include "sysemu/sysemu.h" #include <libfdt.h>
@@ -213,6 +214,8 @@ static int spapr_vlan_init(VIOsPAPRDevice *sdev) object_get_typename(OBJECT(sdev)), sdev->qdev.id, dev);qemu_format_nic_info_str (qemu_get_queue (dev->nic), dev->nicconf.macaddr.a); +add_boot_device_path (dev->nicconf.bootindex,DEVICE (dev),"" ); +return 0 ; }
Signature · 1 line
1.8.4.rc4
PATCH v4 5/8 spapr-vio: fix firmware names
In reply to Alexey KardashevskiyThis changes VIO bridge fw name from spapr-vio-bridge to vdevice and vscsi/veth node names from QEMU object names to VIO specific device tree names.
--- hw/ppc/spapr_vio.c | 2 ++ 1 file changed, 2 insertions(+)
hw/ppc/spapr_vio.c +2 -0
@@ -68,6 +68,7 @@ static void spapr_vio_bus_class_init(ObjectClass *klass, void *data)BusClass *k =BUS_CLASS (klass); k->get_dev_path = spapr_vio_get_dev_name; + k->get_fw_dev_path = spapr_vio_get_dev_name; }static const TypeInfo spapr_vio_bus_info = {
@@ -531,6 +532,7 @@ static void spapr_vio_bridge_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); + dc->fw_name ="vdevice" ; k->init = spapr_vio_bridge_init; dc->no_user =1 ; }
Signature · 1 line
1.8.4.rc4
PATCH v4 6/8 qdev: introduce FWPathProvider interface
In reply to Alexey KardashevskiyQEMU supports firmware names for all devices in the QEMU tree but some architectures expect some parts of firmware path names in different format.
This introduces a firmware-pathname-change interface definition. If some machines needs to redefine the firmware path format, it has to add the TYPE_FW_PATH_PROVIDER interface to an object that is above the device on the QOM tree (typically /machine).
---
Changes:
v4:
* added fw-path-provider.o into tests/Makefile
* fixed 80chars warning from checkpatch.pl
--- hw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 36 ++++++++++++++++++++++++++++++++++++ hw/core/qdev.c | 18 +++++++++++++++++- include/hw/fw-path-provider.h | 32 ++++++++++++++++++++++++++++++++ tests/Makefile | 1 + 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.h
hw/core/Makefile.objs +1 -0
@@ -1,5 +1,6 @@ # core qdev-related obj files, also used by *-user: common-obj-y += qdev.o qdev-properties.o +common-obj-y += fw-path-provider.o # irq.o needed for qdev GPIO handling: common-obj-y += irq.o
hw/core/fw-path-provider.c new file +36 -0
@@ -0,0 +1,36 @@ +#include "hw/fw-path-provider.h" + +char *fw_path_provider_get_dev_path (FWPathProvider *p,BusState *bus, +DeviceState *dev) +{ +FWPathProviderClass *k =FW_PATH_PROVIDER_GET_CLASS (p); + +return k->get_dev_path (p, bus, dev); +} + +char *fw_path_provider_try_get_dev_path (Object *o,BusState *bus, +DeviceState *dev) +{ +FWPathProvider *p = (FWPathProvider *) +object_dynamic_cast (o,TYPE_FW_PATH_PROVIDER ); + +if (p) { +return fw_path_provider_get_dev_path (p, bus, dev); + } + +return NULL ; +} + +static const TypeInfo fw_path_provider_info = { + .name =TYPE_FW_PATH_PROVIDER , + .parent =TYPE_INTERFACE , + .class_size =sizeof (FWPathProviderClass), +}; + + +static void fw_path_provider_register_types (void ) +{ +type_register_static (&fw_path_provider_info); +} + +type_init (fw_path_provider_register_types)
hw/core/qdev.c +17 -1
@@ -26,6 +26,7 @@this API directly. */ #include "hw/qdev.h" +#include "hw/fw-path-provider.h" #include "sysemu/sysemu.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h"
@@ -503,6 +504,18 @@ static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)return NULL ; } +static char *qdev_get_fw_dev_path_from_handler (BusState *bus,DeviceState *dev) +{ +Object *obj =OBJECT (dev); +char *d =NULL ; + +while (!d && obj->parent) { + obj = obj->parent; + d =fw_path_provider_try_get_dev_path (obj, bus, dev); + } +return d; +} +static int qdev_get_fw_dev_path_helper (DeviceState *dev,char *p,int size) {int l =0 ;
@@ -510,7 +523,10 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)if (dev && dev->parent_bus) {char *d; l =qdev_get_fw_dev_path_helper (dev->parent_bus->parent, p, size); - d =bus_get_fw_dev_path (dev->parent_bus, dev); + d =qdev_get_fw_dev_path_from_handler (dev->parent_bus, dev); +if (!d) { + d =bus_get_fw_dev_path (dev->parent_bus, dev); + }if (d) { l +=snprintf (p + l, size - l,"%s" , d);g_free (d);
include/hw/fw-path-provider.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef FW_PATH_PROVIDER_H +#define FW_PATH_PROVIDER_H 1 + +#include "qemu-common.h" +#include "qom/object.h" + +#define TYPE_FW_PATH_PROVIDER "fw-path-provider" + +#define FW_PATH_PROVIDER_CLASS (klass) \ + OBJECT_CLASS_CHECK(FWPathProviderClass, (klass), TYPE_FW_PATH_PROVIDER) +#define FW_PATH_PROVIDER_GET_CLASS (obj) \ + OBJECT_GET_CLASS(FWPathProviderClass, (obj), TYPE_FW_PATH_PROVIDER) +#define FW_PATH_PROVIDER (obj) \ + INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER) + +typedef struct FWPathProvider { +Object Parent; +}FWPathProvider ; + +typedef void (*StreamCanPushNotifyFn )(void *opaque); + +typedef struct FWPathProviderClass { +InterfaceClass parent; +char *(*get_dev_path)(FWPathProvider *p,BusState *bus,DeviceState *dev); +}FWPathProviderClass ; + +char *fw_path_provider_get_dev_path (FWPathProvider *p,BusState *bus, +DeviceState *dev); +char *fw_path_provider_try_get_dev_path (Object *o,BusState *bus, +DeviceState *dev); + +#endif /* FW_PATH_PROVIDER_H */
tests/Makefile +1 -0
@@ -160,6 +160,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ hw/core/qdev.o hw/core/qdev-properties.o \ hw/core/irq.o \ qom/object.o qom/container.o qom/qom-qobject.o \ + hw/core/fw-path-provider.o \ $(test-qapi-obj-y) \ libqemuutil.a libqemustub.a
Signature · 1 line
1.8.4.rc4
Re: [Qemu-devel] [PATCH v4 6/8] qdev: introduce FWPathProvider interface
Am 11.12.2013 11:22, schrieb Alexey Kardashevskiy:
Quoted 9 lines
QEMU supports firmware names for all devices in the QEMU tree but some architectures expect some parts of firmware path names in different format.
This introduces a firmware-pathname-change interface definition. If some machines needs to redefine the firmware path format, it has to add the
TYPE_FW_PATH_PROVIDERinterface to an object that is above the device on the QOM tree (typically /machine).
Quoted 7 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
Changes:
v4:
* added fw-path-provider.o into tests/Makefile
* fixed 80chars warning from checkpatch.pl
I am puzzled that the patch ends in Paolo's Sob but was sent by Alexey. Was this picked up from another series or is it even in multiple concurrent series? Were changes performed since Paolo signed it off? If not, please provide a Patchwork link to the original for convenience. :)
Quoted 27 lines
--- hw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 36 ++++++++++++++++++++++++++++++++++++ hw/core/qdev.c | 18 +++++++++++++++++- include/hw/fw-path-provider.h | 32 ++++++++++++++++++++++++++++++++ tests/Makefile | 1 + 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.hhw/core/Makefile.objs +1
-0@@ -1,5 +1,6 @@ # core qdev-related obj files, also used by *-user: common-obj-y += qdev.o qdev-properties.o +common-obj-y += fw-path-provider.o # irq.o needed for qdev GPIO handling: common-obj-y += irq.ohw/core/fw-path-provider.c new file +0
-0
hw/core/fw-path-provider.c line 1
Quoted 1 line
hw/core/fw-path-provider.c new file +1
-0@@ -0,0 +1,36 @@ +#include "hw/fw-path-provider.h"
This new file is lacking a license header. Same for the header file below.
Quoted 16 lines
hw/core/fw-path-provider.c new file +16
-0+ +char *fw_path_provider_get_dev_path (FWPathProvider *p,BusState *bus, +DeviceState *dev) +{ +FWPathProviderClass *k =FW_PATH_PROVIDER_GET_CLASS (p); + +return k->get_dev_path (p, bus, dev); +} + +char *fw_path_provider_try_get_dev_path (Object *o,BusState *bus, +DeviceState *dev) +{ +FWPathProvider *p = (FWPathProvider *) +object_dynamic_cast (o,TYPE_FW_PATH_PROVIDER ); + +if (p) {
hw/core/fw-path-provider.c line 27
Quoted 10 lines
hw/core/fw-path-provider.c new file +10
-0+return fw_path_provider_get_dev_path (p, bus, dev); + } + +return NULL ; +} + +static const TypeInfo fw_path_provider_info = { + .name =TYPE_FW_PATH_PROVIDER , + .parent =TYPE_INTERFACE , + .class_size =sizeof (FWPathProviderClass),
Indentation looks inconsistent.
hw/core/fw-path-provider.c line 29
Quoted 2 lines
hw/core/fw-path-provider.c new file +2
-0+}; +
Double white line seems unintentional.
Quoted 63 lines
hw/core/fw-path-provider.c new file +7
-0+ +static void fw_path_provider_register_types (void ) +{ +type_register_static (&fw_path_provider_info); +} + +type_init (fw_path_provider_register_types)hw/core/qdev.c +17
-1@@ -26,6 +26,7 @@this API directly. */ #include "hw/qdev.h" +#include "hw/fw-path-provider.h" #include "sysemu/sysemu.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" @@ -503,6 +504,18 @@ static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)return NULL ; } +static char *qdev_get_fw_dev_path_from_handler (BusState *bus,DeviceState *dev) +{ +Object *obj =OBJECT (dev); +char *d =NULL ; + +while (!d && obj->parent) { + obj = obj->parent; + d =fw_path_provider_try_get_dev_path (obj, bus, dev); + } +return d; +} +static int qdev_get_fw_dev_path_helper (DeviceState *dev,char *p,int size) {int l =0 ;@@ -510,7 +523,10 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)if (dev && dev->parent_bus) {char *d; l =qdev_get_fw_dev_path_helper (dev->parent_bus->parent, p, size); - d =bus_get_fw_dev_path (dev->parent_bus, dev); + d =qdev_get_fw_dev_path_from_handler (dev->parent_bus, dev); +if (!d) { + d =bus_get_fw_dev_path (dev->parent_bus, dev); + }if (d) { l +=snprintf (p + l, size - l,"%s" , d);g_free (d);include/hw/fw-path-provider.h new file +7
-0@@ -0,0 +1,32 @@ +#ifndef FW_PATH_PROVIDER_H +#define FW_PATH_PROVIDER_H 1 + +#include "qemu-common.h" +#include "qom/object.h" + +#define TYPE_FW_PATH_PROVIDER "fw-path-provider"
include/hw/fw-path-provider.h line 17
Quoted 10 lines
include/hw/fw-path-provider.h new file +10
-0+ +#define FW_PATH_PROVIDER_CLASS (klass) \ + OBJECT_CLASS_CHECK(FWPathProviderClass, (klass), TYPE_FW_PATH_PROVIDER) +#define FW_PATH_PROVIDER_GET_CLASS (obj) \ + OBJECT_GET_CLASS(FWPathProviderClass, (obj), TYPE_FW_PATH_PROVIDER) +#define FW_PATH_PROVIDER (obj) \ + INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER) + +typedef struct FWPathProvider { + Object Parent;
parent_obj
include/hw/fw-path-provider.h line 23
Quoted 6 lines
include/hw/fw-path-provider.h new file +6
-0+} FWPathProvider; + +typedef void (*StreamCanPushNotifyFn )(void *opaque); + +typedef struct FWPathProviderClass { + InterfaceClass parent;
parent_class and white line after, please.
Patch looks independent of the other pieces, so we could extract some non-ppc pieces if this is not just waiting for an ack.
The QOM patches should already be upstream by now.
Thanks,
Andreas
Quoted 22 lines
include/hw/fw-path-provider.h new file +9
-0+ char *(*get_dev_path)(FWPathProvider *p, BusState *bus, DeviceState *dev); +} FWPathProviderClass; + +char *fw_path_provider_get_dev_path (FWPathProvider *p,BusState *bus, +DeviceState *dev); +char *fw_path_provider_try_get_dev_path (Object *o,BusState *bus, +DeviceState *dev); + +#endif /* FW_PATH_PROVIDER_H */ tests/Makefile +1
-0@@ -160,6 +160,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ hw/core/qdev.o hw/core/qdev-properties.o \ hw/core/irq.o \ qom/object.o qom/container.o qom/qom-qobject.o \ + hw/core/fw-path-provider.o \ $(test-qapi-obj-y) \ libqemuutil.a libqemustub.a
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH v4 7/8 vl: allow customizing the class of /machine
In reply to Alexey KardashevskiyFrom: Paolo Bonzini <[email protected]>
This is a first step towards QOMifying /machine.
--- include/hw/boards.h | 1 + vl.c | 5 +++++ 2 files changed, 6 insertions(+)
include/hw/boards.h +1 -0
@@ -25,6 +25,7 @@ typedef struct QEMUMachine {const char *name;const char *alias;const char *desc; +const char *class_name;QEMUMachineInitFunc *init;QEMUMachineResetFunc *reset;QEMUMachineHotAddCPUFunc *hot_add_cpu;
vl.c +5 -0
@@ -4047,6 +4047,11 @@ int main(int argc, char **argv, char **envp)qtest_init (); } +if (machine->class_name) { +Object *m =object_new (machine->class_name); +object_property_add_child (object_get_root (),"machine" , m,NULL ); + } + machine_opts =qemu_get_machine_opts (); kernel_filename =qemu_opt_get (machine_opts,"kernel" ); initrd_filename =qemu_opt_get (machine_opts,"initrd" );
Signature · 1 line
1.8.4.rc4
PATCH v4 8/8 spapr: define interface to fix device pathname
In reply to Alexey KardashevskiyThis defines an object with the interface to fix firmware pathnames for devices which have @bootindex property.
This fixes SCSI disks device node names (which are wildcard nodes in the device-tree).
This fixes PHB name from "pci" to "pci@XXXX" where XXXX is a BUID as there is no bus on top of sPAPRPHBState where PHB firmware name could be fixed using the BusClass::get_fw_dev_path mechanism.
This stores the boot list in the /chosen/qemu,boot-list property of the device tree. "\n" are replaced by spaces to support OF1275. SLOF needs an update in order to support the boot list.
--- hw/ppc/spapr.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +79 -1
@@ -26,6 +26,7 @@*/ #include "sysemu/sysemu.h" #include "hw/hw.h" +#include "hw/fw-path-provider.h" #include "elf.h" #include "net/net.h" #include "sysemu/blockdev.h"
@@ -45,6 +46,7 @@#include "hw/pci/msi.h" #include "hw/pci/pci.h" +#include "hw/scsi/scsi.h" #include "exec/address-spaces.h" #include "hw/usb.h"
@@ -80,6 +82,8 @@#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift)) +#define TYPE_SPAPR_MACHINE "machine-spapr" +sPAPREnvironment *spapr;int spapr_allocate_irq (int hint,bool lsi)
@@ -587,7 +591,9 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,hwaddr rtas_addr, hwaddr rtas_size) { - int ret; + int ret, i; +size_t cb =0 ; +char *bootlist;void *fdt;sPAPRPHBState *phb;
@@ -629,6 +635,21 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,fprintf (stderr,"Couldn't finalize CPU device tree properties\n" ); } + bootlist =get_boot_devices_list (&cb, true); +if (cb && bootlist) { +int offset =fdt_path_offset (fdt,"/chosen" ); +if (offset <0 ) { +exit (1 ); + } +for (i =0 ; i < cb; i++) { +if (bootlist[i] =='\n' ) { + bootlist[i] =' ' ; + } + + } + ret =fdt_setprop_string (fdt, offset,"qemu,boot-list" , bootlist); + } +if (!spapr->has_graphics) {spapr_populate_chosen_stdout (fdt, spapr->vio_bus); }
@@ -1352,6 +1373,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)static QEMUMachine spapr_machine = { .name ="pseries" , .desc ="pSeries Logical Partition (PAPR compliant)" , + .class_name =TYPE_SPAPR_MACHINE , .is_default =1 , .init = ppc_spapr_init, .reset = ppc_spapr_reset,
@@ -1367,3 +1389,59 @@ static void spapr_machine_init(void) }machine_init (spapr_machine_init); + +/* +* Implementation of an interface to adjust firmware patch +* for the bootindex property handling. +*/ +static char *spapr_get_fw_dev_path (FWPathProvider *p,BusState *bus, +DeviceState *dev) +{ +#define CAST (type, obj, name) \ + ((type *)object_dynamic_cast(OBJECT(obj), (name))) +SCSIDevice *d =CAST (SCSIDevice, dev,TYPE_SCSI_DEVICE ); +sPAPRPHBState *phb =CAST (sPAPRPHBState, dev,TYPE_SPAPR_PCI_HOST_BRIDGE ); + +if (d) { +/* +* Replace "channel@0/disk@0,0" with "disk@8000000000000000": +* We use SRP luns of the form 8000 | (bus << 8) | (id << 5) | lun +* in the top 16 bits of the 64-bit LUN +*/ +unsigned id =0x8000 | (d->channel <<8 ) | (d->id <<5 ) | d->lun; + +return g_strdup_printf ("%s@%" PRIX64 ,qdev_fw_name (dev), + (uint64_t )id <<48 ); + } + +if (phb) { +/* Replace "pci" with "pci@800000020000000" */ +return g_strdup_printf ("pci@%" PRIX64 , phb->buid); + } + +return NULL ; +} + +static void spapr_machine_class_init (ObjectClass *oc,void *data) +{ +FWPathProviderClass *fwc =FW_PATH_PROVIDER_CLASS (oc); + + fwc->get_dev_path = spapr_get_fw_dev_path; +} + +static const TypeInfo spapr_machine_info = { + .name =TYPE_SPAPR_MACHINE , + .parent =TYPE_OBJECT , + .class_init = spapr_machine_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_FW_PATH_PROVIDER }, + { } + } +}; + +static void spapr_machine_register_types (void ) +{ +type_register_static (&spapr_machine_info); +} + +type_init (spapr_machine_register_types)
Signature · 1 line
1.8.4.rc4
Il 11/12/2013 11:22, Alexey Kardashevskiy ha scritto:
Quoted 18 lines
With the great help from Paolo, I am presenting yet another try of bootindex support on sPAPR, this time with some QOM fixes. Details are in the commit messages. Please, comment. Thanks.
Alexey Kardashevskiy (5):
boot: extendget_boot_devices_list()to ignore suffixes
spapr-llan: add to boot device list
spapr-vio: fix firmware names
qdev: introduce FWPathProvider interface
spapr: define interface to fix device pathnameHervé Poussineau (1):
qom: detect bad reentrance duringobject_class_foreachPaolo Bonzini (2):
qom: do not register interface "types" in the type table
vl: allow customizing the class of /machine
Quoted 17 lines
hw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 34 ++++++++++++++++++ hw/core/qdev.c | 18 +++++++++- hw/net/spapr_llan.c | 3 ++ hw/nvram/fw_cfg.c | 2 +- hw/ppc/spapr.c | 80 ++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_vio.c | 2 ++ include/hw/boards.h | 1 + include/hw/fw-path-provider.h | 31 +++++++++++++++++ include/sysemu/sysemu.h | 2 +- qom/object.c | 17 +++++++-- tests/Makefile | 1 + vl.c | 11 ++++-- 13 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.h
Quoted 11 lines · Alexey Kardashevskiy
With the great help from Paolo, I am presenting yet another try of bootindex support on sPAPR, this time with some QOM fixes. Details are in the commit messages. Please, comment. Thanks.
Alexey Kardashevskiy (5):
boot: extendget_boot_devices_list()to ignore suffixes
spapr-llan: add to boot device list
spapr-vio: fix firmware names
qdev: introduce FWPathProvider interface
spapr: define interface to fix device pathname
Quoted 6 lines
Hervé Poussineau (1):
qom: detect bad reentrance duringobject_class_foreachPaolo Bonzini (2):
qom: do not register interface "types" in the type table
vl: allow customizing the class of /machine
Looks good overall.
But this seems to suffer from the same problem as existing bootindex code on x86: you can't add a bootable device by hotplug.
And we really want to fix it on x86 too.
This might be fixable using FW CFG read callback, and updating the bootindex blob dynamically.
See how e.g. acpi_build_update works.
Quoted 20 lines
hw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 34 ++++++++++++++++++ hw/core/qdev.c | 18 +++++++++- hw/net/spapr_llan.c | 3 ++ hw/nvram/fw_cfg.c | 2 +- hw/ppc/spapr.c | 80 ++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_vio.c | 2 ++ include/hw/boards.h | 1 + include/hw/fw-path-provider.h | 31 +++++++++++++++++ include/sysemu/sysemu.h | 2 +- qom/object.c | 17 +++++++-- tests/Makefile | 1 + vl.c | 11 ++++-- 13 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.hSignature · 1 line
1.8.4.rc4
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Alexey Kardashevskiy
With the great help from Paolo, I am presenting yet another try of bootindex support on sPAPR, this time with some QOM fixes. Details are in the commit messages. Please, comment. Thanks.
Alexey Kardashevskiy (5):
boot: extendget_boot_devices_list()to ignore suffixes
spapr-llan: add to boot device list
spapr-vio: fix firmware names
qdev: introduce FWPathProvider interface
spapr: define interface to fix device pathnameHervé Poussineau (1):
qom: detect bad reentrance duringobject_class_foreach
Quoted 8 lines
Quoted 3 lines
Paolo Bonzini (2):
qom: do not register interface "types" in the type table
vl: allow customizing the class of /machineLooks good overall.
But this seems to suffer from the same problem as existing bootindex code on x86: you can't add a bootable device by hotplug.
Why? The boot list is delivered to SLOF via the device tree which is composed on a machine reset (spapr_finalize_fdt() calls get_boot_devices_list() and that's it) so if a bootable device was hotplugged, then after reset it will be in the list.
Quoted 5 lines
And we really want to fix it on x86 too.
This might be fixable using FW CFG read callback, and updating the bootindex blob dynamically.
See how e.g.acpi_build_updateworks.
Sorry, since I do not have good understanding what is happening in x86, I need more details.
Because I would implement qemu_add_machine_reset_notifier (copied from qemu_add_machine_init_done_notifier thing) and make fw_cfg_init() register a reset notifier.
Or just call qemu_add_machine_init_done_notifier() on a machine reset - I do not really see a code in any of those notifiers which could not be executed on a machine reset (but again, I am even more ignorant in x86 field than usual :) ).
Signature · 1 line
Alexey
Quoted 18 lines · Alexey Kardashevskiy
With the great help from Paolo, I am presenting yet another try of bootindex support on sPAPR, this time with some QOM fixes. Details are in the commit messages. Please, comment. Thanks.
Alexey Kardashevskiy (5):
boot: extendget_boot_devices_list()to ignore suffixes
spapr-llan: add to boot device list
spapr-vio: fix firmware names
qdev: introduce FWPathProvider interface
spapr: define interface to fix device pathnameHervé Poussineau (1):
qom: detect bad reentrance duringobject_class_foreachPaolo Bonzini (2):
qom: do not register interface "types" in the type table
vl: allow customizing the class of /machine
Quoted 16 lines
hw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 34 ++++++++++++++++++ hw/core/qdev.c | 18 +++++++++- hw/net/spapr_llan.c | 3 ++ hw/nvram/fw_cfg.c | 2 +- hw/ppc/spapr.c | 80 ++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_vio.c | 2 ++ include/hw/boards.h | 1 + include/hw/fw-path-provider.h | 31 +++++++++++++++++ include/sysemu/sysemu.h | 2 +- qom/object.c | 17 +++++++-- tests/Makefile | 1 + vl.c | 11 ++++-- 13 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.h
Some bits from this went upstream but none of them is mine. What am I missing here? Thanks.
Signature · 1 line
Alexey
Il 22/01/2014 05:19, Alexey Kardashevskiy ha scritto:
Quoted 37 lines · Alexey Kardashevskiy
Quoted 18 lines
With the great help from Paolo, I am presenting yet another try of bootindex support on sPAPR, this time with some QOM fixes. Details are in the commit messages. Please, comment. Thanks.
Alexey Kardashevskiy (5):
boot: extendget_boot_devices_list()to ignore suffixes
spapr-llan: add to boot device list
spapr-vio: fix firmware names
qdev: introduce FWPathProvider interface
spapr: define interface to fix device pathnameHervé Poussineau (1):
qom: detect bad reentrance duringobject_class_foreachPaolo Bonzini (2):
qom: do not register interface "types" in the type table
vl: allow customizing the class of /machineQuoted 16 lines
hw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 34 ++++++++++++++++++ hw/core/qdev.c | 18 +++++++++- hw/net/spapr_llan.c | 3 ++ hw/nvram/fw_cfg.c | 2 +- hw/ppc/spapr.c | 80 ++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_vio.c | 2 ++ include/hw/boards.h | 1 + include/hw/fw-path-provider.h | 31 +++++++++++++++++ include/sysemu/sysemu.h | 2 +- qom/object.c | 17 +++++++-- tests/Makefile | 1 + vl.c | 11 ++++-- 13 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.h
Quoted 2 lines
Some bits from this went upstream but none of them is mine. What am I missing here? Thanks.
No idea, perhaps it's because the same patches were present in multiple series? Alex, are you picking up what's left?
Paolo
Quoted 41 lines · Paolo Bonzini
Il 22/01/2014 05:19, Alexey Kardashevskiy ha scritto:
Quoted 40 lines · Alexey Kardashevskiy
Quoted 37 lines
With the great help from Paolo, I am presenting yet another try of bootindex
support on sPAPR, this time with some QOM fixes. Details are in the commit messages.
Please, comment. Thanks.Alexey Kardashevskiy (5):
boot: extendget_boot_devices_list()to ignore suffixes
spapr-llan: add to boot device list
spapr-vio: fix firmware names
qdev: introduce FWPathProvider interface
spapr: define interface to fix device pathnameHervé Poussineau (1):
qom: detect bad reentrance duringobject_class_foreachPaolo Bonzini (2):
qom: do not register interface "types" in the type table
vl: allow customizing the class of /machinehw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 34 ++++++++++++++++++ hw/core/qdev.c | 18 +++++++++- hw/net/spapr_llan.c | 3 ++ hw/nvram/fw_cfg.c | 2 +- hw/ppc/spapr.c | 80 ++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_vio.c | 2 ++ include/hw/boards.h | 1 + include/hw/fw-path-provider.h | 31 +++++++++++++++++ include/sysemu/sysemu.h | 2 +- qom/object.c | 17 +++++++-- tests/Makefile | 1 + vl.c | 11 ++++-- 13 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.h
Quoted 7 lines
Quoted 2 lines
Some bits from this went upstream but none of them is mine. What am I missing here? Thanks.
No idea, perhaps it's because the same patches were present in multiple series? Alex, are you picking up what's left?
Paolo
In the "Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach" thread Andreas told me:
===
Be patient.
1) I am on holidays and thus not available full-time.
2) Alex has already sent out his ppc PULL, so no urgency.
3) As mentioned, I plan to post QOM and CPU PULLs later today.
And no, you don't need to repost after parts of your series get applied pretty much unmodified.
===
So I wonder if I am not just patient enough :)
Signature · 1 line
Alexey
Quoted 61 lines · Alexey Kardashevskiy
Quoted 41 lines · Paolo Bonzini
Il 22/01/2014 05:19, Alexey Kardashevskiy ha scritto:
Quoted 40 lines · Alexey Kardashevskiy
Quoted 37 lines
With the great help from Paolo, I am presenting yet another try of bootindex
support on sPAPR, this time with some QOM fixes. Details are in the commit messages.
Please, comment. Thanks.Alexey Kardashevskiy (5):
boot: extendget_boot_devices_list()to ignore suffixes
spapr-llan: add to boot device list
spapr-vio: fix firmware names
qdev: introduce FWPathProvider interface
spapr: define interface to fix device pathnameHervé Poussineau (1):
qom: detect bad reentrance duringobject_class_foreachPaolo Bonzini (2):
qom: do not register interface "types" in the type table
vl: allow customizing the class of /machinehw/core/Makefile.objs | 1 + hw/core/fw-path-provider.c | 34 ++++++++++++++++++ hw/core/qdev.c | 18 +++++++++- hw/net/spapr_llan.c | 3 ++ hw/nvram/fw_cfg.c | 2 +- hw/ppc/spapr.c | 80 ++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_vio.c | 2 ++ include/hw/boards.h | 1 + include/hw/fw-path-provider.h | 31 +++++++++++++++++ include/sysemu/sysemu.h | 2 +- qom/object.c | 17 +++++++-- tests/Makefile | 1 + vl.c | 11 ++++-- 13 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 hw/core/fw-path-provider.c create mode 100644 include/hw/fw-path-provider.hQuoted 7 lines
Quoted 2 lines
Some bits from this went upstream but none of them is mine. What am I missing here? Thanks.
No idea, perhaps it's because the same patches were present in multiple series? Alex, are you picking up what's left?
Paolo
In the "Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during
object_class_foreach" thread Andreas told me:===
Be patient.1) I am on holidays and thus not available full-time.
2) Alex has already sent out his ppc PULL, so no urgency.
3) As mentioned, I plan to post QOM and CPU PULLs later today.
Quoted 5 lines
And no, you don't need to repost after parts of your series get applied pretty much unmodified.
===So I wonder if I am not just patient enough :)
Nobody seems picking up the bits I am interested in from this :-/ What can I possibly do to get this in upstream?... I feel I am doing something systematically wrong but nobody is telling me what exactly. Thanks.
Signature · 1 line
Alexey
Il 14/02/2014 04:25, Alexey Kardashevskiy ha scritto:
Quoted 3 lines
Nobody seems picking up the bits I am interested in from this :-/ What can I possibly do to get this in upstream?... I feel I am doing something systematically wrong but nobody is telling me what exactly. Thanks.
No, you're not. Ping agraf on IRC if he doesn't answer.
Paolo
Quoted 7 lines · Paolo Bonzini
Il 14/02/2014 04:25, Alexey Kardashevskiy ha scritto:
Quoted 4 lines
Nobody seems picking up the bits I am interested in from this :-/ What can I possibly do to get this in upstream?... I feel I am doing something systematically wrong but nobody is telling me what exactly. Thanks.
No, you're not. Ping agraf on IRC if he doesn't answer.
This almost never helps...
Signature · 1 line
Alexey
Quoted 10 lines · Alexey Kardashevskiy
Quoted 7 lines · Paolo Bonzini
Il 14/02/2014 04:25, Alexey Kardashevskiy ha scritto:
Quoted 4 lines
Nobody seems picking up the bits I am interested in from this :-/ What can I possibly do to get this in upstream?... I feel I am doing something systematically wrong but nobody is telling me what exactly. Thanks.
No, you're not. Ping agraf on IRC if he doesn't answer.
This almost never helps...
Tried. Did not help. Oh.
I also would like to post a patchset adding NMI for ppc64 and since I am not allowed to post yet another #ifdef PPC64 thing, I tried making it an NMI interface for a machine (same as FWPathProvider) but found out that even "qdev: introduce FWPathProvider interface" it is not upstream yet - where is it now and what are the plans about it?
Signature · 1 line
Alexey
Il 20/02/2014 09:37, Alexey Kardashevskiy ha scritto:
Quoted 10 lines · Alexey Kardashevskiy
Quoted 9 lines
Quoted 9 lines · Paolo Bonzini
Quoted 7 lines
Quoted 7 lines
Il 14/02/2014 04:25, Alexey Kardashevskiy ha scritto:
Quoted 4 lines
Quoted 4 lines
Nobody seems picking up the bits I am interested in from this :-/ What can I possibly do to get this in upstream?... I feel I am doing something systematically wrong but nobody is telling me what exactly. Thanks.
No, you're not. Ping agraf on IRC if he doesn't answer.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
This almost never helps...
Tried. Did not help. Oh.
I also would like to post a patchset adding NMI for ppc64 and since I am not allowed to post yet another #ifdef PPC64 thing, I tried making it an NMI interface for a machine (same as FWPathProvider) but found out that even "qdev: introduce FWPathProvider interface" it is not upstream yet - where is it now and what are the plans about it?
Well, that would also be for Alex since the sole user is pseries.
I suggest you just repost the whole series, either Alex or Andreas can pick it up.
Paolo