To be able to select a particular SD bus from the command
line, add a QOM alias on the machine (using an unique name).

Suggested-by: Peter Maydell <peter.mayd...@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
---
 hw/arm/xilinx_zynq.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index b72772bc824..6a4a1de88cf 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -286,6 +286,7 @@ static void zynq_init(MachineState *machine)
         DriveInfo *di;
         BlockBackend *blk;
         DeviceState *carddev;
+        g_autofree char *bus_name = NULL;
 
         /* Compatible with:
          * - SD Host Controller Specification Version 2.0 Part A2
@@ -299,6 +300,11 @@ static void zynq_init(MachineState *machine)
         sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, hci_addr);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[hci_irq - IRQ_OFFSET]);
 
+        /* Alias controller SD bus to the machine itself */
+        bus_name = g_strdup_printf("sd-bus%d", n);
+        object_property_add_alias(OBJECT(machine), bus_name,
+                                  OBJECT(dev), "sd-bus");
+
         di = drive_get_next(IF_SD);
         blk = di ? blk_by_legacy_dinfo(di) : NULL;
         carddev = qdev_new(TYPE_SD_CARD);
-- 
2.26.2


Reply via email to