diff mbox

[2/2] ide: Fix bootindex for bus_id > 9

Message ID 1408102357-914-3-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Aug. 15, 2014, 11:32 a.m. UTC
We identify devices by their Open Firmware device paths.  The encoding
of bus numbers is incorrect: idebus_get_fw_dev_path() formats them in
decimal, while SeaBIOS uses hexadecimal.  With bus number > 9, SeaBIOS
will miss the bootindex (lucky case), or apply it to another device
(unlucky case).

Bug can't bite right now: ich9-ahci has six ports, and the sysbus-ahci
created by Calxeda Highbank has just one.

Fix it anyway, by changing %d to %x.

I couldn't find an Open Firmware spec covering this.  For what it's
worth, OVMF agrees with SeaBIOS.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ide/qdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Hajnoczi Aug. 26, 2014, 10:51 a.m. UTC | #1
On Fri, Aug 15, 2014 at 01:32:37PM +0200, Markus Armbruster wrote:
> We identify devices by their Open Firmware device paths.  The encoding
> of bus numbers is incorrect: idebus_get_fw_dev_path() formats them in
> decimal, while SeaBIOS uses hexadecimal.  With bus number > 9, SeaBIOS
> will miss the bootindex (lucky case), or apply it to another device
> (unlucky case).
> 
> Bug can't bite right now: ich9-ahci has six ports, and the sysbus-ahci
> created by Calxeda Highbank has just one.
> 
> Fix it anyway, by changing %d to %x.
> 
> I couldn't find an Open Firmware spec covering this.  For what it's
> worth, OVMF agrees with SeaBIOS.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/ide/qdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
diff mbox

Patch

diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 6e475e6..9c4d221 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -59,7 +59,7 @@  static char *idebus_get_fw_dev_path(DeviceState *dev)
 {
     char path[30];
 
-    snprintf(path, sizeof(path), "%s@%d", qdev_fw_name(dev),
+    snprintf(path, sizeof(path), "%s@%x", qdev_fw_name(dev),
              ((IDEBus*)dev->parent_bus)->bus_id);
 
     return g_strdup(path);