[Bug 1890775] Re: Aten USB to Serial bridge does not work with qemu under Windows 10

2020-08-06 Thread Laci
I forgot that the environment is Windows 10 64 bit.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1890775

Title:
  Aten USB to Serial bridge does not work with qemu under Windows 10

Status in QEMU:
  New

Bug description:
  I would like to use MSDOS 6.22 with qemu (unfortunatelly lot of our test 
programs has been written in dos).
  I tried to connect two laptop by RS232 port, one of the machine have a 
built-in serial port and run with native MSDOS 6.22 with 4.0 norton commander. 
Another machine have only USB ports and i try to use a new Aten USB to Serial 
device. Ok. Has been started qemu with -serial and -chardev parameters, at 
startup appear a window with serial port setting such as baud rate, start bit, 
etc...

  Quemu has been satrted succeeded but serial port cannot be used
  becouse was nothing activited on usb serial adapter :(

  I tried same configuration with VirtualBox and everything was worked
  fine (serial connection was estabiled and copied several files from
  one machine into another machine), seems to be the emulated serial
  port has been worked fine.

  I would like to use qemu, i just thougt qemu is better, simple and
  faster...

  Exists solution or is this a qemu bug?

  Thank you!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1890775/+subscriptions



[Bug 1890775] [NEW] Aten USB to Serial bridge does not work with qemu under Windows 10

2020-08-06 Thread Laci
Public bug reported:

I would like to use MSDOS 6.22 with qemu (unfortunatelly lot of our test 
programs has been written in dos).
I tried to connect two laptop by RS232 port, one of the machine have a built-in 
serial port and run with native MSDOS 6.22 with 4.0 norton commander. Another 
machine have only USB ports and i try to use a new Aten USB to Serial device. 
Ok. Has been started qemu with -serial and -chardev parameters, at startup 
appear a window with serial port setting such as baud rate, start bit, etc...

Quemu has been satrted succeeded but serial port cannot be used becouse
was nothing activited on usb serial adapter :(

I tried same configuration with VirtualBox and everything was worked
fine (serial connection was estabiled and copied several files from one
machine into another machine), seems to be the emulated serial port has
been worked fine.

I would like to use qemu, i just thougt qemu is better, simple and
faster...

Exists solution or is this a qemu bug?

Thank you!

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1890775

Title:
  Aten USB to Serial bridge does not work with qemu under Windows 10

Status in QEMU:
  New

Bug description:
  I would like to use MSDOS 6.22 with qemu (unfortunatelly lot of our test 
programs has been written in dos).
  I tried to connect two laptop by RS232 port, one of the machine have a 
built-in serial port and run with native MSDOS 6.22 with 4.0 norton commander. 
Another machine have only USB ports and i try to use a new Aten USB to Serial 
device. Ok. Has been started qemu with -serial and -chardev parameters, at 
startup appear a window with serial port setting such as baud rate, start bit, 
etc...

  Quemu has been satrted succeeded but serial port cannot be used
  becouse was nothing activited on usb serial adapter :(

  I tried same configuration with VirtualBox and everything was worked
  fine (serial connection was estabiled and copied several files from
  one machine into another machine), seems to be the emulated serial
  port has been worked fine.

  I would like to use qemu, i just thougt qemu is better, simple and
  faster...

  Exists solution or is this a qemu bug?

  Thank you!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1890775/+subscriptions



[PATCH for-5.2] hw/null-machine: Add the kvm_type() hook for MIPS

2020-08-06 Thread Huacai Chen
MIPS has two types of KVM: TE & VZ, and TE is the default type. Now,
libvirt uses a null-machine to detect the kvm capability. In the MIPS
case, it will return "KVM not supported" on a VZ platform by default.
So, add the kvm_type() hook to the null-machine.

This seems not a very good solution, but I cannot do it better now.

Reviewed-by: Aleksandar Markovic 
Signed-off-by: Huacai Chen 
Co-developed-by: Jiaxun Yang 
---
 hw/core/Makefile.objs  | 2 +-
 hw/core/null-machine.c | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
index d8fee8e..2daba3f 100644
--- a/hw/core/Makefile.objs
+++ b/hw/core/Makefile.objs
@@ -17,11 +17,11 @@ common-obj-$(CONFIG_SOFTMMU) += vm-change-state-handler.o
 common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o
 common-obj-$(CONFIG_SOFTMMU) += sysbus.o
 common-obj-$(CONFIG_SOFTMMU) += machine.o
-common-obj-$(CONFIG_SOFTMMU) += null-machine.o
 common-obj-$(CONFIG_SOFTMMU) += loader.o
 common-obj-$(CONFIG_SOFTMMU) += machine-hmp-cmds.o
 common-obj-$(CONFIG_SOFTMMU) += numa.o
 common-obj-$(CONFIG_SOFTMMU) += clock-vmstate.o
+obj-$(CONFIG_SOFTMMU) += null-machine.o
 obj-$(CONFIG_SOFTMMU) += machine-qmp-cmds.o
 
 common-obj-$(CONFIG_XILINX_AXI) += stream.o
diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index cb47d9d..1adba5d 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -17,6 +17,9 @@
 #include "sysemu/sysemu.h"
 #include "exec/address-spaces.h"
 #include "hw/core/cpu.h"
+#ifdef TARGET_MIPS
+#include "kvm_mips.h"
+#endif
 
 static void machine_none_init(MachineState *mch)
 {
@@ -50,6 +53,9 @@ static void machine_none_machine_init(MachineClass *mc)
 mc->no_floppy = 1;
 mc->no_cdrom = 1;
 mc->no_sdcard = 1;
+#ifdef TARGET_MIPS
+mc->kvm_type = mips_kvm_type;
+#endif
 }
 
 DEFINE_MACHINE("none", machine_none_machine_init)
-- 
2.7.0




[PATCH V7 for-5.2] hw/mips: Add Loongson-3 machine support (with KVM)

2020-08-06 Thread Huacai Chen
Add Loongson-3 based machine support, it use liointc as the interrupt
controler and use GPEX as the pci controller. Currently it can only work
with KVM, but we will add TCG support in future.

As the machine model is not based on any exiting physical hardware, the
name of the machine is "loongson3-virt". It may be superseded in future
by a real machine model. If this happens, then a regular deprecation
procedure shall occur for "loongson3-virt" machine.

We now already have a full functional Linux kernel (based on Linux-5.4.x
LTS, the kvm host side and guest side have both been upstream for Linux-
5.9, but Linux-5.9 has not been released yet) here:

https://github.com/chenhuacai/linux

Of course the upstream kernel is also usable (though it is "unstable"
now):

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

How to use QEMU/Loongson-3?
1, Download kernel source from the above URL;
2, Build a kernel with arch/mips/configs/loongson3_defconfig;
3, Boot the a Loongson-3A4000 host with this kernel;
4, Build QEMU-master with this patchset;
5, modprobe kvm;
6, Use QEMU with TCG (available in future):
   qemu-system-mips64el -M loongson3-virt,accel=tcg -cpu Loongson-3A1000 
-kernel  -append ...
   Use QEMU with KVM (available at present):
   qemu-system-mips64el -M loongson3-virt,accel=kvm -cpu Loongson-3A4000 
-kernel  -append ...

   The "-cpu" parameter is optional here and QEMU will use the correct type for 
TCG/KVM automatically.

Signed-off-by: Huacai Chen 
Co-developed-by: Jiaxun Yang 
---
 default-configs/mips64el-softmmu.mak |   1 +
 hw/mips/Kconfig  |  11 +
 hw/mips/Makefile.objs|   1 +
 hw/mips/loongson3_virt.c | 965 +++
 4 files changed, 978 insertions(+)
 create mode 100644 hw/mips/loongson3_virt.c

diff --git a/default-configs/mips64el-softmmu.mak 
b/default-configs/mips64el-softmmu.mak
index 9f8a3ef..26c660a 100644
--- a/default-configs/mips64el-softmmu.mak
+++ b/default-configs/mips64el-softmmu.mak
@@ -3,6 +3,7 @@
 include mips-softmmu-common.mak
 CONFIG_IDE_VIA=y
 CONFIG_FULOONG=y
+CONFIG_LOONGSON3V=y
 CONFIG_ATI_VGA=y
 CONFIG_RTL8139_PCI=y
 CONFIG_JAZZ=y
diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
index 67d39c5..cc5609b 100644
--- a/hw/mips/Kconfig
+++ b/hw/mips/Kconfig
@@ -45,6 +45,17 @@ config FULOONG
 bool
 select PCI_BONITO
 
+config LOONGSON3V
+bool
+select PCKBD
+select SERIAL
+select GOLDFISH_RTC
+select LOONGSON_LIOINTC
+select PCI_EXPRESS_GENERIC_BRIDGE
+select VIRTIO_VGA
+select QXL if SPICE
+select MSI_NONBROKEN
+
 config MIPS_CPS
 bool
 select PTIMER
diff --git a/hw/mips/Makefile.objs b/hw/mips/Makefile.objs
index 739e2b7..0993852 100644
--- a/hw/mips/Makefile.objs
+++ b/hw/mips/Makefile.objs
@@ -4,5 +4,6 @@ obj-$(CONFIG_MALTA) += gt64xxx_pci.o malta.o
 obj-$(CONFIG_MIPSSIM) += mipssim.o
 obj-$(CONFIG_JAZZ) += jazz.o
 obj-$(CONFIG_FULOONG) += fuloong2e.o
+obj-$(CONFIG_LOONGSON3V) += loongson3_virt.o
 obj-$(CONFIG_MIPS_CPS) += cps.o
 obj-$(CONFIG_MIPS_BOSTON) += boston.o
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
new file mode 100644
index 000..dec3b91
--- /dev/null
+++ b/hw/mips/loongson3_virt.c
@@ -0,0 +1,963 @@
+/*
+ * Generic Loongson-3 Platform support
+ *
+ * Copyright (c) 2017-2020 Huacai Chen (che...@lemote.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/*
+ * Generic virtualized PC Platform based on Loongson-3 CPU (MIPS64R2 with
+ * extensions, 800~2000MHz)
+ */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qemu/units.h"
+#include "qapi/error.h"
+#include "cpu.h"
+#include "elf.h"
+#include "kvm_mips.h"
+#include "hw/boards.h"
+#include "hw/char/serial.h"
+#include "hw/mips/mips.h"
+#include "hw/mips/cpudevs.h"
+#include "hw/misc/empty_slot.h"
+#include "hw/intc/i8259.h"
+#include "hw/loader.h"
+#include "hw/isa/superio.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/pci_host.h"
+#include "hw/pci-host/gpex.h"
+#include "hw/rtc/mc146818rtc.h"
+#include "hw/usb.h"
+#include "net/net.h"
+#include "exec/address-spaces.h"
+#include "sysemu/kvm.h"
+#include "sysemu/qtest.h"
+#include "sysemu/reset.h"
+#include "sysemu/runstate.h"
+#include "qemu/log.h"
+#include "qemu/error-report.h"
+
+#define PM_CNTL_MODE  0x10
+
+/* Overall MMIO & 

Re: Any reason VIRTQUEUE_MAX_SIZE is 1024? Can we increase this limit?

2020-08-06 Thread Jason Wang



On 2020/8/6 下午8:37, Stefan Hajnoczi wrote:

On Wed, Aug 05, 2020 at 08:13:29AM -0400, Michael S. Tsirkin wrote:

On Wed, Aug 05, 2020 at 01:11:07PM +0100, Stefan Hajnoczi wrote:

On Thu, Jul 30, 2020 at 07:46:09AM +, Yajun Wu wrote:

I'm doing iperf test on VIRTIO net through vhost-user(HW VDPA).
Find maximal acceptable tx_queue_size/rx_queue_size is 1024.
Basically increase queue size can get better RX rate for my case.

Can we increase the limit(VIRTQUEUE_MAX_SIZE) to 8192 to possibly gain better 
performance?

Hi,
The VIRTIO 1.1 specification says the maximum number of descriptors is
32768 for both split and packed virtqueues.

The vhost kernel code seems to support 32768.

The 1024 limit is an implementation limit in QEMU. Increasing it would
require QEMU code changes. For example, VIRTQUEUE_MAX_SIZE is used as
the size of arrays.

I can't think of a fundamental reason why QEMU needs to limit itself to
1024 descriptors. Raising the limit would require fixing up the code and
ensuring that live migration remains compatible with older versions of
QEMU.

Stefan

There's actually a reason for a limit: in theory the vq size
also sets a limit on the number of scatter/gather entries.
both QEMU and vhost can't handle a packet split over > 1k chunks.

We could add an extra limit for s/g size like block and scsi do,
this will need spec, guest and host side work.

Interesting, thanks for explaining! This could be made explicit by
changing the QEMU code to:

include/hw/virtio/virtio.h:#define VIRTQUEUE_MAX_SIZE IOV_MAX

Looking more closely at the vhost kernel code I see that UIO_MAXIOV is
used in some places but not in vhost_vring_set_num() (ioctl
VHOST_SET_VRING_NUM). Is there a reason why UIO_MAXIOV isn't enforced
when the application sets the queue size?



Actually three things:

1) queue size
2) #descriptors in a list
3) IOV size

Spec limit the 2) to 1) but 2) may not equal to 3).

So enforcing UIO_MAXIOV can not solve the problem completely.

For vhost-net, it depends on socket to build skb which requires an iov 
array to work. We need remove this limitation by:


- build skb by vhost-net itself
- do piecewise copying

Then we're not limited with #iov and more and support up to what spec 
supports.


Thanks




Stefan





Re: [PATCH for-5.2 16/19] aspeed/sdmc: Perform memory training

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:38, Philippe Mathieu-Daudé  wrote:

> > @@ -206,6 +206,19 @@ static void aspeed_sdmc_reset(DeviceState *dev)
> >
> >  /* Set ram size bit and defaults values */
> >  s->regs[R_CONF] = asc->compute_conf(s, 0);
> > +
> > +/*
> > + * PHY status:
> > + *  - set phy status ok (set bit 1)
> > + *  - initial PVT calibration ok (clear bit 3)
> > + *  - runtime calibration ok (clear bit 5)
> > + */
> > +s->regs[0x100] = BIT(1);
>
> This is usually implemented with a one-shot timer, see
> sd_ocr_powerup() in hw/sd/sd.c (migration is handled).

You mean we could have the calibration done bits become set at a later time?

It would be hard to work out what to do. We have no documentation for
the register, I modelled it based on the code in u-boot doing this:

 /* make sure DDR-PHY is ready before access */
do {
reg = readl(priv->phy_status) & BIT(1);
} while(reg == 0);

So I think there would be limited value in modelling it.

Thanks for the suggestion though, I'll keep the one shot timer idea in
mind for future models.

Cheers,

Joel



Re: [PATCH for-5.2 19/19] aspeed/smc: Open AHB window of the second chip of the AST2600 FMC controller

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> This change works around the HW default values to be able to test the
> tacoma board with -kernel command line option.
>
> Signed-off-by: Cédric Le Goater 

Good fix. This was required for Tacoma when we had both flash chips
enabled in the device tree, otherwise Linux would fail to probe the
entire controller leaving it with no rootfs.

Reviewed-by: Joel Stanley 

> ---
>  hw/ssi/aspeed_smc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index 8c79a5552f93..795784e5f364 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -230,7 +230,7 @@ static void aspeed_smc_reg_to_segment(const 
> AspeedSMCState *s, uint32_t reg,
>
>  static const AspeedSegments aspeed_segments_ast2600_fmc[] = {
>  { 0x0, 128 * MiB }, /* start address is readonly */
> -{ 0x0, 0 }, /* disabled */
> +{ 128 * MiB, 128 * MiB }, /* default is disabled but needed for -kernel 
> */
>  { 0x0, 0 }, /* disabled */
>  };
>
> --
> 2.25.4
>



Re: [PATCH for-5.2 18/19] aspeed/sdmc: Simplify calculation of RAM bits

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> Changes in commit 533eb415df2e ("arm/aspeed: actually check RAM size")
> introduced a 'valid_ram_sizes' array which can be used to compute the
> associated bit field value encoding the RAM size. The field is simply
> the index of the array.
>
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/misc/aspeed_sdmc.c | 79 ++-
>  1 file changed, 25 insertions(+), 54 deletions(-)
>
> diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c
> index 81c73450ab5d..08f856cbda7e 100644
> --- a/hw/misc/aspeed_sdmc.c
> +++ b/hw/misc/aspeed_sdmc.c
> @@ -159,57 +159,6 @@ static const MemoryRegionOps aspeed_sdmc_ops = {
>  .valid.max_access_size = 4,
>  };
>
> -static int ast2400_rambits(AspeedSDMCState *s)
> -{
> -switch (s->ram_size >> 20) {
> -case 64:
> -return ASPEED_SDMC_DRAM_64MB;
> -case 128:
> -return ASPEED_SDMC_DRAM_128MB;
> -case 256:
> -return ASPEED_SDMC_DRAM_256MB;
> -case 512:
> -return ASPEED_SDMC_DRAM_512MB;
> -default:
> -g_assert_not_reached();
> -break;
> -}
> -}
> -
> -static int ast2500_rambits(AspeedSDMCState *s)
> -{
> -switch (s->ram_size >> 20) {
> -case 128:
> -return ASPEED_SDMC_AST2500_128MB;
> -case 256:
> -return ASPEED_SDMC_AST2500_256MB;
> -case 512:
> -return ASPEED_SDMC_AST2500_512MB;
> -case 1024:
> -return ASPEED_SDMC_AST2500_1024MB;
> -default:
> -g_assert_not_reached();
> -break;
> -}
> -}
> -
> -static int ast2600_rambits(AspeedSDMCState *s)
> -{
> -switch (s->ram_size >> 20) {
> -case 256:
> -return ASPEED_SDMC_AST2600_256MB;
> -case 512:
> -return ASPEED_SDMC_AST2600_512MB;
> -case 1024:
> -return ASPEED_SDMC_AST2600_1024MB;
> -case 2048:
> -return ASPEED_SDMC_AST2600_2048MB;
> -default:
> -g_assert_not_reached();
> -break;
> -}
> -}
> -
>  static void aspeed_sdmc_reset(DeviceState *dev)
>  {
>  AspeedSDMCState *s = ASPEED_SDMC(dev);
> @@ -324,10 +273,32 @@ static const TypeInfo aspeed_sdmc_info = {
>  .abstract   = true,
>  };
>
> +static int aspeed_sdmc_get_ram_bits(AspeedSDMCState *s)
> +{
> +AspeedSDMCClass *asc = ASPEED_SDMC_GET_CLASS(s);
> +int i;
> +
> +/*
> + * The bitfield value encoding the RAM size is the index of the
> + * possible RAM size array
> + */
> +for (i = 0; asc->valid_ram_sizes[i]; i++) {
> +if (s->ram_size == asc->valid_ram_sizes[i]) {
> +return i;
> +}
> +}
> +
> +/*
> + * Invalid RAM sizes should have been excluded when setting the
> + * SoC RAM size.
> + */
> +g_assert_not_reached();
> +}
> +
>  static uint32_t aspeed_2400_sdmc_compute_conf(AspeedSDMCState *s, uint32_t 
> data)
>  {
>  uint32_t fixed_conf = ASPEED_SDMC_VGA_COMPAT |
> -ASPEED_SDMC_DRAM_SIZE(ast2400_rambits(s));
> +ASPEED_SDMC_DRAM_SIZE(aspeed_sdmc_get_ram_bits(s));
>
>  /* Make sure readonly bits are kept */
>  data &= ~ASPEED_SDMC_READONLY_MASK;
> @@ -385,7 +356,7 @@ static uint32_t 
> aspeed_2500_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data)
>  uint32_t fixed_conf = ASPEED_SDMC_HW_VERSION(1) |
>  ASPEED_SDMC_VGA_APERTURE(ASPEED_SDMC_VGA_64MB) |
>  ASPEED_SDMC_CACHE_INITIAL_DONE |
> -ASPEED_SDMC_DRAM_SIZE(ast2500_rambits(s));
> +ASPEED_SDMC_DRAM_SIZE(aspeed_sdmc_get_ram_bits(s));
>
>  /* Make sure readonly bits are kept */
>  data &= ~ASPEED_SDMC_AST2500_READONLY_MASK;
> @@ -451,7 +422,7 @@ static uint32_t 
> aspeed_2600_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data)
>  {
>  uint32_t fixed_conf = ASPEED_SDMC_HW_VERSION(3) |
>  ASPEED_SDMC_VGA_APERTURE(ASPEED_SDMC_VGA_64MB) |
> -ASPEED_SDMC_DRAM_SIZE(ast2600_rambits(s));
> +ASPEED_SDMC_DRAM_SIZE(aspeed_sdmc_get_ram_bits(s));
>
>  /* Make sure readonly bits are kept (use ast2500 mask) */
>  data &= ~ASPEED_SDMC_AST2500_READONLY_MASK;
> --
> 2.25.4
>



Re: [RFC v3 26/71] target/riscv: rvv-1.0: update vext_max_elems() for load/store insns

2020-08-06 Thread Richard Henderson
On 8/6/20 3:46 AM, frank.ch...@sifive.com wrote:
> +static inline uint32_t vext_max_elems(uint32_t desc, uint32_t esz, bool 
> is_ldst)
>  {
> -return simd_maxsz(desc) << vext_lmul(desc);
> +/*
> + * As simd_desc support at most 256 bytes, the max vlen is 256 bits.
> + * so vlen in bytes (vlenb) is encoded as maxsz.
> + */
> +uint32_t vlenb = simd_maxsz(desc);
> +
> +if (is_ldst) {
> +/*
> + * Vector load/store instructions have the EEW encoded
> + * directly in the instructions. The maximum vector size is
> + * calculated with EMUL rather than LMUL.
> + */
> +uint32_t eew = ctzl(esz);
> +uint32_t sew = vext_sew(desc);
> +uint32_t lmul = vext_lmul(desc);
> +int32_t emul = eew - sew + lmul;
> +uint32_t emul_r = emul < 0 ? 0 : emul;
> +return 1 << (ctzl(vlenb) + emul_r - ctzl(esz));

As I said before, the is_ldst instructions should put the EEW and EMUL values
into the SEW and LMUL desc fields, so that this does not need to be
special-cased at all.

> +/* Return VLMAX */
> +return 1 << (ctzl(vlenb) + vext_lmul(desc) - ctzl(esz));

This is overly complicated.

(1) 1 << ctzl(vlenb) == vlenb.
(2) I'm not sure why esz is not already a log2 number.

This ought to look more like

  int scale = lmul - esz;
  return (scale < 0
  ? vlenb >> -scale
  : vlenb << scale);


r~



Re: [PATCH for-5.2 15/19] ftgmac100: Improve software reset

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> The software reset of the MAC needs a finer granularity. Not all
> registers are reseted and some setting in MACCR are kept.

'settings'

This makes the software reset incorrect, but the power on reset values
correct. Was that your goal?

If so, perhaps put that in the commit message.

>
> Cc: Frederic Konrad 
> Fixes: bd44300d1afc ("net: add FTGMAC100 support")
> Signed-off-by: Cédric Le Goater 
> ---
>  hw/net/ftgmac100.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 987b843fabc4..0740049c5268 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -655,11 +655,10 @@ static void ftgmac100_reset(DeviceState *d)
>  s->itc = 0;
>  s->aptcr = 1;
>  s->dblac = 0x00022f00;
> -s->revr = 0;
>  s->fear1 = 0;
>  s->tpafcr = 0xf1;
>
> -s->maccr = 0;
> +s->maccr &= FTGMAC100_MACCR_GIGA_MODE | FTGMAC100_MACCR_FAST_MODE;
>  s->phycr = 0;
>  s->phydata = 0;
>  s->fcr = 0x400;
> @@ -812,6 +811,7 @@ static void ftgmac100_write(void *opaque, hwaddr addr,
>  case FTGMAC100_MACCR: /* MAC Device control */
>  s->maccr = value;
>  if (value & FTGMAC100_MACCR_SW_RST) {
> +/* TODO: rework software reset to have a finer granularity */
>  ftgmac100_reset(DEVICE(s));
>  }
>
> --
> 2.25.4
>



Re: [PATCH for-5.2 14/19] ftgmac100: Fix integer overflow in ftgmac100_do_tx()

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> When inserting the VLAN tag in packets, memmove() can generate an
> integer overflow for packets whose length is less than 12 bytes.
>
> Check length against the size of the ethernet header (14 bytes) to
> avoid the crash and return FTGMAC100_INT_XPKT_LOST status. This seems
> like a good modeling choice even if Aspeed does not specify anything
> in that case.
>
> Cc: Frederic Konrad 
> Cc: Mauro Matteo Cascella 
> Reported-by: Ziming Zhang 
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/net/ftgmac100.c | 19 +++
>  1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 280aa3d3a1e2..987b843fabc4 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -540,10 +540,21 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t 
> tx_ring,
>  s->isr |= FTGMAC100_INT_XPKT_LOST;
>  len =  sizeof(s->frame) - frame_size - 4;
>  }
> -memmove(ptr + 16, ptr + 12, len - 12);
> -stw_be_p(ptr + 12, ETH_P_VLAN);
> -stw_be_p(ptr + 14, bd.des1);
> -len += 4;
> +
> +if (len < sizeof(struct eth_header)) {
> +qemu_log_mask(LOG_GUEST_ERROR,
> + "%s: frame too small for VLAN insertion : %d 
> bytes\n",
> + __func__, len);
> +s->isr |= FTGMAC100_INT_XPKT_LOST;
> +} else {
> +uint8_t *vlan_hdr = ptr + (ETH_ALEN * 2);
> +uint8_t *payload = vlan_hdr + sizeof(struct vlan_header);
> +
> +memmove(payload, vlan_hdr, len - (ETH_ALEN * 2));
> +stw_be_p(vlan_hdr, ETH_P_VLAN);
> +stw_be_p(vlan_hdr + 2, FTGMAC100_TXDES1_VLANTAG_CI(bd.des1));
> +len += sizeof(struct vlan_header);
> +}
>  }
>
>  ptr += len;
> --
> 2.25.4
>



Re: [PATCH for-5.2 13/19] ftgmac100: Check for invalid len and address before doing a DMA transfer

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> According to the Aspeed specs, no interrupts are raised in that case
> but a "Tx-packets lost" status seems like a good modeling choice for
> all implementations. It is covered by the Linux kernel.
>
> Cc: Frederic Konrad 
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/net/ftgmac100.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 014980d30aca..280aa3d3a1e2 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -507,6 +507,15 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t 
> tx_ring,
>  }
>
>  len = FTGMAC100_TXDES0_TXBUF_SIZE(bd.des0);
> +if (!len) {
> +/*
> + * 0 is an invalid size, however the HW does not raise any
> + * interrupt. Flag an error because the guest is buggy.
> + */
> +qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid segment size\n",
> +  __func__);
> +}
> +
>  if (frame_size + len > sizeof(s->frame)) {
>  qemu_log_mask(LOG_GUEST_ERROR, "%s: frame too big : %d bytes\n",
>__func__, len);
> --
> 2.25.4
>



Re: [PATCH for-5.2 12/19] ftgmac100: Change interrupt status when a DMA error occurs

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> The model uses today the "No transmit buffer unavailable" interrupt
> status which it is not appropriate. According to the Aspeed specs, no
> interrupts are raised in that case. An "AHB error" status seems like a
> better modeling choice for all implementations since it is covered by
> the Linux kernel.

The datasheet calls it this:

 NPTXBUF UNAVA: Normal priority transmit buffer unavailable

Perhaps we should say this:

The model uses today the "Normal priority transmit buffer unavailable"
interrupt status which is not appropriate.

Reviewed-by: Joel Stanley 

>
> Cc: Frederic Konrad 
> Signed-off-by: Cédric Le Goater 
> ---
>  hw/net/ftgmac100.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 5c0fe2d8cb75..014980d30aca 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -517,7 +517,7 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t 
> tx_ring,
>  if (dma_memory_read(_space_memory, bd.des3, ptr, len)) {
>  qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to read packet @ 
> 0x%x\n",
>__func__, bd.des3);
> -s->isr |= FTGMAC100_INT_NO_NPTXBUF;
> +s->isr |= FTGMAC100_INT_AHB_ERR;
>  break;
>  }
>
> --
> 2.25.4
>



Re: [PATCH for-5.2 11/19] ftgmac100: Fix interrupt status "Packet moved to RX FIFO"

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> As we don't model the RX or TX FIFO, raise the "Packet moved to RX
> FIFO" interrupt status bit as soon as we are handling a RX packet.
>
> Cc: Frederic Konrad 
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/net/ftgmac100.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index aa3c05ef9882..5c0fe2d8cb75 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -950,6 +950,7 @@ static ssize_t ftgmac100_receive(NetClientState *nc, 
> const uint8_t *buf,
>  break;
>  }
>
> +s->isr |= FTGMAC100_INT_RPKT_FIFO;
>  addr = s->rx_descriptor;
>  while (size > 0) {
>  if (!ftgmac100_can_receive(nc)) {
> @@ -1001,8 +1002,6 @@ static ssize_t ftgmac100_receive(NetClientState *nc, 
> const uint8_t *buf,
>  /* Last buffer in frame.  */
>  bd.des0 |= flags | FTGMAC100_RXDES0_LRS;
>  s->isr |= FTGMAC100_INT_RPKT_BUF;
> -} else {
> -s->isr |= FTGMAC100_INT_RPKT_FIFO;
>  }
>  ftgmac100_write_bd(, addr);
>  if (bd.des0 & s->rxdes0_edorr) {
> --
> 2.25.4
>



Re: [PATCH for-5.2 10/19] ftgmac100: Fix interrupt status "Packet transmitted on ethernet"

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> The second field of the TX descriptor has a set of flags to choose
> when the transmit interrupt is raised : after the packet has been sent
> on the ethernet or after it has been moved into the TX FIFO. But we
> don't model that today.

Does any software depend on this behaviour? Perhaps mention it in the
commit message so we remember why we changed it.

>
> Simply raise the "Packet transmitted on ethernet" the interrupt status
> bit as soon as the packet is sent by QEMU.

delete the second 'the'?

Reviewed-by: Joel Stanley 

>
> Cc: Frederic Konrad 
> Signed-off-by: Cédric Le Goater 
> ---
>  hw/net/ftgmac100.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 0348fcf45676..aa3c05ef9882 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -547,9 +547,7 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t 
> tx_ring,
>  qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size);
>  ptr = s->frame;
>  frame_size = 0;
> -if (flags & FTGMAC100_TXDES1_TXIC) {
> -s->isr |= FTGMAC100_INT_XPKT_ETH;
> -}
> +s->isr |= FTGMAC100_INT_XPKT_ETH;
>  }
>
>  if (flags & FTGMAC100_TXDES1_TX2FIC) {
> --
> 2.25.4
>



Re: [PATCH for-5.2 09/19] ftgmac100: Fix registers that can be read

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> Receive Ring Base Address Register (RXR_BADR) and the Normal Priority
> Transmit Receive Ring Base Address Register (NPTXR_BADR) can als be
> read.
>
> Cc: Frederic Konrad 
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/net/ftgmac100.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 5f4b26fc5f3c..0348fcf45676 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -669,6 +669,10 @@ static uint64_t ftgmac100_read(void *opaque, hwaddr 
> addr, unsigned size)
>  return s->math[0];
>  case FTGMAC100_MATH1:
>  return s->math[1];
> +case FTGMAC100_RXR_BADR:
> +return s->rx_ring;
> +case FTGMAC100_NPTXR_BADR:
> +return s->tx_ring;
>  case FTGMAC100_ITC:
>  return s->itc;
>  case FTGMAC100_DBLAC:
> --
> 2.25.4
>



Re: [PATCH for-5.2 08/19] aspeed/sdhci: Fix reset sequence

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> BIT(0) of the ASPEED_SDHCI_INFO register is set by SW and polled until
> the bit is cleared by HW. Add definitions for the default value of
> this register and fix the reset sequence by clearing the RESET bit.

This is mentioned in the datasheet but I couldn't find if software
depends on the behaviour. Were you just trying to make the model more
accurate?

>  #define ASPEED_SDHCI_INFO0x00
> -#define  ASPEED_SDHCI_INFO_RESET 0x0003
> +#define  ASPEED_SDHCI_INFO_SLOT1 (1 << 17)
> +#define  ASPEED_SDHCI_INFO_SLOT0 (1 << 16)
> +#define  ASPEED_SDHCI_INFO_RESET (1 << 0)
>  #define ASPEED_SDHCI_DEBOUNCE0x04
>  #define  ASPEED_SDHCI_DEBOUNCE_RESET 0x0005
>  #define ASPEED_SDHCI_BUS 0x08
> @@ -67,6 +69,9 @@ static void aspeed_sdhci_write(void *opaque, hwaddr addr, 
> uint64_t val,
>  AspeedSDHCIState *sdhci = opaque;
>
>  switch (addr) {
> +case ASPEED_SDHCI_INFO:
> +sdhci->regs[TO_REG(addr)] = (uint32_t)val & ~ASPEED_SDHCI_INFO_RESET;

I think bits 24 and 25 should be writable too?

sdhci->regs[TO_REG(addr)] = (uint32_t)val &
~(ASPEED_SDHCI_INFO_RESET | ASPEED_SDHCI_INFO_SLOT10 |
ASPEED_SDHCI_INFO_SLOT1);

> +
>  case ASPEED_SDHCI_SDIO_140:
>  sdhci->slots[0].capareg = (uint64_t)(uint32_t)val;
>  break;
> @@ -155,7 +160,8 @@ static void aspeed_sdhci_reset(DeviceState *dev)
>  AspeedSDHCIState *sdhci = ASPEED_SDHCI(dev);
>
>  memset(sdhci->regs, 0, ASPEED_SDHCI_REG_SIZE);
> -sdhci->regs[TO_REG(ASPEED_SDHCI_INFO)] = ASPEED_SDHCI_INFO_RESET;
> +sdhci->regs[TO_REG(ASPEED_SDHCI_INFO)] =
> +ASPEED_SDHCI_INFO_SLOT1 | ASPEED_SDHCI_INFO_SLOT0;

If we want to be super strict this is true for the "sd" devices, but
the "emmc" device in the ast2600 only sets slot0. I don't think this
distinction is important to model though.

>  sdhci->regs[TO_REG(ASPEED_SDHCI_DEBOUNCE)] = ASPEED_SDHCI_DEBOUNCE_RESET;
>  }
>
> --
> 2.25.4
>



Re: [RFC v3 19/71] target/riscv: rvv-1.0: configure instructions

2020-08-06 Thread Richard Henderson
On 8/6/20 3:46 AM, frank.ch...@sifive.com wrote:
> From: Frank Chang 
> 
> Signed-off-by: Frank Chang 
> ---
>  target/riscv/insn_trans/trans_rvv.inc.c | 12 
>  target/riscv/vector_helper.c| 14 +-
>  2 files changed, 21 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson 

r~



Re: [PATCH for-5.2 07/19] aspeed/smc: Fix max_slaves of the legacy SMC device

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> The legacy controller only has one slave.
>
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/ssi/aspeed_smc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index 0646e0dca72e..8c79a5552f93 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -259,7 +259,7 @@ static const AspeedSMCController controllers[] = {
>  .r_timings = R_TIMINGS,
>  .nregs_timings = 1,
>  .conf_enable_w0= CONF_ENABLE_W0,
> -.max_slaves= 5,
> +.max_slaves= 1,
>  .segments  = aspeed_segments_legacy,
>  .flash_window_base = ASPEED_SOC_SMC_FLASH_BASE,
>  .flash_window_size = 0x600,
> --
> 2.25.4
>



Re: [PATCH for-5.2 06/19] aspeed/smc: Fix MemoryRegionOps definition

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:23, Cédric Le Goater  wrote:
>
> Unaligned access support is a leftover from the initial commit. There
> is no such need on this device register mapping. Remove it.
>
> Cc: Michael S. Tsirkin 
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/ssi/aspeed_smc.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index 4fab1f5f855e..0646e0dca72e 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -1299,10 +1299,8 @@ static const MemoryRegionOps aspeed_smc_ops = {
>  .read = aspeed_smc_read,
>  .write = aspeed_smc_write,
>  .endianness = DEVICE_LITTLE_ENDIAN,
> -.valid.unaligned = true,
>  };
>
> -
>  /*
>   * Initialize the custom address spaces for DMAs
>   */
> --
> 2.25.4
>



Re: [PATCH for-5.2 05/19] hw/arm/aspeed: Add board model for Supermicro X11 BMC

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> From: erik-smit 
>
> The BMC Firmware can be downloaded from :
>
>   https://www.supermicro.com/en/products/motherboard/X11SSL-F
>
> Signed-off-by: erik-smit 
> Reviewed-by: Cédric Le Goater 
> [ clg: Modified commit log ]
> Message-Id: <20200715173418.186-1-erik.lucas.s...@gmail.com>
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/arm/aspeed.c | 35 +++
>  1 file changed, 35 insertions(+)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index fcb1a7cd8729..d17a4885a03c 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -57,6 +57,20 @@ struct AspeedMachineState {
>  SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) |   \
>  SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT))
>
> +/* TODO: Find the actual hardware value */

I've asked some bmc people if they could provide this.

> +#define SUPERMICROX11_BMC_HW_STRAP1 (   \
> +SCU_AST2400_HW_STRAP_DRAM_SIZE(DRAM_SIZE_128MB) |   \
> +SCU_AST2400_HW_STRAP_DRAM_CONFIG(2) |   \
> +SCU_AST2400_HW_STRAP_ACPI_DIS | \
> +SCU_AST2400_HW_STRAP_SET_CLK_SOURCE(AST2400_CLK_48M_IN) |   \
> +SCU_HW_STRAP_VGA_CLASS_CODE |   \
> +SCU_HW_STRAP_LPC_RESET_PIN |\
> +SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN) |\
> +SCU_AST2400_HW_STRAP_SET_CPU_AHB_RATIO(AST2400_CPU_AHB_RATIO_2_1) | \
> +SCU_HW_STRAP_SPI_WIDTH |\
> +SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) |   \
> +SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT))
> +
>  /* AST2500 evb hardware value: 0xF100C2E6 */
>  #define AST2500_EVB_HW_STRAP1 ((\
>  AST2500_HW_STRAP1_DEFAULTS |\
> @@ -603,6 +617,23 @@ static void 
> aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
>  aspeed_soc_num_cpus(amc->soc_name);
>  };
>
> +static void aspeed_machine_supermicrox11_bmc_class_init(ObjectClass *oc,
> +void *data)
> +{
> +MachineClass *mc = MACHINE_CLASS(oc);
> +AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
> +
> +mc->desc   = "Supermicro X11 BMC (ARM926EJ-S)";
> +amc->soc_name  = "ast2400-a1";
> +amc->hw_strap1 = SUPERMICROX11_BMC_HW_STRAP1;
> +amc->fmc_model = "mx25l25635e";
> +amc->spi_model = "mx25l25635e";
> +amc->num_cs= 1;
> +amc->macs_mask = ASPEED_MAC0_ON | ASPEED_MAC1_ON;
> +amc->i2c_init  = palmetto_bmc_i2c_init;
> +mc->default_ram_size = 256 * MiB;
> +}
> +
>  static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void 
> *data)
>  {
>  MachineClass *mc = MACHINE_CLASS(oc);
> @@ -731,6 +762,10 @@ static const TypeInfo aspeed_machine_types[] = {
>  .name  = MACHINE_TYPE_NAME("palmetto-bmc"),
>  .parent= TYPE_ASPEED_MACHINE,
>  .class_init= aspeed_machine_palmetto_class_init,
> +}, {
> +.name  = MACHINE_TYPE_NAME("supermicrox11-bmc"),
> +.parent= TYPE_ASPEED_MACHINE,
> +.class_init= aspeed_machine_supermicrox11_bmc_class_init,
>  }, {
>  .name  = MACHINE_TYPE_NAME("ast2500-evb"),
>  .parent= TYPE_ASPEED_MACHINE,
> --
> 2.25.4
>



Re: [RFC v3 16/71] target/riscv: add fp16 nan-box check generator function

2020-08-06 Thread Richard Henderson
On 8/6/20 3:46 AM, frank.ch...@sifive.com wrote:
> From: Frank Chang 
> 
> If a 16-bit input is not properly nanboxed, then the input is replaced
> with the default qnan.
> 
> Signed-off-by: Frank Chang 
> ---
>  target/riscv/translate.c | 10 ++
>  1 file changed, 10 insertions(+)

The code is perfectly fine, but the patch has to be merged with the first user
of gen_check_nanbox_h.  Otherwise a bisection that stops at this patch will
Werror for the unused function.


r~



Re: [RFC v3 18/71] target/riscv: rvv-1.0: apply nanbox helper in opfvf_trans

2020-08-06 Thread Richard Henderson
On 8/6/20 3:46 AM, frank.ch...@sifive.com wrote:
> From: Frank Chang 
> 
> Signed-off-by: Frank Chang 
> ---
>  target/riscv/insn_trans/trans_rvv.inc.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

With patches 16 and 17 merged into here,

Reviewed-by: Richard Henderson 

r~



Re: [PATCH for-5.2 03/19] m25p80: Add support for n25q512ax3

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> Datasheet available here :
>
> https://www.micron.com/-/media/client/global/Documents/Products/Data%20Sheet/NOR%20Flash/Serial%20NOR/N25Q/n25q_512mb_1ce_3v_65nm.pdf
>
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/block/m25p80.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 1696ab1f7821..8a3fd959e218 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -238,6 +238,7 @@ static const FlashPartInfo known_devices[] = {
>  { INFO("n25q128", 0x20ba18,  0,  64 << 10, 256, 0) },
>  { INFO("n25q256a",0x20ba19,  0,  64 << 10, 512, ER_4K) },
>  { INFO("n25q512a",0x20ba20,  0,  64 << 10, 1024, ER_4K) },
> +{ INFO("n25q512ax3",  0x20ba20,  0x1000,  64 << 10, 1024, ER_4K) },
>  { INFO_STACKED("n25q00",0x20ba21, 0x1000, 64 << 10, 2048, ER_4K, 4) 
> },
>  { INFO_STACKED("n25q00a",   0x20bb21, 0x1000, 64 << 10, 2048, ER_4K, 4) 
> },
>  { INFO_STACKED("mt25ql01g", 0x20ba21, 0x1040, 64 << 10, 2048, ER_4K, 2) 
> },
> --
> 2.25.4
>



Re: [RFC v3 17/71] target/riscv: rvv:1.0: add translation-time nan-box helper function

2020-08-06 Thread Richard Henderson
On 8/6/20 3:46 AM, frank.ch...@sifive.com wrote:
> From: Frank Chang 
> 
> Add do_nanbox() helper function to utilize gen_check_nanbox_X() to
> generate the NaN-boxed floating-point values based on SEW setting.
> 
> Signed-off-by: Frank Chang 
> ---
>  target/riscv/insn_trans/trans_rvv.inc.c | 27 +
>  1 file changed, 27 insertions(+)

Similarly, do_nanbox will Werror as an unused function.
Otherwise looks fine.


r~



Re: [PATCH for-5.2 04/19] aspeed/scu: Fix valid access size on AST2400

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> The read access size of the SCU registers can be 1/2/4 bytes and write
> is 4 bytes. Set the min access size to 1 byte to cover both read and
> write operations on the AST2400 but keep the min access size of the
> other SoCs to 4 bytes as this is an unusual access size.
>
> This fixes support for some old firmware doing 2 bytes reads on the
> AST2400 SoC.
>
> Reported-by: erik-smit 
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

> ---
>  hw/misc/aspeed_scu.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c
> index ec4fef900e27..764222404bef 100644
> --- a/hw/misc/aspeed_scu.c
> +++ b/hw/misc/aspeed_scu.c
> @@ -328,9 +328,10 @@ static const MemoryRegionOps aspeed_ast2400_scu_ops = {
>  .read = aspeed_scu_read,
>  .write = aspeed_ast2400_scu_write,
>  .endianness = DEVICE_LITTLE_ENDIAN,
> -.valid.min_access_size = 4,
> -.valid.max_access_size = 4,
> -.valid.unaligned = false,
> +.valid = {
> +.min_access_size = 1,
> +.max_access_size = 4,
> +},
>  };
>
>  static const MemoryRegionOps aspeed_ast2500_scu_ops = {
> --
> 2.25.4
>



Re: [PATCH for-5.2 02/19] m25p80: Add support for mx25l25635f

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 13:21, Cédric Le Goater  wrote:
>
> The mx25l25635f is an extenstion of the mx25l25635e. It includes QPI
> support, 4-Byte Address Command Set and faster transfers. See this
> document for more details :
>
> https://www.macronix.com/Lists/ApplicationNote/Attachments/1892/AN0200V1_MGRT_MX25L25635E_25735E%20to%20MX25L25635F_25735F.pdf
>
> Both devices have the same 3bytes JEDEC ID: 0xc22019. They can be
> distinguished with the QPIID command which is only available on
> mx25l25635f. The mx25l25635f also has a longer JEDEC ID that we can
> use for the model.
>
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Joel Stanley 

We don't have support for this one in upstream Linux. It's the one
that Alexander tried to get merged by renaming the mysterious
mx66l51235l.


> ---
>  hw/block/m25p80.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 605ff55c6756..1696ab1f7821 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -218,6 +218,7 @@ static const FlashPartInfo known_devices[] = {
>  { INFO("mx25l12805d", 0xc22018,  0,  64 << 10, 256, 0) },
>  { INFO("mx25l12855e", 0xc22618,  0,  64 << 10, 256, 0) },
>  { INFO6("mx25l25635e", 0xc22019, 0xc22019,  64 << 10, 512, 0) },
> +{ INFO("mx25l25635f", 0xc22019,  0xc200,  64 << 10, 512, 0) },
>  { INFO("mx25l25655e", 0xc22619,  0,  64 << 10, 512, 0) },
>  { INFO("mx66u51235f", 0xc2253a,  0,  64 << 10, 1024, ER_4K | ER_32K) 
> },
>  { INFO("mx66u1g45g",  0xc2253b,  0,  64 << 10, 2048, ER_4K | ER_32K) 
> },
> --
> 2.25.4
>



Re: [RFC v3 15/71] target/riscv: introduce more imm value modes in translator functions

2020-08-06 Thread Richard Henderson
On 8/6/20 3:46 AM, frank.ch...@sifive.com wrote:
> From: Frank Chang 
> 
> Immediate value in translator function is extended not only
> zero-extended and sign-extended but with more modes to be applicable
> with multiple formats of vector instructions.
> 
> * IMM_ZX: Zero-extended
> * IMM_SX: Sign-extended
> * IMM_TRUNC_SEW:  Truncate to log(SEW) bit
> * IMM_TRUNC_2SEW: Truncate to log(2*SEW) bit
> 
> Signed-off-by: Frank Chang 
> ---
>  target/riscv/insn_trans/trans_rvv.inc.c | 115 ++--
>  1 file changed, 66 insertions(+), 49 deletions(-)
> 
> diff --git a/target/riscv/insn_trans/trans_rvv.inc.c 
> b/target/riscv/insn_trans/trans_rvv.inc.c
> index c2d0865bb9b..0a4dd875e96 100644
> --- a/target/riscv/insn_trans/trans_rvv.inc.c
> +++ b/target/riscv/insn_trans/trans_rvv.inc.c
> @@ -1281,8 +1281,32 @@ static void tcg_gen_gvec_rsubs(unsigned vece, uint32_t 
> dofs, uint32_t aofs,
>  
>  GEN_OPIVX_GVEC_TRANS(vrsub_vx, rsubs)
>  
> +enum {
> +IMM_ZX, /* Zero-extended */
> +IMM_SX, /* Sign-extended */
> +IMM_TRUNC_SEW,  /* Truncate to log(SEW) bits */
> +IMM_TRUNC_2SEW, /* Truncate to log(2*SEW) bits */
> +};

Better to name the enumeration and use it...

> +
> +static int64_t extract_imm(DisasContext *s, uint32_t imm, int imm_mode)

... here.

> +{
> +switch (imm_mode) {
> +case IMM_ZX:
> +return extract64(imm, 0, 5);
> +case IMM_SX:
> +return sextract64(imm, 0, 5);
> +case IMM_TRUNC_SEW:
> +return extract64(imm, 0, 5) & ((1 << (s->sew + 3)) - 1);
> +case IMM_TRUNC_2SEW:
> +return extract64(imm, 0, 5) & ((2 << (s->sew + 3)) - 1);

The extract is redundant with the &.

Alternately, put sew into the extract, like so:

return extract64(imm, 0, s->sew + 3);
and
return extract64(imm, 0, s->sew + 4);


> +default:
> +g_assert_not_reached();
> +break;

Unreachable break.

>  static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm,
> -gen_helper_opivx *fn, DisasContext *s, int zx)
> +gen_helper_opivx *fn, DisasContext *s, int imm_mode)

Use the enum.

>  static inline bool
>  do_opivi_gvec(DisasContext *s, arg_rmrr *a, GVecGen2iFn *gvec_fn,
> -  gen_helper_opivx *fn, int zx)
> +  gen_helper_opivx *fn, int imm_mode)

Use the enum.


r~



Re: [qemu]: How to use qemu to run 64MB bmc image?

2020-08-06 Thread Joel Stanley
On Thu, 6 Aug 2020 at 15:12, Philippe Mathieu-Daudé  wrote:
>
> On 8/6/20 3:54 PM, Cédric Le Goater wrote:
> > Hello,
> >
> > On 8/6/20 3:58 AM, www wrote:
> >> Hi Joel Stanley, Andrew Jeffery, Cédric Le Goater,
> >>
> >> How to modify it so that QEMU can run 64MB BMC image?
> >
> > You can increase the FW image file size with 'dd' or with :
> >
> >   cat foo foo > bar
> >
> > if the expected size is 128MB
>
> You can use 'truncate' from coreutils:
>
> $ truncate -s 128M image.bin

Nice tip!

(What an obvious name for a tool to extend files)

Cheers,

Joel



Re: [PULL 0/6] Improve gitlab-CI and fix a compiler warning

2020-08-06 Thread Alistair Francis
On Wed, Aug 5, 2020 at 5:58 AM Thomas Huth  wrote:
>
>  Hi Peter,
>
> the following changes since commit fd3cd581f9dcd11286daacaa5272e721c65aece8:
>
>   Merge remote-tracking branch 
> 'remotes/pmaydell/tags/pull-target-arm-20200804' into staging (2020-08-04 
> 18:20:32 +0100)
>
> are available in the Git repository at:
>
>   https://gitlab.com/huth/qemu.git tags/pull-request-2020-08-05
>
> for you to fetch changes up to d2a71d7474d4649eabe554994a3fcba75244cce3:
>
>   Get rid of the libqemustub.a remainders (2020-08-05 11:45:43 +0200)
>
> (I know it's late in the 5.1 cycle, feel free to ignore this if it's
> too much for 5.1)
>
> 
> * Test rx-softmmu, avr-softmmu, Centos7 and Debian on gitlab-CI
> * Fix compiler warning on 32-bit big endian systems
> * Remove remainders of libqemustub.a
> 
>
> Thomas Huth (6):
>   tests/docker: Add python3-venv and netcat to the debian-amd64 container
>   tests/acceptance: Disable the rx sash and arm cubieboard replay test on 
> Gitlab
>   gitlab-ci.yml: Add build-system-debian and build-system-centos jobs
>   gitlab-ci: Fix Avocado cache usage
>   target/riscv/vector_helper: Fix build on 32-bit big endian hosts
>   Get rid of the libqemustub.a remainders

Thanks for the RISC-V fix, I'm currently on holidays which is why I
haven't reviewed it.

Alistair

>
>  .gitlab-ci.yml   | 109 
> ++-
>  Makefile |   2 +-
>  scripts/coverity-scan/run-coverity-scan  |   3 -
>  target/riscv/vector_helper.c |   4 +-
>  tests/acceptance/machine_rx_gdbsim.py|   4 +
>  tests/acceptance/replay_kernel.py|   1 +
>  tests/docker/dockerfiles/debian-amd64.docker |   4 +-
>  tests/test-util-sockets.c|   3 +-
>  8 files changed, 103 insertions(+), 27 deletions(-)
>
>



Re: [PATCH 001/143] tests: move socket_scm_helper back to tests/

2020-08-06 Thread Philippe Mathieu-Daudé
On 8/6/20 9:13 PM, Paolo Bonzini wrote:
> This file is unrelated to qemu-iotests and was moved incorrectly
> to tests/qtest/Makefile.include.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  tests/Makefile.include | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index c7e4646..985cd14 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -879,6 +879,8 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES)
>  
>  QEMU_IOTESTS_HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = 
> tests/qemu-iotests/socket_scm_helper$(EXESUF)
>  
> +tests/qemu-iotests/socket_scm_helper$(EXESUF): 
> tests/qemu-iotests/socket_scm_helper.o

Already done in 6e1da96b94 ("tests/qemu-iotests: Fix socket_scm_helper
build path"). Should we move it back to tests/?

> +
>  .PHONY: check-tests/check-block.sh
>  check-tests/check-block.sh: tests/check-block.sh qemu-img$(EXESUF) \
>   qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) \
> 




Re: [PATCH 095/143] meson: convert hw/sd

2020-08-06 Thread Philippe Mathieu-Daudé
On 8/6/20 9:15 PM, Paolo Bonzini wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> Signed-off-by: Paolo Bonzini 
> ---
>  hw/Makefile.objs|  1 -
>  hw/meson.build  |  1 +
>  hw/sd/Makefile.objs | 12 
>  hw/sd/meson.build   | 12 
>  4 files changed, 13 insertions(+), 13 deletions(-)
>  delete mode 100644 hw/sd/Makefile.objs
>  create mode 100644 hw/sd/meson.build
> 
> diff --git a/hw/Makefile.objs b/hw/Makefile.objs
> index e50eb04..6f9c0b7 100644
> --- a/hw/Makefile.objs
> +++ b/hw/Makefile.objs
> @@ -25,7 +25,6 @@ devices-dirs-y += pci/
>  devices-dirs-$(CONFIG_PCI) += pci-bridge/ pci-host/
>  devices-dirs-y += pcmcia/
>  devices-dirs-$(CONFIG_SCSI) += scsi/
> -devices-dirs-y += sd/
>  endif
>  
>  common-obj-y += $(devices-dirs-y)
> diff --git a/hw/meson.build b/hw/meson.build
> index 7564426..a73f4ae 100644
> --- a/hw/meson.build
> +++ b/hw/meson.build
> @@ -2,6 +2,7 @@ subdir('core')
>  subdir('mem')
>  subdir('nubus')
>  subdir('rtc')
> +subdir('sd')
>  subdir('semihosting')
>  subdir('smbios')
>  subdir('ssi')
> diff --git a/hw/sd/Makefile.objs b/hw/sd/Makefile.objs
> deleted file mode 100644
> index 0d1df17..000
> --- a/hw/sd/Makefile.objs
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -common-obj-$(CONFIG_PL181) += pl181.o
> -common-obj-$(CONFIG_SSI_SD) += ssi-sd.o
> -common-obj-$(CONFIG_SD) += sd.o core.o sdmmc-internal.o
> -common-obj-$(CONFIG_SDHCI) += sdhci.o
> -common-obj-$(CONFIG_SDHCI_PCI) += sdhci-pci.o
> -
> -common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-sdhost.o
> -common-obj-$(CONFIG_MILKYMIST) += milkymist-memcard.o
> -common-obj-$(CONFIG_OMAP) += omap_mmc.o
> -common-obj-$(CONFIG_PXA2XX) += pxa2xx_mmci.o
> -common-obj-$(CONFIG_RASPI) += bcm2835_sdhost.o
> -common-obj-$(CONFIG_ASPEED_SOC) += aspeed_sdhci.o
> diff --git a/hw/sd/meson.build b/hw/sd/meson.build
> new file mode 100644
> index 000..b43e59b
> --- /dev/null
> +++ b/hw/sd/meson.build
> @@ -0,0 +1,12 @@
> +softmmu_ss.add(when: 'CONFIG_PL181', if_true: files('pl181.c'))
> +softmmu_ss.add(when: 'CONFIG_SD', if_true: files('sd.c', 'core.c', 
> 'sdmmc-internal.c'))
> +softmmu_ss.add(when: 'CONFIG_SDHCI', if_true: files('sdhci.c'))
> +softmmu_ss.add(when: 'CONFIG_SDHCI_PCI', if_true: files('sdhci-pci.c'))
> +softmmu_ss.add(when: 'CONFIG_SSI_SD', if_true: files('ssi-sd.c'))
> +
> +softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: 
> files('milkymist-memcard.c'))
> +softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_mmc.c'))
> +softmmu_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_mmci.c'))
> +softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_sdhost.c'))
> +softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_sdhci.c'))
> +softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: 
> files('allwinner-sdhost.c'))
> 

Reviewed-by: Philippe Mathieu-Daudé 




Re: [PATCH 108/143] meson: convert hw/intc

2020-08-06 Thread Philippe Mathieu-Daudé
On 8/6/20 11:20 PM, Paolo Bonzini wrote:
> 
> 
> Il gio 6 ago 2020, 23:02 Peter Maydell  > ha scritto:
> 
> On Thu, 6 Aug 2020 at 21:10, Paolo Bonzini  > wrote:
> >
> > From: Marc-André Lureau  >
> >
> > Signed-off-by: Marc-André Lureau  >
> > Signed-off-by: Paolo Bonzini  >
> 
> Compared to:
> 
> > -common-obj-$(CONFIG_HEATHROW_PIC) += heathrow_pic.o
> 
> > +softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true:
> files('heathrow_pic.c'))
> 
> this feels pretty clunky. Doesn't Meson have a nicer
> way of expressing this kind of thing? 

Don't forget we also use:

HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) +=
qemu-bridge-helper$(EXESUF)
ifeq ($(CONFIG_LINUX)$(CONFIG_VIRGL)$(CONFIG_GBM)$(CONFIG_TOOLS),)
HELPERS-y += vhost-user-gpu$(EXESUF)
vhost-user-json-y += contrib/vhost-user-gpu/50-qemu-gpu.json
endif

> 
> 
> Nope, in fact it turns out we had to implement it ourselves because
> there was no way to express it at all in the way that QEMU build
> multiple binaries. My initial version didn't have the when/if_true part
> but the maintainer was quite adamant on requiring them instead of just
> relying on positional arguments.
> 
> Unfortunately, while common in QEMU, and in Linux too, it doesn't seem
> to be a very common idiom in general; Makefiles do express it in a very
> readable and concise way.
> 
> I cannot deny it looks clunky. While Meson does have a huge advantage in
> terms of predictability and lack of surprises when doing harder things,
> the imperative syntax is heavier when dealing with the simplest. They do
> remain simple (it's still one line of coffee), but the quotes and commas
> seem to be enough to "switch" our brain to a different mode.
> 
> My opinion is that you don't really look at these things very much, so
> it doesn't really matter, but I can see people disagreeing.
> 
> (You had already pointed this out during the very first discussions, if
> I remember correctly. I can't add much except that with extra experience
> the balance does tilt in favor of Meson despite the heavier syntax for
> simple cases).
> 
> Paolo
> 
> It's really
> common and I'd hope that a build system language
> would provide less long-winded ways to write common
> operations...
> 
> thanks
> -- PMM
> 




Re: [PATCH-for-5.2] target/mips: Report unimplemented cache() operations

2020-08-06 Thread Philippe Mathieu-Daudé
On 8/6/20 10:51 PM, Peter Maydell wrote:
> On Thu, 6 Aug 2020 at 21:31, Philippe Mathieu-Daudé  wrote:
>>
>> On 8/6/20 8:01 PM, Jiaxun Yang wrote:
>>> 在 2020/8/6 下午8:26, Philippe Mathieu-Daudé 写道:
 We only implement the Index[Store/Load]Tag from the 'cache' opcode.
 Instead of ignoring the other cache operations, report them as
 unimplemented.
>>>
>>> Hmm, I don't think we have anything to do with Invalidate/Writeback etc.
>>> opcodes
>>> in QEMU. Why do we log this?
>>
>> I'm noticed this code is run on Linux 3.3.8 (4KEc):
>>
>> 8880:   3082000fandiv0,a0,0xf
>> 8884:   1088beqza0,88a8
>> :   00a21021adduv0,a1,v0
>> 888c:   08002227j   889c
>> 8890:   1821movev1,zero
>> 8894:   bcf9cache   0x19,0(a3)
>> 8898:   24630010addiu   v1,v1,16
>> 889c:   0062302bsltua2,v1,v0
>> 88a0:   14c0fffcbneza2,8894
>> 88a4:   00833821addua3,a0,v1
>> 88a8:   03e8jr  ra
>> 88ac:   nop
>>
>> Why silently ignore the opcode is not implemented instead of logging it?
> 
> I think the question is whether the opcode is supposed to have
> some behaviour which we're not implementing, or whether "no-op"
> is the correct behaviour for it (which it usually is for
> cache invalidate type operations; compare the way the Arm
> cache ops like IC_IALLU are just ARM_CP_NOP ops).

OK now I understand better, thanks.

I haven't found useful information about this 0x19=25 opcode value.

On a r10k core it is listed as 'Hit Writeback Invalidate (D)' but here
this is a 4kEc. The address used is a SRAM shared with a embedded DSP
on the same SoC. From a RevEng PoV it is helpful to see there is a such
cache access, as I can separate better the peripheral involved.
I'm happy using a trace event instead.

Jiaxun, can you list me the list of opcodes QEMU can safely ignore from
the TCG emulation PoV? That way we can comment them in the code such:

switch (op) {
case 9:
/* Index Store Tag */
...
break;
case 5:
/* Index Load Tag */
...
break;
case X:
case Y:
case Z:
/* No-Op for QEMU */
...
break;
default:
qemu_log_mask(LOG_UNIMP, "cache %u\n", op);
}

Thanks,

Phil.

> 
> thanks
> -- PMM
> 



Re: [PATCH 108/143] meson: convert hw/intc

2020-08-06 Thread Paolo Bonzini
Il gio 6 ago 2020, 23:02 Peter Maydell  ha
scritto:

> On Thu, 6 Aug 2020 at 21:10, Paolo Bonzini  wrote:
> >
> > From: Marc-André Lureau 
> >
> > Signed-off-by: Marc-André Lureau 
> > Signed-off-by: Paolo Bonzini 
>
> Compared to:
>
> > -common-obj-$(CONFIG_HEATHROW_PIC) += heathrow_pic.o
>
> > +softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true:
> files('heathrow_pic.c'))
>
> this feels pretty clunky. Doesn't Meson have a nicer
> way of expressing this kind of thing?


Nope, in fact it turns out we had to implement it ourselves because there
was no way to express it at all in the way that QEMU build multiple
binaries. My initial version didn't have the when/if_true part but the
maintainer was quite adamant on requiring them instead of just relying on
positional arguments.

Unfortunately, while common in QEMU, and in Linux too, it doesn't seem to
be a very common idiom in general; Makefiles do express it in a very
readable and concise way.

I cannot deny it looks clunky. While Meson does have a huge advantage in
terms of predictability and lack of surprises when doing harder things, the
imperative syntax is heavier when dealing with the simplest. They do remain
simple (it's still one line of coffee), but the quotes and commas seem to
be enough to "switch" our brain to a different mode.

My opinion is that you don't really look at these things very much, so it
doesn't really matter, but I can see people disagreeing.

(You had already pointed this out during the very first discussions, if I
remember correctly. I can't add much except that with extra experience the
balance does tilt in favor of Meson despite the heavier syntax for simple
cases).

Paolo

It's really
> common and I'd hope that a build system language
> would provide less long-winded ways to write common
> operations...
>
> thanks
> -- PMM
>
>


[Bug 1594394] Re: Using setreuid / setegid crashes x86_64 user-mode target

2020-08-06 Thread Steve Dodd
Sorry, heat is definitely getting to me - just realized this is an
upstream bug, not an Ubuntu one! Ubuntu package version is 1:2.11+dfsg-
1ubuntu7.26. At some point I will look at building qemu from source, but
won't be an immediate thing. Apologies for noise .. though if anyone
knows off-hand that a fix for this did or didn't get merged that would
useful ..

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1594394

Title:
  Using setreuid / setegid crashes x86_64 user-mode target

Status in QEMU:
  New

Bug description:
  When setreuid() or setegid() are called from x86_64 target code in
  user mode, qemu crashes inside the NPTL signal handlers.  x86 targets
  do not directly use a syscall to handle setreuid() / setegid();
  instead the x86 NPTL implementation sets up a temporary data region in
  memory (__xidcmd) and issues a signal (SIGRT1) to all threads,
  allowing the handler for that signal to issue the syscall.  Under
  qemu, __xidcmd remains null (see variable display below backtrace).

  Backtrace:
  Program received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 0x3fff85c74fc0 (LWP 74517)]
  0x6017491c in sighandler_setxid (sig=33, si=0x3fff85c72d08, 
ctx=0x3fff85c71f90) at nptl-init.c:263
  263 nptl-init.c: No such file or directory.
  (gdb) thread apply all bt

  Thread 3 (Thread 0x3fff87e8efc0 (LWP 74515)):
  #0  0x601cc430 in syscall ()
  #1  0x60109080 in futex_wait (val=, ev=) at /build/qemu/util/qemu-thread-posix.c:292
  #2  qemu_event_wait (ev=0x62367bb0 ) at 
/build/qemu/util/qemu-thread-posix.c:399
  #3  0x6010f73c in call_rcu_thread (opaque=) at 
/build/qemu/util/rcu.c:250
  #4  0x60176f8c in start_thread (arg=0x3fff87e8efc0) at 
pthread_create.c:336
  #5  0x601cebf4 in clone ()

  Thread 2 (Thread 0x3fff85c74fc0 (LWP 74517)):
  #0  0x6017491c in sighandler_setxid (sig=33, si=0x3fff85c72d08, 
ctx=0x3fff85c71f90) at nptl-init.c:263
  #1  
  #2  0x601cc42c in syscall ()
  #3  0x60044b08 in safe_futex (val3=, uaddr2=0x0, 
timeout=, val=, op=128, uaddr=) at 
/build/qemu/linux-user/syscall.c:748
  #4  do_futex (val3=, uaddr2=275186650880, timeout=0, val=1129, 
op=128, uaddr=275186651116) at /build/qemu/linux-user/syscall.c:6201
  #5  do_syscall (cpu_env=0x1000abfd350, num=, 
arg1=275186651116, arg2=, arg3=1129, arg4=0, arg5=275186650880, 
arg6=, arg7=0, arg8=0)
  at /build/qemu/linux-user/syscall.c:10651
  #6  0x600347b8 in cpu_loop (env=0x1000abfd350) at 
/build/qemu/linux-user/main.c:317
  #7  0x60036ae0 in clone_func (arg=0x3fffc4c2ca38) at 
/build/qemu/linux-user/syscall.c:5445
  #8  0x60176f8c in start_thread (arg=0x3fff85c74fc0) at 
pthread_create.c:336
  #9  0x601cebf4 in clone ()

  Thread 1 (Thread 0x1000aa05000 (LWP 74511)):
  #0  0x601cc430 in syscall ()
  #1  0x60044b08 in safe_futex (val3=, uaddr2=0x0, 
timeout=, val=, op=128, uaddr=) at 
/build/qemu/linux-user/syscall.c:748
  #2  do_futex (val3=, uaddr2=1, timeout=0, val=1, op=128, 
uaddr=275078324992) at /build/qemu/linux-user/syscall.c:6201
  #3  do_syscall (cpu_env=0x1000aa23890, num=, 
arg1=275078324992, arg2=, arg3=1, arg4=0, arg5=1, 
arg6=, arg7=0, arg8=0) at /build/qemu/linux-user/syscall.c:10651
  #4  0x600347b8 in cpu_loop (env=0x1000aa23890) at 
/build/qemu/linux-user/main.c:317
  #5  0x600020e4 in main (argc=, argv=, 
envp=) at /build/qemu/linux-user/main.c:4779
  (gdb) p __xidcmd
  $1 = (struct xid_command *) 0x0

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1594394/+subscriptions



[PATCH 2/2] block/qcow: remove runtime opts

2020-08-06 Thread John Snow
Introduced by d85f4222b468,
These were seemingly never used at all.

Signed-off-by: John Snow 
---
 block/qcow.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index e514a86fe5e..f8919a44d19 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -105,15 +105,6 @@ static int qcow_probe(const uint8_t *buf, int buf_size, 
const char *filename)
 return 0;
 }
 
-static QemuOptsList qcow_runtime_opts = {
-.name = "qcow",
-.head = QTAILQ_HEAD_INITIALIZER(qcow_runtime_opts.head),
-.desc = {
-BLOCK_CRYPTO_OPT_DEF_QCOW_KEY_SECRET("encrypt."),
-{ /* end of list */ }
-},
-};
-
 static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
  Error **errp)
 {
-- 
2.26.2




[PATCH 1/2] block/rbd: remove runtime_opts

2020-08-06 Thread John Snow
This saw its last use in 4bfb274165ba.

Signed-off-by: John Snow 
---
 block/rbd.c | 42 --
 1 file changed, 42 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index 688074c64b7..171c67e3a01 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -341,48 +341,6 @@ static void qemu_rbd_memset(RADOSCB *rcb, int64_t offs)
 }
 }
 
-static QemuOptsList runtime_opts = {
-.name = "rbd",
-.head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
-.desc = {
-{
-.name = "pool",
-.type = QEMU_OPT_STRING,
-.help = "Rados pool name",
-},
-{
-.name = "namespace",
-.type = QEMU_OPT_STRING,
-.help = "Rados namespace name in the pool",
-},
-{
-.name = "image",
-.type = QEMU_OPT_STRING,
-.help = "Image name in the pool",
-},
-{
-.name = "conf",
-.type = QEMU_OPT_STRING,
-.help = "Rados config file location",
-},
-{
-.name = "snapshot",
-.type = QEMU_OPT_STRING,
-.help = "Ceph snapshot name",
-},
-{
-/* maps to 'id' in rados_create() */
-.name = "user",
-.type = QEMU_OPT_STRING,
-.help = "Rados id name",
-},
-/*
- * server.* extracted manually, see qemu_rbd_mon_host()
- */
-{ /* end of list */ }
-},
-};
-
 /* FIXME Deprecate and remove keypairs or make it available in QMP. */
 static int qemu_rbd_do_create(BlockdevCreateOptions *options,
   const char *keypairs, const char 
*password_secret,
-- 
2.26.2




[PATCH 0/2] block: remove stale runtime_opts

2020-08-06 Thread John Snow


John Snow (2):
  block/rbd: remove runtime_opts
  block/qcow: remove runtime opts

 block/qcow.c |  9 -
 block/rbd.c  | 42 --
 2 files changed, 51 deletions(-)

-- 
2.26.2





[Bug 1594394] Re: Using setreuid / setegid crashes x86_64 user-mode target

2020-08-06 Thread Steve Dodd
(Need a "cd .." after the tar, doh.)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1594394

Title:
  Using setreuid / setegid crashes x86_64 user-mode target

Status in QEMU:
  New

Bug description:
  When setreuid() or setegid() are called from x86_64 target code in
  user mode, qemu crashes inside the NPTL signal handlers.  x86 targets
  do not directly use a syscall to handle setreuid() / setegid();
  instead the x86 NPTL implementation sets up a temporary data region in
  memory (__xidcmd) and issues a signal (SIGRT1) to all threads,
  allowing the handler for that signal to issue the syscall.  Under
  qemu, __xidcmd remains null (see variable display below backtrace).

  Backtrace:
  Program received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 0x3fff85c74fc0 (LWP 74517)]
  0x6017491c in sighandler_setxid (sig=33, si=0x3fff85c72d08, 
ctx=0x3fff85c71f90) at nptl-init.c:263
  263 nptl-init.c: No such file or directory.
  (gdb) thread apply all bt

  Thread 3 (Thread 0x3fff87e8efc0 (LWP 74515)):
  #0  0x601cc430 in syscall ()
  #1  0x60109080 in futex_wait (val=, ev=) at /build/qemu/util/qemu-thread-posix.c:292
  #2  qemu_event_wait (ev=0x62367bb0 ) at 
/build/qemu/util/qemu-thread-posix.c:399
  #3  0x6010f73c in call_rcu_thread (opaque=) at 
/build/qemu/util/rcu.c:250
  #4  0x60176f8c in start_thread (arg=0x3fff87e8efc0) at 
pthread_create.c:336
  #5  0x601cebf4 in clone ()

  Thread 2 (Thread 0x3fff85c74fc0 (LWP 74517)):
  #0  0x6017491c in sighandler_setxid (sig=33, si=0x3fff85c72d08, 
ctx=0x3fff85c71f90) at nptl-init.c:263
  #1  
  #2  0x601cc42c in syscall ()
  #3  0x60044b08 in safe_futex (val3=, uaddr2=0x0, 
timeout=, val=, op=128, uaddr=) at 
/build/qemu/linux-user/syscall.c:748
  #4  do_futex (val3=, uaddr2=275186650880, timeout=0, val=1129, 
op=128, uaddr=275186651116) at /build/qemu/linux-user/syscall.c:6201
  #5  do_syscall (cpu_env=0x1000abfd350, num=, 
arg1=275186651116, arg2=, arg3=1129, arg4=0, arg5=275186650880, 
arg6=, arg7=0, arg8=0)
  at /build/qemu/linux-user/syscall.c:10651
  #6  0x600347b8 in cpu_loop (env=0x1000abfd350) at 
/build/qemu/linux-user/main.c:317
  #7  0x60036ae0 in clone_func (arg=0x3fffc4c2ca38) at 
/build/qemu/linux-user/syscall.c:5445
  #8  0x60176f8c in start_thread (arg=0x3fff85c74fc0) at 
pthread_create.c:336
  #9  0x601cebf4 in clone ()

  Thread 1 (Thread 0x1000aa05000 (LWP 74511)):
  #0  0x601cc430 in syscall ()
  #1  0x60044b08 in safe_futex (val3=, uaddr2=0x0, 
timeout=, val=, op=128, uaddr=) at 
/build/qemu/linux-user/syscall.c:748
  #2  do_futex (val3=, uaddr2=1, timeout=0, val=1, op=128, 
uaddr=275078324992) at /build/qemu/linux-user/syscall.c:6201
  #3  do_syscall (cpu_env=0x1000aa23890, num=, 
arg1=275078324992, arg2=, arg3=1, arg4=0, arg5=1, 
arg6=, arg7=0, arg8=0) at /build/qemu/linux-user/syscall.c:10651
  #4  0x600347b8 in cpu_loop (env=0x1000aa23890) at 
/build/qemu/linux-user/main.c:317
  #5  0x600020e4 in main (argc=, argv=, 
envp=) at /build/qemu/linux-user/main.c:4779
  (gdb) p __xidcmd
  $1 = (struct xid_command *) 0x0

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1594394/+subscriptions



[Bug 1594394] Re: Using setreuid / setegid crashes x86_64 user-mode target

2020-08-06 Thread Steve Dodd
Sorry, lost your reply in amongst the chaos of my life! OK, quick test
case (type at command line, don't run as script!), host arch is x86-64,
you need qemu-user-static installed..

wget 
https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-armhf-root.tar.xz
sudo -s
mkdir armcont
cd armcont
tar xf ../bionic-server-cloudimg-armhf-root.tar.xz
cp /usr/bin/qemu-arm-static armcont/usr/bin/
rm armcont/etc/resolv.conf; cp /etc/resolv.conf armcont/etc/
systemd-nspawn -D armcont/
do-release-upgrade -d # may need to drop the "-d" once 20.04.1 is released

Yields:

qemu:handle_cpu_signal received signal outside vCPU context @
pc=0x601540af

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1594394

Title:
  Using setreuid / setegid crashes x86_64 user-mode target

Status in QEMU:
  New

Bug description:
  When setreuid() or setegid() are called from x86_64 target code in
  user mode, qemu crashes inside the NPTL signal handlers.  x86 targets
  do not directly use a syscall to handle setreuid() / setegid();
  instead the x86 NPTL implementation sets up a temporary data region in
  memory (__xidcmd) and issues a signal (SIGRT1) to all threads,
  allowing the handler for that signal to issue the syscall.  Under
  qemu, __xidcmd remains null (see variable display below backtrace).

  Backtrace:
  Program received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 0x3fff85c74fc0 (LWP 74517)]
  0x6017491c in sighandler_setxid (sig=33, si=0x3fff85c72d08, 
ctx=0x3fff85c71f90) at nptl-init.c:263
  263 nptl-init.c: No such file or directory.
  (gdb) thread apply all bt

  Thread 3 (Thread 0x3fff87e8efc0 (LWP 74515)):
  #0  0x601cc430 in syscall ()
  #1  0x60109080 in futex_wait (val=, ev=) at /build/qemu/util/qemu-thread-posix.c:292
  #2  qemu_event_wait (ev=0x62367bb0 ) at 
/build/qemu/util/qemu-thread-posix.c:399
  #3  0x6010f73c in call_rcu_thread (opaque=) at 
/build/qemu/util/rcu.c:250
  #4  0x60176f8c in start_thread (arg=0x3fff87e8efc0) at 
pthread_create.c:336
  #5  0x601cebf4 in clone ()

  Thread 2 (Thread 0x3fff85c74fc0 (LWP 74517)):
  #0  0x6017491c in sighandler_setxid (sig=33, si=0x3fff85c72d08, 
ctx=0x3fff85c71f90) at nptl-init.c:263
  #1  
  #2  0x601cc42c in syscall ()
  #3  0x60044b08 in safe_futex (val3=, uaddr2=0x0, 
timeout=, val=, op=128, uaddr=) at 
/build/qemu/linux-user/syscall.c:748
  #4  do_futex (val3=, uaddr2=275186650880, timeout=0, val=1129, 
op=128, uaddr=275186651116) at /build/qemu/linux-user/syscall.c:6201
  #5  do_syscall (cpu_env=0x1000abfd350, num=, 
arg1=275186651116, arg2=, arg3=1129, arg4=0, arg5=275186650880, 
arg6=, arg7=0, arg8=0)
  at /build/qemu/linux-user/syscall.c:10651
  #6  0x600347b8 in cpu_loop (env=0x1000abfd350) at 
/build/qemu/linux-user/main.c:317
  #7  0x60036ae0 in clone_func (arg=0x3fffc4c2ca38) at 
/build/qemu/linux-user/syscall.c:5445
  #8  0x60176f8c in start_thread (arg=0x3fff85c74fc0) at 
pthread_create.c:336
  #9  0x601cebf4 in clone ()

  Thread 1 (Thread 0x1000aa05000 (LWP 74511)):
  #0  0x601cc430 in syscall ()
  #1  0x60044b08 in safe_futex (val3=, uaddr2=0x0, 
timeout=, val=, op=128, uaddr=) at 
/build/qemu/linux-user/syscall.c:748
  #2  do_futex (val3=, uaddr2=1, timeout=0, val=1, op=128, 
uaddr=275078324992) at /build/qemu/linux-user/syscall.c:6201
  #3  do_syscall (cpu_env=0x1000aa23890, num=, 
arg1=275078324992, arg2=, arg3=1, arg4=0, arg5=1, 
arg6=, arg7=0, arg8=0) at /build/qemu/linux-user/syscall.c:10651
  #4  0x600347b8 in cpu_loop (env=0x1000aa23890) at 
/build/qemu/linux-user/main.c:317
  #5  0x600020e4 in main (argc=, argv=, 
envp=) at /build/qemu/linux-user/main.c:4779
  (gdb) p __xidcmd
  $1 = (struct xid_command *) 0x0

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1594394/+subscriptions



[Bug 1594394] Re: Using setreuid / setegid crashes x86_64 user-mode target

2020-08-06 Thread Steve Dodd
Actually, this is possibly not the same bug. I will add to the list to
investigate further..

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1594394

Title:
  Using setreuid / setegid crashes x86_64 user-mode target

Status in QEMU:
  New

Bug description:
  When setreuid() or setegid() are called from x86_64 target code in
  user mode, qemu crashes inside the NPTL signal handlers.  x86 targets
  do not directly use a syscall to handle setreuid() / setegid();
  instead the x86 NPTL implementation sets up a temporary data region in
  memory (__xidcmd) and issues a signal (SIGRT1) to all threads,
  allowing the handler for that signal to issue the syscall.  Under
  qemu, __xidcmd remains null (see variable display below backtrace).

  Backtrace:
  Program received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 0x3fff85c74fc0 (LWP 74517)]
  0x6017491c in sighandler_setxid (sig=33, si=0x3fff85c72d08, 
ctx=0x3fff85c71f90) at nptl-init.c:263
  263 nptl-init.c: No such file or directory.
  (gdb) thread apply all bt

  Thread 3 (Thread 0x3fff87e8efc0 (LWP 74515)):
  #0  0x601cc430 in syscall ()
  #1  0x60109080 in futex_wait (val=, ev=) at /build/qemu/util/qemu-thread-posix.c:292
  #2  qemu_event_wait (ev=0x62367bb0 ) at 
/build/qemu/util/qemu-thread-posix.c:399
  #3  0x6010f73c in call_rcu_thread (opaque=) at 
/build/qemu/util/rcu.c:250
  #4  0x60176f8c in start_thread (arg=0x3fff87e8efc0) at 
pthread_create.c:336
  #5  0x601cebf4 in clone ()

  Thread 2 (Thread 0x3fff85c74fc0 (LWP 74517)):
  #0  0x6017491c in sighandler_setxid (sig=33, si=0x3fff85c72d08, 
ctx=0x3fff85c71f90) at nptl-init.c:263
  #1  
  #2  0x601cc42c in syscall ()
  #3  0x60044b08 in safe_futex (val3=, uaddr2=0x0, 
timeout=, val=, op=128, uaddr=) at 
/build/qemu/linux-user/syscall.c:748
  #4  do_futex (val3=, uaddr2=275186650880, timeout=0, val=1129, 
op=128, uaddr=275186651116) at /build/qemu/linux-user/syscall.c:6201
  #5  do_syscall (cpu_env=0x1000abfd350, num=, 
arg1=275186651116, arg2=, arg3=1129, arg4=0, arg5=275186650880, 
arg6=, arg7=0, arg8=0)
  at /build/qemu/linux-user/syscall.c:10651
  #6  0x600347b8 in cpu_loop (env=0x1000abfd350) at 
/build/qemu/linux-user/main.c:317
  #7  0x60036ae0 in clone_func (arg=0x3fffc4c2ca38) at 
/build/qemu/linux-user/syscall.c:5445
  #8  0x60176f8c in start_thread (arg=0x3fff85c74fc0) at 
pthread_create.c:336
  #9  0x601cebf4 in clone ()

  Thread 1 (Thread 0x1000aa05000 (LWP 74511)):
  #0  0x601cc430 in syscall ()
  #1  0x60044b08 in safe_futex (val3=, uaddr2=0x0, 
timeout=, val=, op=128, uaddr=) at 
/build/qemu/linux-user/syscall.c:748
  #2  do_futex (val3=, uaddr2=1, timeout=0, val=1, op=128, 
uaddr=275078324992) at /build/qemu/linux-user/syscall.c:6201
  #3  do_syscall (cpu_env=0x1000aa23890, num=, 
arg1=275078324992, arg2=, arg3=1, arg4=0, arg5=1, 
arg6=, arg7=0, arg8=0) at /build/qemu/linux-user/syscall.c:10651
  #4  0x600347b8 in cpu_loop (env=0x1000aa23890) at 
/build/qemu/linux-user/main.c:317
  #5  0x600020e4 in main (argc=, argv=, 
envp=) at /build/qemu/linux-user/main.c:4779
  (gdb) p __xidcmd
  $1 = (struct xid_command *) 0x0

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1594394/+subscriptions



Re: [PATCH 0/4] Refactor get_fpstatus_ptr() ready for AArch32 fp16

2020-08-06 Thread Richard Henderson
On 8/6/20 3:44 AM, Peter Maydell wrote:
> Peter Maydell (4):
>   target/arm: Replace A64 get_fpstatus_ptr() with generic fpstatus_ptr()
>   target/arm: Make A32/T32 use new fpstatus_ptr() API
>   target/arm: Implement FPST_STD_F16 fpstatus
>   target/arm: Use correct FPST for VCMLA, VCADD on fp16

Reviewed-by: Richard Henderson 

r~



Re: [PATCH 108/143] meson: convert hw/intc

2020-08-06 Thread Peter Maydell
On Thu, 6 Aug 2020 at 21:10, Paolo Bonzini  wrote:
>
> From: Marc-André Lureau 
>
> Signed-off-by: Marc-André Lureau 
> Signed-off-by: Paolo Bonzini 

Compared to:

> -common-obj-$(CONFIG_HEATHROW_PIC) += heathrow_pic.o

> +softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true: files('heathrow_pic.c'))

this feels pretty clunky. Doesn't Meson have a nicer
way of expressing this kind of thing? It's really
common and I'd hope that a build system language
would provide less long-winded ways to write common
operations...

thanks
-- PMM



Small error in blog post

2020-08-06 Thread Louis Cloete
Hi!

I read your blog post
http://blog.vmsplice.net/2020/08/why-qemu-should-move-from-c-to-rust.html

I thought it was a well thought out exposition of the topic of "what shall
we do to security vulnerabilities due to C bugs. Is Rust the answer".

However, one small inaccuracy caught my eye. Rust doesn't prevent memory
leaks. Memory leaks aren't considered memory unsafe by Rust's definition.
It is possible to leak memory in safe Rust. I believe memory leaks are not
prevented, because trying to prove their absence at compile time boils down
to the halting problem.

Regards
Louis Cloete


Re: [PATCH-for-5.2] target/mips: Report unimplemented cache() operations

2020-08-06 Thread Peter Maydell
On Thu, 6 Aug 2020 at 21:31, Philippe Mathieu-Daudé  wrote:
>
> On 8/6/20 8:01 PM, Jiaxun Yang wrote:
> > 在 2020/8/6 下午8:26, Philippe Mathieu-Daudé 写道:
> >> We only implement the Index[Store/Load]Tag from the 'cache' opcode.
> >> Instead of ignoring the other cache operations, report them as
> >> unimplemented.
> >
> > Hmm, I don't think we have anything to do with Invalidate/Writeback etc.
> > opcodes
> > in QEMU. Why do we log this?
>
> I'm noticed this code is run on Linux 3.3.8 (4KEc):
>
> 8880:   3082000fandiv0,a0,0xf
> 8884:   1088beqza0,88a8
> :   00a21021adduv0,a1,v0
> 888c:   08002227j   889c
> 8890:   1821movev1,zero
> 8894:   bcf9cache   0x19,0(a3)
> 8898:   24630010addiu   v1,v1,16
> 889c:   0062302bsltua2,v1,v0
> 88a0:   14c0fffcbneza2,8894
> 88a4:   00833821addua3,a0,v1
> 88a8:   03e8jr  ra
> 88ac:   nop
>
> Why silently ignore the opcode is not implemented instead of logging it?

I think the question is whether the opcode is supposed to have
some behaviour which we're not implementing, or whether "no-op"
is the correct behaviour for it (which it usually is for
cache invalidate type operations; compare the way the Arm
cache ops like IC_IALLU are just ARM_CP_NOP ops).

thanks
-- PMM



Re: [PATCH v1 01/21] accel/tcg: Change interrupt/exception handling to remove implied BQL

2020-08-06 Thread Robert Foley
The comment around documenting the cpu_mutex fields and critical sections
got us thinking and revisiting our locking assumptions in cpu_handle_interrupt.

Initially we were thinking that removing the BQL from cpu_handle_interrupt
meant that we needed to replace it with the cpu mutex to protect the per cpu
data that is accessed like interrupt_request.  We are reconsidering this and
now thinking that the cpu mutex might not be needed here.

BQL is clearly needed to protect the critical section around the call to
->cpu_exec_interrupt.  What else is the BQL protecting in cpu_handle_interrupt
that we need to consider?  Are we missing anything here?

It's also worth mentioning that we did give this approach a try.
We tried out changes to cpu_handle_interrupt(),
dropping the BQL from all but around ->cpu_exec_interrupt, and not using the
cpu_mutex at all.  It seemed to be functional, passing all the tests that
we tried (so far). :)

Thanks,
-Rob

On Thu, 6 Aug 2020 at 12:11, Robert Foley  wrote:
>
> On Thu, 6 Aug 2020 at 05:22, Paolo Bonzini  wrote:
> >
> > On 05/08/20 21:18, Richard Henderson wrote:
> > > On 8/5/20 11:12 AM, Robert Foley wrote:
> > >> This change removes the implied BQL from the cpu_handle_interrupt,
> > >> and cpu_handle_exception paths. This BQL acquire is being pushed
> > >> down into the per arch implementation.
> > >>
> > >> Signed-off-by: Robert Foley 
> > >> ---
> > >>  accel/tcg/cpu-exec.c | 19 +++
> > >>  1 file changed, 11 insertions(+), 8 deletions(-)
> > >>
> > >> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> > >> index 80d0e649b2..8e2bfd97a1 100644
> > >> --- a/accel/tcg/cpu-exec.c
> > >> +++ b/accel/tcg/cpu-exec.c
> > >> @@ -517,9 +517,7 @@ static inline bool cpu_handle_exception(CPUState 
> > >> *cpu, int *ret)
> > >>  #else
> > >>  if (replay_exception()) {
> > >>  CPUClass *cc = CPU_GET_CLASS(cpu);
> > >> -qemu_mutex_lock_iothread();
> > >>  cc->do_interrupt(cpu);
> > >> -qemu_mutex_unlock_iothread();
> > >>  cpu->exception_index = -1;
> > >>
> > >
> > > This patch is not bisectable.  The removal of the lock here needs to 
> > > happen at
> > > the end, or something.
> >
> > Indeed the series should be structured like this:
> >
> > 1) rename all *_do_interrupt functions to *_do_interrupt_locked
> >
> > 2) add back *_do_interrupt that takes the BQL and calls
> > *_do_interrupt_locked, point ->do_interrupt to it, remove the BQL from
> > cpu-exec.c
> >
> > 3) modify the cpu_mutex and BQL critical sections around
> > ->cpu_exec_interrupt, so that the BQL critical section covers just the
> > call to ->cpu_exec_interrupt.  Document which fields are now covered by
> > cpu_mutex.
> >
> > 4/5) same as 1/2 for ->cpu_exec_interrupt
> >
> > Patches 1/2 would be pretty large, but they're trivial to review just by
> > grepping for "->do_interrupt\s*=", and likewise for 4/5.
> >
>
> Thanks for the details !
>
> It seems like we will have 3 separate patches for this series, 1/2, 3, and 
> 4/5.
>
> We will go in this direction.
>
> Thanks,
> -Rob
>
> > Thanks,
> >
> > Paolo
> >



[PATCH v13 06/11] qcow2_format.py: pass cluster size to substructures

2020-08-06 Thread Andrey Shinkevich
The cluster size of an image is the QcowHeader class member and may be
obtained by dependent extension structures such as Qcow2BitmapExt for
further bitmap table details print.

Signed-off-by: Andrey Shinkevich 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/qcow2_format.py | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index 05a8aa9..ca0d350 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -129,19 +129,21 @@ class Qcow2BitmapExt(Qcow2Struct):
 ('u64', '{:#x}', 'bitmap_directory_offset')
 )
 
-def __init__(self, fd):
+def __init__(self, fd, cluster_size):
 super().__init__(fd=fd)
 tail = struct.calcsize(self.fmt) % 8
 if tail:
 fd.seek(8 - tail, 1)
 position = fd.tell()
+self.cluster_size = cluster_size
 self.read_bitmap_directory(fd)
 fd.seek(position)
 
 def read_bitmap_directory(self, fd):
 fd.seek(self.bitmap_directory_offset)
 self.bitmap_directory = \
-[Qcow2BitmapDirEntry(fd) for _ in range(self.nb_bitmaps)]
+[Qcow2BitmapDirEntry(fd, cluster_size=self.cluster_size)
+ for _ in range(self.nb_bitmaps)]
 
 def dump(self):
 super().dump()
@@ -162,8 +164,9 @@ class Qcow2BitmapDirEntry(Qcow2Struct):
 ('u32', '{}', 'extra_data_size')
 )
 
-def __init__(self, fd):
+def __init__(self, fd, cluster_size):
 super().__init__(fd=fd)
+self.cluster_size = cluster_size
 # Seek relative to the current position in the file
 fd.seek(self.extra_data_size, 1)
 bitmap_name = fd.read(self.name_size)
@@ -203,11 +206,13 @@ class QcowHeaderExtension(Qcow2Struct):
 # then padding to next multiply of 8
 )
 
-def __init__(self, magic=None, length=None, data=None, fd=None):
+def __init__(self, magic=None, length=None, data=None, fd=None,
+ cluster_size=None):
 """
 Support both loading from fd and creation from user data.
 For fd-based creation current position in a file will be used to read
 the data.
+The cluster_size value may be obtained by dependent structures.
 
 This should be somehow refactored and functionality should be moved to
 superclass (to allow creation of any qcow2 struct), but then, fields
@@ -230,7 +235,7 @@ class QcowHeaderExtension(Qcow2Struct):
 assert all(v is None for v in (magic, length, data))
 super().__init__(fd=fd)
 if self.magic == QCOW2_EXT_MAGIC_BITMAPS:
-self.obj = Qcow2BitmapExt(fd=fd)
+self.obj = Qcow2BitmapExt(fd=fd, cluster_size=cluster_size)
 self.data = None
 else:
 padded = (self.length + 7) & ~7
@@ -319,7 +324,7 @@ class QcowHeader(Qcow2Struct):
 end = self.cluster_size
 
 while fd.tell() < end:
-ext = QcowHeaderExtension(fd=fd)
+ext = QcowHeaderExtension(fd=fd, cluster_size=self.cluster_size)
 if ext.magic == 0:
 break
 else:
-- 
1.8.3.1




Re: [PATCH-for-5.2] target/mips: Report unimplemented cache() operations

2020-08-06 Thread Philippe Mathieu-Daudé
On 8/6/20 8:01 PM, Jiaxun Yang wrote:
> 在 2020/8/6 下午8:26, Philippe Mathieu-Daudé 写道:
>> We only implement the Index[Store/Load]Tag from the 'cache' opcode.
>> Instead of ignoring the other cache operations, report them as
>> unimplemented.
> 
> Hmm, I don't think we have anything to do with Invalidate/Writeback etc.
> opcodes
> in QEMU. Why do we log this?

I'm noticed this code is run on Linux 3.3.8 (4KEc):

8880:   3082000fandiv0,a0,0xf
8884:   1088beqza0,88a8
:   00a21021adduv0,a1,v0
888c:   08002227j   889c
8890:   1821movev1,zero
8894:   bcf9cache   0x19,0(a3)
8898:   24630010addiu   v1,v1,16
889c:   0062302bsltua2,v1,v0
88a0:   14c0fffcbneza2,8894
88a4:   00833821addua3,a0,v1
88a8:   03e8jr  ra
88ac:   nop

Why silently ignore the opcode is not implemented instead of logging it?

> 
> Thanks.
> 
> - Jiaxun
> 
>>
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
>>   target/mips/op_helper.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
>> index 9552b280e0..7f87e57c8e 100644
>> --- a/target/mips/op_helper.c
>> +++ b/target/mips/op_helper.c
>> @@ -1583,6 +1583,8 @@ void helper_cache(CPUMIPSState *env,
>> target_ulong addr, uint32_t op)
>>   /* Index Load Tag */
>>   memory_region_dispatch_read(env->itc_tag, index,
>> >CP0_TagLo,
>>   MO_64, MEMTXATTRS_UNSPECIFIED);
>> +    } else {
>> +    qemu_log_mask(LOG_UNIMP, "cache %u\n", op);
>>   }
>>   #endif
>>   }
> 



[PATCH v13 04/11] qcow2_format.py: dump bitmap flags in human readable way.

2020-08-06 Thread Andrey Shinkevich
Introduce the class BitmapFlags that parses a bitmap flags mask.

Suggested-by: Vladimir Sementsov-Ogievskiy 
Signed-off-by: Andrey Shinkevich 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/qcow2_format.py | 16 
 1 file changed, 16 insertions(+)

diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index d4a9974..b447344 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -40,6 +40,22 @@ class Flags64(Qcow2Field):
 return str(bits)
 
 
+class BitmapFlags(Qcow2Field):
+
+flags = {
+0x1: 'in-use',
+0x2: 'auto'
+}
+
+def __str__(self):
+bits = []
+for bit in range(64):
+flag = self.value & (1 << bit)
+if flag:
+bits.append(self.flags.get(flag, f'bit-{bit}'))
+return f'{self.value:#x} ({bits})'
+
+
 class Enum(Qcow2Field):
 
 def __str__(self):
-- 
1.8.3.1




Re: [Virtio-fs] virtio-fs performance

2020-08-06 Thread Vivek Goyal
On Tue, Aug 04, 2020 at 03:51:50PM +0800, Derek Su wrote:
> Vivek Goyal  於 2020年7月28日 週二 下午11:27寫道:
> >
> > On Tue, Jul 28, 2020 at 02:49:36PM +0100, Stefan Hajnoczi wrote:
> > > > I'm trying and testing the virtio-fs feature in QEMU v5.0.0.
> > > > My host and guest OS are both ubuntu 18.04 with kernel 5.4, and the
> > > > underlying storage is one single SSD.
> > > >
> > > > The configuations are:
> > > > (1) virtiofsd
> > > > ./virtiofsd -o
> > > > source=/mnt/ssd/virtiofs,cache=auto,flock,posix_lock,writeback,xattr
> > > > --thread-pool-size=1 --socket-path=/tmp/vhostqemu
> > > >
> > > > (2) qemu
> > > > qemu-system-x86_64 \
> > > > -enable-kvm \
> > > > -name ubuntu \
> > > > -cpu Westmere \
> > > > -m 4096 \
> > > > -global kvm-apic.vapic=false \
> > > > -netdev 
> > > > tap,id=hn0,vhost=off,br=br0,helper=/usr/local/libexec/qemu-bridge-helper
> > > > \
> > > > -device e1000,id=e0,netdev=hn0 \
> > > > -blockdev '{"node-name": "disk0", "driver": "qcow2",
> > > > "refcount-cache-size": 1638400, "l2-cache-size": 6553600, "file": {
> > > > "driver": "file", "filename": "'${imagefolder}\/ubuntu.qcow2'"}}' \
> > > > -device virtio-blk,drive=disk0,id=disk0 \
> > > > -chardev socket,id=ch0,path=/tmp/vhostqemu \
> > > > -device vhost-user-fs-pci,chardev=ch0,tag=myfs \
> > > > -object memory-backend-memfd,id=mem,size=4G,share=on \
> > > > -numa node,memdev=mem \
> > > > -qmp stdio \
> > > > -vnc :0
> > > >
> > > > (3) guest
> > > > mount -t virtiofs myfs /mnt/virtiofs
> > > >
> > > > I tried to change virtiofsd's --thread-pool-size value and test the
> > > > storage performance by fio.
> > > > Before each read/write/randread/randwrite test, the pagecaches of
> > > > guest and host are dropped.
> > > >
> > > > ```
> > > > RW="read" # or write/randread/randwrite
> > > > fio --name=test --rw=$RW --bs=4k --numjobs=1 --ioengine=libaio
> > > > --runtime=60 --direct=0 --iodepth=64 --size=10g
> > > > --filename=/mnt/virtiofs/testfile
> > > > done
> >
> > Couple of things.
> >
> > - Can you try cache=none option in virtiofsd. That will bypass page
> >   cache in guest. It also gets rid of latencies related to
> >   file_remove_privs() as of now.
> >
> > - Also with direct=0, are we really driving iodepth of 64? With direct=0
> >   it is cached I/O. Is it still asynchronous at this point of time of
> >   we have fallen back to synchronous I/O and driving queue depth of
> >   1.
> 
> Hi, Vivek
> 
> I did not see any difference in queue depth with direct={0|1} in my fio test.
> Are there more clues to dig into this issue?

I tried it just again. fio seems to say queue depth 64 in both the cases
but I am not sure if this is correct. Reason being that I get much
better performance with direct=1. Also fio man page says.

 libaio Linux native asynchronous I/O. Note that Linux may
only support queued behavior with non-buffered I/O
(set  `direct=1'  or  `buffered=0').   This engine
defines engine specific options.

Are you see difference in effective bandwidth/iops when you run with
direct=0/1. I see it. 

Anyway, in an attempt to narrow down the issues, I ran virtiofsd 
with cache=none and did not enable xattr. (As of now xattr case
needs to be optimized with SB_NOSEC).

I ran virtiofsd as follows.

./virtiofsd --socket-path=/tmp/vhostqemu2 -o source=/mnt/sdb/virtiofs-source2/ 
-o no_posix_lock -o modcaps=+sys_admin -o log_level=info -o cache=none 
--daemonize

And then ran following fio commands with direct=0 and direct=1.

fio --name=test --rw=randwrite --bs=4K --numjobs=1 --ioengine=libaio 
--runtime=30 --direct=0 --iodepth=64 --filename=fio-file1

direct=0

write: IOPS=8712, BW=34.0MiB/s (35.7MB/s)(1021MiB/30001msec)

direct=1

write: IOPS=84.4k, BW=330MiB/s (346MB/s)(4096MiB/12428msec)

So I see almost 10 fold jump in throughput with direct=1. So I believe
direct=0 is not driving the queue depth.

You raised interesting issue of --thread-pool-size=1 vs 64 and I decided
to give it a try. I ran same tests as above with thread pool size 1
and following are results.

with direct=0
-
write: IOPS=14.7k, BW=57.4MiB/s (60.2MB/s)(1721MiB/30001msec)

with direct=1
-
write: IOPS=71.7k, BW=280MiB/s (294MB/s)(4096MiB/14622msec);

So with we are driving queue depth 1 (direct=0), looks like
--thread-pool-size 1 is helping. I see higher IOPS. But when we are
driving queue depth of 64, then --thread-pool-size=1 seems to hurt.

Now question is, why thread pool size 64 by default hurts so much
for the case of queue depth 1.

You raised anohter issue of it being slower than NFSv4/CIFS. I think
you can run virtiofsd with cache=none and without enabling xattr
and post results here so that we have some idea how much better
NFSv4/CIFS is.

Thanks
Vivek




[PATCH v13 08/11] qcow2.py: Introduce '-j' key to dump in JSON format

2020-08-06 Thread Andrey Shinkevich
Add the command key to the qcow2.py arguments list to dump QCOW2
metadata in JSON format. Here is the suggested way to do that. The
implementation of the dump in JSON format is in the patch that follows.

Signed-off-by: Andrey Shinkevich 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/qcow2.py| 18 ++
 tests/qemu-iotests/qcow2_format.py |  4 ++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index 0910e6a..77ca59c 100755
--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -26,16 +26,19 @@ from qcow2_format import (
 )
 
 
+is_json = False
+
+
 def cmd_dump_header(fd):
 h = QcowHeader(fd)
-h.dump()
+h.dump(is_json)
 print()
-h.dump_extensions()
+h.dump_extensions(is_json)
 
 
 def cmd_dump_header_exts(fd):
 h = QcowHeader(fd)
-h.dump_extensions()
+h.dump_extensions(is_json)
 
 
 def cmd_set_header(fd, name, value):
@@ -151,11 +154,14 @@ def main(filename, cmd, args):
 
 
 def usage():
-print("Usage: %s   [, ...]" % sys.argv[0])
+print("Usage: %s   [, ...] [, ...]" % sys.argv[0])
 print("")
 print("Supported commands:")
 for name, handler, num_args, desc in cmds:
 print("%-20s - %s" % (name, desc))
+print("")
+print("Supported keys:")
+print("%-20s - %s" % ('-j', 'Dump in JSON format'))
 
 
 if __name__ == '__main__':
@@ -163,4 +169,8 @@ if __name__ == '__main__':
 usage()
 sys.exit(1)
 
+is_json = '-j' in sys.argv
+if is_json:
+sys.argv.remove('-j')
+
 main(sys.argv[1], sys.argv[2], sys.argv[3:])
diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index 574249b..de0adcb 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -109,7 +109,7 @@ class Qcow2Struct(metaclass=Qcow2StructMeta):
 self.__dict__ = dict((field[2], values[i])
  for i, field in enumerate(self.fields))
 
-def dump(self):
+def dump(self, is_json=False):
 for f in self.fields:
 value = self.__dict__[f[2]]
 if isinstance(f[1], str):
@@ -408,7 +408,7 @@ class QcowHeader(Qcow2Struct):
 buf = buf[0:header_bytes-1]
 fd.write(buf)
 
-def dump_extensions(self):
+def dump_extensions(self, is_json=False):
 for ex in self.extensions:
 print('Header extension:')
 ex.dump()
-- 
1.8.3.1




Re: [PATCH v1 04/21] target/avr: add BQL to do_interrupt and cpu_exec_interrupt

2020-08-06 Thread Robert Foley
On Thu, 6 Aug 2020 at 14:37, Michael Rolnik  wrote:
>
> Hi Robert.
>
> I am sorry but how can I apply it? following this what I get
>
> error: patch failed: accel/tcg/cpu-exec.c:558
> error: accel/tcg/cpu-exec.c: patch does not apply
> error: patch failed: target/arm/helper.c:9808
> error: target/arm/helper.c: patch does not apply
> error: patch failed: target/ppc/excp_helper.c:1056
> error: target/ppc/excp_helper.c: patch does not apply
> error: patch failed: target/sh4/helper.c:62
> error: target/sh4/helper.c: patch does not apply
> error: patch failed: target/unicore32/softmmu.c:118
> error: target/unicore32/softmmu.c: patch does not apply
>

Hi Michael,
This patch is based on the per-cpu locks patch series:
https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg05314.html

Our current WIP tree for this interrupts patch is here:
https://github.com/rf972/qemu/commits/int_core_v1.4

Also, just so you know, based on the initial feedback we are going
to substantially change this series.

Another version will be sent out in a few days.

Thanks & Regards,
-Rob
>
>
> On Wed, Aug 5, 2020 at 9:17 PM Robert Foley  wrote:
>>
>> This is part of a series of changes to remove the implied BQL
>> from the common code of cpu_handle_interrupt and
>> cpu_handle_exception.  As part of removing the implied BQL
>> from the common code, we are pushing the BQL holding
>> down into the per-arch implementation functions of
>> do_interrupt and cpu_exec_interrupt.
>>
>> The purpose of this set of changes is to set the groundwork
>> so that an arch could move towards removing
>> the BQL from the cpu_handle_interrupt/exception paths.
>>
>> This approach was suggested by Paolo Bonzini.
>> For reference, here are two key posts in the discussion, explaining
>> the reasoning/benefits of this approach.
>> https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html
>> https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html
>>
>> Signed-off-by: Robert Foley 
>> ---
>>  target/avr/helper.c | 12 +++-
>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/target/avr/helper.c b/target/avr/helper.c
>> index d96d14372b..f0d625c195 100644
>> --- a/target/avr/helper.c
>> +++ b/target/avr/helper.c
>> @@ -30,6 +30,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int 
>> interrupt_request)
>>  CPUClass *cc = CPU_GET_CLASS(cs);
>>  AVRCPU *cpu = AVR_CPU(cs);
>>  CPUAVRState *env = >env;
>> +qemu_mutex_lock_iothread();
>>
>>  if (interrupt_request & CPU_INTERRUPT_RESET) {
>>  if (cpu_interrupts_enabled(env)) {
>> @@ -53,6 +54,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int 
>> interrupt_request)
>>  ret = true;
>>  }
>>  }
>> +qemu_mutex_unlock_iothread();
>>  return ret;
>>  }
>>
>> @@ -61,10 +63,15 @@ void avr_cpu_do_interrupt(CPUState *cs)
>>  AVRCPU *cpu = AVR_CPU(cs);
>>  CPUAVRState *env = >env;
>>
>> -uint32_t ret = env->pc_w;
>> +uint32_t ret;
>>  int vector = 0;
>>  int size = avr_feature(env, AVR_FEATURE_JMP_CALL) ? 2 : 1;
>>  int base = 0;
>> +bool bql = !qemu_mutex_iothread_locked();
>> +if (bql) {
>> +qemu_mutex_lock_iothread();
>> +}
>> +ret = env->pc_w;
>>
>>  if (cs->exception_index == EXCP_RESET) {
>>  vector = 0;
>> @@ -87,6 +94,9 @@ void avr_cpu_do_interrupt(CPUState *cs)
>>  env->sregI = 0; /* clear Global Interrupt Flag */
>>
>>  cs->exception_index = -1;
>> +if (bql) {
>> +qemu_mutex_unlock_iothread();
>> +}
>>  }
>>
>>  int avr_cpu_memory_rw_debug(CPUState *cs, vaddr addr, uint8_t *buf,
>> --
>> 2.17.1
>>
>
>
> --
> Best Regards,
> Michael Rolnik



[PATCH v13 11/11] iotests: dump QCOW2 header in JSON in #303

2020-08-06 Thread Andrey Shinkevich
Extend the test case #303 by dumping QCOW2 image metadata in JSON
format.

Signed-off-by: Andrey Shinkevich 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/303 |  3 ++
 tests/qemu-iotests/303.out | 76 ++
 2 files changed, 79 insertions(+)

diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
index e9accdc..6c21774 100755
--- a/tests/qemu-iotests/303
+++ b/tests/qemu-iotests/303
@@ -58,3 +58,6 @@ add_bitmap(1, 0, 6, False)
 add_bitmap(2, 6, 8, True)
 dump = ['qcow2.py', disk, 'dump-header']
 subprocess.run(dump)
+# Dump the metadata in JSON format
+dump.append('-j')
+subprocess.run(dump)
diff --git a/tests/qemu-iotests/303.out b/tests/qemu-iotests/303.out
index 70828e0..7fa1ede 100644
--- a/tests/qemu-iotests/303.out
+++ b/tests/qemu-iotests/303.out
@@ -80,3 +80,79 @@ extra_data_size   0
 Bitmap table   typesize offset
 0  all-zeroes  00
 
+{
+"magic": 1363560955,
+"version": 3,
+"backing_file_offset": 0,
+"backing_file_size": 0,
+"cluster_bits": 16,
+"size": 10485760,
+"crypt_method": 0,
+"l1_size": 1,
+"l1_table_offset": 196608,
+"refcount_table_offset": 65536,
+"refcount_table_clusters": 1,
+"nb_snapshots": 0,
+"snapshot_offset": 0,
+"incompatible_features": 0,
+"compatible_features": 0,
+"autoclear_features": 1,
+"refcount_order": 4,
+"header_length": 112
+}
+
+[
+{
+"name": "Feature table",
+"magic": 1745090647,
+"length": 336,
+"data_str": ""
+},
+{
+"name": "Bitmaps",
+"magic": 595929205,
+"length": 24,
+"data": {
+"nb_bitmaps": 2,
+"reserved32": 0,
+"bitmap_directory_size": 64,
+"bitmap_directory_offset": 10289152,
+"bitmap_directory": [
+{
+"name": "bitmap-1",
+"bitmap_table_offset": 10158080,
+"bitmap_table_size": 1,
+"flags": 2,
+"type": 1,
+"granularity_bits": 15,
+"name_size": 8,
+"extra_data_size": 0,
+"bitmap_table": [
+{
+"type": "serialized",
+"offset": 10092544,
+"reserved": 0
+}
+]
+},
+{
+"name": "bitmap-2",
+"bitmap_table_offset": 10223616,
+"bitmap_table_size": 1,
+"flags": 0,
+"type": 1,
+"granularity_bits": 16,
+"name_size": 8,
+"extra_data_size": 0,
+"bitmap_table": [
+{
+"type": "all-zeroes",
+"offset": 0,
+"reserved": 0
+}
+]
+}
+]
+}
+}
+]
-- 
1.8.3.1




[PATCH v13 05/11] qcow2_format.py: Dump bitmap directory information

2020-08-06 Thread Andrey Shinkevich
Read and dump entries from the bitmap directory of QCOW2 image.

Header extension:
magic 0x23852875 (Bitmaps)
...
Bitmap name   bitmap-1
bitmap_table_offset   0xf
bitmap_table_size 1
flags 0x2 (['auto'])
type  1
granularity_bits  16
name_size 8
extra_data_size   0

Suggested-by: Kevin Wolf 
Signed-off-by: Andrey Shinkevich 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/303.out | 18 +++
 tests/qemu-iotests/qcow2_format.py | 47 ++
 2 files changed, 65 insertions(+)

diff --git a/tests/qemu-iotests/303.out b/tests/qemu-iotests/303.out
index 8d7973c..038ba93 100644
--- a/tests/qemu-iotests/303.out
+++ b/tests/qemu-iotests/303.out
@@ -58,3 +58,21 @@ reserved320
 bitmap_directory_size 0x40
 bitmap_directory_offset   0x9d
 
+Bitmap name   bitmap-1
+bitmap_table_offset   0x9b
+bitmap_table_size 1
+flags 0x2 (['auto'])
+type  1
+granularity_bits  15
+name_size 8
+extra_data_size   0
+
+Bitmap name   bitmap-2
+bitmap_table_offset   0x9c
+bitmap_table_size 1
+flags 0x0 ([])
+type  1
+granularity_bits  16
+name_size 8
+extra_data_size   0
+
diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index b447344..05a8aa9 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -134,6 +134,53 @@ class Qcow2BitmapExt(Qcow2Struct):
 tail = struct.calcsize(self.fmt) % 8
 if tail:
 fd.seek(8 - tail, 1)
+position = fd.tell()
+self.read_bitmap_directory(fd)
+fd.seek(position)
+
+def read_bitmap_directory(self, fd):
+fd.seek(self.bitmap_directory_offset)
+self.bitmap_directory = \
+[Qcow2BitmapDirEntry(fd) for _ in range(self.nb_bitmaps)]
+
+def dump(self):
+super().dump()
+for entry in self.bitmap_directory:
+print()
+entry.dump()
+
+
+class Qcow2BitmapDirEntry(Qcow2Struct):
+
+fields = (
+('u64', '{:#x}', 'bitmap_table_offset'),
+('u32', '{}', 'bitmap_table_size'),
+('u32', BitmapFlags, 'flags'),
+('u8',  '{}', 'type'),
+('u8',  '{}', 'granularity_bits'),
+('u16', '{}', 'name_size'),
+('u32', '{}', 'extra_data_size')
+)
+
+def __init__(self, fd):
+super().__init__(fd=fd)
+# Seek relative to the current position in the file
+fd.seek(self.extra_data_size, 1)
+bitmap_name = fd.read(self.name_size)
+self.name = bitmap_name.decode('ascii')
+# Move position to the end of the entry in the directory
+entry_raw_size = self.bitmap_dir_entry_raw_size()
+padding = ((entry_raw_size + 7) & ~7) - entry_raw_size
+fd.seek(padding, 1)
+
+def bitmap_dir_entry_raw_size(self):
+return struct.calcsize(self.fmt) + self.name_size + \
+self.extra_data_size
+
+def dump(self):
+print(f'{"Bitmap name":<25} {self.name}')
+super(Qcow2BitmapDirEntry, self).dump()
+
 
 QCOW2_EXT_MAGIC_BITMAPS = 0x23852875
 
-- 
1.8.3.1




[PATCH v13 03/11] qcow2_format.py: change Qcow2BitmapExt initialization method

2020-08-06 Thread Andrey Shinkevich
There are two ways to initialize a class derived from Qcow2Struct:
1. Pass a block of binary data to the constructor.
2. Pass the file descriptor to allow reading the file from constructor.
Let's change the Qcow2BitmapExt initialization method from 1 to 2 to
support a scattered reading in the initialization chain.
The implementation comes with the patch that follows.

Suggested-by: Vladimir Sementsov-Ogievskiy 
Signed-off-by: Andrey Shinkevich 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/qcow2_format.py | 36 ++--
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index 2f3681b..d4a9974 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -113,6 +113,11 @@ class Qcow2BitmapExt(Qcow2Struct):
 ('u64', '{:#x}', 'bitmap_directory_offset')
 )
 
+def __init__(self, fd):
+super().__init__(fd=fd)
+tail = struct.calcsize(self.fmt) % 8
+if tail:
+fd.seek(8 - tail, 1)
 
 QCOW2_EXT_MAGIC_BITMAPS = 0x23852875
 
@@ -161,21 +166,24 @@ class QcowHeaderExtension(Qcow2Struct):
 else:
 assert all(v is None for v in (magic, length, data))
 super().__init__(fd=fd)
-padded = (self.length + 7) & ~7
-self.data = fd.read(padded)
-assert self.data is not None
-
-data_str = self.data[:self.length]
-if all(c in string.printable.encode('ascii') for c in data_str):
-data_str = f"'{ data_str.decode('ascii') }'"
-else:
-data_str = ''
-self.data_str = data_str
+if self.magic == QCOW2_EXT_MAGIC_BITMAPS:
+self.obj = Qcow2BitmapExt(fd=fd)
+self.data = None
+else:
+padded = (self.length + 7) & ~7
+self.data = fd.read(padded)
+assert self.data is not None
+self.obj = None
+
+if self.data is not None:
+data_str = self.data[:self.length]
+if all(c in string.printable.encode(
+'ascii') for c in data_str):
+data_str = f"'{ data_str.decode('ascii') }'"
+else:
+data_str = ''
+self.data_str = data_str
 
-if self.magic == QCOW2_EXT_MAGIC_BITMAPS:
-self.obj = Qcow2BitmapExt(data=self.data)
-else:
-self.obj = None
 
 def dump(self):
 super().dump()
-- 
1.8.3.1




[PATCH v13 10/11] qcow2_format.py: support dumping metadata in JSON format

2020-08-06 Thread Andrey Shinkevich
Implementation of dumping QCOW2 image metadata.
The sample output:
{
"Header_extensions": [
{
"name": "Feature table",
"magic": 1745090647,
"length": 192,
"data_str": ""
},
{
"name": "Bitmaps",
"magic": 595929205,
"length": 24,
"data": {
"nb_bitmaps": 2,
"reserved32": 0,
"bitmap_directory_size": 64,
"bitmap_directory_offset": 1048576,
"bitmap_directory": [
{
"name": "bitmap-1",
"bitmap_table_offset": 589824,
"bitmap_table_size": 1,
"flags": 2,
"type": 1,
"granularity_bits": 15,
"name_size": 8,
"extra_data_size": 0,
"bitmap_table": [
{
"type": "serialized",
"offset": 655360
},
...

Suggested-by: Vladimir Sementsov-Ogievskiy 
Signed-off-by: Andrey Shinkevich 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/qcow2_format.py | 17 +
 1 file changed, 17 insertions(+)

diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index 5a298b2..8adc995 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -19,6 +19,15 @@
 
 import struct
 import string
+import json
+
+
+class ComplexEncoder(json.JSONEncoder):
+def default(self, obj):
+if hasattr(obj, 'to_json'):
+return obj.to_json()
+else:
+return json.JSONEncoder.default(self, obj)
 
 
 class Qcow2Field:
@@ -110,6 +119,10 @@ class Qcow2Struct(metaclass=Qcow2StructMeta):
  for i, field in enumerate(self.fields))
 
 def dump(self, is_json=False):
+if is_json:
+print(json.dumps(self.to_json(), indent=4, cls=ComplexEncoder))
+return
+
 for f in self.fields:
 value = self.__dict__[f[2]]
 if isinstance(f[1], str):
@@ -445,6 +458,10 @@ class QcowHeader(Qcow2Struct):
 fd.write(buf)
 
 def dump_extensions(self, is_json=False):
+if is_json:
+print(json.dumps(self.extensions, indent=4, cls=ComplexEncoder))
+return
+
 for ex in self.extensions:
 print('Header extension:')
 ex.dump()
-- 
1.8.3.1




[PATCH v13 01/11] iotests: add test for QCOW2 header dump

2020-08-06 Thread Andrey Shinkevich
The simple script creates a QCOW2 image and fills it with some data.
Two bitmaps are created as well. Then the script reads the image header
with extensions from the disk by running the script qcow2.py and dumps
the information to the output. Other entities, such as snapshots, may
be added to the test later.

Suggested-by: Eric Blake 
Signed-off-by: Andrey Shinkevich 
Reviewed-by: Eric Blake 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/303 | 60 ++
 tests/qemu-iotests/303.out | 60 ++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 121 insertions(+)
 create mode 100755 tests/qemu-iotests/303
 create mode 100644 tests/qemu-iotests/303.out

diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
new file mode 100755
index 000..e9accdc
--- /dev/null
+++ b/tests/qemu-iotests/303
@@ -0,0 +1,60 @@
+#!/usr/bin/env python3
+#
+# Test for dumping of qcow2 image metadata
+#
+# Copyright (c) 2020 Virtuozzo International GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+#
+
+import iotests
+import subprocess
+from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io
+
+iotests.script_initialize(supported_fmts=['qcow2'])
+
+disk = file_path('disk')
+chunk = 1024 * 1024
+
+
+def create_bitmap(bitmap_number, disabled):
+granularity = 1 << (14 + bitmap_number)
+bitmap_name = 'bitmap-' + str(bitmap_number)
+args = ['bitmap', '--add', '-g', f'{granularity}', '-f', iotests.imgfmt,
+disk, bitmap_name]
+if disabled:
+args.append('--disable')
+
+iotests.qemu_img_pipe(*args)
+
+
+def write_to_disk(offset, size):
+write = f'write {offset} {size}'
+log(qemu_io('-c', write, disk), filters=[filter_qemu_io])
+
+
+def add_bitmap(num, begin, end, disabled):
+log(f'Add bitmap {num}')
+create_bitmap(num, disabled)
+for i in range(begin, end):
+write_to_disk((i) * chunk, chunk)
+log('')
+
+
+qemu_img_create('-f', iotests.imgfmt, disk, '10M')
+
+add_bitmap(1, 0, 6, False)
+add_bitmap(2, 6, 8, True)
+dump = ['qcow2.py', disk, 'dump-header']
+subprocess.run(dump)
diff --git a/tests/qemu-iotests/303.out b/tests/qemu-iotests/303.out
new file mode 100644
index 000..8d7973c
--- /dev/null
+++ b/tests/qemu-iotests/303.out
@@ -0,0 +1,60 @@
+Add bitmap 1
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 1048576
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 2097152
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 3145728
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 4194304
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 5242880
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+
+Add bitmap 2
+wrote 1048576/1048576 bytes at offset 6291456
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 7340032
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+
+magic 0x514649fb
+version   3
+backing_file_offset   0x0
+backing_file_size 0x0
+cluster_bits  16
+size  10485760
+crypt_method  0
+l1_size   1
+l1_table_offset   0x3
+refcount_table_offset 0x1
+refcount_table_clusters   1
+nb_snapshots  0
+snapshot_offset   0x0
+incompatible_features []
+compatible_features   []
+autoclear_features[0]
+refcount_order4
+header_length 112
+
+Header extension:
+magic 0x6803f857 (Feature table)
+length336
+data  
+
+Header extension:
+magic 0x23852875 (Bitmaps)
+length24
+nb_bitmaps2
+reserved320
+bitmap_directory_size 0x40
+bitmap_directory_offset   0x9d
+
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 025ed52..7e12e1f 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -309,3 +309,4 @@
 299 auto quick
 301 backing quick
 302 quick
+303 rw quick
-- 

[PATCH v13 07/11] qcow2_format.py: Dump bitmap table serialized entries

2020-08-06 Thread Andrey Shinkevich
Add bitmap table information to the QCOW2 metadata dump.

Bitmap name   bitmap-1
...
Bitmap table   typesize offset
0  serialized  6553610092544
1  all-zeroes  00
2  all-zeroes  00

Signed-off-by: Andrey Shinkevich 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/303.out |  4 +++
 tests/qemu-iotests/qcow2_format.py | 50 ++
 2 files changed, 54 insertions(+)

diff --git a/tests/qemu-iotests/303.out b/tests/qemu-iotests/303.out
index 038ba93..70828e0 100644
--- a/tests/qemu-iotests/303.out
+++ b/tests/qemu-iotests/303.out
@@ -66,6 +66,8 @@ type  1
 granularity_bits  15
 name_size 8
 extra_data_size   0
+Bitmap table   typesize offset
+0  serialized  6553610092544
 
 Bitmap name   bitmap-2
 bitmap_table_offset   0x9c
@@ -75,4 +77,6 @@ type  1
 granularity_bits  16
 name_size 8
 extra_data_size   0
+Bitmap table   typesize offset
+0  all-zeroes  00
 
diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index ca0d350..574249b 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -175,6 +175,10 @@ class Qcow2BitmapDirEntry(Qcow2Struct):
 entry_raw_size = self.bitmap_dir_entry_raw_size()
 padding = ((entry_raw_size + 7) & ~7) - entry_raw_size
 fd.seek(padding, 1)
+self.bitmap_table = Qcow2BitmapTable(fd=fd,
+ offset=self.bitmap_table_offset,
+ nb_entries=self.bitmap_table_size,
+ cluster_size=self.cluster_size)
 
 def bitmap_dir_entry_raw_size(self):
 return struct.calcsize(self.fmt) + self.name_size + \
@@ -183,6 +187,52 @@ class Qcow2BitmapDirEntry(Qcow2Struct):
 def dump(self):
 print(f'{"Bitmap name":<25} {self.name}')
 super(Qcow2BitmapDirEntry, self).dump()
+self.bitmap_table.dump()
+
+
+class Qcow2BitmapTableEntry(Qcow2Struct):
+
+fields = (
+('u64',  '{}', 'entry'),
+)
+
+BME_TABLE_ENTRY_RESERVED_MASK = 0xff0001fe
+BME_TABLE_ENTRY_OFFSET_MASK = 0x00fffe00
+BME_TABLE_ENTRY_FLAG_ALL_ONES = 1
+
+def __init__(self, fd):
+super().__init__(fd=fd)
+self.reserved = self.entry & self.BME_TABLE_ENTRY_RESERVED_MASK
+self.offset = self.entry & self.BME_TABLE_ENTRY_OFFSET_MASK
+if self.offset:
+if self.entry & self.BME_TABLE_ENTRY_FLAG_ALL_ONES:
+self.type = 'invalid'
+else:
+self.type = 'serialized'
+elif self.entry & self.BME_TABLE_ENTRY_FLAG_ALL_ONES:
+self.type = 'all-ones'
+else:
+self.type = 'all-zeroes'
+
+
+class Qcow2BitmapTable:
+
+def __init__(self, fd, offset, nb_entries, cluster_size):
+self.cluster_size = cluster_size
+position = fd.tell()
+fd.seek(offset)
+self.entries = [Qcow2BitmapTableEntry(fd) for _ in range(nb_entries)]
+fd.seek(position)
+
+def dump(self):
+bitmap_table = enumerate(self.entries)
+print(f'{"Bitmap table":<14} {"type":<15} {"size":<12} {"offset"}')
+for i, entry in bitmap_table:
+if entry.type == 'serialized':
+size = self.cluster_size
+else:
+size = 0
+print(f'{i:<14} {entry.type:<15} {size:<12} {entry.offset}')
 
 
 QCOW2_EXT_MAGIC_BITMAPS = 0x23852875
-- 
1.8.3.1




[PATCH v13 00/11] iotests: Dump QCOW2 dirty bitmaps metadata

2020-08-06 Thread Andrey Shinkevich
Add dirty bitmap information to QCOW2 metadata dump in the qcow2_format.py.

v13:
  01: Bitmaps are added without launching VM (suggested by Eric).
  The code amendments suggested by Vladimir.
  07: Bitmap table entry size zeroed up for all types but serialized.
  09: The extra dict variables removed. to_dict() renamed to to_json().
  The to_json() added to the class Qcow2BitmapTable. (By Vladimir).


Andrey Shinkevich (11):
  iotests: add test for QCOW2 header dump
  qcow2_format.py: make printable data an extension class member
  qcow2_format.py: change Qcow2BitmapExt initialization method
  qcow2_format.py: dump bitmap flags in human readable way.
  qcow2_format.py: Dump bitmap directory information
  qcow2_format.py: pass cluster size to substructures
  qcow2_format.py: Dump bitmap table serialized entries
  qcow2.py: Introduce '-j' key to dump in JSON format
  qcow2_format.py: collect fields to dump in JSON format
  qcow2_format.py: support dumping metadata in JSON format
  iotests: dump QCOW2 header in JSON in #303

 tests/qemu-iotests/303 |  63 +++
 tests/qemu-iotests/303.out | 158 +++
 tests/qemu-iotests/group   |   1 +
 tests/qemu-iotests/qcow2.py|  18 +++-
 tests/qemu-iotests/qcow2_format.py | 215 ++---
 5 files changed, 434 insertions(+), 21 deletions(-)
 create mode 100755 tests/qemu-iotests/303
 create mode 100644 tests/qemu-iotests/303.out

-- 
1.8.3.1




[PATCH v13 02/11] qcow2_format.py: make printable data an extension class member

2020-08-06 Thread Andrey Shinkevich
Let us differ binary data type from string one for the extension data
variable and keep the string as the QcowHeaderExtension class member.

Signed-off-by: Andrey Shinkevich 
Reviewed-by: Eric Blake 
Reviewed-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/qcow2_format.py | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index cc432e7..2f3681b 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -165,6 +165,13 @@ class QcowHeaderExtension(Qcow2Struct):
 self.data = fd.read(padded)
 assert self.data is not None
 
+data_str = self.data[:self.length]
+if all(c in string.printable.encode('ascii') for c in data_str):
+data_str = f"'{ data_str.decode('ascii') }'"
+else:
+data_str = ''
+self.data_str = data_str
+
 if self.magic == QCOW2_EXT_MAGIC_BITMAPS:
 self.obj = Qcow2BitmapExt(data=self.data)
 else:
@@ -174,12 +181,7 @@ class QcowHeaderExtension(Qcow2Struct):
 super().dump()
 
 if self.obj is None:
-data = self.data[:self.length]
-if all(c in string.printable.encode('ascii') for c in data):
-data = f"'{ data.decode('ascii') }'"
-else:
-data = ''
-print(f'{"data":<25} {data}')
+print(f'{"data":<25} {self.data_str}')
 else:
 self.obj.dump()
 
-- 
1.8.3.1




Acceptance Test BootLinuxAarch64.test_virt_tcg execution times

2020-08-06 Thread Cleber Rosa
TL;DR: This is a followup from an IRC chat about the
tests/acceptance/boot_linux.py:BootLinuxAarch64.test_virt_tcg test
taking many orders of magnitute longer than other acceptance (and even
similar boot) tests.  I could not find an easy way for this specific
test (aarch64+tcg) to have a significant execution time improvement.
The best solution may be to filter out tests that are known to be
slow, and create a specific "test job" that includes them.

Fisrt, if it's not clear, this specific test runs QEMU with TCG and
boots a Fedora 31 "cloud image" and waits until the cloud-init agent
notifies the test that the boot is over.

Out of the four archtiectures tested with the same approach under
"tests/acceptance/boot_linux.py", aarch64 was special, in the sense
that many Linux "cloud images" got stuck very late in the boot
process.  What seemed to be a disk activity within the guest that
seemed to make the kernel drain its random number sources if my memory
serves me right.  Giving the machine a RNG device fixed it.  This can
still be verified Today if you comment the virtio-rng lines in the
aarch64 test.

So, even with the RNG device and the boot process not getting stuck, a
lot of the test time is spent with QEMU actively using CPU time
produced by the guest boot process.  This may or may not be the cause
for the slowness.

One approach to have a shorter test time, would be to reduce the
things that happen during the guest boot process.  Choosing a minimal
guest, such as CirrOS, would be an example of such a solution, but:

* With less things happening during the guest boot, less things
  get tested within QEMU;

* CirrOS can not make use of the same boot cloud-init configuration
  and boot verification the test currently uses;

So that leaves other non-minimal Linux "cloud images" as options.  But
still, the following things are required or nice to have:

* Support for cloud-init;

* Support for as many as possible architectures;

* Wide user base;

* Be thoroughly tested with this "boot_linux.py" test

So in the end, I picked Fedora 31, which was available and behaved
well for four different architectures with and without KVM. Today, I
verified if switching distros would provide an "easy fix", but the
results were negative.  Any ideas on how to improve the test execution
times are appreciated.

For the record, one of the ways we're trying to improve the overall
test experience is to allow tests to run in parallel (expected to be
fully supported on the upcoming version 81.0).

For those interested, these are the numbers I got, and how I tested
with other distros.  I'm using QEMU e1d322c405 with a vanilla
configure under a x86_64 Fedora 32 host.

Fedora 31 (baseline):


  $ make check-venv
  $ ./tests/venv/bin/avocado run -t arch:aarch64,accel:tcg --keep-tmp on -- 
tests/acceptance/boot_linux.py{}
  JOB ID : 14802f9d5016a44d2937ed7b1fec63b2eaa06e89
  JOB LOG: 
/home/cleber/avocado/job-results/job-2020-08-06T13.19-14802f9/job.log
   (1/5) tests/acceptance/boot_linux.py:BootLinuxAarch64.test_virt_tcg: PASS 
(153.12 s)
   (2/5) tests/acceptance/boot_linux.py:BootLinuxAarch64.test_virt_tcg: PASS 
(149.57 s)
   (3/5) tests/acceptance/boot_linux.py:BootLinuxAarch64.test_virt_tcg: PASS 
(154.45 s)
   (4/5) tests/acceptance/boot_linux.py:BootLinuxAarch64.test_virt_tcg: PASS 
(148.97 s)
   (5/5) tests/acceptance/boot_linux.py:BootLinuxAarch64.test_virt_tcg: PASS 
(150.70 s)
  RESULTS: PASS 5 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | 
CANCEL 0
  JOB TIME   : 757.50 s

Fedora 32:
==

1. Tweak version and image hash:

---
diff --git a/tests/acceptance/boot_linux.py b/tests/acceptance/boot_linux.py
index 0055dc7cee..44c62bd4a2 100644
--- a/tests/acceptance/boot_linux.py
+++ b/tests/acceptance/boot_linux.py
@@ -48,7 +48,7 @@ class BootLinuxBase(Test):
 image_arch = 'ppc64le'
 try:
 boot = vmimage.get(
-'fedora', arch=image_arch, version='31',
+'fedora', arch=image_arch, version='32',
 checksum=self.chksum,
 algorithm='sha256',
 cache_dir=self.cache_dirs[0],
@@ -160,7 +160,7 @@ class BootLinuxAarch64(BootLinux):
 :avocado: tags=machine:gic-version=2
 """
 
-chksum = '1e18d9c0cf734940c4b5d5ec592facaed2af0ad0329383d5639c997fdf16fe49'
+chksum = 'b367755c664a2d7a26955bbfff985855adfa2ca15e908baf15b4b176d68d3967'
 
 def add_common_args(self):
 self.vm.add_args('-bios',
---

2. Download the image before the test:

  $ ./tests/venv/bin/avocado vmimage get --distro=fedora --arch aarch64 
--distro-version=32
  The image was downloaded:
  Provider Version Architecture File
  fedora   32  aarch64  
/tmp/data/cache/by_location/7049001631a4b2eabf5766cc110e66d486e09821/Fedora-Cloud-Base-32-1.6.aarch64.qcow2

3. Run the tests:

  $ ./tests/venv/bin/avocado run -t arch:aarch64,accel:tcg --keep-tmp on -- 

[PATCH 139/143] meson: convert sample plugins

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure|  4 
 tests/Makefile.include   |  9 -
 tests/meson.build|  3 +++
 tests/plugin/Makefile| 46 --
 tests/plugin/meson.build |  7 +++
 5 files changed, 10 insertions(+), 59 deletions(-)
 delete mode 100644 tests/plugin/Makefile
 create mode 100644 tests/plugin/meson.build

diff --git a/configure b/configure
index 13b03ac..a0b51d0 100755
--- a/configure
+++ b/configure
@@ -6823,9 +6823,6 @@ echo "GIT_UPDATE=$git_update" >> $config_host_mak
 
 echo "ARCH=$ARCH" >> $config_host_mak
 
-echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
-echo "GLIB_LDFLAGS=$glib_ldflags" >> $config_host_mak
-
 if test "$default_devices" = "yes" ; then
   echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
 else
@@ -8310,7 +8307,6 @@ DIRS="$DIRS roms/seabios"
 LINKS="Makefile"
 LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
 LINKS="$LINKS tests/tcg/Makefile.target"
-LINKS="$LINKS tests/plugin/Makefile"
 LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
 LINKS="$LINKS roms/seabios/Makefile"
diff --git a/tests/Makefile.include b/tests/Makefile.include
index a1e4871..89eeeaa 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -436,15 +436,6 @@ check-speed: $(check-speed-y)
 check-report-unit.tap: $(check-unit-y)
$(call do_test_tap,$^)
 
-# Plugins
-ifeq ($(CONFIG_PLUGIN),y)
-.PHONY: plugins
-plugins:
-   $(call quiet-command,\
-   $(MAKE) $(SUBDIR_MAKEFLAGS) -C tests/plugin V="$(V)", \
-   "BUILD", "plugins")
-endif
-
 # Per guest TCG tests
 
 BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS))
diff --git a/tests/meson.build b/tests/meson.build
index f834c27..fe2c6d8 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -9,6 +9,9 @@ test('decodetree', sh,
 
 if 'CONFIG_TCG' in config_host
   subdir('fp')
+  if 'CONFIG_PLUGIN' in config_host
+subdir('plugin')
+  endif
 endif
 
 subdir('qapi-schema')
diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile
deleted file mode 100644
index e9348fd..000
--- a/tests/plugin/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# -*- Mode: makefile -*-
-#
-# This Makefile example is fairly independent from the main makefile
-# so users can take and adapt it for their build. We only really
-# include config-host.mak so we don't have to repeat probing for
-# cflags that the main configure has already done for us.
-#
-
-BUILD_DIR := $(CURDIR)/../..
-
-include $(BUILD_DIR)/config-host.mak
-
-VPATH += $(SRC_PATH)/tests/plugin
-
-NAMES :=
-NAMES += bb
-NAMES += empty
-NAMES += insn
-NAMES += mem
-NAMES += hotblocks
-NAMES += howvec
-NAMES += hotpages
-NAMES += lockstep
-
-SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
-
-# The main QEMU uses Glib extensively so it's perfectly fine to use it
-# in plugins (which many example do).
-CFLAGS = $(GLIB_CFLAGS)
-CFLAGS += -fPIC
-CFLAGS += $(if $(findstring no-psabi,$(QEMU_CFLAGS)),-Wpsabi)
-CFLAGS += -I$(SRC_PATH)/include/qemu
-
-all: $(SONAMES)
-
-%.o: %.c
-   $(CC) $(CFLAGS) -c -o $@ $<
-
-lib%.so: %.o
-   $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDLIBS)
-
-clean:
-   rm -f *.o *.so *.d
-   rm -Rf .libs
-
-.PHONY: all clean
diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build
new file mode 100644
index 000..dbbdcba
--- /dev/null
+++ b/tests/plugin/meson.build
@@ -0,0 +1,7 @@
+t = []
+foreach i : ['bb', 'empty', 'insn', 'mem', 'hotblocks', 'howvec', 'hotpages', 
'lockstep']
+  t += shared_module(i, files(i + '.c'),
+ include_directories: '../../include/qemu',
+ dependencies: glib)
+endforeach
+alias_target('plugins', t)
-- 
1.8.3.1





[PATCH 133/143] remove Makefile.target

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Marc-André Lureau 

Signed-off-by: Paolo Bonzini 
---
 Makefile| 53 -
 Makefile.target | 12 
 configure   |  2 --
 3 files changed, 4 insertions(+), 63 deletions(-)
 delete mode 100644 Makefile.target

diff --git a/Makefile b/Makefile
index 603869d..9a97de0 100644
--- a/Makefile
+++ b/Makefile
@@ -164,17 +164,6 @@ include $(SRC_PATH)/tests/Makefile.include
 
 all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) recurse-all modules
 
-config-host.h: config-host.h-timestamp
-config-host.h-timestamp: config-host.mak
-
-TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), 
$(TARGET_DIRS)))
-
-.PHONY: $(TARGET_DIRS_RULES)
-# The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
-# $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
-$(TARGET_DIRS_RULES): $(TARGET_DEPS)
-   $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" 
TARGET_DIR="$(dir $@)" $(notdir $@),)
-
 # LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" 
LIBFDT_lib=""
 DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
@@ -211,8 +200,6 @@ slirp/all: .git-submodule-status
CC="$(CC)" AR="$(AR)"   LD="$(LD)" RANLIB="$(RANLIB)"   \
CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
 
-$(filter %/all, $(TARGET_DIRS_RULES)):
-
 ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
 ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
 # Only keep -O and -g cflags
@@ -220,11 +207,9 @@ ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), 
$(ROM_DIRS)))
 $(ROM_DIRS_RULES):
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" 
TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
 
-.PHONY: recurse-all recurse-clean recurse-install
-recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
-recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
-recurse-install: $(addsuffix /install, $(TARGET_DIRS))
-$(addsuffix /install, $(TARGET_DIRS)): all
+.PHONY: recurse-all recurse-clean
+recurse-all: $(ROM_DIRS)
+recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
 
 ##
 
@@ -274,9 +259,6 @@ distclean: clean
$(call clean-manual,system)
$(call clean-manual,tools)
$(call clean-manual,user)
-   for d in $(TARGET_DIRS); do \
-   rm -rf $$d || exit 1 ; \
-done
rm -Rf .sdk
 
 KEYMAPS=da en-gb  et  fr fr-ch  is  lt  no  pt-br  sv \
@@ -386,8 +368,7 @@ ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 
512x512
 export DESTDIR
 install: all $(if $(BUILD_DOCS),install-doc) \
install-datadir install-localstatedir \
-   $(if $(INSTALL_BLOBS),$(edk2-decompressed)) \
-   recurse-install
+   $(if $(INSTALL_BLOBS),$(edk2-decompressed))
 ifdef CONFIG_TRACE_SYSTEMTAP
$(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
 endif
@@ -432,9 +413,6 @@ endif
set -e; for x in $(KEYMAPS); do \
$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x 
"$(DESTDIR)$(qemu_datadir)/keymaps"; \
done
-   for d in $(TARGET_DIRS); do \
-   $(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
-done
 
 # documentation
 MAKEINFO=makeinfo
@@ -549,20 +527,6 @@ docs/interop/qemu-qmp-ref.dvi 
docs/interop/qemu-qmp-ref.html \
 
 $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
 
-# Reports/Analysis
-
-%/coverage-report.html:
-   @mkdir -p $*
-   $(call quiet-command,\
-   gcovr -r $(SRC_PATH) \
-   $(foreach t, $(TARGET_DIRS), --object-directory 
$(BUILD_DIR)/$(t)) \
---object-directory $(BUILD_DIR) \
-   -p --html --html-details -o $@, \
-   "GEN", "coverage-report.html")
-
-.PHONY: coverage-report
-coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
-
 ifdef CONFIG_WIN32
 
 INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
@@ -650,15 +614,6 @@ endif
$(call print-help,cscope,Generate cscope index)
$(call print-help,sparse,Run sparse on the QEMU source)
@echo  ''
-   @$(if $(TARGET_DIRS), \
-   echo 'Architecture specific targets:'; \
-   $(foreach t, $(TARGET_DIRS), \
-   $(call print-help-run,$(t)/all,Build for $(t)); \
-   $(if $(CONFIG_FUZZ), \
-   $(if $(findstring softmmu,$(t)), \
-   $(call print-help-run,$(t)/fuzz,Build fuzzer 
for $(t)); \
-   ))) \
-   echo '')
@echo  'Cleaning targets:'
$(call print-help,clean,Remove most generated files but keep the config)
$(call print-help,distclean,Remove all generated files)
diff --git a/Makefile.target b/Makefile.target
deleted file mode 100644
index 

[PATCH 142/143] meson: convert po/

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile   |  5 +---
 configure  |  2 +-
 meson.build|  3 +++
 po/LINGUAS |  7 ++
 po/Makefile| 52 -
 po/POTFILES|  1 +
 po/meson.build |  5 
 po/messages.po | 74 --
 8 files changed, 18 insertions(+), 131 deletions(-)
 create mode 100644 po/LINGUAS
 delete mode 100644 po/Makefile
 create mode 100644 po/POTFILES
 create mode 100644 po/meson.build
 delete mode 100644 po/messages.po

diff --git a/Makefile b/Makefile
index bab1021..a0867c5 100644
--- a/Makefile
+++ b/Makefile
@@ -201,7 +201,7 @@ distclean: clean
rm -f config-host.mak config-host.h*
rm -f tests/tcg/config-*.mak
rm -f config-all-disas.mak config.status
-   rm -f po/*.mo tests/qemu-iotests/common.env
+   rm -f tests/qemu-iotests/common.env
rm -f roms/seabios/config.mak roms/vgabios/config.mak
rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
rm -f config.log
@@ -297,9 +297,6 @@ endif
mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
$(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
"$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
-ifdef CONFIG_GTK
-   $(MAKE) -C po $@
-endif
$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
set -e; for x in $(KEYMAPS); do \
$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x 
"$(DESTDIR)$(qemu_datadir)/keymaps"; \
diff --git a/configure b/configure
index cd1ab0c..5ad0f4c 100755
--- a/configure
+++ b/configure
@@ -8081,7 +8081,7 @@ DIRS="$DIRS docs docs/interop fsdev scsi"
 DIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
 DIRS="$DIRS roms/seabios"
 LINKS="Makefile"
-LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
+LINKS="$LINKS tests/tcg/lm32/Makefile"
 LINKS="$LINKS tests/tcg/Makefile.target"
 LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
diff --git a/meson.build b/meson.build
index 913f22d..e9fd237 100644
--- a/meson.build
+++ b/meson.build
@@ -1091,6 +1091,9 @@ subdir('tools')
 subdir('pc-bios')
 subdir('tests')
 subdir('docs')
+if 'CONFIG_GTK' in config_host
+  subdir('po')
+endif
 
 if build_docs
   makeinfo = find_program('makeinfo', required: build_docs)
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644
index 000..054930d
--- /dev/null
+++ b/po/LINGUAS
@@ -0,0 +1,7 @@
+bg
+de_DE
+fr_FR
+hu
+it
+tr
+zh_CN
diff --git a/po/Makefile b/po/Makefile
deleted file mode 100644
index c041f4c..000
--- a/po/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-# This makefile is very special as it's meant to build as part of the build
-# process and also within the source tree to update the translation files.
-
-# Set SRC_PATH for in-tree builds without configuration.
-SRC_PATH=..
-
-# The default target must come before any include statements.
-all:
-
-.PHONY:all build clean install update
-
-%.mo: %.po
-   $(call quiet-command, msgfmt -o $@ $<,"GEN","$@")
-
--include ../config-host.mak
-include $(SRC_PATH)/rules.mak
-
-PO_PATH=$(SRC_PATH)/po
-
-VERSION=$(shell cat $(SRC_PATH)/VERSION)
-SRCS=$(filter-out $(PO_PATH)/messages.po,$(wildcard $(PO_PATH)/*.po))
-OBJS=$(patsubst $(PO_PATH)/%.po,%.mo,$(SRCS))
-
-vpath %.po $(PO_PATH)
-
-all:
-   @echo "Use 'make update' to update translation files or use 'make 
build'"
-   @echo "or 'make install' to build and install the translation files."
-
-update: $(SRCS)
-
-build: $(OBJS)
-
-clean:
-   rm -f $(OBJS)
-
-install: $(OBJS)
-   for obj in $(OBJS); do \
-   base=$$(basename $$obj .mo); \
-   $(INSTALL) -d $(DESTDIR)$(prefix)/share/locale/$$base/LC_MESSAGES; \
-   $(INSTALL) -m644 $$obj 
$(DESTDIR)$(prefix)/share/locale/$$base/LC_MESSAGES/qemu.mo; \
-   done
-
-$(PO_PATH)/messages.po: $(SRC_PATH)/ui/gtk.c
-   $(call quiet-command, ( cd $(SRC_PATH) && \
-  xgettext -o - --from-code=UTF-8 --foreign-user --no-location \
-   --package-name=QEMU --package-version=$(VERSION) \
-   --msgid-bugs-address=qemu-devel@nongnu.org -k_ -C ui/gtk.c | \
- sed -e s/CHARSET/UTF-8/) >$@,"GEN","$@")
-
-$(PO_PATH)/%.po: $(PO_PATH)/messages.po
-   $(call quiet-command, msgmerge -q $@ $< > $@.bak && mv $@.bak 
$@,"GEN","$@")
diff --git a/po/POTFILES b/po/POTFILES
new file mode 100644
index 000..d34d5ed
--- /dev/null
+++ b/po/POTFILES
@@ -0,0 +1 @@
+ui/gtk.c
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 000..b99d8e2
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,5 @@
+i18n = import('i18n')
+
+i18n.gettext(meson.project_name(),
+ args: '--msgid-bugs-address=qemu-devel@nongnu.org',
+ preset: 'glib')
diff --git a/po/messages.po b/po/messages.po
deleted file mode 100644
index 065bd45..000
--- a/po/messages.po
+++ /dev/null
@@ -1,74 +0,0 @@
-# SOME DESCRIPTIVE TITLE.

[PATCH 131/143] meson: convert systemtap files

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile.target   | 85 ++-
 meson.build   | 26 +
 rules.mak |  3 --
 trace/meson.build | 14 -
 4 files changed, 35 insertions(+), 93 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 8ee4c78..a07149c 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -6,88 +6,7 @@ include ../config-host.mak
 include config-target.mak
 include $(SRC_PATH)/rules.mak
 
-$(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
-
-ifdef CONFIG_USER_ONLY
-# user emulator name
-QEMU_PROG=qemu-$(TARGET_NAME)
-else
-# system emulator name
-QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
-endif
-
-STPFILES=
-
-ifdef CONFIG_TRACE_SYSTEMTAP
-stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp 
$(QEMU_PROG)-log.stp
-
-ifdef CONFIG_USER_ONLY
-TARGET_TYPE=user
-else
-TARGET_TYPE=system
-endif
-
-tracetool-y = $(SRC_PATH)/scripts/tracetool.py
-tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
-
-$(QEMU_PROG).stp-installed: $(BUILD_DIR)/trace/trace-events-all $(tracetool-y)
-   $(call quiet-command,$(TRACETOOL) \
-   --group=all \
-   --format=stap \
-   --backends=$(TRACE_BACKENDS) \
-   --binary=$(bindir)/$(QEMU_PROG) \
-   --target-name=$(TARGET_NAME) \
-   --target-type=$(TARGET_TYPE) \
-   $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG).stp-installed")
-
-$(QEMU_PROG).stp: $(BUILD_DIR)/trace/trace-events-all $(tracetool-y)
-   $(call quiet-command,$(TRACETOOL) \
-   --group=all \
-   --format=stap \
-   --backends=$(TRACE_BACKENDS) \
-   --binary=$(realpath .)/$(QEMU_PROG) \
-   --target-name=$(TARGET_NAME) \
-   --target-type=$(TARGET_TYPE) \
-   $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG).stp")
-
-$(QEMU_PROG)-simpletrace.stp: $(BUILD_DIR)/trace/trace-events-all 
$(tracetool-y)
-   $(call quiet-command,$(TRACETOOL) \
-   --group=all \
-   --format=simpletrace-stap \
-   --backends=$(TRACE_BACKENDS) \
-   --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
-   $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG)-simpletrace.stp")
-
-$(QEMU_PROG)-log.stp: $(BUILD_DIR)/trace/trace-events-all $(tracetool-y)
-   $(call quiet-command,$(TRACETOOL) \
-   --group=all \
-   --format=log-stap \
-   --backends=$(TRACE_BACKENDS) \
-   --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
-   $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG)-log.stp")
-
-else
-stap:
-endif
-.PHONY: stap
-
-all: stap
-
-clean:
-   rm -f *.a *~
-   rm -f $(shell find . -name '*.[od]')
-   rm -f hmp-commands.h gdbstub-xml.c
-   rm -f trace/generated-helpers.c trace/generated-helpers.c-timestamp
-ifdef CONFIG_TRACE_SYSTEMTAP
-   rm -f *.stp
-endif
-
+all:
 install: all
-ifdef CONFIG_TRACE_SYSTEMTAP
-   $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
-   $(INSTALL_DATA) $(QEMU_PROG).stp-installed 
"$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
-   $(INSTALL_DATA) $(QEMU_PROG)-simpletrace.stp 
"$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-simpletrace.stp"
-   $(INSTALL_DATA) $(QEMU_PROG)-log.stp 
"$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-log.stp"
-endif
-
+   
 .PHONY: all clean install
diff --git a/meson.build b/meson.build
index 5052165..44b2645 100644
--- a/meson.build
+++ b/meson.build
@@ -797,6 +797,7 @@ common_all = static_library('common',
 name_suffix: 'fa')
 
 feature_to_c = find_program('scripts/feature_to_c.sh')
+tracetool = find_program('scripts/tracetool.py')
 
 emulators = []
 foreach target : target_dirs
@@ -939,6 +940,31 @@ foreach target : target_dirs
link_depends: [block_syms, qemu_syms] + exe.get('link_depends', 
[]),
link_args: link_args,
gui_app: exe['gui'])
+
+if 'CONFIG_TRACE_SYSTEMTAP' in config_host
+  foreach stp: [
+{'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() 
/ exe_name, 'install': false},
+{'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / 
get_option('bindir') / exe_name, 'install': true},
+{'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 
'install': true},
+{'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
+  ]
+custom_target(exe_name + stp['ext'],
+  input: trace_events_all,
+  output: exe_name + stp['ext'],
+  capture: true,
+  install: stp['install'],
+  install_dir: config_host['qemu_datadir'] / 
'../systemtap/tapset',
+

[PATCH 134/143] meson: sphinx-build

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile   | 142 +++--
 configure  |   1 -
 docs/index.html.in |   4 +-
 docs/meson.build   |  68 +
 meson.build|   2 +
 rules.mak  |  48 --
 6 files changed, 79 insertions(+), 186 deletions(-)
 create mode 100644 docs/meson.build

diff --git a/Makefile b/Makefile
index 9a97de0..d0d0294 100644
--- a/Makefile
+++ b/Makefile
@@ -120,36 +120,9 @@ $(call set-vpath, $(SRC_PATH))
 
 LIBS+=-lz $(LIBS_TOOLS)
 
-# Sphinx does not allow building manuals into the same directory as
-# the source files, so if we're doing an in-tree QEMU build we must
-# build the manuals into a subdirectory (and then install them from
-# there for 'make install'). For an out-of-tree build we can just
-# use the docs/ subdirectory in the build tree as normal.
-ifeq ($(realpath $(SRC_PATH)),$(realpath .))
-MANUAL_BUILDDIR := docs/built
-else
-MANUAL_BUILDDIR := docs
-endif
-
 ifdef BUILD_DOCS
-DOCS+=$(MANUAL_BUILDDIR)/system/qemu.1
-DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-img.1
-DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-nbd.8
-DOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga.8
-ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
-DOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
-endif
-DOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
 DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt 
docs/interop/qemu-qmp-ref.7
 DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt 
docs/interop/qemu-ga-ref.7
-DOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
-DOCS+=$(MANUAL_BUILDDIR)/index.html
-ifdef CONFIG_VIRTFS
-DOCS+=$(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1
-endif
-ifdef CONFIG_TRACE_SYSTEMTAP
-DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1
-endif
 else
 DOCS=
 endif
@@ -232,11 +205,6 @@ dist: qemu-$(VERSION).tar.bz2
 qemu-%.tar.bz2:
$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst 
qemu-%.tar.bz2,%,$@)"
 
-define clean-manual =
-rm -rf $(MANUAL_BUILDDIR)/$1/_static
-rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js 
$(MANUAL_BUILDDIR)/$1/*.html
-endef
-
 distclean: clean
rm -f config-host.mak config-host.h* $(DOCS)
rm -f tests/tcg/config-*.mak
@@ -252,13 +220,6 @@ distclean: clean
rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
-   rm -rf .doctrees
-   $(call clean-manual,devel)
-   $(call clean-manual,interop)
-   $(call clean-manual,specs)
-   $(call clean-manual,system)
-   $(call clean-manual,tools)
-   $(call clean-manual,user)
rm -Rf .sdk
 
 KEYMAPS=da en-gb  et  fr fr-ch  is  lt  no  pt-br  sv \
@@ -297,28 +258,8 @@ BLOBS=
 DESCS=
 endif
 
-# Note that we manually filter-out the non-Sphinx documentation which
-# is currently built into the docs/interop directory in the build tree,
-# and also any sphinx-built manpages.
-define install-manual =
-for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) 
"$(DESTDIR)$(qemu_docdir)/$$d"; done
-for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name 
'*.[0-9]' -o -name 'qemu-*-qapi.*' -o -name 'qemu-*-ref.*' ')' ); do 
$(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done
-endef
-
-# Note that we deliberately do not install the "devel" manual: it is
-# for QEMU developers, and not interesting to our users.
-.PHONY: install-sphinxdocs
-install-sphinxdocs: sphinxdocs
-   $(call install-manual,interop)
-   $(call install-manual,specs)
-   $(call install-manual,system)
-   $(call install-manual,tools)
-   $(call install-manual,user)
-
-install-doc: $(DOCS) install-sphinxdocs
+install-doc: $(DOCS)
$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
-   $(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
-   $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
$(INSTALL_DATA) docs/interop/qemu-qmp-ref.html 
"$(DESTDIR)$(qemu_docdir)/interop"
$(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt 
"$(DESTDIR)$(qemu_docdir)/interop"
 ifdef CONFIG_POSIX
@@ -326,19 +267,7 @@ ifdef CONFIG_POSIX
$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 
"$(DESTDIR)$(mandir)/man1"
$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
$(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
-   $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 
"$(DESTDIR)$(mandir)/man7"
-   $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 
"$(DESTDIR)$(mandir)/man7"
-ifeq ($(CONFIG_TOOLS),y)
-   $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 
"$(DESTDIR)$(mandir)/man1"
-   $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
-   $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 

[PATCH 140/143] meson: move SDL and SDL-image detection to meson

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 chardev/meson.build |   2 +-
 configure   | 142 +++-
 meson.build |  24 ++---
 meson_options.txt   |   2 +
 ui/meson.build  |   4 +-
 5 files changed, 30 insertions(+), 144 deletions(-)
 create mode 100644 meson_options.txt

diff --git a/chardev/meson.build b/chardev/meson.build
index 2122505..a0aaafa 100644
--- a/chardev/meson.build
+++ b/chardev/meson.build
@@ -36,7 +36,7 @@ softmmu_ss.add(when: ['CONFIG_SPICE', spice], if_true: 
files('spice.c'))
 
 chardev_modules = []
 
-if config_host.has_key('CONFIG_BRLAPI') and config_host.has_key('CONFIG_SDL')
+if config_host.has_key('CONFIG_BRLAPI') and sdl.found()
   chardev_modules += [['baum', files('baum.c'), [sdl, brlapi]]]
 endif
 
diff --git a/configure b/configure
index a0b51d0..288a75f 100755
--- a/configure
+++ b/configure
@@ -377,8 +377,8 @@ curses=""
 docs=""
 fdt=""
 netmap="no"
-sdl=""
-sdl_image=""
+sdl="auto"
+sdl_image="auto"
 virtfs=""
 mpath=""
 vnc="yes"
@@ -1092,13 +1092,13 @@ for opt do
 # configure to be used by RPM and similar macros that set
 # lots of directory switches by default.
   ;;
-  --disable-sdl) sdl="no"
+  --disable-sdl) sdl="disabled"
   ;;
-  --enable-sdl) sdl="yes"
+  --enable-sdl) sdl="enabled"
   ;;
-  --disable-sdl-image) sdl_image="no"
+  --disable-sdl-image) sdl_image="disabled"
   ;;
-  --enable-sdl-image) sdl_image="yes"
+  --enable-sdl-image) sdl_image="enabled"
   ;;
   --disable-qom-cast-debug) qom_cast_debug="no"
   ;;
@@ -2368,7 +2368,7 @@ if test "$cocoa" = "yes"; then
 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
 fi
 gtk=no
-sdl=no
+sdl=disabled
 fi
 
 # Some versions of Mac OS X incorrectly define SIZE_MAX
@@ -3274,125 +3274,6 @@ if test "$vte" != "no"; then
 fi
 
 ##
-# SDL probe
-
-# Look for sdl configuration program (pkg-config or sdl2-config).  Try
-# sdl2-config even without cross prefix, and favour pkg-config over 
sdl2-config.
-
-sdl_probe ()
-{
-  if $pkg_config sdl2 --exists; then
-sdlconfig="$pkg_config sdl2"
-sdlversion=$($sdlconfig --modversion 2>/dev/null)
-  elif has "$sdl2_config"; then
-sdlconfig="$sdl2_config"
-sdlversion=$($sdlconfig --version)
-  else
-if test "$sdl" = "yes" ; then
-  feature_not_found "sdl" "Install SDL2-devel"
-fi
-sdl=no
-# no need to do the rest
-return
-  fi
-  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl2-config; 
then
-echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
-  fi
-
-  cat > $TMPC << EOF
-#include 
-#undef main /* We don't want SDL to override our main() */
-int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
-EOF
-  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
-  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
-  if test "$static" = "yes" ; then
-if $pkg_config sdl2 --exists; then
-  sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
-else
-  sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
-fi
-  else
-sdl_libs=$($sdlconfig --libs 2>/dev/null)
-  fi
-  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
-sdl=yes
-
-# static link with sdl ? (note: sdl.pc's --static --libs is broken)
-if test "$sdl" = "yes" && test "$static" = "yes" ; then
-  if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
- sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
- sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
-  fi
-  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
-   :
-  else
-sdl=no
-  fi
-fi # static link
-  else # sdl not found
-if test "$sdl" = "yes" ; then
-  feature_not_found "sdl" "Install SDL2 devel"
-fi
-sdl=no
-  fi # sdl compile test
-}
-
-sdl_image_probe ()
-{
-if test "$sdl_image" != "no" ; then
-if $pkg_config SDL2_image --exists; then
-if test "$static" = "yes"; then
-sdl_image_libs=$($pkg_config SDL2_image --libs --static 
2>/dev/null)
-else
-sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
-fi
-sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
-sdl_image=yes
-
-sdl_cflags="$sdl_cflags $sdl_image_cflags"
-sdl_libs="$sdl_libs $sdl_image_libs"
-else
-if test "$sdl_image" = "yes" ; then
-feature_not_found "sdl_image" "Install SDL Image devel"
-else
-sdl_image=no
-fi
-fi
-fi
-}
-
-if test "$sdl" != "no" ; then
-  sdl_probe
-fi
-
-if test "$sdl" = "yes" ; then
-  sdl_image_probe
-else
-  if test "$sdl_image" = "yes"; then
-echo "warning: SDL Image requested, but SDL is not available, disabling"
-  fi
-  sdl_image=no
-fi
-
-if test "$sdl" = "yes" ; then
-  cat > $TMPC <
-#if 

[PATCH 143/143] meson: update build-system documentation

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 docs/devel/build-system.txt | 373 ++--
 1 file changed, 185 insertions(+), 188 deletions(-)

diff --git a/docs/devel/build-system.txt b/docs/devel/build-system.txt
index fea67b2..fb62cb2 100644
--- a/docs/devel/build-system.txt
+++ b/docs/devel/build-system.txt
@@ -22,6 +22,30 @@ silent while it is checking for features. It will only 
display output
 when an error occurs, or to show the final feature enablement summary
 on completion.
 
+Because QEMU uses the Meson build system under the hood, only VPATH
+builds are supported.  There are two general ways to invoke configure &
+perform a build:
+
+ - VPATH, build artifacts outside of QEMU source tree entirely
+
+ cd ../
+ mkdir build
+ cd build
+ ../qemu/configure
+ make
+
+ - VPATH, build artifacts in a subdir of QEMU source tree
+
+ mkdir build
+ cd build
+ ../configure
+ make
+
+For now, checks on the compilation environment are found in configure
+rather than meson.build, though this is expected to change.  The command
+line is parsed in the configure script and, whenever needed, converted
+into the appropriate options to Meson.
+
 Adding new checks to the configure script usually comprises the
 following tasks:
 
@@ -164,145 +188,161 @@ developers in checking for system features:
then --static will be automatically added to $ARGS
 
 
-Stage 2: makefiles
-==
-
-The use of GNU make is required with the QEMU build system.
-
-Although the source code is spread across multiple subdirectories, the
-build system should be considered largely non-recursive in nature, in
-contrast to common practices seen with automake. There is some recursive
-invocation of make, but this is related to the things being built,
-rather than the source directory structure.
-
-QEMU currently supports both VPATH and non-VPATH builds, so there are
-three general ways to invoke configure & perform a build.
+Stage 2: Meson
+==
 
- - VPATH, build artifacts outside of QEMU source tree entirely
+The Meson build system is currently used to describe the build
+process for:
 
- cd ../
- mkdir build
- cd build
- ../qemu/configure
- make
-
- - VPATH, build artifacts in a subdir of QEMU source tree
+1) executables, which include:
+   - Tools - qemu-img, qemu-nbd, qga (guest agent), etc
+   - System emulators - qemu-system-$ARCH
+   - Userspace emulators - qemu-$ARCH
+   - Some (but not all) unit tests
 
- mkdir build
- cd build
- ../configure
- make
+2) documentation
 
- - non-VPATH, build artifacts everywhere
+3) ROMs, which can be either installed as binary blobs or compiled
 
- ./configure
- make
+4) other data files, such as icons or desktop files
 
-The QEMU maintainers generally recommend that a VPATH build is used by
-developers. Patches to QEMU are expected to ensure VPATH build still
-works.
+The source code is highly modularized, split across many files to
+facilitate building of all of these components with as little duplicated
+compilation as possible. The Meson "sourceset" functionality is used
+to list the files and their dependency on various configuration  
+symbols.
 
+Various subsystems that are common to both tools and emulators have
+their own sourceset, for example block_ss for the block device subsystem,
+chardev_ss for the character device subsystem, etc.  These sourcesets
+are then turned into static libraries as follows:
 
-Module structure
-
+libchardev = static_library('chardev', chardev_ss.sources(),
+name_suffix: 'fa',
+build_by_default: false)
 
-There are a number of key outputs of the QEMU build system:
+chardev = declare_dependency(link_whole: libchardev)
 
- - Tools - qemu-img, qemu-nbd, qga (guest agent), etc
- - System emulators - qemu-system-$ARCH
- - Userspace emulators - qemu-$ARCH
- - Unit tests
+The special ".fa" suffix is needed as long as unit tests are built with
+the older Makefile infrastructure, and will go away later.
 
-The source code is highly modularized, split across many files to
-facilitate building of all of these components with as little duplicated
-compilation as possible. There can be considered to be two distinct
-groups of files, those which are independent of the QEMU emulation
-target and those which are dependent on the QEMU emulation target.
+Files linked into emulator targets there can be split into two distinct groups
+of files, those which are independent of the QEMU emulation target and
+those which are dependent on the QEMU emulation target.
 
 In the target-independent set lives various general purpose helper code,
 such as error handling infrastructure, standard data structures,
 platform portability wrapper functions, etc. This code can be compiled
 once only and the .o files linked into all output binaries.
+Target-independent code lives in the 

[PATCH v13 09/11] qcow2_format.py: collect fields to dump in JSON format

2020-08-06 Thread Andrey Shinkevich
As __dict__ is being extended with class members we do not want to
print, add the to_dict() method to classes that returns a dictionary
with desired fields and their values. Extend it in subclass when
necessary to print the final dictionary in the JSON output which
follows.

Suggested-by: Vladimir Sementsov-Ogievskiy 
Signed-off-by: Andrey Shinkevich 
---
 tests/qemu-iotests/qcow2_format.py | 36 
 1 file changed, 36 insertions(+)

diff --git a/tests/qemu-iotests/qcow2_format.py 
b/tests/qemu-iotests/qcow2_format.py
index de0adcb..5a298b2 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -119,6 +119,9 @@ class Qcow2Struct(metaclass=Qcow2StructMeta):
 
 print('{:<25} {}'.format(f[2], value_str))
 
+def to_json(self):
+return dict((f[2], self.__dict__[f[2]]) for f in self.fields)
+
 
 class Qcow2BitmapExt(Qcow2Struct):
 
@@ -151,6 +154,11 @@ class Qcow2BitmapExt(Qcow2Struct):
 print()
 entry.dump()
 
+def to_json(self):
+fields_dict = super().to_json()
+fields_dict['bitmap_directory'] = self.bitmap_directory
+return fields_dict
+
 
 class Qcow2BitmapDirEntry(Qcow2Struct):
 
@@ -189,6 +197,14 @@ class Qcow2BitmapDirEntry(Qcow2Struct):
 super(Qcow2BitmapDirEntry, self).dump()
 self.bitmap_table.dump()
 
+def to_json(self):
+# Put the name ahead of the dict
+return {
+'name': self.name,
+**super().to_json(),
+'bitmap_table': self.bitmap_table
+}
+
 
 class Qcow2BitmapTableEntry(Qcow2Struct):
 
@@ -214,6 +230,10 @@ class Qcow2BitmapTableEntry(Qcow2Struct):
 else:
 self.type = 'all-zeroes'
 
+def to_json(self):
+return {'type': self.type, 'offset': self.offset,
+'reserved': self.reserved}
+
 
 class Qcow2BitmapTable:
 
@@ -234,6 +254,9 @@ class Qcow2BitmapTable:
 size = 0
 print(f'{i:<14} {entry.type:<15} {size:<12} {entry.offset}')
 
+def to_json(self):
+return self.entries
+
 
 QCOW2_EXT_MAGIC_BITMAPS = 0x23852875
 
@@ -249,6 +272,9 @@ class QcowHeaderExtension(Qcow2Struct):
 0x44415441: 'Data file'
 }
 
+def to_json(self):
+return self.mapping.get(self.value, "")
+
 fields = (
 ('u32', Magic, 'magic'),
 ('u32', '{}', 'length')
@@ -311,6 +337,16 @@ class QcowHeaderExtension(Qcow2Struct):
 else:
 self.obj.dump()
 
+def to_json(self):
+# Put the name ahead of the dict
+res = {'name': self.Magic(self.magic), **super().to_json()}
+if self.obj is not None:
+res['data'] = self.obj
+else:
+res['data_str'] = self.data_str
+
+return res
+
 @classmethod
 def create(cls, magic, data):
 return QcowHeaderExtension(magic, len(data), data)
-- 
1.8.3.1




[PATCH 141/143] meson: convert VNC and dependent libraries to meson

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure | 122 ++
 meson.build   |  42 ++-
 meson_options.txt |   4 ++
 ui/meson.build|  10 ++---
 4 files changed, 44 insertions(+), 134 deletions(-)

diff --git a/configure b/configure
index 288a75f..cd1ab0c 100755
--- a/configure
+++ b/configure
@@ -381,12 +381,12 @@ sdl="auto"
 sdl_image="auto"
 virtfs=""
 mpath=""
-vnc="yes"
+vnc="enabled"
 sparse="no"
 vde=""
-vnc_sasl=""
-vnc_jpeg=""
-vnc_png=""
+vnc_sasl="auto"
+vnc_jpeg="auto"
+vnc_png="auto"
 xkbcommon=""
 xen=""
 xen_ctrl_version=""
@@ -1112,9 +1112,9 @@ for opt do
   ;;
   --enable-mpath) mpath="yes"
   ;;
-  --disable-vnc) vnc="no"
+  --disable-vnc) vnc="disabled"
   ;;
-  --enable-vnc) vnc="yes"
+  --enable-vnc) vnc="enabled"
   ;;
   --oss-lib=*) oss_lib="$optarg"
   ;;
@@ -1150,17 +1150,17 @@ for opt do
   ;;
   --disable-strip) strip_opt="no"
   ;;
-  --disable-vnc-sasl) vnc_sasl="no"
+  --disable-vnc-sasl) vnc_sasl="disabled"
   ;;
-  --enable-vnc-sasl) vnc_sasl="yes"
+  --enable-vnc-sasl) vnc_sasl="enabled"
   ;;
-  --disable-vnc-jpeg) vnc_jpeg="no"
+  --disable-vnc-jpeg) vnc_jpeg="disabled"
   ;;
-  --enable-vnc-jpeg) vnc_jpeg="yes"
+  --enable-vnc-jpeg) vnc_jpeg="enabled"
   ;;
-  --disable-vnc-png) vnc_png="no"
+  --disable-vnc-png) vnc_png="disabled"
   ;;
-  --enable-vnc-png) vnc_png="yes"
+  --enable-vnc-png) vnc_png="enabled"
   ;;
   --disable-slirp) slirp="no"
   ;;
@@ -3369,85 +3369,6 @@ EOF
 fi
 
 ##
-# VNC SASL detection
-if test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
-  cat > $TMPC <
-#include 
-int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
-EOF
-  # Assuming Cyrus-SASL installed in /usr prefix
-  # QEMU defines struct iovec in "qemu/osdep.h",
-  # we don't want libsasl to redefine it in .
-  vnc_sasl_cflags="-DSTRUCT_IOVEC_DEFINED"
-  vnc_sasl_libs="-lsasl2"
-  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
-vnc_sasl=yes
-libs_softmmu="$vnc_sasl_libs $libs_softmmu"
-QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
-  else
-if test "$vnc_sasl" = "yes" ; then
-  feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
-fi
-vnc_sasl=no
-  fi
-fi
-
-##
-# VNC JPEG detection
-if test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
-cat > $TMPC <
-#include 
-int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(); 
return 0; }
-EOF
-vnc_jpeg_cflags=""
-vnc_jpeg_libs="-ljpeg"
-  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
-vnc_jpeg=yes
-libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
-QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
-  else
-if test "$vnc_jpeg" = "yes" ; then
-  feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
-fi
-vnc_jpeg=no
-  fi
-fi
-
-##
-# VNC PNG detection
-if test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
-cat > $TMPC <
-#include 
-#include 
-int main(void) {
-png_structp png_ptr;
-png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-return png_ptr != 0;
-}
-EOF
-  if $pkg_config libpng --exists; then
-vnc_png_cflags=$($pkg_config libpng --cflags)
-vnc_png_libs=$($pkg_config libpng --libs)
-  else
-vnc_png_cflags=""
-vnc_png_libs="-lpng"
-  fi
-  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
-vnc_png=yes
-libs_softmmu="$vnc_png_libs $libs_softmmu"
-QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
-  else
-if test "$vnc_png" = "yes" ; then
-  feature_not_found "vnc-png" "Install libpng devel"
-fi
-vnc_png=no
-  fi
-fi
-
-##
 # xkbcommon probe
 if test "$xkbcommon" != "no" ; then
   if $pkg_config xkbcommon --exists; then
@@ -6834,24 +6755,6 @@ if test "$audio_win_int" = "yes" ; then
 fi
 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
-if test "$vnc" = "yes" ; then
-  echo "CONFIG_VNC=y" >> $config_host_mak
-fi
-if test "$vnc_sasl" = "yes" ; then
-  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
-fi
-echo "SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
-echo "SASL_LIBS=$vnc_sasl_libs" >> $config_host_mak
-if test "$vnc_jpeg" = "yes" ; then
-  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
-fi
-echo "JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
-echo "JPEG_LIBS=$vnc_jpeg_libs" >> $config_host_mak
-if test "$vnc_png" = "yes" ; then
-  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
-fi
-echo "PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
-echo "PNG_LIBS=$vnc_png_libs" >> $config_host_mak
 if test "$xkbcommon" = "yes" ; then
   echo "CONFIG_XKBCOMMON=y" >> $config_host_mak
   echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
@@ -8298,6 +8201,7 @@ NINJA=$PWD/ninjatool $python $meson setup \
 

[PATCH 121/143] meson: convert hw/acpi

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs  |  1 -
 hw/acpi/Makefile.objs | 26 --
 hw/acpi/meson.build   | 25 +
 hw/meson.build|  1 +
 4 files changed, 26 insertions(+), 27 deletions(-)
 delete mode 100644 hw/acpi/Makefile.objs
 create mode 100644 hw/acpi/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 4bdb674..ebae00a 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -1,6 +1,5 @@
 ifeq ($(CONFIG_SOFTMMU), y)
 devices-dirs-$(call lor,$(CONFIG_VIRTIO_9P),$(call 
land,$(CONFIG_VIRTFS),$(CONFIG_XEN))) += 9pfs/
-devices-dirs-y += acpi/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
deleted file mode 100644
index 72886c7..000
--- a/hw/acpi/Makefile.objs
+++ /dev/null
@@ -1,26 +0,0 @@
-ifeq ($(CONFIG_ACPI),y)
-common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
-common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
-common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
-common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
-common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
-common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
-common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
-common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o
-common-obj-$(CONFIG_ACPI_HMAT) += hmat.o
-common-obj-$(CONFIG_ACPI_APEI) += ghes.o
-common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
-common-obj-$(call lnot,$(CONFIG_PC)) += acpi-x86-stub.o
-
-common-obj-y += acpi_interface.o
-common-obj-y += bios-linker-loader.o
-common-obj-y += aml-build.o utils.o
-common-obj-$(CONFIG_ACPI_PCI) += pci.o
-common-obj-$(CONFIG_TPM) += tpm.o
-
-common-obj-$(CONFIG_IPMI) += ipmi.o
-common-obj-$(call lnot,$(CONFIG_IPMI)) += ipmi-stub.o
-else
-common-obj-y += acpi-stub.o aml-build-stub.o
-endif
-common-obj-$(CONFIG_ALL) += acpi-stub.o aml-build-stub.o acpi-x86-stub.o 
ipmi-stub.o
diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build
new file mode 100644
index 000..dd69577
--- /dev/null
+++ b/hw/acpi/meson.build
@@ -0,0 +1,25 @@
+acpi_ss = ss.source_set()
+acpi_ss.add(files(
+  'acpi_interface.c',
+  'aml-build.c',
+  'bios-linker-loader.c',
+  'utils.c',
+))
+acpi_ss.add(when: 'CONFIG_ACPI_CPU_HOTPLUG', if_true: files('cpu.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_CPU_HOTPLUG', if_true: files('cpu_hotplug.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_MEMORY_HOTPLUG', if_true: 
files('memory_hotplug.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_NVDIMM', if_true: files('nvdimm.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_PCI', if_true: files('pci.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_VMGENID', if_true: files('vmgenid.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: 
files('generic_event_device.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_X86', if_true: files('core.c', 'piix4.c', 
'pcihp.c'), if_false: files('acpi-stub.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_X86_ICH', if_true: files('ich9.c', 'tco.c'))
+acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c'), if_false: 
files('ipmi-stub.c'))
+acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c'))
+acpi_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c'))
+softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 
'aml-build-stub.c'))
+softmmu_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss)
+softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c', 
'aml-build-stub.c',
+  'acpi-x86-stub.c', 
'ipmi-stub.c'))
diff --git a/hw/meson.build b/hw/meson.build
index ffa3f06..55ca2b2 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,3 +1,4 @@
+subdir('acpi')
 subdir('adc')
 subdir('audio')
 subdir('block')
-- 
1.8.3.1





[PATCH 138/143] meson: replace create-config with meson configure_file

2020-08-06 Thread Paolo Bonzini
Move the create-config logic to meson.build; create a
configuration_data object and let meson handle the
quoting and output.

Signed-off-by: Paolo Bonzini 
---
 Makefile   |   2 +-
 block.c|   4 +-
 configure  |   9 ++-
 meson.build| 100 ++-
 scripts/create_config  | 131 -
 tests/qtest/bios-tables-test.c |   2 +-
 6 files changed, 80 insertions(+), 168 deletions(-)
 delete mode 100755 scripts/create_config

diff --git a/Makefile b/Makefile
index cc0b053..bab1021 100644
--- a/Makefile
+++ b/Makefile
@@ -190,7 +190,7 @@ clean: recurse-clean
rm -f fsdev/*.pod scsi/*.pod
rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
 
-VERSION ?= $(shell cat VERSION)
+VERSION = $(shell cat $(SRC_PATH)/VERSION)
 
 dist: qemu-$(VERSION).tar.bz2
 
diff --git a/block.c b/block.c
index 67c5028..67ca543 100644
--- a/block.c
+++ b/block.c
@@ -443,13 +443,13 @@ static int bdrv_format_is_whitelisted(const char 
*format_name, bool read_only)
 return 1;   /* no whitelist, anything goes */
 }
 
-for (p = whitelist_rw; *p; p++) {
+for (p = whitelist_rw; p < _rw[ARRAY_SIZE(whitelist_rw)]; p++) {
 if (!strcmp(format_name, *p)) {
 return 1;
 }
 }
 if (read_only) {
-for (p = whitelist_ro; *p; p++) {
+for (p = whitelist_ro; p < _ro[ARRAY_SIZE(whitelist_ro)]; 
p++) {
 if (!strcmp(format_name, *p)) {
 return 1;
 }
diff --git a/configure b/configure
index 99ed6fa..13b03ac 100755
--- a/configure
+++ b/configure
@@ -6905,7 +6905,7 @@ if test "$slirp" != "no"; then
   echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
 fi
 if [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
-echo "config-host.h: slirp/all" >> $config_host_mak
+echo "all Makefile: slirp/all" >> $config_host_mak
 fi
 if test "$vde" = "yes" ; then
   echo "CONFIG_VDE=y" >> $config_host_mak
@@ -6983,7 +6983,6 @@ if test "$xfs" = "yes" ; then
   echo "CONFIG_XFS=y" >> $config_host_mak
 fi
 qemu_version=$(head $source_path/VERSION)
-echo "VERSION=$qemu_version" >>$config_host_mak
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
 echo "TARGET_DIRS=$target_list" >> $config_host_mak
@@ -7742,7 +7741,7 @@ echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
 echo "MESON=$meson" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
 if $iasl -h > /dev/null 2>&1; then
-  echo "IASL=$iasl" >> $config_host_mak
+  echo "CONFIG_IASL=$iasl" >> $config_host_mak
 fi
 echo "HOST_CC=$host_cc" >> $config_host_mak
 echo "CXX=$cxx" >> $config_host_mak
@@ -8271,10 +8270,10 @@ echo "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak
 echo "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak
 
 if [ "$fdt" = "git" ]; then
-  echo "config-host.h: dtc/all" >> $config_host_mak
+  echo "all Makefile: dtc/all" >> $config_host_mak
 fi
 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
-  echo "config-host.h: capstone/all" >> $config_host_mak
+  echo "all Makefile: capstone/all" >> $config_host_mak
 fi
 if test -n "$LIBCAPSTONE"; then
   echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
diff --git a/meson.build b/meson.build
index e2e3348..cb2ffd6 100644
--- a/meson.build
+++ b/meson.build
@@ -12,6 +12,8 @@ config_host = keyval.load(meson.current_build_dir() / 
'config-host.mak')
 config_all_disas = keyval.load(meson.current_build_dir() / 
'config-all-disas.mak')
 enable_modules = 'CONFIG_MODULES' in config_host
 build_docs = 'BUILD_DOCS' in config_host
+config_host_data = configuration_data()
+genh = []
 
 add_project_arguments(config_host['QEMU_CFLAGS'].split(),
   language: ['c', 'objc'])
@@ -342,13 +344,47 @@ if 'CONFIG_LIBPMEM' in config_host
link_args: config_host['LIBPMEM_LIBS'].split())
 endif
 
-create_config = find_program('scripts/create_config')
+# Create config-host.h
+
+config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
+config_host_data.set('QEMU_VERSION_MAJOR', 
meson.project_version().split('.')[0])
+config_host_data.set('QEMU_VERSION_MINOR', 
meson.project_version().split('.')[1])
+config_host_data.set('QEMU_VERSION_MICRO', 
meson.project_version().split('.')[2])
+
+arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 
'CONFIG_BDRV_RO_WHITELIST']
+ignored = ['HOST_USB', 'HOST_CC']
+strings = ['HOST_DSOSUF', 'CONFIG_IASL']
+foreach k, v: config_host
+  if arrays.contains(k)
+if v != ''
+  v = '"' + '", "'.join(v.split()) + '", '
+endif
+config_host_data.set(k, v)
+  elif k == 'ARCH'
+config_host_data.set('HOST_' + v.to_upper(), 1)
+  elif ignored.contains(k)
+# do nothing
+  elif k.startswith('qemu') and (k.endswith('dir') or k.endswith('path'))
+config_host_data.set_quoted('CONFIG_' + k.to_upper(), v)
+  elif 

[PATCH 120/143] meson: convert hw/adc

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs | 1 -
 hw/adc/Makefile.objs | 1 -
 hw/adc/meson.build   | 1 +
 hw/meson.build   | 1 +
 4 files changed, 2 insertions(+), 2 deletions(-)
 delete mode 100644 hw/adc/Makefile.objs
 create mode 100644 hw/adc/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index c0cbc0f..4bdb674 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -1,7 +1,6 @@
 ifeq ($(CONFIG_SOFTMMU), y)
 devices-dirs-$(call lor,$(CONFIG_VIRTIO_9P),$(call 
land,$(CONFIG_VIRTFS),$(CONFIG_XEN))) += 9pfs/
 devices-dirs-y += acpi/
-devices-dirs-y += adc/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/adc/Makefile.objs b/hw/adc/Makefile.objs
deleted file mode 100644
index 2b9dc36..000
--- a/hw/adc/Makefile.objs
+++ /dev/null
@@ -1 +0,0 @@
-common-obj-$(CONFIG_STM32F2XX_ADC) += stm32f2xx_adc.o
diff --git a/hw/adc/meson.build b/hw/adc/meson.build
new file mode 100644
index 000..0d62ae9
--- /dev/null
+++ b/hw/adc/meson.build
@@ -0,0 +1 @@
+softmmu_ss.add(when: 'CONFIG_STM32F2XX_ADC', if_true: files('stm32f2xx_adc.c'))
diff --git a/hw/meson.build b/hw/meson.build
index 624335b..ffa3f06 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,3 +1,4 @@
+subdir('adc')
 subdir('audio')
 subdir('block')
 subdir('char')
-- 
1.8.3.1





[PATCH 132/143] rules.mak: remove version.o

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile  | 5 -
 Makefile.objs | 4 
 rules.mak | 4 +---
 3 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 1f89680..603869d 100644
--- a/Makefile
+++ b/Makefile
@@ -226,11 +226,6 @@ recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) 
$(ROM_DIRS))
 recurse-install: $(addsuffix /install, $(TARGET_DIRS))
 $(addsuffix /install, $(TARGET_DIRS)): all
 
-$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
-   $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ 
$<,"RC","version.o")
-
-Makefile: $(version-obj-y)
-
 ##
 
 clean: recurse-clean
diff --git a/Makefile.objs b/Makefile.objs
index 9f73e86..306d81d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -31,7 +31,3 @@ crypto-obj-y = crypto/libcrypto.fa
 io-obj-y = io/libio.fa
 
 endif # CONFIG_SOFTMMU or CONFIG_TOOLS
-
-##
-# Resource file for Windows executables
-version-obj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.o
diff --git a/rules.mak b/rules.mak
index b983c7f..6d89001 100644
--- a/rules.mak
+++ b/rules.mak
@@ -77,8 +77,6 @@ expand-objs = $(strip $(sort $(filter %.o,$1)) \
$(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
   $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \
   -c -o $@ $<,"CC","$(TARGET_DIR)$@")
-%.o: %.rc
-   $(call quiet-command,$(WINDRES) -I. -o $@ $<,"RC","$(TARGET_DIR)$@")
 
 # If we have a CXX we might have some C++ objects, in which case we
 # must link with the C++ compiler, not the plain C compiler.
@@ -86,7 +84,7 @@ LINKPROG = $(or $(CXX),$(CC))
 
 LINK = $(call quiet-command, $(LINKPROG) $(CFLAGS) $(QEMU_LDFLAGS) -o $@ \
$(call process-archive-undefs, $1) \
-   $(version-obj-y) $(call extract-libs,$1) 
$(LIBS),"LINK","$(TARGET_DIR)$@")
+   $(call extract-libs,$1) $(LIBS),"LINK","$(TARGET_DIR)$@")
 
 %.o: %.S
$(call quiet-command,$(CCAS) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
-- 
1.8.3.1





[PATCH 119/143] meson: convert hw/audio

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs   |  1 -
 hw/audio/Makefile.objs | 18 --
 hw/audio/meson.build   | 14 ++
 hw/meson.build |  1 +
 4 files changed, 15 insertions(+), 19 deletions(-)
 delete mode 100644 hw/audio/Makefile.objs
 create mode 100644 hw/audio/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 9068859..c0cbc0f 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -2,7 +2,6 @@ ifeq ($(CONFIG_SOFTMMU), y)
 devices-dirs-$(call lor,$(CONFIG_VIRTIO_9P),$(call 
land,$(CONFIG_VIRTFS),$(CONFIG_XEN))) += 9pfs/
 devices-dirs-y += acpi/
 devices-dirs-y += adc/
-devices-dirs-y += audio/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/audio/Makefile.objs b/hw/audio/Makefile.objs
deleted file mode 100644
index 63db383..000
--- a/hw/audio/Makefile.objs
+++ /dev/null
@@ -1,18 +0,0 @@
-# Sound
-common-obj-$(CONFIG_SB16) += sb16.o
-common-obj-$(CONFIG_ES1370) += es1370.o
-common-obj-$(CONFIG_AC97) += ac97.o
-common-obj-$(CONFIG_ADLIB) += fmopl.o adlib.o
-common-obj-$(CONFIG_GUS) += gus.o gusemu_hal.o gusemu_mixer.o
-common-obj-$(CONFIG_CS4231A) += cs4231a.o
-common-obj-$(CONFIG_HDA) += intel-hda.o hda-codec.o
-
-common-obj-$(CONFIG_PCSPK) += pcspk.o
-common-obj-$(CONFIG_WM8750) += wm8750.o
-common-obj-$(CONFIG_PL041) += pl041.o lm4549.o
-
-common-obj-$(CONFIG_CS4231) += cs4231.o
-common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
-common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
-
-common-obj-y += soundhw.o
diff --git a/hw/audio/meson.build b/hw/audio/meson.build
new file mode 100644
index 000..549e9a0
--- /dev/null
+++ b/hw/audio/meson.build
@@ -0,0 +1,14 @@
+softmmu_ss.add(files('soundhw.c'))
+softmmu_ss.add(when: 'CONFIG_AC97', if_true: files('ac97.c'))
+softmmu_ss.add(when: 'CONFIG_ADLIB', if_true: files('fmopl.c', 'adlib.c'))
+softmmu_ss.add(when: 'CONFIG_CS4231', if_true: files('cs4231.c'))
+softmmu_ss.add(when: 'CONFIG_CS4231A', if_true: files('cs4231a.c'))
+softmmu_ss.add(when: 'CONFIG_ES1370', if_true: files('es1370.c'))
+softmmu_ss.add(when: 'CONFIG_GUS', if_true: files('gus.c', 'gusemu_hal.c', 
'gusemu_mixer.c'))
+softmmu_ss.add(when: 'CONFIG_HDA', if_true: files('intel-hda.c', 
'hda-codec.c'))
+softmmu_ss.add(when: 'CONFIG_MARVELL_88W8618', if_true: 
files('marvell_88w8618.c'))
+softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-ac97.c'))
+softmmu_ss.add(when: 'CONFIG_PCSPK', if_true: files('pcspk.c'))
+softmmu_ss.add(when: 'CONFIG_PL041', if_true: files('pl041.c', 'lm4549.c'))
+softmmu_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c'))
+softmmu_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c'))
diff --git a/hw/meson.build b/hw/meson.build
index f968aa8..624335b 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,3 +1,4 @@
+subdir('audio')
 subdir('block')
 subdir('char')
 subdir('core')
-- 
1.8.3.1





[PATCH 136/143] meson: convert check-block

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 tests/Makefile.include | 18 ++
 tests/meson.build  |  4 
 tests/qemu-iotests/meson.build |  8 
 3 files changed, 14 insertions(+), 16 deletions(-)
 create mode 100644 tests/qemu-iotests/meson.build

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 7468e99..a1e4871 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -160,8 +160,6 @@ check-unit-y += tests/test-uuid$(EXESUF)
 check-unit-y += tests/ptimer-test$(EXESUF)
 check-unit-y += tests/test-qapi-util$(EXESUF)
 
-check-block-$(call land,$(CONFIG_POSIX),$(CONFIG_SOFTMMU)) += 
tests/check-block.sh
-
 generated-files-y += tests/test-qapi-types.h
 generated-files-y += tests/include/test-qapi-types-sub-module.h
 generated-files-y += tests/test-qapi-types-sub-sub-module.h
@@ -487,16 +485,6 @@ check-tcg: $(RUN_TCG_TARGET_RULES)
 clean-tcg: $(CLEAN_TCG_TARGET_RULES)
 
 
-QEMU_IOTESTS_HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = 
tests/qemu-iotests/socket_scm_helper$(EXESUF)
-
-tests/qemu-iotests/socket_scm_helper$(EXESUF): 
tests/qemu-iotests/socket_scm_helper.o
-
-.PHONY: check-tests/check-block.sh
-check-tests/check-block.sh: tests/check-block.sh qemu-img$(EXESUF) \
-   qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) \
-   $(patsubst %-softmmu,qemu-system-%,$(filter 
%-softmmu,$(TARGET_DIRS)))
-   @$<
-
 # Python venv for running tests
 
 .PHONY: check-venv check-acceptance
@@ -550,13 +538,13 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) 
get-vm-images
 
 # Consolidated targets
 
-.PHONY: check-block check-unit check check-clean get-vm-images
+.PHONY: check-unit check check-clean get-vm-images
 ifeq ($(CONFIG_TOOLS),y)
 check-block: $(patsubst %,check-%, $(check-block-y))
 endif
 check-build: build-unit
 
-check: check-block check-unit
+check: check-unit
 check-clean:
rm -rf $(check-unit-y) tests/*.o tests/*/*.o $(QEMU_IOTESTS_HELPERS-y)
rm -f tests/test-qapi-gen-timestamp
@@ -568,8 +556,6 @@ clean: check-clean
 
 # Build the help program automatically
 
-all: $(QEMU_IOTESTS_HELPERS-y)
-
 -include $(wildcard tests/*.d)
 
 endif
diff --git a/tests/meson.build b/tests/meson.build
index d724402..f834c27 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,3 +1,7 @@
+if have_system and 'CONFIG_POSIX' in config_host
+  subdir('qemu-iotests')
+endif
+
 test('decodetree', sh,
  args: [ files('decode/check.sh'), config_host['PYTHON'], 
files('../scripts/decodetree.py') ],
  workdir: meson.current_source_dir() / 'decode',
diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build
new file mode 100644
index 000..60e81a2
--- /dev/null
+++ b/tests/qemu-iotests/meson.build
@@ -0,0 +1,8 @@
+dep = [qemu_img, qemu_io, qemu_nbd, emulators]
+if 'CONFIG_LINUX' in config_host
+dep += executable('socket_scm_helper', 'socket_scm_helper.c',
+  build_by_default: false)
+endif
+test('qemu-iotests', sh, args: [files('../check-block.sh')], depends: dep,
+ suite: 'block', timeout: 1)
+
-- 
1.8.3.1





[PATCH 115/143] meson: convert hw/display

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile.target  |  1 +
 hw/Makefile.objs |  1 -
 hw/display/Makefile.objs | 65 -
 hw/display/meson.build   | 94 
 hw/meson.build   |  1 +
 5 files changed, 96 insertions(+), 66 deletions(-)
 delete mode 100644 hw/display/Makefile.objs
 create mode 100644 hw/display/meson.build

diff --git a/Makefile.target b/Makefile.target
index 3d5a2af..3534ece 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -169,6 +169,7 @@ LIBS := $(LIBS) $(BRLAPI_LIBS) $(SDL_LIBS) $(SPICE_LIBS) 
$(OPENGL_LIBS) $(SECCOM
 LIBS := $(LIBS) $(COREAUDIO_LIBS) $(DSOUND_LIBS)
 LIBS := $(LIBS) $(VDE_LIBS) $(SLIRP_LIBS)
 LIBS := $(LIBS) $(LIBUSB_LIBS) $(SMARTCARD_LIBS) $(USB_REDIR_LIBS)
+LIBS := $(LIBS) $(VIRGL_LIBS)
 
 # Hardware support
 ifeq ($(TARGET_NAME), sparc64)
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 26917a4..6fce6a1 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -6,7 +6,6 @@ devices-dirs-y += audio/
 devices-dirs-y += block/
 devices-dirs-y += char/
 devices-dirs-y += cpu/
-devices-dirs-y += display/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
deleted file mode 100644
index d619594..000
--- a/hw/display/Makefile.objs
+++ /dev/null
@@ -1,65 +0,0 @@
-common-obj-$(CONFIG_DDC) += i2c-ddc.o
-common-obj-$(CONFIG_EDID) += edid-generate.o edid-region.o
-
-common-obj-$(CONFIG_FW_CFG_DMA) += ramfb.o
-common-obj-$(CONFIG_FW_CFG_DMA) += ramfb-standalone.o
-
-common-obj-$(CONFIG_ADS7846) += ads7846.o
-common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
-common-obj-$(call 
land,$(CONFIG_VGA_CIRRUS),$(CONFIG_VGA_ISA))+=cirrus_vga_isa.o
-common-obj-$(CONFIG_G364FB) += g364fb.o
-common-obj-$(CONFIG_JAZZ_LED) += jazz_led.o
-common-obj-$(CONFIG_PL110) += pl110.o
-common-obj-$(CONFIG_SII9022) += sii9022.o
-common-obj-$(CONFIG_SSD0303) += ssd0303.o
-common-obj-$(CONFIG_SSD0323) += ssd0323.o
-common-obj-$(CONFIG_XEN) += xenfb.o
-
-common-obj-$(CONFIG_VGA_PCI) += vga-pci.o
-common-obj-$(CONFIG_VGA_ISA) += vga-isa.o
-common-obj-$(CONFIG_VGA_ISA_MM) += vga-isa-mm.o
-common-obj-$(CONFIG_VMWARE_VGA) += vmware_vga.o
-common-obj-$(CONFIG_BOCHS_DISPLAY) += bochs-display.o
-
-common-obj-$(CONFIG_BLIZZARD) += blizzard.o
-common-obj-$(CONFIG_EXYNOS4) += exynos4210_fimd.o
-common-obj-$(CONFIG_FRAMEBUFFER) += framebuffer.o
-common-obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o
-common-obj-$(CONFIG_ZAURUS) += tc6393xb.o
-common-obj-$(CONFIG_MACFB) += macfb.o
-
-obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o
-milkymist-tmu2.o-cflags := $(X11_CFLAGS) $(OPENGL_CFLAGS)
-milkymist-tmu2.o-libs := $(X11_LIBS) $(OPENGL_LIBS)
-
-common-obj-$(CONFIG_OMAP) += omap_dss.o
-obj-$(CONFIG_OMAP) += omap_lcdc.o
-common-obj-$(CONFIG_PXA2XX) += pxa2xx_lcd.o
-common-obj-$(CONFIG_RASPI) += bcm2835_fb.o
-common-obj-$(CONFIG_SM501) += sm501.o
-common-obj-$(CONFIG_TCX) += tcx.o
-common-obj-$(CONFIG_CG3) += cg3.o
-common-obj-$(CONFIG_NEXTCUBE) += next-fb.o
-common-obj-$(CONFIG_ARTIST) += artist.o
-
-obj-$(CONFIG_VGA) += vga.o
-
-ifeq ($(CONFIG_QXL),y)
-common-obj-m += qxl.mo
-qxl.mo-objs = qxl.o qxl-logger.o qxl-render.o
-endif
-
-common-obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o 
virtio-gpu-3d.o
-common-obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o
-common-obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += 
virtio-gpu-pci.o
-common-obj-$(call land,$(CONFIG_VHOST_USER_GPU),$(CONFIG_VIRTIO_PCI)) += 
vhost-user-gpu-pci.o
-common-obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
-common-obj-$(CONFIG_VHOST_USER_VGA) += vhost-user-vga.o
-virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
-virtio-gpu.o-libs += $(VIRGL_LIBS)
-virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
-virtio-gpu-3d.o-libs += $(VIRGL_LIBS)
-common-obj-$(CONFIG_DPCD) += dpcd.o
-common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx_dp.o
-
-common-obj-$(CONFIG_ATI_VGA) += ati.o ati_2d.o ati_dbg.o
diff --git a/hw/display/meson.build b/hw/display/meson.build
new file mode 100644
index 000..efe18f2
--- /dev/null
+++ b/hw/display/meson.build
@@ -0,0 +1,94 @@
+hw_display_modules = []
+
+softmmu_ss.add(when: 'CONFIG_DDC', if_true: files('i2c-ddc.c'))
+softmmu_ss.add(when: 'CONFIG_EDID', if_true: files('edid-generate.c', 
'edid-region.c'))
+
+softmmu_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('ramfb.c'))
+softmmu_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('ramfb-standalone.c'))
+
+softmmu_ss.add(when: 'CONFIG_ADS7846', if_true: files('ads7846.c'))
+softmmu_ss.add(when: 'CONFIG_VGA_CIRRUS', if_true: files('cirrus_vga.c'))
+softmmu_ss.add(when: ['CONFIG_VGA_CIRRUS', 'CONFIG_VGA_ISA'], if_true: 
files('cirrus_vga_isa.c'))
+softmmu_ss.add(when: 'CONFIG_G364FB', if_true: files('g364fb.c'))
+softmmu_ss.add(when: 'CONFIG_JAZZ_LED', if_true: files('jazz_led.c'))
+softmmu_ss.add(when: 'CONFIG_PL110', if_true: files('pl110.c'))
+softmmu_ss.add(when: 

[PATCH 130/143] meson: link emulators without Makefile.target

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 .gitlab-ci.yml|   4 +-
 Makefile  |  34 +--
 Makefile.objs |  32 ---
 Makefile.target   | 153 +-
 configure |  22 ++---
 docs/devel/blkverify.txt  |   4 +-
 docs/devel/testing.rst|   4 +-
 docs/interop/live-block-operations.rst|   4 +-
 meson.build   |  81 +++-
 os-posix.c|   2 +-
 plugins/meson.build   |  10 +-
 rules.mak |   1 -
 scripts/device-crash-test |   2 +-
 softmmu/Makefile.objs |   3 -
 softmmu/meson.build   |   4 +
 tests/Makefile.include|   2 +-
 tests/acceptance/avocado_qemu/__init__.py |   3 +-
 tests/data/acpi/rebuild-expected-aml.sh   |   2 +-
 tests/multiboot/run_test.sh   |   2 +-
 tests/qemu-iotests/check  |   6 +-
 tests/qtest/fuzz/Makefile.include |  39 
 tests/qtest/fuzz/i440fx_fuzz.c|   4 +-
 tests/qtest/fuzz/meson.build  |  34 +++
 tests/qtest/fuzz/virtio_net_fuzz.c|   3 +-
 tests/qtest/libqos/qgraph.h   |   2 +-
 tests/qtest/meson.build   |   2 +-
 tests/qtest/rtas-test.c   |   2 +-
 tests/tcg/configure.sh|   4 +-
 28 files changed, 161 insertions(+), 304 deletions(-)
 delete mode 100644 softmmu/Makefile.objs
 delete mode 100644 tests/qtest/fuzz/Makefile.include
 create mode 100644 tests/qtest/fuzz/meson.build

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9820066..f6556e5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -269,5 +269,5 @@ build-tci:
 ./tests/qtest/boot-serial-test || exit 1 ;
 ./tests/qtest/cdrom-test || exit 1 ;
   done
-- QTEST_QEMU_BINARY="x86_64-softmmu/qemu-system-x86_64" 
./tests/qtest/pxe-test
-- QTEST_QEMU_BINARY="s390x-softmmu/qemu-system-s390x" 
./tests/qtest/pxe-test -m slow
+- QTEST_QEMU_BINARY="./qemu-system-x86_64" ./tests/qtest/pxe-test
+- QTEST_QEMU_BINARY="./qemu-system-s390x" ./tests/qtest/pxe-test -m slow
diff --git a/Makefile b/Makefile
index 5320a06..1f89680 100644
--- a/Makefile
+++ b/Makefile
@@ -105,9 +105,6 @@ include $(SRC_PATH)/rules.mak
 # lor is defined in rules.mak
 CONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
 
-generated-files-y += target/s390x/gen-features.h
-target/s390x/gen-features.h: Makefile.ninja
-
 generated-files-y += .git-submodule-status
 
 edk2-decompressed = $(basename $(wildcard pc-bios/edk2-*.fd.bz2))
@@ -172,29 +169,6 @@ config-host.h-timestamp: config-host.mak
 
 TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), 
$(TARGET_DIRS)))
 
-SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
-$(SOFTMMU_ALL_RULES): $(authz-obj-y)
-$(SOFTMMU_ALL_RULES): $(block-obj-y)
-$(SOFTMMU_ALL_RULES): $(chardev-obj-y)
-$(SOFTMMU_ALL_RULES): $(crypto-obj-y)
-$(SOFTMMU_ALL_RULES): $(io-obj-y)
-$(SOFTMMU_ALL_RULES): $(qom-obj-y)
-$(SOFTMMU_ALL_RULES): config-all-devices.mak
-
-SOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES))
-$(SOFTMMU_FUZZ_RULES): $(authz-obj-y)
-$(SOFTMMU_FUZZ_RULES): $(block-obj-y)
-$(SOFTMMU_FUZZ_RULES): $(chardev-obj-y)
-$(SOFTMMU_FUZZ_RULES): $(crypto-obj-y)
-$(SOFTMMU_FUZZ_RULES): $(io-obj-y)
-$(SOFTMMU_FUZZ_RULES): config-all-devices.mak
-$(SOFTMMU_FUZZ_RULES): $(edk2-decompressed)
-
-# meson: this is sub-optimal but going away after conversion
-TARGET_DEPS = $(patsubst %,%-config-target.h, $(TARGET_DIRS))
-TARGET_DEPS += $(patsubst %,%-config-devices.h, $(filter 
%-softmmu,$(TARGET_DIRS)))
-TARGET_DEPS += $(patsubst %,libqemu-%.fa, $(TARGET_DIRS))
-
 .PHONY: $(TARGET_DIRS_RULES)
 # The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
 # $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
@@ -237,11 +211,7 @@ slirp/all: .git-submodule-status
CC="$(CC)" AR="$(AR)"   LD="$(LD)" RANLIB="$(RANLIB)"   \
CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
 
-$(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
-   $(qom-obj-y) block.syms qemu.syms
-
-$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
-   $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
+$(filter %/all, $(TARGET_DIRS_RULES)):
 
 ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
 ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
@@ -263,8 +233,6 @@ Makefile: $(version-obj-y)
 
 ##
 
-COMMON_LDADDS = libqemuutil.a
-
 clean: recurse-clean
 # avoid old build problems by removing potentially incorrect old files
rm -f 

[PATCH 137/143] rules.mak: drop unneeded macros

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 .gitignore  |   1 -
 Makefile|   7 +-
 configure   |  32 +-
 docs/devel/build-system.txt |   5 +-
 rules.mak   | 231 +---
 scripts/create_config   |   6 +-
 6 files changed, 14 insertions(+), 268 deletions(-)

diff --git a/.gitignore b/.gitignore
index de1f20e..5eaeada 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,7 +78,6 @@
 *.msi
 *.dll
 *.so
-*.mo
 *.fn
 *.ky
 *.log
diff --git a/Makefile b/Makefile
index 6735832..cc0b053 100644
--- a/Makefile
+++ b/Makefile
@@ -127,7 +127,7 @@ endif
 
 include $(SRC_PATH)/tests/Makefile.include
 
-all: recurse-all modules
+all: recurse-all
 
 # LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" 
LIBFDT_lib=""
@@ -181,7 +181,7 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
 clean: recurse-clean
 # avoid old build problems by removing potentially incorrect old files
rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h 
gen-op-arm.h
-   find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name 
'*.[oda]' \) -type f \
+   find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll 
\
@@ -383,9 +383,6 @@ print-help = $(quiet-@)$(call print-help-run,$1,$2)
 help:
@echo  'Generic targets:'
$(call print-help,all,Build all)
-ifdef CONFIG_MODULES
-   $(call print-help,modules,Build all modules)
-endif
$(call print-help,dir/file.o,Build specified target only)
$(call print-help,install,Install QEMU, documentation and tools)
$(call print-help,ctags/TAGS,Generate tags file for editors)
diff --git a/configure b/configure
index 08aee81..99ed6fa 100755
--- a/configure
+++ b/configure
@@ -29,7 +29,6 @@ TMPC="${TMPDIR1}/${TMPB}.c"
 TMPO="${TMPDIR1}/${TMPB}.o"
 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
 TMPE="${TMPDIR1}/${TMPB}.exe"
-TMPMO="${TMPDIR1}/${TMPB}.mo"
 TMPTXT="${TMPDIR1}/${TMPB}.txt"
 
 rm -f config.log
@@ -424,7 +423,7 @@ bigendian="no"
 mingw32="no"
 gcov="no"
 EXESUF=""
-DSOSUF=".so"
+HOST_DSOSUF=".so"
 LDFLAGS_SHARED="-shared"
 modules="no"
 module_upgrades="no"
@@ -958,7 +957,7 @@ fi
 
 if test "$mingw32" = "yes" ; then
   EXESUF=".exe"
-  DSOSUF=".dll"
+  HOST_DSOSUF=".dll"
   # MinGW needs -mthreads for TLS and macro _MT.
   QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
   LIBS="-lwinmm -lws2_32 $LIBS"
@@ -6205,31 +6204,6 @@ EOF
   fi
 fi
 
-#
-# Sparc implicitly links with --relax, which is
-# incompatible with -r, so --no-relax should be
-# given. It does no harm to give it on other
-# platforms too.
-
-# Note: the prototype is needed since QEMU_CFLAGS
-#   contains -Wmissing-prototypes
-cat > $TMPC << EOF
-extern int foo(void);
-int foo(void) { return 0; }
-EOF
-if ! compile_object ""; then
-  error_exit "Failed to compile object file for LD_REL_FLAGS test"
-fi
-for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
-  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
-LD_REL_FLAGS=$i
-break
-  fi
-done
-if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
-  feature_not_found "modules" "Cannot find how to build relocatable objects"
-fi
-
 ##
 # check for sysmacros.h
 
@@ -7803,7 +,7 @@ echo "LIBS+=$LIBS" >> $config_host_mak
 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
-echo "DSOSUF=$DSOSUF" >> $config_host_mak
+echo "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
diff --git a/docs/devel/build-system.txt b/docs/devel/build-system.txt
index 41bd08e..fea67b2 100644
--- a/docs/devel/build-system.txt
+++ b/docs/devel/build-system.txt
@@ -404,10 +404,7 @@ using Makefile.target for the build rules.
 - rules.mak
 
 This file provides the generic helper rules for invoking build tools, in
-particular the compiler and linker. This also contains the magic (hairy)
-'unnest-vars' function which is used to merge the variable definitions
-from all Makefile.objs in the source tree down into the main Makefile
-context.
+particular the compiler and linker.
 
 
 - default-configs/*.mak
diff --git a/rules.mak b/rules.mak
index 6cab0b9..c66c821 100644
--- a/rules.mak
+++ b/rules.mak
@@ -33,11 +33,6 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d
 # different for target-dependent ones.
 QEMU_LOCAL_INCLUDES = -iquote $(BUILD_DIR) -iquote $(BUILD_DIR)/$(@D) -iquote 
$(@D)
 
-WL_U := 

[PATCH 135/143] meson: build texi doc

2020-08-06 Thread Paolo Bonzini
Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile   | 108 +++--
 docs/interop/qemu-ga-ref.texi  |   2 +-
 docs/interop/qemu-qmp-ref.texi |   2 +-
 meson.build|  85 
 qga/meson.build|  12 +++--
 version.texi.in|   2 +
 6 files changed, 105 insertions(+), 106 deletions(-)
 create mode 100644 version.texi.in

diff --git a/Makefile b/Makefile
index d0d0294..6735832 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,6 @@ BUILD_DIR=$(CURDIR)
 SRC_PATH=.
 
 UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
-html info pdf txt \
 help check-help print-% \
 docker docker-% vm-help vm-test vm-build-%
 
@@ -113,20 +112,13 @@ edk2-decompressed = $(basename $(wildcard 
pc-bios/edk2-*.fd.bz2))
 Makefile: ;
 configure: ;
 
-.PHONY: all clean cscope distclean html info install install-doc \
-   pdf txt recurse-all dist msi FORCE
+.PHONY: all clean cscope distclean install \
+   recurse-all dist msi FORCE
 
 $(call set-vpath, $(SRC_PATH))
 
 LIBS+=-lz $(LIBS_TOOLS)
 
-ifdef BUILD_DOCS
-DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt 
docs/interop/qemu-qmp-ref.7
-DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt 
docs/interop/qemu-ga-ref.7
-else
-DOCS=
-endif
-
 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) 
BUILD_DIR=$(BUILD_DIR)
 
 ifneq ($(wildcard config-host.mak),)
@@ -135,7 +127,7 @@ endif
 
 include $(SRC_PATH)/tests/Makefile.include
 
-all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) recurse-all modules
+all: recurse-all modules
 
 # LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" 
LIBFDT_lib=""
@@ -206,7 +198,7 @@ qemu-%.tar.bz2:
$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst 
qemu-%.tar.bz2,%,$@)"
 
 distclean: clean
-   rm -f config-host.mak config-host.h* $(DOCS)
+   rm -f config-host.mak config-host.h*
rm -f tests/tcg/config-*.mak
rm -f config-all-disas.mak config.status
rm -f po/*.mo tests/qemu-iotests/common.env
@@ -214,12 +206,6 @@ distclean: clean
rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
rm -f config.log
rm -f linux-headers/asm
-   rm -f docs/version.texi
-   rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
-   rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
-   rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
-   rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
-   rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
rm -Rf .sdk
 
 KEYMAPS=da en-gb  et  fr fr-ch  is  lt  no  pt-br  sv \
@@ -258,29 +244,6 @@ BLOBS=
 DESCS=
 endif
 
-install-doc: $(DOCS)
-   $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
-   $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html 
"$(DESTDIR)$(qemu_docdir)/interop"
-   $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt 
"$(DESTDIR)$(qemu_docdir)/interop"
-ifdef CONFIG_POSIX
-   $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
-   $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 
"$(DESTDIR)$(mandir)/man1"
-   $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
-   $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
-ifeq ($(CONFIG_GUEST_AGENT),y)
-   $(INSTALL_DATA) docs/interop/qemu-ga-ref.html 
"$(DESTDIR)$(qemu_docdir)/interop"
-   $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt 
"$(DESTDIR)$(qemu_docdir)/interop"
-   $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
-endif
-endif
-ifdef CONFIG_VIRTFS
-   $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
-   $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 
"$(DESTDIR)$(mandir)/man1"
-endif
-ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
-   $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 
"$(DESTDIR)$(mandir)/man1"
-endif
-
 install-datadir:
$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
 
@@ -295,8 +258,7 @@ ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 
512x512
 
 # Needed by "meson install"
 export DESTDIR
-install: all $(if $(BUILD_DOCS),install-doc) \
-   install-datadir install-localstatedir \
+install: all install-datadir install-localstatedir \
$(if $(INSTALL_BLOBS),$(edk2-decompressed))
 ifdef CONFIG_TRACE_SYSTEMTAP
$(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
@@ -343,62 +305,6 @@ endif
$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x 
"$(DESTDIR)$(qemu_datadir)/keymaps"; \
done
 
-# documentation
-MAKEINFO=makeinfo
-MAKEINFOINCLUDES= -I docs -I $( $@,"GEN","$@")
-
-%.html: %.texi docs/version.texi
-   $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers 
\
-   --html $< -o $@,"GEN","$@")
-
-%.info: %.texi 

[PATCH 128/143] meson: cpu-emu

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile.target | 12 
 configure   |  8 
 meson.build | 37 +
 scripts/feature_to_c.sh | 24 
 4 files changed, 53 insertions(+), 28 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 5c099fa..c180b4c 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -108,15 +108,6 @@ obj-y += $(LIBQEMU)
 obj-y += trace/
 
 #
-# cpu emulator library
-obj-y += exec.o exec-vary.o
-obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-gvec.o
-obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o
-obj-$(CONFIG_TCG_INTERPRETER) += tcg/tci.o
-obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
-obj-$(CONFIG_TCG) += fpu/softfloat.o
-obj-y += disas.o
-obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
 LIBS := $(libs_cpu) $(LIBS)
 
 obj-$(CONFIG_PLUGIN) += plugins/
@@ -200,9 +191,6 @@ ifdef CONFIG_DARWIN
$(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@")
 endif
 
-gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
-   $(call quiet-command,rm -f $@ && $(SHELL) 
$(SRC_PATH)/scripts/feature_to_c.sh $@ 
$(TARGET_XML_FILES),"GEN","$(TARGET_DIR)$@")
-
 clean: clean-target
rm -f *.a *~ $(PROGS)
rm -f $(shell find . -name '*.[od]')
diff --git a/configure b/configure
index 525f415..a7a4538 100755
--- a/configure
+++ b/configure
@@ -5416,9 +5416,13 @@ case "$capstone" in
   LIBCAPSTONE=libcapstone.a
 fi
 libs_cpu="-L$PWD/capstone -lcapstone $libs_cpu"
+capstone_libs="-L$PWD/capstone -lcapstone"
+capstone_cflags="-I${source_path}/capstone/include"
 ;;
 
   system)
+capstone_libs="$($pkg_config --libs capstone)"
+capstone_cflags="$($pkg_config --cflags capstone)"
 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
 libs_cpu="$($pkg_config --libs capstone) $libs_cpu"
 ;;
@@ -7637,6 +7641,8 @@ if test "$ivshmem" = "yes" ; then
 fi
 if test "$capstone" != "no" ; then
   echo "CONFIG_CAPSTONE=y" >> $config_host_mak
+  echo "CAPSTONE_CFLAGS=$capstone_cflags" >> $config_host_mak
+  echo "CAPSTONE_LIBS=$capstone_libs" >> $config_host_mak
 fi
 if test "$debug_mutex" = "yes" ; then
   echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
@@ -7657,6 +7663,8 @@ fi
 
 if test "$libpmem" = "yes" ; then
   echo "CONFIG_LIBPMEM=y" >> $config_host_mak
+  echo "LIBPMEM_LIBS=$libpmem_libs" >> $config_host_mak
+  echo "LIBPMEM_CFLAGS=$libpmem_cflags" >> $config_host_mak
 fi
 
 if test "$libdaxctl" = "yes" ; then
diff --git a/meson.build b/meson.build
index e1d7672..7ed8276 100644
--- a/meson.build
+++ b/meson.build
@@ -328,6 +328,16 @@ if 'CONFIG_USB_LIBUSB' in config_host
   libusb = declare_dependency(compile_args: 
config_host['LIBUSB_CFLAGS'].split(),
   link_args: config_host['LIBUSB_LIBS'].split())
 endif
+capstone = not_found
+if 'CONFIG_CAPSTONE' in config_host
+  capstone = declare_dependency(compile_args: 
config_host['CAPSTONE_CFLAGS'].split(),
+link_args: 
config_host['CAPSTONE_LIBS'].split())
+endif
+libpmem = not_found
+if 'CONFIG_LIBPMEM' in config_host
+  libpmem = declare_dependency(compile_args: 
config_host['LIBPMEM_CFLAGS'].split(),
+   link_args: config_host['LIBPMEM_LIBS'].split())
+endif
 
 create_config = find_program('scripts/create_config')
 minikconf = find_program('scripts/minikconf.py')
@@ -505,6 +515,8 @@ target_softmmu_arch = {}
 # Trace files #
 ###
 
+# TODO: add each directory to the subdirs from its own meson.build, once
+# we have those
 trace_events_subdirs = [
   'accel/kvm',
   'accel/tcg',
@@ -670,6 +682,20 @@ softmmu_ss.add(when: ['CONFIG_FDT', fdt],  if_true: 
[files('device_tree.c')])
 common_ss.add(files('cpus-common.c'))
 
 subdir('softmmu')
+
+specific_ss.add(files('disas.c', 'exec.c', 'gdbstub.c'), capstone, libpmem)
+specific_ss.add(files('exec-vary.c'))
+specific_ss.add(when: 'CONFIG_TCG', if_true: files(
+  'fpu/softfloat.c',
+  'tcg/optimize.c',
+  'tcg/tcg-common.c',
+  'tcg/tcg-op-gvec.c',
+  'tcg/tcg-op-vec.c',
+  'tcg/tcg-op.c',
+  'tcg/tcg.c',
+))
+specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('disas/tci.c', 
'tcg/tci.c'))
+
 subdir('backends')
 subdir('disas')
 subdir('migration')
@@ -761,6 +787,8 @@ common_all = static_library('common',
 dependencies: common_all.dependencies(),
 name_suffix: 'fa')
 
+feature_to_c = find_program('scripts/feature_to_c.sh')
+
 foreach target : target_dirs
   config_target = config_target_mak[target]
   target_name = config_target['TARGET_NAME']
@@ -807,6 +835,15 @@ foreach target : target_dirs
 endif
   endif
 
+  if 'TARGET_XML_FILES' in config_target
+gdbstub_xml = custom_target(target + 

[PATCH 127/143] meson: bsd-user

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile.target|  3 ---
 bsd-user/Makefile.objs |  2 --
 bsd-user/meson.build   | 10 ++
 meson.build|  4 
 4 files changed, 14 insertions(+), 5 deletions(-)
 delete mode 100644 bsd-user/Makefile.objs
 create mode 100644 bsd-user/meson.build

diff --git a/Makefile.target b/Makefile.target
index a68859d..5c099fa 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -141,9 +141,6 @@ ifdef CONFIG_BSD_USER
 QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) \
 -I$(SRC_PATH)/bsd-user/$(HOST_VARIANT_DIR)
 
-obj-y += bsd-user/
-obj-y += gdbstub.o
-
 endif #CONFIG_BSD_USER
 
 #
diff --git a/bsd-user/Makefile.objs b/bsd-user/Makefile.objs
deleted file mode 100644
index 5e77f57..000
--- a/bsd-user/Makefile.objs
+++ /dev/null
@@ -1,2 +0,0 @@
-obj-y = main.o bsdload.o elfload.o mmap.o signal.o strace.o syscall.o \
-   uaccess.o
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
new file mode 100644
index 000..0369549
--- /dev/null
+++ b/bsd-user/meson.build
@@ -0,0 +1,10 @@
+bsd_user_ss.add(files(
+  'bsdload.c',
+  'elfload.c',
+  'main.c',
+  'mmap.c',
+  'signal.c',
+  'strace.c',
+  'syscall.c',
+  'uaccess.c',
+))
diff --git a/meson.build b/meson.build
index 483e65f..e1d7672 100644
--- a/meson.build
+++ b/meson.build
@@ -678,8 +678,12 @@ subdir('net')
 subdir('replay')
 subdir('hw')
 subdir('accel')
+subdir('bsd-user')
 subdir('linux-user')
 
+bsd_user_ss.add(files('gdbstub.c'))
+specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
+
 linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
 specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
 
-- 
1.8.3.1





[PATCH 113/143] meson: convert hw/gpio

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs  |  1 -
 hw/gpio/Makefile.objs | 12 
 hw/gpio/meson.build   | 12 
 hw/meson.build|  1 +
 4 files changed, 13 insertions(+), 13 deletions(-)
 delete mode 100644 hw/gpio/Makefile.objs
 create mode 100644 hw/gpio/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index a2c2f6d..c04dfe5 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -8,7 +8,6 @@ devices-dirs-y += char/
 devices-dirs-y += cpu/
 devices-dirs-y += display/
 devices-dirs-y += dma/
-devices-dirs-y += gpio/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/gpio/Makefile.objs b/hw/gpio/Makefile.objs
deleted file mode 100644
index 3cfc261..000
--- a/hw/gpio/Makefile.objs
+++ /dev/null
@@ -1,12 +0,0 @@
-common-obj-$(CONFIG_MAX7310) += max7310.o
-common-obj-$(CONFIG_PL061) += pl061.o
-common-obj-$(CONFIG_PUV3) += puv3_gpio.o
-common-obj-$(CONFIG_ZAURUS) += zaurus.o
-common-obj-$(CONFIG_E500) += mpc8xxx.o
-common-obj-$(CONFIG_GPIO_KEY) += gpio_key.o
-
-common-obj-$(CONFIG_OMAP) += omap_gpio.o
-common-obj-$(CONFIG_IMX) += imx_gpio.o
-common-obj-$(CONFIG_RASPI) += bcm2835_gpio.o
-common-obj-$(CONFIG_NRF51_SOC) += nrf51_gpio.o
-common-obj-$(CONFIG_ASPEED_SOC) += aspeed_gpio.o
diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build
new file mode 100644
index 000..6bcdfa6
--- /dev/null
+++ b/hw/gpio/meson.build
@@ -0,0 +1,12 @@
+softmmu_ss.add(when: 'CONFIG_E500', if_true: files('mpc8xxx.c'))
+softmmu_ss.add(when: 'CONFIG_GPIO_KEY', if_true: files('gpio_key.c'))
+softmmu_ss.add(when: 'CONFIG_MAX7310', if_true: files('max7310.c'))
+softmmu_ss.add(when: 'CONFIG_PL061', if_true: files('pl061.c'))
+softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_gpio.c'))
+softmmu_ss.add(when: 'CONFIG_ZAURUS', if_true: files('zaurus.c'))
+
+softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_gpio.c'))
+softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_gpio.c'))
+softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_gpio.c'))
+softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_gpio.c'))
+softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c'))
diff --git a/hw/meson.build b/hw/meson.build
index f9e5adf..52577c3 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,4 +1,5 @@
 subdir('core')
+subdir('gpio')
 subdir('hyperv')
 subdir('i2c')
 subdir('ide')
-- 
1.8.3.1





[PATCH 129/143] meson: plugins

2020-08-06 Thread Paolo Bonzini
For now link arguments end up in Makefile.target, they will move to the
right place soon.

Signed-off-by: Paolo Bonzini 
---
 Makefile  |  8 +---
 Makefile.target   | 12 ++--
 meson.build   |  5 +
 plugins/Makefile.objs | 21 -
 plugins/meson.build   |  5 +
 5 files changed, 21 insertions(+), 30 deletions(-)
 delete mode 100644 plugins/Makefile.objs
 create mode 100644 plugins/meson.build

diff --git a/Makefile b/Makefile
index 2aaa3f8..5320a06 100644
--- a/Makefile
+++ b/Makefile
@@ -419,13 +419,10 @@ endif
 
 ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
 
-install-includedir:
-   $(INSTALL_DIR) "$(DESTDIR)$(includedir)"
-
 # Needed by "meson install"
 export DESTDIR
 install: all $(if $(BUILD_DOCS),install-doc) \
-   install-datadir install-localstatedir install-includedir \
+   install-datadir install-localstatedir \
$(if $(INSTALL_BLOBS),$(edk2-decompressed)) \
recurse-install
 ifdef CONFIG_TRACE_SYSTEMTAP
@@ -468,9 +465,6 @@ endif
 ifdef CONFIG_GTK
$(MAKE) -C po $@
 endif
-ifeq ($(CONFIG_PLUGIN),y)
-   $(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h 
"$(DESTDIR)$(includedir)/qemu-plugin.h"
-endif
$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
set -e; for x in $(KEYMAPS); do \
$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x 
"$(DESTDIR)$(qemu_datadir)/keymaps"; \
diff --git a/Makefile.target b/Makefile.target
index c180b4c..2b7280b 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -110,8 +110,6 @@ obj-y += trace/
 #
 LIBS := $(libs_cpu) $(LIBS)
 
-obj-$(CONFIG_PLUGIN) += plugins/
-
 #
 # Linux user emulator target
 
@@ -153,6 +151,16 @@ LIBS := $(LIBS) $(VDE_LIBS) $(SLIRP_LIBS)
 LIBS := $(LIBS) $(LIBUSB_LIBS) $(SMARTCARD_LIBS) $(USB_REDIR_LIBS)
 LIBS := $(LIBS) $(VIRGL_LIBS) $(CURSES_LIBS)
 
+ifeq ($(CONFIG_PLUGIN),y)
+ifdef CONFIG_HAS_LD_DYNAMIC_LIST
+LIBS += -Wl,--dynamic-list=$(BUILD_DIR)/qemu-plugins-ld.symbols
+else
+ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST
+LIBS += -Wl,-exported_symbols_list,$(BUILD_DIR)/qemu-plugins-ld64.symbols
+endif
+endif
+endif
+
 generated-files-y += hmp-commands.h hmp-commands-info.h
 
 endif # CONFIG_SOFTMMU
diff --git a/meson.build b/meson.build
index 7ed8276..58f84e8 100644
--- a/meson.build
+++ b/meson.build
@@ -704,6 +704,7 @@ subdir('net')
 subdir('replay')
 subdir('hw')
 subdir('accel')
+subdir('plugins')
 subdir('bsd-user')
 subdir('linux-user')
 
@@ -872,6 +873,10 @@ endforeach
 
 # Other build targets
 
+if 'CONFIG_PLUGIN' in config_host
+  install_headers('include/qemu/qemu-plugin.h')
+endif
+
 if 'CONFIG_GUEST_AGENT' in config_host
   subdir('qga')
 endif
diff --git a/plugins/Makefile.objs b/plugins/Makefile.objs
deleted file mode 100644
index 6f14d91..000
--- a/plugins/Makefile.objs
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Plugin Support
-#
-
-obj-y += loader.o
-obj-y += core.o
-obj-y += api.o
-
-# Abuse -libs suffix to only link with --dynamic-list/-exported_symbols_list
-# when the final binary includes the plugin object.
-#
-# Note that simply setting LDFLAGS is not enough: we build binaries that
-# never link plugin.o, and the linker might fail (at least ld64 does)
-# if the symbols in the list are not in the output binary.
-ifdef CONFIG_HAS_LD_DYNAMIC_LIST
-api.o-libs := -Wl,--dynamic-list=$(BUILD_DIR)/qemu-plugins-ld.symbols
-else
-ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST
-api.o-libs := -Wl,-exported_symbols_list,$(BUILD_DIR)/qemu-plugins-ld64.symbols
-endif
-endif
diff --git a/plugins/meson.build b/plugins/meson.build
new file mode 100644
index 000..9608e52
--- /dev/null
+++ b/plugins/meson.build
@@ -0,0 +1,5 @@
+specific_ss.add(when: 'CONFIG_PLUGIN', if_true: [files(
+  'loader.c',
+  'core.c',
+  'api.c',
+)])
-- 
1.8.3.1





[PATCH 118/143] meson: convert hw/block

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs |  1 -
 hw/block/Makefile.objs   | 18 --
 hw/block/dataplane/Makefile.objs |  2 --
 hw/block/dataplane/meson.build   |  2 ++
 hw/block/meson.build | 21 +
 hw/meson.build   |  1 +
 6 files changed, 24 insertions(+), 21 deletions(-)
 delete mode 100644 hw/block/Makefile.objs
 delete mode 100644 hw/block/dataplane/Makefile.objs
 create mode 100644 hw/block/dataplane/meson.build
 create mode 100644 hw/block/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 04cfb6c..9068859 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -3,7 +3,6 @@ devices-dirs-$(call lor,$(CONFIG_VIRTIO_9P),$(call 
land,$(CONFIG_VIRTFS),$(CONFI
 devices-dirs-y += acpi/
 devices-dirs-y += adc/
 devices-dirs-y += audio/
-devices-dirs-y += block/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs
deleted file mode 100644
index 8855c22..000
--- a/hw/block/Makefile.objs
+++ /dev/null
@@ -1,18 +0,0 @@
-common-obj-y += block.o cdrom.o hd-geometry.o
-common-obj-$(CONFIG_FDC) += fdc.o
-common-obj-$(CONFIG_SSI_M25P80) += m25p80.o
-common-obj-$(CONFIG_NAND) += nand.o
-common-obj-$(CONFIG_PFLASH_CFI01) += pflash_cfi01.o
-common-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o
-common-obj-$(CONFIG_XEN) += xen-block.o
-common-obj-$(CONFIG_ECC) += ecc.o
-common-obj-$(CONFIG_ONENAND) += onenand.o
-common-obj-$(CONFIG_SWIM) += swim.o
-
-common-obj-$(CONFIG_SH4) += tc58128.o
-
-obj-$(CONFIG_VIRTIO_BLK) += virtio-blk.o
-obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk.o
-common-obj-$(CONFIG_NVME_PCI) += nvme.o
-
-obj-y += dataplane/
diff --git a/hw/block/dataplane/Makefile.objs b/hw/block/dataplane/Makefile.objs
deleted file mode 100644
index 0c52702..000
--- a/hw/block/dataplane/Makefile.objs
+++ /dev/null
@@ -1,2 +0,0 @@
-obj-$(CONFIG_VIRTIO_BLK) += virtio-blk.o
-obj-$(CONFIG_XEN) += xen-block.o
diff --git a/hw/block/dataplane/meson.build b/hw/block/dataplane/meson.build
new file mode 100644
index 000..12c6a26
--- /dev/null
+++ b/hw/block/dataplane/meson.build
@@ -0,0 +1,2 @@
+specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
+specific_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
diff --git a/hw/block/meson.build b/hw/block/meson.build
new file mode 100644
index 000..78cad8f
--- /dev/null
+++ b/hw/block/meson.build
@@ -0,0 +1,21 @@
+softmmu_ss.add(files(
+  'block.c',
+  'cdrom.c',
+  'hd-geometry.c'
+))
+softmmu_ss.add(when: 'CONFIG_ECC', if_true: files('ecc.c'))
+softmmu_ss.add(when: 'CONFIG_FDC', if_true: files('fdc.c'))
+softmmu_ss.add(when: 'CONFIG_NAND', if_true: files('nand.c'))
+softmmu_ss.add(when: 'CONFIG_ONENAND', if_true: files('onenand.c'))
+softmmu_ss.add(when: 'CONFIG_PFLASH_CFI01', if_true: files('pflash_cfi01.c'))
+softmmu_ss.add(when: 'CONFIG_PFLASH_CFI02', if_true: files('pflash_cfi02.c'))
+softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80.c'))
+softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c'))
+softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
+softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('tc58128.c'))
+softmmu_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('nvme.c'))
+
+specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
+specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: 
files('vhost-user-blk.c'))
+
+subdir('dataplane')
diff --git a/hw/meson.build b/hw/meson.build
index dd0c77e..f968aa8 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,3 +1,4 @@
+subdir('block')
 subdir('char')
 subdir('core')
 subdir('cpu')
-- 
1.8.3.1





[PATCH 108/143] meson: convert hw/intc

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs  |  1 -
 hw/intc/Makefile.objs | 54 --
 hw/intc/meson.build   | 55 +++
 hw/meson.build|  1 +
 4 files changed, 56 insertions(+), 55 deletions(-)
 delete mode 100644 hw/intc/Makefile.objs
 create mode 100644 hw/intc/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 76d9305..80b1041 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -13,7 +13,6 @@ devices-dirs-$(CONFIG_HYPERV) += hyperv/
 devices-dirs-$(CONFIG_I2C) += i2c/
 devices-dirs-y += ide/
 devices-dirs-y += input/
-devices-dirs-y += intc/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/intc/Makefile.objs b/hw/intc/Makefile.objs
deleted file mode 100644
index 3ac2b40..000
--- a/hw/intc/Makefile.objs
+++ /dev/null
@@ -1,54 +0,0 @@
-common-obj-$(CONFIG_HEATHROW_PIC) += heathrow_pic.o
-common-obj-$(CONFIG_I8259) += i8259_common.o i8259.o
-common-obj-$(CONFIG_PL190) += pl190.o
-common-obj-$(CONFIG_PUV3) += puv3_intc.o
-common-obj-$(CONFIG_XILINX) += xilinx_intc.o
-common-obj-$(CONFIG_XLNX_ZYNQMP_PMU) += xlnx-pmu-iomod-intc.o
-common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-ipi.o
-common-obj-$(CONFIG_ETRAXFS) += etraxfs_pic.o
-common-obj-$(CONFIG_IMX) += imx_avic.o imx_gpcv2.o
-common-obj-$(CONFIG_LM32) += lm32_pic.o
-common-obj-$(CONFIG_REALVIEW) += realview_gic.o
-common-obj-$(CONFIG_SLAVIO) += slavio_intctl.o
-common-obj-$(CONFIG_IOAPIC) += ioapic_common.o
-common-obj-$(CONFIG_ARM_GIC) += arm_gic_common.o
-common-obj-$(CONFIG_ARM_GIC) += arm_gic.o
-common-obj-$(CONFIG_ARM_GIC) += arm_gicv2m.o
-common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_common.o
-common-obj-$(CONFIG_ARM_GIC) += arm_gicv3.o
-common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_dist.o
-common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_redist.o
-common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_its_common.o
-common-obj-$(CONFIG_OPENPIC) += openpic.o
-common-obj-$(CONFIG_RX_ICU) += rx_icu.o
-common-obj-y += intc.o
-
-obj-$(CONFIG_APIC) += apic.o apic_common.o
-obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o
-obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_kvm.o
-obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_its_kvm.o
-obj-$(CONFIG_ARM_V7M) += armv7m_nvic.o
-obj-$(CONFIG_EXYNOS4) += exynos4210_gic.o exynos4210_combiner.o
-obj-$(CONFIG_GRLIB) += grlib_irqmp.o
-obj-$(CONFIG_IOAPIC) += ioapic.o
-obj-$(CONFIG_OMAP) += omap_intc.o
-obj-$(CONFIG_OPENPIC_KVM) += openpic_kvm.o
-obj-$(CONFIG_RASPI) += bcm2835_ic.o bcm2836_control.o
-obj-$(CONFIG_SH4) += sh_intc.o
-obj-$(CONFIG_XICS) += xics.o
-obj-$(CONFIG_XICS_SPAPR) += xics_spapr.o
-obj-$(CONFIG_XICS_KVM) += xics_kvm.o
-obj-$(CONFIG_XIVE) += xive.o
-obj-$(CONFIG_XIVE_SPAPR) += spapr_xive.o
-obj-$(CONFIG_XIVE_KVM) += spapr_xive_kvm.o
-obj-$(CONFIG_POWERNV) += xics_pnv.o pnv_xive.o
-obj-$(CONFIG_ALLWINNER_A10_PIC) += allwinner-a10-pic.o
-obj-$(CONFIG_S390_FLIC) += s390_flic.o
-obj-$(CONFIG_S390_FLIC_KVM) += s390_flic_kvm.o
-obj-$(CONFIG_ASPEED_SOC) += aspeed_vic.o
-obj-$(CONFIG_ARM_GIC) += arm_gicv3_cpuif.o
-obj-$(CONFIG_MIPS_CPS) += mips_gic.o
-obj-$(CONFIG_NIOS2) += nios2_iic.o
-obj-$(CONFIG_OMPIC) += ompic.o
-obj-$(CONFIG_IBEX) += ibex_plic.o
-obj-$(CONFIG_LOONGSON_LIOINTC) += loongson_liointc.o
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
new file mode 100644
index 000..c16f7f0
--- /dev/null
+++ b/hw/intc/meson.build
@@ -0,0 +1,55 @@
+softmmu_ss.add(files('intc.c'))
+softmmu_ss.add(when: 'CONFIG_ARM_GIC', if_true: files(
+  'arm_gic.c',
+  'arm_gic_common.c',
+  'arm_gicv2m.c',
+  'arm_gicv3.c',
+  'arm_gicv3_common.c',
+  'arm_gicv3_dist.c',
+  'arm_gicv3_its_common.c',
+  'arm_gicv3_redist.c',
+))
+softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_pic.c'))
+softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true: files('heathrow_pic.c'))
+softmmu_ss.add(when: 'CONFIG_I8259', if_true: files('i8259_common.c', 
'i8259.c'))
+softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_avic.c', 'imx_gpcv2.c'))
+softmmu_ss.add(when: 'CONFIG_IOAPIC', if_true: files('ioapic_common.c'))
+softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_pic.c'))
+softmmu_ss.add(when: 'CONFIG_OPENPIC', if_true: files('openpic.c'))
+softmmu_ss.add(when: 'CONFIG_PL190', if_true: files('pl190.c'))
+softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_intc.c'))
+softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview_gic.c'))
+softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_intctl.c'))
+softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_intc.c'))
+softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP', if_true: files('xlnx-zynqmp-ipi.c'))
+softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: 
files('xlnx-pmu-iomod-intc.c'))
+
+specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: 
files('allwinner-a10-pic.c'))
+specific_ss.add(when: 'CONFIG_APIC', 

[PATCH 126/143] meson: linux-user

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile.target |  3 ---
 configure   | 27 ---
 linux-user/Makefile.objs| 25 -
 linux-user/alpha/Makefile.objs  |  5 -
 linux-user/alpha/meson.build|  5 +
 linux-user/arm/Makefile.objs|  8 
 linux-user/arm/meson.build  | 10 ++
 linux-user/arm/nwfpe/Makefile.objs  |  2 --
 linux-user/arm/nwfpe/meson.build| 10 ++
 linux-user/hppa/Makefile.objs   |  5 -
 linux-user/hppa/meson.build |  5 +
 linux-user/i386/Makefile.objs   |  5 -
 linux-user/i386/meson.build |  5 +
 linux-user/i386/syscall_nr.h|  1 +
 linux-user/m68k/Makefile.objs   |  5 -
 linux-user/m68k/meson.build |  5 +
 linux-user/meson.build  | 37 +
 linux-user/microblaze/Makefile.objs |  5 -
 linux-user/microblaze/meson.build   |  5 +
 linux-user/mips/Makefile.objs   |  5 -
 linux-user/mips/meson.build |  5 +
 linux-user/mips/syscall_nr.h|  1 +
 linux-user/mips64/Makefile.objs | 12 
 linux-user/mips64/meson.build   |  6 ++
 linux-user/mips64/syscall_nr.h  |  7 +++
 linux-user/ppc/Makefile.objs|  6 --
 linux-user/ppc/meson.build  |  5 +
 linux-user/s390x/Makefile.objs  |  5 -
 linux-user/s390x/meson.build|  5 +
 linux-user/sh4/Makefile.objs|  5 -
 linux-user/sh4/meson.build  |  5 +
 linux-user/sparc/Makefile.objs  |  5 -
 linux-user/sparc/meson.build|  5 +
 linux-user/sparc64/Makefile.objs|  5 -
 linux-user/sparc64/meson.build  |  5 +
 linux-user/x86_64/Makefile.objs |  5 -
 linux-user/x86_64/meson.build   |  5 +
 linux-user/x86_64/syscall_nr.h  |  1 +
 linux-user/xtensa/Makefile.objs |  5 -
 linux-user/xtensa/meson.build   |  5 +
 meson.build | 16 +++-
 41 files changed, 165 insertions(+), 132 deletions(-)
 delete mode 100644 linux-user/Makefile.objs
 delete mode 100644 linux-user/alpha/Makefile.objs
 create mode 100644 linux-user/alpha/meson.build
 delete mode 100644 linux-user/arm/Makefile.objs
 create mode 100644 linux-user/arm/meson.build
 delete mode 100644 linux-user/arm/nwfpe/Makefile.objs
 create mode 100644 linux-user/arm/nwfpe/meson.build
 delete mode 100644 linux-user/hppa/Makefile.objs
 create mode 100644 linux-user/hppa/meson.build
 delete mode 100644 linux-user/i386/Makefile.objs
 create mode 100644 linux-user/i386/meson.build
 create mode 100644 linux-user/i386/syscall_nr.h
 delete mode 100644 linux-user/m68k/Makefile.objs
 create mode 100644 linux-user/m68k/meson.build
 create mode 100644 linux-user/meson.build
 delete mode 100644 linux-user/microblaze/Makefile.objs
 create mode 100644 linux-user/microblaze/meson.build
 delete mode 100644 linux-user/mips/Makefile.objs
 create mode 100644 linux-user/mips/meson.build
 create mode 100644 linux-user/mips/syscall_nr.h
 delete mode 100644 linux-user/mips64/Makefile.objs
 create mode 100644 linux-user/mips64/meson.build
 create mode 100644 linux-user/mips64/syscall_nr.h
 delete mode 100644 linux-user/ppc/Makefile.objs
 create mode 100644 linux-user/ppc/meson.build
 delete mode 100644 linux-user/s390x/Makefile.objs
 create mode 100644 linux-user/s390x/meson.build
 delete mode 100644 linux-user/sh4/Makefile.objs
 create mode 100644 linux-user/sh4/meson.build
 delete mode 100644 linux-user/sparc/Makefile.objs
 create mode 100644 linux-user/sparc/meson.build
 delete mode 100644 linux-user/sparc64/Makefile.objs
 create mode 100644 linux-user/sparc64/meson.build
 delete mode 100644 linux-user/x86_64/Makefile.objs
 create mode 100644 linux-user/x86_64/meson.build
 create mode 100644 linux-user/x86_64/syscall_nr.h
 delete mode 100644 linux-user/xtensa/Makefile.objs
 create mode 100644 linux-user/xtensa/meson.build

diff --git a/Makefile.target b/Makefile.target
index 8633e2b..a68859d 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -131,9 +131,6 @@ QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) \
  -I$(SRC_PATH)/linux-user \
  -Ilinux-user/$(TARGET_ABI_DIR)
 
-obj-y += linux-user/
-obj-y += gdbstub.o thunk.o
-
 endif #CONFIG_LINUX_USER
 
 #
diff --git a/configure b/configure
index 3483d6c..525f415 100755
--- a/configure
+++ b/configure
@@ -1945,20 +1945,6 @@ fi
 # Remove old dependency files to make sure that they get properly regenerated
 rm -f */config-devices.mak.d
 
-# Remove syscall_nr.h to be sure they will be regenerated in the build
-# directory, not in the source directory
-for arch in alpha hppa m68k xtensa sh4 microblaze arm ppc s390x sparc sparc64 \
-i386 x86_64 mips mips64 ; do
-   

[PATCH 124/143] meson: target

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile.target |  3 +-
 libdecnumber/Makefile.objs  |  5 ---
 libdecnumber/meson.build|  7 
 meson.build | 11 +
 scripts/decodetree.py   |  2 +-
 target/alpha/Makefile.objs  |  4 --
 target/alpha/meson.build| 18 +
 target/arm/Makefile.objs| 89 -
 target/arm/meson.build  | 62 
 target/avr/Makefile.objs| 34 
 target/avr/disas.c  |  2 +-
 target/avr/meson.build  | 20 +
 target/avr/translate.c  |  2 +-
 target/cris/Makefile.objs   |  3 --
 target/cris/meson.build | 14 +++
 target/hppa/Makefile.objs   | 11 -
 target/hppa/meson.build | 19 +
 target/hppa/translate.c |  2 +-
 target/i386/Makefile.objs   | 23 ---
 target/i386/hvf/Makefile.objs   |  2 -
 target/i386/hvf/meson.build | 12 ++
 target/i386/meson.build | 40 ++
 target/lm32/Makefile.objs   |  4 --
 target/lm32/meson.build | 15 +++
 target/m68k/Makefile.objs   |  5 ---
 target/m68k/meson.build | 17 
 target/meson.build  | 22 ++
 target/microblaze/Makefile.objs |  3 --
 target/microblaze/meson.build   | 14 +++
 target/mips/Makefile.objs   |  6 ---
 target/mips/meson.build | 24 +++
 target/moxie/Makefile.objs  |  2 -
 target/moxie/meson.build| 14 +++
 target/nios2/Makefile.objs  |  4 --
 target/nios2/meson.build| 15 +++
 target/openrisc/Makefile.objs   | 15 ---
 target/openrisc/disas.c |  2 +-
 target/openrisc/meson.build | 23 +++
 target/openrisc/translate.c |  2 +-
 target/ppc/Makefile.objs| 20 -
 target/ppc/meson.build  | 37 +
 target/riscv/Makefile.objs  | 28 -
 target/riscv/meson.build| 34 
 target/riscv/translate.c|  4 +-
 target/rx/Makefile.objs | 11 -
 target/rx/disas.c   |  2 +-
 target/rx/meson.build   | 16 
 target/rx/translate.c   |  2 +-
 target/s390x/Makefile.objs  | 10 -
 target/s390x/meson.build| 42 ++-
 target/sh4/Makefile.objs|  3 --
 target/sh4/meson.build  | 14 +++
 target/sparc/Makefile.objs  |  7 
 target/sparc/meson.build| 23 +++
 target/tilegx/Makefile.objs |  1 -
 target/tilegx/meson.build   | 13 ++
 target/tricore/Makefile.objs|  1 -
 target/tricore/meson.build  | 15 +++
 target/unicore32/Makefile.objs  |  8 
 target/unicore32/meson.build| 14 +++
 target/xtensa/Makefile.objs | 16 
 target/xtensa/meson.build   | 30 ++
 62 files changed, 595 insertions(+), 328 deletions(-)
 delete mode 100644 libdecnumber/Makefile.objs
 create mode 100644 libdecnumber/meson.build
 delete mode 100644 target/alpha/Makefile.objs
 create mode 100644 target/alpha/meson.build
 delete mode 100644 target/arm/Makefile.objs
 create mode 100644 target/arm/meson.build
 delete mode 100644 target/avr/Makefile.objs
 create mode 100644 target/avr/meson.build
 delete mode 100644 target/cris/Makefile.objs
 create mode 100644 target/cris/meson.build
 delete mode 100644 target/hppa/Makefile.objs
 create mode 100644 target/hppa/meson.build
 delete mode 100644 target/i386/Makefile.objs
 delete mode 100644 target/i386/hvf/Makefile.objs
 create mode 100644 target/i386/hvf/meson.build
 create mode 100644 target/i386/meson.build
 delete mode 100644 target/lm32/Makefile.objs
 create mode 100644 target/lm32/meson.build
 delete mode 100644 target/m68k/Makefile.objs
 create mode 100644 target/m68k/meson.build
 delete mode 100644 target/microblaze/Makefile.objs
 create mode 100644 target/microblaze/meson.build
 delete mode 100644 target/mips/Makefile.objs
 create mode 100644 target/mips/meson.build
 delete mode 100644 target/moxie/Makefile.objs
 create mode 100644 target/moxie/meson.build
 delete mode 100644 target/nios2/Makefile.objs
 create mode 100644 target/nios2/meson.build
 delete mode 100644 target/openrisc/Makefile.objs
 create mode 100644 target/openrisc/meson.build
 delete mode 100644 target/ppc/Makefile.objs
 create mode 100644 target/ppc/meson.build
 delete mode 100644 target/riscv/Makefile.objs
 create mode 100644 target/riscv/meson.build
 delete mode 100644 target/rx/Makefile.objs
 create mode 100644 target/rx/meson.build
 delete mode 100644 target/s390x/Makefile.objs
 delete mode 100644 target/sh4/Makefile.objs
 create mode 100644 target/sh4/meson.build
 delete mode 100644 target/sparc/Makefile.objs
 create mode 100644 target/sparc/meson.build
 delete mode 100644 target/tilegx/Makefile.objs
 create mode 100644 target/tilegx/meson.build
 delete mode 

[PATCH 125/143] meson: accel

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile.objs |  2 +-
 Makefile.target   |  1 -
 accel/Makefile.objs   |  6 --
 accel/kvm/Makefile.objs   |  2 --
 accel/kvm/meson.build |  5 +
 accel/meson.build |  7 +++
 accel/stubs/Makefile.objs |  6 --
 accel/stubs/meson.build   |  6 ++
 accel/tcg/Makefile.objs   |  9 -
 accel/tcg/meson.build | 15 +++
 accel/xen/Makefile.objs   |  1 -
 accel/xen/meson.build |  1 +
 meson.build   |  1 +
 13 files changed, 36 insertions(+), 26 deletions(-)
 delete mode 100644 accel/Makefile.objs
 delete mode 100644 accel/kvm/Makefile.objs
 create mode 100644 accel/kvm/meson.build
 create mode 100644 accel/meson.build
 delete mode 100644 accel/stubs/Makefile.objs
 create mode 100644 accel/stubs/meson.build
 delete mode 100644 accel/tcg/Makefile.objs
 create mode 100644 accel/tcg/meson.build
 delete mode 100644 accel/xen/Makefile.objs
 create mode 100644 accel/xen/meson.build

diff --git a/Makefile.objs b/Makefile.objs
index 7eaf047..40e23a2 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -38,7 +38,7 @@ endif # CONFIG_SOFTMMU or CONFIG_TOOLS
 # single QEMU executable should support all CPUs and machines.
 
 ifeq ($(CONFIG_SOFTMMU),y)
-common-obj-y = accel/
+common-obj-y =
 
 common-obj-$(CONFIG_AUDIO_ALSA) += audio-alsa$(DSOSUF)
 common-obj-$(CONFIG_AUDIO_OSS) += audio-oss$(DSOSUF)
diff --git a/Makefile.target b/Makefile.target
index 1ab8773..8633e2b 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -110,7 +110,6 @@ obj-y += trace/
 #
 # cpu emulator library
 obj-y += exec.o exec-vary.o
-obj-y += accel/
 obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-gvec.o
 obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o
 obj-$(CONFIG_TCG_INTERPRETER) += tcg/tci.o
diff --git a/accel/Makefile.objs b/accel/Makefile.objs
deleted file mode 100644
index ff72f0d..000
--- a/accel/Makefile.objs
+++ /dev/null
@@ -1,6 +0,0 @@
-common-obj-$(CONFIG_SOFTMMU) += accel.o
-obj-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_POSIX)) += qtest.o
-obj-$(CONFIG_KVM) += kvm/
-obj-$(CONFIG_TCG) += tcg/
-obj-$(CONFIG_XEN) += xen/
-obj-y += stubs/
diff --git a/accel/kvm/Makefile.objs b/accel/kvm/Makefile.objs
deleted file mode 100644
index fdfa481..000
--- a/accel/kvm/Makefile.objs
+++ /dev/null
@@ -1,2 +0,0 @@
-obj-y += kvm-all.o
-obj-$(call lnot,$(CONFIG_SEV)) += sev-stub.o
diff --git a/accel/kvm/meson.build b/accel/kvm/meson.build
new file mode 100644
index 000..4db2388
--- /dev/null
+++ b/accel/kvm/meson.build
@@ -0,0 +1,5 @@
+kvm_ss = ss.source_set()
+kvm_ss.add(files('kvm-all.c'))
+kvm_ss.add(when: 'CONFIG_SEV', if_false: files('sev-stub.c'))
+
+specific_ss.add_all(when: 'CONFIG_KVM', if_true: kvm_ss)
diff --git a/accel/meson.build b/accel/meson.build
new file mode 100644
index 000..26c503e
--- /dev/null
+++ b/accel/meson.build
@@ -0,0 +1,7 @@
+softmmu_ss.add(files('accel.c'))
+specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: 
files('qtest.c'))
+
+subdir('kvm')
+subdir('tcg')
+subdir('xen')
+subdir('stubs')
diff --git a/accel/stubs/Makefile.objs b/accel/stubs/Makefile.objs
deleted file mode 100644
index bbd14e7..000
--- a/accel/stubs/Makefile.objs
+++ /dev/null
@@ -1,6 +0,0 @@
-obj-$(call lnot,$(CONFIG_HAX))  += hax-stub.o
-obj-$(call lnot,$(CONFIG_HVF))  += hvf-stub.o
-obj-$(call lnot,$(CONFIG_WHPX)) += whpx-stub.o
-obj-$(call lnot,$(CONFIG_KVM))  += kvm-stub.o
-obj-$(call lnot,$(CONFIG_TCG))  += tcg-stub.o
-obj-$(call lnot,$(CONFIG_XEN))  += xen-stub.o
diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
new file mode 100644
index 000..314e3cf
--- /dev/null
+++ b/accel/stubs/meson.build
@@ -0,0 +1,6 @@
+specific_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c'))
+specific_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
+specific_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
+specific_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
+specific_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
+specific_ss.add(when: 'CONFIG_WHPX', if_false: files('whpx-stub.c'))
diff --git a/accel/tcg/Makefile.objs b/accel/tcg/Makefile.objs
deleted file mode 100644
index a92f2c4..000
--- a/accel/tcg/Makefile.objs
+++ /dev/null
@@ -1,9 +0,0 @@
-obj-$(CONFIG_SOFTMMU) += tcg-all.o
-obj-$(CONFIG_SOFTMMU) += cputlb.o
-obj-y += tcg-runtime.o tcg-runtime-gvec.o
-obj-y += cpu-exec.o cpu-exec-common.o translate-all.o
-obj-y += translator.o
-
-obj-$(CONFIG_USER_ONLY) += user-exec.o
-obj-$(call lnot,$(CONFIG_SOFTMMU)) += user-exec-stub.o
-obj-$(CONFIG_PLUGIN) += plugin-gen.o
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
new file mode 100644
index 000..2a335b5
--- /dev/null
+++ b/accel/tcg/meson.build
@@ -0,0 +1,15 @@
+tcg_ss = ss.source_set()
+tcg_ss.add(files(
+  'cpu-exec-common.c',
+  

[PATCH 116/143] meson: convert hw/cpu

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs | 1 -
 hw/cpu/Makefile.objs | 5 -
 hw/cpu/meson.build   | 6 ++
 hw/meson.build   | 1 +
 4 files changed, 7 insertions(+), 6 deletions(-)
 delete mode 100644 hw/cpu/Makefile.objs
 create mode 100644 hw/cpu/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 6fce6a1..97ad302 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -5,7 +5,6 @@ devices-dirs-y += adc/
 devices-dirs-y += audio/
 devices-dirs-y += block/
 devices-dirs-y += char/
-devices-dirs-y += cpu/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs
deleted file mode 100644
index 8db9e8a..000
--- a/hw/cpu/Makefile.objs
+++ /dev/null
@@ -1,5 +0,0 @@
-obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o
-obj-$(CONFIG_REALVIEW) += realview_mpcore.o
-obj-$(CONFIG_A9MPCORE) += a9mpcore.o
-obj-$(CONFIG_A15MPCORE) += a15mpcore.o
-common-obj-y += core.o cluster.o
diff --git a/hw/cpu/meson.build b/hw/cpu/meson.build
new file mode 100644
index 000..9e52fee
--- /dev/null
+++ b/hw/cpu/meson.build
@@ -0,0 +1,6 @@
+softmmu_ss.add(files('core.c', 'cluster.c'))
+
+specific_ss.add(when: 'CONFIG_ARM11MPCORE', if_true: files('arm11mpcore.c'))
+specific_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview_mpcore.c'))
+specific_ss.add(when: 'CONFIG_A9MPCORE', if_true: files('a9mpcore.c'))
+specific_ss.add(when: 'CONFIG_A15MPCORE', if_true: files('a15mpcore.c'))
diff --git a/hw/meson.build b/hw/meson.build
index dacd26c..103da48 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,4 +1,5 @@
 subdir('core')
+subdir('cpu')
 subdir('display')
 subdir('dma')
 subdir('gpio')
-- 
1.8.3.1





[PATCH 105/143] meson: convert hw/isa

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs |  1 -
 hw/isa/Makefile.objs | 11 ---
 hw/isa/meson.build   | 11 +++
 hw/meson.build   |  1 +
 4 files changed, 12 insertions(+), 12 deletions(-)
 delete mode 100644 hw/isa/Makefile.objs
 create mode 100644 hw/isa/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index ac8278e..a28e211 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -16,7 +16,6 @@ devices-dirs-y += input/
 devices-dirs-y += intc/
 devices-dirs-$(CONFIG_IPACK) += ipack/
 devices-dirs-$(CONFIG_IPMI) += ipmi/
-devices-dirs-y += isa/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/isa/Makefile.objs b/hw/isa/Makefile.objs
deleted file mode 100644
index 8e73960..000
--- a/hw/isa/Makefile.objs
+++ /dev/null
@@ -1,11 +0,0 @@
-common-obj-$(CONFIG_ISA_BUS) += isa-bus.o
-common-obj-$(CONFIG_ISA_SUPERIO) += isa-superio.o
-common-obj-$(CONFIG_APM) += apm.o
-common-obj-$(CONFIG_I82378) += i82378.o
-common-obj-$(CONFIG_PC87312) += pc87312.o
-common-obj-$(CONFIG_PIIX3) += piix3.o
-common-obj-$(CONFIG_PIIX4) += piix4.o
-common-obj-$(CONFIG_VT82C686) += vt82c686.o
-common-obj-$(CONFIG_SMC37C669) += smc37c669-superio.o
-
-obj-$(CONFIG_LPC_ICH9) += lpc_ich9.o
diff --git a/hw/isa/meson.build b/hw/isa/meson.build
new file mode 100644
index 000..8bf678c
--- /dev/null
+++ b/hw/isa/meson.build
@@ -0,0 +1,11 @@
+softmmu_ss.add(when: 'CONFIG_APM', if_true: files('apm.c'))
+softmmu_ss.add(when: 'CONFIG_I82378', if_true: files('i82378.c'))
+softmmu_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('isa-bus.c'))
+softmmu_ss.add(when: 'CONFIG_ISA_SUPERIO', if_true: files('isa-superio.c'))
+softmmu_ss.add(when: 'CONFIG_PC87312', if_true: files('pc87312.c'))
+softmmu_ss.add(when: 'CONFIG_PIIX3', if_true: files('piix3.c'))
+softmmu_ss.add(when: 'CONFIG_PIIX4', if_true: files('piix4.c'))
+softmmu_ss.add(when: 'CONFIG_SMC37C669', if_true: files('smc37c669-superio.c'))
+softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('vt82c686.c'))
+
+specific_ss.add(when: 'CONFIG_LPC_ICH9', if_true: files('lpc_ich9.c'))
diff --git a/hw/meson.build b/hw/meson.build
index 6ca82b0..8659854 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,4 +1,5 @@
 subdir('core')
+subdir('isa')
 subdir('mem')
 subdir('misc')
 subdir('net')
-- 
1.8.3.1





[PATCH 123/143] meson: convert hw/arch*

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile.target |  7 
 hw/alpha/Makefile.objs  |  1 -
 hw/alpha/meson.build|  8 +
 hw/arm/Makefile.objs| 56 ---
 hw/arm/meson.build  | 59 +
 hw/avr/Makefile.objs|  3 --
 hw/avr/meson.build  |  6 
 hw/cris/Makefile.objs   |  2 --
 hw/cris/meson.build |  5 +++
 hw/hppa/Makefile.objs   |  1 -
 hw/hppa/meson.build |  4 +++
 hw/i386/Makefile.objs   | 20 
 hw/i386/kvm/Makefile.objs   |  5 ---
 hw/i386/kvm/meson.build |  8 +
 hw/i386/meson.build | 32 ++
 hw/i386/xen/Makefile.objs   |  1 -
 hw/i386/xen/meson.build |  7 
 hw/lm32/Makefile.objs   |  3 --
 hw/lm32/meson.build |  6 
 hw/m68k/Makefile.objs   |  4 ---
 hw/m68k/meson.build |  7 
 hw/meson.build  | 25 ++
 hw/microblaze/Makefile.objs |  4 ---
 hw/microblaze/meson.build   |  7 
 hw/mips/Makefile.objs   |  8 -
 hw/mips/meson.build | 11 +++
 hw/moxie/Makefile.objs  |  2 --
 hw/moxie/meson.build|  4 +++
 hw/nios2/Makefile.objs  |  3 --
 hw/nios2/meson.build|  6 
 hw/openrisc/Makefile.objs   |  2 --
 hw/openrisc/meson.build |  5 +++
 hw/ppc/Makefile.objs| 35 
 hw/ppc/meson.build  | 80 +
 hw/riscv/Makefile.objs  | 16 -
 hw/riscv/meson.build| 19 +++
 hw/rx/Makefile.objs |  2 --
 hw/rx/meson.build   |  5 +++
 hw/s390x/Makefile.objs  | 37 -
 hw/s390x/meson.build| 46 ++
 hw/sh4/Makefile.objs|  4 ---
 hw/sh4/meson.build  | 10 ++
 hw/sparc/Makefile.objs  |  3 --
 hw/sparc/meson.build|  6 
 hw/sparc64/Makefile.objs|  4 ---
 hw/sparc64/meson.build  |  6 
 hw/tricore/Makefile.objs|  1 -
 hw/tricore/meson.build  |  4 +++
 hw/unicore32/Makefile.objs  |  4 ---
 hw/unicore32/meson.build|  5 +++
 hw/xenpv/Makefile.objs  |  2 --
 hw/xenpv/meson.build|  3 ++
 hw/xtensa/Makefile.objs |  6 
 hw/xtensa/meson.build   | 11 +++
 meson.build |  4 +++
 55 files changed, 399 insertions(+), 236 deletions(-)
 delete mode 100644 hw/alpha/Makefile.objs
 create mode 100644 hw/alpha/meson.build
 delete mode 100644 hw/arm/Makefile.objs
 create mode 100644 hw/arm/meson.build
 delete mode 100644 hw/avr/Makefile.objs
 create mode 100644 hw/avr/meson.build
 delete mode 100644 hw/cris/Makefile.objs
 create mode 100644 hw/cris/meson.build
 delete mode 100644 hw/hppa/Makefile.objs
 create mode 100644 hw/hppa/meson.build
 delete mode 100644 hw/i386/Makefile.objs
 delete mode 100644 hw/i386/kvm/Makefile.objs
 create mode 100644 hw/i386/kvm/meson.build
 create mode 100644 hw/i386/meson.build
 delete mode 100644 hw/i386/xen/Makefile.objs
 create mode 100644 hw/i386/xen/meson.build
 delete mode 100644 hw/lm32/Makefile.objs
 create mode 100644 hw/lm32/meson.build
 delete mode 100644 hw/m68k/Makefile.objs
 create mode 100644 hw/m68k/meson.build
 delete mode 100644 hw/microblaze/Makefile.objs
 create mode 100644 hw/microblaze/meson.build
 delete mode 100644 hw/mips/Makefile.objs
 create mode 100644 hw/mips/meson.build
 delete mode 100644 hw/moxie/Makefile.objs
 create mode 100644 hw/moxie/meson.build
 delete mode 100644 hw/nios2/Makefile.objs
 create mode 100644 hw/nios2/meson.build
 delete mode 100644 hw/openrisc/Makefile.objs
 create mode 100644 hw/openrisc/meson.build
 delete mode 100644 hw/ppc/Makefile.objs
 create mode 100644 hw/ppc/meson.build
 delete mode 100644 hw/riscv/Makefile.objs
 create mode 100644 hw/riscv/meson.build
 delete mode 100644 hw/rx/Makefile.objs
 create mode 100644 hw/rx/meson.build
 delete mode 100644 hw/s390x/Makefile.objs
 create mode 100644 hw/s390x/meson.build
 delete mode 100644 hw/sh4/Makefile.objs
 create mode 100644 hw/sh4/meson.build
 delete mode 100644 hw/sparc/Makefile.objs
 create mode 100644 hw/sparc/meson.build
 delete mode 100644 hw/sparc64/Makefile.objs
 create mode 100644 hw/sparc64/meson.build
 delete mode 100644 hw/tricore/Makefile.objs
 create mode 100644 hw/tricore/meson.build
 delete mode 100644 hw/unicore32/Makefile.objs
 create mode 100644 hw/unicore32/meson.build
 delete mode 100644 hw/xenpv/Makefile.objs
 create mode 100644 hw/xenpv/meson.build
 delete mode 100644 hw/xtensa/Makefile.objs
 create mode 100644 hw/xtensa/meson.build

diff --git a/Makefile.target b/Makefile.target
index c95e0de..28cefba 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -170,13 +170,6 @@ LIBS := $(LIBS) $(VDE_LIBS) $(SLIRP_LIBS)
 LIBS := $(LIBS) $(LIBUSB_LIBS) $(SMARTCARD_LIBS) $(USB_REDIR_LIBS)
 LIBS := $(LIBS) $(VIRGL_LIBS)
 
-# Hardware support
-ifeq ($(TARGET_NAME), sparc64)
-obj-y += 

[PATCH 117/143] meson: convert hw/char

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs  |  1 -
 hw/char/Makefile.objs | 39 ---
 hw/char/meson.build   | 38 ++
 hw/meson.build|  1 +
 4 files changed, 39 insertions(+), 40 deletions(-)
 delete mode 100644 hw/char/Makefile.objs
 create mode 100644 hw/char/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 97ad302..04cfb6c 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -4,7 +4,6 @@ devices-dirs-y += acpi/
 devices-dirs-y += adc/
 devices-dirs-y += audio/
 devices-dirs-y += block/
-devices-dirs-y += char/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/char/Makefile.objs b/hw/char/Makefile.objs
deleted file mode 100644
index bf177ac..000
--- a/hw/char/Makefile.objs
+++ /dev/null
@@ -1,39 +0,0 @@
-common-obj-$(CONFIG_IPACK) += ipoctal232.o
-common-obj-$(CONFIG_ESCC) += escc.o
-common-obj-$(CONFIG_NRF51_SOC) += nrf51_uart.o
-common-obj-$(CONFIG_PARALLEL) += parallel.o
-common-obj-$(CONFIG_ISA_BUS) += parallel-isa.o
-common-obj-$(CONFIG_PL011) += pl011.o
-common-obj-$(CONFIG_SERIAL) += serial.o
-common-obj-$(CONFIG_SERIAL_ISA) += serial-isa.o
-common-obj-$(CONFIG_SERIAL_PCI) += serial-pci.o
-common-obj-$(CONFIG_SERIAL_PCI_MULTI) += serial-pci-multi.o
-common-obj-$(CONFIG_VIRTIO_SERIAL) += virtio-console.o
-common-obj-$(CONFIG_XILINX) += xilinx_uartlite.o
-common-obj-$(CONFIG_XEN) += xen_console.o
-common-obj-$(CONFIG_CADENCE) += cadence_uart.o
-common-obj-$(CONFIG_IBEX) += ibex_uart.o
-
-common-obj-$(CONFIG_EXYNOS4) += exynos4210_uart.o
-common-obj-$(CONFIG_COLDFIRE) += mcf_uart.o
-common-obj-$(CONFIG_OMAP) += omap_uart.o
-common-obj-$(CONFIG_SH4) += sh_serial.o
-common-obj-$(CONFIG_DIGIC) += digic-uart.o
-common-obj-$(CONFIG_STM32F2XX_USART) += stm32f2xx_usart.o
-common-obj-$(CONFIG_RASPI) += bcm2835_aux.o
-common-obj-$(CONFIG_RENESAS_SCI) += renesas_sci.o
-common-obj-$(CONFIG_AVR_USART) += avr_usart.o
-
-common-obj-$(CONFIG_CMSDK_APB_UART) += cmsdk-apb-uart.o
-common-obj-$(CONFIG_ETRAXFS) += etraxfs_ser.o
-common-obj-$(CONFIG_ISA_DEBUG) += debugcon.o
-common-obj-$(CONFIG_GRLIB) += grlib_apbuart.o
-common-obj-$(CONFIG_IMX) += imx_serial.o
-common-obj-$(CONFIG_LM32) += lm32_juart.o
-common-obj-$(CONFIG_LM32) += lm32_uart.o
-common-obj-$(CONFIG_MILKYMIST) += milkymist-uart.o
-common-obj-$(CONFIG_SCLPCONSOLE) += sclpconsole.o sclpconsole-lm.o
-
-obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o
-obj-$(CONFIG_PSERIES) += spapr_vty.o
-obj-$(CONFIG_TERMINAL3270) += terminal3270.o
diff --git a/hw/char/meson.build b/hw/char/meson.build
new file mode 100644
index 000..e888215
--- /dev/null
+++ b/hw/char/meson.build
@@ -0,0 +1,38 @@
+softmmu_ss.add(when: 'CONFIG_CADENCE', if_true: files('cadence_uart.c'))
+softmmu_ss.add(when: 'CONFIG_CMSDK_APB_UART', if_true: 
files('cmsdk-apb-uart.c'))
+softmmu_ss.add(when: 'CONFIG_ESCC', if_true: files('escc.c'))
+softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_ser.c'))
+softmmu_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_apbuart.c'))
+softmmu_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_uart.c'))
+softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_serial.c'))
+softmmu_ss.add(when: 'CONFIG_IPACK', if_true: files('ipoctal232.c'))
+softmmu_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('parallel-isa.c'))
+softmmu_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugcon.c'))
+softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_juart.c'))
+softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_uart.c'))
+softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-uart.c'))
+softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_uart.c'))
+softmmu_ss.add(when: 'CONFIG_PARALLEL', if_true: files('parallel.c'))
+softmmu_ss.add(when: 'CONFIG_PL011', if_true: files('pl011.c'))
+softmmu_ss.add(when: 'CONFIG_SCLPCONSOLE', if_true: files('sclpconsole.c', 
'sclpconsole-lm.c'))
+softmmu_ss.add(when: 'CONFIG_SERIAL', if_true: files('serial.c'))
+softmmu_ss.add(when: 'CONFIG_SERIAL_ISA', if_true: files('serial-isa.c'))
+softmmu_ss.add(when: 'CONFIG_SERIAL_PCI', if_true: files('serial-pci.c'))
+softmmu_ss.add(when: 'CONFIG_SERIAL_PCI_MULTI', if_true: 
files('serial-pci-multi.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true: 
files('virtio-console.c'))
+softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen_console.c'))
+softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_uartlite.c'))
+
+softmmu_ss.add(when: 'CONFIG_AVR_USART', if_true: files('avr_usart.c'))
+softmmu_ss.add(when: 'CONFIG_COLDFIRE', if_true: files('mcf_uart.c'))
+softmmu_ss.add(when: 'CONFIG_DIGIC', if_true: files('digic-uart.c'))
+softmmu_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_uart.c'))
+softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_uart.c'))
+softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_aux.c'))
+softmmu_ss.add(when: 

[PATCH 106/143] meson: convert hw/ipmi

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs  |  1 -
 hw/ipmi/Makefile.objs |  8 
 hw/ipmi/meson.build   | 11 +++
 hw/meson.build|  1 +
 4 files changed, 12 insertions(+), 9 deletions(-)
 delete mode 100644 hw/ipmi/Makefile.objs
 create mode 100644 hw/ipmi/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index a28e211..f136377 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -15,7 +15,6 @@ devices-dirs-y += ide/
 devices-dirs-y += input/
 devices-dirs-y += intc/
 devices-dirs-$(CONFIG_IPACK) += ipack/
-devices-dirs-$(CONFIG_IPMI) += ipmi/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs
deleted file mode 100644
index 3cca10b..000
--- a/hw/ipmi/Makefile.objs
+++ /dev/null
@@ -1,8 +0,0 @@
-common-obj-$(CONFIG_IPMI) += ipmi.o ipmi_kcs.o ipmi_bt.o
-common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o
-common-obj-$(CONFIG_IPMI_EXTERN) += ipmi_bmc_extern.o
-common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o
-common-obj-$(CONFIG_PCI_IPMI_KCS) += pci_ipmi_kcs.o
-common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o
-common-obj-$(CONFIG_PCI_IPMI_BT) += pci_ipmi_bt.o
-common-obj-$(CONFIG_IPMI_SSIF) += smbus_ipmi.o
diff --git a/hw/ipmi/meson.build b/hw/ipmi/meson.build
new file mode 100644
index 000..9622ea2
--- /dev/null
+++ b/hw/ipmi/meson.build
@@ -0,0 +1,11 @@
+ipmi_ss = ss.source_set()
+ipmi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c', 'ipmi_kcs.c', 
'ipmi_bt.c'))
+ipmi_ss.add(when: 'CONFIG_IPMI_LOCAL', if_true: files('ipmi_bmc_sim.c'))
+ipmi_ss.add(when: 'CONFIG_IPMI_EXTERN', if_true: files('ipmi_bmc_extern.c'))
+ipmi_ss.add(when: 'CONFIG_ISA_IPMI_KCS', if_true: files('isa_ipmi_kcs.c'))
+ipmi_ss.add(when: 'CONFIG_PCI_IPMI_KCS', if_true: files('pci_ipmi_kcs.c'))
+ipmi_ss.add(when: 'CONFIG_ISA_IPMI_BT', if_true: files('isa_ipmi_bt.c'))
+ipmi_ss.add(when: 'CONFIG_PCI_IPMI_BT', if_true: files('pci_ipmi_bt.c'))
+ipmi_ss.add(when: 'CONFIG_IPMI_SSIF', if_true: files('smbus_ipmi.c'))
+
+softmmu_ss.add_all(when: 'CONFIG_IPMI', if_true: ipmi_ss)
diff --git a/hw/meson.build b/hw/meson.build
index 8659854..9796f95 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,4 +1,5 @@
 subdir('core')
+subdir('ipmi')
 subdir('isa')
 subdir('mem')
 subdir('misc')
-- 
1.8.3.1





[PATCH 114/143] meson: convert hw/dma

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs |  1 -
 hw/dma/Makefile.objs | 16 
 hw/dma/meson.build   | 15 +++
 hw/meson.build   |  1 +
 4 files changed, 16 insertions(+), 17 deletions(-)
 delete mode 100644 hw/dma/Makefile.objs
 create mode 100644 hw/dma/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index c04dfe5..26917a4 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -7,7 +7,6 @@ devices-dirs-y += block/
 devices-dirs-y += char/
 devices-dirs-y += cpu/
 devices-dirs-y += display/
-devices-dirs-y += dma/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs
deleted file mode 100644
index f4b1cfe..000
--- a/hw/dma/Makefile.objs
+++ /dev/null
@@ -1,16 +0,0 @@
-common-obj-$(CONFIG_PUV3) += puv3_dma.o
-common-obj-$(CONFIG_RC4030) += rc4030.o
-common-obj-$(CONFIG_PL080) += pl080.o
-common-obj-$(CONFIG_PL330) += pl330.o
-common-obj-$(CONFIG_I82374) += i82374.o
-common-obj-$(CONFIG_I8257) += i8257.o
-common-obj-$(CONFIG_XILINX_AXI) += xilinx_axidma.o
-common-obj-$(CONFIG_ZYNQ_DEVCFG) += xlnx-zynq-devcfg.o
-common-obj-$(CONFIG_ETRAXFS) += etraxfs_dma.o
-common-obj-$(CONFIG_STP2000) += sparc32_dma.o
-common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx_dpdma.o
-common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zdma.o
-
-common-obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o
-common-obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o
-common-obj-$(CONFIG_RASPI) += bcm2835_dma.o
diff --git a/hw/dma/meson.build b/hw/dma/meson.build
new file mode 100644
index 000..ff5bb37
--- /dev/null
+++ b/hw/dma/meson.build
@@ -0,0 +1,15 @@
+softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_dma.c'))
+softmmu_ss.add(when: 'CONFIG_RC4030', if_true: files('rc4030.c'))
+softmmu_ss.add(when: 'CONFIG_PL080', if_true: files('pl080.c'))
+softmmu_ss.add(when: 'CONFIG_PL330', if_true: files('pl330.c'))
+softmmu_ss.add(when: 'CONFIG_I82374', if_true: files('i82374.c'))
+softmmu_ss.add(when: 'CONFIG_I8257', if_true: files('i8257.c'))
+softmmu_ss.add(when: 'CONFIG_XILINX_AXI', if_true: files('xilinx_axidma.c'))
+softmmu_ss.add(when: 'CONFIG_ZYNQ_DEVCFG', if_true: 
files('xlnx-zynq-devcfg.c'))
+softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_dma.c'))
+softmmu_ss.add(when: 'CONFIG_STP2000', if_true: files('sparc32_dma.c'))
+softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx_dpdma.c'))
+softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zdma.c'))
+softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_dma.c', 'soc_dma.c'))
+softmmu_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_dma.c'))
+softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_dma.c'))
diff --git a/hw/meson.build b/hw/meson.build
index 52577c3..96da0bb 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,4 +1,5 @@
 subdir('core')
+subdir('dma')
 subdir('gpio')
 subdir('hyperv')
 subdir('i2c')
-- 
1.8.3.1





[PATCH 122/143] meson: convert hw/9pfs, cleanup

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

hw/Makefile.objs is gone so there is more code that can be removed.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 Makefile  |  4 
 Makefile.objs |  8 
 Makefile.target   | 15 ---
 hw/9pfs/Kconfig   |  4 
 hw/9pfs/Makefile.objs |  9 -
 hw/9pfs/meson.build   | 20 
 hw/Makefile.objs  |  8 
 hw/meson.build|  1 +
 8 files changed, 25 insertions(+), 44 deletions(-)
 delete mode 100644 hw/9pfs/Makefile.objs
 create mode 100644 hw/9pfs/meson.build
 delete mode 100644 hw/Makefile.objs

diff --git a/Makefile b/Makefile
index d9d6b59..2aaa3f8 100644
--- a/Makefile
+++ b/Makefile
@@ -163,10 +163,6 @@ ifneq ($(wildcard config-host.mak),)
 include $(SRC_PATH)/Makefile.objs
 endif
 
-dummy := $(call unnest-vars,, \
-common-obj-y \
-common-obj-m)
-
 include $(SRC_PATH)/tests/Makefile.include
 
 all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) recurse-all modules
diff --git a/Makefile.objs b/Makefile.objs
index 965f64c..7eaf047 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -60,18 +60,10 @@ common-obj-$(if $(CONFIG_RBD),m) += block-rbd$(DSOSUF)
 common-obj-$(if $(CONFIG_LZFSE),m) += block-dmg-lzfse$(DSOSUF)
 common-obj-$(if $(and $(CONFIG_BZIP2),$(CONFIG_DMG)),m) += 
block-dmg-bz2$(DSOSUF)
 
-common-obj-y += hw/
-common-obj-m += hw/
-
 common-obj-y += libqmp.fa
 
 endif # CONFIG_SOFTMMU
 
-###
-# Target-independent parts used in system and user emulation
-
-common-obj-y += hw/
-
 ##
 # Resource file for Windows executables
 version-obj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.o
diff --git a/Makefile.target b/Makefile.target
index 3534ece..c95e0de 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -156,7 +156,6 @@ endif #CONFIG_BSD_USER
 ifdef CONFIG_SOFTMMU
 obj-y += softmmu/
 obj-y += gdbstub.o
-obj-y += hw/
 LIBS := $(libs_softmmu) $(LIBS)
 
 # Temporary until emulators are linked by Meson
@@ -185,20 +184,6 @@ endif # CONFIG_SOFTMMU
 dummy := $(call unnest-vars,,obj-y)
 all-obj-y := $(obj-y)
 
-#
-# common-obj-m has some crap here, probably as side effect from
-# unnest-vars recursing into target directories to fill obj-y and not
-# properly handling the -m case.
-#
-# Clear common-obj-m as workaround.  Fixes suspious dependency errors
-# when building devices as modules.  A bit hackish, but should be ok
-# as long as we do not have any target-specific modules.
-#
-# The meson-based build system currently in development doesn't need
-# unnest-vars and will obsolete this workaround.
-#
-common-obj-m :=
-
 include $(SRC_PATH)/Makefile.objs
 dummy := $(call fix-paths,../,, \
   authz-obj-y \
diff --git a/hw/9pfs/Kconfig b/hw/9pfs/Kconfig
index 3ae5749..d3ebd73 100644
--- a/hw/9pfs/Kconfig
+++ b/hw/9pfs/Kconfig
@@ -2,8 +2,12 @@ config FSDEV_9P
 bool
 depends on VIRTFS
 
+config 9PFS
+bool
+
 config VIRTIO_9P
 bool
 default y
 depends on VIRTFS && VIRTIO
 select FSDEV_9P
+select 9PFS
diff --git a/hw/9pfs/Makefile.objs b/hw/9pfs/Makefile.objs
deleted file mode 100644
index 70ded6f..000
--- a/hw/9pfs/Makefile.objs
+++ /dev/null
@@ -1,9 +0,0 @@
-common-obj-y  = 9p.o 9p-util.o
-common-obj-y += 9p-local.o 9p-xattr.o
-common-obj-y += 9p-xattr-user.o 9p-posix-acl.o
-common-obj-y += coth.o cofs.o codir.o cofile.o
-common-obj-y += coxattr.o 9p-synth.o
-common-obj-y += 9p-proxy.o
-
-common-obj-$(CONFIG_XEN) += xen-9p-backend.o
-obj-$(CONFIG_VIRTIO_9P) += virtio-9p-device.o
diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build
new file mode 100644
index 000..cc09426
--- /dev/null
+++ b/hw/9pfs/meson.build
@@ -0,0 +1,20 @@
+fs_ss = ss.source_set()
+fs_ss.add(files(
+  '9p-local.c',
+  '9p-posix-acl.c',
+  '9p-proxy.c',
+  '9p-synth.c',
+  '9p-util.c',
+  '9p-xattr-user.c',
+  '9p-xattr.c',
+  '9p.c',
+  'codir.c',
+  'cofile.c',
+  'cofs.c',
+  'coth.c',
+  'coxattr.c',
+))
+fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c'))
+softmmu_ss.add_all(when: 'CONFIG_9PFS', if_true: fs_ss)
+
+specific_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device.c'))
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
deleted file mode 100644
index ebae00a..000
--- a/hw/Makefile.objs
+++ /dev/null
@@ -1,8 +0,0 @@
-ifeq ($(CONFIG_SOFTMMU), y)
-devices-dirs-$(call lor,$(CONFIG_VIRTIO_9P),$(call 
land,$(CONFIG_VIRTFS),$(CONFIG_XEN))) += 9pfs/
-endif
-
-common-obj-y += $(devices-dirs-y)
-common-obj-m += display/
-common-obj-m += usb/
-obj-y += $(devices-dirs-y)
diff --git a/hw/meson.build b/hw/meson.build
index 55ca2b2..ba8763c 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,3 +1,4 @@
+subdir('9pfs')
 subdir('acpi')
 subdir('adc')
 subdir('audio')
-- 
1.8.3.1





[PATCH 101/143] meson: convert hw/nvram

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs   | 1 -
 hw/meson.build | 1 +
 hw/nvram/Makefile.objs | 8 
 hw/nvram/meson.build   | 9 +
 4 files changed, 10 insertions(+), 9 deletions(-)
 delete mode 100644 hw/nvram/Makefile.objs
 create mode 100644 hw/nvram/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 2083284..78860ae 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -20,7 +20,6 @@ devices-dirs-y += isa/
 devices-dirs-y += misc/
 devices-dirs-y += net/
 devices-dirs-y += rdma/
-devices-dirs-y += nvram/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/meson.build b/hw/meson.build
index 53c347c..0bdd6a2 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,6 +1,7 @@
 subdir('core')
 subdir('mem')
 subdir('nubus')
+subdir('nvram')
 subdir('pci')
 subdir('pci-bridge')
 subdir('pci-host')
diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs
deleted file mode 100644
index f3ad921..000
--- a/hw/nvram/Makefile.objs
+++ /dev/null
@@ -1,8 +0,0 @@
-common-obj-$(CONFIG_DS1225Y) += ds1225y.o
-common-obj-$(CONFIG_NMC93XX_EEPROM) += eeprom93xx.o
-common-obj-$(CONFIG_AT24C) += eeprom_at24c.o
-common-obj-y += fw_cfg.o
-common-obj-$(CONFIG_CHRP_NVRAM) += chrp_nvram.o
-common-obj-$(CONFIG_MAC_NVRAM) += mac_nvram.o
-common-obj-$(CONFIG_NRF51_SOC) += nrf51_nvm.o
-obj-$(CONFIG_PSERIES) += spapr_nvram.o
diff --git a/hw/nvram/meson.build b/hw/nvram/meson.build
new file mode 100644
index 000..ba21455
--- /dev/null
+++ b/hw/nvram/meson.build
@@ -0,0 +1,9 @@
+softmmu_ss.add(files('fw_cfg.c'))
+softmmu_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c'))
+softmmu_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c'))
+softmmu_ss.add(when: 'CONFIG_NMC93XX_EEPROM', if_true: files('eeprom93xx.c'))
+softmmu_ss.add(when: 'CONFIG_AT24C', if_true: files('eeprom_at24c.c'))
+softmmu_ss.add(when: 'CONFIG_MAC_NVRAM', if_true: files('mac_nvram.c'))
+softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_nvm.c'))
+
+specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_nvram.c'))
-- 
1.8.3.1





[PATCH 110/143] meson: convert hw/ide

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs |  1 -
 hw/ide/Makefile.objs | 14 --
 hw/ide/meson.build   | 14 ++
 hw/meson.build   |  1 +
 4 files changed, 15 insertions(+), 15 deletions(-)
 delete mode 100644 hw/ide/Makefile.objs
 create mode 100644 hw/ide/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 3feccd8..02c5c0d 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -11,7 +11,6 @@ devices-dirs-y += dma/
 devices-dirs-y += gpio/
 devices-dirs-$(CONFIG_HYPERV) += hyperv/
 devices-dirs-$(CONFIG_I2C) += i2c/
-devices-dirs-y += ide/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/ide/Makefile.objs b/hw/ide/Makefile.objs
deleted file mode 100644
index faf04e0..000
--- a/hw/ide/Makefile.objs
+++ /dev/null
@@ -1,14 +0,0 @@
-common-obj-$(CONFIG_IDE_CORE) += core.o atapi.o
-common-obj-$(CONFIG_IDE_QDEV) += qdev.o
-common-obj-$(CONFIG_IDE_PCI) += pci.o
-common-obj-$(CONFIG_IDE_ISA) += isa.o ioport.o
-common-obj-$(CONFIG_IDE_PIIX) += piix.o ioport.o
-common-obj-$(CONFIG_IDE_CMD646) += cmd646.o
-common-obj-$(CONFIG_IDE_MACIO) += macio.o
-common-obj-$(CONFIG_IDE_MMIO) += mmio.o
-common-obj-$(CONFIG_IDE_VIA) += via.o
-common-obj-$(CONFIG_MICRODRIVE) += microdrive.o
-common-obj-$(CONFIG_AHCI) += ahci.o
-common-obj-$(CONFIG_AHCI_ICH9) += ich.o
-common-obj-$(CONFIG_ALLWINNER_A10) += ahci-allwinner.o
-common-obj-$(CONFIG_IDE_SII3112) += sii3112.o
diff --git a/hw/ide/meson.build b/hw/ide/meson.build
new file mode 100644
index 000..ddcb3b2
--- /dev/null
+++ b/hw/ide/meson.build
@@ -0,0 +1,14 @@
+softmmu_ss.add(when: 'CONFIG_AHCI', if_true: files('ahci.c'))
+softmmu_ss.add(when: 'CONFIG_AHCI_ICH9', if_true: files('ich.c'))
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: 
files('ahci-allwinner.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_CMD646', if_true: files('cmd646.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_CORE', if_true: files('core.c', 'atapi.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_ISA', if_true: files('isa.c', 'ioport.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_MACIO', if_true: files('macio.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_MMIO', if_true: files('mmio.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_PCI', if_true: files('pci.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_PIIX', if_true: files('piix.c', 'ioport.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_QDEV', if_true: files('qdev.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_SII3112', if_true: files('sii3112.c'))
+softmmu_ss.add(when: 'CONFIG_IDE_VIA', if_true: files('via.c'))
+softmmu_ss.add(when: 'CONFIG_MICRODRIVE', if_true: files('microdrive.c'))
diff --git a/hw/meson.build b/hw/meson.build
index b15c8d0..4d7c31c6 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,4 +1,5 @@
 subdir('core')
+subdir('ide')
 subdir('input')
 subdir('intc')
 subdir('ipack')
-- 
1.8.3.1





[PATCH 109/143] meson: convert hw/input

2020-08-06 Thread Paolo Bonzini
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Paolo Bonzini 
---
 hw/Makefile.objs   |  1 -
 hw/input/Makefile.objs | 18 --
 hw/input/meson.build   | 18 ++
 hw/meson.build |  1 +
 4 files changed, 19 insertions(+), 19 deletions(-)
 delete mode 100644 hw/input/Makefile.objs
 create mode 100644 hw/input/meson.build

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 80b1041..3feccd8 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -12,7 +12,6 @@ devices-dirs-y += gpio/
 devices-dirs-$(CONFIG_HYPERV) += hyperv/
 devices-dirs-$(CONFIG_I2C) += i2c/
 devices-dirs-y += ide/
-devices-dirs-y += input/
 endif
 
 common-obj-y += $(devices-dirs-y)
diff --git a/hw/input/Makefile.objs b/hw/input/Makefile.objs
deleted file mode 100644
index abc1ff0..000
--- a/hw/input/Makefile.objs
+++ /dev/null
@@ -1,18 +0,0 @@
-common-obj-$(CONFIG_ADB) += adb.o adb-mouse.o adb-kbd.o
-common-obj-y += hid.o
-common-obj-$(CONFIG_LM832X) += lm832x.o
-common-obj-$(CONFIG_PCKBD) += pckbd.o
-common-obj-$(CONFIG_PL050) += pl050.o
-common-obj-$(CONFIG_PS2) += ps2.o
-common-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
-common-obj-$(CONFIG_TSC2005) += tsc2005.o
-
-common-obj-$(CONFIG_VIRTIO_INPUT) += virtio-input.o
-common-obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-hid.o
-common-obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host.o
-common-obj-$(CONFIG_VHOST_USER_INPUT) += vhost-user-input.o
-
-common-obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
-common-obj-$(CONFIG_PXA2XX) += pxa2xx_keypad.o
-common-obj-$(CONFIG_TSC210X) += tsc210x.o
-common-obj-$(CONFIG_LASIPS2) += lasips2.o
diff --git a/hw/input/meson.build b/hw/input/meson.build
new file mode 100644
index 000..e7285b1
--- /dev/null
+++ b/hw/input/meson.build
@@ -0,0 +1,18 @@
+softmmu_ss.add(files('hid.c'))
+softmmu_ss.add(when: 'CONFIG_ADB', if_true: files('adb.c', 'adb-mouse.c', 
'adb-kbd.c'))
+softmmu_ss.add(when: 'CONFIG_LM832X', if_true: files('lm832x.c'))
+softmmu_ss.add(when: 'CONFIG_PCKBD', if_true: files('pckbd.c'))
+softmmu_ss.add(when: 'CONFIG_PL050', if_true: files('pl050.c'))
+softmmu_ss.add(when: 'CONFIG_PS2', if_true: files('ps2.c'))
+softmmu_ss.add(when: 'CONFIG_STELLARIS_INPUT', if_true: 
files('stellaris_input.c'))
+softmmu_ss.add(when: 'CONFIG_TSC2005', if_true: files('tsc2005.c'))
+
+softmmu_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-input.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: 
files('virtio-input-hid.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_INPUT_HOST', if_true: 
files('virtio-input-host.c'))
+softmmu_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: 
files('vhost-user-input.c'))
+
+softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-softusb.c'))
+softmmu_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_keypad.c'))
+softmmu_ss.add(when: 'CONFIG_TSC210X', if_true: files('tsc210x.c'))
+softmmu_ss.add(when: 'CONFIG_LASIPS2', if_true: files('lasips2.c'))
diff --git a/hw/meson.build b/hw/meson.build
index 986e710..b15c8d0 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -1,4 +1,5 @@
 subdir('core')
+subdir('input')
 subdir('intc')
 subdir('ipack')
 subdir('ipmi')
-- 
1.8.3.1





  1   2   3   4   5   6   >