Re: [Qemu-devel] [PATCHv2 4/8] Store IDE bus id in IDEBus structure for easy access.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's a generic answer to the question "which of the device's buses is
this?"

int qbus_index(BusState *bus)
{
    BusState *b;
    int i, index;

    index = -1;
    i = 0;
    QLIST_FOREACH(b, &bus->parent->child_bus, sibling) {
        if (b == bus) {
            index = i;
        }
        i++;
    }
    assert(0 <= index && index < i);
    return i - 1 - index;
}

The bus created first has index 0.

Note that the child_bus holds the children in reverse creation order,
and we can't traverse it backwards.  Same problem also visible with
makes info qtree:

      dev: piix3-ide, id ""
[...]
        bus: ide.1
          type IDE
        bus: ide.0
          type IDE
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux