qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99
@ 2019-01-14 10:01 Thomas Huth
  2019-01-14 10:01 ` [Qemu-devel] [PULL 01/25] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device Thomas Huth
                   ` (25 more replies)
  0 siblings, 26 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:01 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

 Hi Peter,

the following changes since commit 27df21ca3886fff4dd3d70e515517667963a52f1:

  Merge remote-tracking branch 'remotes/kraxel/tags/misc-20190111-pull-request' into staging (2019-01-11 16:45:59 +0000)

are available in the git repository at:

  https://gitlab.com/huth/qemu.git tags/pull-request-2019-01-14

for you to fetch changes up to 62c36a5f7cad3048bfc41ac24c0593f466b408f4:

  tests/hexloader-test: Don't pass -nographic to the QEMU under test (2019-01-14 10:50:40 +0100)

----------------------------------------------------------------
- Remove deprecated "ivshmem" legacy device
- Bug fix for vhost-user-test
- Use more CONFIG Makefile switches for qtests
- Get rid of global_qtests in some more qtests
- typedef cleanups
- Fixes for compiling with Clang
- Force C standard to gnu99
----------------------------------------------------------------

Li Qiang (3):
      tests: vhost-user-test: initialize 'fd' in chr_read
      vhost-user: fix ioeventfd_enabled
      util: check the return value of fcntl in qemu_set_{block, nonblock}

Peter Maydell (1):
      tests/hexloader-test: Don't pass -nographic to the QEMU under test

Philippe Mathieu-Daudé (11):
      hw/input/ps2: Remove PS2State from "qemu/typedefs.h"
      hw/pcmcia: Remove PCMCIACardState from "qemu/typedefs.h"
      hw/ssi: Remove SSIBus from "qemu/typedefs.h"
      hw/ide/ahci: Remove AllwinnerAHCIState from "qemu/typedefs.h"
      hw/i2c/smbus: Remove SMBusDevice from "qemu/typedefs.h"
      hw/bt: Remove HCIInfo from "qemu/typedefs.h"
      hw/char/serial: Remove SerialState from "qemu/typedefs.h"
      hw/i386: Remove PCMachineClass from "qemu/typedefs.h"
      audio: Remove AudioState from "qemu/typedefs.h"
      ui/console: Remove QemuDmaBuf from "qemu/typedefs.h"
      ui/console: Remove DisplayState/DisplaySurface from "qemu/typedefs.h"

Thomas Huth (10):
      hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device
      tests/Makefile: Use some more CONFIG switches for x86 tests
      tests/Makefile: Use some more CONFIG switches for ppc tests
      tests/endianesss: Make test independent of global_qtest
      tests/boot-order: Make test independent of global_qtest
      tests/pnv-xscom: Make test independent of global_qtest
      linux-user: Fix compilation with clang 3.4
      ppc: Move spapr-related prototypes from xics.h into a seperate header file
      ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode
      configure: Force the C standard to gnu99

 audio/audio_int.h           |   4 +-
 configure                   |   5 +-
 docs/specs/ivshmem-spec.txt |   8 +-
 hw/arm/strongarm.h          |   1 +
 hw/i386/pc_piix.c           |   1 -
 hw/intc/xics_kvm.c          |   1 +
 hw/intc/xics_spapr.c        |   1 +
 hw/misc/ivshmem.c           | 210 +---------------------------
 hw/ppc/spapr_irq.c          |   1 +
 hw/virtio/vhost-user.c      |   2 +-
 include/hw/arm/pxa.h        |   2 +
 include/hw/char/serial.h    |   4 +-
 include/hw/i2c/smbus.h      |   2 +
 include/hw/i386/pc.h        |   4 +-
 include/hw/ide/ahci.h       |   4 +-
 include/hw/input/ps2.h      |   2 +
 include/hw/pcmcia.h         |   4 +-
 include/hw/ppc/spapr.h      |   5 +-
 include/hw/ppc/spapr_xive.h |   2 -
 include/hw/ppc/xics.h       |   7 -
 include/hw/ppc/xics_spapr.h |  37 +++++
 include/hw/ssi/pl022.h      |   1 +
 include/hw/ssi/ssi.h        |   1 +
 include/qemu/compiler.h     |   4 +
 include/qemu/typedefs.h     |  12 --
 include/sysemu/bt.h         |   4 +-
 include/ui/console.h        |  10 +-
 linux-user/qemu.h           |   6 +-
 qemu-deprecated.texi        |   5 -
 scripts/device-crash-test   |   1 -
 target/ppc/cpu.h            |  13 +-
 tests/Makefile.include      |  22 +--
 tests/boot-order-test.c     |  59 ++++----
 tests/endianness-test.c     | 329 ++++++++++++++++++++++----------------------
 tests/hexloader-test.c      |   2 +-
 tests/ivshmem-test.c        |  67 ++++-----
 tests/pnv-xscom-test.c      |  29 ++--
 tests/vhost-user-test.c     |   2 +-
 util/oslib-posix.c          |   8 +-
 39 files changed, 352 insertions(+), 530 deletions(-)
 create mode 100644 include/hw/ppc/xics_spapr.h

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 01/25] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
@ 2019-01-14 10:01 ` Thomas Huth
  2019-01-14 10:01 ` [Qemu-devel] [PULL 02/25] tests: vhost-user-test: initialize 'fd' in chr_read Thomas Huth
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:01 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

It's been marked as deprecated in QEMU v2.6.0 already, so really nobody
should use the legacy "ivshmem" device anymore (but use ivshmem-plain or
ivshmem-doorbell instead). Time to remove the deprecated device now.

Belatedly also update a mention of the deprecated "ivshmem" in the file
docs/specs/ivshmem-spec.txt to "ivshmem-doorbell". Missed in commit
5400c02b90b ("ivshmem: Split ivshmem-plain, ivshmem-doorbell off ivshmem").

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 docs/specs/ivshmem-spec.txt |   8 +-
 hw/i386/pc_piix.c           |   1 -
 hw/misc/ivshmem.c           | 210 ++------------------------------------------
 qemu-deprecated.texi        |   5 --
 scripts/device-crash-test   |   1 -
 tests/ivshmem-test.c        |  67 +++++---------
 6 files changed, 34 insertions(+), 258 deletions(-)

diff --git a/docs/specs/ivshmem-spec.txt b/docs/specs/ivshmem-spec.txt
index a1f5499..042f7ea 100644
--- a/docs/specs/ivshmem-spec.txt
+++ b/docs/specs/ivshmem-spec.txt
@@ -17,12 +17,16 @@ get interrupted by its peers.
 
 There are two basic configurations:
 
-- Just shared memory: -device ivshmem-plain,memdev=HMB,...
+- Just shared memory:
+
+      -device ivshmem-plain,memdev=HMB,...
 
   This uses host memory backend HMB.  It should have option "share"
   set.
 
-- Shared memory plus interrupts: -device ivshmem,chardev=CHR,vectors=N,...
+- Shared memory plus interrupts:
+
+      -device ivshmem-doorbell,chardev=CHR,vectors=N,...
 
   An ivshmem server must already be running on the host.  The device
   connects to the server's UNIX domain socket via character device
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 5088e2f..63c84e3 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -715,7 +715,6 @@ static void pc_i440fx_1_2_machine_options(MachineClass *m)
         PC_CPU_MODEL_IDS("1.2.0")
         { "nec-usb-xhci", "msi", "off" },
         { "nec-usb-xhci", "msix", "off" },
-        { "ivshmem", "use64", "0" },
         { "qxl", "revision", "3" },
         { "qxl-vga", "revision", "3" },
         { "VGA", "mmio", "off" },
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 8213659..c7b6bbc 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -112,13 +112,6 @@ typedef struct IVShmemState {
     /* migration stuff */
     OnOffAuto master;
     Error *migration_blocker;
-
-    /* legacy cruft */
-    char *role;
-    char *shmobj;
-    char *sizearg;
-    size_t legacy_size;
-    uint32_t not_legacy_32bit;
 } IVShmemState;
 
 /* registers for the Inter-VM shared memory device */
@@ -529,17 +522,6 @@ static void process_msg_shmem(IVShmemState *s, int fd, Error **errp)
 
     size = buf.st_size;
 
-    /* Legacy cruft */
-    if (s->legacy_size != SIZE_MAX) {
-        if (size < s->legacy_size) {
-            error_setg(errp, "server sent only %zd bytes of shared memory",
-                       (size_t)buf.st_size);
-            close(fd);
-            return;
-        }
-        size = s->legacy_size;
-    }
-
     /* mmap the region and map into the BAR2 */
     memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s),
                                    "ivshmem.bar2", size, true, fd, &local_err);
@@ -882,8 +864,6 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
     IVShmemState *s = IVSHMEM_COMMON(dev);
     Error *err = NULL;
     uint8_t *pci_conf;
-    uint8_t attr = PCI_BASE_ADDRESS_SPACE_MEMORY |
-        PCI_BASE_ADDRESS_MEM_PREFETCH;
     Error *local_err = NULL;
 
     /* IRQFD requires MSI */
@@ -903,10 +883,6 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
     pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY,
                      &s->ivshmem_mmio);
 
-    if (s->not_legacy_32bit) {
-        attr |= PCI_BASE_ADDRESS_MEM_TYPE_64;
-    }
-
     if (s->hostmem != NULL) {
         IVSHMEM_DPRINTF("using hostmem\n");
 
@@ -964,7 +940,11 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
     }
 
     vmstate_register_ram(s->ivshmem_bar2, DEVICE(s));
-    pci_register_bar(PCI_DEVICE(s), 2, attr, s->ivshmem_bar2);
+    pci_register_bar(PCI_DEVICE(s), 2,
+                     PCI_BASE_ADDRESS_SPACE_MEMORY |
+                     PCI_BASE_ADDRESS_MEM_PREFETCH |
+                     PCI_BASE_ADDRESS_MEM_TYPE_64,
+                     s->ivshmem_bar2);
 }
 
 static void ivshmem_exit(PCIDevice *dev)
@@ -1084,13 +1064,6 @@ static Property ivshmem_plain_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
-static void ivshmem_plain_init(Object *obj)
-{
-    IVShmemState *s = IVSHMEM_PLAIN(obj);
-
-    s->not_legacy_32bit = 1;
-}
-
 static void ivshmem_plain_realize(PCIDevice *dev, Error **errp)
 {
     IVShmemState *s = IVSHMEM_COMMON(dev);
@@ -1122,7 +1095,6 @@ static const TypeInfo ivshmem_plain_info = {
     .name          = TYPE_IVSHMEM_PLAIN,
     .parent        = TYPE_IVSHMEM_COMMON,
     .instance_size = sizeof(IVShmemState),
-    .instance_init = ivshmem_plain_init,
     .class_init    = ivshmem_plain_class_init,
 };
 
@@ -1155,8 +1127,6 @@ static void ivshmem_doorbell_init(Object *obj)
     IVShmemState *s = IVSHMEM_DOORBELL(obj);
 
     s->features |= (1 << IVSHMEM_MSI);
-    s->legacy_size = SIZE_MAX;  /* whatever the server sends */
-    s->not_legacy_32bit = 1;
 }
 
 static void ivshmem_doorbell_realize(PCIDevice *dev, Error **errp)
@@ -1189,181 +1159,11 @@ static const TypeInfo ivshmem_doorbell_info = {
     .class_init    = ivshmem_doorbell_class_init,
 };
 
-static int ivshmem_load_old(QEMUFile *f, void *opaque, int version_id)
-{
-    IVShmemState *s = opaque;
-    PCIDevice *pdev = PCI_DEVICE(s);
-    int ret;
-
-    IVSHMEM_DPRINTF("ivshmem_load_old\n");
-
-    if (version_id != 0) {
-        return -EINVAL;
-    }
-
-    ret = ivshmem_pre_load(s);
-    if (ret) {
-        return ret;
-    }
-
-    ret = pci_device_load(pdev, f);
-    if (ret) {
-        return ret;
-    }
-
-    if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
-        msix_load(pdev, f);
-        ivshmem_msix_vector_use(s);
-    } else {
-        s->intrstatus = qemu_get_be32(f);
-        s->intrmask = qemu_get_be32(f);
-    }
-
-    return 0;
-}
-
-static bool test_msix(void *opaque, int version_id)
-{
-    IVShmemState *s = opaque;
-
-    return ivshmem_has_feature(s, IVSHMEM_MSI);
-}
-
-static bool test_no_msix(void *opaque, int version_id)
-{
-    return !test_msix(opaque, version_id);
-}
-
-static const VMStateDescription ivshmem_vmsd = {
-    .name = "ivshmem",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .pre_load = ivshmem_pre_load,
-    .post_load = ivshmem_post_load,
-    .fields = (VMStateField[]) {
-        VMSTATE_PCI_DEVICE(parent_obj, IVShmemState),
-
-        VMSTATE_MSIX_TEST(parent_obj, IVShmemState, test_msix),
-        VMSTATE_UINT32_TEST(intrstatus, IVShmemState, test_no_msix),
-        VMSTATE_UINT32_TEST(intrmask, IVShmemState, test_no_msix),
-
-        VMSTATE_END_OF_LIST()
-    },
-    .load_state_old = ivshmem_load_old,
-    .minimum_version_id_old = 0
-};
-
-static Property ivshmem_properties[] = {
-    DEFINE_PROP_CHR("chardev", IVShmemState, server_chr),
-    DEFINE_PROP_STRING("size", IVShmemState, sizearg),
-    DEFINE_PROP_UINT32("vectors", IVShmemState, vectors, 1),
-    DEFINE_PROP_BIT("ioeventfd", IVShmemState, features, IVSHMEM_IOEVENTFD,
-                    false),
-    DEFINE_PROP_BIT("msi", IVShmemState, features, IVSHMEM_MSI, true),
-    DEFINE_PROP_STRING("shm", IVShmemState, shmobj),
-    DEFINE_PROP_STRING("role", IVShmemState, role),
-    DEFINE_PROP_UINT32("use64", IVShmemState, not_legacy_32bit, 1),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
-static void desugar_shm(IVShmemState *s)
-{
-    Object *obj;
-    char *path;
-
-    obj = object_new("memory-backend-file");
-    path = g_strdup_printf("/dev/shm/%s", s->shmobj);
-    object_property_set_str(obj, path, "mem-path", &error_abort);
-    g_free(path);
-    object_property_set_int(obj, s->legacy_size, "size", &error_abort);
-    object_property_set_bool(obj, true, "share", &error_abort);
-    object_property_add_child(OBJECT(s), "internal-shm-backend", obj,
-                              &error_abort);
-    object_unref(obj);
-    user_creatable_complete(USER_CREATABLE(obj), &error_abort);
-    s->hostmem = MEMORY_BACKEND(obj);
-}
-
-static void ivshmem_realize(PCIDevice *dev, Error **errp)
-{
-    IVShmemState *s = IVSHMEM_COMMON(dev);
-
-    if (!qtest_enabled()) {
-        warn_report("ivshmem is deprecated, please use ivshmem-plain"
-                    " or ivshmem-doorbell instead");
-    }
-
-    if (qemu_chr_fe_backend_connected(&s->server_chr) + !!s->shmobj != 1) {
-        error_setg(errp, "You must specify either 'shm' or 'chardev'");
-        return;
-    }
-
-    if (s->sizearg == NULL) {
-        s->legacy_size = 4 * MiB; /* 4 MB default */
-    } else {
-        int ret;
-        uint64_t size;
-
-        ret = qemu_strtosz_MiB(s->sizearg, NULL, &size);
-        if (ret < 0 || (size_t)size != size || !is_power_of_2(size)) {
-            error_setg(errp, "Invalid size %s", s->sizearg);
-            return;
-        }
-        s->legacy_size = size;
-    }
-
-    /* check that role is reasonable */
-    if (s->role) {
-        if (strncmp(s->role, "peer", 5) == 0) {
-            s->master = ON_OFF_AUTO_OFF;
-        } else if (strncmp(s->role, "master", 7) == 0) {
-            s->master = ON_OFF_AUTO_ON;
-        } else {
-            error_setg(errp, "'role' must be 'peer' or 'master'");
-            return;
-        }
-    } else {
-        s->master = ON_OFF_AUTO_AUTO;
-    }
-
-    if (s->shmobj) {
-        desugar_shm(s);
-    }
-
-    /*
-     * Note: we don't use INTx with IVSHMEM_MSI at all, so this is a
-     * bald-faced lie then.  But it's a backwards compatible lie.
-     */
-    pci_config_set_interrupt_pin(dev->config, 1);
-
-    ivshmem_common_realize(dev, errp);
-}
-
-static void ivshmem_class_init(ObjectClass *klass, void *data)
-{
-    DeviceClass *dc = DEVICE_CLASS(klass);
-    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
-    k->realize = ivshmem_realize;
-    k->revision = 0;
-    dc->desc = "Inter-VM shared memory (legacy)";
-    dc->props = ivshmem_properties;
-    dc->vmsd = &ivshmem_vmsd;
-}
-
-static const TypeInfo ivshmem_info = {
-    .name          = TYPE_IVSHMEM,
-    .parent        = TYPE_IVSHMEM_COMMON,
-    .instance_size = sizeof(IVShmemState),
-    .class_init    = ivshmem_class_init,
-};
-
 static void ivshmem_register_types(void)
 {
     type_register_static(&ivshmem_common_info);
     type_register_static(&ivshmem_plain_info);
     type_register_static(&ivshmem_doorbell_info);
-    type_register_static(&ivshmem_info);
 }
 
 type_init(ivshmem_register_types)
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 81de5fc..219206a 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -126,11 +126,6 @@ documentation of ``query-hotpluggable-cpus'' for additional details.
 
 @section System emulator devices
 
-@subsection ivshmem (since 2.6.0)
-
-The ``ivshmem'' device type is replaced by either the ``ivshmem-plain''
-or ``ivshmem-doorbell`` device types.
-
 @subsection bluetooth (since 3.1)
 
 The bluetooth subsystem is unmaintained since many years and likely bitrotten
diff --git a/scripts/device-crash-test b/scripts/device-crash-test
index e93a7c0..a835772 100755
--- a/scripts/device-crash-test
+++ b/scripts/device-crash-test
@@ -83,7 +83,6 @@ ERROR_WHITELIST = [
     {'device':'isa-ipmi-bt', 'expected':True},             # IPMI device requires a bmc attribute to be set
     {'device':'isa-ipmi-kcs', 'expected':True},            # IPMI device requires a bmc attribute to be set
     {'device':'isa-parallel', 'expected':True},            # Can't create serial device, empty char device
-    {'device':'ivshmem', 'expected':True},                 # You must specify either 'shm' or 'chardev'
     {'device':'ivshmem-doorbell', 'expected':True},        # You must specify a 'chardev'
     {'device':'ivshmem-plain', 'expected':True},           # You must specify a 'memdev'
     {'device':'loader', 'expected':True},                  # please include valid arguments
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index fe5eb30..4911b69 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -291,20 +291,20 @@ static void *server_thread(void *data)
     return NULL;
 }
 
-static void setup_vm_with_server(IVState *s, int nvectors, bool msi)
+static void setup_vm_with_server(IVState *s, int nvectors)
 {
-    char *cmd = g_strdup_printf("-chardev socket,id=chr0,path=%s,nowait "
-                                "-device ivshmem%s,chardev=chr0,vectors=%d",
-                                tmpserver,
-                                msi ? "-doorbell" : ",size=1M,msi=off",
-                                nvectors);
+    char *cmd;
 
-    setup_vm_cmd(s, cmd, msi);
+    cmd = g_strdup_printf("-chardev socket,id=chr0,path=%s,nowait "
+                          "-device ivshmem-doorbell,chardev=chr0,vectors=%d",
+                          tmpserver, nvectors);
+
+    setup_vm_cmd(s, cmd, true);
 
     g_free(cmd);
 }
 
-static void test_ivshmem_server(bool msi)
+static void test_ivshmem_server(void)
 {
     IVState state1, state2, *s1, *s2;
     ServerThread thread;
@@ -327,9 +327,9 @@ static void test_ivshmem_server(bool msi)
     thread.thread = g_thread_new("ivshmem-server", server_thread, &thread);
     g_assert(thread.thread != NULL);
 
-    setup_vm_with_server(&state1, nvectors, msi);
+    setup_vm_with_server(&state1, nvectors);
     s1 = &state1;
-    setup_vm_with_server(&state2, nvectors, msi);
+    setup_vm_with_server(&state2, nvectors);
     s2 = &state2;
 
     /* check got different VM ids */
@@ -340,38 +340,28 @@ static void test_ivshmem_server(bool msi)
     g_assert_cmpint(vm1, !=, vm2);
 
     /* check number of MSI-X vectors */
-    if (msi) {
-        ret = qpci_msix_table_size(s1->dev);
-        g_assert_cmpuint(ret, ==, nvectors);
-    }
+    ret = qpci_msix_table_size(s1->dev);
+    g_assert_cmpuint(ret, ==, nvectors);
 
     /* TODO test behavior before MSI-X is enabled */
 
     /* ping vm2 -> vm1 on vector 0 */
-    if (msi) {
-        ret = qpci_msix_pending(s1->dev, 0);
-        g_assert_cmpuint(ret, ==, 0);
-    } else {
-        g_assert_cmpuint(in_reg(s1, INTRSTATUS), ==, 0);
-    }
+    ret = qpci_msix_pending(s1->dev, 0);
+    g_assert_cmpuint(ret, ==, 0);
     out_reg(s2, DOORBELL, vm1 << 16);
     do {
         g_usleep(10000);
-        ret = msi ? qpci_msix_pending(s1->dev, 0) : in_reg(s1, INTRSTATUS);
+        ret = qpci_msix_pending(s1->dev, 0);
     } while (ret == 0 && g_get_monotonic_time() < end_time);
     g_assert_cmpuint(ret, !=, 0);
 
     /* ping vm1 -> vm2 on vector 1 */
-    if (msi) {
-        ret = qpci_msix_pending(s2->dev, 1);
-        g_assert_cmpuint(ret, ==, 0);
-    } else {
-        g_assert_cmpuint(in_reg(s2, INTRSTATUS), ==, 0);
-    }
+    ret = qpci_msix_pending(s2->dev, 1);
+    g_assert_cmpuint(ret, ==, 0);
     out_reg(s1, DOORBELL, vm2 << 16 | 1);
     do {
         g_usleep(10000);
-        ret = msi ? qpci_msix_pending(s2->dev, 1) : in_reg(s2, INTRSTATUS);
+        ret = qpci_msix_pending(s2->dev, 1);
     } while (ret == 0 && g_get_monotonic_time() < end_time);
     g_assert_cmpuint(ret, !=, 0);
 
@@ -389,27 +379,17 @@ static void test_ivshmem_server(bool msi)
     close(thread.pipe[0]);
 }
 
-static void test_ivshmem_server_msi(void)
-{
-    test_ivshmem_server(true);
-}
-
-static void test_ivshmem_server_irq(void)
-{
-    test_ivshmem_server(false);
-}
-
 #define PCI_SLOT_HP             0x06
 
 static void test_ivshmem_hotplug(void)
 {
     const char *arch = qtest_get_arch();
 
-    qtest_start("");
+    qtest_start("-object memory-backend-ram,size=1M,id=mb1");
 
-    qtest_qmp_device_add("ivshmem",
-                         "iv1", "{'addr': %s, 'shm': %s, 'size': '1M'}",
-                         stringify(PCI_SLOT_HP), tmpshm);
+    qtest_qmp_device_add("ivshmem-plain", "iv1",
+                         "{'addr': %s, 'memdev': 'mb1'}",
+                         stringify(PCI_SLOT_HP));
     if (strcmp(arch, "ppc64") != 0) {
         qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
     }
@@ -509,8 +489,7 @@ int main(int argc, char **argv)
     if (g_test_slow()) {
         qtest_add_func("/ivshmem/pair", test_ivshmem_pair);
         if (strcmp(arch, "ppc64") != 0) {
-            qtest_add_func("/ivshmem/server-msi", test_ivshmem_server_msi);
-            qtest_add_func("/ivshmem/server-irq", test_ivshmem_server_irq);
+            qtest_add_func("/ivshmem/server", test_ivshmem_server);
         }
     }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 02/25] tests: vhost-user-test: initialize 'fd' in chr_read
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
  2019-01-14 10:01 ` [Qemu-devel] [PULL 01/25] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device Thomas Huth
@ 2019-01-14 10:01 ` Thomas Huth
  2019-01-14 10:01 ` [Qemu-devel] [PULL 03/25] vhost-user: fix ioeventfd_enabled Thomas Huth
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:01 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Li Qiang <liq3ea@163.com>

Currently when processing VHOST_USER_SET_VRING_CALL
if 'qemu_chr_fe_get_msgfds' get no fd, the 'fd' will
be a stack uninitialized value.

Signed-off-by: Li Qiang <liq3ea@163.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/vhost-user-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 54982f6..84e50d8 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -309,7 +309,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
     CharBackend *chr = &s->chr;
     VhostUserMsg msg;
     uint8_t *p = (uint8_t *) &msg;
-    int fd;
+    int fd = -1;
 
     if (s->test_fail) {
         qemu_chr_fe_disconnect(chr);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 03/25] vhost-user: fix ioeventfd_enabled
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
  2019-01-14 10:01 ` [Qemu-devel] [PULL 01/25] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device Thomas Huth
  2019-01-14 10:01 ` [Qemu-devel] [PULL 02/25] tests: vhost-user-test: initialize 'fd' in chr_read Thomas Huth
@ 2019-01-14 10:01 ` Thomas Huth
  2019-01-14 10:01 ` [Qemu-devel] [PULL 04/25] util: check the return value of fcntl in qemu_set_{block, nonblock} Thomas Huth
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:01 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Li Qiang <liq3ea@163.com>

Currently, the vhost-user-test assumes the eventfd is available.
However it's not true because the accel is qtest. So the
'vhost_set_vring_file' will not add fds to the msg and the server
side of vhost-user-test will be broken. The bug is in 'ioeventfd_enabled'.
We should make this function return true if not using kvm accel.

Signed-off-by: Li Qiang <liq3ea@163.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/virtio/vhost-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index e09bed0..564a31d 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -207,7 +207,7 @@ struct vhost_user {
 
 static bool ioeventfd_enabled(void)
 {
-    return kvm_enabled() && kvm_eventfds_enabled();
+    return !kvm_enabled() || kvm_eventfds_enabled();
 }
 
 static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 04/25] util: check the return value of fcntl in qemu_set_{block, nonblock}
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (2 preceding siblings ...)
  2019-01-14 10:01 ` [Qemu-devel] [PULL 03/25] vhost-user: fix ioeventfd_enabled Thomas Huth
@ 2019-01-14 10:01 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 05/25] tests/Makefile: Use some more CONFIG switches for x86 tests Thomas Huth
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:01 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Li Qiang <liq3ea@163.com>

Assert that the return value is not an error. This is like commit
7e6478e7d4f for qemu_set_cloexec.

Signed-off-by: Li Qiang <liq3ea@163.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 util/oslib-posix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index c1bee2a..4ce1ba9 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -233,14 +233,18 @@ void qemu_set_block(int fd)
 {
     int f;
     f = fcntl(fd, F_GETFL);
-    fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
+    assert(f != -1);
+    f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
+    assert(f != -1);
 }
 
 void qemu_set_nonblock(int fd)
 {
     int f;
     f = fcntl(fd, F_GETFL);
-    fcntl(fd, F_SETFL, f | O_NONBLOCK);
+    assert(f != -1);
+    f = fcntl(fd, F_SETFL, f | O_NONBLOCK);
+    assert(f != -1);
 }
 
 int socket_set_fast_reuse(int fd)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 05/25] tests/Makefile: Use some more CONFIG switches for x86 tests
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (3 preceding siblings ...)
  2019-01-14 10:01 ` [Qemu-devel] [PULL 04/25] util: check the return value of fcntl in qemu_set_{block, nonblock} Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 06/25] tests/Makefile: Use some more CONFIG switches for ppc tests Thomas Huth
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

To be able to build and test QEMU binaries where certain devices are
disabled, we have to use the right CONFIG_* switches to run certain
tests only if the corresponding device really has been compiled into
the binary.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/Makefile.include | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index c17f6d5..462b5e0 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -165,13 +165,13 @@ check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF)
 check-qtest-pci-$(CONFIG_NVME_PCI) += tests/nvme-test$(EXESUF)
 check-qtest-pci-$(CONFIG_AC97) += tests/ac97-test$(EXESUF)
 check-qtest-pci-$(CONFIG_ES1370) += tests/es1370-test$(EXESUF)
-check-qtest-pci-y += $(check-qtest-virtio-y)
+check-qtest-pci-$(CONFIG_VIRTIO) += $(check-qtest-virtio-y)
 check-qtest-pci-$(CONFIG_IPACK) += tests/tpci200-test$(EXESUF)
 check-qtest-pci-$(CONFIG_IPACK) += $(check-qtest-ipack-y)
-check-qtest-pci-y += tests/display-vga-test$(EXESUF)
+check-qtest-pci-$(CONFIG_VGA) += tests/display-vga-test$(EXESUF)
 check-qtest-pci-$(CONFIG_HDA) += tests/intel-hda-test$(EXESUF)
 check-qtest-pci-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF)
-check-qtest-pci-y += tests/megasas-test$(EXESUF)
+check-qtest-pci-$(CONFIG_MEGASAS_SCSI_PCI) += tests/megasas-test$(EXESUF)
 
 check-qtest-i386-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 check-qtest-i386-y += tests/fdc-test$(EXESUF)
@@ -183,8 +183,8 @@ check-qtest-i386-y += tests/bios-tables-test$(EXESUF)
 check-qtest-i386-$(CONFIG_SGA) += tests/boot-serial-test$(EXESUF)
 check-qtest-i386-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
 check-qtest-i386-y += tests/rtc-test$(EXESUF)
-check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF)
-check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF)
+check-qtest-i386-$(CONFIG_ISA_IPMI_KCS) += tests/ipmi-kcs-test$(EXESUF)
+check-qtest-i386-$(CONFIG_ISA_IPMI_BT) += tests/ipmi-bt-test$(EXESUF)
 check-qtest-i386-y += tests/i440fx-test$(EXESUF)
 check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
 check-qtest-i386-y += tests/drive_del-test$(EXESUF)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 06/25] tests/Makefile: Use some more CONFIG switches for ppc tests
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (4 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 05/25] tests/Makefile: Use some more CONFIG switches for x86 tests Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 07/25] tests/endianesss: Make test independent of global_qtest Thomas Huth
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

To be able to build and test QEMU binaries where certain devices or machines
are disabled, we have to use the right CONFIG_* switches to run certain tests
only if the corresponding device or machine really has been compiled into
the binary.

Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/Makefile.include | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 462b5e0..476b943 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -242,22 +242,22 @@ check-qtest-ppc-y += tests/boot-order-test$(EXESUF)
 check-qtest-ppc-y += tests/prom-env-test$(EXESUF)
 check-qtest-ppc-y += tests/drive_del-test$(EXESUF)
 check-qtest-ppc-y += tests/boot-serial-test$(EXESUF)
-check-qtest-ppc-y += tests/m48t59-test$(EXESUF)
+check-qtest-ppc-$(CONFIG_M48T59) += tests/m48t59-test$(EXESUF)
 
 check-qtest-ppc64-y += $(check-qtest-ppc-y)
-check-qtest-ppc64-y += tests/spapr-phb-test$(EXESUF)
-check-qtest-ppc64-y += tests/pnv-xscom-test$(EXESUF)
+check-qtest-ppc64-$(CONFIG_PSERIES) += tests/spapr-phb-test$(EXESUF)
+check-qtest-ppc64-$(CONFIG_POWERNV) += tests/pnv-xscom-test$(EXESUF)
 check-qtest-ppc64-y += tests/migration-test$(EXESUF)
-check-qtest-ppc64-y += tests/rtas-test$(EXESUF)
+check-qtest-ppc64-$(CONFIG_PSERIES) += tests/rtas-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_USB_OHCI) += tests/usb-hcd-ohci-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_USB_UHCI) += tests/usb-hcd-uhci-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_USB_XHCI_NEC) += tests/usb-hcd-xhci-test$(EXESUF)
-check-qtest-ppc64-y += $(check-qtest-virtio-y)
+check-qtest-ppc64-$(CONFIG_VIRTIO) += $(check-qtest-virtio-y)
 check-qtest-ppc64-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-$(CONFIG_RTL8139_PCI) += tests/test-filter-redirector$(EXESUF)
-check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
+check-qtest-ppc64-$(CONFIG_VGA) += tests/display-vga-test$(EXESUF)
 check-qtest-ppc64-y += tests/numa-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF)
 check-qtest-ppc64-y += tests/cpu-plug-test$(EXESUF)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 07/25] tests/endianesss: Make test independent of global_qtest
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (5 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 06/25] tests/Makefile: Use some more CONFIG switches for ppc tests Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 08/25] tests/boot-order: " Thomas Huth
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

Pass around the test state explicitly, to be able to use the qtest_in*()
and qtest_out*() function in this test.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/endianness-test.c | 329 ++++++++++++++++++++++++------------------------
 1 file changed, 166 insertions(+), 163 deletions(-)

diff --git a/tests/endianness-test.c b/tests/endianness-test.c
index 48680cd..5852795 100644
--- a/tests/endianness-test.c
+++ b/tests/endianness-test.c
@@ -48,65 +48,68 @@ static const TestCase test_cases[] = {
     {}
 };
 
-static uint8_t isa_inb(const TestCase *test, uint16_t addr)
+static uint8_t isa_inb(QTestState *qts, const TestCase *test, uint16_t addr)
 {
     uint8_t value;
     if (test->isa_base == -1) {
-        value = inb(addr);
+        value = qtest_inb(qts, addr);
     } else {
-        value = readb(test->isa_base + addr);
+        value = qtest_readb(qts, test->isa_base + addr);
     }
     return value;
 }
 
-static uint16_t isa_inw(const TestCase *test, uint16_t addr)
+static uint16_t isa_inw(QTestState *qts, const TestCase *test, uint16_t addr)
 {
     uint16_t value;
     if (test->isa_base == -1) {
-        value = inw(addr);
+        value = qtest_inw(qts, addr);
     } else {
-        value = readw(test->isa_base + addr);
+        value = qtest_readw(qts, test->isa_base + addr);
     }
     return test->bswap ? bswap16(value) : value;
 }
 
-static uint32_t isa_inl(const TestCase *test, uint16_t addr)
+static uint32_t isa_inl(QTestState *qts, const TestCase *test, uint16_t addr)
 {
     uint32_t value;
     if (test->isa_base == -1) {
-        value = inl(addr);
+        value = qtest_inl(qts, addr);
     } else {
-        value = readl(test->isa_base + addr);
+        value = qtest_readl(qts, test->isa_base + addr);
     }
     return test->bswap ? bswap32(value) : value;
 }
 
-static void isa_outb(const TestCase *test, uint16_t addr, uint8_t value)
+static void isa_outb(QTestState *qts, const TestCase *test, uint16_t addr,
+                     uint8_t value)
 {
     if (test->isa_base == -1) {
-        outb(addr, value);
+        qtest_outb(qts, addr, value);
     } else {
-        writeb(test->isa_base + addr, value);
+        qtest_writeb(qts, test->isa_base + addr, value);
     }
 }
 
-static void isa_outw(const TestCase *test, uint16_t addr, uint16_t value)
+static void isa_outw(QTestState *qts, const TestCase *test, uint16_t addr,
+                     uint16_t value)
 {
     value = test->bswap ? bswap16(value) : value;
     if (test->isa_base == -1) {
-        outw(addr, value);
+        qtest_outw(qts, addr, value);
     } else {
-        writew(test->isa_base + addr, value);
+        qtest_writew(qts, test->isa_base + addr, value);
     }
 }
 
-static void isa_outl(const TestCase *test, uint16_t addr, uint32_t value)
+static void isa_outl(QTestState *qts, const TestCase *test, uint16_t addr,
+                     uint32_t value)
 {
     value = test->bswap ? bswap32(value) : value;
     if (test->isa_base == -1) {
-        outl(addr, value);
+        qtest_outl(qts, addr, value);
     } else {
-        writel(test->isa_base + addr, value);
+        qtest_writel(qts, test->isa_base + addr, value);
     }
 }
 
@@ -114,161 +117,161 @@ static void isa_outl(const TestCase *test, uint16_t addr, uint32_t value)
 static void test_endianness(gconstpointer data)
 {
     const TestCase *test = data;
-
-    global_qtest = qtest_initf("-M %s%s%s -device pc-testdev",
-                               test->machine,
-                               test->superio ? " -device " : "",
-                               test->superio ?: "");
-    isa_outl(test, 0xe0, 0x87654321);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
-    g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
-    g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
-    g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
-    g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
-
-    isa_outw(test, 0xe2, 0x8866);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664321);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
-    g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x88);
-    g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
-    g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
-    g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
-
-    isa_outw(test, 0xe0, 0x4422);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664422);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422);
-    g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x88);
-    g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
-    g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
-    g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
-
-    isa_outb(test, 0xe3, 0x87);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87664422);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8766);
-    g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
-    g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
-    g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
-    g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
-
-    isa_outb(test, 0xe2, 0x65);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654422);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422);
-    g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
-    g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
-    g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
-    g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
-
-    isa_outb(test, 0xe1, 0x43);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654322);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4322);
-    g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
-    g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
-    g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
-    g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
-
-    isa_outb(test, 0xe0, 0x21);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
-    g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
-    g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
-    g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
-    g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
-    qtest_quit(global_qtest);
+    QTestState *qts;
+
+    qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
+                      test->superio ? " -device " : "",
+                      test->superio ?: "");
+    isa_outl(qts, test, 0xe0, 0x87654321);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
+    g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
+    g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
+    g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
+    g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
+
+    isa_outw(qts, test, 0xe2, 0x8866);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664321);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
+    g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x88);
+    g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
+    g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
+    g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
+
+    isa_outw(qts, test, 0xe0, 0x4422);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664422);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
+    g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x88);
+    g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
+    g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
+    g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
+
+    isa_outb(qts, test, 0xe3, 0x87);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87664422);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8766);
+    g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
+    g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
+    g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
+    g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
+
+    isa_outb(qts, test, 0xe2, 0x65);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654422);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
+    g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
+    g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
+    g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
+    g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
+
+    isa_outb(qts, test, 0xe1, 0x43);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654322);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4322);
+    g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
+    g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
+    g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
+    g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
+
+    isa_outb(qts, test, 0xe0, 0x21);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
+    g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
+    g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
+    g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
+    g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
+    qtest_quit(qts);
 }
 
 static void test_endianness_split(gconstpointer data)
 {
     const TestCase *test = data;
-
-    global_qtest = qtest_initf("-M %s%s%s -device pc-testdev",
-                               test->machine,
-                               test->superio ? " -device " : "",
-                               test->superio ?: "");
-    isa_outl(test, 0xe8, 0x87654321);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
-
-    isa_outw(test, 0xea, 0x8866);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664321);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
-
-    isa_outw(test, 0xe8, 0x4422);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664422);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422);
-
-    isa_outb(test, 0xeb, 0x87);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87664422);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8766);
-
-    isa_outb(test, 0xea, 0x65);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654422);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422);
-
-    isa_outb(test, 0xe9, 0x43);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654322);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4322);
-
-    isa_outb(test, 0xe8, 0x21);
-    g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
-    g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
-    qtest_quit(global_qtest);
+    QTestState *qts;
+
+    qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
+                      test->superio ? " -device " : "",
+                      test->superio ?: "");
+    isa_outl(qts, test, 0xe8, 0x87654321);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
+
+    isa_outw(qts, test, 0xea, 0x8866);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664321);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
+
+    isa_outw(qts, test, 0xe8, 0x4422);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664422);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
+
+    isa_outb(qts, test, 0xeb, 0x87);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87664422);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8766);
+
+    isa_outb(qts, test, 0xea, 0x65);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654422);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
+
+    isa_outb(qts, test, 0xe9, 0x43);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654322);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4322);
+
+    isa_outb(qts, test, 0xe8, 0x21);
+    g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
+    g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
+    qtest_quit(qts);
 }
 
 static void test_endianness_combine(gconstpointer data)
 {
     const TestCase *test = data;
-
-    global_qtest = qtest_initf("-M %s%s%s -device pc-testdev",
-                               test->machine,
-                               test->superio ? " -device " : "",
-                               test->superio ?: "");
-    isa_outl(test, 0xe0, 0x87654321);
-    g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321);
-    g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321);
-
-    isa_outw(test, 0xe2, 0x8866);
-    g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x88664321);
-    g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8866);
-    g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321);
-
-    isa_outw(test, 0xe0, 0x4422);
-    g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x88664422);
-    g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8866);
-    g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4422);
-
-    isa_outb(test, 0xe3, 0x87);
-    g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87664422);
-    g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8766);
-
-    isa_outb(test, 0xe2, 0x65);
-    g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654422);
-    g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4422);
-
-    isa_outb(test, 0xe1, 0x43);
-    g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654322);
-    g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4322);
-
-    isa_outb(test, 0xe0, 0x21);
-    g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321);
-    g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
-    g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321);
-    qtest_quit(global_qtest);
+    QTestState *qts;
+
+    qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
+                      test->superio ? " -device " : "",
+                      test->superio ?: "");
+    isa_outl(qts, test, 0xe0, 0x87654321);
+    g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654321);
+    g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
+
+    isa_outw(qts, test, 0xe2, 0x8866);
+    g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x88664321);
+    g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8866);
+    g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
+
+    isa_outw(qts, test, 0xe0, 0x4422);
+    g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x88664422);
+    g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8866);
+    g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4422);
+
+    isa_outb(qts, test, 0xe3, 0x87);
+    g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87664422);
+    g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8766);
+
+    isa_outb(qts, test, 0xe2, 0x65);
+    g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654422);
+    g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4422);
+
+    isa_outb(qts, test, 0xe1, 0x43);
+    g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654322);
+    g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4322);
+
+    isa_outb(qts, test, 0xe0, 0x21);
+    g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654321);
+    g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
+    g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
+    qtest_quit(qts);
 }
 
 int main(int argc, char **argv)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 08/25] tests/boot-order: Make test independent of global_qtest
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (6 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 07/25] tests/endianesss: Make test independent of global_qtest Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 09/25] tests/pnv-xscom: " Thomas Huth
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

Pass around the QTestState from function to function, so that we can finally
get rid of the out-of-favor global_qtest variable in this file, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/boot-order-test.c | 59 ++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index c60ebcf..a725bce 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -17,7 +17,7 @@
 #include "standard-headers/linux/qemu_fw_cfg.h"
 
 /* TODO actually test the results and get rid of this */
-#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__))
+#define qmp_discard_response(qs, ...) qobject_unref(qtest_qmp(qs, __VA_ARGS__))
 
 typedef struct {
     const char *args;
@@ -27,31 +27,30 @@ typedef struct {
 
 static void test_a_boot_order(const char *machine,
                               const char *test_args,
-                              uint64_t (*read_boot_order)(void),
+                              uint64_t (*read_boot_order)(QTestState *),
                               uint64_t expected_boot,
                               uint64_t expected_reboot)
 {
     uint64_t actual;
+    QTestState *qts;
 
-    global_qtest = qtest_initf("-nodefaults%s%s %s",
-                               machine ? " -M " : "",
-                               machine ?: "",
-                               test_args);
-    actual = read_boot_order();
+    qts = qtest_initf("-nodefaults%s%s %s", machine ? " -M " : "",
+                      machine ?: "", test_args);
+    actual = read_boot_order(qts);
     g_assert_cmphex(actual, ==, expected_boot);
-    qmp_discard_response("{ 'execute': 'system_reset' }");
+    qmp_discard_response(qts, "{ 'execute': 'system_reset' }");
     /*
      * system_reset only requests reset.  We get a RESET event after
      * the actual reset completes.  Need to wait for that.
      */
-    qmp_eventwait("RESET");
-    actual = read_boot_order();
+    qtest_qmp_eventwait(qts, "RESET");
+    actual = read_boot_order(qts);
     g_assert_cmphex(actual, ==, expected_reboot);
-    qtest_quit(global_qtest);
+    qtest_quit(qts);
 }
 
 static void test_boot_orders(const char *machine,
-                             uint64_t (*read_boot_order)(void),
+                             uint64_t (*read_boot_order)(QTestState *),
                              const boot_order_test *tests)
 {
     int i;
@@ -64,16 +63,16 @@ static void test_boot_orders(const char *machine,
     }
 }
 
-static uint8_t read_mc146818(uint16_t port, uint8_t reg)
+static uint8_t read_mc146818(QTestState *qts, uint16_t port, uint8_t reg)
 {
-    outb(port, reg);
-    return inb(port + 1);
+    qtest_outb(qts, port, reg);
+    return qtest_inb(qts, port + 1);
 }
 
-static uint64_t read_boot_order_pc(void)
+static uint64_t read_boot_order_pc(QTestState *qts)
 {
-    uint8_t b1 = read_mc146818(0x70, 0x38);
-    uint8_t b2 = read_mc146818(0x70, 0x3d);
+    uint8_t b1 = read_mc146818(qts, 0x70, 0x38);
+    uint8_t b2 = read_mc146818(qts, 0x70, 0x3d);
 
     return b1 | (b2 << 8);
 }
@@ -109,16 +108,16 @@ static void test_pc_boot_order(void)
     test_boot_orders(NULL, read_boot_order_pc, test_cases_pc);
 }
 
-static uint8_t read_m48t59(uint64_t addr, uint16_t reg)
+static uint8_t read_m48t59(QTestState *qts, uint64_t addr, uint16_t reg)
 {
-    writeb(addr, reg & 0xff);
-    writeb(addr + 1, reg >> 8);
-    return readb(addr + 3);
+    qtest_writeb(qts, addr, reg & 0xff);
+    qtest_writeb(qts, addr + 1, reg >> 8);
+    return qtest_readb(qts, addr + 3);
 }
 
-static uint64_t read_boot_order_prep(void)
+static uint64_t read_boot_order_prep(QTestState *qts)
 {
-    return read_m48t59(0x80000000 + 0x74, 0x34);
+    return read_m48t59(qts, 0x80000000 + 0x74, 0x34);
 }
 
 static const boot_order_test test_cases_prep[] = {
@@ -133,9 +132,9 @@ static void test_prep_boot_order(void)
     test_boot_orders("prep", read_boot_order_prep, test_cases_prep);
 }
 
-static uint64_t read_boot_order_pmac(void)
+static uint64_t read_boot_order_pmac(QTestState *qts)
 {
-    QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xf0000510);
+    QFWCFG *fw_cfg = mm_fw_cfg_init(qts, 0xf0000510);
 
     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
@@ -158,9 +157,9 @@ static void test_pmac_newworld_boot_order(void)
     test_boot_orders("mac99", read_boot_order_pmac, test_cases_fw_cfg);
 }
 
-static uint64_t read_boot_order_sun4m(void)
+static uint64_t read_boot_order_sun4m(QTestState *qts)
 {
-    QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xd00000510ULL);
+    QFWCFG *fw_cfg = mm_fw_cfg_init(qts, 0xd00000510ULL);
 
     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
@@ -170,9 +169,9 @@ static void test_sun4m_boot_order(void)
     test_boot_orders("SS-5", read_boot_order_sun4m, test_cases_fw_cfg);
 }
 
-static uint64_t read_boot_order_sun4u(void)
+static uint64_t read_boot_order_sun4u(QTestState *qts)
 {
-    QFWCFG *fw_cfg = io_fw_cfg_init(global_qtest, 0x510);
+    QFWCFG *fw_cfg = io_fw_cfg_init(qts, 0x510);
 
     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 09/25] tests/pnv-xscom: Make test independent of global_qtest
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (7 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 08/25] tests/boot-order: " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 10/25] hw/input/ps2: Remove PS2State from "qemu/typedefs.h" Thomas Huth
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

Pass around the QTestState, so that we can finally get rid of the
out-of-favor global_qtest variable in this file, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/pnv-xscom-test.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/tests/pnv-xscom-test.c b/tests/pnv-xscom-test.c
index 70f4c84..974f8da 100644
--- a/tests/pnv-xscom-test.c
+++ b/tests/pnv-xscom-test.c
@@ -63,14 +63,15 @@ static uint64_t pnv_xscom_addr(const PnvChip *chip, uint32_t pcba)
     return addr;
 }
 
-static uint64_t pnv_xscom_read(const PnvChip *chip, uint32_t pcba)
+static uint64_t pnv_xscom_read(QTestState *qts, const PnvChip *chip,
+                               uint32_t pcba)
 {
-    return readq(pnv_xscom_addr(chip, pcba));
+    return qtest_readq(qts, pnv_xscom_addr(chip, pcba));
 }
 
-static void test_xscom_cfam_id(const PnvChip *chip)
+static void test_xscom_cfam_id(QTestState *qts, const PnvChip *chip)
 {
-    uint64_t f000f = pnv_xscom_read(chip, 0xf000f);
+    uint64_t f000f = pnv_xscom_read(qts, chip, 0xf000f);
 
     g_assert_cmphex(f000f, ==, chip->cfam_id);
 }
@@ -78,11 +79,11 @@ static void test_xscom_cfam_id(const PnvChip *chip)
 static void test_cfam_id(const void *data)
 {
     const PnvChip *chip = data;
+    QTestState *qts;
 
-    global_qtest = qtest_initf("-M powernv,accel=tcg -cpu %s",
-                               chip->cpu_model);
-    test_xscom_cfam_id(chip);
-    qtest_quit(global_qtest);
+    qts = qtest_initf("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
+    test_xscom_cfam_id(qts, chip);
+    qtest_quit(qts);
 }
 
 
@@ -94,7 +95,7 @@ static void test_cfam_id(const void *data)
 
 #define PNV_XSCOM_EX_DTS_RESULT0     0x50000
 
-static void test_xscom_core(const PnvChip *chip)
+static void test_xscom_core(QTestState *qts, const PnvChip *chip)
 {
     uint32_t first_core_dts0 = PNV_XSCOM_EX_DTS_RESULT0;
     uint64_t dts0;
@@ -105,7 +106,7 @@ static void test_xscom_core(const PnvChip *chip)
         first_core_dts0 |= PNV_XSCOM_P9_EC_BASE(chip->first_core);
     }
 
-    dts0 = pnv_xscom_read(chip, first_core_dts0);
+    dts0 = pnv_xscom_read(qts, chip, first_core_dts0);
 
     g_assert_cmphex(dts0, ==, 0x26f024f023f0000ull);
 }
@@ -113,11 +114,11 @@ static void test_xscom_core(const PnvChip *chip)
 static void test_core(const void *data)
 {
     const PnvChip *chip = data;
+    QTestState *qts;
 
-    global_qtest = qtest_initf("-M powernv,accel=tcg -cpu %s",
-                               chip->cpu_model);
-    test_xscom_core(chip);
-    qtest_quit(global_qtest);
+    qts = qtest_initf("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
+    test_xscom_core(qts, chip);
+    qtest_quit(qts);
 }
 
 static void add_test(const char *name, void (*test)(const void *data))
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 10/25] hw/input/ps2: Remove PS2State from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (8 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 09/25] tests/pnv-xscom: " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 11/25] hw/pcmcia: Remove PCMCIACardState " Thomas Huth
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <philmd@redhat.com>

PS2State is only used in "hw/input/ps2.h", there is no
need to expose it via "qemu/typedefs.h".

To clean "qemu/typedefs.h", move the forward declaration
to "hw/input/ps2.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/input/ps2.h  | 2 ++
 include/qemu/typedefs.h | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h
index 213aa16..b60455d 100644
--- a/include/hw/input/ps2.h
+++ b/include/hw/input/ps2.h
@@ -31,6 +31,8 @@
 #define PS2_MOUSE_BUTTON_SIDE   0x08
 #define PS2_MOUSE_BUTTON_EXTRA  0x10
 
+typedef struct PS2State PS2State;
+
 /* ps2.c */
 void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);
 void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg);
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 741935f..28a8b9e 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -83,7 +83,6 @@ typedef struct PixelFormat PixelFormat;
 typedef struct PostcopyDiscardState PostcopyDiscardState;
 typedef struct Property Property;
 typedef struct PropertyInfo PropertyInfo;
-typedef struct PS2State PS2State;
 typedef struct QBool QBool;
 typedef struct QDict QDict;
 typedef struct QEMUBH QEMUBH;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 11/25] hw/pcmcia: Remove PCMCIACardState from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (9 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 10/25] hw/input/ps2: Remove PS2State from "qemu/typedefs.h" Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 12/25] hw/ssi: Remove SSIBus " Thomas Huth
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

There is only one header file requiring this typedef (hw/arm/pxa.h),
let it include "hw/pcmcia.h" directly to simplify "qemu/typedefs.h".

To clean "qemu/typedefs.h", move the declaration to "hw/pcmcia.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
[thuth: slightly tweaked commit message]
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/arm/pxa.h    | 1 +
 include/hw/pcmcia.h     | 4 ++--
 include/qemu/typedefs.h | 1 -
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
index 0df1199..f6dfb5c 100644
--- a/include/hw/arm/pxa.h
+++ b/include/hw/arm/pxa.h
@@ -12,6 +12,7 @@
 
 #include "exec/memory.h"
 #include "target/arm/cpu-qom.h"
+#include "hw/pcmcia.h"
 
 /* Interrupt numbers */
 # define PXA2XX_PIC_SSP3	0
diff --git a/include/hw/pcmcia.h b/include/hw/pcmcia.h
index 79cac9c..1b40807 100644
--- a/include/hw/pcmcia.h
+++ b/include/hw/pcmcia.h
@@ -18,13 +18,13 @@ typedef struct PCMCIASocket {
 #define PCMCIA_CARD_CLASS(cls) \
     OBJECT_CLASS_CHECK(PCMCIACardClass, cls, TYPE_PCMCIA_CARD)
 
-struct PCMCIACardState {
+typedef struct PCMCIACardState {
     /*< private >*/
     DeviceState parent_obj;
     /*< public >*/
 
     PCMCIASocket *slot;
-};
+} PCMCIACardState;
 
 typedef struct PCMCIACardClass {
     /*< private >*/
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 28a8b9e..3bd9215 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -78,7 +78,6 @@ typedef struct PCIHostDeviceAddress PCIHostDeviceAddress;
 typedef struct PCIHostState PCIHostState;
 typedef struct PCMachineClass PCMachineClass;
 typedef struct PCMachineState PCMachineState;
-typedef struct PCMCIACardState PCMCIACardState;
 typedef struct PixelFormat PixelFormat;
 typedef struct PostcopyDiscardState PostcopyDiscardState;
 typedef struct Property Property;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 12/25] hw/ssi: Remove SSIBus from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (10 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 11/25] hw/pcmcia: Remove PCMCIACardState " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 13/25] hw/ide/ahci: Remove AllwinnerAHCIState " Thomas Huth
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

There are only three header files requiring this typedef, let them
include "hw/ssi/ssi.h" directly to simplify "qemu/typedefs.h".

To clean "qemu/typedefs.h", move the forward declaration
to "hw/ssi/ssi.h".

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
[thuth: slightly tweaked commit message]
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/arm/strongarm.h      | 1 +
 include/hw/arm/pxa.h    | 1 +
 include/hw/ssi/pl022.h  | 1 +
 include/hw/ssi/ssi.h    | 1 +
 include/qemu/typedefs.h | 1 -
 5 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/arm/strongarm.h b/hw/arm/strongarm.h
index e98840b..ae51a1a 100644
--- a/hw/arm/strongarm.h
+++ b/hw/arm/strongarm.h
@@ -3,6 +3,7 @@
 
 #include "exec/memory.h"
 #include "target/arm/cpu-qom.h"
+#include "hw/ssi/ssi.h"
 
 #define SA_CS0          0x00000000
 #define SA_CS1          0x08000000
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
index f6dfb5c..f184349 100644
--- a/include/hw/arm/pxa.h
+++ b/include/hw/arm/pxa.h
@@ -13,6 +13,7 @@
 #include "exec/memory.h"
 #include "target/arm/cpu-qom.h"
 #include "hw/pcmcia.h"
+#include "hw/ssi/ssi.h"
 
 /* Interrupt numbers */
 # define PXA2XX_PIC_SSP3	0
diff --git a/include/hw/ssi/pl022.h b/include/hw/ssi/pl022.h
index a080519..1cf16f1 100644
--- a/include/hw/ssi/pl022.h
+++ b/include/hw/ssi/pl022.h
@@ -22,6 +22,7 @@
 #define HW_SSI_PL022_H
 
 #include "hw/sysbus.h"
+#include "hw/ssi/ssi.h"
 
 #define TYPE_PL022 "pl022"
 #define PL022(obj) OBJECT_CHECK(PL022State, (obj), TYPE_PL022)
diff --git a/include/hw/ssi/ssi.h b/include/hw/ssi/ssi.h
index 6a0c3c3..bdbf3c5 100644
--- a/include/hw/ssi/ssi.h
+++ b/include/hw/ssi/ssi.h
@@ -13,6 +13,7 @@
 
 #include "hw/qdev.h"
 
+typedef struct SSIBus SSIBus;
 typedef struct SSISlave SSISlave;
 typedef struct SSISlaveClass SSISlaveClass;
 typedef enum SSICSMode SSICSMode;
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 3bd9215..c026229 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -108,7 +108,6 @@ typedef struct Range Range;
 typedef struct SerialState SerialState;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct SMBusDevice SMBusDevice;
-typedef struct SSIBus SSIBus;
 typedef struct uWireSlave uWireSlave;
 typedef struct VirtIODevice VirtIODevice;
 typedef struct Visitor Visitor;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 13/25] hw/ide/ahci: Remove AllwinnerAHCIState from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (11 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 12/25] hw/ssi: Remove SSIBus " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 14/25] hw/i2c/smbus: Remove SMBusDevice " Thomas Huth
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Files requiring AllwinnerAHCIState already include "hw/ide/ahci.h".

To clean "qemu/typedefs.h", move the declaration to "hw/ide/ahci.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/ide/ahci.h   | 4 ++--
 include/qemu/typedefs.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/hw/ide/ahci.h b/include/hw/ide/ahci.h
index b7bb2b0..b44e300 100644
--- a/include/hw/ide/ahci.h
+++ b/include/hw/ide/ahci.h
@@ -73,13 +73,13 @@ typedef struct SysbusAHCIState {
 #define ALLWINNER_AHCI_MMIO_OFF  0x80
 #define ALLWINNER_AHCI_MMIO_SIZE 0x80
 
-struct AllwinnerAHCIState {
+typedef struct AllwinnerAHCIState {
     /*< private >*/
     SysbusAHCIState parent_obj;
     /*< public >*/
 
     MemoryRegion mmio;
     uint32_t regs[ALLWINNER_AHCI_MMIO_SIZE/4];
-};
+} AllwinnerAHCIState;
 
 #endif /* HW_IDE_AHCI_H */
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index c026229..3a5ca74 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -8,7 +8,6 @@
 typedef struct AdapterInfo AdapterInfo;
 typedef struct AddressSpace AddressSpace;
 typedef struct AioContext AioContext;
-typedef struct AllwinnerAHCIState AllwinnerAHCIState;
 typedef struct AudioState AudioState;
 typedef struct BdrvDirtyBitmap BdrvDirtyBitmap;
 typedef struct BdrvDirtyBitmapIter BdrvDirtyBitmapIter;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 14/25] hw/i2c/smbus: Remove SMBusDevice from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (12 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 13/25] hw/ide/ahci: Remove AllwinnerAHCIState " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 15/25] hw/bt: Remove HCIInfo " Thomas Huth
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Files requiring SMBusDevice already include "hw/i2c/smbus.h".

To clean "qemu/typedefs.h", move the forward declaration
to "hw/i2c/smbus.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/i2c/smbus.h  | 2 ++
 include/qemu/typedefs.h | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h
index d8b1b9e..5c61c05 100644
--- a/include/hw/i2c/smbus.h
+++ b/include/hw/i2c/smbus.h
@@ -35,6 +35,8 @@
 #define SMBUS_DEVICE_GET_CLASS(obj) \
      OBJECT_GET_CLASS(SMBusDeviceClass, (obj), TYPE_SMBUS_DEVICE)
 
+typedef struct SMBusDevice SMBusDevice;
+
 typedef struct SMBusDeviceClass
 {
     I2CSlaveClass parent_class;
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 3a5ca74..26e40fd 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -106,7 +106,6 @@ typedef struct RAMBlock RAMBlock;
 typedef struct Range Range;
 typedef struct SerialState SerialState;
 typedef struct SHPCDevice SHPCDevice;
-typedef struct SMBusDevice SMBusDevice;
 typedef struct uWireSlave uWireSlave;
 typedef struct VirtIODevice VirtIODevice;
 typedef struct Visitor Visitor;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 15/25] hw/bt: Remove HCIInfo from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (13 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 14/25] hw/i2c/smbus: Remove SMBusDevice " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 16/25] hw/char/serial: Remove SerialState " Thomas Huth
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Files requiring HCIInfo already include "sysemu/bt.h".

To clean "qemu/typedefs.h", move the declaration to "sysemu/bt.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/qemu/typedefs.h | 1 -
 include/sysemu/bt.h     | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 26e40fd..7271e98 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -35,7 +35,6 @@ typedef struct FWCfgEntry FWCfgEntry;
 typedef struct FWCfgIoState FWCfgIoState;
 typedef struct FWCfgMemState FWCfgMemState;
 typedef struct FWCfgState FWCfgState;
-typedef struct HCIInfo HCIInfo;
 typedef struct HVFX86EmulatorState HVFX86EmulatorState;
 typedef struct I2CBus I2CBus;
 typedef struct I2SCodec I2SCodec;
diff --git a/include/sysemu/bt.h b/include/sysemu/bt.h
index ddb05cd..2fd8c0f 100644
--- a/include/sysemu/bt.h
+++ b/include/sysemu/bt.h
@@ -3,7 +3,7 @@
 
 /* BT HCI info */
 
-struct HCIInfo {
+typedef struct HCIInfo {
     int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
     void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
     void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
@@ -11,7 +11,7 @@ struct HCIInfo {
     void *opaque;
     void (*evt_recv)(void *opaque, const uint8_t *data, int len);
     void (*acl_recv)(void *opaque, const uint8_t *data, int len);
-};
+} HCIInfo;
 
 /* bt-host.c */
 struct HCIInfo *bt_host_hci(const char *id);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 16/25] hw/char/serial: Remove SerialState from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (14 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 15/25] hw/bt: Remove HCIInfo " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 17/25] hw/i386: Remove PCMachineClass " Thomas Huth
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Files requiring SerialState already include "hw/char/serial.h".

To clean "qemu/typedefs.h", move the declaration to "hw/char/serial.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/char/serial.h | 4 ++--
 include/qemu/typedefs.h  | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 0acfbbc..abd5cf7 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -35,7 +35,7 @@
 
 #define UART_FIFO_LENGTH    16      /* 16550A Fifo Length */
 
-struct SerialState {
+typedef struct SerialState {
     uint16_t divider;
     uint8_t rbr; /* receive register */
     uint8_t thr; /* transmit holding register */
@@ -77,7 +77,7 @@ struct SerialState {
 
     QEMUTimer *modem_status_poll;
     MemoryRegion io;
-};
+} SerialState;
 
 extern const VMStateDescription vmstate_serial;
 extern const MemoryRegionOps serial_io_ops;
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 7271e98..4c694b7 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -103,7 +103,6 @@ typedef struct QObject QObject;
 typedef struct QString QString;
 typedef struct RAMBlock RAMBlock;
 typedef struct Range Range;
-typedef struct SerialState SerialState;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct uWireSlave uWireSlave;
 typedef struct VirtIODevice VirtIODevice;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 17/25] hw/i386: Remove PCMachineClass from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (15 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 16/25] hw/char/serial: Remove SerialState " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 18/25] audio: Remove AudioState " Thomas Huth
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Files requiring PCMachineClass already include "hw/i386/pc.h".

To clean "qemu/typedefs.h", move the declaration to "hw/i386/pc.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/i386/pc.h    | 4 ++--
 include/qemu/typedefs.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 0abbe45..882fd8d 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -96,7 +96,7 @@ struct PCMachineState {
  *                  way we can use 1GByte pages in the host.
  *
  */
-struct PCMachineClass {
+typedef struct PCMachineClass {
     /*< private >*/
     MachineClass parent_class;
 
@@ -133,7 +133,7 @@ struct PCMachineClass {
 
     /* use DMA capable linuxboot option rom */
     bool linuxboot_dma_enabled;
-};
+} PCMachineClass;
 
 #define TYPE_PC_MACHINE "generic-pc-machine"
 #define PC_MACHINE(obj) \
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 4c694b7..5edf44e 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -74,7 +74,6 @@ typedef struct PCIExpressDevice PCIExpressDevice;
 typedef struct PCIExpressHost PCIExpressHost;
 typedef struct PCIHostDeviceAddress PCIHostDeviceAddress;
 typedef struct PCIHostState PCIHostState;
-typedef struct PCMachineClass PCMachineClass;
 typedef struct PCMachineState PCMachineState;
 typedef struct PixelFormat PixelFormat;
 typedef struct PostcopyDiscardState PostcopyDiscardState;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 18/25] audio: Remove AudioState from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (16 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 17/25] hw/i386: Remove PCMachineClass " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 19/25] ui/console: Remove QemuDmaBuf " Thomas Huth
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Files requiring AudioState already include "audio_int.h".

To clean "qemu/typedefs.h", move the declaration to "audio_int.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 audio/audio_int.h       | 4 ++--
 include/qemu/typedefs.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/audio/audio_int.h b/audio/audio_int.h
index 244b454..6c451b9 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -191,7 +191,7 @@ struct SWVoiceCap {
     QLIST_ENTRY (SWVoiceCap) entries;
 };
 
-struct AudioState {
+typedef struct AudioState {
     struct audio_driver *drv;
     void *drv_opaque;
 
@@ -203,7 +203,7 @@ struct AudioState {
     int nb_hw_voices_out;
     int nb_hw_voices_in;
     int vm_running;
-};
+} AudioState;
 
 extern const struct mixeng_volume nominal_volume;
 
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 5edf44e..c6d1c1b 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -8,7 +8,6 @@
 typedef struct AdapterInfo AdapterInfo;
 typedef struct AddressSpace AddressSpace;
 typedef struct AioContext AioContext;
-typedef struct AudioState AudioState;
 typedef struct BdrvDirtyBitmap BdrvDirtyBitmap;
 typedef struct BdrvDirtyBitmapIter BdrvDirtyBitmapIter;
 typedef struct BlockBackend BlockBackend;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 19/25] ui/console: Remove QemuDmaBuf from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (17 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 18/25] audio: Remove AudioState " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 20/25] ui/console: Remove DisplayState/DisplaySurface " Thomas Huth
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Files requiring QemuDmaBuf already include "ui/console.h".

To clean "qemu/typedefs.h", move the declaration to "ui/console.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/qemu/typedefs.h | 1 -
 include/ui/console.h    | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index c6d1c1b..67dd04f 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -82,7 +82,6 @@ typedef struct QBool QBool;
 typedef struct QDict QDict;
 typedef struct QEMUBH QEMUBH;
 typedef struct QemuConsole QemuConsole;
-typedef struct QemuDmaBuf QemuDmaBuf;
 typedef struct QEMUFile QEMUFile;
 typedef struct QemuLockable QemuLockable;
 typedef struct QemuMutex QemuMutex;
diff --git a/include/ui/console.h b/include/ui/console.h
index 853fcf4..c4f497c 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -179,7 +179,7 @@ struct QEMUGLParams {
     int minor_ver;
 };
 
-struct QemuDmaBuf {
+typedef struct QemuDmaBuf {
     int       fd;
     uint32_t  width;
     uint32_t  height;
@@ -187,7 +187,7 @@ struct QemuDmaBuf {
     uint32_t  fourcc;
     uint32_t  texture;
     bool      y0_top;
-};
+} QemuDmaBuf;
 
 typedef struct DisplayChangeListenerOps {
     const char *dpy_name;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 20/25] ui/console: Remove DisplayState/DisplaySurface from "qemu/typedefs.h"
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (18 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 19/25] ui/console: Remove QemuDmaBuf " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 21/25] linux-user: Fix compilation with clang 3.4 Thomas Huth
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Files requiring DisplayState/DisplaySurface already include "ui/console.h".

To clean "qemu/typedefs.h", move the declarations to "ui/console.h"
(removing DisplaySurface forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/qemu/typedefs.h | 2 --
 include/ui/console.h    | 6 ++++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 67dd04f..30ad8b2 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -24,8 +24,6 @@ typedef struct DeviceListener DeviceListener;
 typedef struct DeviceState DeviceState;
 typedef struct DirtyBitmapSnapshot DirtyBitmapSnapshot;
 typedef struct DisplayChangeListener DisplayChangeListener;
-typedef struct DisplayState DisplayState;
-typedef struct DisplaySurface DisplaySurface;
 typedef struct DriveInfo DriveInfo;
 typedef struct Error Error;
 typedef struct EventNotifier EventNotifier;
diff --git a/include/ui/console.h b/include/ui/console.h
index c4f497c..0a19037 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -131,7 +131,7 @@ struct PixelFormat {
     uint8_t rbits, gbits, bbits, abits;
 };
 
-struct DisplaySurface {
+typedef struct DisplaySurface {
     pixman_format_code_t format;
     pixman_image_t *image;
     uint8_t flags;
@@ -140,7 +140,7 @@ struct DisplaySurface {
     GLenum gltype;
     GLuint texture;
 #endif
-};
+} DisplaySurface;
 
 typedef struct QemuUIInfo {
     /* geometry */
@@ -189,6 +189,8 @@ typedef struct QemuDmaBuf {
     bool      y0_top;
 } QemuDmaBuf;
 
+typedef struct DisplayState DisplayState;
+
 typedef struct DisplayChangeListenerOps {
     const char *dpy_name;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 21/25] linux-user: Fix compilation with clang 3.4
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (19 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 20/25] ui/console: Remove DisplayState/DisplaySurface " Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 22/25] ppc: Move spapr-related prototypes from xics.h into a seperate header file Thomas Huth
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

Clang version 3.4.2 does not know the -Wpragmas option yet and bails
out with an error when we try to disable it in linux-user/qemu.h.
Fortunately, clang has a __has_warning() macro which allows us to add
an explicit check for the option that we want to ignore. With that we
can check for the availability of "-Waddress-of-packed-member" properly
and do not need the "-Wpragmas" at all here.

Fixes: 850d5e330a9c68cc998cecc02caf8a3c8d1ee8a3
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/qemu/compiler.h | 4 ++++
 linux-user/qemu.h       | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 261842b..28fa438 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -113,6 +113,10 @@
 #define GCC_FMT_ATTR(n, m)
 #endif
 
+#ifndef __has_warning
+#define __has_warning(x) 0 /* compatibility with non-clang compilers */
+#endif
+
 #ifndef __has_feature
 #define __has_feature(x) 0 /* compatibility with non-clang compilers */
 #endif
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 069df8f..ef400cb 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -474,17 +474,13 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
  *   functions than host-endian unaligned load/store plus tswapN.
  * - The pragmas are necessary only to silence a clang false-positive
  *   warning: see https://bugs.llvm.org/show_bug.cgi?id=39113 .
- * - We have to disable -Wpragmas warnings to avoid a complaint about
- *   an unknown warning type from older compilers that don't know about
- *   -Waddress-of-packed-member.
  * - gcc has bugs in its _Pragma() support in some versions, eg
  *   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83256 -- so we only
  *   include the warning-suppression pragmas for clang
  */
-#ifdef __clang__
+#if defined(__clang__) && __has_warning("-Waddress-of-packed-member")
 #define PRAGMA_DISABLE_PACKED_WARNING                                   \
     _Pragma("GCC diagnostic push");                                     \
-    _Pragma("GCC diagnostic ignored \"-Wpragmas\"");                    \
     _Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\"")
 
 #define PRAGMA_REENABLE_PACKED_WARNING          \
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 22/25] ppc: Move spapr-related prototypes from xics.h into a seperate header file
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (20 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 21/25] linux-user: Fix compilation with clang 3.4 Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 23/25] ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode Thomas Huth
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

When compiling with Clang in -std=gnu99 mode, there is a warning/error:

  CC      ppc64-softmmu/hw/intc/xics_spapr.o
In file included from /home/thuth/devel/qemu/hw/intc/xics_spapr.c:34:
/home/thuth/devel/qemu/include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
      [-Werror,-Wtypedef-redefinition]
typedef struct sPAPRMachineState sPAPRMachineState;
                                 ^
/home/thuth/devel/qemu/include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here
typedef struct sPAPRMachineState sPAPRMachineState;
                                 ^

We have to remove the duplicated typedef here and include "spapr.h" instead.
But "spapr.h" should not be included for the pnv machine files. So move
the spapr-related prototypes into a new file called "xics_spapr.h" instead.

Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/intc/xics_kvm.c          |  1 +
 hw/intc/xics_spapr.c        |  1 +
 hw/ppc/spapr_irq.c          |  1 +
 include/hw/ppc/xics.h       |  7 -------
 include/hw/ppc/xics_spapr.h | 37 +++++++++++++++++++++++++++++++++++++
 5 files changed, 40 insertions(+), 7 deletions(-)
 create mode 100644 include/hw/ppc/xics_spapr.h

diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index ac94594..dff1330 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -34,6 +34,7 @@
 #include "sysemu/kvm.h"
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/xics.h"
+#include "hw/ppc/xics_spapr.h"
 #include "kvm_ppc.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 9c1a90d..de6cc15 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -32,6 +32,7 @@
 #include "qemu/timer.h"
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/xics.h"
+#include "hw/ppc/xics_spapr.h"
 #include "hw/ppc/fdt.h"
 #include "qapi/visitor.h"
 
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
index 5fce72f..1da7a32 100644
--- a/hw/ppc/spapr_irq.c
+++ b/hw/ppc/spapr_irq.c
@@ -14,6 +14,7 @@
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_xive.h"
 #include "hw/ppc/xics.h"
+#include "hw/ppc/xics_spapr.h"
 #include "sysemu/kvm.h"
 
 #include "trace.h"
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 07508cb..fad786e 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -200,13 +200,6 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon);
 void ics_resend(ICSState *ics);
 void icp_resend(ICPState *ss);
 
-typedef struct sPAPRMachineState sPAPRMachineState;
-
-void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
-                   uint32_t phandle);
-int xics_kvm_init(sPAPRMachineState *spapr, Error **errp);
-void xics_spapr_init(sPAPRMachineState *spapr);
-
 Object *icp_create(Object *cpu, const char *type, XICSFabric *xi,
                    Error **errp);
 
diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h
new file mode 100644
index 0000000..b1ab27d
--- /dev/null
+++ b/include/hw/ppc/xics_spapr.h
@@ -0,0 +1,37 @@
+/*
+ * QEMU PowerPC pSeries Logical Partition (aka sPAPR) hardware System Emulator
+ *
+ * PAPR Virtualized Interrupt System, aka ICS/ICP aka xics
+ *
+ * Copyright (c) 2010, 2011 David Gibson, IBM Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef XICS_SPAPR_H
+#define XICS_SPAPR_H
+
+#include "hw/ppc/spapr.h"
+
+void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
+                   uint32_t phandle);
+int xics_kvm_init(sPAPRMachineState *spapr, Error **errp);
+void xics_spapr_init(sPAPRMachineState *spapr);
+
+#endif /* XICS_SPAPR_H */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 23/25] ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (21 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 22/25] ppc: Move spapr-related prototypes from xics.h into a seperate header file Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 24/25] configure: Force the C standard to gnu99 Thomas Huth
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

When compiling the ppc code with clang and -std=gnu99, there are a
couple of warnings/errors like this one:

  CC      ppc64-softmmu/hw/intc/xics.o
In file included from hw/intc/xics.c:35:
include/hw/ppc/xics.h:43:25: error: redefinition of typedef 'ICPState' is a C11 feature
      [-Werror,-Wtypedef-redefinition]
typedef struct ICPState ICPState;
                        ^
target/ppc/cpu.h:1181:25: note: previous definition is here
typedef struct ICPState ICPState;
                        ^
Work around the problems by including the proper headers instead.

Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/ppc/spapr.h      |  5 +++--
 include/hw/ppc/spapr_xive.h |  2 --
 target/ppc/cpu.h            | 13 +++++++++----
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 9e01a5a..a947a0a 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -8,15 +8,16 @@
 #include "hw/mem/pc-dimm.h"
 #include "hw/ppc/spapr_ovec.h"
 #include "hw/ppc/spapr_irq.h"
+#include "hw/ppc/spapr_xive.h"  /* For sPAPRXive */
+#include "hw/ppc/xics.h"        /* For ICSState */
 
 struct VIOsPAPRBus;
 struct sPAPRPHBState;
 struct sPAPRNVRAM;
+
 typedef struct sPAPREventLogEntry sPAPREventLogEntry;
 typedef struct sPAPREventSource sPAPREventSource;
 typedef struct sPAPRPendingHPT sPAPRPendingHPT;
-typedef struct ICSState ICSState;
-typedef struct sPAPRXive sPAPRXive;
 
 #define HPTE64_V_HPTE_DIRTY     0x0000000000000040ULL
 #define SPAPR_ENTRY_POINT       0x100
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index 7fdc250..9bec919 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -41,8 +41,6 @@ bool spapr_xive_irq_claim(sPAPRXive *xive, uint32_t lisn, bool lsi);
 bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn);
 void spapr_xive_pic_print_info(sPAPRXive *xive, Monitor *mon);
 
-typedef struct sPAPRMachineState sPAPRMachineState;
-
 void spapr_xive_hcall_init(sPAPRMachineState *spapr);
 void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
                    uint32_t phandle);
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 486abaf..bde4dff 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -23,6 +23,11 @@
 #include "qemu-common.h"
 #include "qemu/int128.h"
 
+#ifndef CONFIG_USER_ONLY
+#include "hw/ppc/xive.h" /* for XiveTCTX */
+#include "hw/ppc/xics.h" /* for ICPState */
+#endif
+
 //#define PPC_EMULATE_32BITS_HYPV
 
 #if defined (TARGET_PPC64)
@@ -1177,8 +1182,6 @@ do {                                            \
 
 typedef struct PPCVirtualHypervisor PPCVirtualHypervisor;
 typedef struct PPCVirtualHypervisorClass PPCVirtualHypervisorClass;
-typedef struct XiveTCTX XiveTCTX;
-typedef struct ICPState ICPState;
 
 /**
  * PowerPCCPU:
@@ -1197,11 +1200,13 @@ struct PowerPCCPU {
     int vcpu_id;
     uint32_t compat_pvr;
     PPCVirtualHypervisor *vhyp;
-    ICPState *icp;
-    XiveTCTX *tctx;
     void *machine_data;
     int32_t node_id; /* NUMA node this CPU belongs to */
     PPCHash64Options *hash64_opts;
+#ifndef CONFIG_USER_ONLY
+    ICPState *icp;
+    XiveTCTX *tctx;
+#endif
 
     /* Fields related to migration compatibility hacks */
     bool pre_2_8_migration;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 24/25] configure: Force the C standard to gnu99
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (22 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 23/25] ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 10:02 ` [Qemu-devel] [PULL 25/25] tests/hexloader-test: Don't pass -nographic to the QEMU under test Thomas Huth
  2019-01-14 12:52 ` [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Peter Maydell
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

Different versions of GCC and Clang use different versions of the C standard.
This repeatedly caused problems already, e.g. with duplicated typedefs:

 https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05829.html

or with for-loop variable initializers:

 https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg00237.html

To avoid these problems, we should enforce the C language version to the
same level for all compilers. Since our minimum compiler versions is
GCC v4.8, our best option is "gnu99" for C code right now ("gnu17" is not
available there yet, and "gnu11" is marked as "experimental"), and "gnu++98"
for the few C++ code that we have in the repository.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 configure | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index e0915da..05b7e85 100755
--- a/configure
+++ b/configure
@@ -107,6 +107,9 @@ update_cxxflags() {
             -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
             -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
                 ;;
+            -std=gnu99)
+                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98"
+                ;;
             *)
                 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
                 ;;
@@ -585,7 +588,7 @@ ARFLAGS="${ARFLAGS-rv}"
 # left shift of signed integers is well defined and has the expected
 # 2s-complement style results. (Both clang and gcc agree that it
 # provides these semantics.)
-QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
+QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PULL 25/25] tests/hexloader-test: Don't pass -nographic to the QEMU under test
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (23 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 24/25] configure: Force the C standard to gnu99 Thomas Huth
@ 2019-01-14 10:02 ` Thomas Huth
  2019-01-14 12:52 ` [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Peter Maydell
  25 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 10:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Philippe Mathieu-Daudé, Li Qiang

From: Peter Maydell <peter.maydell@linaro.org>

The hexloader test invokes QEMU with the -nographic argument. This
is unnecessary, because the qtest_initf() function will pass it
-display none, which suffices to disable the graphical window.
It also means that the QEMU process will make the stdin/stdout
O_NONBLOCK. Since O_NONBLOCK is not per-file descriptor but per
"file description", this non-blocking behaviour is then shared
with any other process that's using the stdin/stdout of the
'make check' run, including make itself. This can result in make
falling over with "make: write error: stdout" because it got
an unexpected EINTR trying to write output messages to the terminal.
This is particularly noticable if running 'make check' in a loop with
  while make check; do true; done
(It does not affect single make check runs so much because the
shell will remove the O_NONBLOCK status before it reads the
terminal for interactive input.)

Remove the unwanted -nographic argument.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/hexloader-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/hexloader-test.c b/tests/hexloader-test.c
index 834ed52..8b7aa2d 100644
--- a/tests/hexloader-test.c
+++ b/tests/hexloader-test.c
@@ -23,7 +23,7 @@ static void hex_loader_test(void)
     const unsigned int base_addr = 0x00010000;
 
     QTestState *s = qtest_initf(
-        "-M vexpress-a9 -nographic -device loader,file=tests/data/hex-loader/test.hex");
+        "-M vexpress-a9 -device loader,file=tests/data/hex-loader/test.hex");
 
     for (i = 0; i < 256; ++i) {
         uint8_t val = qtest_readb(s, base_addr + i);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99
  2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
                   ` (24 preceding siblings ...)
  2019-01-14 10:02 ` [Qemu-devel] [PULL 25/25] tests/hexloader-test: Don't pass -nographic to the QEMU under test Thomas Huth
@ 2019-01-14 12:52 ` Peter Maydell
  2019-01-14 12:58   ` Thomas Huth
  25 siblings, 1 reply; 28+ messages in thread
From: Peter Maydell @ 2019-01-14 12:52 UTC (permalink / raw)
  To: Thomas Huth; +Cc: QEMU Developers, Philippe Mathieu-Daudé, Li Qiang

On Mon, 14 Jan 2019 at 10:02, Thomas Huth <thuth@redhat.com> wrote:
>
>  Hi Peter,
>
> the following changes since commit 27df21ca3886fff4dd3d70e515517667963a52f1:
>
>   Merge remote-tracking branch 'remotes/kraxel/tags/misc-20190111-pull-request' into staging (2019-01-11 16:45:59 +0000)
>
> are available in the git repository at:
>
>   https://gitlab.com/huth/qemu.git tags/pull-request-2019-01-14
>
> for you to fetch changes up to 62c36a5f7cad3048bfc41ac24c0593f466b408f4:
>
>   tests/hexloader-test: Don't pass -nographic to the QEMU under test (2019-01-14 10:50:40 +0100)
>
> ----------------------------------------------------------------
> - Remove deprecated "ivshmem" legacy device
> - Bug fix for vhost-user-test
> - Use more CONFIG Makefile switches for qtests
> - Get rid of global_qtests in some more qtests
> - typedef cleanups
> - Fixes for compiling with Clang
> - Force C standard to gnu99
> ----------------------------------------------------------------

Compile failure, ppc64 host:

In file included from /home/pm215/qemu/block/iscsi.c:52:0:
/usr/include/iscsi/scsi-lowlevel.h:810:13: error: inline function
‘scsi_set_uint16’ declared but never defined [-Werror]
 inline void scsi_set_uint16(unsigned char *c, uint16_t val);
             ^
/usr/include/iscsi/scsi-lowlevel.h:809:13: error: inline function
‘scsi_set_uint32’ declared but never defined [-Werror]
 inline void scsi_set_uint32(unsigned char *c, uint32_t val);
             ^
/usr/include/iscsi/scsi-lowlevel.h:808:17: error: inline function
‘scsi_get_uint16’ declared but never defined [-Werror]
 inline uint16_t scsi_get_uint16(const unsigned char *c);
                 ^
/usr/include/iscsi/scsi-lowlevel.h:807:17: error: inline function
‘scsi_get_uint32’ declared but never defined [-Werror]
 inline uint32_t scsi_get_uint32(const unsigned char *c);
                 ^
/usr/include/iscsi/scsi-lowlevel.h:810:13: error: inline function
‘scsi_set_uint16’ declared but never defined [-Werror]
 inline void scsi_set_uint16(unsigned char *c, uint16_t val);
             ^
/usr/include/iscsi/scsi-lowlevel.h:809:13: error: inline function
‘scsi_set_uint32’ declared but never defined [-Werror]
 inline void scsi_set_uint32(unsigned char *c, uint32_t val);
             ^
/usr/include/iscsi/scsi-lowlevel.h:808:17: error: inline function
‘scsi_get_uint16’ declared but never defined [-Werror]
 inline uint16_t scsi_get_uint16(const unsigned char *c);
                 ^
/usr/include/iscsi/scsi-lowlevel.h:807:17: error: inline function
‘scsi_get_uint32’ declared but never defined [-Werror]
 inline uint32_t scsi_get_uint32(const unsigned char *c);
                 ^

thanks
-- PMM

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99
  2019-01-14 12:52 ` [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Peter Maydell
@ 2019-01-14 12:58   ` Thomas Huth
  0 siblings, 0 replies; 28+ messages in thread
From: Thomas Huth @ 2019-01-14 12:58 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Philippe Mathieu-Daudé, Li Qiang

On 2019-01-14 13:52, Peter Maydell wrote:
> On Mon, 14 Jan 2019 at 10:02, Thomas Huth <thuth@redhat.com> wrote:
>>
>>  Hi Peter,
>>
>> the following changes since commit 27df21ca3886fff4dd3d70e515517667963a52f1:
>>
>>   Merge remote-tracking branch 'remotes/kraxel/tags/misc-20190111-pull-request' into staging (2019-01-11 16:45:59 +0000)
>>
>> are available in the git repository at:
>>
>>   https://gitlab.com/huth/qemu.git tags/pull-request-2019-01-14
>>
>> for you to fetch changes up to 62c36a5f7cad3048bfc41ac24c0593f466b408f4:
>>
>>   tests/hexloader-test: Don't pass -nographic to the QEMU under test (2019-01-14 10:50:40 +0100)
>>
>> ----------------------------------------------------------------
>> - Remove deprecated "ivshmem" legacy device
>> - Bug fix for vhost-user-test
>> - Use more CONFIG Makefile switches for qtests
>> - Get rid of global_qtests in some more qtests
>> - typedef cleanups
>> - Fixes for compiling with Clang
>> - Force C standard to gnu99
>> ----------------------------------------------------------------
> 
> Compile failure, ppc64 host:
> 
> In file included from /home/pm215/qemu/block/iscsi.c:52:0:
> /usr/include/iscsi/scsi-lowlevel.h:810:13: error: inline function
> ‘scsi_set_uint16’ declared but never defined [-Werror]
>  inline void scsi_set_uint16(unsigned char *c, uint16_t val);
>              ^

What the .... in a system header?? That's not fair... sigh, let me think
of a work-around...

 Thomas

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2019-01-14 12:58 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
2019-01-14 10:01 ` [Qemu-devel] [PULL 01/25] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device Thomas Huth
2019-01-14 10:01 ` [Qemu-devel] [PULL 02/25] tests: vhost-user-test: initialize 'fd' in chr_read Thomas Huth
2019-01-14 10:01 ` [Qemu-devel] [PULL 03/25] vhost-user: fix ioeventfd_enabled Thomas Huth
2019-01-14 10:01 ` [Qemu-devel] [PULL 04/25] util: check the return value of fcntl in qemu_set_{block, nonblock} Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 05/25] tests/Makefile: Use some more CONFIG switches for x86 tests Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 06/25] tests/Makefile: Use some more CONFIG switches for ppc tests Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 07/25] tests/endianesss: Make test independent of global_qtest Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 08/25] tests/boot-order: " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 09/25] tests/pnv-xscom: " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 10/25] hw/input/ps2: Remove PS2State from "qemu/typedefs.h" Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 11/25] hw/pcmcia: Remove PCMCIACardState " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 12/25] hw/ssi: Remove SSIBus " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 13/25] hw/ide/ahci: Remove AllwinnerAHCIState " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 14/25] hw/i2c/smbus: Remove SMBusDevice " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 15/25] hw/bt: Remove HCIInfo " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 16/25] hw/char/serial: Remove SerialState " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 17/25] hw/i386: Remove PCMachineClass " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 18/25] audio: Remove AudioState " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 19/25] ui/console: Remove QemuDmaBuf " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 20/25] ui/console: Remove DisplayState/DisplaySurface " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 21/25] linux-user: Fix compilation with clang 3.4 Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 22/25] ppc: Move spapr-related prototypes from xics.h into a seperate header file Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 23/25] ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 24/25] configure: Force the C standard to gnu99 Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 25/25] tests/hexloader-test: Don't pass -nographic to the QEMU under test Thomas Huth
2019-01-14 12:52 ` [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Peter Maydell
2019-01-14 12:58   ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).