On 09/15/2011 01:31 AM, Gleb Natapov wrote:
On Wed, Sep 14, 2011 at 01:04:00PM -0500, Anthony Liguori wrote:
All device relationships are identified as named properties. A QOM
path name
consists of a named device, followed by a series of properties which
may or may
not refer to other devices. For instance, all of the following are
valid paths:
/i440fx/piix3/i8042/aux
/i440fx/slot[1.0]/i8042/aux
/i440fx/slot[1.0]/bus/piix3/i8042/aux
Have you looked at device paths generated by get_fw_dev_path() in qdev?
This function generates Open Firmware device path. The difference
between OF device path and the examples above is that OF device path has
a meaning outside of QEMU and can be used by firmware to find a device
a path refers too. Will QOM be able to generate them?
The paths look like:
/pci@i0cf8/ide@1,1/drive@1/disk@0
/pci@i0cf8/isa@1/fdc@03f1/floppy@1
/pci@i0cf8/isa@1/fdc@03f1/floppy@0
/pci@i0cf8/ide@1,1/drive@1/disk@1
/pci@i0cf8/ide@1,1/drive@0/disk@0
/pci@i0cf8/scsi@3/disk@0,0
/pci@i0cf8/ethernet@4/ethernet-phy@0
/pci@i0cf8/ethernet@5/ethernet-phy@0
/pci@i0cf8/ide@1,1/drive@0/disk@1
/pci@i0cf8/isa@1/ide@01e8/drive@0/disk@0
/pci@i0cf8/usb@1,2/network@0/ethernet@0
/pci@i0cf8/usb@1,2/hub@1/network@0/ethernet@0
/rom@genroms/linuxboot.bin
For isa machines:
/isa/ide@0170/drive@0/disk@0
/isa/fdc@03f1/floppy@1
/isa/fdc@03f1/floppy@0
/isa/ide@0170/drive@0/disk@1
A critical point that I neglected to previously mention is that while qdev has a
canonical path (only one path, really) to address a device, QOM does not. That
means a different approach is needed to make the graph look like a tree as OF
requires.
You need something like this:
void generate_tree(Device *node)
{
if (IS_PCI_BUS(node)) {
for (i = 0; i < 32; i++) {
generate_tree(lookup_device(get_property(node, "slot[%d]", i)));
}
} else if (IS_ISA_BUS(node)) {
....
} else {
// leaf node, generate path segment
}
}
There are certainly ways to walk the graph generically (by coloring or following
the composition paths) but that won't give you the desired ordering.
Regards,
Anthony Liguori
}
--
Gleb.