qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-ppc] [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState wi


From: Thomas Huth
Subject: Re: [Qemu-ppc] [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
Date: Tue, 5 Sep 2017 11:36:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

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).
> 
> Signed-off-by: Eric Blake <address@hidden>
> ---
[...]
> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
> index 6226546c28..c95428e1cb 100644
> --- a/tests/libqos/libqos.c
> +++ b/tests/libqos/libqos.c
> @@ -26,8 +26,8 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, 
> va_list ap)
>          if (ops->init_allocator) {
>              qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
>          }
> -        if (ops->qpci_init && qs->alloc) {
> -            qs->pcibus = ops->qpci_init(qs->alloc);
> +        if (ops->qpci_init) {

Why did you remove the check for qs->alloc?

> +            qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
>          }
>      }
> 
> diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
> index 02ce49927a..85b34c6d13 100644
> --- a/tests/libqos/pci-pc.c
> +++ 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));
> +    ret->bus.qts = qts;
> 
>      ret->bus.pio_readb = qpci_pc_pio_readb;
>      ret->bus.pio_readw = qpci_pc_pio_readw;
> diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
> index 2043f1e123..cd9b8f52d2 100644
> --- a/tests/libqos/pci-spapr.c
> +++ b/tests/libqos/pci-spapr.c
> @@ -154,11 +154,14 @@ static void qpci_spapr_config_writel(QPCIBus *bus, int 
> devfn, uint8_t offset,
>  #define SPAPR_PCI_MMIO32_WIN_SIZE    0x80000000 /* 2 GiB */
>  #define SPAPR_PCI_IO_WIN_SIZE        0x10000
> 
> -QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
> +QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc)
>  {
>      QPCIBusSPAPR *ret;
> 
> +    assert(qts);
> +
>      ret = g_malloc(sizeof(*ret));

+1 for using g_malloc0 here instead.

> +    ret->bus.qts = qts;
> 
>      ret->alloc = alloc;
> 
> @@ -201,6 +204,7 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
>      ret->bus.mmio_alloc_ptr = ret->mmio32.pci_base;
>      ret->bus.mmio_limit = ret->mmio32.pci_base + ret->mmio32.size;
> 
> +

Superfluous white space change.

>      return &ret->bus;
>  }

 Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]