[Qemu-devel] [PATCH 08/14] check: Only test nvdim_acpi when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/bios-tables-test.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index fd59c7f9a2..1de6e3d58c 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -825,6 +825,7 @@ static void test_acpi_piix4_tcg_numamem(void)
 free_test_data();
 }
 
+#ifdef CONFIG_NVDIM_ACPI
 static void test_acpi_tcg_dimm_pxm(const char *machine)
 {
 test_data data;
@@ -860,6 +861,7 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
 {
 test_acpi_tcg_dimm_pxm(MACHINE_PC);
 }
+#endif
 
 int main(int argc, char *argv[])
 {
@@ -887,8 +889,10 @@ int main(int argc, char *argv[])
 qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
 qtest_add_func("acpi/piix4/numamem", test_acpi_piix4_tcg_numamem);
 qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
+#ifdef CONFIG_NVDIM_ACPI
 qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
 qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+#endif
 }
 ret = g_test_run();
 boot_sector_cleanup(disk);
-- 
2.17.1




[Qemu-devel] [PATCH 06/14] check: Only test usb smartcard when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/usb-hcd-xhci-test.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c
index 5b1b681bf2..be80c5f032 100644
--- a/tests/usb-hcd-xhci-test.c
+++ b/tests/usb-hcd-xhci-test.c
@@ -35,6 +35,7 @@ static void test_usb_uas_hotplug(void)
 qtest_qmp_device_del("uas");
 }
 
+#ifdef CONFIG_USB_SMARTCARD
 static void test_usb_ccid_hotplug(void)
 {
 qtest_qmp_device_add("usb-ccid", "ccid", NULL);
@@ -43,6 +44,7 @@ static void test_usb_ccid_hotplug(void)
 qtest_qmp_device_add("usb-ccid", "ccid", NULL);
 qtest_qmp_device_del("ccid");
 }
+#endif
 
 int main(int argc, char **argv)
 {
@@ -53,8 +55,9 @@ int main(int argc, char **argv)
 qtest_add_func("/xhci/pci/init", test_xhci_init);
 qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
 qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
+#ifdef CONFIG_USB_SMARTCARD
 qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug);
-
+#endif
 qtest_start("-device nec-usb-xhci,id=xhci"
 " -drive id=drive0,if=none,file=null-co://,format=raw");
 ret = g_test_run();
-- 
2.17.1




[Qemu-devel] [PATCH 09/14] check: Only test virtio-balloon when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 hw/virtio/virtio-pci.c | 5 -
 tests/Makefile.include | 6 +++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 3a01fe90f0..bdbc7ab78d 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -2287,7 +2287,7 @@ static const TypeInfo vhost_vsock_pci_info = {
 #endif
 
 /* virtio-balloon-pci */
-
+#ifdef CONFIG_VIRTIO_BALLOON
 static Property virtio_balloon_pci_properties[] = {
 DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0),
 DEFINE_PROP_END_OF_LIST(),
@@ -2341,6 +2341,7 @@ static const TypeInfo virtio_balloon_pci_info = {
 .instance_init = virtio_balloon_pci_instance_init,
 .class_init= virtio_balloon_pci_class_init,
 };
+#endif
 
 /* virtio-serial-pci */
 
@@ -2711,7 +2712,9 @@ static void virtio_pci_register_types(void)
 type_register_static(_user_blk_pci_info);
 #endif
 type_register_static(_scsi_pci_info);
+#ifdef CONFIG_VIRTIO_BALLOON
 type_register_static(_balloon_pci_info);
+#endif
 type_register_static(_serial_pci_info);
 type_register_static(_net_pci_info);
 #ifdef CONFIG_VHOST_SCSI
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 9193945c24..bb30c56795 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -191,8 +191,8 @@ gcov-files-virtioserial-y += hw/char/virtio-console.c
 gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio.c
 check-qtest-virtio-y += tests/virtio-net-test$(EXESUF)
 gcov-files-virtio-y += i386-softmmu/hw/net/virtio-net.c
-check-qtest-virtio-y += tests/virtio-balloon-test$(EXESUF)
-gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio-balloon.c
+check-qtest-virtio-$(CONFIG_VIRTIO_BALLOON) += 
tests/virtio-balloon-test$(EXESUF)
+gcov-files-virtio-$(CONFIG_VIRTIO_BALLOON) += 
i386-softmmu/hw/virtio/virtio-balloon.c
 check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF)
 gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c
 check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF)
@@ -397,7 +397,7 @@ check-qtest-s390x-$(CONFIG_SLIRP) += 
tests/test-netfilter$(EXESUF)
 check-qtest-s390x-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
 check-qtest-s390x-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
 check-qtest-s390x-y += tests/drive_del-test$(EXESUF)
-check-qtest-s390x-y += tests/virtio-balloon-test$(EXESUF)
+check-qtest-s390x-$(CONFIG_VIRTIO_BALLOON) += 
tests/virtio-balloon-test$(EXESUF)
 check-qtest-s390x-y += tests/virtio-console-test$(EXESUF)
 check-qtest-s390x-y += tests/virtio-serial-test$(EXESUF)
 check-qtest-s390x-y += tests/cpu-plug-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 01/14] check: Only test ipmi when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include   | 4 ++--
 tests/bios-tables-test.c | 4 
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 0ac4b960bc..bb1080ecb5 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -260,8 +260,8 @@ check-qtest-i386-y += tests/bios-tables-test$(EXESUF)
 check-qtest-i386-y += tests/boot-serial-test$(EXESUF)
 check-qtest-i386-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
 check-qtest-i386-y += tests/rtc-test$(EXESUF)
-check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF)
-check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF)
+check-qtest-i386-$(CONFIG_ISA_IPMI_KCS) += tests/ipmi-kcs-test$(EXESUF)
+check-qtest-i386-$(CONFIG_ISA_IPMI_BT) += tests/ipmi-bt-test$(EXESUF)
 check-qtest-i386-y += tests/i440fx-test$(EXESUF)
 check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
 check-qtest-i386-y += tests/drive_del-test$(EXESUF)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 4e24930c4b..fd59c7f9a2 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -736,6 +736,7 @@ static void test_acpi_q35_tcg_cphp(void)
 free_test_data();
 }
 
+#ifdef CONFIG_IPMI
 static uint8_t ipmi_required_struct_types[] = {
 0, 1, 3, 4, 16, 17, 19, 32, 38, 127
 };
@@ -772,6 +773,7 @@ static void test_acpi_piix4_tcg_ipmi(void)
   );
 free_test_data();
 }
+#endif
 
 static void test_acpi_q35_tcg_memhp(void)
 {
@@ -875,8 +877,10 @@ int main(int argc, char *argv[])
 qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
 qtest_add_func("acpi/q35", test_acpi_q35_tcg);
 qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
+#ifdef CONFIG_IPMI
 qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
 qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
+#endif
 qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
 qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
 qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
-- 
2.17.1




[Qemu-devel] [PATCH 05/14] check: Only test sga when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/boot-serial-test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
index 952a2e7ead..3f7c46fdf7 100644
--- a/tests/boot-serial-test.c
+++ b/tests/boot-serial-test.c
@@ -87,11 +87,13 @@ static testdef_t tests[] = {
 { "ppc64", "pseries", "", "Open Firmware" },
 { "ppc64", "powernv", "-cpu POWER8", "OPAL" },
 { "ppc64", "sam460ex", "-device e1000", "8086  100e" },
+#ifdef CONFIG_SGA
 { "i386", "isapc", "-cpu qemu32 -device sga", "SGABIOS" },
 { "i386", "pc", "-device sga", "SGABIOS" },
 { "i386", "q35", "-device sga", "SGABIOS" },
 { "x86_64", "isapc", "-cpu qemu32 -device sga", "SGABIOS" },
 { "x86_64", "q35", "-device sga", "SGABIOS" },
+#endif
 { "sparc", "LX", "", "TMS390S10" },
 { "sparc", "SS-4", "", "MB86904" },
 { "sparc", "SS-600MP", "", "TMS390Z55" },
-- 
2.17.1




[Qemu-devel] [PATCH 03/14] check: Only test lsi when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/cdrom-test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/cdrom-test.c b/tests/cdrom-test.c
index 42c29524b8..bab2ecc306 100644
--- a/tests/cdrom-test.c
+++ b/tests/cdrom-test.c
@@ -140,9 +140,11 @@ static void add_x86_tests(void)
 qtest_add_data_func("cdrom/boot/dc390",
 "-device dc390 -device scsi-cd,drive=cd1 "
 "-blockdev file,node-name=cd1,filename=", test_cdboot);
+#ifdef CONFIG_LSI_SCSI_PCI
 qtest_add_data_func("cdrom/boot/lsi53c895a",
 "-device lsi53c895a -device scsi-cd,drive=cd1 "
 "-blockdev file,node-name=cd1,filename=", test_cdboot);
+#endif
 #ifdef CONFIG_MEGASAS_SCSI_PCI
 qtest_add_data_func("cdrom/boot/megasas", "-M q35 "
 "-device megasas -device scsi-cd,drive=cd1 "
-- 
2.17.1




[Qemu-devel] [PATCH 04/14] check: Only test esp when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/cdrom-test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/cdrom-test.c b/tests/cdrom-test.c
index bab2ecc306..0d7dff6da5 100644
--- a/tests/cdrom-test.c
+++ b/tests/cdrom-test.c
@@ -134,12 +134,14 @@ static void add_x86_tests(void)
 "-blockdev file,node-name=cdr,filename=", test_cdboot);
 qtest_add_data_func("cdrom/boot/isapc", "-M isapc "
 "-drive if=ide,media=cdrom,file=", test_cdboot);
+#ifdef CONFIG_ESP_PCI
 qtest_add_data_func("cdrom/boot/am53c974",
 "-device am53c974 -device scsi-cd,drive=cd1 "
 "-drive if=none,id=cd1,format=raw,file=", test_cdboot);
 qtest_add_data_func("cdrom/boot/dc390",
 "-device dc390 -device scsi-cd,drive=cd1 "
 "-blockdev file,node-name=cd1,filename=", test_cdboot);
+#endif
 #ifdef CONFIG_LSI_SCSI_PCI
 qtest_add_data_func("cdrom/boot/lsi53c895a",
 "-device lsi53c895a -device scsi-cd,drive=cd1 "
-- 
2.17.1




[Qemu-devel] [PATCH 02/14] check: Only test megasas when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 tests/cdrom-test.c | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index bb1080ecb5..6565206a78 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -245,8 +245,8 @@ check-qtest-pci-$(CONFIG_HDA) += 
tests/intel-hda-test$(EXESUF)
 gcov-files-pci-$(CONFIG_HDA) += hw/audio/intel-hda.c hw/audio/hda-codec.c
 check-qtest-pci-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF)
 gcov-files-pci-$(CONFIG_IVSHMEM_DEVICE) += hw/misc/ivshmem.c
-check-qtest-pci-y += tests/megasas-test$(EXESUF)
-gcov-files-pci-y += hw/scsi/megasas.c
+check-qtest-pci-$(CONFIG_MEGASAS_SCSI_PCI) += tests/megasas-test$(EXESUF)
+gcov-files-pci-$(CONFIG_MEGASAS_SCSI_PCI) += hw/scsi/megasas.c
 
 check-qtest-i386-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 check-qtest-i386-y += tests/fdc-test$(EXESUF)
diff --git a/tests/cdrom-test.c b/tests/cdrom-test.c
index 7a1fce5dfb..42c29524b8 100644
--- a/tests/cdrom-test.c
+++ b/tests/cdrom-test.c
@@ -143,12 +143,14 @@ static void add_x86_tests(void)
 qtest_add_data_func("cdrom/boot/lsi53c895a",
 "-device lsi53c895a -device scsi-cd,drive=cd1 "
 "-blockdev file,node-name=cd1,filename=", test_cdboot);
+#ifdef CONFIG_MEGASAS_SCSI_PCI
 qtest_add_data_func("cdrom/boot/megasas", "-M q35 "
 "-device megasas -device scsi-cd,drive=cd1 "
 "-blockdev file,node-name=cd1,filename=", test_cdboot);
 qtest_add_data_func("cdrom/boot/megasas-gen2", "-M q35 "
 "-device megasas-gen2 -device scsi-cd,drive=cd1 "
 "-blockdev file,node-name=cd1,filename=", test_cdboot);
+#endif
 }
 
 static void add_s390x_tests(void)
-- 
2.17.1




[Qemu-devel] [RFC 00/14] More patches to disable stuff

2018-07-17 Thread Juan Quintela
Hi

Notice that this is an RFC because they don't work.  As said on my
previous submmision, we need -softmmu/config-devices.h to make
this work.  This series just allow us to disable the devices, but not
to enable it back O:-)

Notice:

- scsi stuff: we are testing they in cdrom-test.c, so we need to be
  able to config them out.  Notice also that #ifdefs only go in tests/<...>

- virtio stuff: see how we need to also change hw/virtio/virtio-pci.c
  to disable it.  The problem appears in the device-instropect-test.c.
  As they are defined in the binary, but not complied in.  We can
  change for a registration appreach, but that is more work that what
  I intended for this series.

What do you think?

Later, Juan.

Based-on: 20180717113402.5510-1-quint...@redhat.com

Juan Quintela (14):
  check: Only test ipmi when it is compiled in
  check: Only test megasas when it is compiled in
  check: Only test lsi when it is compiled in
  check: Only test esp when it is compiled in
  check: Only test sga when it is compiled in
  check: Only test usb smartcard when it is compiled in
  check: Only test usb storage when it is compiled in
  check: Only test nvdim_acpi when it is compiled in
  check: Only test virtio-balloon when it is compiled in
  check: Only test virtio-serial when it is compiled in
  check: Only test virtio-rng when it is compiled in
  check: Only test virtio-gpu when it is compiled in
  check: Only test virtio-input when it is compiled in
  check: Only test virtio-scsi when it is compiled in

 hw/virtio/virtio-pci.c| 15 ---
 tests/Makefile.include| 36 ++--
 tests/bios-tables-test.c  |  8 
 tests/boot-serial-test.c  |  2 ++
 tests/cdrom-test.c| 10 ++
 tests/display-vga-test.c  |  4 
 tests/drive_del-test.c|  6 ++
 tests/usb-hcd-uhci-test.c |  5 -
 tests/usb-hcd-xhci-test.c |  9 -
 9 files changed, 72 insertions(+), 23 deletions(-)

-- 
2.17.1




Re: [Qemu-devel] [PATCH 11/25] check: Only test hda when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index af395b5f22..691f853ab6 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -241,8 +241,8 @@ gcov-files-pci-y += hw/display/vga-pci.c
>  gcov-files-pci-y += hw/display/virtio-gpu.c
>  gcov-files-pci-y += hw/display/virtio-gpu-pci.c
>  gcov-files-pci-$(CONFIG_VIRTIO_VGA) += hw/display/virtio-vga.c
> -check-qtest-pci-y += tests/intel-hda-test$(EXESUF)
> -gcov-files-pci-y += hw/audio/intel-hda.c hw/audio/hda-codec.c
> +check-qtest-pci-$(CONFIG_HDA) += tests/intel-hda-test$(EXESUF)
> +gcov-files-pci-$(CONFIG_HDA) += hw/audio/intel-hda.c hw/audio/hda-codec.c
>  check-qtest-pci-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
>  gcov-files-pci-y += hw/misc/ivshmem.c
>  check-qtest-pci-y += tests/megasas-test$(EXESUF)
> 

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH 06/25] check: Only test eepro100 when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index ae77d26932..560f486416 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -218,8 +218,8 @@ gcov-files-pci-y += hw/net/rtl8139.c
>  check-qtest-pci-y += tests/pcnet-test$(EXESUF)
>  gcov-files-pci-y += hw/net/pcnet.c
>  gcov-files-pci-y += hw/net/pcnet-pci.c
> -check-qtest-pci-y += tests/eepro100-test$(EXESUF)
> -gcov-files-pci-y += hw/net/eepro100.c
> +check-qtest-pci-$(CONFIG_EEPRO100_PCI) += tests/eepro100-test$(EXESUF)
> +gcov-files-pci-$(CONFIG_EEPRO100_PCI) += hw/net/eepro100.c
>  check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF)
>  gcov-files-pci-$(CONFIG_NE2000_PCI) += hw/net/ne2000.c
>  check-qtest-pci-y += tests/nvme-test$(EXESUF)

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH 07/25] check: Only test pcnet when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 560f486416..a039b70f9b 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -215,9 +215,9 @@ check-qtest-pci-y += tests/e1000e-test$(EXESUF)
>  gcov-files-pci-y += hw/net/e1000e.c hw/net/e1000e_core.c
>  check-qtest-pci-y += tests/rtl8139-test$(EXESUF)
>  gcov-files-pci-y += hw/net/rtl8139.c
> -check-qtest-pci-y += tests/pcnet-test$(EXESUF)
> -gcov-files-pci-y += hw/net/pcnet.c
> -gcov-files-pci-y += hw/net/pcnet-pci.c
> +check-qtest-pci-$(CONFIG_PCNET_PCI) += tests/pcnet-test$(EXESUF)
> +gcov-files-pci-$(CONFIG_PCNET_PCI) += hw/net/pcnet.c
> +gcov-files-pci-$(CONFIG_PCNET_PCI) += hw/net/pcnet-pci.c
>  check-qtest-pci-$(CONFIG_EEPRO100_PCI) += tests/eepro100-test$(EXESUF)
>  gcov-files-pci-$(CONFIG_EEPRO100_PCI) += hw/net/eepro100.c
>  check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF)

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH 05/25] check: Only test ne2000 when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index e9dd3e8928..ae77d26932 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -220,8 +220,8 @@ gcov-files-pci-y += hw/net/pcnet.c
>  gcov-files-pci-y += hw/net/pcnet-pci.c
>  check-qtest-pci-y += tests/eepro100-test$(EXESUF)
>  gcov-files-pci-y += hw/net/eepro100.c
> -check-qtest-pci-y += tests/ne2000-test$(EXESUF)
> -gcov-files-pci-y += hw/net/ne2000.c
> +check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF)
> +gcov-files-pci-$(CONFIG_NE2000_PCI) += hw/net/ne2000.c
>  check-qtest-pci-y += tests/nvme-test$(EXESUF)
>  gcov-files-pci-y += hw/block/nvme.c
>  check-qtest-pci-y += tests/ac97-test$(EXESUF)

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH 09/25] check: Only test es1370 when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index c6156fe105..3d146310f0 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -226,8 +226,8 @@ check-qtest-pci-y += tests/nvme-test$(EXESUF)
>  gcov-files-pci-y += hw/block/nvme.c
>  check-qtest-pci-y += tests/ac97-test$(EXESUF)
>  gcov-files-pci-y += hw/audio/ac97.c
> -check-qtest-pci-y += tests/es1370-test$(EXESUF)
> -gcov-files-pci-y += hw/audio/es1370.c
> +check-qtest-pci-$(CONFIG_ES1370) += tests/es1370-test$(EXESUF)
> +gcov-files-pci-$(CONFIG_ES1370) += hw/audio/es1370.c
>  check-qtest-pci-y += $(check-qtest-virtio-y)
>  gcov-files-pci-y += $(gcov-files-virtio-y) hw/virtio/virtio-pci.c
>  check-qtest-pci-y += tests/tpci200-test$(EXESUF)
> 

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH 17/25] check: Only test wdt_ib700 when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 868a41986b..f635517a68 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -265,9 +265,9 @@ check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF)
>  check-qtest-i386-y += tests/i440fx-test$(EXESUF)
>  check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
>  check-qtest-i386-y += tests/drive_del-test$(EXESUF)
> -check-qtest-i386-y += tests/wdt_ib700-test$(EXESUF)
> +check-qtest-i386-$(CONFIG_WDT_IB700) += tests/wdt_ib700-test$(EXESUF)
>  check-qtest-i386-y += tests/tco-test$(EXESUF)
> -gcov-files-i386-y += hw/watchdog/watchdog.c hw/watchdog/wdt_ib700.c
> +gcov-files-i386-$(CONFIG_WDT_IB700) += hw/watchdog/watchdog.c 
> hw/watchdog/wdt_ib700.c
>  check-qtest-i386-y += $(check-qtest-pci-y)
>  gcov-files-i386-y += $(gcov-files-pci-y)
>  check-qtest-i386-$(CONFIG_VMXNET3_PCI) += tests/vmxnet3-test$(EXESUF)

In case you respin: Move the two ib700 lines next to each other again
while you're at it?

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH 04/25] check: Only test vmxnet3 when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 47aea32193..e9dd3e8928 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -270,8 +270,8 @@ check-qtest-i386-y += tests/tco-test$(EXESUF)
>  gcov-files-i386-y += hw/watchdog/watchdog.c hw/watchdog/wdt_ib700.c
>  check-qtest-i386-y += $(check-qtest-pci-y)
>  gcov-files-i386-y += $(gcov-files-pci-y)
> -check-qtest-i386-y += tests/vmxnet3-test$(EXESUF)
> -gcov-files-i386-y += hw/net/vmxnet3.c
> +check-qtest-i386-$(CONFIG_VMXNET3_PCI) += tests/vmxnet3-test$(EXESUF)
> +gcov-files-i386-$(CONFIG_VMXNET3_PCI) += hw/net/vmxnet3.c
>  gcov-files-i386-y += hw/net/net_rx_pkt.c
>  gcov-files-i386-y += hw/net/net_tx_pkt.c
>  check-qtest-i386-y += tests/pvpanic-test$(EXESUF)
> 

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH 10/25] check: Only test ac97 when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 3d146310f0..af395b5f22 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -224,8 +224,8 @@ check-qtest-pci-$(CONFIG_NE2000_PCI) += 
> tests/ne2000-test$(EXESUF)
>  gcov-files-pci-$(CONFIG_NE2000_PCI) += hw/net/ne2000.c
>  check-qtest-pci-y += tests/nvme-test$(EXESUF)
>  gcov-files-pci-y += hw/block/nvme.c
> -check-qtest-pci-y += tests/ac97-test$(EXESUF)
> -gcov-files-pci-y += hw/audio/ac97.c
> +check-qtest-pci-$(CONFIG_AC97) += tests/ac97-test$(EXESUF)
> +gcov-files-pci-$(CONFIG_AC97) += hw/audio/ac97.c
>  check-qtest-pci-$(CONFIG_ES1370) += tests/es1370-test$(EXESUF)
>  gcov-files-pci-$(CONFIG_ES1370) += hw/audio/es1370.c
>  check-qtest-pci-y += $(check-qtest-virtio-y)
> 

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH 08/25] check: Only test rtl8139 when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> test-file-redirector uses rtl8139 in everything except s390.
> 
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index a039b70f9b..c6156fe105 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -213,8 +213,8 @@ check-qtest-pci-y += tests/e1000-test$(EXESUF)
>  gcov-files-pci-y += hw/net/e1000.c
>  check-qtest-pci-y += tests/e1000e-test$(EXESUF)
>  gcov-files-pci-y += hw/net/e1000e.c hw/net/e1000e_core.c
> -check-qtest-pci-y += tests/rtl8139-test$(EXESUF)
> -gcov-files-pci-y += hw/net/rtl8139.c
> +check-qtest-pci-$(CONFIG_RTL8139_PCI) += tests/rtl8139-test$(EXESUF)
> +gcov-files-pci-$(CONFIG_RTL8139_PCI) += hw/net/rtl8139.c
>  check-qtest-pci-$(CONFIG_PCNET_PCI) += tests/pcnet-test$(EXESUF)
>  gcov-files-pci-$(CONFIG_PCNET_PCI) += hw/net/pcnet.c
>  gcov-files-pci-$(CONFIG_PCNET_PCI) += hw/net/pcnet-pci.c
> @@ -302,7 +302,7 @@ check-qtest-i386-$(CONFIG_TPM) += 
> tests/tpm-tis-swtpm-test$(EXESUF)
>  check-qtest-i386-$(CONFIG_TPM) += tests/tpm-tis-test$(EXESUF)
>  check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
>  check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
> -check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
> +check-qtest-i386-$(CONFIG_RTL8139_PCI) += 
> tests/test-filter-redirector$(EXESUF)
>  check-qtest-i386-y += tests/migration-test$(EXESUF)
>  check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
>  check-qtest-i386-y += tests/numa-test$(EXESUF)
> @@ -352,7 +352,7 @@ gcov-files-ppc64-y += hw/usb/hcd-xhci.c
>  check-qtest-ppc64-y += $(check-qtest-virtio-y)
>  check-qtest-ppc64-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
>  check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
> -check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
> +check-qtest-ppc64-$(CONFIG_RTL8139_PCI) += 
> tests/test-filter-redirector$(EXESUF)
>  check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
>  check-qtest-ppc64-y += tests/numa-test$(EXESUF)
>  check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)

Reviewed-by: Thomas Huth 



[Qemu-devel] [PATCH 24/25] check: Only test ivshm when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 731443387d..188f555600 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -243,8 +243,8 @@ gcov-files-pci-y += hw/display/virtio-gpu-pci.c
 gcov-files-pci-$(CONFIG_VIRTIO_VGA) += hw/display/virtio-vga.c
 check-qtest-pci-$(CONFIG_HDA) += tests/intel-hda-test$(EXESUF)
 gcov-files-pci-$(CONFIG_HDA) += hw/audio/intel-hda.c hw/audio/hda-codec.c
-check-qtest-pci-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
-gcov-files-pci-y += hw/misc/ivshmem.c
+check-qtest-pci-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF)
+gcov-files-pci-$(CONFIG_IVSHMEM_DEVICE) += hw/misc/ivshmem.c
 check-qtest-pci-y += tests/megasas-test$(EXESUF)
 gcov-files-pci-y += hw/scsi/megasas.c
 
@@ -355,7 +355,7 @@ check-qtest-ppc64-$(CONFIG_POSIX) += 
tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-$(CONFIG_RTL8139_PCI) += 
tests/test-filter-redirector$(EXESUF)
 check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
 check-qtest-ppc64-y += tests/numa-test$(EXESUF)
-check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
+check-qtest-ppc64-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF)
 check-qtest-ppc64-y += tests/cpu-plug-test$(EXESUF)
 
 check-qtest-sh4-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
-- 
2.17.1




Re: [Qemu-devel] [PATCH 16/25] check: Only test sdhci when it is compiled in

2018-07-17 Thread Thomas Huth
On 17.07.2018 13:33, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  tests/Makefile.include | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index b0aa79909b..868a41986b 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -307,7 +307,7 @@ check-qtest-i386-y += tests/migration-test$(EXESUF)
>  check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
>  check-qtest-i386-y += tests/numa-test$(EXESUF)
>  check-qtest-x86_64-y += $(check-qtest-i386-y)
> -check-qtest-x86_64-y += tests/sdhci-test$(EXESUF)
> +check-qtest-x86_64-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
>  gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
>  gcov-files-x86_64-y = $(subst 
> i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y))
>  
> @@ -381,10 +381,10 @@ gcov-files-arm-y += arm-softmmu/hw/block/virtio-blk.c
>  check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF)
>  gcov-files-arm-y += hw/timer/arm_mptimer.c
>  check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
> -check-qtest-arm-y += tests/sdhci-test$(EXESUF)
> +check-qtest-arm-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
>  
>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
> -check-qtest-aarch64-y += tests/sdhci-test$(EXESUF)
> +check-qtest-aarch64-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
>  check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
>  
>  check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
> 

Reviewed-by: Thomas Huth 



[Qemu-devel] [PATCH 23/25] check: Only test usb-ehci when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 27f50e3231..731443387d 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -284,8 +284,8 @@ check-qtest-i386-$(CONFIG_USB_OHCI) += 
tests/usb-hcd-ohci-test$(EXESUF)
 gcov-files-i386-$(CONFIG_USB_OHCI) += hw/usb/hcd-ohci.c
 check-qtest-i386-$(CONFIG_USB_UHCI) += tests/usb-hcd-uhci-test$(EXESUF)
 gcov-files-i386-$(CONFIG_USB_UHCI) += hw/usb/hcd-uhci.c
-check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
-gcov-files-i386-y += hw/usb/hcd-ehci.c
+check-qtest-i386-$(CONFIG_USB_EHCI) += tests/usb-hcd-ehci-test$(EXESUF)
+gcov-files-i386-$(CONFIG_USB_EHCI) += hw/usb/hcd-ehci.c
 gcov-files-i386-y += hw/usb/dev-hid.c
 gcov-files-i386-y += hw/usb/dev-storage.c
 check-qtest-i386-$(CONFIG_USB_XHCI_NEC) += tests/usb-hcd-xhci-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 22/25] check: Only test usb-uhci devices when they are compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 3a78ada070..27f50e3231 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -282,8 +282,8 @@ check-qtest-i386-$(CONFIG_IOH3420) += 
tests/ioh3420-test$(EXESUF)
 gcov-files-i386-$(CONFIG_IOH3420) += hw/pci-bridge/ioh3420.c
 check-qtest-i386-$(CONFIG_USB_OHCI) += tests/usb-hcd-ohci-test$(EXESUF)
 gcov-files-i386-$(CONFIG_USB_OHCI) += hw/usb/hcd-ohci.c
-check-qtest-i386-y += tests/usb-hcd-uhci-test$(EXESUF)
-gcov-files-i386-y += hw/usb/hcd-uhci.c
+check-qtest-i386-$(CONFIG_USB_UHCI) += tests/usb-hcd-uhci-test$(EXESUF)
+gcov-files-i386-$(CONFIG_USB_UHCI) += hw/usb/hcd-uhci.c
 check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-ehci.c
 gcov-files-i386-y += hw/usb/dev-hid.c
@@ -345,8 +345,8 @@ check-qtest-ppc64-y += tests/rtas-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_USB_OHCI) += tests/usb-hcd-ohci-test$(EXESUF)
 gcov-files-ppc64-$(CONFIG_USB_OHCI) += hw/usb/hcd-ohci.c
-check-qtest-ppc64-y += tests/usb-hcd-uhci-test$(EXESUF)
-gcov-files-ppc64-y += hw/usb/hcd-uhci.c
+check-qtest-ppc64-$(CONFIG_USB_UHCI) += tests/usb-hcd-uhci-test$(EXESUF)
+gcov-files-ppc64-$(CONFIG_USB_UHCI) += hw/usb/hcd-uhci.c
 check-qtest-ppc64-$(CONFIG_USB_XHCI_NEC) += tests/usb-hcd-xhci-test$(EXESUF)
 gcov-files-ppc64-$(CONFIG_USB_XHCI) += hw/usb/hcd-xhci.c
 check-qtest-ppc64-y += $(check-qtest-virtio-y)
-- 
2.17.1




[Qemu-devel] [PATCH 25/25] check: Only test tpm devices when they are compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 188f555600..0ac4b960bc 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -296,10 +296,10 @@ check-qtest-i386-y += tests/vmgenid-test$(EXESUF)
 gcov-files-i386-y += hw/pci-host/q35.c
 check-qtest-i386-$(CONFIG_VHOST_USER_NET_TEST_i386) += 
tests/vhost-user-test$(EXESUF)
 check-qtest-x86_64-$(call lor, $(CONFIG_VHOST_USER_NET_TEST_i386), 
$(CONFIG_VHOST_USER_NET_TEST_x86_64)) += tests/vhost-user-test$(EXESUF)
-check-qtest-i386-$(CONFIG_TPM) += tests/tpm-crb-swtpm-test$(EXESUF)
-check-qtest-i386-$(CONFIG_TPM) += tests/tpm-crb-test$(EXESUF)
-check-qtest-i386-$(CONFIG_TPM) += tests/tpm-tis-swtpm-test$(EXESUF)
-check-qtest-i386-$(CONFIG_TPM) += tests/tpm-tis-test$(EXESUF)
+check-qtest-i386-$(CONFIG_TPM_CRB) += tests/tpm-crb-swtpm-test$(EXESUF)
+check-qtest-i386-$(CONFIG_TPM_CRB) += tests/tpm-crb-test$(EXESUF)
+check-qtest-i386-$(CONFIG_TPM_TIS) += tests/tpm-tis-swtpm-test$(EXESUF)
+check-qtest-i386-$(CONFIG_TPM_TIS) += tests/tpm-tis-test$(EXESUF)
 check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
 check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
 check-qtest-i386-$(CONFIG_RTL8139_PCI) += tests/test-filter-redirector$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 19/25] check: Only test nvme when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 31d124ee44..b3e707e8c3 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -222,8 +222,8 @@ check-qtest-pci-$(CONFIG_EEPRO100_PCI) += 
tests/eepro100-test$(EXESUF)
 gcov-files-pci-$(CONFIG_EEPRO100_PCI) += hw/net/eepro100.c
 check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF)
 gcov-files-pci-$(CONFIG_NE2000_PCI) += hw/net/ne2000.c
-check-qtest-pci-y += tests/nvme-test$(EXESUF)
-gcov-files-pci-y += hw/block/nvme.c
+check-qtest-pci-$(CONFIG_NVME_PCI) += tests/nvme-test$(EXESUF)
+gcov-files-pci-$(CONFIG_NVME_PCI) += hw/block/nvme.c
 check-qtest-pci-$(CONFIG_AC97) += tests/ac97-test$(EXESUF)
 gcov-files-pci-$(CONFIG_AC97) += hw/audio/ac97.c
 check-qtest-pci-$(CONFIG_ES1370) += tests/es1370-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 21/25] check: Only test usb-ohci when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index ccf71bddcc..3a78ada070 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -280,8 +280,8 @@ check-qtest-i386-$(CONFIG_I82801B11) += 
tests/i82801b11-test$(EXESUF)
 gcov-files-i386-$(CONFIG_I82801B11) += hw/pci-bridge/i82801b11.c
 check-qtest-i386-$(CONFIG_IOH3420) += tests/ioh3420-test$(EXESUF)
 gcov-files-i386-$(CONFIG_IOH3420) += hw/pci-bridge/ioh3420.c
-check-qtest-i386-y += tests/usb-hcd-ohci-test$(EXESUF)
-gcov-files-i386-y += hw/usb/hcd-ohci.c
+check-qtest-i386-$(CONFIG_USB_OHCI) += tests/usb-hcd-ohci-test$(EXESUF)
+gcov-files-i386-$(CONFIG_USB_OHCI) += hw/usb/hcd-ohci.c
 check-qtest-i386-y += tests/usb-hcd-uhci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-uhci.c
 check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
@@ -343,8 +343,8 @@ check-qtest-ppc64-y += tests/pnv-xscom-test$(EXESUF)
 check-qtest-ppc64-y += tests/migration-test$(EXESUF)
 check-qtest-ppc64-y += tests/rtas-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
-check-qtest-ppc64-y += tests/usb-hcd-ohci-test$(EXESUF)
-gcov-files-ppc64-y += hw/usb/hcd-ohci.c
+check-qtest-ppc64-$(CONFIG_USB_OHCI) += tests/usb-hcd-ohci-test$(EXESUF)
+gcov-files-ppc64-$(CONFIG_USB_OHCI) += hw/usb/hcd-ohci.c
 check-qtest-ppc64-y += tests/usb-hcd-uhci-test$(EXESUF)
 gcov-files-ppc64-y += hw/usb/hcd-uhci.c
 check-qtest-ppc64-$(CONFIG_USB_XHCI_NEC) += tests/usb-hcd-xhci-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 20/25] check: Only test usb-xhci-nec when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index b3e707e8c3..ccf71bddcc 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -288,8 +288,8 @@ check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-ehci.c
 gcov-files-i386-y += hw/usb/dev-hid.c
 gcov-files-i386-y += hw/usb/dev-storage.c
-check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF)
-gcov-files-i386-y += hw/usb/hcd-xhci.c
+check-qtest-i386-$(CONFIG_USB_XHCI_NEC) += tests/usb-hcd-xhci-test$(EXESUF)
+gcov-files-i386-$(CONFIG_USB_XHCI) += hw/usb/hcd-xhci.c
 check-qtest-i386-y += tests/cpu-plug-test$(EXESUF)
 check-qtest-i386-y += tests/q35-test$(EXESUF)
 check-qtest-i386-y += tests/vmgenid-test$(EXESUF)
@@ -347,8 +347,8 @@ check-qtest-ppc64-y += tests/usb-hcd-ohci-test$(EXESUF)
 gcov-files-ppc64-y += hw/usb/hcd-ohci.c
 check-qtest-ppc64-y += tests/usb-hcd-uhci-test$(EXESUF)
 gcov-files-ppc64-y += hw/usb/hcd-uhci.c
-check-qtest-ppc64-y += tests/usb-hcd-xhci-test$(EXESUF)
-gcov-files-ppc64-y += hw/usb/hcd-xhci.c
+check-qtest-ppc64-$(CONFIG_USB_XHCI_NEC) += tests/usb-hcd-xhci-test$(EXESUF)
+gcov-files-ppc64-$(CONFIG_USB_XHCI) += hw/usb/hcd-xhci.c
 check-qtest-ppc64-y += $(check-qtest-virtio-y)
 check-qtest-ppc64-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 15/25] check: Only test i82801b11 when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 3b555660bd..b0aa79909b 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -276,8 +276,8 @@ gcov-files-i386-y += hw/net/net_rx_pkt.c
 gcov-files-i386-y += hw/net/net_tx_pkt.c
 check-qtest-i386-y += tests/pvpanic-test$(EXESUF)
 gcov-files-i386-y += i386-softmmu/hw/misc/pvpanic.c
-check-qtest-i386-y += tests/i82801b11-test$(EXESUF)
-gcov-files-i386-y += hw/pci-bridge/i82801b11.c
+check-qtest-i386-$(CONFIG_I82801B11) += tests/i82801b11-test$(EXESUF)
+gcov-files-i386-$(CONFIG_I82801B11) += hw/pci-bridge/i82801b11.c
 check-qtest-i386-$(CONFIG_IOH3420) += tests/ioh3420-test$(EXESUF)
 gcov-files-i386-$(CONFIG_IOH3420) += hw/pci-bridge/ioh3420.c
 check-qtest-i386-y += tests/usb-hcd-ohci-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 13/25] check: Only test isa-testdev when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 5a3943c81c..a56d423303 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -248,7 +248,7 @@ gcov-files-pci-y += hw/misc/ivshmem.c
 check-qtest-pci-y += tests/megasas-test$(EXESUF)
 gcov-files-pci-y += hw/scsi/megasas.c
 
-check-qtest-i386-y = tests/endianness-test$(EXESUF)
+check-qtest-i386-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 check-qtest-i386-y += tests/fdc-test$(EXESUF)
 gcov-files-i386-y = hw/block/fdc.c
 check-qtest-i386-y += tests/ide-test$(EXESUF)
@@ -319,15 +319,15 @@ check-qtest-m68k-y = tests/boot-serial-test$(EXESUF)
 
 check-qtest-microblaze-y = tests/boot-serial-test$(EXESUF)
 
-check-qtest-mips-y = tests/endianness-test$(EXESUF)
+check-qtest-mips-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 
-check-qtest-mips64-y = tests/endianness-test$(EXESUF)
+check-qtest-mips64-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 
-check-qtest-mips64el-y = tests/endianness-test$(EXESUF)
+check-qtest-mips64el-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 
-check-qtest-moxie-y = tests/boot-serial-test$(EXESUF)
+check-qtest-moxie-$(CONFIG_ISA_TESTDEV) = tests/boot-serial-test$(EXESUF)
 
-check-qtest-ppc-y = tests/endianness-test$(EXESUF)
+check-qtest-ppc-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 check-qtest-ppc-y += tests/boot-order-test$(EXESUF)
 check-qtest-ppc-y += tests/prom-env-test$(EXESUF)
 check-qtest-ppc-y += tests/drive_del-test$(EXESUF)
@@ -358,16 +358,16 @@ check-qtest-ppc64-y += tests/numa-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
 check-qtest-ppc64-y += tests/cpu-plug-test$(EXESUF)
 
-check-qtest-sh4-y = tests/endianness-test$(EXESUF)
+check-qtest-sh4-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 
-check-qtest-sh4eb-y = tests/endianness-test$(EXESUF)
+check-qtest-sh4eb-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 
 check-qtest-sparc-y = tests/prom-env-test$(EXESUF)
 check-qtest-sparc-y += tests/m48t59-test$(EXESUF)
 gcov-files-sparc-y = hw/timer/m48t59.c
 check-qtest-sparc-y += tests/boot-serial-test$(EXESUF)
 
-check-qtest-sparc64-y = tests/endianness-test$(EXESUF)
+check-qtest-sparc64-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 check-qtest-sparc64-y += tests/prom-env-test$(EXESUF)
 check-qtest-sparc64-y += tests/boot-serial-test$(EXESUF)
 
-- 
2.17.1




[Qemu-devel] [PATCH 18/25] check: Only test pvpanic when it is compiled in

2018-07-17 Thread Juan Quintela
There was not possible to compile out pvpanic.  Use the same trick
that applesmc.

Signed-off-by: Juan Quintela 
---
 hw/misc/pvpanic.c | 11 ---
 include/hw/misc/pvpanic.h | 11 ++-
 tests/Makefile.include|  4 ++--
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index b26250dec9..9d8961ba0c 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -99,17 +99,6 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error 
**errp)
 isa_register_ioport(d, >io, s->ioport);
 }
 
-#define PVPANIC_IOPORT_PROP "ioport"
-
-uint16_t pvpanic_port(void)
-{
-Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL);
-if (!o) {
-return 0;
-}
-return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL);
-}
-
 static Property pvpanic_isa_properties[] = {
 DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505),
 DEFINE_PROP_END_OF_LIST(),
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
index 36a54e270c..1ee071a703 100644
--- a/include/hw/misc/pvpanic.h
+++ b/include/hw/misc/pvpanic.h
@@ -16,6 +16,15 @@
 
 #define TYPE_PVPANIC "pvpanic"
 
-uint16_t pvpanic_port(void);
+#define PVPANIC_IOPORT_PROP "ioport"
+
+static inline uint16_t pvpanic_port(void)
+{
+Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL);
+if (!o) {
+return 0;
+}
+return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL);
+}
 
 #endif
diff --git a/tests/Makefile.include b/tests/Makefile.include
index f635517a68..31d124ee44 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -274,8 +274,8 @@ check-qtest-i386-$(CONFIG_VMXNET3_PCI) += 
tests/vmxnet3-test$(EXESUF)
 gcov-files-i386-$(CONFIG_VMXNET3_PCI) += hw/net/vmxnet3.c
 gcov-files-i386-y += hw/net/net_rx_pkt.c
 gcov-files-i386-y += hw/net/net_tx_pkt.c
-check-qtest-i386-y += tests/pvpanic-test$(EXESUF)
-gcov-files-i386-y += i386-softmmu/hw/misc/pvpanic.c
+check-qtest-i386-$(CONFIG_PVPANIC) += tests/pvpanic-test$(EXESUF)
+gcov-files-i386-$(CONFIG_PVPANIC) += i386-softmmu/hw/misc/pvpanic.c
 check-qtest-i386-$(CONFIG_I82801B11) += tests/i82801b11-test$(EXESUF)
 gcov-files-i386-$(CONFIG_I82801B11) += hw/pci-bridge/i82801b11.c
 check-qtest-i386-$(CONFIG_IOH3420) += tests/ioh3420-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 12/25] check: Only test ipack when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 691f853ab6..5a3943c81c 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -230,10 +230,10 @@ check-qtest-pci-$(CONFIG_ES1370) += 
tests/es1370-test$(EXESUF)
 gcov-files-pci-$(CONFIG_ES1370) += hw/audio/es1370.c
 check-qtest-pci-y += $(check-qtest-virtio-y)
 gcov-files-pci-y += $(gcov-files-virtio-y) hw/virtio/virtio-pci.c
-check-qtest-pci-y += tests/tpci200-test$(EXESUF)
-gcov-files-pci-y += hw/ipack/tpci200.c
-check-qtest-pci-y += $(check-qtest-ipack-y)
-gcov-files-pci-y += $(gcov-files-ipack-y)
+check-qtest-pci-$(CONFIG_IPACK) += tests/tpci200-test$(EXESUF)
+gcov-files-pci-$(CONFIG_IPACK) += hw/ipack/tpci200.c
+check-qtest-pci-$(CONFIG_IPACK) += $(check-qtest-ipack-y)
+gcov-files-pci-$(CONFIG_IPACK) += $(gcov-files-ipack-y)
 check-qtest-pci-y += tests/display-vga-test$(EXESUF)
 gcov-files-pci-y += hw/display/vga.c
 gcov-files-pci-y += hw/display/cirrus_vga.c
-- 
2.17.1




[Qemu-devel] [PATCH 17/25] check: Only test wdt_ib700 when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 868a41986b..f635517a68 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -265,9 +265,9 @@ check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF)
 check-qtest-i386-y += tests/i440fx-test$(EXESUF)
 check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
 check-qtest-i386-y += tests/drive_del-test$(EXESUF)
-check-qtest-i386-y += tests/wdt_ib700-test$(EXESUF)
+check-qtest-i386-$(CONFIG_WDT_IB700) += tests/wdt_ib700-test$(EXESUF)
 check-qtest-i386-y += tests/tco-test$(EXESUF)
-gcov-files-i386-y += hw/watchdog/watchdog.c hw/watchdog/wdt_ib700.c
+gcov-files-i386-$(CONFIG_WDT_IB700) += hw/watchdog/watchdog.c 
hw/watchdog/wdt_ib700.c
 check-qtest-i386-y += $(check-qtest-pci-y)
 gcov-files-i386-y += $(gcov-files-pci-y)
 check-qtest-i386-$(CONFIG_VMXNET3_PCI) += tests/vmxnet3-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 14/25] check: Only test ioh3420 when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index a56d423303..3b555660bd 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -278,8 +278,8 @@ check-qtest-i386-y += tests/pvpanic-test$(EXESUF)
 gcov-files-i386-y += i386-softmmu/hw/misc/pvpanic.c
 check-qtest-i386-y += tests/i82801b11-test$(EXESUF)
 gcov-files-i386-y += hw/pci-bridge/i82801b11.c
-check-qtest-i386-y += tests/ioh3420-test$(EXESUF)
-gcov-files-i386-y += hw/pci-bridge/ioh3420.c
+check-qtest-i386-$(CONFIG_IOH3420) += tests/ioh3420-test$(EXESUF)
+gcov-files-i386-$(CONFIG_IOH3420) += hw/pci-bridge/ioh3420.c
 check-qtest-i386-y += tests/usb-hcd-ohci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-ohci.c
 check-qtest-i386-y += tests/usb-hcd-uhci-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 09/25] check: Only test es1370 when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index c6156fe105..3d146310f0 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -226,8 +226,8 @@ check-qtest-pci-y += tests/nvme-test$(EXESUF)
 gcov-files-pci-y += hw/block/nvme.c
 check-qtest-pci-y += tests/ac97-test$(EXESUF)
 gcov-files-pci-y += hw/audio/ac97.c
-check-qtest-pci-y += tests/es1370-test$(EXESUF)
-gcov-files-pci-y += hw/audio/es1370.c
+check-qtest-pci-$(CONFIG_ES1370) += tests/es1370-test$(EXESUF)
+gcov-files-pci-$(CONFIG_ES1370) += hw/audio/es1370.c
 check-qtest-pci-y += $(check-qtest-virtio-y)
 gcov-files-pci-y += $(gcov-files-virtio-y) hw/virtio/virtio-pci.c
 check-qtest-pci-y += tests/tpci200-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 11/25] check: Only test hda when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index af395b5f22..691f853ab6 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -241,8 +241,8 @@ gcov-files-pci-y += hw/display/vga-pci.c
 gcov-files-pci-y += hw/display/virtio-gpu.c
 gcov-files-pci-y += hw/display/virtio-gpu-pci.c
 gcov-files-pci-$(CONFIG_VIRTIO_VGA) += hw/display/virtio-vga.c
-check-qtest-pci-y += tests/intel-hda-test$(EXESUF)
-gcov-files-pci-y += hw/audio/intel-hda.c hw/audio/hda-codec.c
+check-qtest-pci-$(CONFIG_HDA) += tests/intel-hda-test$(EXESUF)
+gcov-files-pci-$(CONFIG_HDA) += hw/audio/intel-hda.c hw/audio/hda-codec.c
 check-qtest-pci-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
 gcov-files-pci-y += hw/misc/ivshmem.c
 check-qtest-pci-y += tests/megasas-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 10/25] check: Only test ac97 when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 3d146310f0..af395b5f22 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -224,8 +224,8 @@ check-qtest-pci-$(CONFIG_NE2000_PCI) += 
tests/ne2000-test$(EXESUF)
 gcov-files-pci-$(CONFIG_NE2000_PCI) += hw/net/ne2000.c
 check-qtest-pci-y += tests/nvme-test$(EXESUF)
 gcov-files-pci-y += hw/block/nvme.c
-check-qtest-pci-y += tests/ac97-test$(EXESUF)
-gcov-files-pci-y += hw/audio/ac97.c
+check-qtest-pci-$(CONFIG_AC97) += tests/ac97-test$(EXESUF)
+gcov-files-pci-$(CONFIG_AC97) += hw/audio/ac97.c
 check-qtest-pci-$(CONFIG_ES1370) += tests/es1370-test$(EXESUF)
 gcov-files-pci-$(CONFIG_ES1370) += hw/audio/es1370.c
 check-qtest-pci-y += $(check-qtest-virtio-y)
-- 
2.17.1




[Qemu-devel] [PATCH 06/25] check: Only test eepro100 when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index ae77d26932..560f486416 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -218,8 +218,8 @@ gcov-files-pci-y += hw/net/rtl8139.c
 check-qtest-pci-y += tests/pcnet-test$(EXESUF)
 gcov-files-pci-y += hw/net/pcnet.c
 gcov-files-pci-y += hw/net/pcnet-pci.c
-check-qtest-pci-y += tests/eepro100-test$(EXESUF)
-gcov-files-pci-y += hw/net/eepro100.c
+check-qtest-pci-$(CONFIG_EEPRO100_PCI) += tests/eepro100-test$(EXESUF)
+gcov-files-pci-$(CONFIG_EEPRO100_PCI) += hw/net/eepro100.c
 check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF)
 gcov-files-pci-$(CONFIG_NE2000_PCI) += hw/net/ne2000.c
 check-qtest-pci-y += tests/nvme-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 16/25] check: Only test sdhci when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index b0aa79909b..868a41986b 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -307,7 +307,7 @@ check-qtest-i386-y += tests/migration-test$(EXESUF)
 check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
 check-qtest-i386-y += tests/numa-test$(EXESUF)
 check-qtest-x86_64-y += $(check-qtest-i386-y)
-check-qtest-x86_64-y += tests/sdhci-test$(EXESUF)
+check-qtest-x86_64-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
 gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
 gcov-files-x86_64-y = $(subst 
i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y))
 
@@ -381,10 +381,10 @@ gcov-files-arm-y += arm-softmmu/hw/block/virtio-blk.c
 check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF)
 gcov-files-arm-y += hw/timer/arm_mptimer.c
 check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
-check-qtest-arm-y += tests/sdhci-test$(EXESUF)
+check-qtest-arm-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
 
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
-check-qtest-aarch64-y += tests/sdhci-test$(EXESUF)
+check-qtest-aarch64-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 
 check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
-- 
2.17.1




[Qemu-devel] [PATCH 08/25] check: Only test rtl8139 when it is compiled in

2018-07-17 Thread Juan Quintela
test-file-redirector uses rtl8139 in everything except s390.

Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index a039b70f9b..c6156fe105 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -213,8 +213,8 @@ check-qtest-pci-y += tests/e1000-test$(EXESUF)
 gcov-files-pci-y += hw/net/e1000.c
 check-qtest-pci-y += tests/e1000e-test$(EXESUF)
 gcov-files-pci-y += hw/net/e1000e.c hw/net/e1000e_core.c
-check-qtest-pci-y += tests/rtl8139-test$(EXESUF)
-gcov-files-pci-y += hw/net/rtl8139.c
+check-qtest-pci-$(CONFIG_RTL8139_PCI) += tests/rtl8139-test$(EXESUF)
+gcov-files-pci-$(CONFIG_RTL8139_PCI) += hw/net/rtl8139.c
 check-qtest-pci-$(CONFIG_PCNET_PCI) += tests/pcnet-test$(EXESUF)
 gcov-files-pci-$(CONFIG_PCNET_PCI) += hw/net/pcnet.c
 gcov-files-pci-$(CONFIG_PCNET_PCI) += hw/net/pcnet-pci.c
@@ -302,7 +302,7 @@ check-qtest-i386-$(CONFIG_TPM) += 
tests/tpm-tis-swtpm-test$(EXESUF)
 check-qtest-i386-$(CONFIG_TPM) += tests/tpm-tis-test$(EXESUF)
 check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
 check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
-check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
+check-qtest-i386-$(CONFIG_RTL8139_PCI) += tests/test-filter-redirector$(EXESUF)
 check-qtest-i386-y += tests/migration-test$(EXESUF)
 check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
 check-qtest-i386-y += tests/numa-test$(EXESUF)
@@ -352,7 +352,7 @@ gcov-files-ppc64-y += hw/usb/hcd-xhci.c
 check-qtest-ppc64-y += $(check-qtest-virtio-y)
 check-qtest-ppc64-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
 check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
-check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
+check-qtest-ppc64-$(CONFIG_RTL8139_PCI) += 
tests/test-filter-redirector$(EXESUF)
 check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
 check-qtest-ppc64-y += tests/numa-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 00/25] Don't "check" disabled drivers

2018-07-17 Thread Juan Quintela
Hi

We can disable drivers with "-softmmu/config-devices.mak".  But
if we remove drivers there and do "make check", we still try to test
that devices (that are compiled in).  This is a list with the removal
of the ovbious ones.

While I was doing this I fonund:
- we remove -softmmu/config-devices.mak when we do make clean
  That is an "user" configuration file, we shouldn't do that.
- Use land/lor for consistence
- CONFIG_SERIAL was defined twice for all configurations that include
  pci.mak, fix it.
- pvpanic: We can do the same tricks that everywhere to be able to
  compile it out.

To do a better job, we are in trouble because we only have
"config-devices.mak", but not config-devices.h, so we can't disable
part of the tests/files when we don't want them.  Bigger culprits here
are usb and virtio devices, basically all of them depend of the others
one way or another.

Motivation:

- I compile *lots* of times a day, so it is great to be able to
  compile less devices, it takes less time.
- But if I want to do make check, I need to compile basically a full
  configuration for that platform, so we are at square one.

There are still things that still take too long:
- e1000*/virtio-net pxe test.  It takes more than one second for each,
  and we have e1000/virtio-net/e1000p/virtio-net(again).
- qom tests.  We check _all_ machine types here.  In fast mode, IMHO
  we would only want something like pc-3.0 and q35-30 in fast mode
  (in slow mode everything is ok).
- migration tests: yes, they also took around 5-6 seconds in total,
  and we are adding new tests.  Something needs to be done here.

Time to do "make check" on my laptop (reasonably fast laptop from this
Jannuary) is almost 3mins.  This makes it too long to run continously
for testing that I haven't broken anything.

In another submission I wil send some examples on "how" to disable
other drivers that we can't do now.  But it requires that we generate
config-devices.h to be able to apply them (or yet more complicated
things of registration, see how virtio devices needs to be disabled)

Please review, Juan.

Juan Quintela (25):
  configure: We don't want to clean configuration files
  config:  CONFIG_SERIAL* is already in pci.mak
  check: Use land/lor when possible
  check: Only test vmxnet3 when it is compiled in
  check: Only test ne2000 when it is compiled in
  check: Only test eepro100 when it is compiled in
  check: Only test pcnet when it is compiled in
  check: Only test rtl8139 when it is compiled in
  check: Only test es1370 when it is compiled in
  check: Only test ac97 when it is compiled in
  check: Only test hda when it is compiled in
  check: Only test ipack when it is compiled in
  check: Only test isa-testdev when it is compiled in
  check: Only test ioh3420 when it is compiled in
  check: Only test i82801b11 when it is compiled in
  check: Only test sdhci when it is compiled in
  check: Only test wdt_ib700 when it is compiled in
  check: Only test pvpanic when it is compiled in
  check: Only test nvme when it is compiled in
  check: Only test usb-xhci-nec when it is compiled in
  check: Only test usb-ohci when it is compiled in
  check: Only test usb-uhci devices when they are compiled in
  check: Only test usb-ehci when it is compiled in
  check: Only test ivshm when it is compiled in
  check: Only test tpm devices when they are compiled in

 Makefile|   2 +-
 default-configs/alpha-softmmu.mak   |   2 -
 default-configs/arm-softmmu.mak |   2 -
 default-configs/hppa-softmmu.mak|   3 -
 default-configs/i386-softmmu.mak|   2 -
 default-configs/mips-softmmu-common.mak |   2 -
 default-configs/ppc-softmmu.mak |   1 -
 default-configs/ppcemb-softmmu.mak  |   2 -
 default-configs/sh4-softmmu.mak |   2 -
 default-configs/sh4eb-softmmu.mak   |   2 -
 default-configs/sparc64-softmmu.mak |   2 -
 default-configs/x86_64-softmmu.mak  |   2 -
 hw/misc/pvpanic.c   |  11 --
 include/hw/misc/pvpanic.h   |  11 +-
 tests/Makefile.include  | 144 
 15 files changed, 81 insertions(+), 109 deletions(-)

-- 
2.17.1




[Qemu-devel] [PATCH 04/25] check: Only test vmxnet3 when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 47aea32193..e9dd3e8928 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -270,8 +270,8 @@ check-qtest-i386-y += tests/tco-test$(EXESUF)
 gcov-files-i386-y += hw/watchdog/watchdog.c hw/watchdog/wdt_ib700.c
 check-qtest-i386-y += $(check-qtest-pci-y)
 gcov-files-i386-y += $(gcov-files-pci-y)
-check-qtest-i386-y += tests/vmxnet3-test$(EXESUF)
-gcov-files-i386-y += hw/net/vmxnet3.c
+check-qtest-i386-$(CONFIG_VMXNET3_PCI) += tests/vmxnet3-test$(EXESUF)
+gcov-files-i386-$(CONFIG_VMXNET3_PCI) += hw/net/vmxnet3.c
 gcov-files-i386-y += hw/net/net_rx_pkt.c
 gcov-files-i386-y += hw/net/net_tx_pkt.c
 check-qtest-i386-y += tests/pvpanic-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 07/25] check: Only test pcnet when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 560f486416..a039b70f9b 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -215,9 +215,9 @@ check-qtest-pci-y += tests/e1000e-test$(EXESUF)
 gcov-files-pci-y += hw/net/e1000e.c hw/net/e1000e_core.c
 check-qtest-pci-y += tests/rtl8139-test$(EXESUF)
 gcov-files-pci-y += hw/net/rtl8139.c
-check-qtest-pci-y += tests/pcnet-test$(EXESUF)
-gcov-files-pci-y += hw/net/pcnet.c
-gcov-files-pci-y += hw/net/pcnet-pci.c
+check-qtest-pci-$(CONFIG_PCNET_PCI) += tests/pcnet-test$(EXESUF)
+gcov-files-pci-$(CONFIG_PCNET_PCI) += hw/net/pcnet.c
+gcov-files-pci-$(CONFIG_PCNET_PCI) += hw/net/pcnet-pci.c
 check-qtest-pci-$(CONFIG_EEPRO100_PCI) += tests/eepro100-test$(EXESUF)
 gcov-files-pci-$(CONFIG_EEPRO100_PCI) += hw/net/eepro100.c
 check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 01/25] configure: We don't want to clean configuration files

2018-07-17 Thread Juan Quintela
If you don't want to compile everything, you configure
config-devices.mak.  And then make clean remove it, and make will
create a default one without your configuration.  Fix it by not
removing it.

Signed-off-by: Juan Quintela 
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 2da686be33..2ffbcde323 100644
--- a/Makefile
+++ b/Makefile
@@ -751,7 +751,7 @@ clean:
if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
rm -f $$d/qemu-options.def; \
 done
-   rm -f $(SUBDIR_DEVICES_MAK) config-all-devices.mak
+   rm -f config-all-devices.mak
 
 VERSION ?= $(shell cat VERSION)
 
-- 
2.17.1




[Qemu-devel] [PATCH 03/25] check: Use land/lor when possible

2018-07-17 Thread Juan Quintela
So everythig is (a bit) more consistent

Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index a49282704e..47aea32193 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -98,11 +98,9 @@ check-unit-y += tests/test-block-backend$(EXESUF)
 check-unit-y += tests/test-x86-cpuid$(EXESUF)
 # all code tested by test-x86-cpuid is inside topology.h
 gcov-files-test-x86-cpuid-y =
-ifeq ($(CONFIG_SOFTMMU),y)
-check-unit-y += tests/test-xbzrle$(EXESUF)
-gcov-files-test-xbzrle-y = migration/xbzrle.c
-check-unit-$(CONFIG_POSIX) += tests/test-vmstate$(EXESUF)
-endif
+check-unit-$(CONFIG_SOFTMMU) += tests/test-xbzrle$(EXESUF)
+gcov-files-test-xbzrle-$(CONFIG_SOFTMMU) = migration/xbzrle.c
+check-unit-$(call land, $(CONFIG_SOFTMMU), $(CONFIG_POSIX)) += 
tests/test-vmstate$(EXESUF)
 check-unit-y += tests/test-cutils$(EXESUF)
 gcov-files-test-cutils-y += util/cutils.c
 check-unit-y += tests/test-shift128$(EXESUF)
@@ -297,9 +295,7 @@ check-qtest-i386-y += tests/q35-test$(EXESUF)
 check-qtest-i386-y += tests/vmgenid-test$(EXESUF)
 gcov-files-i386-y += hw/pci-host/q35.c
 check-qtest-i386-$(CONFIG_VHOST_USER_NET_TEST_i386) += 
tests/vhost-user-test$(EXESUF)
-ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),)
-check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) += 
tests/vhost-user-test$(EXESUF)
-endif
+check-qtest-x86_64-$(call lor, $(CONFIG_VHOST_USER_NET_TEST_i386), 
$(CONFIG_VHOST_USER_NET_TEST_x86_64)) += tests/vhost-user-test$(EXESUF)
 check-qtest-i386-$(CONFIG_TPM) += tests/tpm-crb-swtpm-test$(EXESUF)
 check-qtest-i386-$(CONFIG_TPM) += tests/tpm-crb-test$(EXESUF)
 check-qtest-i386-$(CONFIG_TPM) += tests/tpm-tis-swtpm-test$(EXESUF)
-- 
2.17.1




[Qemu-devel] [PATCH 02/25] config: CONFIG_SERIAL* is already in pci.mak

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 default-configs/alpha-softmmu.mak   | 2 --
 default-configs/arm-softmmu.mak | 2 --
 default-configs/hppa-softmmu.mak| 3 ---
 default-configs/i386-softmmu.mak| 2 --
 default-configs/mips-softmmu-common.mak | 2 --
 default-configs/ppc-softmmu.mak | 1 -
 default-configs/ppcemb-softmmu.mak  | 2 --
 default-configs/sh4-softmmu.mak | 2 --
 default-configs/sh4eb-softmmu.mak   | 2 --
 default-configs/sparc64-softmmu.mak | 2 --
 default-configs/x86_64-softmmu.mak  | 2 --
 11 files changed, 22 deletions(-)

diff --git a/default-configs/alpha-softmmu.mak 
b/default-configs/alpha-softmmu.mak
index bbe361f01a..2d81a98441 100644
--- a/default-configs/alpha-softmmu.mak
+++ b/default-configs/alpha-softmmu.mak
@@ -2,8 +2,6 @@
 
 include pci.mak
 include usb.mak
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_I82374=y
 CONFIG_I8254=y
 CONFIG_I8257=y
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index 834d45cfaf..4d33e9983d 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -5,8 +5,6 @@ include usb.mak
 CONFIG_VGA=y
 CONFIG_NAND=y
 CONFIG_ECC=y
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_PTIMER=y
 CONFIG_SD=y
 CONFIG_MAX7310=y
diff --git a/default-configs/hppa-softmmu.mak b/default-configs/hppa-softmmu.mak
index 4badc0521e..f3712afc27 100644
--- a/default-configs/hppa-softmmu.mak
+++ b/default-configs/hppa-softmmu.mak
@@ -1,8 +1,5 @@
 include pci.mak
 include usb.mak
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
-CONFIG_ISA_BUS=y
 CONFIG_I8259=y
 CONFIG_E1000_PCI=y
 CONFIG_IDE_ISA=y
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 8c7d4a0fa0..8827166ba1 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -15,8 +15,6 @@ CONFIG_IPMI_LOCAL=y
 CONFIG_IPMI_EXTERN=y
 CONFIG_ISA_IPMI_KCS=y
 CONFIG_ISA_IPMI_BT=y
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
 CONFIG_PCSPK=y
diff --git a/default-configs/mips-softmmu-common.mak 
b/default-configs/mips-softmmu-common.mak
index fae2347ee7..9bae997ca0 100644
--- a/default-configs/mips-softmmu-common.mak
+++ b/default-configs/mips-softmmu-common.mak
@@ -9,8 +9,6 @@ CONFIG_VGA_ISA=y
 CONFIG_VGA_ISA_MM=y
 CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
 CONFIG_PCSPK=y
diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.mak
index 3181bbf163..d8dd969499 100644
--- a/default-configs/ppc-softmmu.mak
+++ b/default-configs/ppc-softmmu.mak
@@ -53,7 +53,6 @@ CONFIG_IDE_MACIO=y
 # For PReP
 CONFIG_PREP=y
 CONFIG_PREP_PCI=y
-CONFIG_SERIAL_ISA=y
 CONFIG_MC146818RTC=y
 CONFIG_ISA_TESTDEV=y
 CONFIG_RS6000_MC=y
diff --git a/default-configs/ppcemb-softmmu.mak 
b/default-configs/ppcemb-softmmu.mak
index ac44f150c6..f7a0d577d8 100644
--- a/default-configs/ppcemb-softmmu.mak
+++ b/default-configs/ppcemb-softmmu.mak
@@ -5,8 +5,6 @@ include sound.mak
 include usb.mak
 CONFIG_PPC4XX=y
 CONFIG_M48T59=y
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_I8257=y
 CONFIG_OPENPIC=y
 CONFIG_PFLASH_CFI01=y
diff --git a/default-configs/sh4-softmmu.mak b/default-configs/sh4-softmmu.mak
index caeccd55be..2b46d57ab4 100644
--- a/default-configs/sh4-softmmu.mak
+++ b/default-configs/sh4-softmmu.mak
@@ -2,8 +2,6 @@
 
 include pci.mak
 include usb.mak
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_PTIMER=y
 CONFIG_PFLASH_CFI02=y
 CONFIG_SH4=y
diff --git a/default-configs/sh4eb-softmmu.mak 
b/default-configs/sh4eb-softmmu.mak
index 53b9cd7b5a..279896a43d 100644
--- a/default-configs/sh4eb-softmmu.mak
+++ b/default-configs/sh4eb-softmmu.mak
@@ -2,8 +2,6 @@
 
 include pci.mak
 include usb.mak
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_PTIMER=y
 CONFIG_PFLASH_CFI02=y
 CONFIG_SH4=y
diff --git a/default-configs/sparc64-softmmu.mak 
b/default-configs/sparc64-softmmu.mak
index 52edafe547..e039ae3057 100644
--- a/default-configs/sparc64-softmmu.mak
+++ b/default-configs/sparc64-softmmu.mak
@@ -4,8 +4,6 @@ include pci.mak
 include usb.mak
 CONFIG_M48T59=y
 CONFIG_PTIMER=y
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_PARALLEL=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index 0390b4303c..85528ac9af 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -15,8 +15,6 @@ CONFIG_IPMI_LOCAL=y
 CONFIG_IPMI_EXTERN=y
 CONFIG_ISA_IPMI_KCS=y
 CONFIG_ISA_IPMI_BT=y
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
 CONFIG_PCSPK=y
-- 
2.17.1




[Qemu-devel] [PATCH 05/25] check: Only test ne2000 when it is compiled in

2018-07-17 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 tests/Makefile.include | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index e9dd3e8928..ae77d26932 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -220,8 +220,8 @@ gcov-files-pci-y += hw/net/pcnet.c
 gcov-files-pci-y += hw/net/pcnet-pci.c
 check-qtest-pci-y += tests/eepro100-test$(EXESUF)
 gcov-files-pci-y += hw/net/eepro100.c
-check-qtest-pci-y += tests/ne2000-test$(EXESUF)
-gcov-files-pci-y += hw/net/ne2000.c
+check-qtest-pci-$(CONFIG_NE2000_PCI) += tests/ne2000-test$(EXESUF)
+gcov-files-pci-$(CONFIG_NE2000_PCI) += hw/net/ne2000.c
 check-qtest-pci-y += tests/nvme-test$(EXESUF)
 gcov-files-pci-y += hw/block/nvme.c
 check-qtest-pci-y += tests/ac97-test$(EXESUF)
-- 
2.17.1




Re: [Qemu-devel] [PATCH] Document command line options with single dash

2018-07-17 Thread Paolo Bonzini
On 17/07/2018 09:43, Thomas Huth wrote:
> On 16.07.2018 21:12, BALATON Zoltan wrote:
>> QEMU options have a single dash (but also work as double dash for
>> convenience and compatibility). Most options are listed with single
>> dash in command line help but some were listed with two dashes.
>> Normalize these to have the same format as the others.
>>
>> Left --preconfig as that is mentioned as double dash everywhere so I
>> assume that is the preferred form for that.
>>
>> Signed-off-by: BALATON Zoltan 
>> ---
>>  qemu-options.hx | 8 
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/qemu-options.hx b/qemu-options.hx
>> index 371c427..b1bf0f4 100644
>> --- a/qemu-options.hx
>> +++ b/qemu-options.hx
>> @@ -471,7 +471,7 @@ STEXI
>>  @item -balloon virtio[,addr=@var{addr}]
>>  @findex -balloon
>>  Enable virtio balloon device, optionally with PCI address @var{addr}. This
>> -option is deprecated, use @option{--device virtio-balloon} instead.
>> +option is deprecated, use @option{-device virtio-balloon} instead.
>>  ETEXI
>>  
>>  DEF("device", HAS_ARG, QEMU_OPTION_device,
>> @@ -2005,7 +2005,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
>>  "-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
>>  "configure a hub port on the hub with ID 'n'\n", 
>> QEMU_ARCH_ALL)
>>  DEF("nic", HAS_ARG, QEMU_OPTION_nic,
>> -"--nic [tap|bridge|"
>> +"-nic [tap|bridge|"
>>  #ifdef CONFIG_SLIRP
>>  "user|"
>>  #endif
>> @@ -2024,7 +2024,7 @@ DEF("nic", HAS_ARG, QEMU_OPTION_nic,
>>  "socket][,option][,...][mac=macaddr]\n"
>>  "initialize an on-board / default host NIC (using MAC 
>> address\n"
>>  "macaddr) and connect it to the given host network 
>> backend\n"
>> -"--nic none  use it alone to have zero network devices (the default 
>> is to\n"
>> +"-nic none   use it alone to have zero network devices (the default 
>> is to\n"
>>  "provided a 'user' network connection)\n",
>>  QEMU_ARCH_ALL)
>>  DEF("net", HAS_ARG, QEMU_OPTION_net,
>> @@ -3339,7 +3339,7 @@ mlocking qemu and guest memory can be enabled via 
>> @option{mlock=on}
>>  ETEXI
>>  
>>  DEF("overcommit", HAS_ARG, QEMU_OPTION_overcommit,
>> -"--overcommit [mem-lock=on|off][cpu-pm=on|off]\n"
>> +"-overcommit [mem-lock=on|off][cpu-pm=on|off]\n"
>>  "run qemu with overcommit hints\n"
>>  "mem-lock=on|off controls memory lock support (default: 
>> off)\n"
>>  "cpu-pm=on|off controls cpu power management (default: 
>> off)\n",
>>
> 
> Acked-by: Thomas Huth 
> 
> ... I'm in favour for consistency for the 3.0 release. But in the long
> run, we should really come to a conclusion what we prefer (we still got
> the double dash task at
> https://wiki.qemu.org/BiteSizedTasks#Consistent_option_usage_in_documentation
> )
> 

Queued, thanks.

Paolo



Re: [Qemu-devel] [kvm-unit-tests PATCH 2/2] arm64: timer: Add TVAL timeout IRQ trigger test

2018-07-17 Thread Andrew Jones
On Mon, Jul 16, 2018 at 04:14:38PM +0100, Andre Przywara wrote:
> So far we were only testing the CVAL register. Add a test which programs
> a (relative) TVAL value to check this functionality as well.
> Also we go into WFI and wait for the interrupt to release us from it.
> The timer tests are run with a 2 second timeout on the host side, so
> that any failure in coming back would be covered.
> 
> Signed-off-by: Andre Przywara 
> ---
>  arm/timer.c | 10 ++
>  1 file changed, 10 insertions(+)
>

Reviewed-by: Andrew Jones 



Re: [Qemu-devel] [kvm-unit-tests PATCH 1/2] arm64: timer: add TVAL accessors

2018-07-17 Thread Andrew Jones
On Mon, Jul 16, 2018 at 04:14:37PM +0100, Andre Przywara wrote:
> The ARM arch timer features the CVAL register, which holds an absolute
> value that is compared against the counter value.
> But there is also the TVAL register, which is defined as (CVAL - counter),
> and can be used to program or read relative timeouts.
> 
> Add accessors for the TVAL register, to be able to read and write them
> easily later.
> 
> Signed-off-by: Andre Przywara 
> ---
>  arm/timer.c | 26 ++
>  1 file changed, 26 insertions(+)
>

Reviewed-by: Andrew Jones 



[Qemu-devel] [Bug 1587065] Re: btrfs qemu-ga - multiple mounts block fsfreeze

2018-07-17 Thread  Christian Ehrhardt 
Tests are all ok, MP review was acked and case confirmed.
No Security Update since then in between, so sponsoring into SRU queue now ...

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

Title:
  btrfs qemu-ga - multiple mounts block fsfreeze

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Xenial:
  In Progress

Bug description:
  [Impact]

   * backport upstream fix to avoid double unmounts (e.g. bind mounts)
     hanging the freeze action.

  [Test Case]

   * Prepare a guest
     $ uvt-simplestreams-libvirt --verbose sync --source 
http://cloud-images.ubuntu.com/daily arch=amd64 release=xenial label=daily
  uvt-kvm create --password ubuntu x-freeze arch=amd64 release=xenial 
label=daily

   * Shut it down and use virsh edit to add a channel for the agent. Add this 
somewhere under :
  
     
     
  

    * Start the guest again, in it install qemu-guest-agent

    *

    * On the Host then freeze and thaw the guest
  $ virsh domfsfreeze x-freeze
  $ virsh domfsthaw x-freeze

    # The above works, then trigger the issue, in the guest do
  $ sudo mkdir /mnt/test
  $ sudo mount -o bind / /mnt/test/

    * Now the freeze/thaw will fail unless the fix is applied to the
  guest.

  [Regression Potential]

   * From looking at the code alone I could think of a different cause that
     makes it return EBUSY.
     The biggest risk I could see due to that is the agent reporting a
     successful freeze due to accepting EBUSY which is not actually true.
     But we have that in Ubuntu since Artful and
     upstream since January 2017 and there are no such reports.

  [Other Info]

   * n/a

  ---

  Having two mounts of the same device makes fsfreeze through qemu-ga 
impossible.
  root@CmsrvMTA:/# mount -l | grep /dev/vda2
  /dev/vda2 on / type btrfs (rw,relatime,space_cache,subvolid=257,subvol=/@)
  /dev/vda2 on /home type btrfs 
(rw,relatime,space_cache,subvolid=258,subvol=/@home)

  Having two mounts is rather common with btrfs, so the feature fsfreeze
  is unusable on these systems.

  Below more information about how we encountered this issue...

  Message send to qemu-disc...@nongnu.org:

  Message 1:
  --
  I use external snapshots to backup my guests. I use the 'quiesce' option to 
flush and frees the guest file system with the qemu guest agent.

  With the exeption of one guest, this procedure works fine. On the 'unwilling' 
guest, I get this error message:
  "ERROR 2016-05-25 00:51:19 | T25-bakVMSCmsrvVH2 | fout: internal error: 
unable to execute QEMU agent command 'guest-fsfreeze-freeze': failed to freeze 
/: Device or resource busy"

  I don't think this is not some sort of time-out error, because
  activation of the fsfreeze and the error message happen immediately
  after each other:

  $ grep qemu-ga syslog.1
  May 25 00:51:19 CmsrvMTA qemu-ga: info: guest-fsfreeze called

  This is the only entry of the qemu guest agent in syslog.

  $ sudo virsh version
  Compiled against library: libvirt 1.3.1
  Using library: libvirt 1.3.1
  Gebruikte API: QEMU 1.3.1
  Draaiende hypervisor: QEMU 2.5.0

  $ virsh qemu-agent-command CmsrvMTA '{"execute": "guest-info"}'
  {"return":{"version":"2.5.0", ... 
,{"enabled":true,"name":"guest-fstrim","success-response":true},{"enabled":true,"name":"guest-fsfreeze-thaw","success-response":true},{"enabled":true,"name":"guest-fsfreeze-status","success-response":true},{"enabled":true,"name":"guest-fsfreeze-freeze-list","success-response":true},{"enabled":true,"name":"guest-fsfreeze-freeze","success-response":true},
 ... }

  For making an external snapshot, I use this command:
  $ virsh snapshot-create-as --domain CmsrvMTA sn1 --disk-only --atomic 
--quiesce --no-metadata --diskspec vda,file=/srv/poolVMS/CmsrvMTA.sn1

  Piece of reply 1:
  -
  I have encountered this before. Some operating systems
   may have bind-mounts that let a device appear multiple times in the mount 
list. Unfortunately the guest agent is not smart enough to consider a device 
that has been frozen as succesfull and keep going. This causes this specific 
error.

  Piece of reply 2:
  -
  Ok, that seems to be it.

  I’ve got the ‘/’ and ‘/home’ on the same device formatted as btrfs on
  two separate sub volumes.

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



Re: [Qemu-devel] [PATCH v2 for-2.11.2] spapr: make pseries-2.11 the default machine type

2018-07-17 Thread David Gibson
On Thu, Jun 21, 2018 at 03:23:21PM +0200, Greg Kurz wrote:
> On Thu, 21 Jun 2018 11:18:09 +1000
> David Gibson  wrote:
> 
> > On Wed, Jun 20, 2018 at 02:54:15PM +0200, Greg Kurz wrote:
> > > The spapr capability framework was introduced in QEMU 2.12. It allows
> > > to have an explicit control on how host features are exposed to the
> > > guest. This is especially needed to handle migration between hetero-
> > > geneous hosts (eg, POWER8 to POWER9). It is also used to expose fixes/
> > > workarounds against speculative execution vulnerabilities to guests.
> > > The framework was hence backported to QEMU 2.11.1, especially these
> > > commits:
> > > 
> > > 0fac4aa93074 spapr: Add pseries-2.12 machine type
> > > 9070f408f491 spapr: Treat Hardware Transactional Memory (HTM) as an
> > >  optional capability
> > > 
> > > 0fac4aa93074 has the confusing effect of making pseries-2.12 the default
> > > machine type for QEMU 2.11.1, instead of the expected pseries-2.11. This
> > > patch changes the default machine back to pseries-2.11.
> > > 
> > > Unfortunately, 9070f408f491 enforces the HTM capability for pseries-2.11
> > > to be enabled by default, ie, when not passing cap-htm on the command
> > > line. This breaks several 'make check' testcases that run 
> > > qemu-system-ppc64
> > > with TCG.
> > > 
> > > The only sane way to fix this is to adapt the impacted testcases so that
> > > they all pass cap-htm=off in this case. This patch does that as well.
> > > 
> > > Signed-off-by: Greg Kurz 
> > > ---
> > > v2: - have the testcases to pass cap-htm=off instead of violating the
> > >   capabilities logic.
> > > 
> > > Upstream doesn't need anything like that since newer pseries machine types
> > > start with HTM disabled by default. This is really a oneshot fix for 
> > > 2.11.2,
> > > and I've tried to make it as small as possible.
> > > 
> > > This is a full replacement of the previous version. It is based on Mike's
> > > staging tree for 2.11:  
> > 
> > Thanks for fixing this up
> > 
> > Reviewed-by: David Gibson 
> > 
> > Btw, 2.11.z should probably have the 2.12 machine type removed
> > entirely, as well as (obviously) not being the default.  Not within
> > scope for this patch, though.
> > 
> 
> Well... it is indeed weird but I don't think it hurts. Also, people
> may have started using pseries-2.12 with QEMU 2.11.1 (I seem to
> remember Mike told me about something like this the other day)...

I came back to thinking about this and realized this is a terrible
idea.  The problem is that because of the way we define the latest
machine type, then backwards compat props for the earlier ones, it's
very likely that the "pseries-2.12" in 2.11 won't be the same as
pseries-2.12 in 2.12, simply because 2.11 won't have the necessary
features to implement pseries-2.12 as in 2.12.


-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v8 2/5] tpm: implement virtual memory device for TPM PPI

2018-07-17 Thread Marc-André Lureau
Hi

On Tue, Jul 17, 2018 at 12:03 PM, Igor Mammedov  wrote:
> On Mon, 16 Jul 2018 14:59:45 +0200
> Marc-André Lureau  wrote:
>
>> From: Stefan Berger 
>>
>> Implement a virtual memory device for the TPM Physical Presence interface.
>> The memory is located at 0xFED45000 and used by ACPI to send messages to the
>> firmware (BIOS) and by the firmware to provide parameters for each one of
>> the supported codes.
> ...
> another question wrt E820 table, is firmware putting a reservation record
> for this RAM area overlay or should we do it QEMU?

There doesn't seem to be any reservation done in ovmf, or on my
laptop. I also wonder if it should be done. And how OS deal with that
today (/proc/iomem is correct).

Laszlo, any idea?



Re: [Qemu-devel] [PATCH] opts: fix NULL pointer derefernce in get_opt_value

2018-07-17 Thread Paolo Bonzini
On 16/07/2018 20:47, Daniel P. Berrange wrote:
> On Mon, Jul 16, 2018 at 06:41:46PM +0100, Mike Krinkin wrote:
>> The value argument can be NULL, for example, in hw/i386/multiboot.c
>> in the load_multiboot function get_opt_value is explicitly called
>> with NULL as the second argument.
>>
>> The problem was introduced in commit 950c4e6c94b1 ("opts: don't
>> silently truncate long option values"). This change fixes the
>> problem by adding a check whether the value is NULL or not.
>>
>> Signed-off-by: Mike Krinkin 
>> ---
>>  util/qemu-option.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> This problem is fixed in this:
> 
>   https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg01490.html
> 
> but it is still waiting for i386 maintainers to respond

Generally Kevin has looked at multiboot patches, but I'll merge these
ones because he's on vacation.  Thanks,

Paolo




Re: [Qemu-devel] [PATCH for 3.1 2/4] virtio: Check qemu_get_virtqueue_element returns

2018-07-17 Thread Stefan Hajnoczi
On Mon, Jul 16, 2018 at 06:37:41PM +0100, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" 
> 
> Check calls to qemu_get_virtqueue_element for NULL and pass
> up the chain.

What happens to the device state that has been partially deserialized
(e.g. virtio-blk's s->rq linked list)?

It's not clear to me that simply returning NULL is enough to put QEMU
into a sane state without memory leaks or crashes if we decide to retry.


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v8 2/5] tpm: implement virtual memory device for TPM PPI

2018-07-17 Thread Marc-André Lureau
On Tue, Jul 17, 2018 at 9:59 AM, Igor Mammedov  wrote:
> On Mon, 16 Jul 2018 16:56:36 +0200
> Marc-André Lureau  wrote:
>
>> Hi
>>
>> On Mon, Jul 16, 2018 at 4:44 PM, Igor Mammedov  wrote:
>> > On Mon, 16 Jul 2018 14:59:45 +0200
>> > Marc-André Lureau  wrote:
>> >
>> >> From: Stefan Berger 
>> >>
>> >> Implement a virtual memory device for the TPM Physical Presence interface.
>> >> The memory is located at 0xFED45000 and used by ACPI to send messages to 
>> >> the
>> >> firmware (BIOS) and by the firmware to provide parameters for each one of
>> >> the supported codes.
>> > it doesn't implement anything, maybe something like this would be better?
>> >
>> > tpm: allocate/map buffer for TPM Physical Presence interface
>> >
>> > ...
>> >
>> >>
>> >> This device should be used by all TPM interfaces on x86 and can be added
>> >> by calling tpm_ppi_init_io().
>> > Did you mean:
>> >  This *interface* should be used by all TPM *devices* on x86 and can be 
>> > added
>> >  by calling tpm_ppi_init_io().
>> >
>> >
>> >> Note: bios_linker cannot be used to allocate the PPI memory region,
>> >> since the reserved memory should stay stable across reboots, and might
>> >> be needed before the ACPI tables are installed.
>> >>
>> >> Signed-off-by: Stefan Berger 
>> >> Signed-off-by: Marc-André Lureau 
>> >> ---
>> >>  hw/tpm/tpm_ppi.h  | 26 ++
>> >>  include/hw/acpi/tpm.h |  6 ++
>> >>  hw/tpm/tpm_crb.c  |  8 
>> >>  hw/tpm/tpm_ppi.c  | 31 +++
>> >>  hw/tpm/tpm_tis.c  |  8 
>> >>  hw/tpm/Makefile.objs  |  1 +
>> >>  6 files changed, 80 insertions(+)
>> >>  create mode 100644 hw/tpm/tpm_ppi.h
>> >>  create mode 100644 hw/tpm/tpm_ppi.c
>> >>
>> >> diff --git a/hw/tpm/tpm_ppi.h b/hw/tpm/tpm_ppi.h
>> >> new file mode 100644
>> >> index 00..f6458bf87e
>> >> --- /dev/null
>> >> +++ b/hw/tpm/tpm_ppi.h
>> >> @@ -0,0 +1,26 @@
>> >> +/*
>> >> + * TPM Physical Presence Interface
>> >> + *
>> >> + * Copyright (C) 2018 IBM Corporation
>> >> + *
>> >> + * Authors:
>> >> + *  Stefan Berger
>> >> + *
>> >> + * This work is licensed under the terms of the GNU GPL, version 2 or 
>> >> later.
>> >> + * See the COPYING file in the top-level directory.
>> >> + */
>> >> +#ifndef TPM_TPM_PPI_H
>> >> +#define TPM_TPM_PPI_H
>> >> +
>> >> +#include "hw/acpi/tpm.h"
>> >> +#include "exec/address-spaces.h"
>> >> +
>> >> +typedef struct TPMPPI {
>> >> +MemoryRegion ram;
>> >> +uint8_t buf[TPM_PPI_ADDR_SIZE];
>> >> +} TPMPPI;
>> >> +
>> >> +bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
>> >> +  hwaddr addr, Object *obj, Error **errp);
>> >> +
>> >> +#endif /* TPM_TPM_PPI_H */
>> >> diff --git a/include/hw/acpi/tpm.h b/include/hw/acpi/tpm.h
>> >> index 3580ffd50c..b8796df916 100644
>> >> --- a/include/hw/acpi/tpm.h
>> >> +++ b/include/hw/acpi/tpm.h
>> >> @@ -188,4 +188,10 @@ REG32(CRB_DATA_BUFFER, 0x80)
>> >>  #define TPM2_START_METHOD_MMIO  6
>> >>  #define TPM2_START_METHOD_CRB   7
>> >>
>> >> +/*
>> >> + * Physical Presence Interface
>> >> + */
>> >> +#define TPM_PPI_ADDR_SIZE   0x400
>> >> +#define TPM_PPI_ADDR_BASE   0xFED45000
>> >> +
>> >>  #endif /* HW_ACPI_TPM_H */
>> >> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
>> >> index d5b0ac5920..b243222fd6 100644
>> >> --- a/hw/tpm/tpm_crb.c
>> >> +++ b/hw/tpm/tpm_crb.c
>> >> @@ -29,6 +29,7 @@
>> >>  #include "sysemu/reset.h"
>> >>  #include "tpm_int.h"
>> >>  #include "tpm_util.h"
>> >> +#include "tpm_ppi.h"
>> >>  #include "trace.h"
>> >>
>> >>  typedef struct CRBState {
>> >> @@ -43,6 +44,7 @@ typedef struct CRBState {
>> >>  size_t be_buffer_size;
>> >>
>> >>  bool ppi_enabled;
>> >> +TPMPPI ppi;
>> >>  } CRBState;
>> >>
>> >>  #define CRB(obj) OBJECT_CHECK(CRBState, (obj), TYPE_TPM_CRB)
>> >> @@ -294,6 +296,12 @@ static void tpm_crb_realize(DeviceState *dev, Error 
>> >> **errp)
>> >>  memory_region_add_subregion(get_system_memory(),
>> >>  TPM_CRB_ADDR_BASE + sizeof(s->regs), >cmdmem);
>> >>
>> >> +if (s->ppi_enabled &&
>> >> +!tpm_ppi_init(>ppi, get_system_memory(),
>> >> +  TPM_PPI_ADDR_BASE, OBJECT(s), errp)) {
>> >> +return;
>> >> +}
>> >> +
>> >>  qemu_register_reset(tpm_crb_reset, dev);
>> >>  }
>> >>
>> >> diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
>> >> new file mode 100644
>> >> index 00..8b46b9dd4b
>> >> --- /dev/null
>> >> +++ b/hw/tpm/tpm_ppi.c
>> >> @@ -0,0 +1,31 @@
>> >> +/*
>> >> + * tpm_ppi.c - TPM Physical Presence Interface
>> >> + *
>> >> + * Copyright (C) 2018 IBM Corporation
>> >> + *
>> >> + * Authors:
>> >> + *  Stefan Berger 
>> >> + *
>> >> + * This work is licensed under the terms of the GNU GPL, version 2 or 
>> >> later.
>> >> + * See the COPYING file in the top-level directory.
>> >> + *
>> >> + */
>> >> +
>> >> +#include "qemu/osdep.h"
>> >> +
>> >> +#include "qapi/error.h"
>> >> +#include "cpu.h"
>> >> +#include 

Re: [Qemu-devel] [PATCH v2 for 3.0 07/16] docker: gracefully skip check_qemu

2018-07-17 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> On 07/13/2018 09:17 AM, Alex Bennée wrote:
>> Not all our images are able to run the tests. Rather than use features
>> we can just check for the existence and run-ability of gtester. If the
>> image has been setup for binfmt_misc it will be able to run anyway.
>>
>> Signed-off-by: Alex Bennée 
>> ---
>>  tests/docker/common.rc | 8 +++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/docker/common.rc b/tests/docker/common.rc
>> index cfc620d554..6df431eb72 100755
>> --- a/tests/docker/common.rc
>> +++ b/tests/docker/common.rc
>> @@ -47,7 +47,13 @@ check_qemu()
>>  else
>>  TEST="$@"
>>  fi
>> -make $MAKEFLAGS $TEST
>> +
>> +if type gtester > /dev/null 2>&1 && \
>
> commit e465ce7d09939d631f1861e0bd8873417c1c0d65
>
> tests: Use "command -v" instead of which(1) in shell scripts

type is also a shell built-in albeit an 1982 bashism. I'll switch to
command -v as tending towards POSIX is what we should aim for (although
our test-FOO/common.rc structure seems a little confused).

>
> When which(1) is not installed, we would complain "perl not found"
> because it's the first set_prog_path check. The error message is
> wrong.
>
> Fix it by using "command -v", a native way to query the existence
> of a command.
>
>> +   gtester --version > /dev/null 2>&1; then
>> +make $MAKEFLAGS $TEST
>> +else
>> +echo "No working gtester, skipping make $TEST"
>> +fi
>>  }
>>
>>  test_fail()
>>


--
Alex Bennée



[Qemu-devel] [PATCH v3] trace/simple: fix hang in child after fork(2)

2018-07-17 Thread Stefan Hajnoczi
The simple trace backend spawns a write-out thread which is used to
asynchronously flush the in-memory ring buffer to disk.

fork(2) does not clone all threads, only the thread that invoked
fork(2).  As a result there is no write-out thread in the child process!

This causes a hang during shutdown when atexit(3) handler installed by
the simple trace backend waits for the non-existent write-out thread.

This patch uses pthread_atfork(3) to terminate the write-out thread
before fork and restart it in both the parent and child after fork.
This solves a hang in qemu-iotests 147 due to qemu-nbd --fork usage.

Reported-by: Cornelia Huck 
Suggested-by: Paolo Bonzini 
Signed-off-by: Stefan Hajnoczi 
---
v3:
 * Hold trace_lock across fork() to prevent possibility of another
   thread holding it and disappearing [Paolo]

 trace/simple.c | 80 --
 1 file changed, 71 insertions(+), 9 deletions(-)

diff --git a/trace/simple.c b/trace/simple.c
index 701dec639c..a4300b6ff1 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -39,9 +39,11 @@
 static GMutex trace_lock;
 static GCond trace_available_cond;
 static GCond trace_empty_cond;
+static GThread *trace_writeout_thread;
 
 static bool trace_available;
 static bool trace_writeout_enabled;
+static bool trace_writeout_running;
 
 enum {
 TRACE_BUF_LEN = 4096 * 64,
@@ -142,15 +144,34 @@ static void flush_trace_file(bool wait)
 g_mutex_unlock(_lock);
 }
 
-static void wait_for_trace_records_available(void)
+/**
+ * Wait to be kicked by flush_trace_file()
+ *
+ * Returns: true if the writeout thread should continue
+ *  false if the writeout thread should terminate
+ */
+static bool wait_for_trace_records_available(void)
 {
+bool running;
+
 g_mutex_lock(_lock);
-while (!(trace_available && trace_writeout_enabled)) {
+for (;;) {
+running = trace_writeout_running;
+if (!running) {
+break;
+}
+
+if (trace_available && trace_writeout_enabled) {
+break;
+}
+
 g_cond_signal(_empty_cond);
 g_cond_wait(_available_cond, _lock);
 }
 trace_available = false;
 g_mutex_unlock(_lock);
+
+return running;
 }
 
 static gpointer writeout_thread(gpointer opaque)
@@ -165,9 +186,7 @@ static gpointer writeout_thread(gpointer opaque)
 size_t unused __attribute__ ((unused));
 uint64_t type = TRACE_RECORD_TYPE_EVENT;
 
-for (;;) {
-wait_for_trace_records_available();
-
+while (wait_for_trace_records_available()) {
 if (g_atomic_int_get(_events)) {
 dropped.rec.event = DROPPED_EVENT_ID,
 dropped.rec.timestamp_ns = get_clock();
@@ -398,18 +417,61 @@ static GThread *trace_thread_create(GThreadFunc fn)
 return thread;
 }
 
+#ifndef _WIN32
+static void stop_writeout_thread(void)
+{
+g_mutex_lock(_lock);
+trace_writeout_running = false;
+g_cond_signal(_available_cond);
+g_mutex_unlock(_lock);
+
+g_thread_join(trace_writeout_thread);
+trace_writeout_thread = NULL;
+
+/* Hold trace_lock across fork!  Since threads aren't cloned by fork() the
+ * mutex would be held in the child process and cause a deadlock.
+ * Acquiring the mutex here prevents other threads from being in a
+ * trace_lock critical region when fork() occurs.
+ */
+g_mutex_lock(_lock);
+}
+
+static void restart_writeout_thread(void)
+{
+trace_writeout_running = true;
+trace_writeout_thread = trace_thread_create(writeout_thread);
+if (!trace_writeout_thread) {
+warn_report("unable to initialize simple trace backend");
+}
+
+/* This relies on undefined behavior in the fork() child (it's fine in the
+ * fork() parent).  g_mutex_unlock() on a mutex acquired by another thread
+ * is undefined (see glib documentation).
+ */
+g_mutex_unlock(_lock);
+}
+#endif /* !_WIN32 */
+
 bool st_init(void)
 {
-GThread *thread;
-
 trace_pid = getpid();
+trace_writeout_running = true;
 
-thread = trace_thread_create(writeout_thread);
-if (!thread) {
+trace_writeout_thread = trace_thread_create(writeout_thread);
+if (!trace_writeout_thread) {
 warn_report("unable to initialize simple trace backend");
 return false;
 }
 
+#ifndef _WIN32
+/* Terminate writeout thread across fork and restart it in parent and
+ * child afterwards.
+ */
+pthread_atfork(stop_writeout_thread,
+   restart_writeout_thread,
+   restart_writeout_thread);
+#endif
+
 atexit(st_flush_trace_buffer);
 return true;
 }
-- 
2.17.1




Re: [Qemu-devel] [PATCH v8 2/5] tpm: implement virtual memory device for TPM PPI

2018-07-17 Thread Igor Mammedov
On Mon, 16 Jul 2018 14:59:45 +0200
Marc-André Lureau  wrote:

> From: Stefan Berger 
> 
> Implement a virtual memory device for the TPM Physical Presence interface.
> The memory is located at 0xFED45000 and used by ACPI to send messages to the
> firmware (BIOS) and by the firmware to provide parameters for each one of
> the supported codes.
...
another question wrt E820 table, is firmware putting a reservation record
for this RAM area overlay or should we do it QEMU?



[Qemu-devel] [Bug 1755912] Re: qemu-system-x86_64 crashed with SIGABRT when using option -vga qxl

2018-07-17 Thread  Christian Ehrhardt 
Nice, thanks Leonardo for the Bisect - lets call upstream Fixed
Committed then (as there is no 2.13 released yet).

For the separate gl discussion feel free to subscribe/chime in on bug
1657409

Currently 2.12 is on its way into Cosmic.
I'll add and test that patch afterwards, it looks small and safe to me.

** Changed in: qemu
   Status: New => Fix Committed

** Changed in: qemu (Ubuntu)
   Status: Confirmed => Triaged

** Tags added: qemu-18.10 server-next

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

Title:
  qemu-system-x86_64 crashed with SIGABRT when using option -vga qxl

Status in QEMU:
  Fix Committed
Status in qemu package in Ubuntu:
  Triaged

Bug description:
  When using qemu-system-x86_64 with the option -vga qxl, it crashes.
  The easiest way to crash it is by trying to change the guest's
  resolution. However, the system may randomly crash too, not happening
  only when changing resolution. Here is the terminal output of one of
  these random crashes:

  

  $ qemu-system-x86_64 -hda /dev/sdb -m 2048 -enable-kvm -cpu host -vga qxl 
-nodefaults -netdev user,id=hostnet0 -device 
virtio-net-pci,id=net0,netdev=hostnet0
  WARNING: Image format was not specified for '/dev/sdb' and probing guessed 
raw.
   Automatically detecting the format is dangerous for raw images, 
write operations on block 0 will be restricted.
   Specify the 'raw' format explicitly to remove the restrictions.

  (process:21313): Spice-WARNING **: 16:01:45.759: display-
  channel.c:2431:display_channel_validate_surface: canvas address is
  0x7f8eb948ab18 for 0 (and is NULL)

  
  (process:21313): Spice-WARNING **: 16:01:45.759: 
display-channel.c:2432:display_channel_validate_surface: failed on 0

  (process:21313): Spice-CRITICAL **: 16:01:45.759: 
display-channel.c:2035:display_channel_update: condition 
`display_channel_validate_surface(display, surface_id)' failed
  Abortado (imagem do núcleo gravada)

  

  I was running QEMU as a normal user which is on the groups kvm and
  disk. Initially I supposed the problem was because I was running QEMU
  as root, but as a normal user this happens too.

  I have tested with guests with different Ubuntu version: 18.04, 17.10
  and 16.04. It is happening with them all.

  ProblemType: Crash
  DistroRelease: Ubuntu 18.04
  Package: qemu-system-x86 1:2.11+dfsg-1ubuntu4
  ProcVersionSignature: Ubuntu 4.15.0-10.11-generic 4.15.3
  Uname: Linux 4.15.0-10-generic x86_64
  ApportVersion: 2.20.8-0ubuntu10
  Architecture: amd64
  CurrentDesktop: XFCE
  Date: Wed Mar 14 17:13:52 2018
  ExecutablePath: /usr/bin/qemu-system-x86_64
  InstallationDate: Installed on 2017-06-13 (273 days ago)
  InstallationMedia: Xubuntu 17.04 "Zesty Zapus" - Release amd64 (20170412)
  KvmCmdLine: COMMAND STAT  EUID  RUID   PID  PPID %CPU COMMAND
  MachineType: LENOVO 80UG
  ProcCmdline: qemu-system-x86_64 -hda /dev/sdb -smp cpus=2 -m 512 -enable-kvm 
-cpu host -vga qxl -nodefaults -netdev user,id=hostnet0 -device 
virtio-net-pci,id=net0,netdev=hostnet0
  ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.15.0-10-generic.efi.signed 
root=UUID=6b4ae5c0-c78c-49a6-a1ba-029192618a7a ro quiet
  Signal: 6
  SourcePackage: qemu
  StacktraceTop:
   () at /usr/lib/x86_64-linux-gnu/libspice-server.so.1
   () at /usr/lib/x86_64-linux-gnu/libspice-server.so.1
   () at /usr/lib/x86_64-linux-gnu/libspice-server.so.1
   () at /usr/lib/x86_64-linux-gnu/libspice-server.so.1
   () at /usr/lib/x86_64-linux-gnu/libspice-server.so.1
  Title: qemu-system-x86_64 crashed with SIGABRT
  UpgradeStatus: Upgraded to bionic on 2017-10-20 (145 days ago)
  UserGroups: adm bluetooth cdrom dialout dip disk kvm libvirt lpadmin netdev 
plugdev sambashare sudo
  dmi.bios.date: 07/10/2017
  dmi.bios.vendor: LENOVO
  dmi.bios.version: 0XCN43WW
  dmi.board.asset.tag: NO Asset Tag
  dmi.board.name: Toronto 4A2
  dmi.board.vendor: LENOVO
  dmi.board.version: SDK0J40679 WIN
  dmi.chassis.asset.tag: NO Asset Tag
  dmi.chassis.type: 10
  dmi.chassis.vendor: LENOVO
  dmi.chassis.version: Lenovo ideapad 310-14ISK
  dmi.modalias: 
dmi:bvnLENOVO:bvr0XCN43WW:bd07/10/2017:svnLENOVO:pn80UG:pvrLenovoideapad310-14ISK:rvnLENOVO:rnToronto4A2:rvrSDK0J40679WIN:cvnLENOVO:ct10:cvrLenovoideapad310-14ISK:
  dmi.product.family: IDEAPAD
  dmi.product.name: 80UG
  dmi.product.version: Lenovo ideapad 310-14ISK
  dmi.sys.vendor: LENOVO

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



Re: [Qemu-devel] [RFC 10/15] s390-bios: Support for running format-0/1 channel programs

2018-07-17 Thread Cornelia Huck
On Fri, 6 Jul 2018 10:35:06 -0400
"Jason J. Herne"  wrote:

> On 07/06/2018 04:03 AM, Cornelia Huck wrote:
> > On Thu,  5 Jul 2018 13:25:38 -0400
> > "Jason J. Herne"  wrote:

> >> +senseIdCcw.count = sizeof(senseData);
> >> +
> >> +if (do_cio(schid, ptr2u32(), CCW_FMT1)) {
> >> +panic("Failed to run SenseID CCw\n");
> >> +}
> >> +
> >> +return senseData.cu_type;
> >> +}
> >> +
> >> +static bool irb_error(Irb *irb)
> >> +{
> >> +/* We have to ignore Incorrect Length (cstat == 0x40) indicators 
> >> because
> >> + * real devices expect a 24 byte SenseID  buffer, and virtio devices 
> >> expect
> >> + * a much larger buffer. Neither device type can tolerate a buffer 
> >> size
> >> + * different from what they expect so they set this indicator.  
> > 
> > Hm... do you have details? Is that basic vs. extended SenseID
> > information?
> > 
> > (If the code in QEMU is making incorrect assumptions, I'd like to fix
> > that.)  
> 
> I really have no idea and was hoping someone who knows virtio ccw better 
> than myself would have some ideas. This comment simply documents what I 
> discovered in testing. I can look into it more if no one else has any 
> information on this. FWIW, it has been working without issue in my testing.

OK, I've looked at this a bit more. It seems that we always get at
least the basic information; the command, however, provides for a
variable length (the CIWs).

The Linux kernel always tries to get the maximum length (basic sense id
information + maximum number possible number of CIWs), but sets SLI as
it may get less of that. I'm not sure what I should return in QEMU for
emulated devices, the documentation of SenseID I could find is a bit
light on details (as the data can be of variable length). I think you
should simply always use SLI, as you don't know the length of the
SenseID data you can get beforehand.

(BTW, is there a newer public version of SA22-7204-01 - Common I/O
Device Commands - available? That one is a bit dated.)



[Qemu-devel] [Bug 1782107] Re: Random errors when emulating armv7 and using dh

2018-07-17 Thread Peter Maydell
The ioctl warnings are I think for BTRFS_IOC_CLONE, which are probably
harmless (the calling program ought to cope with it not working and fall
back to something else).

Which version of QEMU are you using ?

(Unfortunately the log is not very revealing about what has gone wrong:
it says "Running setup.py bdist_wheel for itsdangerous ... error" but
gives no detail about what the error was. Is it possible to get the
python build/install process to be more verbose?)

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

Title:
  Random errors when emulating armv7 and using dh

Status in QEMU:
  New

Bug description:
  Howdy,
  I'm encountering random errors when using qemu to cross-package my project 
using dh. In previous iterations of my project it would only fail once every 
two attempts. Now it fails every time.

  Example error included.


  If you'd like to try and replicate this error, a version of my project is 
publicly available with simple instructions on how to package it (using qemu) 
here:
  https://github.com/Nadav-Ruskin/configsite

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



Re: [Qemu-devel] [PATCH v2 for 3.0 06/16] docker: move make check into check_qemu helper

2018-07-17 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> On 07/13/2018 09:17 AM, Alex Bennée wrote:
>> Not all docker images can run the check step. Let's move everything
>> into a common helper so we don't need to replicate checks in the
>> future.
>>
>> Signed-off-by: Alex Bennée 
>>
>> ---
>> v2
>>   - add "move" to Let's everything in commit message
>> ---
>>  tests/docker/common.rc  | 10 ++
>>  tests/docker/test-clang |  2 +-
>>  tests/docker/test-debug |  2 +-
>>  tests/docker/test-full  |  2 +-
>>  tests/docker/test-quick |  2 +-
>>  5 files changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/tests/docker/common.rc b/tests/docker/common.rc
>> index ba1f942328..cfc620d554 100755
>> --- a/tests/docker/common.rc
>> +++ b/tests/docker/common.rc
>> @@ -40,6 +40,16 @@ build_qemu()
>>  make $MAKEFLAGS
>>  }
>>
>> +check_qemu()
>> +{
>> +if test -z "$@"; then
>> +TEST="check"
>> +else
>> +TEST="$@"
>
> This is a bit confuse:
>
>   check_qemu V=1 -> TEST=V=1
>
>> +fi
>> +make $MAKEFLAGS $TEST
>
> -> make V=1

How about s/TEST/INVOCATION/?

>
>> +}
>> +
>>  test_fail()
>>  {
>>  echo "$@"
>> diff --git a/tests/docker/test-clang b/tests/docker/test-clang
>> index e90a793178..324e341cea 100755
>> --- a/tests/docker/test-clang
>> +++ b/tests/docker/test-clang
>> @@ -23,5 +23,5 @@ OPTS="--cxx=clang++ --cc=clang --host-cc=clang"
>>  #OPTS="$OPTS --extra-cflags=-fsanitize=undefined \
>>  #--extra-cflags=-fno-sanitize=float-divide-by-zero"
>>  build_qemu $OPTS
>> -make $MAKEFLAGS check
>> +check_qemu
>>  install_qemu
>> diff --git a/tests/docker/test-debug b/tests/docker/test-debug
>> index d3f9f70d01..137f4f2ddc 100755
>> --- a/tests/docker/test-debug
>> +++ b/tests/docker/test-debug
>> @@ -22,5 +22,5 @@ OPTS="--cxx=clang++ --cc=clang --host-cc=clang"
>>  OPTS="--enable-debug --enable-sanitizers $OPTS"
>>
>>  build_qemu $OPTS
>> -make $MAKEFLAGS V=1 check
>> +check_qemu check V=1
>
> Gotcha!
>
>>  install_qemu
>> diff --git a/tests/docker/test-full b/tests/docker/test-full
>> index b4e42d25d7..aadc0f00a2 100755
>> --- a/tests/docker/test-full
>> +++ b/tests/docker/test-full
>> @@ -15,4 +15,4 @@
>>
>>  cd "$BUILD_DIR"
>>
>> -build_qemu && make check $MAKEFLAGS && install_qemu
>> +build_qemu && check_qemu && install_qemu
>> diff --git a/tests/docker/test-quick b/tests/docker/test-quick
>> index 3b7bce6105..eee59c55fb 100755
>> --- a/tests/docker/test-quick
>> +++ b/tests/docker/test-quick
>> @@ -18,5 +18,5 @@ cd "$BUILD_DIR"
>>  DEF_TARGET_LIST="x86_64-softmmu,aarch64-softmmu"
>>  TARGET_LIST=${TARGET_LIST:-$DEF_TARGET_LIST} \
>>  build_qemu
>> -make check $MAKEFLAGS
>> +check_qemu
>>  install_qemu
>>


--
Alex Bennée



Re: [Qemu-devel] [PATCH 09/12] tests: add a few qemu-qmp tests

2018-07-17 Thread Marc-André Lureau
Hi

On Tue, Jul 17, 2018 at 10:01 AM, Markus Armbruster  wrote:
> Marc-André Lureau  writes:
>
>> These 2 tests exhibited two qmp bugs that were fixed in 2.7
>> (series from commit e64c75a9752c5d0fd64eb2e684c656a5ea7d03c6 to
>> commit 1382d4abdf9619985e4078e37e49e487cea9935e)
>>
>> Signed-off-by: Marc-André Lureau 
>> ---
>>  tests/qmp-test.c | 38 ++
>>  1 file changed, 38 insertions(+)
>>
>> diff --git a/tests/qmp-test.c b/tests/qmp-test.c
>> index ceaf4a6789..084c5edff0 100644
>> --- a/tests/qmp-test.c
>> +++ b/tests/qmp-test.c
>> @@ -249,7 +249,39 @@ static void test_qmp_oob(void)
>>  recv_cmd_id(qts, "blocks-2");
>>  recv_cmd_id(qts, "err-2");
>>  cleanup_blocking_cmd();
>> +}
>> +
>> +static void test_object_add_without_props(void)
>> +{
>> +QTestState *qts;
>> +QDict *ret;
>> +
>> +qts = qtest_init(common_args);
>> +
>> +ret = qtest_qmp(qts, "{'execute': 'object-add',"
>> +  " 'arguments': { 'qom-type': 'memory-backend-ram', 'id': 'ram1' } 
>> }");
>
> Please break lines between arguments instead of within.  More of the
> same below.

Sorry I am not sure I understand what you want. It's broken between
argument "execute" and "arguments", how do you want to change it?

>
>> +g_assert_nonnull(ret);
>> +
>> +g_assert_cmpstr(get_error_class(ret), ==, "GenericError");
>> +
>> +qobject_unref(ret);
>> +qtest_quit(qts);
>> +}
>> +
>> +static void test_qom_set_without_value(void)
>> +{
>> +QTestState *qts;
>> +QDict *ret;
>> +
>> +qts = qtest_init(common_args);
>>
>> +ret = qtest_qmp(qts, "{'execute': 'qom-set',"
>> +  " 'arguments': { 'path': '/machine', 'property': 'rtc-time' } 
>> }");
>> +g_assert_nonnull(ret);
>> +
>> +g_assert_cmpstr(get_error_class(ret), ==, "GenericError");
>> +
>> +qobject_unref(ret);
>>  qtest_quit(qts);
>>  }
>>
>> @@ -479,8 +511,13 @@ int main(int argc, char *argv[])
>>
>>  g_test_init(, , NULL);
>>
>> +qtest_add_func("qmp/object-add-without-props",
>> +   test_object_add_without_props);
>> +qtest_add_func("qmp/qom-set-without-value",
>> +   test_qom_set_without_value);
>>  qtest_add_func("qmp/protocol", test_qmp_protocol);
>>  qtest_add_func("qmp/oob", test_qmp_oob);
>> +
>>  qmp_schema_init();
>>  add_query_tests();
>>  qtest_add_func("qmp/preconfig", test_qmp_preconfig);
>> @@ -488,5 +525,6 @@ int main(int argc, char *argv[])
>>  ret = g_test_run();
>>
>>  qmp_schema_cleanup();
>> +
>>  return ret;
>>  }
>
> Is this hunk intentional?
>

no

> Taking a step back: the test cases look good, but is this file an
> appropriate home?  The file comment states it's about "QMP protocol test
> cases".  These test cases test commands, not the protocol.

Actually, the tests were written to test the qapi/qmp fixes mentionned
in commit message. So they were more "protocol" related than command
related.

>
> I figure test_qom_set_without_value() belongs to qom-test.c.
>
> test_object_add_without_props() could go into a memory backend test
> collection, or an object-add test collection.  Sadly, neither exists.
> We could have a qmp command test collection as a home of last resort.
> Temptation to just throw a few random test cases there instead of
> covering (a set of related) commands with a proper test case collection.
>
> As is, your patch turns qmp-test.c into such a home of last resort.  If
> that's what we want, we should update the file comment.  But I think I'd
> rather have a separate qmp-cmd-test.c.
>
> Thoughts?

It's somewhat blurry lines to me, it would be simpler to just use qmp-test.



Re: [Qemu-devel] [PULL for-3.0 0/2] qemu-ga patch queue for hard-freeze

2018-07-17 Thread Peter Maydell
On 16 July 2018 at 22:44, Michael Roth  wrote:
> The following changes since commit 102ad0a80f5110483efd06877c29c4236be267f9:
>
>   Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2018-07-16' 
> into staging (2018-07-16 15:34:38 +0100)
>
> are available in the git repository at:
>
>   git://github.com/mdroth/qemu.git tags/qga-pull-2018-07-16-tag
>
> for you to fetch changes up to d9c745c1768727aadd77e352c85114bc61e67bd4:
>
>   qga: fix file descriptor leak (2018-07-16 15:05:58 -0500)
>
> 
> qemu-ga patch queue for hard-freeze
>
> * fix file descriptor leak in suspend command
> * fix leak in guest-get-fsinfo
>
> 
> Marc-André Lureau (1):
>   qga: fix 'driver' leak in guest-get-fsinfo
>
> Paolo Bonzini (1):
>   qga: fix file descriptor leak
>
>  qga/commands-posix.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks.

-- PMM



[Qemu-devel] [Bug 1782107] [NEW] Random errors when emulating armv7 and using dh

2018-07-17 Thread Nadav Ruskin
Public bug reported:

Howdy,
I'm encountering random errors when using qemu to cross-package my project 
using dh. In previous iterations of my project it would only fail once every 
two attempts. Now it fails every time.

Example error included.


If you'd like to try and replicate this error, a version of my project is 
publicly available with simple instructions on how to package it (using qemu) 
here:
https://github.com/Nadav-Ruskin/configsite

** Affects: qemu
 Importance: Undecided
 Status: New


** Tags: dh error

** Attachment added: "myerror.txt"
   
https://bugs.launchpad.net/bugs/1782107/+attachment/5164433/+files/myerror.txt

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

Title:
  Random errors when emulating armv7 and using dh

Status in QEMU:
  New

Bug description:
  Howdy,
  I'm encountering random errors when using qemu to cross-package my project 
using dh. In previous iterations of my project it would only fail once every 
two attempts. Now it fails every time.

  Example error included.


  If you'd like to try and replicate this error, a version of my project is 
publicly available with simple instructions on how to package it (using qemu) 
here:
  https://github.com/Nadav-Ruskin/configsite

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



Re: [Qemu-devel] [PATCH] Do not enable QOM debugging by default

2018-07-17 Thread Daniel P . Berrangé
On Mon, Jul 16, 2018 at 09:41:12PM +0100, Peter Maydell wrote:
> On 16 July 2018 at 20:47, BALATON Zoltan  wrote:
> > Commit 3556c233d 5 years ago added an option to disable QOM debugging,
> > noting that it can have high performance cost but left the default to on.
> > Change the default to off and only enable it when debugging is requested
> > to avoid the performance penalty for those compiling without debug options.
> >
> > Signed-off-by: BALATON Zoltan 
> 
> Looking at the code, doesn't this disable all the type checking
> on the QOM casts? That is not something I think we should drop,
> in the same way that we do not disable assert()s even in the
> non-debug build.
> 
> Is this coming up as significant in profiling? In the past we've
> done some special casing if there are particular QOM casts in
> hot paths that use significant runtime.

There might also be scope for doing optimization of the
object_dynamic_cast_assert() implementation too.

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



Re: [Qemu-devel] [PATCH] qga-win: Handle fstrim for OSes lower than Win8

2018-07-17 Thread Daniel P . Berrangé
On Mon, Jul 16, 2018 at 03:10:38PM -0500, Michael Roth wrote:
> Quoting Sameeh Jubran (2018-06-24 07:45:40)
> > From: Sameeh Jubran 
> > 
> > The defrag.exe tool which is used for executing the fstrim command
> > on Windows doesn't support retrim for OSes lower than Win8. This
> > commit handles this case and returns a suitable error.
> > 
> > Output of fstrim before this commit:
> > {"execute":"guest-fstrim"}
> > {"return": {"paths": [{"path": "C:\\", "error": "An invalid command line 
> > option
> > was specified. (0x8908)"}, {"path": "F:\\", "error": "An invalid command
> > line option was specified. (0x8908)"}, {"path": "S:\\", "error": "An
> > invalid command line option was specified. (0x8908)"}]}}
> > 
> > Reported on:
> > https://bugzilla.redhat.com/show_bug.cgi?id=1594113
> > 
> > Signed-off-by: Sameeh Jubran 
> > ---
> >  qga/commands-win32.c | 6 ++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> > index d79974f212..0bdcd9dd38 100644
> > --- a/qga/commands-win32.c
> > +++ b/qga/commands-win32.c
> > @@ -30,6 +30,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> 
> I have this queued locally but the mingw64 build environment I've been
> using (fc20) doesn't support this header and I'm running into some odd

Please tell me that fc20 is a typo, and you're actually using the modern
fc28 :-)  Fedora 20 went end of life 3 years ago, so is not considered
a supported platform for QEMU per our policy here:

  https://qemu.weilnetz.de/doc/qemu-doc.html#Supported-build-platforms

> null pointer / 0xc005 / access violation issues with the binary
> generated in newer tool chains. I'll send a pull for this next week when
> I can get it tested.
> 
> What build envionment are you using?

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



Re: [Qemu-devel] [PATCH 06/12] qga: process_event() simplification and leak fix

2018-07-17 Thread Marc-André Lureau
Hi

On Tue, Jul 17, 2018 at 7:53 AM, Markus Armbruster  wrote:
> Marc-André Lureau  writes:
>
>> json_parser_parse_err() may return something else than a QDict, in
>> which case we loose the object. Let's keep track of the original
>> object to avoid leaks.
>
> Should this leak fix go into 3.0?

It has been there for a while, but it could be fixed for 3.0 indeed.

>
>> When an error occurs, "qdict" contains the response, but we still
>> check the "execute" key there.
>
> Harmless.
>
>>Untangle a bit this code, by having a
>> clear error path.
>
> Untangling might make sense anyway.  Let's see.
>
>> Signed-off-by: Marc-André Lureau 
>> ---
>>  qga/main.c | 50 +-
>>  1 file changed, 25 insertions(+), 25 deletions(-)
>>
>> diff --git a/qga/main.c b/qga/main.c
>> index 537cc0e162..0784761605 100644
>> --- a/qga/main.c
>> +++ b/qga/main.c
>> @@ -600,6 +600,7 @@ static void process_command(GAState *s, QDict *req)
>>  static void process_event(JSONMessageParser *parser, GQueue *tokens)
>>  {
>>  GAState *s = container_of(parser, GAState, parser);
>> +QObject *obj;
>>  QDict *qdict;
>>  Error *err = NULL;
>>  int ret;
>> @@ -607,35 +608,34 @@ static void process_event(JSONMessageParser *parser, 
>> GQueue *tokens)
>>  g_assert(s && parser);
>>
>>  g_debug("process_event: called");
>> -qdict = qobject_to(QDict, json_parser_parse_err(tokens, NULL, ));
>> -if (err || !qdict) {
>> -qobject_unref(qdict);
>> -if (!err) {
>> -g_warning("failed to parse event: unknown error");
>> -error_setg(, QERR_JSON_PARSING);
>> -} else {
>> -g_warning("failed to parse event: %s", error_get_pretty(err));
>> -}
>> -qdict = qmp_error_response(err);
>> +obj = json_parser_parse_err(tokens, NULL, );
>> +if (err) {
>> +goto err;
>>  }
>> -
>> -/* handle host->guest commands */
>> -if (qdict_haskey(qdict, "execute")) {
>> -process_command(s, qdict);
>> -} else {
>> -if (!qdict_haskey(qdict, "error")) {
>> -qobject_unref(qdict);
>> -g_warning("unrecognized payload format");
>> -error_setg(, QERR_UNSUPPORTED);
>> -qdict = qmp_error_response(err);
>> -}
>> -ret = send_response(s, qdict);
>> -if (ret < 0) {
>> -g_warning("error sending error response: %s", strerror(-ret));
>> -}
>> +qdict = qobject_to(QDict, obj);
>> +if (!qdict) {
>> +error_setg(, QERR_JSON_PARSING);
>> +goto err;
>> +}
>> +if (!qdict_haskey(qdict, "execute")) {
>> +g_warning("unrecognized payload format");
>> +error_setg(, QERR_UNSUPPORTED);
>> +goto err;
>>  }
>>
>> +process_command(s, qdict);
>> +qobject_unref(obj);
>> +return;
>> +
>> +err:
>> +g_warning("failed to parse event: %s", error_get_pretty(err));
>> +qdict = qmp_error_response(err);
>> +ret = send_response(s, qdict);
>> +if (ret < 0) {
>> +g_warning("error sending error response: %s", strerror(-ret));
>> +}
>>  qobject_unref(qdict);
>> +qobject_unref(obj);
>>  }
>>
>>  /* false return signals GAChannel to close the current client connection */
>
> Control flow is much improved.  Took me a minute to convince myself the
> reference counting is okay: qdict is a weak reference before qdict =
> qmp_error_response(), and becomes strong there.  Suggest to use a new
> variable @err_rsp for the latter purpose.

Yes, the code is further improved in patch 11.

>
> Regardless:
> Reviewed-by: Markus Armbruster 
>

thanks


-- 
Marc-André Lureau



Re: [Qemu-devel] [PATCH for 3.1 4/4] virtio: qemu_get_virtqueue_element fail rather than assert

2018-07-17 Thread Cornelia Huck
On Mon, 16 Jul 2018 18:37:43 +0100
"Dr. David Alan Gilbert (git)"  wrote:

$SUBJECT reads a bit odd without a 'make', but it is already long...

> From: "Dr. David Alan Gilbert" 
> 
> Make it return NULL rather than assert.
> 
> Signed-off-by: Dr. David Alan Gilbert 
> ---
>  hw/virtio/virtio.c | 13 ++---
>  1 file changed, 6 insertions(+), 7 deletions(-)

Reviewed-by: Cornelia Huck 



Re: [Qemu-devel] [PATCH for 3.1 3/4] virtio-scsi/migration: Allow load_request to fail

2018-07-17 Thread Cornelia Huck
On Mon, 16 Jul 2018 18:37:42 +0100
"Dr. David Alan Gilbert (git)"  wrote:

> From: "Dr. David Alan Gilbert" 
> 
> Rather than asserting, check values and return NULL
> on failure.
> 
> Signed-off-by: Dr. David Alan Gilbert 
> ---
>  hw/scsi/virtio-scsi.c | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index 6301af76ad..3441bfe6d7 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -204,7 +204,11 @@ static void *virtio_scsi_load_request(QEMUFile *f, 
> SCSIRequest *sreq)
>  uint32_t n;
>  
>  qemu_get_be32s(f, );
> -assert(n < vs->conf.num_queues);
> +if (n >= vs->conf.num_queues) {
> +error_report("%s: Bad queue number (%d vs %d)",
> + __func__, n, vs->conf.num_queues);

Hm... "(%d, num_queues %d)" might be a bit clearer?

> +return NULL;
> +}
>  req = qemu_get_virtqueue_element(vdev, f,
>   sizeof(VirtIOSCSIReq) + vs->cdb_size);
>  if (!req) {

Still,
Reviewed-by: Cornelia Huck 



Re: [Qemu-devel] [PATCH for 3.1 2/4] virtio: Check qemu_get_virtqueue_element returns

2018-07-17 Thread Cornelia Huck
On Mon, 16 Jul 2018 18:37:41 +0100
"Dr. David Alan Gilbert (git)"  wrote:

> From: "Dr. David Alan Gilbert" 
> 
> Check calls to qemu_get_virtqueue_element for NULL and pass
> up the chain.
> 
> Signed-off-by: Dr. David Alan Gilbert 
> ---
>  hw/block/virtio-blk.c   | 4 
>  hw/char/virtio-serial-bus.c | 4 
>  hw/scsi/virtio-scsi.c   | 4 
>  3 files changed, 12 insertions(+)
> 
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 50b5c869e3..324c6b2b27 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -888,6 +888,10 @@ static int virtio_blk_load_device(VirtIODevice *vdev, 
> QEMUFile *f,
>  }
>  
>  req = qemu_get_virtqueue_element(vdev, f, sizeof(VirtIOBlockReq));
> +if (!req) {
> +error_report("%s: Bad vq element %u", __func__, vq_idx);

Minor nit: vq_idx is the virtqueue index, and this message makes it
look like it is the 'bad vq element'... either add 'vq index', or drop
it completely from the error message?

> +return -EINVAL;
> +}
>  virtio_blk_init_request(s, virtio_get_queue(vdev, vq_idx), req);
>  req->next = s->rq;
>  s->rq = req;

Anyway,
Reviewed-by: Cornelia Huck 



Re: [Qemu-devel] [PATCH for 3.1 1/4] scsi/migration: Allow bus load request to fail

2018-07-17 Thread Cornelia Huck
On Mon, 16 Jul 2018 18:37:40 +0100
"Dr. David Alan Gilbert (git)"  wrote:

> From: "Dr. David Alan Gilbert" 
> 
> Allow the load_request method on a bus to fail and error
> the migration cleanly.
> 
> Signed-off-by: Dr. David Alan Gilbert 
> ---
>  hw/scsi/scsi-bus.c | 5 +
>  1 file changed, 5 insertions(+)

Reviewed-by: Cornelia Huck 



Re: [Qemu-devel] [PULL 0/8] target-arm queue

2018-07-17 Thread Peter Maydell
On 16 July 2018 at 17:42, Peter Maydell  wrote:
> target-arm queue: a smallish set of patches for rc1 tomorrow.
> I've included the tcg patches because RTH has no others that
> would merit a pullreq.
>
> I haven't included Thomas Huth's 17-patch set to deal with
> the introspection crashes, to give that a little more time
> on-list for review.
>
> thanks
> -- PMM
>
> The following changes since commit 102ad0a80f5110483efd06877c29c4236be267f9:
>
>   Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2018-07-16' 
> into staging (2018-07-16 15:34:38 +0100)
>
> are available in the Git repository at:
>
>   git://git.linaro.org/people/pmaydell/qemu-arm.git 
> tags/pull-target-arm-20180716
>
> for you to fetch changes up to 3474c98a2a2afcefa7c665f02ad2bed2a43ab0f7:
>
>   accel/tcg: Assert that tlb fill gave us a valid TLB entry (2018-07-16 
> 17:26:01 +0100)
>
> 
> target-arm queue:
>  * accel/tcg: Use correct test when looking in victim TLB for code
>  * bcm2835_aux: Swap RX and TX interrupt assignments
>  * hw/arm/bcm2836: Mark the bcm2836 / bcm2837 devices with user_creatable = 
> false
>  * hw/intc/arm_gic: Fix handling of GICD_ITARGETSR
>  * hw/intc/arm_gic: Check interrupt number in gic_deactivate_irq()
>  * aspeed: Implement write-1-{set, clear} for AST2500 strapping
>  * target/arm: Fix LD1W and LDFF1W (scalar plus vector)
>
> 

Applied, thanks.

-- PMM



Re: [Qemu-devel] [Qemu-block] [PATCH] throttle-groups: fix hang when group member leaves

2018-07-17 Thread Stefan Hajnoczi
On Wed, Jul 04, 2018 at 03:54:10PM +0100, Stefan Hajnoczi wrote:
> Throttle groups consist of members sharing one throttling state
> (including bps/iops limits).  Round-robin scheduling is used to ensure
> fairness.  If a group member already has a timer pending then other
> groups members do not schedule their own timers.  The next group member
> will have its turn when the existing timer expires.
> 
> A hang may occur when a group member leaves while it had a timer
> scheduled.  Although the code carefully removes the group member from
> the round-robin list, it does not schedule the next member.  Therefore
> remaining members continue to wait for the removed member's timer to
> expire.
> 
> This patch schedules the next request if a timer is pending.
> Unfortunately the actual bug is a race condition that I've been unable
> to capture in a test case.
> 
> Sometimes drive2 hangs when drive1 is removed from the throttling group:
> 
>   $ qemu ... -drive 
> if=none,id=drive1,cache=none,format=qcow2,file=data1.qcow2,iops=100,group=foo 
> \
>  -device virtio-blk-pci,id=virtio-blk-pci0,drive=drive1 \
>  -drive 
> if=none,id=drive2,cache=none,format=qcow2,file=data2.qcow2,iops=10,group=foo \
>  -device virtio-blk-pci,id=virtio-blk-pci1,drive=drive2
>   (guest-console1)# fio -filename /dev/vda 4k-seq-read.job
>   (guest-console2)# fio -filename /dev/vdb 4k-seq-read.job
>   (qmp) {"execute": "block_set_io_throttle", "arguments": {"device": 
> "drive1","bps": 0,"bps_rd": 0,"bps_wr": 0,"iops": 0,"iops_rd": 0,"iops_wr": 
> 0}}
> 
> Reported-by: Nini Gu 
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1535914
> Cc: Alberto Garcia 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  block/throttle-groups.c | 4 
>  1 file changed, 4 insertions(+)

Berto is away in July.  I am merging this fix for QEMU 3.0.  If there
are any comments when Berto is back I'll send a follow-up patch.

Applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH 09/12] tests: add a few qemu-qmp tests

2018-07-17 Thread Markus Armbruster
Marc-André Lureau  writes:

> These 2 tests exhibited two qmp bugs that were fixed in 2.7
> (series from commit e64c75a9752c5d0fd64eb2e684c656a5ea7d03c6 to
> commit 1382d4abdf9619985e4078e37e49e487cea9935e)
>
> Signed-off-by: Marc-André Lureau 
> ---
>  tests/qmp-test.c | 38 ++
>  1 file changed, 38 insertions(+)
>
> diff --git a/tests/qmp-test.c b/tests/qmp-test.c
> index ceaf4a6789..084c5edff0 100644
> --- a/tests/qmp-test.c
> +++ b/tests/qmp-test.c
> @@ -249,7 +249,39 @@ static void test_qmp_oob(void)
>  recv_cmd_id(qts, "blocks-2");
>  recv_cmd_id(qts, "err-2");
>  cleanup_blocking_cmd();
> +}
> +
> +static void test_object_add_without_props(void)
> +{
> +QTestState *qts;
> +QDict *ret;
> +
> +qts = qtest_init(common_args);
> +
> +ret = qtest_qmp(qts, "{'execute': 'object-add',"
> +  " 'arguments': { 'qom-type': 'memory-backend-ram', 'id': 'ram1' } 
> }");

Please break lines between arguments instead of within.  More of the
same below.

> +g_assert_nonnull(ret);
> +
> +g_assert_cmpstr(get_error_class(ret), ==, "GenericError");
> +
> +qobject_unref(ret);
> +qtest_quit(qts);
> +}
> +
> +static void test_qom_set_without_value(void)
> +{
> +QTestState *qts;
> +QDict *ret;
> +
> +qts = qtest_init(common_args);
>  
> +ret = qtest_qmp(qts, "{'execute': 'qom-set',"
> +  " 'arguments': { 'path': '/machine', 'property': 'rtc-time' } 
> }");
> +g_assert_nonnull(ret);
> +
> +g_assert_cmpstr(get_error_class(ret), ==, "GenericError");
> +
> +qobject_unref(ret);
>  qtest_quit(qts);
>  }
>  
> @@ -479,8 +511,13 @@ int main(int argc, char *argv[])
>  
>  g_test_init(, , NULL);
>  
> +qtest_add_func("qmp/object-add-without-props",
> +   test_object_add_without_props);
> +qtest_add_func("qmp/qom-set-without-value",
> +   test_qom_set_without_value);
>  qtest_add_func("qmp/protocol", test_qmp_protocol);
>  qtest_add_func("qmp/oob", test_qmp_oob);
> +
>  qmp_schema_init();
>  add_query_tests();
>  qtest_add_func("qmp/preconfig", test_qmp_preconfig);
> @@ -488,5 +525,6 @@ int main(int argc, char *argv[])
>  ret = g_test_run();
>  
>  qmp_schema_cleanup();
> +
>  return ret;
>  }

Is this hunk intentional?

Taking a step back: the test cases look good, but is this file an
appropriate home?  The file comment states it's about "QMP protocol test
cases".  These test cases test commands, not the protocol.

I figure test_qom_set_without_value() belongs to qom-test.c.

test_object_add_without_props() could go into a memory backend test
collection, or an object-add test collection.  Sadly, neither exists.
We could have a qmp command test collection as a home of last resort.
Temptation to just throw a few random test cases there instead of
covering (a set of related) commands with a proper test case collection.

As is, your patch turns qmp-test.c into such a home of last resort.  If
that's what we want, we should update the file comment.  But I think I'd
rather have a separate qmp-cmd-test.c.

Thoughts?



Re: [Qemu-devel] [PATCH v8 2/5] tpm: implement virtual memory device for TPM PPI

2018-07-17 Thread Igor Mammedov
On Mon, 16 Jul 2018 16:56:36 +0200
Marc-André Lureau  wrote:

> Hi
> 
> On Mon, Jul 16, 2018 at 4:44 PM, Igor Mammedov  wrote:
> > On Mon, 16 Jul 2018 14:59:45 +0200
> > Marc-André Lureau  wrote:
> >  
> >> From: Stefan Berger 
> >>
> >> Implement a virtual memory device for the TPM Physical Presence interface.
> >> The memory is located at 0xFED45000 and used by ACPI to send messages to 
> >> the
> >> firmware (BIOS) and by the firmware to provide parameters for each one of
> >> the supported codes.  
> > it doesn't implement anything, maybe something like this would be better?
> >
> > tpm: allocate/map buffer for TPM Physical Presence interface
> >
> > ...
> >  
> >>
> >> This device should be used by all TPM interfaces on x86 and can be added
> >> by calling tpm_ppi_init_io().  
> > Did you mean:
> >  This *interface* should be used by all TPM *devices* on x86 and can be 
> > added
> >  by calling tpm_ppi_init_io().
> >
> >  
> >> Note: bios_linker cannot be used to allocate the PPI memory region,
> >> since the reserved memory should stay stable across reboots, and might
> >> be needed before the ACPI tables are installed.
> >>
> >> Signed-off-by: Stefan Berger 
> >> Signed-off-by: Marc-André Lureau 
> >> ---
> >>  hw/tpm/tpm_ppi.h  | 26 ++
> >>  include/hw/acpi/tpm.h |  6 ++
> >>  hw/tpm/tpm_crb.c  |  8 
> >>  hw/tpm/tpm_ppi.c  | 31 +++
> >>  hw/tpm/tpm_tis.c  |  8 
> >>  hw/tpm/Makefile.objs  |  1 +
> >>  6 files changed, 80 insertions(+)
> >>  create mode 100644 hw/tpm/tpm_ppi.h
> >>  create mode 100644 hw/tpm/tpm_ppi.c
> >>
> >> diff --git a/hw/tpm/tpm_ppi.h b/hw/tpm/tpm_ppi.h
> >> new file mode 100644
> >> index 00..f6458bf87e
> >> --- /dev/null
> >> +++ b/hw/tpm/tpm_ppi.h
> >> @@ -0,0 +1,26 @@
> >> +/*
> >> + * TPM Physical Presence Interface
> >> + *
> >> + * Copyright (C) 2018 IBM Corporation
> >> + *
> >> + * Authors:
> >> + *  Stefan Berger
> >> + *
> >> + * This work is licensed under the terms of the GNU GPL, version 2 or 
> >> later.
> >> + * See the COPYING file in the top-level directory.
> >> + */
> >> +#ifndef TPM_TPM_PPI_H
> >> +#define TPM_TPM_PPI_H
> >> +
> >> +#include "hw/acpi/tpm.h"
> >> +#include "exec/address-spaces.h"
> >> +
> >> +typedef struct TPMPPI {
> >> +MemoryRegion ram;
> >> +uint8_t buf[TPM_PPI_ADDR_SIZE];
> >> +} TPMPPI;
> >> +
> >> +bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
> >> +  hwaddr addr, Object *obj, Error **errp);
> >> +
> >> +#endif /* TPM_TPM_PPI_H */
> >> diff --git a/include/hw/acpi/tpm.h b/include/hw/acpi/tpm.h
> >> index 3580ffd50c..b8796df916 100644
> >> --- a/include/hw/acpi/tpm.h
> >> +++ b/include/hw/acpi/tpm.h
> >> @@ -188,4 +188,10 @@ REG32(CRB_DATA_BUFFER, 0x80)
> >>  #define TPM2_START_METHOD_MMIO  6
> >>  #define TPM2_START_METHOD_CRB   7
> >>
> >> +/*
> >> + * Physical Presence Interface
> >> + */
> >> +#define TPM_PPI_ADDR_SIZE   0x400
> >> +#define TPM_PPI_ADDR_BASE   0xFED45000
> >> +
> >>  #endif /* HW_ACPI_TPM_H */
> >> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
> >> index d5b0ac5920..b243222fd6 100644
> >> --- a/hw/tpm/tpm_crb.c
> >> +++ b/hw/tpm/tpm_crb.c
> >> @@ -29,6 +29,7 @@
> >>  #include "sysemu/reset.h"
> >>  #include "tpm_int.h"
> >>  #include "tpm_util.h"
> >> +#include "tpm_ppi.h"
> >>  #include "trace.h"
> >>
> >>  typedef struct CRBState {
> >> @@ -43,6 +44,7 @@ typedef struct CRBState {
> >>  size_t be_buffer_size;
> >>
> >>  bool ppi_enabled;
> >> +TPMPPI ppi;
> >>  } CRBState;
> >>
> >>  #define CRB(obj) OBJECT_CHECK(CRBState, (obj), TYPE_TPM_CRB)
> >> @@ -294,6 +296,12 @@ static void tpm_crb_realize(DeviceState *dev, Error 
> >> **errp)
> >>  memory_region_add_subregion(get_system_memory(),
> >>  TPM_CRB_ADDR_BASE + sizeof(s->regs), >cmdmem);
> >>
> >> +if (s->ppi_enabled &&
> >> +!tpm_ppi_init(>ppi, get_system_memory(),
> >> +  TPM_PPI_ADDR_BASE, OBJECT(s), errp)) {
> >> +return;
> >> +}
> >> +
> >>  qemu_register_reset(tpm_crb_reset, dev);
> >>  }
> >>
> >> diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
> >> new file mode 100644
> >> index 00..8b46b9dd4b
> >> --- /dev/null
> >> +++ b/hw/tpm/tpm_ppi.c
> >> @@ -0,0 +1,31 @@
> >> +/*
> >> + * tpm_ppi.c - TPM Physical Presence Interface
> >> + *
> >> + * Copyright (C) 2018 IBM Corporation
> >> + *
> >> + * Authors:
> >> + *  Stefan Berger 
> >> + *
> >> + * This work is licensed under the terms of the GNU GPL, version 2 or 
> >> later.
> >> + * See the COPYING file in the top-level directory.
> >> + *
> >> + */
> >> +
> >> +#include "qemu/osdep.h"
> >> +
> >> +#include "qapi/error.h"
> >> +#include "cpu.h"
> >> +#include "sysemu/memory_mapping.h"
> >> +#include "migration/vmstate.h"
> >> +#include "tpm_ppi.h"
> >> +
> >> +bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
> >> +  hwaddr addr, Object 

Re: [Qemu-devel] [PATCH 2/2] qga-win: fsinfo: pci-info: allow partial info

2018-07-17 Thread Sameeh Jubran
On Mon, Jul 16, 2018 at 11:04 PM, Michael Roth 
wrote:

> Quoting Sameeh Jubran (2018-06-26 10:10:38)
> > From: Sameeh Jubran 
> >
> > The call to SetupDiGetDeviceRegistryProperty might fail because the
> > value doesn't exist in the registry, in this case we shouldn't exit from
> > the loop but instead continue to look for other available values in the
> > registry and set this value as unavailable (-1).
> >
> > Signed-off-by: Sameeh Jubran 
>
> The values I'm seeing look off:
>
> win7:
>
> {'execute':'guest-get-fsinfo','arguments':{}}
>
> {"return": [{"name":
> "?\\Volume{2823bc2b-b90f-11e7-9ea5-806e6f6e6963}\\", "total-bytes":
> 316628992, "mountpoint": "E:\\", "disk": [{"bus-type": "ide", "bus": 0,
> "unit": 0, "pci-controller": {"bus": -1, "slot": -1, "domain": -1,
> "function": -1}, "target": 0}], "used-bytes": 316628992, "type":
> "CDFS"}, {"name":
> "?\\Volume{a1ed8064-3f4a-11e1-972d-806e6f6e6963}\\", "total-bytes":
> 21367877632, "mountpoint": "C:\\", "disk": [{"bus-type": "scsi", "bus":
> 0, "unit": 0, "pci-controller": {"bus": -1, "slot": -1, "domain": 0,
> "function": 2}, "target": 0}], "used-bytes": 19656269824, "type":
> "NTFS"}, {"name":
> "?\\Volume{a1ed8063-3f4a-11e1-972d-806e6f6e6963}\\", "mountpoint":
> "System Reserved", "disk": [{"bus-type": "scsi", "bus": 0, "unit": 0,
> "pci-controller": {"bus": -1, "slot": -1, "domain": 0, "function": 1},
> "target": 0}], "type": "NTFS"}]}
>
> win10:
>
> {'execute':'guest-get-fsinfo','arguments':{}}
>
> {"return": [{"name":
> "?\\Volume{83835b2d-0032-11e6-a84f-806e6f6e6963}\\", "total-bytes":
> 160755712, "mountpoint": "D:\\", "disk": [{"bus-type": "ide", "bus": 0,
> "unit": 0, "pci-controller": {"bus": -1, "slot": -1, "domain": -1,
> "function": -1}, "target": 0}], "used-bytes": 160755712, "type":
> "CDFS"}, {"name":
> "?\\Volume{2ea839c6----80620c00}\\", "mountpoint":
> "System Reserved", "disk": [{"bus-type": "scsi", "bus": 0, "unit": 0,
> "pci-controller": {"bus": -1, "slot": -1, "domain": 0, "function": 3},
> "target": 0}], "type": "NTFS"}, {"name":
> "?\\Volume{2ea839c6----501f}\\", "total-bytes":
> 52665839616, "mountpoint": "C:\\", "disk": [{"bus-type": "scsi", "bus":
> 0, "unit": 0, "pci-controller": {"bus": -1, "slot": -1, "domain": 0,
> "function": 2}, "target": 0}], "used-bytes": 29645811712, "type":
> "NTFS"}, {"name":
> "?\\Volume{2ea839c6----1000}\\", "mountpoint":
> "System Reserved", "disk": [{"bus-type": "scsi", "bus": 0, "unit": 0,
> "pci-controller": {"bus": -1, "slot": -1, "domain": 0, "function": 1},
> "target": 0}], "type": "NTFS"}]}
>
> If any one of domain/bus/slot/func fail, we should initialize everything
> to -1 since we can't partially report a PCI address. The fact that we
> get partial success makes me think SPDRP_ADDRESS, SPDRP_UI_NUMBER, etc.
> aren't reporting what we expect they should. The documentation seems
> a bit nebulous. Also I'm not using multifunction to the non-0 function
> values seem off.
>


>
> Do you know of anyone manually setting CONFIG_QGA_NTDDSCSI in practice?
>
Yes, I am using it actually.

> It's been left disabled in configure (left misnamed as CONFIG_QGA_NTDDDISK
> due to some problems that popped up when we tried to enable it that I
> don't quite recall, maybe similar issues to what you're seeing). I'm
> starting to think it's better to leave this for 3.1 since it's not
> technically a supported feature yet and may need some reworking outside
> of the issue you were originally addressing.
>
No problem it can wait for 3.1.

>
> > ---
> >  qga/commands-win32.c | 17 +
> >  1 file changed, 9 insertions(+), 8 deletions(-)
> >
> > diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> > index c5f1c884e1..55e460dee3 100644
> > --- a/qga/commands-win32.c
> > +++ b/qga/commands-win32.c
> > @@ -505,7 +505,8 @@ static GuestPCIAddress *get_pci_info(char *guid,
> Error **errp)
> >
> >  dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
> >  for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, _info_data);
> i++) {
> > -DWORD addr, bus, slot, func, dev, data, size2;
> > +DWORD addr, bus, slot, data, size2;
> > +int func, dev;
> >  while (!SetupDiGetDeviceRegistryProperty(dev_info,
> _info_data,
> >
> SPDRP_PHYSICAL_DEVICE_OBJECT_NAME,
> >  , (PBYTE)buffer, size,
> > @@ -535,21 +536,21 @@ static GuestPCIAddress *get_pci_info(char *guid,
> Error **errp)
> >   */
> >  if (!SetupDiGetDeviceRegistryProperty(dev_info, _info_data,
> > SPDRP_BUSNUMBER, , (PBYTE), size, NULL)) {
> > -break;
> > +bus = -1;
> >  }
> >
> >  /* The function retrieves the device's address. This value will
> be
> >   * transformed into device function and number */
> >  if (!SetupDiGetDeviceRegistryProperty(dev_info, _info_data,
> > SPDRP_ADDRESS, , 

Re: [Qemu-devel] [PATCH v8 5/5] PoC: tpm: add ACPI memory clear interface

2018-07-17 Thread Igor Mammedov
On Mon, 16 Jul 2018 14:59:48 +0200
Marc-André Lureau  wrote:

> This allows to pass the last failing test from the Windows HLK TPM 2.0
> TCG PPI 1.3 tests.
> 
> The interface is described in the "TCG Platform Reset Attack
> Mitigation Specification", chapter 6 "ACPI _DSM Function". According
> to Laszlo, it's not so easy to implement in OVMF, he suggested to do
> it in qemu instead. It is relatively simple to implement in QEMU, but
> make this a proof-of-concept PATCH for discussion, since this is not
> a conventional approach.
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  hw/i386/acpi-build.c | 46 
>  hw/tpm/tpm_ppi.c | 25 
>  docs/specs/tpm.txt   |  2 ++
>  hw/tpm/trace-events  |  3 +++
>  4 files changed, 76 insertions(+)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 882fc27846..7e3c217076 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1824,6 +1824,13 @@ build_tpm_ppi(TPMIf *tpm, Aml *dev)
>  pprq = aml_name("PPRQ");
>  pprm = aml_name("PPRM");
>  
> +aml_append(dev,
> +   aml_operation_region("TPP3", AML_SYSTEM_MEMORY,
> +aml_int(TPM_PPI_ADDR_BASE + 0x200),
> +0x1));
> +field = aml_field("TPP3", AML_ANY_ACC, AML_NOLOCK, AML_PRESERVE);
 ^^^ AML_BYTE_ACC

> +aml_append(field, aml_named_field("MOVV", 8));
> +aml_append(dev, field);
>  /*
>   * DerefOf in Windows is broken with SYSTEM_MEMORY.  Use a dynamic
>   * operation region inside of a method for getting FUNC[op].
> @@ -2166,7 +2173,46 @@ build_tpm_ppi(TPMIf *tpm, Aml *dev)
>  aml_append(ifctx, aml_return(aml_buffer(1, zerobyte)));
>  }
>  aml_append(method, ifctx);
> +
> +ifctx = aml_if(
> +aml_equal(uuid,
> +  aml_touuid("376054ED-CC13-4675-901C-4756D7F2D45D")));
> +{
> +/* standard DSM query function */
> +ifctx2 = aml_if(aml_equal(function, zero));
> +{
> +uint8_t byte_list[1] = { 0x03 };
> +aml_append(ifctx2, aml_return(aml_buffer(1, byte_list)));
> +}
> +aml_append(ifctx, ifctx2);
> +
> +/*
> + * TCG Platform Reset Attack Mitigation Specification 1.0 Ch.6
> + *
> + * Arg 2 (Integer): Function Index = 1
> + * Arg 3 (Package): Arguments = Package: Type: Integer
> + *  Operation Value of the Request
> + * Returns: Type: Integer
> + *  0: Success
> + *  1: General Failure
> + */
> +ifctx2 = aml_if(aml_equal(function, one));
> +{
> +aml_append(ifctx2,
> +   aml_store(aml_derefof(aml_index(arguments, zero)),
> + op));
> +{
> +aml_append(ifctx2, aml_store(op, aml_name("MOVV")));
> +
> +/* 0: success */
> +aml_append(ifctx2, aml_return(zero));
> +}
> +}
> +aml_append(ifctx, ifctx2);
> +}
> +aml_append(method, ifctx);
>  }
> +
>  aml_append(dev, method);
>  }
>  
> diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
> index 8b46b9dd4b..64e8d828e8 100644
> --- a/hw/tpm/tpm_ppi.c
> +++ b/hw/tpm/tpm_ppi.c
> @@ -16,8 +16,31 @@
>  #include "qapi/error.h"
>  #include "cpu.h"
>  #include "sysemu/memory_mapping.h"
> +#include "sysemu/reset.h"
>  #include "migration/vmstate.h"
>  #include "tpm_ppi.h"
> +#include "trace.h"
> +
> +static void tpm_ppi_reset(void *opaque)
> +{
> +TPMPPI *tpmppi = opaque;
> +char *ptr = memory_region_get_ram_ptr(>ram);
> +
> +if (ptr[0x200] & 0x1) {
> +GuestPhysBlockList guest_phys_blocks;
> +GuestPhysBlock *block;
> +
> +guest_phys_blocks_init(_phys_blocks);
> +guest_phys_blocks_append(_phys_blocks);
> +QTAILQ_FOREACH(block, _phys_blocks.head, next) {
> +trace_tpm_ppi_memset(block->host_addr,
> + block->target_end - block->target_start);
> +memset(block->host_addr, 0,
> +   block->target_end - block->target_start);
> +}
> +guest_phys_blocks_free(_phys_blocks);
> +}
> +}
>  
>  bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
>hwaddr addr, Object *obj, Error **errp)
> @@ -27,5 +50,7 @@ bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
>  vmstate_register_ram(>ram, DEVICE(obj));
>  
>  memory_region_add_subregion(m, addr, >ram);
> +qemu_register_reset(tpm_ppi_reset, tpmppi);
is it necessary,
shouldn't it be reset by bus initiated reset?

> +
>  return true;
>  }
> diff --git a/docs/specs/tpm.txt b/docs/specs/tpm.txt
> index 

Re: [Qemu-devel] [PATCH] Document command line options with single dash

2018-07-17 Thread Thomas Huth
On 16.07.2018 21:12, BALATON Zoltan wrote:
> QEMU options have a single dash (but also work as double dash for
> convenience and compatibility). Most options are listed with single
> dash in command line help but some were listed with two dashes.
> Normalize these to have the same format as the others.
> 
> Left --preconfig as that is mentioned as double dash everywhere so I
> assume that is the preferred form for that.
> 
> Signed-off-by: BALATON Zoltan 
> ---
>  qemu-options.hx | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 371c427..b1bf0f4 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -471,7 +471,7 @@ STEXI
>  @item -balloon virtio[,addr=@var{addr}]
>  @findex -balloon
>  Enable virtio balloon device, optionally with PCI address @var{addr}. This
> -option is deprecated, use @option{--device virtio-balloon} instead.
> +option is deprecated, use @option{-device virtio-balloon} instead.
>  ETEXI
>  
>  DEF("device", HAS_ARG, QEMU_OPTION_device,
> @@ -2005,7 +2005,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
>  "-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
>  "configure a hub port on the hub with ID 'n'\n", 
> QEMU_ARCH_ALL)
>  DEF("nic", HAS_ARG, QEMU_OPTION_nic,
> -"--nic [tap|bridge|"
> +"-nic [tap|bridge|"
>  #ifdef CONFIG_SLIRP
>  "user|"
>  #endif
> @@ -2024,7 +2024,7 @@ DEF("nic", HAS_ARG, QEMU_OPTION_nic,
>  "socket][,option][,...][mac=macaddr]\n"
>  "initialize an on-board / default host NIC (using MAC 
> address\n"
>  "macaddr) and connect it to the given host network 
> backend\n"
> -"--nic none  use it alone to have zero network devices (the default 
> is to\n"
> +"-nic none   use it alone to have zero network devices (the default 
> is to\n"
>  "provided a 'user' network connection)\n",
>  QEMU_ARCH_ALL)
>  DEF("net", HAS_ARG, QEMU_OPTION_net,
> @@ -3339,7 +3339,7 @@ mlocking qemu and guest memory can be enabled via 
> @option{mlock=on}
>  ETEXI
>  
>  DEF("overcommit", HAS_ARG, QEMU_OPTION_overcommit,
> -"--overcommit [mem-lock=on|off][cpu-pm=on|off]\n"
> +"-overcommit [mem-lock=on|off][cpu-pm=on|off]\n"
>  "run qemu with overcommit hints\n"
>  "mem-lock=on|off controls memory lock support (default: 
> off)\n"
>  "cpu-pm=on|off controls cpu power management (default: 
> off)\n",
> 

Acked-by: Thomas Huth 

... I'm in favour for consistency for the 3.0 release. But in the long
run, we should really come to a conclusion what we prefer (we still got
the double dash task at
https://wiki.qemu.org/BiteSizedTasks#Consistent_option_usage_in_documentation
)



Re: [Qemu-devel] [PATCH 08/12] json-lexer: make it safe to call multiple times

2018-07-17 Thread Markus Armbruster
Marc-André Lureau  writes:

> We can easily avoid the burden of checking if the lexer was
> initialized prior to calling destroy by the caller, let's do it.
>
> This allows simplification in state tracking in later patches of the
> qmp-async RFC series.
>
> Signed-off-by: Marc-André Lureau 
> ---
>  qobject/json-lexer.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c
> index 980ba159d6..0eaba43a2c 100644
> --- a/qobject/json-lexer.c
> +++ b/qobject/json-lexer.c
> @@ -386,5 +386,8 @@ int json_lexer_flush(JSONLexer *lexer)
>  
>  void json_lexer_destroy(JSONLexer *lexer)
>  {
> -g_string_free(lexer->token, true);
> +if (lexer->token) {
> +g_string_free(lexer->token, true);
> +lexer->token = NULL;
> +}
>  }

Is this just on general principles[*], or does it enable simplifactions
later in this series?

I asked the same question for its predecessor, and you answered

It allowed further simplification later in the series. I don't know if
this is still necessary after the rebase and other changes [...]

Do you have an updated answer?



Re: [Qemu-devel] [PATCH 07/12] json-parser: always set an error if return NULL

2018-07-17 Thread Markus Armbruster
Marc-André Lureau  writes:

> Let's make json_parser_parse_err() suck less, and simplify caller
> error handling.

Missing:

   * monitor.c handle_qmp_command(): drop workaround

>  * qga/main.c process_event() doesn't need further changes after
>previous cleanup.

"Doesn't need further changes" yes, but I think it could use one.
Consider:

obj = json_parser_parse_err(tokens, NULL, );
if (err) {
goto err;
}
qdict = qobject_to(QDict, obj);
if (!qdict) {
error_setg(, QERR_JSON_PARSING);
goto err;
}

Before this patch, we get to the error_setg() when
json_parser_parse_err() fails without setting an error, and when it
succeeds but returns anything but a dictionary.  QERR_JSON_PARSING is
appropriate for the first case, but not the second.

This patch removes the first case.  Please improve the error message.

>  * qobject/json-parser.c json_parser_parse()
>Ignores the error.

Stupid wrapper that's used exactly once, in libqtest.c.  Let's use
json_parser_parse_err() there, and drop the wrapper.  Let's rename
json_parser_parse_err() to json_parser_parse() then.

>  * qobject/qjson.c qobject_from_jsonv() via parse_json()
>   - qobject_from_json()
> ~ block.c parse_json_filename() - removed workaround
> ~ block/rbd.c - abort (generated json - should never fail)
> ~ qapi/qobject-input-visitor.c - removed workaround
> ~ tests/check-qjson.c - abort, ok

To be precise, we pass _abort and either assert or crash when it
returns null.  Okay.  Same for other instances of "abort, ok" below.

There are a few instances that don't abort.  First one when !utf8_out:

obj = qobject_from_json(json_in, utf8_out ? _abort : NULL);
if (utf8_out) {
str = qobject_to(QString, obj);
g_assert(str);
g_assert_cmpstr(qstring_get_str(str), ==, utf8_out);
} else {
g_assert(!obj);
}
qobject_unref(obj);

It ignores the error.  Okay.

Next one:

static void unterminated_string(void)
{
Error *err = NULL;
QObject *obj = qobject_from_json("\"abc", );
g_assert(!err); /* BUG */
g_assert(obj == NULL);
}

This patch should fix the BUG.  We'll see at [*] below why it doens't.

> ~ tests/test-visitor-serialization.c - abort, ok
>
>   - qobject_from_jsonf()

This is called qobject_from_jsonf_nofail() since commit f3e9cc9f7a1, and
became the obvious wrapper around qobject_from_vjsonf_nofail() in commit
74670550ee0.  Please mention both new names.

I guess the commit message needs more updates for these recent changes
below, but I'm glossing over that now, along with much of the patch,
because I think I've found something more serious, explained at the end
of the patch.

> Now dies in error_handle_fatal() instead of the assertion.

Which assertion?  Ah, the one in qobject_from_vjsonf_nofail().

The assertion is now dead, isn't it?

> Only used in tests, ok.
>
>   - tests/test-qobject-input-visitor.c
>   - tests/libqtest.c qmp_fd_sendv()
> Passes _abort, does nothing when qobject_from_jsonv() returns
> null.  The fix makes this catch invalid JSON instead of silently
> ignoring it.
>
> Signed-off-by: Marc-André Lureau 
> ---
>  block.c  | 5 -
>  monitor.c| 4 
>  qapi/qobject-input-visitor.c | 5 -
>  qobject/json-parser.c| 8 +++-
>  4 files changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/block.c b/block.c
> index ac8b3a3511..9046d66465 100644
> --- a/block.c
> +++ b/block.c
> @@ -1478,11 +1478,6 @@ static QDict *parse_json_filename(const char 
> *filename, Error **errp)
>  
>  options_obj = qobject_from_json(filename, errp);
>  if (!options_obj) {
> -/* Work around qobject_from_json() lossage TODO fix that */
> -if (errp && !*errp) {
> -error_setg(errp, "Could not parse the JSON options");
> -return NULL;
> -}
>  error_prepend(errp, "Could not parse the JSON options: ");
>  return NULL;
>  }
> diff --git a/monitor.c b/monitor.c
> index ec40a80d81..a3efe96d1d 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -4112,10 +4112,6 @@ static void handle_qmp_command(JSONMessageParser 
> *parser, GQueue *tokens)
>  QMPRequest *req_obj;
>  
>  req = json_parser_parse_err(tokens, NULL, );
> -if (!req && !err) {
> -/* json_parser_parse_err() sucks: can fail without setting @err */
> -error_setg(, QERR_JSON_PARSING);
> -}
>  
>  qdict = qobject_to(QDict, req);
>  if (qdict) {
> diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
> index da57f4cc24..3e88b27f9e 100644
> --- a/qapi/qobject-input-visitor.c
> +++ b/qapi/qobject-input-visitor.c
> @@ -725,11 +725,6 @@ Visitor *qobject_input_visitor_new_str(const char *str,
>  if (is_json) {
>  obj = qobject_from_json(str, errp);
>  if (!obj) {
> -/* Work 

[Qemu-devel] [PATCH 7/7 V10] migration/ram: ensure write persistence on loading all data to PMEM.

2018-07-17 Thread junyan . he
From: Junyan He 

Because we need to make sure the pmem kind memory data is synced
after migration, we choose to call pmem_persist() when the migration
finish. This will make sure the data of pmem is safe and will not
lose if power is off.

Signed-off-by: Junyan He 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Igor Mammedov 
---
 include/qemu/pmem.h |  1 +
 migration/ram.c | 10 +-
 stubs/pmem.c|  4 
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/qemu/pmem.h b/include/qemu/pmem.h
index 00d6680..8f52b08 100644
--- a/include/qemu/pmem.h
+++ b/include/qemu/pmem.h
@@ -17,6 +17,7 @@
 #else  /* !CONFIG_LIBPMEM */
 
 void *pmem_memcpy_persist(void *pmemdest, const void *src, size_t len);
+void pmem_persist(const void *addr, size_t len);
 
 #endif /* CONFIG_LIBPMEM */
 
diff --git a/migration/ram.c b/migration/ram.c
index fd7cba1..67b620b 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -33,6 +33,7 @@
 #include "qemu/bitops.h"
 #include "qemu/bitmap.h"
 #include "qemu/main-loop.h"
+#include "qemu/pmem.h"
 #include "xbzrle.h"
 #include "ram.h"
 #include "migration.h"
@@ -3540,6 +3541,13 @@ static int ram_load_setup(QEMUFile *f, void *opaque)
 static int ram_load_cleanup(void *opaque)
 {
 RAMBlock *rb;
+
+RAMBLOCK_FOREACH_MIGRATABLE(rb) {
+if (ramblock_is_pmem(rb)) {
+pmem_persist(rb->host, rb->used_length);
+}
+}
+
 xbzrle_load_cleanup();
 compress_threads_load_cleanup();
 
@@ -3900,7 +3908,7 @@ static int ram_load(QEMUFile *f, void *opaque, int 
version_id)
 static bool ram_has_postcopy(void *opaque)
 {
 RAMBlock *rb;
-RAMBLOCK_FOREACH(rb) {
+RAMBLOCK_FOREACH_MIGRATABLE(rb) {
 if (ramblock_is_pmem(rb)) {
 info_report("Block: %s, host: %p is a nvdimm memory, postcopy"
  "is not supported now!", rb->idstr, rb->host);
diff --git a/stubs/pmem.c b/stubs/pmem.c
index b4ec72d..f794262 100644
--- a/stubs/pmem.c
+++ b/stubs/pmem.c
@@ -17,3 +17,7 @@ void *pmem_memcpy_persist(void *pmemdest, const void *src, 
size_t len)
 {
 return memcpy(pmemdest, src, len);
 }
+
+void pmem_persist(const void *addr, size_t len)
+{
+}
-- 
2.7.4




[Qemu-devel] [PATCH 6/7 V10] migration/ram: Add check and info message to nvdimm post copy.

2018-07-17 Thread junyan . he
From: Junyan He 

The nvdimm kind memory does not support post copy now.
We disable post copy if we have nvdimm memory and print some
log hint to user.

Signed-off-by: Junyan He 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Igor Mammedov 
---
 migration/ram.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/migration/ram.c b/migration/ram.c
index 52dd678..fd7cba1 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -3899,6 +3899,15 @@ static int ram_load(QEMUFile *f, void *opaque, int 
version_id)
 
 static bool ram_has_postcopy(void *opaque)
 {
+RAMBlock *rb;
+RAMBLOCK_FOREACH(rb) {
+if (ramblock_is_pmem(rb)) {
+info_report("Block: %s, host: %p is a nvdimm memory, postcopy"
+ "is not supported now!", rb->idstr, rb->host);
+return false;
+}
+}
+
 return migrate_postcopy_ram();
 }
 
-- 
2.7.4




[Qemu-devel] [PATCH 3/7 V10] configure: add libpmem support

2018-07-17 Thread junyan . he
From: Junyan He 

Add a pair of configure options --{enable,disable}-libpmem to control
whether QEMU is compiled with PMDK libpmem [1].

QEMU may write to the host persistent memory (e.g. in vNVDIMM label
emulation and live migration), so it must take the proper operations
to ensure the persistence of its own writes. Depending on the CPU
models and available instructions, the optimal operation can vary [2].
PMDK libpmem have already implemented those operations on multiple CPU
models (x86 and ARM) and the logic to select the optimal ones, so QEMU
can just use libpmem rather than re-implement them.

Libpem is a part of PMDK project(formerly known as NMVL).
The project's home page is: http://pmem.io/pmdk/
And the project's repository is: https://github.com/pmem/pmdk/

For more information about libpmem APIs, you can refer to the comments
in source code of: pmdk/src/libpmem/pmem.c, begin at line 33.

Signed-off-by: Junyan He 
Signed-off-by: Haozhong Zhang 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Igor Mammedov 
---
 configure | 29 +
 1 file changed, 29 insertions(+)

diff --git a/configure b/configure
index 2a7796e..1c9288b 100755
--- a/configure
+++ b/configure
@@ -475,6 +475,7 @@ vxhs=""
 libxml2=""
 docker="no"
 debug_mutex="no"
+libpmem=""
 
 # cross compilers defaults, can be overridden with --cross-cc-ARCH
 cross_cc_aarch64="aarch64-linux-gnu-gcc"
@@ -1435,6 +1436,10 @@ for opt do
   ;;
   --disable-debug-mutex) debug_mutex=no
   ;;
+  --enable-libpmem) libpmem=yes
+  ;;
+  --disable-libpmem) libpmem=no
+  ;;
   *)
   echo "ERROR: unknown option $opt"
   echo "Try '$0 --help' for more information"
@@ -1710,6 +1715,7 @@ disabled with --disable-FEATURE, default is enabled if 
available:
   vhost-user  vhost-user support
   capstonecapstone disassembler support
   debug-mutex mutex debugging support
+  libpmem libpmem support
 
 NOTE: The object files are built at the place where configure is launched
 EOF
@@ -5546,6 +5552,24 @@ if has "docker"; then
 fi
 
 ##
+# check for libpmem
+
+if test "$libpmem" != "no"; then
+   if $pkg_config --exists "libpmem"; then
+   libpmem="yes"
+   libpmem_libs=$($pkg_config --libs libpmem)
+   libpmem_cflags=$($pkg_config --cflags libpmem)
+   libs_softmmu="$libs_softmmu $libpmem_libs"
+   QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
+   else
+   if test "$libpmem" = "yes" ; then
+   feature_not_found "libpmem" "Install nvml or pmdk"
+   fi
+   libpmem="no"
+   fi
+fi
+
+##
 # End of CC checks
 # After here, no more $cc or $ld runs
 
@@ -6010,6 +6034,7 @@ echo "replication support $replication"
 echo "VxHS block device $vxhs"
 echo "capstone  $capstone"
 echo "docker$docker"
+echo "libpmem support   $libpmem"
 
 if test "$sdl_too_old" = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -6763,6 +6788,10 @@ if test "$vxhs" = "yes" ; then
   echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
 fi
 
+if test "$libpmem" = "yes" ; then
+  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
+fi
+
 if test "$tcg_interpreter" = "yes"; then
   QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
 elif test "$ARCH" = "sparc64" ; then
-- 
2.7.4




[Qemu-devel] [PATCH 5/7 V10] mem/nvdimm: ensure write persistence to PMEM in label emulation

2018-07-17 Thread junyan . he
From: Junyan He 

Guest writes to vNVDIMM labels are intercepted and performed on the
backend by QEMU. When the backend is a real persistent memort, QEMU
needs to take proper operations to ensure its write persistence on the
persistent memory. Otherwise, a host power failure may result in the
loss of guest label configurations.

Signed-off-by: Haozhong Zhang 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Igor Mammedov 
---
 hw/mem/nvdimm.c |  9 -
 include/qemu/pmem.h | 23 +++
 stubs/Makefile.objs |  1 +
 stubs/pmem.c| 19 +++
 4 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 include/qemu/pmem.h
 create mode 100644 stubs/pmem.c

diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index 021d1c3..1c6674c 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/pmem.h"
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "hw/mem/nvdimm.h"
@@ -164,11 +165,17 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvdimm, 
const void *buf,
 {
 MemoryRegion *mr;
 PCDIMMDevice *dimm = PC_DIMM(nvdimm);
+bool is_pmem = object_property_get_bool(OBJECT(dimm->hostmem),
+"pmem", NULL);
 uint64_t backend_offset;
 
 nvdimm_validate_rw_label_data(nvdimm, size, offset);
 
-memcpy(nvdimm->label_data + offset, buf, size);
+if (!is_pmem) {
+memcpy(nvdimm->label_data + offset, buf, size);
+} else {
+pmem_memcpy_persist(nvdimm->label_data + offset, buf, size);
+}
 
 mr = host_memory_backend_get_memory(dimm->hostmem);
 backend_offset = memory_region_size(mr) - nvdimm->label_size + offset;
diff --git a/include/qemu/pmem.h b/include/qemu/pmem.h
new file mode 100644
index 000..00d6680
--- /dev/null
+++ b/include/qemu/pmem.h
@@ -0,0 +1,23 @@
+/*
+ * QEMU header file for libpmem.
+ *
+ * Copyright (c) 2018 Intel Corporation.
+ *
+ * Author: Haozhong Zhang 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_PMEM_H
+#define QEMU_PMEM_H
+
+#ifdef CONFIG_LIBPMEM
+#include 
+#else  /* !CONFIG_LIBPMEM */
+
+void *pmem_memcpy_persist(void *pmemdest, const void *src, size_t len);
+
+#endif /* CONFIG_LIBPMEM */
+
+#endif /* !QEMU_PMEM_H */
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 53d3f32..be9a042 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -43,3 +43,4 @@ stub-obj-y += xen-common.o
 stub-obj-y += xen-hvm.o
 stub-obj-y += pci-host-piix.o
 stub-obj-y += ram-block.o
+stub-obj-$(call lnot,$(CONFIG_LIBPMEM)) += pmem.o
\ No newline at end of file
diff --git a/stubs/pmem.c b/stubs/pmem.c
new file mode 100644
index 000..b4ec72d
--- /dev/null
+++ b/stubs/pmem.c
@@ -0,0 +1,19 @@
+/*
+ * Stubs for libpmem.
+ *
+ * Copyright (c) 2018 Intel Corporation.
+ *
+ * Author: Haozhong Zhang 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include 
+
+#include "qemu/pmem.h"
+
+void *pmem_memcpy_persist(void *pmemdest, const void *src, size_t len)
+{
+return memcpy(pmemdest, src, len);
+}
-- 
2.7.4




[Qemu-devel] [PATCH 0/7 V10] nvdimm: guarantee persistence of QEMU writes to persistent memory

2018-07-17 Thread junyan . he
From: Junyan He 

QEMU writes to vNVDIMM backends in the vNVDIMM label emulation and live 
migration.
If the backend is on the persistent memory, QEMU needs to take proper 
operations to
ensure its writes persistent on the persistent memory. Otherwise, a host power 
failure
may result in the loss the guest data on the persistent memory.

This patch series is based on Marcel's patch "mem: add share parameter to 
memory-backend-ram" [1]
because of the changes in patch 1.
[1] https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg03858.html

Previous versions of this patch series can be found at: 
v9: https://lists.gnu.org/archive/html/qemu-devel/2018-07/msg02361.html
v8: https://lists.gnu.org/archive/html/qemu-devel/2018-07/msg02279.html
v7: https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg02997.html
v6: https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg00061.html
v5: https://lists.gnu.org/archive/html/qemu-devel/2018-05/msg02258.html
V4: https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg06993.html
v3: https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg04365.html
v2: https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg01579.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg05040.html

Changes in v10:
* (Patch 4) Fix a nit in nvdimm docs about pmem option usage in command line 
The v10 patch set is all reviewed by Igor Mammedov 

Changes in v9:
* (Patch 3 and Patch 4) Reorder these two patches to make logic right.
Firstly add libpmem support, and then we can use libpmem's configure
check result. Also fix some typo and grammar issues in these two patches.

Changs in v8: 
* (Patch 3) Report a error when user set 'pmem' to file-backend, while
the qemu is lack of libpmem support. In this case, we can not ensure
the persistence of the file-backend, so we choose to fail the build
rather than contine and make the thing more confused.

Changes in v7: 
The v6 patch set has already reviewed by Stefan Hajnoczi 
No logic change in this v7 version, just:
* Spelling check and some document words refined.
* Rebase to "ram is migratable" patch set.

Changes in v6: 
* (Patch 1) Expose all ram block flags rather than redefine the flags.
* (Patch 4) Use pkg-config rather the hard check when configure. 
* (Patch 7) Sync and flush all the pmem data when migration completes,
rather than sync pages one by one in previous version.

Changes in v5: 
* (Patch 9) Add post copy check and output some messages for nvdimm.

Changes in v4: 
* (Patch 2) Fix compilation errors found by patchew.

Changes in v3:
* (Patch 5) Add a is_pmem flag to ram_handle_compressed() and handle
PMEM writes in it, so we don't need the _common function.
* (Patch 6) Expose qemu_get_buffer_common so we can remove the
unnecessary qemu_get_buffer_to_pmem wrapper.
* (Patch 8) Add a is_pmem flag to xbzrle_decode_buffer() and handle
PMEM writes in it, so we can remove the unnecessary
xbzrle_decode_buffer_{common, to_pmem}.
* Move libpmem stubs to stubs/pmem.c and fix the compilation failures
of test-{xbzrle,vmstate}.c.

Changes in v2:
* (Patch 1) Use a flags parameter in file ram allocation functions.
* (Patch 2) Add a new option 'pmem' to hostmem-file.
* (Patch 3) Use libpmem to operate on the persistent memory, rather
than re-implementing those operations in QEMU.
* (Patch 5-8) Consider the write persistence in the migration path.


Junyan:
[1/7] memory, exec: Expose all memory block related flags.
[6/7] migration/ram: Add check and info message to nvdimm post copy.
[7/7] migration/ram: ensure write persistence on loading all date to PMEM.

Haozhong:
[5/7] mem/nvdimm: ensure write persistence to PMEM in label emulation

Haozhong & Junyan:
[2/7] memory, exec: switch file ram allocation functions to 'flags' parameters
[3/7] configure: add libpmem support [4/7] hostmem-file: add the 'pmem' option
[4/7] hostmem-file: add the 'pmem' option

--
 backends/hostmem-file.c | 42 +-
 configure   | 29 +
 docs/nvdimm.txt | 22 ++
 exec.c  | 38 +-
 hw/mem/nvdimm.c |  9 -
 include/exec/memory.h   | 31 +--
 include/exec/ram_addr.h | 28 ++--
 include/qemu/pmem.h | 24 
 memory.c|  8 +---
 migration/ram.c | 17 +
 numa.c  |  2 +-
 qemu-options.hx |  7 +++
 stubs/Makefile.objs |  1 +
 stubs/pmem.c| 23 +++
 14 files changed, 246 insertions(+), 35 deletions(-)
 create mode 100644 include/qemu/pmem.h
 create mode 100644 stubs/pmem.c

-- 
2.7.4




[Qemu-devel] [PATCH 4/7 V10] hostmem-file: add the 'pmem' option

2018-07-17 Thread junyan . he
From: Junyan He 

When QEMU emulates vNVDIMM labels and migrates vNVDIMM devices, it
needs to know whether the backend storage is a real persistent memory,
in order to decide whether special operations should be performed to
ensure the data persistence.

This boolean option 'pmem' allows users to specify whether the backend
storage of memory-backend-file is a real persistent memory. If
'pmem=on', QEMU will set the flag RAM_PMEM in the RAM block of the
corresponding memory region. If 'pmem' is set while lack of libpmem
support, a error is generated.

Signed-off-by: Junyan He 
Signed-off-by: Haozhong Zhang 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Igor Mammedov 

---
 backends/hostmem-file.c | 41 -
 docs/nvdimm.txt | 22 ++
 exec.c  |  8 
 include/exec/memory.h   |  4 
 include/exec/ram_addr.h |  3 +++
 qemu-options.hx |  7 +++
 6 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 34c68bb..b1a2453 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -12,6 +12,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "sysemu/hostmem.h"
 #include "sysemu/sysemu.h"
 #include "qom/object_interfaces.h"
@@ -34,6 +35,7 @@ struct HostMemoryBackendFile {
 bool discard_data;
 char *mem_path;
 uint64_t align;
+bool is_pmem;
 };
 
 static void
@@ -59,7 +61,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error 
**errp)
 memory_region_init_ram_from_file(>mr, OBJECT(backend),
  path,
  backend->size, fb->align,
- backend->share ? RAM_SHARED : 0,
+ (backend->share ? RAM_SHARED : 0) |
+ (fb->is_pmem ? RAM_PMEM : 0),
  fb->mem_path, errp);
 g_free(path);
 }
@@ -131,6 +134,39 @@ static void file_memory_backend_set_align(Object *o, 
Visitor *v,
 error_propagate(errp, local_err);
 }
 
+static bool file_memory_backend_get_pmem(Object *o, Error **errp)
+{
+return MEMORY_BACKEND_FILE(o)->is_pmem;
+}
+
+static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp)
+{
+HostMemoryBackend *backend = MEMORY_BACKEND(o);
+HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o);
+
+if (host_memory_backend_mr_inited(backend)) {
+error_setg(errp, "cannot change property 'pmem' of %s '%s'",
+   object_get_typename(o),
+   object_get_canonical_path_component(o));
+return;
+}
+
+#ifndef CONFIG_LIBPMEM
+if (value) {
+Error *local_err = NULL;
+error_setg(_err,
+   "Lack of libpmem support while setting the 'pmem=on'"
+   " of %s '%s'. We can't ensure data persistence.",
+   object_get_typename(o),
+   object_get_canonical_path_component(o));
+error_propagate(errp, local_err);
+return;
+}
+#endif
+
+fb->is_pmem = value;
+}
+
 static void file_backend_unparent(Object *obj)
 {
 HostMemoryBackend *backend = MEMORY_BACKEND(obj);
@@ -162,6 +198,9 @@ file_backend_class_init(ObjectClass *oc, void *data)
 file_memory_backend_get_align,
 file_memory_backend_set_align,
 NULL, NULL, _abort);
+object_class_property_add_bool(oc, "pmem",
+file_memory_backend_get_pmem, file_memory_backend_set_pmem,
+_abort);
 }
 
 static void file_backend_instance_finalize(Object *o)
diff --git a/docs/nvdimm.txt b/docs/nvdimm.txt
index 24b443b..48754d2 100644
--- a/docs/nvdimm.txt
+++ b/docs/nvdimm.txt
@@ -173,3 +173,25 @@ There are currently two valid values for this option:
  the NVDIMMs in the event of power loss.  This implies that the
  platform also supports flushing dirty data through the memory
  controller on power loss.
+
+If the vNVDIMM backend is on the host persistent memory that can be
+accessed in SNIA NVM Programming Model [1] (e.g., Intel NVDIMM), it's
+suggested to set the 'pmem' option of memory-backend-file to 'on'. When
+'pmem' is 'on' and QEMU is built with libpmem [2] support (configured with
+--enable-libpmem), QEMU will take necessary operations to guarantee the
+persistence of its own writes to the vNVDIMM backend(e.g., in vNVDIMM label
+emulation and live migration). If 'pmem' is 'on' while there is no libpmem
+support, qemu will exit and report a "lack of libpmem support" message to
+ensure the persistence is available. For example, if we want to ensure the
+persistence for some backend file, use the QEMU command line:
+
+-object memory-backend-file,id=nv_mem,mem-path=/XXX/yyy,size=4G,pmem=on
+
+References
+--
+
+[1] NVM Programming Model (NPM)
+   Version 1.2
+

[Qemu-devel] [PATCH 2/7 V10] memory, exec: switch file ram allocation functions to 'flags' parameters

2018-07-17 Thread junyan . he
From: Junyan He 

As more flag parameters besides the existing 'share' are going to be
added to following functions
memory_region_init_ram_from_file
qemu_ram_alloc_from_fd
qemu_ram_alloc_from_file
let's switch them to use the 'flags' parameters so as to ease future
flag additions.

The existing 'share' flag is converted to the RAM_SHARED bit in ram_flags,
and other flag bits are ignored by above functions right now.

Signed-off-by: Junyan He 
Signed-off-by: Haozhong Zhang 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Igor Mammedov 
---
 backends/hostmem-file.c |  3 ++-
 exec.c  | 10 +-
 include/exec/memory.h   |  7 +--
 include/exec/ram_addr.h | 25 +++--
 memory.c|  8 +---
 numa.c  |  2 +-
 6 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 134b08d..34c68bb 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -58,7 +58,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error 
**errp)
 path = object_get_canonical_path(OBJECT(backend));
 memory_region_init_ram_from_file(>mr, OBJECT(backend),
  path,
- backend->size, fb->align, backend->share,
+ backend->size, fb->align,
+ backend->share ? RAM_SHARED : 0,
  fb->mem_path, errp);
 g_free(path);
 }
diff --git a/exec.c b/exec.c
index cc042dc..1ec539d 100644
--- a/exec.c
+++ b/exec.c
@@ -2238,7 +2238,7 @@ static void ram_block_add(RAMBlock *new_block, Error 
**errp, bool shared)
 
 #ifdef __linux__
 RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
- bool share, int fd,
+ uint64_t ram_flags, int fd,
  Error **errp)
 {
 RAMBlock *new_block;
@@ -2280,14 +2280,14 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, 
MemoryRegion *mr,
 new_block->mr = mr;
 new_block->used_length = size;
 new_block->max_length = size;
-new_block->flags = share ? RAM_SHARED : 0;
+new_block->flags = ram_flags;
 new_block->host = file_ram_alloc(new_block, size, fd, !file_size, errp);
 if (!new_block->host) {
 g_free(new_block);
 return NULL;
 }
 
-ram_block_add(new_block, _err, share);
+ram_block_add(new_block, _err, ram_flags & RAM_SHARED);
 if (local_err) {
 g_free(new_block);
 error_propagate(errp, local_err);
@@ -2299,7 +2299,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, 
MemoryRegion *mr,
 
 
 RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
-   bool share, const char *mem_path,
+   uint64_t ram_flags, const char *mem_path,
Error **errp)
 {
 int fd;
@@ -2311,7 +2311,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, 
MemoryRegion *mr,
 return NULL;
 }
 
-block = qemu_ram_alloc_from_fd(size, mr, share, fd, errp);
+block = qemu_ram_alloc_from_fd(size, mr, ram_flags, fd, errp);
 if (!block) {
 if (created) {
 unlink(mem_path);
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 6d0af29..513ec8d 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -640,6 +640,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
void *host),
Error **errp);
 #ifdef __linux__
+
 /**
  * memory_region_init_ram_from_file:  Initialize RAM memory region with a
  *mmap-ed backend.
@@ -651,7 +652,9 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
  * @size: size of the region.
  * @align: alignment of the region base address; if 0, the default alignment
  * (getpagesize()) will be used.
- * @share: %true if memory must be mmaped with the MAP_SHARED flag
+ * @ram_flags: Memory region features:
+ * - RAM_SHARED: memory must be mmaped with the MAP_SHARED flag
+ * Other bits are ignored now.
  * @path: the path in which to allocate the RAM.
  * @errp: pointer to Error*, to store an error if it happens.
  *
@@ -663,7 +666,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
   const char *name,
   uint64_t size,
   uint64_t align,
-  bool share,
+  uint64_t ram_flags,
   const char *path,
   Error **errp);
 
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index cf4ce06..bb0a09b 100644
--- 

[Qemu-devel] [PATCH 1/7 V10] memory, exec: Expose all memory block related flags.

2018-07-17 Thread junyan . he
From: Junyan He 

We need to use these flags in other files rather than just in exec.c,
For example, RAM_SHARED should be used when create a ram block from file.
We expose them the exec/memory.h

Signed-off-by: Junyan He 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Igor Mammedov 
---
 exec.c| 20 
 include/exec/memory.h | 20 
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/exec.c b/exec.c
index 4f5df07..cc042dc 100644
--- a/exec.c
+++ b/exec.c
@@ -87,26 +87,6 @@ AddressSpace address_space_memory;
 
 MemoryRegion io_mem_rom, io_mem_notdirty;
 static MemoryRegion io_mem_unassigned;
-
-/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */
-#define RAM_PREALLOC   (1 << 0)
-
-/* RAM is mmap-ed with MAP_SHARED */
-#define RAM_SHARED (1 << 1)
-
-/* Only a portion of RAM (used_length) is actually used, and migrated.
- * This used_length size can change across reboots.
- */
-#define RAM_RESIZEABLE (1 << 2)
-
-/* UFFDIO_ZEROPAGE is available on this RAMBlock to atomically
- * zero the page and wake waiting processes.
- * (Set during postcopy)
- */
-#define RAM_UF_ZEROPAGE (1 << 3)
-
-/* RAM can be migrated */
-#define RAM_MIGRATABLE (1 << 4)
 #endif
 
 #ifdef TARGET_PAGE_BITS_VARY
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 448d41a..6d0af29 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -103,6 +103,26 @@ struct IOMMUNotifier {
 };
 typedef struct IOMMUNotifier IOMMUNotifier;
 
+/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */
+#define RAM_PREALLOC   (1 << 0)
+
+/* RAM is mmap-ed with MAP_SHARED */
+#define RAM_SHARED (1 << 1)
+
+/* Only a portion of RAM (used_length) is actually used, and migrated.
+ * This used_length size can change across reboots.
+ */
+#define RAM_RESIZEABLE (1 << 2)
+
+/* UFFDIO_ZEROPAGE is available on this RAMBlock to atomically
+ * zero the page and wake waiting processes.
+ * (Set during postcopy)
+ */
+#define RAM_UF_ZEROPAGE (1 << 3)
+
+/* RAM can be migrated */
+#define RAM_MIGRATABLE (1 << 4)
+
 static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn,
IOMMUNotifierFlag flags,
hwaddr start, hwaddr end,
-- 
2.7.4




Re: [Qemu-devel] [PATCH 05/12] monitor: no need to save need_resume

2018-07-17 Thread Peter Xu
On Tue, Jul 17, 2018 at 07:38:32AM +0200, Markus Armbruster wrote:
> Marc-André Lureau  writes:
> 
> > There is no need for per-command need_resume granularity, it should
> > resume after running an non-oob command on oob-disabled monitor.
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  monitor.c | 12 +++-
> >  1 file changed, 3 insertions(+), 9 deletions(-)
> >
> > diff --git a/monitor.c b/monitor.c
> > index 462cf96f7b..ec40a80d81 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -257,12 +257,6 @@ struct QMPRequest {
> >   */
> >  QObject *req;
> >  Error *err;
> > -/*
> > - * Whether we need to resume the monitor afterward.  This flag is
> > - * used to emulate the old QMP server behavior that the current
> > - * command must be completed before execution of the next one.
> > - */
> > -bool need_resume;
> 
> Note for later: this comment goes away without a replacement.
> 
> >  };
> >  typedef struct QMPRequest QMPRequest;
> >  
> > @@ -4079,11 +4073,13 @@ static void monitor_qmp_bh_dispatcher(void *data)
> >  {
> >  QMPRequest *req_obj = monitor_qmp_requests_pop_any();
> >  QDict *rsp;
> > +bool need_resume;
> >  
> >  if (!req_obj) {
> >  return;
> >  }
> >  
> > +need_resume = !qmp_oob_enabled(req_obj->mon);

[1]

> >  if (req_obj->req) {
> >  trace_monitor_qmp_cmd_in_band(qobject_get_try_str(req_obj->id) ?: 
> > "");
> >  monitor_qmp_dispatch(req_obj->mon, req_obj->req, req_obj->id);
> > @@ -4094,7 +4090,7 @@ static void monitor_qmp_bh_dispatcher(void *data)
> >  qobject_unref(rsp);
> >  }
> >  
> > -if (req_obj->need_resume) {
> > +if (need_resume) {
> >  /* Pairs with the monitor_suspend() in handle_qmp_command() */
> 
> Why not
> 
>if (!qmp_oob_enabled(req_obj->mon)) {
> 
> and drop the variable?  Perhaps you keep the variable to have its name
> provide a hint on why we resume.  But even with that hint and the "pairs
> with" comment, it's still less than clear.  What about...

IMO it's because the value of qmp_oob_enabled(req_obj->mon) might
change along the way, and we need to cache the old result to decide
whether we'll need to resume the monitor.  The trick is that when we
send the first "qmp_capabilities" command to enable out-of-band, then
when at [1] we will get a FALSE (since out-of-band is off by default)
while when reach here we'll get a TRUE instead (after we handled the
"qmp_capabilities" command, out-of-band is enabled).

So if we really want to remove the req_obj->need_resume variable or
anything similar, IMHO we'd better add some comment at [1] mentioning
about this trick.

Thanks,

> 
> >  monitor_resume(req_obj->mon);
> >  }
> > @@ -4146,7 +4142,6 @@ static void handle_qmp_command(JSONMessageParser 
> > *parser, GQueue *tokens)
> >  req_obj->id = id;
> >  req_obj->req = req;
> >  req_obj->err = err;
> > -req_obj->need_resume = false;
> >  
> >  /* Protect qmp_requests and fetching its length. */
> >  qemu_mutex_lock(>qmp.qmp_queue_lock);
> > @@ -4159,7 +4154,6 @@ static void handle_qmp_command(JSONMessageParser 
> > *parser, GQueue *tokens)
> >   */
> >  if (!qmp_oob_enabled(mon)) {
> 
> ... adding a replacement for the deleted comment here, say
> 
>/*
>* Emulate traditional QMP server behavior: read next command
>* only after current command completed.  Pairs with
>* monitor_resume() in monitor_qmp_bh_dispatcher().
>*/
> 
> Would you then be okay with cutting out the variable?
> 
> >  monitor_suspend(mon);
> > -req_obj->need_resume = true;
> >  } else {
> >  /* Drop the request if queue is full. */
> >  if (mon->qmp.qmp_requests->length >= QMP_REQ_QUEUE_LEN_MAX) {
> 
> Your patch works fine as far as I can tell, so
> Reviewed-by: Markus Armbruster 

-- 
Peter Xu



<    1   2   3