On 09/07/2017 12:35 AM, Thomas Huth wrote: > On 06.09.2017 23:00, Eric Blake wrote: >> On 09/05/2017 04:36 AM, Thomas Huth wrote: >>> On 01.09.2017 20:03, 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). >>>> >>> >>> Why did you remove the check for qs->alloc? >>> >>>> + qs->pcibus = ops->qpci_init(qs->qts, qs->alloc); >> >> Because we want to ensure qpci_init() is called to set qs->qts >> (presumably, whether or not qs->alloc is set). Furthermore, only two >> files declare a 'static QOSOps' structure in the first place >> (libqos-pc.c and libqos-spapr.c); where both files set both the >> .init_allocator and .qpci_init callbacks; a little bit of auditing shows >> that the .init_allocator() never returns NULL (although that requires >> browsing yet more files for malloc-{pc,spapr}.c). > > OK, thanks for the explanation! ... but maybe we should > g_assert(gs->alloc) somewhere instead? ... just an idea, I'm also fine > if you leave it away. Users of QOSOps always supply qs->alloc, but there are tests that successfully use NULL for qs->alloc (because they did not go through QOSOps). At any rate, I can certainly update the commit message. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org