On 09/01/2017 02:20 PM, Philippe Mathieu-Daudé wrote: > Hi Eric, > > On 09/01/2017 03:03 PM, Eric Blake wrote: >> 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). >> >> +++ b/tests/libqos/pci-pc.c >> @@ -115,11 +115,14 @@ static void qpci_pc_config_writel(QPCIBus *bus, >> int devfn, uint8_t offset, uint3 >>       outl(0xcfc, value); >>   } >> >> -QPCIBus *qpci_init_pc(QGuestAllocator *alloc) >> +QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc) >>   { >>       QPCIBusPC *ret; >> >> +    assert(qts); >> + >>       ret = g_malloc(sizeof(*ret)); > > I'd rather use g_malloc0() here (safer!) Pre-existing, but yes, I can touch it while in the area. > >> +    ret->bus.qts = qts; >> >>       ret->bus.pio_readb = qpci_pc_pio_readb; >>       ret->bus.pio_readw = qpci_pc_pio_readw; > > or init qts field in same order than struct: Okay. > > Either ways: > Reviewed-by: Philippe Mathieu-Daudé > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org