Commit e5d1730d authored by Eric Blake's avatar Eric Blake Committed by Thomas Huth
Browse files

libqos: Track QTestState with QPCIBus



When initializing a QPCIBus, track which QTestState the bus is
associated with (so that a later patch can then explicitly use
that test state for all communication on the bus, rather than
blindly relying on global_qtest).  Update the initialization
functions to take another parameter, and update all callers to
pass in state (for now, most callers get away with passing the
current global_qtest as the current state, although this required
fixing the order of initialization to ensure qtest_start() is
called before qpci_init*() in rtl8139-test, and provided an
opportunity to pass in the allocator in e1000e-test).

Touch up some allocations to use g_new0() rather than g_malloc()
while in the area, and simplify some code (all implementations
of QOSOps provide a .init_allocator() that never fails).

Signed-off-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
[thuth: Removed hunk from vhost-user-test.c that is not required anymore,
 fixed conflict in qtest_vboot() and adjusted qpci_init_pc() in sdhci-test]
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
parent 50990b16
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ static AHCIQState *ahci_vboot(const char *cli, va_list ap)
    alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT);

    /* Verify that we have an AHCI device present. */
    s->dev = get_ahci_device(&s->fingerprint);
    s->dev = get_ahci_device(s->parent->qts, &s->fingerprint);

    return s;
}
+3 −3
Original line number Diff line number Diff line
@@ -392,12 +392,12 @@ static void data_test_init(e1000e_device *d)
    qtest_start(cmdline);
    g_free(cmdline);

    test_bus = qpci_init_pc(NULL);
    g_assert_nonnull(test_bus);

    test_alloc = pc_alloc_init();
    g_assert_nonnull(test_alloc);

    test_bus = qpci_init_pc(global_qtest, test_alloc);
    g_assert_nonnull(test_bus);

    e1000e_device_init(test_bus, d);
}

+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ static QPCIBus *test_start_get_bus(const TestData *s)
    cmdline = g_strdup_printf("-smp %d", s->num_cpus);
    qtest_start(cmdline);
    g_free(cmdline);
    return qpci_init_pc(NULL);
    return qpci_init_pc(global_qtest, NULL);
}

static void test_i440fx_defaults(gconstpointer opaque)
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ static QPCIDevice *get_pci_device(QPCIBar *bmdma_bar, QPCIBar *ide_bar)
    uint16_t vendor_id, device_id;

    if (!pcibus) {
        pcibus = qpci_init_pc(NULL);
        pcibus = qpci_init_pc(global_qtest, NULL);
    }

    /* Find PCI device and verify it's the right one */
+2 −2
Original line number Diff line number Diff line
@@ -123,13 +123,13 @@ bool is_atapi(AHCIQState *ahci, uint8_t port)
/**
 * Locate, verify, and return a handle to the AHCI device.
 */
QPCIDevice *get_ahci_device(uint32_t *fingerprint)
QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint)
{
    QPCIDevice *ahci;
    uint32_t ahci_fingerprint;
    QPCIBus *pcibus;

    pcibus = qpci_init_pc(NULL);
    pcibus = qpci_init_pc(qts, NULL);

    /* Find the AHCI PCI device and verify it's the right one. */
    ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02));
Loading