All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v7 0/6] spapr: bootindex support
@ 2014-03-17  2:40 Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 1/6] boot: extend get_boot_devices_list() to ignore suffixes Alexey Kardashevskiy
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Alexey Kardashevskiy @ 2014-03-17  2:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf, Andreas Färber

Rebased on top of 2.0-rc0 so the only change was the way of QEMUMachine's
object creation. Too late/raw/controversial for 2.0? 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
  spapr: QOM'fy machine
  spapr: define interface to fix device pathname

Paolo Bonzini (1):
  qdev: introduce FWPathProvider interface

 hw/core/Makefile.objs         |   1 +
 hw/core/fw-path-provider.c    |  51 ++++++++++++++++++++
 hw/core/qdev.c                |  18 ++++++-
 hw/net/spapr_llan.c           |   3 ++
 hw/nvram/fw_cfg.c             |   2 +-
 hw/ppc/spapr.c                | 108 +++++++++++++++++++++++++++++++++++++++++-
 hw/ppc/spapr_vio.c            |   3 ++
 include/hw/fw-path-provider.h |  47 ++++++++++++++++++
 include/sysemu/sysemu.h       |   2 +-
 tests/Makefile                |   1 +
 vl.c                          |   8 ++--
 11 files changed, 237 insertions(+), 7 deletions(-)
 create mode 100644 hw/core/fw-path-provider.c
 create mode 100644 include/hw/fw-path-provider.h

-- 
1.8.4.rc4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v7 1/6] boot: extend get_boot_devices_list() to ignore suffixes
  2014-03-17  2:40 [Qemu-devel] [PATCH v7 0/6] spapr: bootindex support Alexey Kardashevskiy
@ 2014-03-17  2:40 ` Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 2/6] qdev: introduce FWPathProvider interface Alexey Kardashevskiy
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Alexey Kardashevskiy @ 2014-03-17  2:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf, Andreas Färber

As 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.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
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                    | 8 +++++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index cb36dc2..282341a 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -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);
 }
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index c01304d..3915ce3 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -186,7 +186,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);
 
diff --git a/vl.c b/vl.c
index 842e897..19b4842 100644
--- a/vl.c
+++ b/vl.c
@@ -1206,7 +1206,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;
@@ -1221,7 +1221,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);
@@ -1229,9 +1229,11 @@ 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);
+        } else {
+            bootpath = g_strdup("");
         }
 
         if (total) {
-- 
1.8.4.rc4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v7 2/6] qdev: introduce FWPathProvider interface
  2014-03-17  2:40 [Qemu-devel] [PATCH v7 0/6] spapr: bootindex support Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 1/6] boot: extend get_boot_devices_list() to ignore suffixes Alexey Kardashevskiy
@ 2014-03-17  2:40 ` Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 3/6] spapr-llan: add to boot device list Alexey Kardashevskiy
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Alexey Kardashevskiy @ 2014-03-17  2:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, Paolo Bonzini, qemu-ppc, Alexander Graf,
	Andreas Färber

From: Paolo Bonzini <pbonzini@redhat.com>

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_PROVIDER interface to an object that is above
the device on the QOM tree (typically /machine).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v6:
* fixed "sob" order in the commit message :)
* remove cut-n-paste leftovers

v5:
* fixed code design
* added license headers

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    | 51 +++++++++++++++++++++++++++++++++++++++++++
 hw/core/qdev.c                | 18 ++++++++++++++-
 include/hw/fw-path-provider.h | 47 +++++++++++++++++++++++++++++++++++++++
 tests/Makefile                |  1 +
 5 files changed, 117 insertions(+), 1 deletion(-)
 create mode 100644 hw/core/fw-path-provider.c
 create mode 100644 include/hw/fw-path-provider.h

diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
index 981593c..5377d05 100644
--- a/hw/core/Makefile.objs
+++ b/hw/core/Makefile.objs
@@ -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
 common-obj-y += hotplug.o
diff --git a/hw/core/fw-path-provider.c b/hw/core/fw-path-provider.c
new file mode 100644
index 0000000..b117157
--- /dev/null
+++ b/hw/core/fw-path-provider.c
@@ -0,0 +1,51 @@
+/*
+ *  Firmware patch provider class and helpers.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#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)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9f0a522..cd09cd4 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -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"
@@ -568,6 +569,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;
@@ -575,7 +588,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);
diff --git a/include/hw/fw-path-provider.h b/include/hw/fw-path-provider.h
new file mode 100644
index 0000000..3018349
--- /dev/null
+++ b/include/hw/fw-path-provider.h
@@ -0,0 +1,47 @@
+/*
+ *  Firmware patch provider class and helpers definitions.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#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_obj;
+} FWPathProvider;
+
+typedef struct FWPathProviderClass {
+    InterfaceClass parent_class;
+
+    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 */
diff --git a/tests/Makefile b/tests/Makefile
index 471b4c8..2d021fb 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -206,6 +206,7 @@ tests/test-int128$(EXESUF): tests/test-int128.o
 tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\
 	hw/core/irq.o \
+	hw/core/fw-path-provider.o \
 	$(qom-core-obj) \
 	$(test-qapi-obj-y) \
 	libqemuutil.a libqemustub.a
-- 
1.8.4.rc4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v7 3/6] spapr-llan: add to boot device list
  2014-03-17  2:40 [Qemu-devel] [PATCH v7 0/6] spapr: bootindex support Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 1/6] boot: extend get_boot_devices_list() to ignore suffixes Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 2/6] qdev: introduce FWPathProvider interface Alexey Kardashevskiy
@ 2014-03-17  2:40 ` Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 4/6] spapr-vio: fix firmware names Alexey Kardashevskiy
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Alexey Kardashevskiy @ 2014-03-17  2:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf, Andreas Färber

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 hw/net/spapr_llan.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index f6fbcb5..c433337 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -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;
 }
 
-- 
1.8.4.rc4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v7 4/6] spapr-vio: fix firmware names
  2014-03-17  2:40 [Qemu-devel] [PATCH v7 0/6] spapr: bootindex support Alexey Kardashevskiy
                   ` (2 preceding siblings ...)
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 3/6] spapr-llan: add to boot device list Alexey Kardashevskiy
@ 2014-03-17  2:40 ` Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 5/6] spapr: QOM'fy machine Alexey Kardashevskiy
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 6/6] spapr: define interface to fix device pathname Alexey Kardashevskiy
  5 siblings, 0 replies; 8+ messages in thread
From: Alexey Kardashevskiy @ 2014-03-17  2:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf, Andreas Färber

This 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.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 hw/ppc/spapr_vio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 4e33f46..2ae06a3 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -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 = {
@@ -529,7 +530,9 @@ static int spapr_vio_bridge_init(SysBusDevice *dev)
 static void spapr_vio_bridge_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
+    dc->fw_name = "vdevice";
     k->init = spapr_vio_bridge_init;
 }
 
-- 
1.8.4.rc4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v7 5/6] spapr: QOM'fy machine
  2014-03-17  2:40 [Qemu-devel] [PATCH v7 0/6] spapr: bootindex support Alexey Kardashevskiy
                   ` (3 preceding siblings ...)
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 4/6] spapr-vio: fix firmware names Alexey Kardashevskiy
@ 2014-03-17  2:40 ` Alexey Kardashevskiy
  2014-03-20  0:39   ` Andreas Färber
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 6/6] spapr: define interface to fix device pathname Alexey Kardashevskiy
  5 siblings, 1 reply; 8+ messages in thread
From: Alexey Kardashevskiy @ 2014-03-17  2:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf, Andreas Färber

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v8:
* QOM'ed according to the latest rules from 2.0-rc0.
---
 hw/ppc/spapr.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 5c9a154..43b9fcb 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -81,6 +81,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)
@@ -1416,3 +1418,24 @@ static void spapr_machine_init(void)
 }
 
 machine_init(spapr_machine_init);
+
+static void spapr_machine_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->qemu_machine = data;
+}
+
+static const TypeInfo spapr_machine_info = {
+    .name          = TYPE_SPAPR_MACHINE,
+    .parent        = TYPE_MACHINE,
+    .class_init    = spapr_machine_class_init,
+    .class_data    = &spapr_machine,
+};
+
+static void spapr_machine_register_types(void)
+{
+    type_register_static(&spapr_machine_info);
+}
+
+type_init(spapr_machine_register_types)
-- 
1.8.4.rc4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v7 6/6] spapr: define interface to fix device pathname
  2014-03-17  2:40 [Qemu-devel] [PATCH v7 0/6] spapr: bootindex support Alexey Kardashevskiy
                   ` (4 preceding siblings ...)
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 5/6] spapr: QOM'fy machine Alexey Kardashevskiy
@ 2014-03-17  2:40 ` Alexey Kardashevskiy
  5 siblings, 0 replies; 8+ messages in thread
From: Alexey Kardashevskiy @ 2014-03-17  2:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf, Andreas Färber

This 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), for spapr-vsci, virtio-scsi and usb-storage.

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.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v6:
* moved QOM'fication piece to a separate patch

v5:
* addev virtio and usb handling

v2:
* added special handling for virtio-scsi and USB as they use different
LUN encoding in SLOF
---
 hw/ppc/spapr.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 84 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 43b9fcb..553b5a1 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -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,8 @@
 #include "hw/pci/msi.h"
 
 #include "hw/pci/pci.h"
+#include "hw/scsi/scsi.h"
+#include "hw/virtio/virtio-scsi.h"
 
 #include "exec/address-spaces.h"
 #include "hw/usb.h"
@@ -600,7 +603,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;
 
@@ -642,6 +647,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);
     }
@@ -1419,11 +1439,70 @@ 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) {
+        void *spapr = CAST(void, bus->parent, "spapr-vscsi");
+        VirtIOSCSI *virtio = CAST(VirtIOSCSI, bus->parent, TYPE_VIRTIO_SCSI);
+        USBDevice *usb = CAST(USBDevice, bus->parent, TYPE_USB_DEVICE);
+
+        if (spapr) {
+            /*
+             * 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->id << 8) | d->lun;
+            return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
+                                   (uint64_t)id << 48);
+        } else if (virtio) {
+            /*
+             * We use SRP luns of the form 01000000 | (target << 8) | lun
+             * in the top 32 bits of the 64-bit LUN
+             * Note: the quote above is from SLOF and it is wrong,
+             * the actual binding is:
+             * swap 0100 or 10 << or 20 << ( target lun-id -- srplun )
+             */
+            unsigned id = 0x1000000 | (d->id << 16) | d->lun;
+            return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
+                                   (uint64_t)id << 32);
+        } else if (usb) {
+            /*
+             * We use SRP luns of the form 01000000 | (usb-port << 16) | lun
+             * in the top 32 bits of the 64-bit LUN
+             */
+            unsigned usb_port = atoi(usb->port->path);
+            unsigned id = 0x1000000 | (usb_port << 16) | d->lun;
+            return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
+                                   (uint64_t)id << 32);
+        }
+    }
+
+    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)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
+    FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc);
 
     mc->qemu_machine = data;
+    fwc->get_dev_path = spapr_get_fw_dev_path;
 }
 
 static const TypeInfo spapr_machine_info = {
@@ -1431,6 +1510,10 @@ static const TypeInfo spapr_machine_info = {
     .parent        = TYPE_MACHINE,
     .class_init    = spapr_machine_class_init,
     .class_data    = &spapr_machine,
+    .interfaces = (InterfaceInfo[]) {
+            { TYPE_FW_PATH_PROVIDER },
+            { }
+    }
 };
 
 static void spapr_machine_register_types(void)
-- 
1.8.4.rc4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v7 5/6] spapr: QOM'fy machine
  2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 5/6] spapr: QOM'fy machine Alexey Kardashevskiy
@ 2014-03-20  0:39   ` Andreas Färber
  0 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2014-03-20  0:39 UTC (permalink / raw)
  To: Alexey Kardashevskiy, qemu-devel; +Cc: qemu-ppc, Alexander Graf

Am 17.03.2014 03:40, schrieb Alexey Kardashevskiy:
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> Changes:
> v8:
> * QOM'ed according to the latest rules from 2.0-rc0.

Fixing up as follows:

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 43b9fcb..170e083 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -81,7 +81,7 @@

 #define HTAB_SIZE(spapr)        (1ULL << ((spapr)->htab_shift))

-#define TYPE_SPAPR_MACHINE      "machine-spapr"
+#define TYPE_SPAPR_MACHINE      "spapr-machine"

 sPAPREnvironment *spapr;

@@ -1412,13 +1412,6 @@ static QEMUMachine spapr_machine = {
     .kvm_type = spapr_kvm_type,
 };

-static void spapr_machine_init(void)
-{
-    qemu_register_machine(&spapr_machine);
-}
-
-machine_init(spapr_machine_init);
-
 static void spapr_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-03-20  0:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-17  2:40 [Qemu-devel] [PATCH v7 0/6] spapr: bootindex support Alexey Kardashevskiy
2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 1/6] boot: extend get_boot_devices_list() to ignore suffixes Alexey Kardashevskiy
2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 2/6] qdev: introduce FWPathProvider interface Alexey Kardashevskiy
2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 3/6] spapr-llan: add to boot device list Alexey Kardashevskiy
2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 4/6] spapr-vio: fix firmware names Alexey Kardashevskiy
2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 5/6] spapr: QOM'fy machine Alexey Kardashevskiy
2014-03-20  0:39   ` Andreas Färber
2014-03-17  2:40 ` [Qemu-devel] [PATCH v7 6/6] spapr: define interface to fix device pathname Alexey Kardashevskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.