Message ID | 517E9F94.4010302@greensocs.com |
---|---|
State | New |
Headers | show |
Il 29/04/2013 18:28, KONRAD Frédéric ha scritto: >>> >> Could this be simply a qdev property? > > Yes, that can be a good idea. > > What about adding a qdev property bus_name and using it in qbus_realize? > > Like this: > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index 4eb0134..c5d5407 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -421,6 +421,13 @@ static void qbus_realize(BusState *bus, DeviceState > *parent, const char *name) > > if (name) { > bus->name = g_strdup(name); > + } else if (bus->parent && bus->parent->bus_name) { > + /* parent device has bus_name -> use it for bus name */ > + len = strlen(bus->parent->bus_name) + 16; > + buf = g_malloc(len); > + snprintf(buf, len, "%s.%d", bus->parent->bus_name, > + bus->parent->num_child_bus); > + bus->name = buf; > } else if (bus->parent && bus->parent->id) { > /* parent device has id -> use it for bus name */ > len = strlen(bus->parent->id) + 16; > > If so, change to scsi_bus_new is not needed and the two new functions are > not needed. > > Is that making sense? Ah, that's a bit more extreme. :) I think I like it, but I need more input. Paolo
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 4eb0134..c5d5407 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -421,6 +421,13 @@ static void qbus_realize(BusState *bus, DeviceState *parent, const char *name) if (name) { bus->name = g_strdup(name); + } else if (bus->parent && bus->parent->bus_name) { + /* parent device has bus_name -> use it for bus name */ + len = strlen(bus->parent->bus_name) + 16; + buf = g_malloc(len); + snprintf(buf, len, "%s.%d", bus->parent->bus_name, + bus->parent->num_child_bus); + bus->name = buf; } else if (bus->parent && bus->parent->id) { /* parent device has id -> use it for bus name */