X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fpci.c;h=1f4976b9438e4326b6f2686d2994e04c618ac6e7;hb=fdb16aa5e99a19a91264ae84beaf77d3036548d5;hp=04d56f3ea5967d2af7cbc08e31e1cfd275c29e8f;hpb=6d6988cc9c8bac21d96afd800076afe0915cf2cd;p=palacios.git diff --git a/palacios/src/devices/pci.c b/palacios/src/devices/pci.c index 04d56f3..1f4976b 100644 --- a/palacios/src/devices/pci.c +++ b/palacios/src/devices/pci.c @@ -611,8 +611,24 @@ static void init_pci_busses(struct pci_internal * pci_state) { static int pci_free(struct pci_internal * pci_state) { + int i; + + + // cleanup devices + for (i = 0; i < PCI_BUS_COUNT; i++) { + struct pci_bus * bus = &(pci_state->bus_list[i]); + struct rb_node * node = v3_rb_first(&(bus->devices)); + struct pci_device * dev = NULL; - // cleanup devices (?) + while (node) { + dev = rb_entry(node, struct pci_device, dev_tree_node); + node = v3_rb_next(node); + + v3_rb_erase(&(dev->dev_tree_node), &(bus->devices)); + V3_Free(dev); + } + + } V3_Free(pci_state); return 0;