diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2018-11-29 12:37:04 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-03-07 17:28:07 +0100 |
commit | eb5937bad691ed18a401079a0604aa11fea0ecdd (patch) | |
tree | a26310ca140c15230c51cceeebc538f7f55b7888 /tests/ide-test.c | |
parent | 143e6db6fa4ecd2a85de740cc3754aeb86d1e802 (diff) |
tests/libqos: embed allocators instead of malloc-ing them separately
qgraph will embed these objects instead of allocating them in a separate
object. Expose a new API "generic_alloc_init" and "generic_alloc_destroy"
for that, and rename the existing API with s/init/new/ and s/uninit/free/.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/ide-test.c')
-rw-r--r-- | tests/ide-test.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/ide-test.c b/tests/ide-test.c index 46898d96bf..d863a99f7f 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -120,7 +120,7 @@ enum { #define assert_bit_clear(data, mask) g_assert_cmphex((data) & (mask), ==, 0) static QPCIBus *pcibus = NULL; -static QGuestAllocator *guest_malloc; +static QGuestAllocator guest_malloc; static char tmp_path[] = "/tmp/qtest.XXXXXX"; static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX"; @@ -135,7 +135,7 @@ static void ide_test_start(const char *cmdline_fmt, ...) va_end(ap); qtest_start(cmdline); - guest_malloc = pc_alloc_init(global_qtest); + pc_alloc_init(&guest_malloc, global_qtest, 0); g_free(cmdline); } @@ -146,8 +146,7 @@ static void ide_test_quit(void) qpci_free_pc(pcibus); pcibus = NULL; } - pc_alloc_uninit(guest_malloc); - guest_malloc = NULL; + alloc_destroy(&guest_malloc); qtest_end(); } @@ -246,7 +245,7 @@ static int send_dma_request(int cmd, uint64_t sector, int nb_sectors, /* Setup PRDT */ len = sizeof(*prdt) * prdt_entries; - guest_prdt = guest_alloc(guest_malloc, len); + guest_prdt = guest_alloc(&guest_malloc, len); memwrite(guest_prdt, prdt, len); qpci_io_writel(dev, bmdma_bar, bmreg_prdt, guest_prdt); @@ -311,7 +310,7 @@ static void test_bmdma_simple_rw(void) uint8_t *buf; uint8_t *cmpbuf; size_t len = 512; - uintptr_t guest_buf = guest_alloc(guest_malloc, len); + uintptr_t guest_buf = guest_alloc(&guest_malloc, len); PrdtEntry prdt[] = { { @@ -381,7 +380,7 @@ static void test_bmdma_trim(void) const uint64_t bad_range = trim_range_le(TEST_IMAGE_SIZE / 512 - 1, 2); size_t len = 512; uint8_t *buf; - uintptr_t guest_buf = guest_alloc(guest_malloc, len); + uintptr_t guest_buf = guest_alloc(&guest_malloc, len); PrdtEntry prdt[] = { { @@ -625,7 +624,7 @@ static void make_dirty(uint8_t device) dev = get_pci_device(&bmdma_bar, &ide_bar); - guest_buf = guest_alloc(guest_malloc, len); + guest_buf = guest_alloc(&guest_malloc, len); buf = g_malloc(len); memset(buf, rand() % 255 + 1, len); g_assert(guest_buf); @@ -986,7 +985,7 @@ static void test_cdrom_dma(void) "-device ide-cd,drive=sr0,bus=ide.0", tmp_path); qtest_irq_intercept_in(global_qtest, "ioapic"); - guest_buf = guest_alloc(guest_malloc, len); + guest_buf = guest_alloc(&guest_malloc, len); prdt[0].addr = cpu_to_le32(guest_buf); prdt[0].size = cpu_to_le32(len | PRDT_EOT); |