diff options
author | John Snow | 2015-02-05 18:41:28 +0100 |
---|---|---|
committer | Stefan Hajnoczi | 2015-02-16 16:07:17 +0100 |
commit | 259342d34dbdfb304374f569feec26317edd97c9 (patch) | |
tree | 38487465cbf6252fe1ee0b8214471184d932c78d /tests/libqos/ahci.c | |
parent | libqos/ahci: add ahci_io (diff) | |
download | qemu-259342d34dbdfb304374f569feec26317edd97c9.tar.gz qemu-259342d34dbdfb304374f569feec26317edd97c9.tar.xz qemu-259342d34dbdfb304374f569feec26317edd97c9.zip |
libqos/ahci: Add ahci_clean_mem
Clean up guest memory being used in ahci_clean_mem, to be
called during ahci_shutdown. With all guest memory leaks removed,
add an option to the allocator to throw an assertion if a leak
occurs.
This test adds some sanity to both the AHCI library and the
allocator.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1423158090-25580-18-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/libqos/ahci.c')
-rw-r--r-- | tests/libqos/ahci.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c index 85222248b6..a6105c750f 100644 --- a/tests/libqos/ahci.c +++ b/tests/libqos/ahci.c @@ -130,6 +130,24 @@ void free_ahci_device(QPCIDevice *dev) qpci_free_pc(pcibus); } +/* Free all memory in-use by the AHCI device. */ +void ahci_clean_mem(AHCIQState *ahci) +{ + uint8_t port, slot; + + for (port = 0; port < 32; ++port) { + if (ahci->port[port].fb) { + ahci_free(ahci, ahci->port[port].fb); + } + if (ahci->port[port].clb) { + for (slot = 0; slot < 32; slot++) { + ahci_destroy_command(ahci, port, slot); + } + ahci_free(ahci, ahci->port[port].clb); + } + } +} + /*** Logical Device Initialization ***/ /** |