From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnqHM-0006ey-TC for qemu-devel@nongnu.org; Tue, 03 Dec 2013 08:44:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnqHG-0002qx-H0 for qemu-devel@nongnu.org; Tue, 03 Dec 2013 08:44:44 -0500 Message-ID: <529DE041.70006@suse.de> Date: Tue, 03 Dec 2013 14:44:33 +0100 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1385364460-24332-1-git-send-email-aik@ozlabs.ru> <1385364460-24332-3-git-send-email-aik@ozlabs.ru> <529DA675.8030705@redhat.com> In-Reply-To: <529DA675.8030705@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/5] machine: introduce get_fw_dev_path() callback List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Alexey Kardashevskiy Cc: qemu-ppc@nongnu.org, Paul Mackerras , qemu-devel@nongnu.org, Nikunj A Dadhania Am 03.12.2013 10:37, schrieb Paolo Bonzini: > Il 25/11/2013 08:27, Alexey Kardashevskiy ha scritto: >> QEMU supports firmware names for all devices in the QEMU tree but >> sometime the exact format differs from what sPAPR platform uses. >> >> This introduces a callback to let a machine fix device tree path names= . >> >> Signed-off-by: Alexey Kardashevskiy >> --- >> hw/core/qdev.c | 15 ++++++++++++++- >> include/hw/boards.h | 1 + >> 2 files changed, 15 insertions(+), 1 deletion(-) >> >> diff --git a/hw/core/qdev.c b/hw/core/qdev.c >> index e374a93..7347483 100644 >> --- a/hw/core/qdev.c >> +++ b/hw/core/qdev.c >> @@ -26,6 +26,7 @@ >> this API directly. */ >> =20 >> #include "hw/qdev.h" >> +#include "hw/boards.h" >> #include "sysemu/sysemu.h" >> #include "qapi/error.h" >> #include "qapi/qmp/qerror.h" >> @@ -497,6 +498,15 @@ static char *bus_get_fw_dev_path(BusState *bus, D= eviceState *dev) >> return NULL; >> } >> =20 >> +static char *machine_get_fw_dev_path(BusState *bus, DeviceState *dev) >> +{ >> + if (current_machine->get_fw_dev_path) { >> + return current_machine->get_fw_dev_path(bus, dev); >> + } >> + >> + return NULL; >> +} >> + >> static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int= size) >> { >> int l =3D 0; >> @@ -504,7 +514,10 @@ static int qdev_get_fw_dev_path_helper(DeviceStat= e *dev, char *p, int size) >> if (dev && dev->parent_bus) { >> char *d; >> l =3D qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p,= size); >> - d =3D bus_get_fw_dev_path(dev->parent_bus, dev); >> + d =3D machine_get_fw_dev_path(dev->parent_bus, dev); >> + if (!d) { >> + d =3D bus_get_fw_dev_path(dev->parent_bus, dev); >> + } >> if (d) { >> l +=3D snprintf(p + l, size - l, "%s", d); >> g_free(d); >> diff --git a/include/hw/boards.h b/include/hw/boards.h >> index 5a7ae9f..50ff24a 100644 >> --- a/include/hw/boards.h >> +++ b/include/hw/boards.h >> @@ -43,6 +43,7 @@ typedef struct QEMUMachine { >> GlobalProperty *compat_props; >> struct QEMUMachine *next; >> const char *hw_version; >> + char *(*get_fw_dev_path)(BusState *bus, DeviceState *dev); >> } QEMUMachine; >> =20 >> int qemu_register_machine(QEMUMachine *m); >> >=20 > You can check "if (current_machine && > current_machine->get_fw_dev_path)", and move current_machine from vl.c > to hw/qdev/core.c. Please don't encourage moving random stuff into "core" device code. If needed, we can easily add a machine.c, but that should remain softmmu-only. Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg