All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, John Snow <jsnow@redhat.com>,
	armbru@redhat.com, stefanha@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 4/6] ide: Update ide_drive_get to be HBA agnostic
Date: Tue, 23 Sep 2014 12:48:03 -0400	[thread overview]
Message-ID: <1411490885-29782-5-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1411490885-29782-1-git-send-email-jsnow@redhat.com>

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 <jsnow@redhat.com>
---
 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;
+    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);
     }
 
-    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);
     }
 }
-- 
1.9.3

  parent reply	other threads:[~2014-09-23 16:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 16:47 [Qemu-devel] [PATCH 0/6] Q35: Implement -cdrom/-hda sugar John Snow
2014-09-23 16:48 ` [Qemu-devel] [PATCH 1/6] blockdev: Orphaned drive search John Snow
2014-09-24 14:06   ` Markus Armbruster
2014-09-24 22:36     ` John Snow
2014-09-23 16:48 ` [Qemu-devel] [PATCH 2/6] blockdev: Allow overriding if_max_dev property John Snow
2014-09-24 14:10   ` Markus Armbruster
2014-09-23 16:48 ` [Qemu-devel] [PATCH 3/6] pc/vl: Add units-per-default-bus property John Snow
2014-09-24 14:25   ` Markus Armbruster
2014-09-23 16:48 ` John Snow [this message]
2014-09-24 14:35   ` [Qemu-devel] [PATCH 4/6] ide: Update ide_drive_get to be HBA agnostic Markus Armbruster
2014-09-24 16:49     ` John Snow
2014-09-25  6:13       ` Markus Armbruster
2014-09-26 16:34         ` John Snow
2014-09-27  8:41           ` Markus Armbruster
2014-09-23 16:48 ` [Qemu-devel] [PATCH 5/6] qtest/bios-tables: Correct Q35 command line John Snow
2014-09-23 16:48 ` [Qemu-devel] [PATCH 6/6] q35/ahci: Pick up -cdrom and -hda options John Snow
2014-09-24 15:08   ` Markus Armbruster
2014-09-24 15:30     ` Markus Armbruster
2014-09-24 15:32 ` [Qemu-devel] [PATCH 0/6] Q35: Implement -cdrom/-hda sugar Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411490885-29782-5-git-send-email-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.