[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/6] ide: Update ide_drive_get to be HBA agnosti
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 4/6] ide: Update ide_drive_get to be HBA agnostic |
Date: |
Wed, 24 Sep 2014 16:35:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
John Snow <address@hidden> writes:
> Instead of duplicating the logic for the if_ide
> (bus,unit) mappings, rely on the blockdev layer
> for managing those mappings for us, and use the
> drive_get_by_index call instead.
>
> This allows ide_drive_get to work for AHCI HBAs
> as well, and can be used in the Q35 initialization.
>
> Signed-off-by: John Snow <address@hidden>
> ---
> hw/ide/core.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/hw/ide/core.c b/hw/ide/core.c
> index 6fba056..1e43d50 100644
> --- a/hw/ide/core.c
> +++ b/hw/ide/core.c
> @@ -2551,13 +2551,15 @@ const VMStateDescription vmstate_ide_bus = {
> void ide_drive_get(DriveInfo **hd, int max_bus)
> {
> int i;
> + int max_devs = if_get_max_devs(IF_IDE) * max_bus;
Okay, here you need if_get_max_devs(). Suggest to move its introduction
from PATCH 2 to this one. Hmm, I guess we better change its name to
start with drive_.
> + int buses = drive_get_max_bus(IF_IDE) + 1;
>
> - if (drive_get_max_bus(IF_IDE) >= max_bus) {
> - fprintf(stderr, "qemu: too many IDE bus: %d\n", max_bus);
> - exit(1);
> + if (buses > max_bus) {
> + fprintf(stderr, "Warning: Too many IDE buses defined (%d > %d)\n",
> + buses, max_bus);
New! Error message now English!
Since you touch it, you could use error_report(). Not important, as
doesn't make much of a difference in this case.
> }
>
> - for(i = 0; i < max_bus * MAX_IDE_DEVS; i++) {
> - hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
> + for (i = 0; i < max_devs; i++) {
> + hd[i] = drive_get_by_index(IF_IDE, i);
> }
> }
Maybe parameter max_bus should be replaced by the number of slots in
hd[]. What do you think?
[Qemu-devel] [PATCH 3/6] pc/vl: Add units-per-default-bus property, John Snow, 2014/09/23
[Qemu-devel] [PATCH 5/6] qtest/bios-tables: Correct Q35 command line, John Snow, 2014/09/23
[Qemu-devel] [PATCH 6/6] q35/ahci: Pick up -cdrom and -hda options, John Snow, 2014/09/23