1. 16 8月, 2018 1 次提交
    • M
      tests: Clean up string interpolation into QMP input (simple cases) · 015715f5
      Markus Armbruster 提交于
      When you build QMP input manually like this
      
          cmd = g_strdup_printf("{ 'execute': 'migrate',"
                                "'arguments': { 'uri': '%s' } }",
                                uri);
          rsp = qmp(cmd);
          g_free(cmd);
      
      you're responsible for escaping the interpolated values for JSON.  Not
      done here, and therefore works only for sufficiently nice @uri.  For
      instance, if @uri contained a single "'", qobject_from_vjsonf_nofail()
      would abort.  A sufficiently nasty @uri could even inject unwanted
      members into the arguments object.
      
      Leaving interpolation into JSON to qmp() is more robust:
      
          rsp = qmp("{ 'execute': 'migrate', 'arguments': { 'uri': %s } }", uri);
      
      It's also more concise.
      
      Clean up the simple cases where we interpolate exactly a JSON value.
      
      Bonus: gets rid of non-literal format strings.  A step towards
      compile-time format string checking without triggering
      -Wformat-nonliteral.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20180806065344.7103-13-armbru@redhat.com>
      015715f5
  2. 04 5月, 2018 1 次提交
  3. 14 2月, 2018 2 次提交
    • E
      libqos: Track QTestState with QPCIBus · e5d1730d
      Eric Blake 提交于
      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: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NThomas 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: NThomas Huth <thuth@redhat.com>
      e5d1730d
    • M
      tests: Clean up wait for event · 2c58c27b
      Markus Armbruster 提交于
      We still use hacks like qmp("") to wait for an event, even though we
      have qmp_eventwait() since commit 8fe941f7, and qmp_eventwait_ref()
      since commit 7ffe3124.  Both commits neglected to convert all the
      existing hacks.  Make up what they missed.
      
      Bonus: gets rid of empty format strings.  A step towards compile-time
      format string checking without triggering -Wformat-zero-length.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      [thuth: dropped the hunks from the usb tests - not needed anymore]
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      2c58c27b
  4. 09 2月, 2018 1 次提交
  5. 28 10月, 2016 5 次提交
    • D
      libqos: Add 64-bit PCI IO accessors · f775f45a
      David Gibson 提交于
      Currently the libqos PCI layer includes accessor helpers for 8, 16 and 32
      bit reads and writes.  It's likely that we'll want 64-bit accesses in the
      future (plenty of modern peripherals will have 64-bit reigsters).  This
      adds them.
      
      For PIO (not MMIO) accesses on the PC backend, this is implemented as two
      32-bit ins or outs.  That's not ideal but AFAICT x86 doesn't have 64-bit
      versions of in and out.
      
      This patch also converts the single current user of 64-bit accesses -
      virtio-pci.c to use the new mechanism, rather than a sequence of 8 byte
      reads.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      f775f45a
    • D
      libqos: Implement mmio accessors in terms of mem{read,write} · 352d664c
      David Gibson 提交于
      In the libqos PCI code we now have accessors both for registers (byte
      significance preserving) and for streaming data (byte address order
      preserving).  These exist in both the interface for qtest drivers and in
      the machine specific backends.
      
      However, the register-style accessors aren't actually necessary in the
      backend.  They can be implemented in terms of the byte address order
      preserving accessors by the libqos wrappers.  This works because PCI is
      always little endian.
      
      This does assume that the back end byte address order preserving accessors
      will perform the equivalent of a single bus transaction for short lengths.
      This is the case, and in fact they currently end up using the same
      cpu_physical_memory_rw() implementation within the qtest accelerator.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      352d664c
    • D
      libqos: Add streaming accessors for PCI MMIO · 9a84f889
      David Gibson 提交于
      Currently PCI memory (aka MMIO) space is accessed via a set of readb/writeb
      style accessors.  This is what we want for accessing discrete registers of
      a certain size.  However, there are a few cases where we instead need a
      "bag of bytes" style streaming interface to PCI MMIO space.  This can be
      either for streaming data style registers or when there's actual memory
      rather than registers in PCI space, for example frame buffers or ivshmem.
      
      This patch adds backend callbacks, and libqos wrappers for this type of
      byte address order preserving accesses.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      9a84f889
    • D
      libqos: Move BAR assignment to common code · b8cc4d02
      David Gibson 提交于
      The PCI backends in libqos each supply an iomap() and iounmap() function
      which is used to set up a specified PCI BAR.  But PCI BAR allocation takes
      place entirely within PCI space, so doesn't really need per-backend
      versions.  For example, Linux includes generic BAR allocation code used on
      platforms where that isn't done by firmware.
      
      This patch merges the BAR allocation from the two existing backends into a
      single simplified copy.  The back ends just need to set up some parameters
      describing the window of PCI IO and PCI memory addresses which are
      available for allocation.  Like both the existing versions the new one uses
      a simple bump allocator.
      
      Note that (again like the existing versions) this doesn't really handle
      64-bit memory BARs properly.  It is actually used for such a BAR by the
      ivshmem test, and apparently the 32-bit MMIO BAR logic is close enough to
      work, as long as the BAR isn't too big.  Fixing that to properly handle
      64-bit BAR allocation is a problem for another time.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      b8cc4d02
    • D
      libqos: Handle PCI IO de-multiplexing in common code · a795fc08
      David Gibson 提交于
      The PCI IO space (aka PIO, aka legacy IO) and PCI memory space (aka MMIO)
      are distinct address spaces by the PCI spec (although parts of one might be
      aliased to parts of the other in some cases).
      
      However, qpci_io_read*() and qpci_io_write*() can perform accesses to
      either space depending on parameter.  That's convenient for test case
      drivers, since there are a fair few devices which can be controlled via
      either a PIO or MMIO BAR but with an otherwise identical driver.
      
      This is implemented by having addresses below 64kiB treated as PIO, and
      those above treated as MMIO.  This works because low addresses in memory
      space are generally reserved for DMA rather than MMIO.
      
      At the moment, this demultiplexing must be handled by each PCI backend
      (pc and spapr, so far).  There's no real reason for this - the current
      encoding is likely to work for all platforms, and even if it doesn't we
      can still use a more complex common encoding since the value returned from
      iomap are semi-opaque.
      
      This patch moves the demultiplexing into the common part of the libqos PCI
      code, with the backends having simpler, separate accessors for PIO and
      MMIO space.  This also means we have a way of explicitly accessing either
      space if it's necessary for some special case.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      a795fc08
  6. 06 10月, 2016 2 次提交
  7. 07 6月, 2016 1 次提交
  8. 22 3月, 2016 1 次提交
    • M
      tests/libqos/pci-pc: Fix qpci_pc_iomap() to map BARs aligned · 99826172
      Markus Armbruster 提交于
      qpci_pc_iomap() maps BARs one after the other, without padding.  This
      is wrong.  PCI Local Bus Specification Revision 3.0, 6.2.5.1. Address
      Maps: "all address spaces used are a power of two in size and are
      naturally aligned".  That's because the size of a BAR is given by the
      number of address bits the device decodes, and the BAR needs to be
      mapped at a multiple of that size to ensure the address decoding
      works.
      
      Fix qpci_pc_iomap() accordingly.  This takes care of a FIXME in
      ivshmem-test.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-7-git-send-email-armbru@redhat.com>
      99826172
  9. 16 2月, 2016 1 次提交
  10. 15 10月, 2014 1 次提交
  11. 16 8月, 2014 2 次提交
  12. 15 7月, 2014 1 次提交
    • A
      libqos: Fix PC PCI endianness glitches · 0e162974
      Andreas Färber 提交于
      The libqos implementation of io_read{b,w,l} and io_write{b,w,l} hooks
      was relying on qtest_mem{read,write}() respectively. With d81d4106 (usb:
      improve ehci/uhci test) this resulted in assertion failures on ppc hosts:
      
       ERROR:tests/usb-hcd-ehci-test.c:78:ehci_port_test: assertion failed: ((value & mask) == (expect & mask))
      
       ERROR:tests/usb-hcd-ehci-test.c:128:pci_uhci_port_2: assertion failed: (pcibus != NULL)
      
       ERROR:tests/usb-hcd-ehci-test.c:150:pci_ehci_port_2: assertion failed: (pcibus != NULL)
      
      qtest_read{b,w,l,q}() and qtest_write{b,w,l,q}() had been introduced
      as endian-safe replacement for qtest_mem{read,write}() in I2C in
      872536bf (qtest: Add MMIO support). Use them for PCI as well.
      
      Cc: Anthony Liguori <aliguori@amazon.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Fixes: c4efe1ca qtest: add libqos including PCI support
      Fixes: d81d4106 usb: improve ehci/uhci test
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      0e162974
  13. 27 3月, 2014 1 次提交
  14. 17 4月, 2013 1 次提交