提交 4f43c1ff 编写于 作者: A Alex Williamson 提交者: Anthony Liguori

pci: Implement BusInfo.get_dev_path()

This works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquely
describes a global address.  No need to traverse up the qdev tree.
PCI segment support is a placeholder for compatibility once we
support multiple segments.
Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 6772b936
...@@ -58,11 +58,13 @@ struct PCIBus { ...@@ -58,11 +58,13 @@ struct PCIBus {
}; };
static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent); static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
static char *pcibus_get_dev_path(DeviceState *dev);
static struct BusInfo pci_bus_info = { static struct BusInfo pci_bus_info = {
.name = "PCI", .name = "PCI",
.size = sizeof(PCIBus), .size = sizeof(PCIBus),
.print_dev = pcibus_dev_print, .print_dev = pcibus_dev_print,
.get_dev_path = pcibus_get_dev_path,
.props = (Property[]) { .props = (Property[]) {
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
...@@ -1853,6 +1855,18 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) ...@@ -1853,6 +1855,18 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
} }
} }
static char *pcibus_get_dev_path(DeviceState *dev)
{
PCIDevice *d = (PCIDevice *)dev;
char path[16];
snprintf(path, sizeof(path), "%04x:%02x:%02x.%x",
pci_find_domain(d->bus), d->config[PCI_SECONDARY_BUS],
PCI_SLOT(d->devfn), PCI_FUNC(d->devfn));
return strdup(path);
}
static PCIDeviceInfo bridge_info = { static PCIDeviceInfo bridge_info = {
.qdev.name = "pci-bridge", .qdev.name = "pci-bridge",
.qdev.size = sizeof(PCIBridge), .qdev.size = sizeof(PCIBridge),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册