[PATCH 8/30] powerpc tcg: Fix Lesser GPL version number

2020-10-19 Thread Chetan Pant
There is no "version 2" of the "Lesser" General Public License.
It is either "GPL version 2.0" or "Lesser GPL version 2.1".
This patch replaces all occurrences of "Lesser GPL version 2" with
"Lesser GPL version 2.1" in comment section.

Signed-off-by: Chetan Pant 
---
 hw/ppc/ppce500_spin.c   | 2 +-
 target/ppc/compat.c | 2 +-
 target/ppc/cpu-models.c | 2 +-
 target/ppc/cpu-models.h | 2 +-
 target/ppc/cpu.c| 2 +-
 target/ppc/cpu.h| 2 +-
 target/ppc/dfp_helper.c | 2 +-
 target/ppc/excp_helper.c| 2 +-
 target/ppc/fpu_helper.c | 2 +-
 target/ppc/gdbstub.c| 2 +-
 target/ppc/helper_regs.h| 2 +-
 target/ppc/int_helper.c | 2 +-
 target/ppc/internal.h   | 2 +-
 target/ppc/mem_helper.c | 2 +-
 target/ppc/misc_helper.c| 2 +-
 target/ppc/mmu-book3s-v3.c  | 2 +-
 target/ppc/mmu-book3s-v3.h  | 2 +-
 target/ppc/mmu-hash32.c | 2 +-
 target/ppc/mmu-hash64.c | 2 +-
 target/ppc/mmu-radix64.c| 2 +-
 target/ppc/mmu_helper.c | 2 +-
 target/ppc/timebase_helper.c| 2 +-
 target/ppc/translate.c  | 2 +-
 target/ppc/translate_init.c.inc | 2 +-
 target/ppc/user_only_helper.c   | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c
index 25c9ce7..d57b199 100644
--- a/hw/ppc/ppce500_spin.c
+++ b/hw/ppc/ppce500_spin.c
@@ -8,7 +8,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/target/ppc/compat.c b/target/ppc/compat.c
index 08aede8..dd56025 100644
--- a/target/ppc/compat.c
+++ b/target/ppc/compat.c
@@ -6,7 +6,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/target/ppc/cpu-models.c b/target/ppc/cpu-models.c
index 4ad1686..87e4228 100644
--- a/target/ppc/cpu-models.c
+++ b/target/ppc/cpu-models.c
@@ -8,7 +8,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/target/ppc/cpu-models.h b/target/ppc/cpu-models.h
index ce750b2..fc5e217 100644
--- a/target/ppc/cpu-models.h
+++ b/target/ppc/cpu-models.h
@@ -8,7 +8,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/target/ppc/cpu.c b/target/ppc/cpu.c
index 2801166..e501a7f 100644
--- a/target/ppc/cpu.c
+++ b/target/ppc/cpu.c
@@ -6,7 +6,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 766e9c5..9e108ed 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -6,7 +6,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the 

Re: [PATCH 0/4] RfC: microvm: add second ioapic

2020-10-19 Thread Gerd Hoffmann
On Fri, Oct 16, 2020 at 03:16:20PM +0200, Philippe Mathieu-Daudé wrote:
> On 10/16/20 1:43 PM, Gerd Hoffmann wrote:
> > Add a second ioapic to microvm.  Gives us more IRQ lines we can
> > use for virtio-mmio devices.  Bump number of possible virtio-mmio
> > devices from 8 to 24.
> > 
> > Gerd Hoffmann (4):
> >microvm: make number of virtio transports runtime configurable
> >microvm: make pcie irq base runtime configurable
> >microvm: add second ioapic
> >microvm: reconfigure irqs if second ioapic is available
> 
> After looking at Laurent's m68k virt machine,
> I wonder if it is possible to use the Goldfish-PIC
> with the MicroVM instead (or another Goldfish machine
> type).

/me updates the WIP microvm blog post ;)

Problem with goldfish is that it tries to drag over stuff from the arm
world to x86.  Specifically device trees.  On arm this works reasonable
well meanwhile.  Firmware and bootloaders have support for using device
trees and passing them on in the boot chain, so the linux kernel has a
device tree which it can use to figure which hardware is present on the
system.

On x86 this doesn't work at all, so you'll end up building a custom
kernel for the goldfish platform.  A stock distro kernel is not going
to work.

I'm to driving microvm the opposite direction:  Add acpi support.  That
is the standard x86 way to do hardware discovery (for hardware you can't
detect in other ways like pci devices).  Which in turn allows us to drop
microvm-specific quirks (like adding virtio-mmio devices to the kernel
command line) when booting linux.

So, for microvm this is not going to happen.  But feel free to add a
goldfish machine type if you want play with that.  The microvm merge
also cleaned up the x86 code base which in turn should make this
relatively easy now.

take care,
  Gerd




[PATCH 01/14] spice: add module helpers

2020-10-19 Thread Gerd Hoffmann
Add new spice-module.c + qemu-spice-module.h files.  The code needed to
support modular spice will be there.  For starters this will be only the
using_spice variable, more will follow ...

Signed-off-by: Gerd Hoffmann 
---
 include/ui/qemu-spice-module.h | 23 +++
 include/ui/qemu-spice.h|  4 +---
 ui/spice-core.c|  1 -
 ui/spice-module.c  | 23 +++
 ui/meson.build |  1 +
 5 files changed, 48 insertions(+), 4 deletions(-)
 create mode 100644 include/ui/qemu-spice-module.h
 create mode 100644 ui/spice-module.c

diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h
new file mode 100644
index ..1af0e659a109
--- /dev/null
+++ b/include/ui/qemu-spice-module.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#ifndef QEMU_SPICE_MODULE_H
+#define QEMU_SPICE_MODULE_H
+
+extern int using_spice;
+
+#endif
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index 0e8ec3f0d776..ab523788b9a9 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -19,14 +19,13 @@
 #define QEMU_SPICE_H
 
 #include "qapi/error.h"
+#include "ui/qemu-spice-module.h"
 
 #ifdef CONFIG_SPICE
 
 #include 
 #include "qemu/config-file.h"
 
-extern int using_spice;
-
 void qemu_spice_init(void);
 void qemu_spice_input_init(void);
 void qemu_spice_display_init(void);
@@ -50,7 +49,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, 
int tls_port,
 
 #include "qemu/error-report.h"
 
-#define using_spice 0
 #define spice_displays 0
 static inline int qemu_spice_set_passwd(const char *passwd,
 bool fail_if_connected,
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 47700b220059..a7fa5743585f 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -48,7 +48,6 @@ static time_t auth_expires = TIME_MAX;
 static int spice_migration_completed;
 static int spice_display_is_running;
 static int spice_have_target_host;
-int using_spice = 0;
 
 static QemuThread me;
 
diff --git a/ui/spice-module.c b/ui/spice-module.c
new file mode 100644
index ..f86b0ac517dc
--- /dev/null
+++ b/ui/spice-module.c
@@ -0,0 +1,23 @@
+/*
+ * spice module support, also spice stubs.
+ *
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#include "qemu/osdep.h"
+#include "ui/qemu-spice-module.h"
+
+int using_spice;
diff --git a/ui/meson.build b/ui/meson.build
index 6ce814867852..fc1b31daec47 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -12,6 +12,7 @@ softmmu_ss.add(files(
   'keymaps.c',
   'qemu-pixman.c',
 ))
+softmmu_ss.add([spice_headers, files('spice-module.c')])
 
 softmmu_ss.add(when: 'CONFIG_LINUX', if_true: files('input-linux.c'))
 softmmu_ss.add(when: [spice, 'CONFIG_SPICE'], if_true: files('spice-core.c', 
'spice-input.c', 'spice-display.c'))
-- 
2.27.0




[PATCH 04/14] spice: move display_init() to QemuSpiceOps.

2020-10-19 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 include/ui/qemu-spice-module.h | 1 +
 include/ui/qemu-spice.h| 7 ---
 softmmu/vl.c   | 2 +-
 ui/spice-core.c| 1 +
 ui/spice-module.c  | 9 +
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h
index b182bc4c21a6..dbe09035dade 100644
--- a/include/ui/qemu-spice-module.h
+++ b/include/ui/qemu-spice-module.h
@@ -20,6 +20,7 @@
 
 struct QemuSpiceOps {
 void (*init)(void);
+void (*display_init)(void);
 int (*migrate_info)(const char *h, int p, int t, const char *s);
 };
 
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index e6df0a8715b0..a3fd1ea5ade8 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -66,13 +66,6 @@ static inline int qemu_spice_display_add_client(int csock, 
int skipauth,
 return -1;
 }
 
-static inline void qemu_spice_display_init(void)
-{
-/* This must never be called if CONFIG_SPICE is disabled */
-error_report("spice support is disabled");
-abort();
-}
-
 #endif /* CONFIG_SPICE */
 
 static inline bool qemu_using_spice(Error **errp)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 65c34a6b8a2e..8a06fe8bf77a 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4447,7 +4447,7 @@ void qemu_init(int argc, char **argv, char **envp)
 #endif
 
 if (using_spice) {
-qemu_spice_display_init();
+qemu_spice.display_init();
 }
 
 if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 6ef66eb387de..82d5dbda3e26 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -995,6 +995,7 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
 
 static struct QemuSpiceOps real_spice_ops = {
 .init = qemu_spice_init,
+.display_init = qemu_spice_display_init,
 .migrate_info = qemu_spice_migrate_info,
 };
 
diff --git a/ui/spice-module.c b/ui/spice-module.c
index a30fa452ea93..56868aaffe9a 100644
--- a/ui/spice-module.c
+++ b/ui/spice-module.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "ui/qemu-spice-module.h"
 
 int using_spice;
@@ -26,6 +27,13 @@ static void qemu_spice_init_stub(void)
 {
 }
 
+static void qemu_spice_display_init_stub(void)
+{
+/* This must never be called if CONFIG_SPICE is disabled */
+error_report("spice support is disabled");
+abort();
+}
+
 static int qemu_spice_migrate_info_stub(const char *h, int p, int t,
 const char *s)
 {
@@ -34,5 +42,6 @@ static int qemu_spice_migrate_info_stub(const char *h, int p, 
int t,
 
 struct QemuSpiceOps qemu_spice = {
 .init = qemu_spice_init_stub,
+.display_init = qemu_spice_display_init_stub,
 .migrate_info = qemu_spice_migrate_info_stub,
 };
-- 
2.27.0




[PATCH 09/14] spice: load module when enabled on the cmdline

2020-10-19 Thread Gerd Hoffmann
In case the spice opts are not registered, try loading the spice module.

Signed-off-by: Gerd Hoffmann 
---
 softmmu/vl.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 8a06fe8bf77a..14fc527fc6e0 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3705,7 +3705,11 @@ void qemu_init(int argc, char **argv, char **envp)
 break;
 }
 case QEMU_OPTION_spice:
-olist = qemu_find_opts("spice");
+olist = qemu_find_opts_err("spice", NULL);
+if (!olist) {
+ui_module_load_one("spice-core");
+olist = qemu_find_opts("spice");
+}
 if (!olist) {
 error_report("spice support is disabled");
 exit(1);
-- 
2.27.0




Re: [PATCH v2 1/2] vhost-vdpa: Add qemu_close in vhost_vdpa_cleanup

2020-10-19 Thread Jason Wang



On 2020/10/16 上午11:09, Cindy Lu wrote:

fix the bug that fd will still open after the cleanup

Signed-off-by: Cindy Lu 
---
  net/vhost-vdpa.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index bc0e0d2d35..0480b92102 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -144,6 +144,10 @@ static void vhost_vdpa_cleanup(NetClientState *nc)
  g_free(s->vhost_net);
  s->vhost_net = NULL;
  }
+ if (s->vhost_vdpa.device_fd >= 0) {
+qemu_close(s->vhost_vdpa.device_fd);
+s->vhost_vdpa.device_fd = -1;
+}
  }
  
  static bool vhost_vdpa_has_vnet_hdr(NetClientState *nc)



Acked-by: Jason Wang 





Re: [PATCH v2 2/2] net: Add vhost-vdpa in show_netdevs()

2020-10-19 Thread Jason Wang



On 2020/10/16 上午11:09, Cindy Lu wrote:

Fix the bug that while Check qemu supported netdev,
there is no vhost-vdpa

Signed-off-by: Cindy Lu 
---
  net/net.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/net/net.c b/net/net.c
index 7a2a0fb5ac..794c652282 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1049,6 +1049,9 @@ static void show_netdevs(void)
  #endif
  #ifdef CONFIG_POSIX
  "vhost-user",
+#endif
+#ifdef CONFIG_VHOST_VDPA
+"vhost-vdpa",
  #endif
  };



Acked-by: Jason Wang 


  





Re: [PATCH] hw/riscv: microchip_pfsoc: IOSCBCTRL memmap entry

2020-10-19 Thread Ivan Griffin
Hi Bin,

Well spotted with the register map. I grepped it for 0x3702 and didn't find 
it, but it seems the address (incorrectly) is 0x0702 in the documentation.

Thanks,
Ivan.


From: Bin Meng 
Sent: Monday 19 October 2020 03:05
To: Ivan Griffin 
Cc: Alistair Francis ; QEMU Trivial 
; Bin Meng ; open list:RISC-V 
; qemu-devel@nongnu.org Developers 

Subject: Re: [PATCH] hw/riscv: microchip_pfsoc: IOSCBCTRL memmap entry

Hi Ivan,

On Sat, Oct 17, 2020 at 12:31 AM Ivan Griffin  wrote:
>
> I don't know why it isn't documented in that PDF (or in the register map), 
> but if you check 
> https://github.com/polarfire-soc/polarfire-soc-bare-metal-library/blob/master/src/platform/drivers/mss_sys_services/mss_sys_services.h
>  you'll see the following
>
> ```
> typedef struct
> {
> volatile uint32_t SOFT_RESET;
> volatile uint32_t VDETECTOR;
> volatile uint32_t TVS_CONTROL;
> volatile uint32_t TVS_TEMP_A;
> volatile uint32_t TVS_TEMP_B;
> volatile uint32_t TVS_TEMP_C;
> volatile uint32_t TVS_VOLT_A;
> volatile uint32_t TVS_VOLT_B;
> volatile uint32_t TVS_VOLT_C;
> volatile uint32_t TVS_OUTPUT0;
> volatile uint32_t TVS_OUTPUT1;
> volatile uint32_t TVS_TRIGGER;
> volatile uint32_t TRIM_VDET1P05;
> volatile uint32_t TRIM_VDET1P8;
> volatile uint32_t TRIM_VDET2P5;
> volatile uint32_t TRIM_TVS;
> volatile uint32_t TRIM_GDET1P05;
> volatile uint32_t RESERVED0;
> volatile uint32_t RESERVED1;
> volatile uint32_t RESERVED2;
> volatile uint32_t SERVICES_CR;
> volatile uint32_t SERVICES_SR;
> volatile uint32_t USER_DETECTOR_SR;
> volatile uint32_t USER_DETECTOR_CR;
> volatile uint32_t MSS_SPI_CR;
>
> } SCBCTRL_TypeDef;
>
> #define MSS_SCBCTRL((SCBCTRL_TypeDef*) (0x3702UL))
>
> /*2kB bytes long mailbox.*/
> #define MSS_SCBMAILBOX ((uint32_t*) (0x37020800UL))
> ```
>
> And in 
> https://github.com/polarfire-soc/polarfire-soc-bare-metal-library/blob/master/src/platform/drivers/mss_sys_services/mss_sys_services.c
>  you'll see MSS_SCB and MSS_SCBMAILBOX used in many places to interact with 
> the FPGA system controller to perform various services.

It's actually documented, but not in the PDF file. I also spent some
time locating the doc when I do the DDR controller modeling work.

See Register Map/PF_SoC_RegMap_V1_1/MPFS250T/pfsoc_control_scb.htm in
https://www.microsemi.com/document-portal/doc_download/1244581-polarfire-soc-register-map

Regards,
Bin


Re: [PATCH v2 3/8] migration: Add spaces around operator

2020-10-19 Thread Markus Armbruster
"Dr. David Alan Gilbert"  writes:

> * Bihong Yu (yubih...@huawei.com) wrote:
>> Signed-off-by: Bihong Yu 
>> Reviewed-by: Chuan Zheng 
>
> Yes that's OK, I'm a bit sturprised we need the space afte rthe * in the
> VMStateDescription case, I wouldn't necessarily go and change them all.

We don't: it's not the binary multiplication operator *, where we want a
space on both sides, it's a pointer declarator, where we want a space on
the left only.

Example:

int *pa, *pb, *pc;
*pa = *pb * *pc;

Note the space on both side of binary operator * (multiplication), but
only on the left side of the pointer declarator's * and the unary
operator * (indirection).

> Reviewed-by: Dr. David Alan Gilbert 
[...]
>> diff --git a/migration/savevm.c b/migration/savevm.c
>> index d2e141f..9e95df1 100644
>> --- a/migration/savevm.c
>> +++ b/migration/savevm.c
>> @@ -521,7 +521,7 @@ static const VMStateDescription vmstate_configuration = {
>>  VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len),
>>  VMSTATE_END_OF_LIST()
>>  },
>> -.subsections = (const VMStateDescription*[]) {
>> +.subsections = (const VMStateDescription * []) {
>>  _target_page_bits,
>>  _capabilites,
>>  _uuid,

Should be

   .subsections = (const VMStateDescription *[]) {

[...]




Re: [PATCH 0/4] RfC: microvm: add second ioapic

2020-10-19 Thread Philippe Mathieu-Daudé

On 10/19/20 9:07 AM, Gerd Hoffmann wrote:

On Fri, Oct 16, 2020 at 03:16:20PM +0200, Philippe Mathieu-Daudé wrote:

On 10/16/20 1:43 PM, Gerd Hoffmann wrote:

Add a second ioapic to microvm.  Gives us more IRQ lines we can
use for virtio-mmio devices.  Bump number of possible virtio-mmio
devices from 8 to 24.

Gerd Hoffmann (4):
microvm: make number of virtio transports runtime configurable
microvm: make pcie irq base runtime configurable
microvm: add second ioapic
microvm: reconfigure irqs if second ioapic is available


After looking at Laurent's m68k virt machine,
I wonder if it is possible to use the Goldfish-PIC
with the MicroVM instead (or another Goldfish machine
type).


/me updates the WIP microvm blog post ;)

Problem with goldfish is that it tries to drag over stuff from the arm
world to x86.  Specifically device trees.  On arm this works reasonable
well meanwhile.  Firmware and bootloaders have support for using device
trees and passing them on in the boot chain, so the linux kernel has a
device tree which it can use to figure which hardware is present on the
system.

On x86 this doesn't work at all, so you'll end up building a custom
kernel for the goldfish platform.  A stock distro kernel is not going
to work.

I'm to driving microvm the opposite direction:  Add acpi support.  That
is the standard x86 way to do hardware discovery (for hardware you can't
detect in other ways like pci devices).  Which in turn allows us to drop
microvm-specific quirks (like adding virtio-mmio devices to the kernel
command line) when booting linux.


My x86 knowledge is limited to asm, not to the architecture.
While this might be obvious for some, it helped me to better
understand, so thank you for the explanation :)


So, for microvm this is not going to happen.  But feel free to add a
goldfish machine type if you want play with that.  The microvm merge
also cleaned up the x86 code base which in turn should make this
relatively easy now.

take care,
   Gerd






Re: [PATCH v26 13/17] vfio: create mapped iova list when vIOMMU is enabled

2020-10-19 Thread Kirti Wankhede




On 9/26/2020 3:53 AM, Alex Williamson wrote:

On Wed, 23 Sep 2020 04:54:15 +0530
Kirti Wankhede  wrote:


Create mapped iova list when vIOMMU is enabled. For each mapped iova
save translated address. Add node to list on MAP and remove node from
list on UNMAP.
This list is used to track dirty pages during migration.

Signed-off-by: Kirti Wankhede 
---
  hw/vfio/common.c  | 58 ++-
  include/hw/vfio/vfio-common.h |  8 ++
  2 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index d4959c036dd1..dc56cded2d95 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -407,8 +407,8 @@ static bool 
vfio_listener_skipped_section(MemoryRegionSection *section)
  }
  
  /* Called with rcu_read_lock held.  */

-static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr,
-   bool *read_only)
+static bool vfio_get_xlat_addr(IOMMUTLBEntry *iotlb, void **vaddr,
+   ram_addr_t *ram_addr, bool *read_only)
  {
  MemoryRegion *mr;
  hwaddr xlat;
@@ -439,8 +439,17 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void 
**vaddr,
  return false;
  }
  
-*vaddr = memory_region_get_ram_ptr(mr) + xlat;

-*read_only = !writable || mr->readonly;
+if (vaddr) {
+*vaddr = memory_region_get_ram_ptr(mr) + xlat;
+}
+
+if (ram_addr) {
+*ram_addr = memory_region_get_ram_addr(mr) + xlat;
+}
+
+if (read_only) {
+*read_only = !writable || mr->readonly;
+}
  
  return true;

  }
@@ -450,7 +459,6 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, 
IOMMUTLBEntry *iotlb)
  VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
  VFIOContainer *container = giommu->container;
  hwaddr iova = iotlb->iova + giommu->iommu_offset;
-bool read_only;
  void *vaddr;
  int ret;
  
@@ -466,7 +474,10 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)

  rcu_read_lock();
  
  if ((iotlb->perm & IOMMU_RW) != IOMMU_NONE) {

-if (!vfio_get_vaddr(iotlb, , _only)) {
+ram_addr_t ram_addr;
+bool read_only;
+
+if (!vfio_get_xlat_addr(iotlb, , _addr, _only)) {
  goto out;
  }
  /*
@@ -484,8 +495,28 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, 
IOMMUTLBEntry *iotlb)
   "0x%"HWADDR_PRIx", %p) = %d (%m)",
   container, iova,
   iotlb->addr_mask + 1, vaddr, ret);
+} else {
+VFIOIovaRange *iova_range;
+
+iova_range = g_malloc0(sizeof(*iova_range));
+iova_range->iova = iova;
+iova_range->size = iotlb->addr_mask + 1;
+iova_range->ram_addr = ram_addr;
+
+QLIST_INSERT_HEAD(>iova_list, iova_range, next);
  }
  } else {
+VFIOIovaRange *iova_range, *tmp;
+
+QLIST_FOREACH_SAFE(iova_range, >iova_list, next, tmp) {
+if (iova_range->iova >= iova &&
+iova_range->iova + iova_range->size <= iova +
+   iotlb->addr_mask + 1) {
+QLIST_REMOVE(iova_range, next);
+g_free(iova_range);
+}
+}
+



This is some pretty serious overhead... can't we trigger a replay when
migration is enabled to build this information then? 


Are you suggesting to call memory_region_iommu_replay() before 
vfio_sync_dirty_bitmap(), which would call vfio_iommu_map_notify() where 
iova list of mapping is maintained? Then in the notifer check if 
migration_is_running() and container->dirty_pages_supported == true, 
then only create iova mapping tree? In this case how would we know that 
this is triggered by

vfio_sync_dirty_bitmap()
 -> memory_region_iommu_replay()
and we don't have to call vfio_dma_map()?


We're looking at
potentially thousands of entries, so a list is probably also not a good
choice. 


Changing it to tree.

Thanks,
Kirti

 I don't think it's acceptable to incur this even when not

migrating (ie. the vast majority of the time).  Thanks,

Alex


  ret = vfio_dma_unmap(container, iova, iotlb->addr_mask + 1);
  if (ret) {
  error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
@@ -642,6 +673,7 @@ static void vfio_listener_region_add(MemoryListener 
*listener,
  g_free(giommu);
  goto fail;
  }
+QLIST_INIT(>iova_list);
  QLIST_INSERT_HEAD(>giommu_list, giommu, giommu_next);
  memory_region_iommu_replay(giommu->iommu, >n);
  
@@ -740,6 +772,13 @@ static void vfio_listener_region_del(MemoryListener *listener,

  QLIST_FOREACH(giommu, >giommu_list, giommu_next) {
  if (MEMORY_REGION(giommu->iommu) == section->mr &&
  giommu->n.start == section->offset_within_region) {
+VFIOIovaRange *iova_range, 

Re: [PULL 00/13] qemu-macppc queue 20201018

2020-10-19 Thread Mark Cave-Ayland

On 18/10/2020 16:59, Mark Cave-Ayland wrote:


The following changes since commit e12ce85b2c79d83a340953291912875c30b3af06:

   Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' 
into staging (2020-10-16 22:46:28 +0100)

are available in the Git repository at:

   git://github.com/mcayland/qemu.git tags/qemu-macppc-20201018

for you to fetch changes up to 45e6b0fe210dc8a08117e6ccbdc081348e21de09:

   mac_oldworld: Change PCI address of macio to match real hardware (2020-10-18 
16:21:42 +0100)


qemu-macppc updates


BALATON Zoltan (4):
   mac_newworld: Allow loading binary ROM image
   mac_oldworld: Drop a variable, use get_system_memory() directly
   mac_oldworld: Drop some variables
   mac_oldworld: Change PCI address of macio to match real hardware

BALATON Zoltan via (1):
   mac_oldworld: Allow loading binary ROM image

Mark Cave-Ayland (8):
   macio: don't reference serial_hd() directly within the device
   grackle: use qdev gpios for PCI IRQs
   uninorth: use qdev gpios for PCI IRQs
   m48t59-isa: remove legacy m48t59_init_isa() function
   sun4m: use qdev properties instead of legacy m48t59_init() function
   sun4u: use qdev properties instead of legacy m48t59_init() function
   ppc405_boards: use qdev properties instead of legacy m48t59_init() 
function
   m48t59: remove legacy m48t59_init() function

  hw/misc/macio/macio.c  |  4 ---
  hw/pci-host/grackle.c  | 19 ++
  hw/pci-host/uninorth.c | 45 +---
  hw/ppc/mac.h   |  2 --
  hw/ppc/mac_newworld.c  | 52 ++-
  hw/ppc/mac_oldworld.c  | 80 ++
  hw/ppc/ppc405_boards.c | 10 +-
  hw/rtc/m48t59-isa.c| 25 -
  hw/rtc/m48t59.c| 35 --
  hw/sparc/sun4m.c   | 10 --
  hw/sparc64/sun4u.c |  7 ++--
  include/hw/pci-host/uninorth.h |  2 --
  include/hw/rtc/m48t59.h|  6 
  13 files changed, 118 insertions(+), 179 deletions(-)


Looks like Zoltan's email address got replaced by that of the qemu-devel list in his 
last patch - let me repush with that fixed.



ATB,

Mark.



Re: [PATCH v7 00/11] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set

2020-10-19 Thread Niklas Cassel
On Mon, Oct 19, 2020 at 11:17:15AM +0900, Dmitry Fomichev wrote:

(snip)

> 
> Dmitry Fomichev (9):
>   hw/block/nvme: Add Commands Supported and Effects log
>   hw/block/nvme: Generate namespace UUIDs
>   hw/block/nvme: Support Zoned Namespace Command Set
>   hw/block/nvme: Introduce max active and open zone limits
>   hw/block/nvme: Support Zone Descriptor Extensions
>   hw/block/nvme: Add injection of Offline/Read-Only zones
>   hw/block/nvme: Document zoned parameters in usage text
>   hw/block/nvme: Separate read and write handlers
>   hw/block/nvme: Merge nvme_write_zeroes() with nvme_write()
> 
> Niklas Cassel (2):
>   hw/block/nvme: Add support for Namespace Types
>   hw/block/nvme: Support allocated CNS command variants
> 
>  block/nvme.c  |2 +-
>  hw/block/nvme-ns.c|  295 
>  hw/block/nvme-ns.h|  109 +++
>  hw/block/nvme.c   | 1550 ++---
>  hw/block/nvme.h   |9 +
>  hw/block/trace-events |   36 +-
>  include/block/nvme.h  |  201 +-
>  7 files changed, 2078 insertions(+), 124 deletions(-)
> 
> -- 
> 2.21.0
> 

Thank you Dmitry, this version was easier to review.

Except for a missing
/* fall through */ comment in nvme_cmd_effects().
(in the "hw/block/nvme: Add Commands Supported and Effects log" patch.)

For the whole series:
Reviewed-by: Niklas Cassel 


[PATCH 11/14] modules: add spice dependencies

2020-10-19 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 util/module.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/util/module.c b/util/module.c
index 0c0f258923dc..21237dcc24df 100644
--- a/util/module.c
+++ b/util/module.c
@@ -176,6 +176,11 @@ static const struct {
 const char *name;
 const char *dep;
 } module_deps[] = {
+{ "audio-spice","ui-spice-core" },
+{ "chardev-spice",  "ui-spice-core" },
+{ "hw-display-qxl", "ui-spice-core" },
+{ "ui-spice-app",   "ui-spice-core" },
+{ "ui-spice-app",   "chardev-spice" },
 };
 #endif
 
-- 
2.27.0




[PATCH 06/14] spice: move auth functions to QemuSpiceOps.

2020-10-19 Thread Gerd Hoffmann
Move qemu_spice_set_passwd() and qemu_spice_set_pw_expire() functions to
QemuSpiceOps.

Signed-off-by: Gerd Hoffmann 
---
 include/ui/qemu-spice-module.h |  3 +++
 include/ui/qemu-spice.h| 14 --
 monitor/qmp-cmds.c |  4 ++--
 ui/spice-core.c| 10 ++
 ui/spice-module.c  | 14 ++
 5 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h
index f93acde5743c..1ea3a999ce8a 100644
--- a/include/ui/qemu-spice-module.h
+++ b/include/ui/qemu-spice-module.h
@@ -26,6 +26,9 @@ struct QemuSpiceOps {
 void (*init)(void);
 void (*display_init)(void);
 int (*migrate_info)(const char *h, int p, int t, const char *s);
+int (*set_passwd)(const char *passwd,
+  bool fail_if_connected, bool disconnect_if_connected);
+int (*set_pw_expire)(time_t expires);
 #ifdef CONFIG_SPICE
 int (*add_interface)(SpiceBaseInstance *sin);
 #endif
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index 6018577c5278..921b7a38d023 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -31,9 +31,6 @@ void qemu_spice_display_init(void);
 int qemu_spice_display_add_client(int csock, int skipauth, int tls);
 bool qemu_spice_have_display_interface(QemuConsole *con);
 int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con);
-int qemu_spice_set_passwd(const char *passwd,
-  bool fail_if_connected, bool 
disconnect_if_connected);
-int qemu_spice_set_pw_expire(time_t expires);
 int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
 const char *subject);
 
@@ -48,17 +45,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, 
int tls_port,
 #include "qemu/error-report.h"
 
 #define spice_displays 0
-static inline int qemu_spice_set_passwd(const char *passwd,
-bool fail_if_connected,
-bool disconnect_if_connected)
-{
-return -1;
-}
-static inline int qemu_spice_set_pw_expire(time_t expires)
-{
-return -1;
-}
-
 static inline int qemu_spice_display_add_client(int csock, int skipauth,
 int tls)
 {
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index 1abef70a8959..8ac59977e661 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -197,7 +197,7 @@ void qmp_set_password(const char *protocol, const char 
*password,
 if (!qemu_using_spice(errp)) {
 return;
 }
-rc = qemu_spice_set_passwd(password, fail_if_connected,
+rc = qemu_spice.set_passwd(password, fail_if_connected,
disconnect_if_connected);
 if (rc != 0) {
 error_setg(errp, QERR_SET_PASSWD_FAILED);
@@ -243,7 +243,7 @@ void qmp_expire_password(const char *protocol, const char 
*whenstr,
 if (!qemu_using_spice(errp)) {
 return;
 }
-rc = qemu_spice_set_pw_expire(when);
+rc = qemu_spice.set_pw_expire(when);
 if (rc != 0) {
 error_setg(errp, QERR_SET_PASSWD_FAILED);
 }
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 483d880a3362..4fe543aba058 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -727,7 +727,7 @@ static void qemu_spice_init(void)
  tls_ciphers);
 }
 if (password) {
-qemu_spice_set_passwd(password, false, false);
+qemu_spice.set_passwd(password, false, false);
 }
 if (qemu_opt_get_bool(opts, "sasl", 0)) {
 if (spice_server_set_sasl(spice_server, 1) == -1) {
@@ -941,8 +941,8 @@ static int qemu_spice_set_ticket(bool fail_if_conn, bool 
disconnect_if_conn)
fail_if_conn, disconnect_if_conn);
 }
 
-int qemu_spice_set_passwd(const char *passwd,
-  bool fail_if_conn, bool disconnect_if_conn)
+static int qemu_spice_set_passwd(const char *passwd,
+ bool fail_if_conn, bool disconnect_if_conn)
 {
 if (strcmp(auth, "spice") != 0) {
 return -1;
@@ -953,7 +953,7 @@ int qemu_spice_set_passwd(const char *passwd,
 return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn);
 }
 
-int qemu_spice_set_pw_expire(time_t expires)
+static int qemu_spice_set_pw_expire(time_t expires)
 {
 auth_expires = expires;
 return qemu_spice_set_ticket(false, false);
@@ -997,6 +997,8 @@ static struct QemuSpiceOps real_spice_ops = {
 .init = qemu_spice_init,
 .display_init = qemu_spice_display_init,
 .migrate_info = qemu_spice_migrate_info,
+.set_passwd   = qemu_spice_set_passwd,
+.set_pw_expire = qemu_spice_set_pw_expire,
 .add_interface = qemu_spice_add_interface,
 };
 
diff --git a/ui/spice-module.c b/ui/spice-module.c
index 56868aaffe9a..299aeb479be5 100644
--- a/ui/spice-module.c

[PATCH 00/14] ui: build spice and opengl as module.

2020-10-19 Thread Gerd Hoffmann
- Add QemuSpiceOps, reorganize spice stubs.
- Add support for module dependencies.
- Build spice-core modular, and make the existing spice
  modules (audio, chardev, qxl) depend on spice-core.
- Build egl-headless display and opengl helpers modular
  (pretty easy thanks to module dependencies).

Gerd Hoffmann (14):
  spice: add module helpers
  spice: add QemuSpiceOps, move migrate_info
  spice: move qemu_spice_init() to QemuSpiceOps.
  spice: move display_init() to QemuSpiceOps.
  spice: move add_interface() to QemuSpiceOps.
  spice: move auth functions to QemuSpiceOps.
  spice: move display_add_client() to QemuSpiceOps.
  spice: wire up monitor in QemuSpiceOps.
  spice: load module when enabled on the cmdline
  modules: dependencies infrastructure
  modules: add spice dependencies
  spice: flip modules switch
  opengl: build egl-headless display modular
  opengl: build opengl helper code modular

 include/ui/qemu-spice-module.h | 44 ++
 include/ui/qemu-spice.h| 42 +
 audio/spiceaudio.c |  4 +-
 chardev/spice.c|  2 +-
 monitor/misc.c |  2 +-
 monitor/qmp-cmds.c |  6 +--
 softmmu/vl.c   | 10 ++--
 ui/spice-core.c| 31 +
 ui/spice-input.c   |  6 +--
 ui/spice-module.c  | 85 ++
 util/module.c  | 44 --
 ui/meson.build | 28 +--
 12 files changed, 232 insertions(+), 72 deletions(-)
 create mode 100644 include/ui/qemu-spice-module.h
 create mode 100644 ui/spice-module.c

-- 
2.27.0





Re: [PULL v2 00/22] Build system + misc changes for 2020-10-16

2020-10-19 Thread Paolo Bonzini
On 17/10/20 21:48, Peter Maydell wrote:
>> 1) are you going to pull v3 and I can fix up everything later?  Or would
>> you prefer me to send v4 once the new curses test is reviewed?
> 
> If the only issue with v3 is that stray warning message I'm
> OK with applying it and improving the test later.

Yes.

>> 2) would you prefer the "library was found but headers weren't" to warn,
>> issue an informative message, or be completely silent?
> 
> I think the build system should just say whether it found a
> working curses setup or not, and do our usual "this is fatal
> if --enable-whatever, otherwise just disable feature". If we
> happen to have convenient information to put in whatever
> the new build system's equivalent of config.log is [ie the
> saved-for-debug-purposes log], we might as well put it in,
> but we don't need to put that in the stdout. (We shouldn't
> say "ncurses found: YES" unless we actually found a working
> version, ideally.)

Ok, I think we can at least use cc.find_library(has_headers: '...') to
avoid warning for the most basic failure mode, and then use cc.links()
to further refine the check.  If the curses header is present but the
test program fails to link, then we are in the same situation as the
multipath check and warning makes sense.

Paolo




Re: [PATCH] meson: Only install icons and qemu.desktop if have_system

2020-10-19 Thread Daniel P . Berrangé
On Fri, Oct 16, 2020 at 10:26:16AM +0200, Philippe Mathieu-Daudé wrote:
> Le jeu. 15 oct. 2020 22:22, Bruce Rogers  a écrit :
> 
> > These files are not needed for a linux-user only install.
> 
> 
> > Signed-off-by: Bruce Rogers 
> > ---
> >  ui/meson.build | 7 +--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/ui/meson.build b/ui/meson.build
> > index 78ad792ffb..fb36d305ca 100644
> > --- a/ui/meson.build
> > +++ b/ui/meson.build
> > @@ -113,8 +113,11 @@ if have_system or xkbcommon.found()
> >  endif
> >
> >  subdir('shader')
> > -subdir('icons')
> >
> > -install_data('qemu.desktop', install_dir: config_host['qemu_desktopdir'])
> > +if have_system
> >
> 
> Some tools could have an icon, QSD later?

The icons are only needed for the tools with graphical display (ie SDL)
right now.


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: [PATCH] softfloat: Mark base int-to-float routines QEMU_FLATTEN

2020-10-19 Thread Philippe Mathieu-Daudé

On 10/18/20 10:33 PM, Richard Henderson wrote:

This merges the int_to_float routine and the round_pack_canonical
routine into the same function, allowing the FloatParts structure
to be decomposed by the compiler.

This results in a 60-75% speedup of the flattened function.

Leave the narrower integer inputs to tail-call the int64_t version.



Reported-by: Ahmed Karaman 


Buglink: https://bugs.launchpad.net/qemu/+bug/1892081
Signed-off-by: Richard Henderson 


Reviewed-by: Philippe Mathieu-Daudé 


---
  fpu/softfloat.c | 24 
  1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 7b6aee9323..2cbcf5bf10 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -2794,7 +2794,8 @@ static FloatParts int_to_float(int64_t a, int scale, 
float_status *status)
  return r;
  }
  
-float16 int64_to_float16_scalbn(int64_t a, int scale, float_status *status)

+float16 QEMU_FLATTEN
+int64_to_float16_scalbn(int64_t a, int scale, float_status *status)
  {
  FloatParts pa = int_to_float(a, scale, status);
  return float16_round_pack_canonical(pa, status);
@@ -2830,7 +2831,8 @@ float16 int8_to_float16(int8_t a, float_status *status)
  return int64_to_float16_scalbn(a, 0, status);
  }
  
-float32 int64_to_float32_scalbn(int64_t a, int scale, float_status *status)

+float32 QEMU_FLATTEN
+int64_to_float32_scalbn(int64_t a, int scale, float_status *status)
  {
  FloatParts pa = int_to_float(a, scale, status);
  return float32_round_pack_canonical(pa, status);
@@ -2861,7 +2863,8 @@ float32 int16_to_float32(int16_t a, float_status *status)
  return int64_to_float32_scalbn(a, 0, status);
  }
  
-float64 int64_to_float64_scalbn(int64_t a, int scale, float_status *status)

+float64 QEMU_FLATTEN
+int64_to_float64_scalbn(int64_t a, int scale, float_status *status)
  {
  FloatParts pa = int_to_float(a, scale, status);
  return float64_round_pack_canonical(pa, status);
@@ -2897,7 +2900,8 @@ float64 int16_to_float64(int16_t a, float_status *status)
   * to the bfloat16 format.
   */
  
-bfloat16 int64_to_bfloat16_scalbn(int64_t a, int scale, float_status *status)

+bfloat16 QEMU_FLATTEN
+int64_to_bfloat16_scalbn(int64_t a, int scale, float_status *status)
  {
  FloatParts pa = int_to_float(a, scale, status);
  return bfloat16_round_pack_canonical(pa, status);
@@ -2959,7 +2963,8 @@ static FloatParts uint_to_float(uint64_t a, int scale, 
float_status *status)
  return r;
  }
  
-float16 uint64_to_float16_scalbn(uint64_t a, int scale, float_status *status)

+float16 QEMU_FLATTEN
+uint64_to_float16_scalbn(uint64_t a, int scale, float_status *status)
  {
  FloatParts pa = uint_to_float(a, scale, status);
  return float16_round_pack_canonical(pa, status);
@@ -2995,7 +3000,8 @@ float16 uint8_to_float16(uint8_t a, float_status *status)
  return uint64_to_float16_scalbn(a, 0, status);
  }
  
-float32 uint64_to_float32_scalbn(uint64_t a, int scale, float_status *status)

+float32 QEMU_FLATTEN
+uint64_to_float32_scalbn(uint64_t a, int scale, float_status *status)
  {
  FloatParts pa = uint_to_float(a, scale, status);
  return float32_round_pack_canonical(pa, status);
@@ -3026,7 +3032,8 @@ float32 uint16_to_float32(uint16_t a, float_status 
*status)
  return uint64_to_float32_scalbn(a, 0, status);
  }
  
-float64 uint64_to_float64_scalbn(uint64_t a, int scale, float_status *status)

+float64 QEMU_FLATTEN
+uint64_to_float64_scalbn(uint64_t a, int scale, float_status *status)
  {
  FloatParts pa = uint_to_float(a, scale, status);
  return float64_round_pack_canonical(pa, status);
@@ -3062,7 +3069,8 @@ float64 uint16_to_float64(uint16_t a, float_status 
*status)
   * bfloat16 format.
   */
  
-bfloat16 uint64_to_bfloat16_scalbn(uint64_t a, int scale, float_status *status)

+bfloat16 QEMU_FLATTEN
+uint64_to_bfloat16_scalbn(uint64_t a, int scale, float_status *status)
  {
  FloatParts pa = uint_to_float(a, scale, status);
  return bfloat16_round_pack_canonical(pa, status);






[PATCH] docs/system: Deprecate raspi2/raspi3 machine aliases

2020-10-19 Thread Philippe Mathieu-Daudé
Since commit aa35ec2213b ("hw/arm/raspi: Use more
specific machine names") the raspi2/raspi3 machines
have been renamed as raspi2b/raspi3b.

As more Raspberry Pi 2/3 models are emulated, in order
to avoid confusion deprecate the raspi2/raspi3 machine
aliases.

Signed-off-by: Philippe Mathieu-Daudé 
---
 docs/system/deprecated.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 905628f3a0c..f0c7aaeb2ff 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -355,6 +355,11 @@ This machine has been renamed ``fuloong2e``.
 These machine types are very old and likely can not be used for live migration
 from old QEMU versions anymore. A newer machine type should be used instead.
 
+Raspberry Pi ``raspi2`` and ``raspi3`` machines (since 5.2)
+'
+
+These machines have been respectively renamed ``raspi2b`` and ``raspi3b``.
+
 Device options
 --
 
-- 
2.26.2




[PATCH] hw/block/nvme: fix aer logic

2020-10-19 Thread Klaus Jensen
From: Klaus Jensen 

Fix same flawed logic in the handling of event masking. Before this
patch the device would erroneously

  a) queue up events even though that event type is masked
  b) issue AERs for queued events in response to events getting cleared
  c) respond to new AERs with queued events even though the event was
 already cleared

Fix this by moving the mask check to nvme_enqueue_event() and replace
the nvme_process_aers() call with a pruning of queued events when the
event type is cleared.

Fixes: 5d5a53302b95 ("hw/block/nvme: add support for the asynchronous event 
request command")
Cc: Maxim Levitsky 
Cc: Dmitry Fomichev 
Signed-off-by: Klaus Jensen 
---
 hw/block/nvme.c   | 22 ++
 hw/block/trace-events |  2 +-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 9d30ca69dcf1..b18a310d9271 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -805,12 +805,6 @@ static void nvme_process_aers(void *opaque)
 break;
 }
 
-/* ignore if masked (cqe posted, but event not cleared) */
-if (n->aer_mask & (1 << event->result.event_type)) {
-trace_pci_nvme_aer_masked(event->result.event_type, n->aer_mask);
-continue;
-}
-
 QTAILQ_REMOVE(>aer_queue, event, entry);
 n->aer_queued--;
 
@@ -844,6 +838,12 @@ static void nvme_enqueue_event(NvmeCtrl *n, uint8_t 
event_type,
 return;
 }
 
+/* ignore if masked (cqe posted, but event not cleared) */
+if (n->aer_mask & (1 << event_type)) {
+trace_pci_nvme_aer_masked(event_type, n->aer_mask);
+return;
+}
+
 event = g_new(NvmeAsyncEvent, 1);
 event->result = (NvmeAerResult) {
 .event_type = event_type,
@@ -859,9 +859,15 @@ static void nvme_enqueue_event(NvmeCtrl *n, uint8_t 
event_type,
 
 static void nvme_clear_events(NvmeCtrl *n, uint8_t event_type)
 {
+NvmeAsyncEvent *event, *next;
+
 n->aer_mask &= ~(1 << event_type);
-if (!QTAILQ_EMPTY(>aer_queue)) {
-nvme_process_aers(n);
+
+QTAILQ_FOREACH_SAFE(event, >aer_queue, entry, next) {
+if (event->result.event_type == event_type) {
+QTAILQ_REMOVE(>aer_queue, event, entry);
+n->aer_queued--;
+}
 }
 }
 
diff --git a/hw/block/trace-events b/hw/block/trace-events
index cab9913b1f2d..11bad6ae6a11 100644
--- a/hw/block/trace-events
+++ b/hw/block/trace-events
@@ -67,7 +67,7 @@ pci_nvme_aer_post_cqe(uint8_t typ, uint8_t info, uint8_t 
log_page) "type 0x%"PRI
 pci_nvme_enqueue_event(uint8_t typ, uint8_t info, uint8_t log_page) "type 
0x%"PRIx8" info 0x%"PRIx8" lid 0x%"PRIx8""
 pci_nvme_enqueue_event_noqueue(int queued) "queued %d"
 pci_nvme_enqueue_event_masked(uint8_t typ) "type 0x%"PRIx8""
-pci_nvme_no_outstanding_aers(void) "ignoring event; no outstanding AERs"
+pci_nvme_no_outstanding_aers(void) "no outstanding aers"
 pci_nvme_enqueue_req_completion(uint16_t cid, uint16_t cqid, uint16_t status) 
"cid %"PRIu16" cqid %"PRIu16" status 0x%"PRIx16""
 pci_nvme_mmio_read(uint64_t addr) "addr 0x%"PRIx64""
 pci_nvme_mmio_write(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" data 
0x%"PRIx64""
-- 
2.28.0




[PULL v2 00/13] qemu-macppc queue 20201019

2020-10-19 Thread Mark Cave-Ayland
The following changes since commit e12ce85b2c79d83a340953291912875c30b3af06:

  Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' 
into staging (2020-10-16 22:46:28 +0100)

are available in the Git repository at:

  git://github.com/mcayland/qemu.git tags/qemu-macppc-20201019

for you to fetch changes up to bb997e5c967b3b6f19f1461811df6317ed37c5ff:

  mac_oldworld: Change PCI address of macio to match real hardware (2020-10-19 
08:11:21 +0100)


qemu-macppc updates


BALATON Zoltan (5):
  mac_oldworld: Allow loading binary ROM image
  mac_newworld: Allow loading binary ROM image
  mac_oldworld: Drop a variable, use get_system_memory() directly
  mac_oldworld: Drop some variables
  mac_oldworld: Change PCI address of macio to match real hardware

Mark Cave-Ayland (8):
  macio: don't reference serial_hd() directly within the device
  grackle: use qdev gpios for PCI IRQs
  uninorth: use qdev gpios for PCI IRQs
  m48t59-isa: remove legacy m48t59_init_isa() function
  sun4m: use qdev properties instead of legacy m48t59_init() function
  sun4u: use qdev properties instead of legacy m48t59_init() function
  ppc405_boards: use qdev properties instead of legacy m48t59_init() 
function
  m48t59: remove legacy m48t59_init() function

 hw/misc/macio/macio.c  |  4 ---
 hw/pci-host/grackle.c  | 19 ++
 hw/pci-host/uninorth.c | 45 +---
 hw/ppc/mac.h   |  2 --
 hw/ppc/mac_newworld.c  | 52 ++-
 hw/ppc/mac_oldworld.c  | 80 ++
 hw/ppc/ppc405_boards.c | 10 +-
 hw/rtc/m48t59-isa.c| 25 -
 hw/rtc/m48t59.c| 35 --
 hw/sparc/sun4m.c   | 10 --
 hw/sparc64/sun4u.c |  7 ++--
 include/hw/pci-host/uninorth.h |  2 --
 include/hw/rtc/m48t59.h|  6 
 13 files changed, 118 insertions(+), 179 deletions(-)



[PATCH 02/14] spice: add QemuSpiceOps, move migrate_info

2020-10-19 Thread Gerd Hoffmann
Add QemuSpiceOps struct.  This struct holds function pointers to the
spice functions.  It will be initialized with pointers to the stub
functions.  When spice gets initialized the function pointers will
be re-written to the real functions.

The spice stubs will move from qemu-spice.h to spice-module.c for that,
because they will be needed for both "CONFIG_SPICE=n" and "CONFIG_SPICE=y
but spice module not loaded" cases.

This patch adds the infrastructure and starts with moving
qemu_spice_migrate_info() to QemuSpiceOps.

Signed-off-by: Gerd Hoffmann 
---
 include/ui/qemu-spice-module.h |  5 +
 include/ui/qemu-spice.h|  5 -
 monitor/misc.c |  2 +-
 ui/spice-core.c|  5 +
 ui/spice-module.c  | 10 ++
 5 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h
index 1af0e659a109..7a9963dd5810 100644
--- a/include/ui/qemu-spice-module.h
+++ b/include/ui/qemu-spice-module.h
@@ -18,6 +18,11 @@
 #ifndef QEMU_SPICE_MODULE_H
 #define QEMU_SPICE_MODULE_H
 
+struct QemuSpiceOps {
+int (*migrate_info)(const char *h, int p, int t, const char *s);
+};
+
 extern int using_spice;
+extern struct QemuSpiceOps qemu_spice;
 
 #endif
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index ab523788b9a9..3157016c2bb4 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -60,11 +60,6 @@ static inline int qemu_spice_set_pw_expire(time_t expires)
 {
 return -1;
 }
-static inline int qemu_spice_migrate_info(const char *h, int p, int t,
-  const char *s)
-{
-return -1;
-}
 
 static inline int qemu_spice_display_add_client(int csock, int skipauth,
 int tls)
diff --git a/monitor/misc.c b/monitor/misc.c
index 4a859fb24a21..32e6a8c13d07 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -437,7 +437,7 @@ void qmp_client_migrate_info(const char *protocol, const 
char *hostname,
 return;
 }
 
-if (qemu_spice_migrate_info(hostname,
+if (qemu_spice.migrate_info(hostname,
 has_port ? port : -1,
 has_tls_port ? tls_port : -1,
 cert_subject)) {
diff --git a/ui/spice-core.c b/ui/spice-core.c
index a7fa5743585f..b03d743cf9b9 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -993,8 +993,13 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
 return spice_display_is_running;
 }
 
+static struct QemuSpiceOps real_spice_ops = {
+.migrate_info = qemu_spice_migrate_info,
+};
+
 static void spice_register_config(void)
 {
+qemu_spice = real_spice_ops;
 qemu_add_opts(_spice_opts);
 }
 opts_init(spice_register_config);
diff --git a/ui/spice-module.c b/ui/spice-module.c
index f86b0ac517dc..f1939545a684 100644
--- a/ui/spice-module.c
+++ b/ui/spice-module.c
@@ -21,3 +21,13 @@
 #include "ui/qemu-spice-module.h"
 
 int using_spice;
+
+static int qemu_spice_migrate_info_stub(const char *h, int p, int t,
+const char *s)
+{
+return -1;
+}
+
+struct QemuSpiceOps qemu_spice = {
+.migrate_info = qemu_spice_migrate_info_stub,
+};
-- 
2.27.0




[PATCH 12/14] spice: flip modules switch

2020-10-19 Thread Gerd Hoffmann
Build spice core code as module.  This removes libspice-server and a
handful of indirect dependencies from core qemu.  The number of shared
libraries for qemu-system-x86_64 goes down from 73 to 66 on my system.

Signed-off-by: Gerd Hoffmann 
---
 ui/meson.build | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/ui/meson.build b/ui/meson.build
index fc1b31daec47..996e1d13ab34 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -15,7 +15,6 @@ softmmu_ss.add(files(
 softmmu_ss.add([spice_headers, files('spice-module.c')])
 
 softmmu_ss.add(when: 'CONFIG_LINUX', if_true: files('input-linux.c'))
-softmmu_ss.add(when: [spice, 'CONFIG_SPICE'], if_true: files('spice-core.c', 
'spice-input.c', 'spice-display.c'))
 softmmu_ss.add(when: cocoa, if_true: files('cocoa.m'))
 
 vnc_ss = ss.source_set()
@@ -71,6 +70,16 @@ if sdl.found()
   ui_modules += {'sdl' : sdl_ss}
 endif
 
+if config_host.has_key('CONFIG_SPICE')
+  spice_core_ss = ss.source_set()
+  spice_core_ss.add(spice, pixman, files(
+'spice-core.c',
+'spice-input.c',
+'spice-display.c'
+  ))
+  ui_modules += {'spice-core' : spice_core_ss}
+endif
+
 if config_host.has_key('CONFIG_SPICE') and config_host.has_key('CONFIG_GIO')
   spice_ss = ss.source_set()
   spice_ss.add(spice, gio, pixman, files('spice-app.c'))
-- 
2.27.0




Re: [PATCH v2 0/5] qapi: Restrict machine (and migration) specific commands

2020-10-19 Thread Markus Armbruster
Eduardo Habkost  writes:

> On Mon, Oct 12, 2020 at 02:15:31PM +0200, Philippe Mathieu-Daudé wrote:
>> Reduce the machine code pulled into qemu-storage-daemon.
>> 
>> The series is fully Acked, but Markus wants it reviewed
>> by the Machine core maintainers.
>
> I've confirmed that all patches move QAPI schema code without
> introducing any additional changes.
>
> Reviewed-by: Eduardo Habkost 

I take this as "I agree the things moved to machine.json belong there".
Holler if I'm mistaken.




Re: [PATCH v2 2/9] configure: cross-compiling without cross_prefix

2020-10-19 Thread Thomas Huth
On 19/10/2020 10.07, Thomas Huth wrote:
> On 19/10/2020 03.39, Joelle van Dyne wrote:
>> From: osy 
>>
>> The iOS toolchain does not use the host prefix naming convention. We add a
>> new option `--enable-cross-compile` that forces cross-compile even without
>> a cross_prefix.
>>
>> Signed-off-by: Joelle van Dyne 
>> ---
>>  configure | 13 -
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index 3c63879750..46d5db63e8 100755
>> --- a/configure
>> +++ b/configure
>> @@ -234,6 +234,7 @@ cpu=""
>>  iasl="iasl"
>>  interp_prefix="/usr/gnemul/qemu-%M"
>>  static="no"
>> +cross_compile="no"
>>  cross_prefix=""
>>  audio_drv_list=""
>>  block_drv_rw_whitelist=""
>> @@ -456,6 +457,11 @@ for opt do
>>optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
>>case "$opt" in
>>--cross-prefix=*) cross_prefix="$optarg"
>> +cross_compile="yes"
>> +  ;;
>> +  --enable-cross-compile) cross_compile="yes"
>> +  ;;
>> +  --disable-cross-compile) cross_compile="no"
> 
> Can't you simply use --cros-prefix="" instead?

I mean, still introduce the "cross_compile=yes" variable, just omit the new
options.

 Thomas




Re: [PATCH] hw/riscv: microchip_pfsoc: IOSCBCTRL memmap entry

2020-10-19 Thread Bin Meng
Hi Ivan,

On Mon, Oct 19, 2020 at 4:17 PM Ivan Griffin  wrote:
>
> Hi Bin,
>
> Well spotted with the register map. I grepped it for 0x3702 and didn't 
> find it, but it seems the address (incorrectly) is 0x0702 in the 
> documentation.
>

I believe the documented offset 0x0702 is the offset into the
IOSCB block, not the final one that is mapped into the system memory.

Regards,
Bin

> 
> From: Bin Meng 
> Sent: Monday 19 October 2020 03:05
> To: Ivan Griffin 
> Cc: Alistair Francis ; QEMU Trivial 
> ; Bin Meng ; open 
> list:RISC-V ; qemu-devel@nongnu.org Developers 
> 
> Subject: Re: [PATCH] hw/riscv: microchip_pfsoc: IOSCBCTRL memmap entry
>
> Hi Ivan,
>
> On Sat, Oct 17, 2020 at 12:31 AM Ivan Griffin  wrote:
> >
> > I don't know why it isn't documented in that PDF (or in the register map), 
> > but if you check 
> > https://github.com/polarfire-soc/polarfire-soc-bare-metal-library/blob/master/src/platform/drivers/mss_sys_services/mss_sys_services.h
> >  you'll see the following
> >
> > ```
> > typedef struct
> > {
> > volatile uint32_t SOFT_RESET;
> > volatile uint32_t VDETECTOR;
> > volatile uint32_t TVS_CONTROL;
> > volatile uint32_t TVS_TEMP_A;
> > volatile uint32_t TVS_TEMP_B;
> > volatile uint32_t TVS_TEMP_C;
> > volatile uint32_t TVS_VOLT_A;
> > volatile uint32_t TVS_VOLT_B;
> > volatile uint32_t TVS_VOLT_C;
> > volatile uint32_t TVS_OUTPUT0;
> > volatile uint32_t TVS_OUTPUT1;
> > volatile uint32_t TVS_TRIGGER;
> > volatile uint32_t TRIM_VDET1P05;
> > volatile uint32_t TRIM_VDET1P8;
> > volatile uint32_t TRIM_VDET2P5;
> > volatile uint32_t TRIM_TVS;
> > volatile uint32_t TRIM_GDET1P05;
> > volatile uint32_t RESERVED0;
> > volatile uint32_t RESERVED1;
> > volatile uint32_t RESERVED2;
> > volatile uint32_t SERVICES_CR;
> > volatile uint32_t SERVICES_SR;
> > volatile uint32_t USER_DETECTOR_SR;
> > volatile uint32_t USER_DETECTOR_CR;
> > volatile uint32_t MSS_SPI_CR;
> >
> > } SCBCTRL_TypeDef;
> >
> > #define MSS_SCBCTRL((SCBCTRL_TypeDef*) (0x3702UL))
> >
> > /*2kB bytes long mailbox.*/
> > #define MSS_SCBMAILBOX ((uint32_t*) (0x37020800UL))
> > ```
> >
> > And in 
> > https://github.com/polarfire-soc/polarfire-soc-bare-metal-library/blob/master/src/platform/drivers/mss_sys_services/mss_sys_services.c
> >  you'll see MSS_SCB and MSS_SCBMAILBOX used in many places to interact with 
> > the FPGA system controller to perform various services.
>
> It's actually documented, but not in the PDF file. I also spent some
> time locating the doc when I do the DDR controller modeling work.
>
> See Register Map/PF_SoC_RegMap_V1_1/MPFS250T/pfsoc_control_scb.htm in
> https://www.microsemi.com/document-portal/doc_download/1244581-polarfire-soc-register-map



[PATCH 10/14] modules: dependencies infrastructure

2020-10-19 Thread Gerd Hoffmann
Allow modules depending on other modules.

module_load_file() gets the option to export symbols (by not adding the
G_MODULE_BIND_LOCAL flag).

module_load_one() will check the module dependency list to figure (a)
whenever are other modules must be loaded first, or (b) the module
should export the symbols.

The dependencies are specificed as static list in the source code for
now as I expect the list will stay small.

Signed-off-by: Gerd Hoffmann 
---
 util/module.c | 32 +++-
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/util/module.c b/util/module.c
index f0ed05fbd06b..0c0f258923dc 100644
--- a/util/module.c
+++ b/util/module.c
@@ -110,7 +110,7 @@ void module_call_init(module_init_type type)
 }
 
 #ifdef CONFIG_MODULES
-static int module_load_file(const char *fname, bool mayfail)
+static int module_load_file(const char *fname, bool mayfail, bool 
export_symbols)
 {
 GModule *g_module;
 void (*sym)(void);
@@ -118,7 +118,7 @@ static int module_load_file(const char *fname, bool mayfail)
 int len = strlen(fname);
 int suf_len = strlen(dsosuf);
 ModuleEntry *e, *next;
-int ret;
+int ret, flags;
 
 if (len <= suf_len || strcmp([len - suf_len], dsosuf)) {
 /* wrong suffix */
@@ -132,7 +132,11 @@ static int module_load_file(const char *fname, bool 
mayfail)
 
 assert(QTAILQ_EMPTY(_init_list));
 
-g_module = g_module_open(fname, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+flags = G_MODULE_BIND_LAZY;
+if (!export_symbols) {
+flags |= G_MODULE_BIND_LOCAL;
+}
+g_module = g_module_open(fname, flags);
 if (!g_module) {
 if (!mayfail) {
 fprintf(stderr, "Failed to open module: %s\n",
@@ -167,6 +171,12 @@ static int module_load_file(const char *fname, bool 
mayfail)
 out:
 return ret;
 }
+
+static const struct {
+const char *name;
+const char *dep;
+} module_deps[] = {
+};
 #endif
 
 bool module_load_one(const char *prefix, const char *lib_name, bool mayfail)
@@ -182,7 +192,8 @@ bool module_load_one(const char *prefix, const char 
*lib_name, bool mayfail)
 char *dirs[5];
 char *module_name;
 int i = 0, n_dirs = 0;
-int ret;
+int ret, dep;
+bool export_symbols = false;
 static GHashTable *loaded_modules;
 
 if (!g_module_supported()) {
@@ -196,6 +207,17 @@ bool module_load_one(const char *prefix, const char 
*lib_name, bool mayfail)
 
 module_name = g_strdup_printf("%s%s", prefix, lib_name);
 
+for (dep = 0; dep < ARRAY_SIZE(module_deps); dep++) {
+if (strcmp(module_name, module_deps[dep].name) == 0) {
+/* we depend on another module */
+module_load_one("", module_deps[dep].dep, false);
+}
+if (strcmp(module_name, module_deps[dep].dep) == 0) {
+/* another module depends on us */
+export_symbols = true;
+}
+}
+
 if (!g_hash_table_add(loaded_modules, module_name)) {
 g_free(module_name);
 return true;
@@ -220,7 +242,7 @@ bool module_load_one(const char *prefix, const char 
*lib_name, bool mayfail)
 for (i = 0; i < n_dirs; i++) {
 fname = g_strdup_printf("%s/%s%s",
 dirs[i], module_name, CONFIG_HOST_DSOSUF);
-ret = module_load_file(fname, mayfail);
+ret = module_load_file(fname, mayfail, export_symbols);
 g_free(fname);
 fname = NULL;
 /* Try loading until loaded a module file */
-- 
2.27.0




[PATCH 13/14] opengl: build egl-headless display modular

2020-10-19 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 ui/meson.build | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ui/meson.build b/ui/meson.build
index 996e1d13ab34..3cf03d2c297b 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -34,7 +34,6 @@ vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c'))
 softmmu_ss.add_all(when: vnc, if_true: vnc_ss)
 softmmu_ss.add(when: vnc, if_false: files('vnc-stubs.c'))
 softmmu_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('shader.c', 
'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
-softmmu_ss.add(when: [opengl, 'CONFIG_OPENGL_DMABUF'], if_true: 
files('egl-headless.c'))
 specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)
 
 ui_modules = {}
@@ -45,6 +44,13 @@ if curses.found()
   ui_modules += {'curses' : curses_ss}
 endif
 
+if config_host.has_key('CONFIG_OPENGL_DMABUF')
+  egl_headless_ss = ss.source_set()
+  egl_headless_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL_DMABUF'],
+  if_true: files('egl-headless.c'))
+  ui_modules += {'egl-headless' : egl_headless_ss}
+endif
+
 if config_host.has_key('CONFIG_GTK')
   softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('win32-kbd-hook.c'))
 
-- 
2.27.0




[PATCH 07/14] spice: move display_add_client() to QemuSpiceOps.

2020-10-19 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 include/ui/qemu-spice-module.h | 1 +
 include/ui/qemu-spice.h| 6 --
 monitor/qmp-cmds.c | 2 +-
 ui/spice-core.c| 3 ++-
 ui/spice-module.c  | 7 +++
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h
index 1ea3a999ce8a..7422f6404ba0 100644
--- a/include/ui/qemu-spice-module.h
+++ b/include/ui/qemu-spice-module.h
@@ -29,6 +29,7 @@ struct QemuSpiceOps {
 int (*set_passwd)(const char *passwd,
   bool fail_if_connected, bool disconnect_if_connected);
 int (*set_pw_expire)(time_t expires);
+int (*display_add_client)(int csock, int skipauth, int tls);
 #ifdef CONFIG_SPICE
 int (*add_interface)(SpiceBaseInstance *sin);
 #endif
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index 921b7a38d023..2beb7929728c 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -28,7 +28,6 @@
 
 void qemu_spice_input_init(void);
 void qemu_spice_display_init(void);
-int qemu_spice_display_add_client(int csock, int skipauth, int tls);
 bool qemu_spice_have_display_interface(QemuConsole *con);
 int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con);
 int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
@@ -45,11 +44,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, 
int tls_port,
 #include "qemu/error-report.h"
 
 #define spice_displays 0
-static inline int qemu_spice_display_add_client(int csock, int skipauth,
-int tls)
-{
-return -1;
-}
 
 #endif /* CONFIG_SPICE */
 
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index 8ac59977e661..a08143b32335 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -340,7 +340,7 @@ void qmp_add_client(const char *protocol, const char 
*fdname,
 }
 skipauth = has_skipauth ? skipauth : false;
 tls = has_tls ? tls : false;
-if (qemu_spice_display_add_client(fd, skipauth, tls) < 0) {
+if (qemu_spice.display_add_client(fd, skipauth, tls) < 0) {
 error_setg(errp, "spice failed to add client");
 close(fd);
 }
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 4fe543aba058..99457c226e6f 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -959,7 +959,7 @@ static int qemu_spice_set_pw_expire(time_t expires)
 return qemu_spice_set_ticket(false, false);
 }
 
-int qemu_spice_display_add_client(int csock, int skipauth, int tls)
+static int qemu_spice_display_add_client(int csock, int skipauth, int tls)
 {
 if (tls) {
 return spice_server_add_ssl_client(spice_server, csock, skipauth);
@@ -999,6 +999,7 @@ static struct QemuSpiceOps real_spice_ops = {
 .migrate_info = qemu_spice_migrate_info,
 .set_passwd   = qemu_spice_set_passwd,
 .set_pw_expire = qemu_spice_set_pw_expire,
+.display_add_client = qemu_spice_display_add_client,
 .add_interface = qemu_spice_add_interface,
 };
 
diff --git a/ui/spice-module.c b/ui/spice-module.c
index 299aeb479be5..8fbc99c03c55 100644
--- a/ui/spice-module.c
+++ b/ui/spice-module.c
@@ -52,10 +52,17 @@ static int qemu_spice_set_pw_expire_stub(time_t expires)
 return -1;
 }
 
+static int qemu_spice_display_add_client_stub(int csock, int skipauth,
+  int tls)
+{
+return -1;
+}
+
 struct QemuSpiceOps qemu_spice = {
 .init = qemu_spice_init_stub,
 .display_init = qemu_spice_display_init_stub,
 .migrate_info = qemu_spice_migrate_info_stub,
 .set_passwd   = qemu_spice_set_passwd_stub,
 .set_pw_expire = qemu_spice_set_pw_expire_stub,
+.display_add_client = qemu_spice_display_add_client_stub,
 };
-- 
2.27.0




[PATCH 05/14] spice: move add_interface() to QemuSpiceOps.

2020-10-19 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 include/ui/qemu-spice-module.h | 7 +++
 include/ui/qemu-spice.h| 1 -
 audio/spiceaudio.c | 4 ++--
 chardev/spice.c| 2 +-
 ui/spice-core.c| 5 +++--
 ui/spice-input.c   | 6 +++---
 6 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h
index dbe09035dade..f93acde5743c 100644
--- a/include/ui/qemu-spice-module.h
+++ b/include/ui/qemu-spice-module.h
@@ -18,10 +18,17 @@
 #ifndef QEMU_SPICE_MODULE_H
 #define QEMU_SPICE_MODULE_H
 
+#ifdef CONFIG_SPICE
+#include 
+#endif
+
 struct QemuSpiceOps {
 void (*init)(void);
 void (*display_init)(void);
 int (*migrate_info)(const char *h, int p, int t, const char *s);
+#ifdef CONFIG_SPICE
+int (*add_interface)(SpiceBaseInstance *sin);
+#endif
 };
 
 extern int using_spice;
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index a3fd1ea5ade8..6018577c5278 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -29,7 +29,6 @@
 void qemu_spice_input_init(void);
 void qemu_spice_display_init(void);
 int qemu_spice_display_add_client(int csock, int skipauth, int tls);
-int qemu_spice_add_interface(SpiceBaseInstance *sin);
 bool qemu_spice_have_display_interface(QemuConsole *con);
 int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con);
 int qemu_spice_set_passwd(const char *passwd,
diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index ed6dff1dcc41..8967cca12925 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -106,7 +106,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings 
*as,
 out->active = 0;
 
 out->sin.base.sif = _sif.base;
-qemu_spice_add_interface (>sin.base);
+qemu_spice.add_interface(>sin.base);
 #if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
 spice_server_set_playback_rate(>sin, settings.freq);
 #endif
@@ -215,7 +215,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings 
*as, void *drv_opaque)
 in->active = 0;
 
 in->sin.base.sif = _sif.base;
-qemu_spice_add_interface (>sin.base);
+qemu_spice.add_interface(>sin.base);
 #if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
 spice_server_set_record_rate(>sin, settings.freq);
 #endif
diff --git a/chardev/spice.c b/chardev/spice.c
index 7d1fb1771894..1104426e3a11 100644
--- a/chardev/spice.c
+++ b/chardev/spice.c
@@ -110,7 +110,7 @@ static void vmc_register_interface(SpiceChardev *scd)
 return;
 }
 scd->sin.base.sif = _interface.base;
-qemu_spice_add_interface(>sin.base);
+qemu_spice.add_interface(>sin.base);
 scd->active = true;
 trace_spice_vmc_register_interface(scd);
 }
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 82d5dbda3e26..483d880a3362 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -800,7 +800,7 @@ static void qemu_spice_init(void)
 migration_state.notify = migration_state_notifier;
 add_migration_state_change_notifier(_state);
 spice_migrate.base.sif = _interface.base;
-qemu_spice_add_interface(_migrate.base);
+qemu_spice.add_interface(_migrate.base);
 
 qemu_spice_input_init();
 
@@ -829,7 +829,7 @@ static void qemu_spice_init(void)
 #endif
 }
 
-int qemu_spice_add_interface(SpiceBaseInstance *sin)
+static int qemu_spice_add_interface(SpiceBaseInstance *sin)
 {
 if (!spice_server) {
 if (QTAILQ_FIRST(_spice_opts.head) != NULL) {
@@ -997,6 +997,7 @@ static struct QemuSpiceOps real_spice_ops = {
 .init = qemu_spice_init,
 .display_init = qemu_spice_display_init,
 .migrate_info = qemu_spice_migrate_info,
+.add_interface = qemu_spice_add_interface,
 };
 
 static void spice_register_config(void)
diff --git a/ui/spice-input.c b/ui/spice-input.c
index 21990fa9962b..bbd502564edf 100644
--- a/ui/spice-input.c
+++ b/ui/spice-input.c
@@ -231,7 +231,7 @@ static void mouse_mode_notifier(Notifier *notifier, void 
*data)
 }
 
 if (is_absolute) {
-qemu_spice_add_interface(>tablet.base);
+qemu_spice.add_interface(>tablet.base);
 } else {
 spice_server_remove_interface(>tablet.base);
 }
@@ -245,13 +245,13 @@ void qemu_spice_input_init(void)
 
 kbd = g_malloc0(sizeof(*kbd));
 kbd->sin.base.sif = _interface.base;
-qemu_spice_add_interface(>sin.base);
+qemu_spice.add_interface(>sin.base);
 qemu_add_led_event_handler(kbd_leds, kbd);
 
 pointer = g_malloc0(sizeof(*pointer));
 pointer->mouse.base.sif  = _interface.base;
 pointer->tablet.base.sif = _interface.base;
-qemu_spice_add_interface(>mouse.base);
+qemu_spice.add_interface(>mouse.base);
 
 pointer->absolute = false;
 pointer->mouse_mode.notify = mouse_mode_notifier;
-- 
2.27.0




[PATCH 03/14] spice: move qemu_spice_init() to QemuSpiceOps.

2020-10-19 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 include/ui/qemu-spice-module.h | 1 +
 include/ui/qemu-spice.h| 5 -
 softmmu/vl.c   | 2 +-
 ui/spice-core.c| 3 ++-
 ui/spice-module.c  | 5 +
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h
index 7a9963dd5810..b182bc4c21a6 100644
--- a/include/ui/qemu-spice-module.h
+++ b/include/ui/qemu-spice-module.h
@@ -19,6 +19,7 @@
 #define QEMU_SPICE_MODULE_H
 
 struct QemuSpiceOps {
+void (*init)(void);
 int (*migrate_info)(const char *h, int p, int t, const char *s);
 };
 
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index 3157016c2bb4..e6df0a8715b0 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -26,7 +26,6 @@
 #include 
 #include "qemu/config-file.h"
 
-void qemu_spice_init(void);
 void qemu_spice_input_init(void);
 void qemu_spice_display_init(void);
 int qemu_spice_display_add_client(int csock, int skipauth, int tls);
@@ -74,10 +73,6 @@ static inline void qemu_spice_display_init(void)
 abort();
 }
 
-static inline void qemu_spice_init(void)
-{
-}
-
 #endif /* CONFIG_SPICE */
 
 static inline bool qemu_using_spice(Error **errp)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index cb476aa70bcc..65c34a6b8a2e 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4151,7 +4151,7 @@ void qemu_init(int argc, char **argv, char **envp)
 /* spice needs the timers to be initialized by this point */
 /* spice must initialize before audio as it changes the default auiodev */
 /* spice must initialize before chardevs (for spicevmc and spiceport) */
-qemu_spice_init();
+qemu_spice.init();
 
 qemu_opts_foreach(qemu_find_opts("chardev"),
   chardev_init_func, NULL, _fatal);
diff --git a/ui/spice-core.c b/ui/spice-core.c
index b03d743cf9b9..6ef66eb387de 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -633,7 +633,7 @@ static void vm_change_state_handler(void *opaque, int 
running,
 }
 }
 
-void qemu_spice_init(void)
+static void qemu_spice_init(void)
 {
 QemuOpts *opts = QTAILQ_FIRST(_spice_opts.head);
 const char *password, *str, *x509_dir, *addr,
@@ -994,6 +994,7 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
 }
 
 static struct QemuSpiceOps real_spice_ops = {
+.init = qemu_spice_init,
 .migrate_info = qemu_spice_migrate_info,
 };
 
diff --git a/ui/spice-module.c b/ui/spice-module.c
index f1939545a684..a30fa452ea93 100644
--- a/ui/spice-module.c
+++ b/ui/spice-module.c
@@ -22,6 +22,10 @@
 
 int using_spice;
 
+static void qemu_spice_init_stub(void)
+{
+}
+
 static int qemu_spice_migrate_info_stub(const char *h, int p, int t,
 const char *s)
 {
@@ -29,5 +33,6 @@ static int qemu_spice_migrate_info_stub(const char *h, int p, 
int t,
 }
 
 struct QemuSpiceOps qemu_spice = {
+.init = qemu_spice_init_stub,
 .migrate_info = qemu_spice_migrate_info_stub,
 };
-- 
2.27.0




Re: [PATCH v2 2/9] configure: cross-compiling without cross_prefix

2020-10-19 Thread Thomas Huth
On 19/10/2020 03.39, Joelle van Dyne wrote:
> From: osy 
> 
> The iOS toolchain does not use the host prefix naming convention. We add a
> new option `--enable-cross-compile` that forces cross-compile even without
> a cross_prefix.
> 
> Signed-off-by: Joelle van Dyne 
> ---
>  configure | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 3c63879750..46d5db63e8 100755
> --- a/configure
> +++ b/configure
> @@ -234,6 +234,7 @@ cpu=""
>  iasl="iasl"
>  interp_prefix="/usr/gnemul/qemu-%M"
>  static="no"
> +cross_compile="no"
>  cross_prefix=""
>  audio_drv_list=""
>  block_drv_rw_whitelist=""
> @@ -456,6 +457,11 @@ for opt do
>optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
>case "$opt" in
>--cross-prefix=*) cross_prefix="$optarg"
> +cross_compile="yes"
> +  ;;
> +  --enable-cross-compile) cross_compile="yes"
> +  ;;
> +  --disable-cross-compile) cross_compile="no"

Can't you simply use --cros-prefix="" instead?

 Thomas




Re: [PULL v3 00/22] Build system + misc changes for 2020-10-16

2020-10-19 Thread Peter Maydell
On Sat, 17 Oct 2020 at 15:50, Paolo Bonzini  wrote:
>
> The following changes since commit 3e40748834923798aa57e3751db13a069e2c617b:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-mb-20201014' into 
> staging (2020-10-15 20:30:24 +0100)
>
> are available in the Git repository at:
>
>   https://gitlab.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to c47110d90fa5401bcc42c17f8ae0724a1c96599a:
>
>   ci: include configure and meson logs in all jobs if configure fails 
> (2020-10-17 10:45:53 -0400)
>
> 
> * Drop ninjatool and just require ninja (Paolo)
> * Fix docs build under msys2 (Yonggang)
> * HAX snafu fix (Claudio)
> * Disable signal handlers during fuzzing (Alex)
> * Miscellaneous fixes (Bruce, Greg)
>

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.2
for any user-visible changes.

-- PMM



Re: [PULL 25/33] tests/acceptance: Add a test for the N800 and N810 arm machines

2020-10-19 Thread Thomas Huth
On 17/10/2020 19.51, Philippe Mathieu-Daudé wrote:
> Hi Peter, Igor, Thomas,
> 
> On 2/28/20 5:38 PM, Peter Maydell wrote:
>> From: Thomas Huth 
>>
>> Old kernels from the Meego project can be used to check that Linux
>> is at least starting on these machines.
>>
>> Signed-off-by: Thomas Huth 
>> Reviewed-by: Wainer dos Santos Moschetta 
>> Reviewed-by: Philippe Mathieu-Daudé 
>> Tested-by: Philippe Mathieu-Daudé 
>> Signed-off-by: Philippe Mathieu-Daudé 
>> Message-id: 20200225172501.29609-2-phi...@redhat.com
>> Message-Id: <20200129131920.22302-1-th...@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé 
>> Signed-off-by: Peter Maydell 
>> ---
>>   MAINTAINERS  |  1 +
>>   tests/acceptance/machine_arm_n8x0.py | 49 
>>   2 files changed, 50 insertions(+)
>>   create mode 100644 tests/acceptance/machine_arm_n8x0.py
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index b66c46dcb9f..264374adbe8 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -686,6 +686,7 @@ F: hw/rtc/twl92230.c
>>   F: include/hw/display/blizzard.h
>>   F: include/hw/input/tsc2xxx.h
>>   F: include/hw/misc/cbus.h
>> +F: tests/acceptance/machine_arm_n8x0.py
>>     Palm
>>   M: Andrzej Zaborowski 
>> diff --git a/tests/acceptance/machine_arm_n8x0.py
>> b/tests/acceptance/machine_arm_n8x0.py
>> new file mode 100644
>> index 000..e5741f2d8d1
>> --- /dev/null
>> +++ b/tests/acceptance/machine_arm_n8x0.py
>> @@ -0,0 +1,49 @@
>> +# Functional test that boots a Linux kernel and checks the console
>> +#
>> +# Copyright (c) 2020 Red Hat, Inc.
>> +#
>> +# Author:
>> +#  Thomas Huth 
>> +#
>> +# This work is licensed under the terms of the GNU GPL, version 2 or
>> +# later.  See the COPYING file in the top-level directory.
>> +
>> +import os
>> +
>> +from avocado import skipUnless
>> +from avocado_qemu import Test
>> +from avocado_qemu import wait_for_console_pattern
>> +
>> +class N8x0Machine(Test):
>> +    """Boots the Linux kernel and checks that the console is operational"""
>> +
>> +    timeout = 90
>> +
>> +    def __do_test_n8x0(self):
>> +    kernel_url = ('http://stskeeps.subnetmask.net/meego-n8x0/'
>> +  'meego-arm-n8x0-1.0.80.20100712.1431-'
>> +  'vmlinuz-2.6.35~rc4-129.1-n8x0')
>> +    kernel_hash = 'e9d5ab8d7548923a0061b6fbf601465e479ed269'
>> +    kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>> +
>> +    self.vm.set_console(console_index=1)
>> +    self.vm.add_args('-kernel', kernel_path,
>> + '-append', 'printk.time=0 console=ttyS1')
>> +    self.vm.launch()
>> +    wait_for_console_pattern(self, 'TSC2005 driver initializing')
>> +
>> +    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
>> +    def test_n800(self):
>> +    """
>> +    :avocado: tags=arch:arm
>> +    :avocado: tags=machine:n800
>> +    """
>> +    self.__do_test_n8x0()
>> +
>> +    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
>> +    def test_n810(self):
>> +    """
>> +    :avocado: tags=arch:arm
>> +    :avocado: tags=machine:n810
>> +    """
>> +    self.__do_test_n8x0()
>>
> 
> FYI this test is failing:
> 
> qemu-system-arm: kernel 'meego-arm-n8x0-1.0.80.20100712.1431-vml
> inuz-2.6.35~rc4-129.1-n8x0' is too large to fit in RAM (kernel size 1964608,
> RAM size 0)
> 
> Alex, Thomas, can we enable AVOCADO_ALLOW_UNTRUSTED_CODE on GitLab
> to avoid such regressions?

Yes, please, if you've got some spare minutes to work on such a patch, that
would be great! ... I once already wanted to send such a patch, but IIRC
there were some other ALLOW_UNTRUSTED_CODE tests failing at that poing in
time, and I never got around to fix them...

 Thomas




[PATCH 08/14] spice: wire up monitor in QemuSpiceOps.

2020-10-19 Thread Gerd Hoffmann
Rename qmp_query_spice() to qmp_query_spice_real(), add to QemuSpiceOps.

Add new qmp_query_spice() function which calls the real function via
QemuSpiceOps if available, otherwise return SpiceInfo.enabled = false.

Signed-off-by: Gerd Hoffmann 
---
 include/ui/qemu-spice-module.h |  3 +++
 ui/spice-core.c|  3 ++-
 ui/spice-module.c  | 17 +
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h
index 7422f6404ba0..1f22d557ea2f 100644
--- a/include/ui/qemu-spice-module.h
+++ b/include/ui/qemu-spice-module.h
@@ -22,6 +22,8 @@
 #include 
 #endif
 
+typedef struct SpiceInfo SpiceInfo;
+
 struct QemuSpiceOps {
 void (*init)(void);
 void (*display_init)(void);
@@ -32,6 +34,7 @@ struct QemuSpiceOps {
 int (*display_add_client)(int csock, int skipauth, int tls);
 #ifdef CONFIG_SPICE
 int (*add_interface)(SpiceBaseInstance *sin);
+SpiceInfo* (*qmp_query)(Error **errp);
 #endif
 };
 
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 99457c226e6f..eea52f538999 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -502,7 +502,7 @@ static QemuOptsList qemu_spice_opts = {
 },
 };
 
-SpiceInfo *qmp_query_spice(Error **errp)
+static SpiceInfo *qmp_query_spice_real(Error **errp)
 {
 QemuOpts *opts = QTAILQ_FIRST(_spice_opts.head);
 int port, tls_port;
@@ -1001,6 +1001,7 @@ static struct QemuSpiceOps real_spice_ops = {
 .set_pw_expire = qemu_spice_set_pw_expire,
 .display_add_client = qemu_spice_display_add_client,
 .add_interface = qemu_spice_add_interface,
+.qmp_query = qmp_query_spice_real,
 };
 
 static void spice_register_config(void)
diff --git a/ui/spice-module.c b/ui/spice-module.c
index 8fbc99c03c55..32223358722c 100644
--- a/ui/spice-module.c
+++ b/ui/spice-module.c
@@ -19,6 +19,9 @@
 
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
+#include "qapi/error.h"
+#include "qapi/qapi-types-ui.h"
+#include "qapi/qapi-commands-ui.h"
 #include "ui/qemu-spice-module.h"
 
 int using_spice;
@@ -66,3 +69,17 @@ struct QemuSpiceOps qemu_spice = {
 .set_pw_expire = qemu_spice_set_pw_expire_stub,
 .display_add_client = qemu_spice_display_add_client_stub,
 };
+
+#ifdef CONFIG_SPICE
+
+SpiceInfo *qmp_query_spice(Error **errp)
+{
+if (!qemu_spice.qmp_query) {
+SpiceInfo *info = g_new0(SpiceInfo, 1);
+info->enabled = false;
+return info;
+}
+return qemu_spice.qmp_query(errp);
+}
+
+#endif
-- 
2.27.0




Re: [PATCH] hw/pci-host/grackle: Verify PIC link is properly set

2020-10-19 Thread Markus Armbruster
Philippe Mathieu-Daudé  writes:

> On 10/12/20 1:50 PM, BALATON Zoltan via wrote:
>> On Mon, 12 Oct 2020, David Gibson wrote:
>>> On Mon, Oct 12, 2020 at 08:21:41AM +0200, Philippe
>>> Mathieu-Daudé wrote:
 On 10/12/20 12:34 AM, David Gibson wrote:
> On Sun, Oct 11, 2020 at 09:03:32PM +0200, Philippe
> Mathieu-Daudé wrote:
>> The Grackle PCI host model expects the interrupt controller
>> being set, but does not verify it is present. Add a check to
>> help developers using this model.
>
> I don't think thaqt's very likely, but, sure, applied to ppc-for-5.2

 Do you want I correct the description as:
 "The Grackle PCI host model expects the interrupt controller
 being set, but does not verify it is present.
 A developer basing its implementation on the Grackle model
 might hit this problem. Add a check to help future developers
 using this model as reference."?
>>>
>>> No, it's fine.  All I was saying is that the chances of anyone using
>>> Grackle in future seem very low to me.
>> So maybe an assert instead of a user visible error would be enough?
>
> My understanding is realize() shouldn't abort()
> (the caller might choose to by using _abort).

assert() is for checking invariants.  A violated invariant is a
programming error: developers screwed up, safe recovery is impossible.

Abusing assert() to catch errors that are not programming errors is
wrong.

You may check invariants with assert() anywhere in the code.

You should not misuse assert() anywhere in the code.

Sometimes, an error condition that is *not* a programming error in the
function where it is detected *is* a programming error for certain
calls.  Having these calls pass _abort is a common solution for
this problem.

Hope this helps.




[PATCH 14/14] opengl: build opengl helper code modular

2020-10-19 Thread Gerd Hoffmann
Removes opengl dependency from core qemu.  The number of shared
libraries for qemu-system-x86_64 goes down from 66 to 60 on my system.

Signed-off-by: Gerd Hoffmann 
---
 util/module.c  | 7 +++
 ui/meson.build | 8 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/util/module.c b/util/module.c
index 21237dcc24df..fe3b82dd4d37 100644
--- a/util/module.c
+++ b/util/module.c
@@ -181,6 +181,13 @@ static const struct {
 { "hw-display-qxl", "ui-spice-core" },
 { "ui-spice-app",   "ui-spice-core" },
 { "ui-spice-app",   "chardev-spice" },
+
+#ifdef CONFIG_OPENGL
+{ "ui-egl-headless", "ui-opengl"},
+{ "ui-gtk",  "ui-opengl"},
+{ "ui-sdl",  "ui-opengl"},
+{ "ui-spice-core",   "ui-opengl"},
+#endif
 };
 #endif
 
diff --git a/ui/meson.build b/ui/meson.build
index 3cf03d2c297b..73c8dbc7c742 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -33,7 +33,6 @@ vnc_ss.add(zlib, png, jpeg)
 vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c'))
 softmmu_ss.add_all(when: vnc, if_true: vnc_ss)
 softmmu_ss.add(when: vnc, if_false: files('vnc-stubs.c'))
-softmmu_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('shader.c', 
'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
 specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)
 
 ui_modules = {}
@@ -44,6 +43,13 @@ if curses.found()
   ui_modules += {'curses' : curses_ss}
 endif
 
+if config_host.has_key('CONFIG_OPENGL')
+  opengl_ss = ss.source_set()
+  opengl_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL'],
+   if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 
'egl-context.c'))
+  ui_modules += {'opengl' : opengl_ss}
+endif
+
 if config_host.has_key('CONFIG_OPENGL_DMABUF')
   egl_headless_ss = ss.source_set()
   egl_headless_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL_DMABUF'],
-- 
2.27.0




Re: [PULL 00/34] QAPI patches patches for 2020-10-10

2020-10-19 Thread Markus Armbruster
Philippe Mathieu-Daudé  writes:

> On 10/10/20 11:54 AM, Markus Armbruster wrote:
>> The following changes since commit 4a7c0bd9dcb08798c6f82e55b5a3423f7ee669f1:
>>Merge remote-tracking branch
>> 'remotes/dgibson/tags/ppc-for-5.2-20201009' into staging (2020-10-09
>> 15:48:04 +0100)
>> are available in the Git repository at:
>>git://repo.or.cz/qemu/armbru.git tags/pull-qapi-2020-10-10
>> for you to fetch changes up to
>> b4c0aa59aff520e2a55edd5fef393058ca6520de:
>>qapi/visit.py: add type hint annotations (2020-10-10 11:37:49
>> +0200)
>> 
>> QAPI patches patches for 2020-10-10
>
> The "GCC check-tcg (user)" is 6 min slower since this pull request,
> making Travis-CI fails:
>
> https://travis-ci.org/github/qemu/qemu/builds/734773760
> https://travis-ci.org/github/qemu/qemu/builds/734983001
>
> Any remote idea what could be the reason?

No.  This is unexpected.  The changes to generated QAPI files are
limited to whitespace.

John, can you work with Philippe to get to the bottom of this?




Re: [PATCH] docs/system: Deprecate raspi2/raspi3 machine aliases

2020-10-19 Thread Philippe Mathieu-Daudé

On 10/19/20 10:21 AM, Philippe Mathieu-Daudé wrote:

Since commit aa35ec2213b ("hw/arm/raspi: Use more
specific machine names") the raspi2/raspi3 machines
have been renamed as raspi2b/raspi3b.

As more Raspberry Pi 2/3 models are emulated, in order
to avoid confusion deprecate the raspi2/raspi3 machine
aliases.


Note that the raspi3ap (posted yesterday) is a closer match
to what we model than the raspi3b. But the B model has 1GB
of RAM, while the A+ has 512MB. As a bigger amount of RAM
is probably more useful to our users, I'm not suggesting
replacing the raspi3 alias.



Signed-off-by: Philippe Mathieu-Daudé 
---
  docs/system/deprecated.rst | 5 +
  1 file changed, 5 insertions(+)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 905628f3a0c..f0c7aaeb2ff 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -355,6 +355,11 @@ This machine has been renamed ``fuloong2e``.
  These machine types are very old and likely can not be used for live migration
  from old QEMU versions anymore. A newer machine type should be used instead.
  
+Raspberry Pi ``raspi2`` and ``raspi3`` machines (since 5.2)

+'
+
+These machines have been respectively renamed ``raspi2b`` and ``raspi3b``.
+
  Device options
  --
  





Re: [PATCH v2 0/9] iOS and Apple Silicon host support

2020-10-19 Thread Thomas Huth
On 19/10/2020 03.39, Joelle van Dyne wrote:
> These set of changes brings QEMU TCG to iOS devices and future Apple Silicon
> devices. They were originally developed last year and have been working in the
> UTM app. Recently, we ported the changes to master, re-wrote a lot of the 
> build
> script changes for meson, and broke up the patches into more distinct units.
> 
> A summary of the changes:
> 
> * `CONFIG_IOS` and `CONFIG_IOS_JIT` defined when building for iOS and
>   iOS specific changes (as well as unsupported code) are gated behind it.
> * A new dependency, libucontext is added since iOS does not have native 
> ucontext
>   and broken support for sigaltstack. libucontext is available as a new option
>   for coroutine backend.
> * On stock iOS devices, there is a workaround for running JIT code without
>   any special entitlement. It requires the JIT region to be mirror mapped with
>   one region RW and another one RX. To support this style of JIT, TCG is 
> changed
>   to support writing to a different code_ptr. These changes are gated by the
>   `CONFIG_IOS_JIT`.
> * For (recent) jailbroken iOS devices as well as upcoming Apple Silicon 
> devices,
>   there are new rules for applications supporting JIT (with the proper
>   entitlement). These rules are implemented as well.
> 
> Since v2:
> 
> * Changed getting mirror pointer from a macro to inline functions
> * Split constification of TCG code pointers to separate patch
> * Removed slirp updates (will send future patch once slirp changes are in)
> * Removed shared library patch (will send future patch)
> 
> -j
> 
> osy (9):
>   configure: option to disable host block devices
>   configure: cross-compiling without cross_prefix
>   qemu: add support for iOS host
>   coroutine: add libucontext as external library
>   tcg: add const hints for code pointers
>   tcg: implement mirror mapped JIT for iOS
>   tcg: mirror mapping RWX pages for iOS optional
>   tcg: support JIT on Apple Silicon
>   block: check availablity for preadv/pwritev on mac

Is there maybe also a way to compile-test this automatically in a macOS
container on Cirrus-CI or Travis, too? ... otherwise I'm a little bit afraid
that this support might bit-rot quite fast again, since most developers
don't have the corresponding setup...

 Thomas




Re: [PATCH] hw/riscv: microchip_pfsoc: IOSCBCTRL memmap entry

2020-10-19 Thread Ivan Griffin
Yes, it could be.

But the "Physical Address" column, in my mind, should be the 0x3702 
address.  At least when I check other peripherals, their physical address 
values in the register map HTML corresponds to the source code.

Cheers,
Ivan.


From: Bin Meng 
Sent: Monday 19 October 2020 09:38
To: Ivan Griffin 
Cc: Alistair Francis ; QEMU Trivial 
; open list:RISC-V ; 
qemu-devel@nongnu.org Developers 
Subject: Re: [PATCH] hw/riscv: microchip_pfsoc: IOSCBCTRL memmap entry

Hi Ivan,

On Mon, Oct 19, 2020 at 4:17 PM Ivan Griffin  wrote:
>
> Hi Bin,
>
> Well spotted with the register map. I grepped it for 0x3702 and didn't 
> find it, but it seems the address (incorrectly) is 0x0702 in the 
> documentation.
>

I believe the documented offset 0x0702 is the offset into the
IOSCB block, not the final one that is mapped into the system memory.

Regards,
Bin

> 
> From: Bin Meng 
> Sent: Monday 19 October 2020 03:05
> To: Ivan Griffin 
> Cc: Alistair Francis ; QEMU Trivial 
> ; Bin Meng ; open 
> list:RISC-V ; qemu-devel@nongnu.org Developers 
> 
> Subject: Re: [PATCH] hw/riscv: microchip_pfsoc: IOSCBCTRL memmap entry
>
> Hi Ivan,
>
> On Sat, Oct 17, 2020 at 12:31 AM Ivan Griffin  wrote:
> >
> > I don't know why it isn't documented in that PDF (or in the register map), 
> > but if you check 
> > https://github.com/polarfire-soc/polarfire-soc-bare-metal-library/blob/master/src/platform/drivers/mss_sys_services/mss_sys_services.h
> >  you'll see the following
> >
> > ```
> > typedef struct
> > {
> > volatile uint32_t SOFT_RESET;
> > volatile uint32_t VDETECTOR;
> > volatile uint32_t TVS_CONTROL;
> > volatile uint32_t TVS_TEMP_A;
> > volatile uint32_t TVS_TEMP_B;
> > volatile uint32_t TVS_TEMP_C;
> > volatile uint32_t TVS_VOLT_A;
> > volatile uint32_t TVS_VOLT_B;
> > volatile uint32_t TVS_VOLT_C;
> > volatile uint32_t TVS_OUTPUT0;
> > volatile uint32_t TVS_OUTPUT1;
> > volatile uint32_t TVS_TRIGGER;
> > volatile uint32_t TRIM_VDET1P05;
> > volatile uint32_t TRIM_VDET1P8;
> > volatile uint32_t TRIM_VDET2P5;
> > volatile uint32_t TRIM_TVS;
> > volatile uint32_t TRIM_GDET1P05;
> > volatile uint32_t RESERVED0;
> > volatile uint32_t RESERVED1;
> > volatile uint32_t RESERVED2;
> > volatile uint32_t SERVICES_CR;
> > volatile uint32_t SERVICES_SR;
> > volatile uint32_t USER_DETECTOR_SR;
> > volatile uint32_t USER_DETECTOR_CR;
> > volatile uint32_t MSS_SPI_CR;
> >
> > } SCBCTRL_TypeDef;
> >
> > #define MSS_SCBCTRL((SCBCTRL_TypeDef*) (0x3702UL))
> >
> > /*2kB bytes long mailbox.*/
> > #define MSS_SCBMAILBOX ((uint32_t*) (0x37020800UL))
> > ```
> >
> > And in 
> > https://github.com/polarfire-soc/polarfire-soc-bare-metal-library/blob/master/src/platform/drivers/mss_sys_services/mss_sys_services.c
> >  you'll see MSS_SCB and MSS_SCBMAILBOX used in many places to interact with 
> > the FPGA system controller to perform various services.
>
> It's actually documented, but not in the PDF file. I also spent some
> time locating the doc when I do the DDR controller modeling work.
>
> See Register Map/PF_SoC_RegMap_V1_1/MPFS250T/pfsoc_control_scb.htm in
> https://www.microsemi.com/document-portal/doc_download/1244581-polarfire-soc-register-map


Re: [PATCH] ati: mask x y display parameter values

2020-10-19 Thread P J P
+-- On Sun, 18 Oct 2020, BALATON Zoltan wrote --+
| The s->regs.[src|dst]_[xy] values should not be over 0x3fff because we mask 
| them on register write in ati.c

  Yes, those register values are set to zero(0).

| and here [src|dst]_[x|y] local variables are declared unsigned so negative 
| values come out as large integers that should be caught by the checks below 
| as being over VRAM end

  As above register values are zero(0), following expression(s)

dst_x = ... (s->regs.dst_x(=0) + 1 - s->regs.dst_width(=16383))
dst_y = ... (s->regs.dst_y(=0) + 1 - s->regs.dst_height(=16383))

result in large unsigned values: 

  ati_2d_blt
pixman_blt(0x7f03cbe0, 0x7f03cbe0, 131064, 131064, 32, 32,
   src_x=0, src_y=-16382, dst_x=0, dst_y=-16382, 16383, 16383)

Shown as negative values due to signed '%d' conversion.

| but those checks may have an off by one error or some other mistake.

uint8_t *end = s->vga.vram_ptr + s->vga.vram_size;
if (dst_bits >= end || dst_bits + dst_x + (dst_y + s->regs.dst_height) * 
dst_stride >= end) {
qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n");
return;
}

* Above check does not seem to catch it.

* Does a check below look okay?
===
diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c
index 524bc03a83..b75acc7fda 100644
--- a/hw/display/ati_2d.c
+++ b/hw/display/ati_2d.c
@@ -54,9 +54,13 @@ void ati_2d_blt(ATIVGAState *s)
...
+if (dst_x > 0x3fff || dst_y > 0x3fff) {
+qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n");
+return;
+}
...
+if (src_x > 0x3fff || src_y > 0x3fff) {
+qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n");
+return;
+}
===

* ati_2d_blt() routine looks complex. Maybe it can be divided in two halves.


Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D




Re: [PATCH V2 00/10] COLO project queued patches 20-Oct

2020-10-19 Thread Jason Wang



On 2020/10/16 下午1:51, Zhang Chen wrote:

From: Zhang Chen 

Hi Jason, this series include latest COLO related patches.
please check and merge it.

Li Zhijian (2):
   colo-compare: fix missing compare_seq initialization
   colo-compare: check mark in mutual exclusion

Pan Nengyuan (1):
   net/filter-rewriter: destroy g_hash_table in colo_rewriter_cleanup

Rao, Lei (3):
   Optimize seq_sorter function for colo-compare
   Reduce the time of checkpoint for COLO
   Fix the qemu crash when guest shutdown in COLO mode

Zhang Chen (4):
   net/colo-compare.c: Fix compare_timeout format issue
   net/colo-compare.c: Change the timer clock type
   net/colo-compare.c: Add secondary old packet detection
   net/colo-compare.c: Increase default queued packet scan frequency

  migration/ram.c   | 14 ++-
  net/colo-compare.c| 58 ++-
  net/colo.c|  5 +---
  net/filter-rewriter.c |  2 ++
  softmmu/vl.c  |  1 +
  5 files changed, 47 insertions(+), 33 deletions(-)



Applied.

Thanks




答复: [PATCH 1/1] Skip flatview_simplify() for cpu vendor zhaoxin

2020-10-19 Thread FelixCui-oc
hi paolo,


>2) you're adding a check for the host, but the bug applies to all hosts.
>If there is a bug on x86 hardware emulation, it should be fixed even
>when emulating x86 from ARM.  It should also apply to all CPU vendors.


What is the progress of handling this bug ?

If the processing is more complicated, can we temporarily remove 
flatview_simplify()?


hi Alex,


>the issue here is that the delete+add passes are racing against an
>assigned device's DMA


Please help comment how to solve this problem.


Best regards

Felixcui-oc



发件人: Paolo Bonzini 
发送时间: 2020年10月16日 19:42:29
收件人: FelixCui-oc; Richard Henderson; Eduardo Habkost; Alex Williamson
抄送: qemu-devel@nongnu.org; RockCui-oc; Tony W Wang-oc; CobeChen-oc; Alex 
Williamson
主题: Re: [PATCH 1/1] Skip flatview_simplify() for cpu vendor zhaoxin

On 16/10/20 13:29, FelixCuioc wrote:
> The issue here is that an assinged EHCI device accesses
> an adjacent mapping between the delete and add phases
> of the VFIO MemoryListener.
> We want to skip flatview_simplify() is to prevent EHCI
> device IOVA mappings from being unmapped.

Hi,

there is indeed a bug, but I have already explained last month
(https://mail.gnu.org/archive/html/qemu-devel/2020-09/msg01279.html)
that this patch is conceptually wrong:

1) you're adding host_get_vendor conditioned on compiling the x86
emulator, so you are breaking compilation on non-x86 machines.

2) you're adding a check for the host, but the bug applies to all hosts.
 If there is a bug on x86 hardware emulation, it should be fixed even
when emulating x86 from ARM.  It should also apply to all CPU vendors.

Alex, the issue here is that the delete+add passes are racing against an
assigned device's DMA. For KVM we were thinking of changing the whole
memory map with a single ioctl, but that's much easier because KVM
builds its page tables lazily. It would be possible for the IOMMU too
but it would require a relatively complicated comparison of the old and
new memory maps in the kernel.

Paolo



Re: [PATCH v6 03/36] qapi-gen: Separate arg-parsing from generation

2020-10-19 Thread Markus Armbruster
John Snow  writes:

> On 10/9/20 1:26 PM, Markus Armbruster wrote:
>> John Snow  writes:
>> 
>>> This is a minor re-work of the entrypoint script. It isolates a
>> entrypoint is not a word  ;-P
>> 
>
> I'm not entirely sure why a German is complaining about the birth of a
> new and beautiful compound noun.

Ha!

> (I started to make sure I wrote it out as two words, but missed a
> spot. Too late now, unless you fixed it already.)

I didn't.

>>> generate() method from the actual command-line mechanism.
>>>
>>> Signed-off-by: John Snow 
>>> Reviewed-by: Eduardo Habkost 
>>> Reviewed-by: Cleber Rosa 
>>> Tested-by: Cleber Rosa 
>>> ---
>>>   scripts/qapi-gen.py | 89 ++---
>>>   1 file changed, 67 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py
>>> index 541e8c1f55d..054554ed846 100644
>>> --- a/scripts/qapi-gen.py
>>> +++ b/scripts/qapi-gen.py
>>> @@ -1,30 +1,77 @@
>>>   #!/usr/bin/env python3
>>> -# QAPI generator
>>> -#
>>> +
>>>   # This work is licensed under the terms of the GNU GPL, version 2 or 
>>> later.
>>>   # See the COPYING file in the top-level directory.
>>>   +"""
>>> +QAPI Generator
>>> +
>>> +This is the main entry point for generating C code from the QAPI schema.
>>> +"""
>>> import argparse
>>>   import re
>>>   import sys
>>> +from typing import Optional
>>> from qapi.commands import gen_commands
>>> +from qapi.error import QAPIError
>>>   from qapi.events import gen_events
>>>   from qapi.introspect import gen_introspect
>>> -from qapi.schema import QAPIError, QAPISchema
>>> +from qapi.schema import QAPISchema
>>>   from qapi.types import gen_types
>>>   from qapi.visit import gen_visit
>>> 
>>> -def main(argv):
>>> +def invalid_char(prefix: str) -> Optional[str]:
>> 
>> Naming is hard...  invalid_char() makes sense because it returns the
>> invalid character.  The name's a tad generic, though.  Would
>> first_invalid_prefix_char() be easier to understand?
>
> Sounds like an improvement to me. I guess that should be in a follow-up now.

I took the liberty to rename it to invalid_prefix_char() in my tree.
Has since been merged into master as commit 52a474180ae.

>>> +match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix)
>>> +if match.end() != len(prefix):
>>> +return prefix[match.end()]
>>> +return None
>> [...]
>> 




Re: [PATCH v2 9/9] block: check availablity for preadv/pwritev on mac

2020-10-19 Thread Thomas Huth
On 19/10/2020 03.39, Joelle van Dyne wrote:
> From: osy 

That "From:" line looks wrong ... could you please fix the "Author" of your
patches / your git config?

> macOS 11/iOS 14 added preadv/pwritev APIs. Due to weak linking, configure
> will succeed with CONFIG_PREADV even when targeting a lower OS version. We
> therefore need to check at run time if we can actually use these APIs.

That sounds like the wrong approach to me ... could you please try to fix
the check in "configure" instead? E.g. by running compile_prog with
"-Werror", so that the test fails if there is no valid prototype available?

 Thomas




[PATCH] [RFC] hw/arm/smmuv3: Set the restoration priority of the vSMMUv3 explicitly

2020-10-19 Thread Zenghui Yu
Ensure the vSMMUv3 will be restored before all PCIe devices so that DMA
translation can work properly during migration.

Signed-off-by: Zenghui Yu 
---

not sure if anything would actually go wrong...

 hw/arm/smmuv3.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index 0122700e72..2017ba7a5a 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -1440,6 +1440,7 @@ static const VMStateDescription vmstate_smmuv3 = {
 .name = "smmuv3",
 .version_id = 1,
 .minimum_version_id = 1,
+.priority = MIG_PRI_IOMMU,
 .fields = (VMStateField[]) {
 VMSTATE_UINT32(features, SMMUv3State),
 VMSTATE_UINT8(sid_size, SMMUv3State),
-- 
2.19.1




Re: [PATCH v7 05/11] hw/block/nvme: Support Zoned Namespace Command Set

2020-10-19 Thread Klaus Jensen
On Oct 19 11:17, Dmitry Fomichev wrote:
> The emulation code has been changed to advertise NVM Command Set when
> "zoned" device property is not set (default) and Zoned Namespace
> Command Set otherwise.
> 
> Define values and structures that are needed to support Zoned
> Namespace Command Set (NVMe TP 4053) in PCI NVMe controller emulator.
> Define trace events where needed in newly introduced code.
> 
> In order to improve scalability, all open, closed and full zones
> are organized in separate linked lists. Consequently, almost all
> zone operations don't require scanning of the entire zone array
> (which potentially can be quite large) - it is only necessary to
> enumerate one or more zone lists.
> 
> Handlers for three new NVMe commands introduced in Zoned Namespace
> Command Set specification are added, namely for Zone Management
> Receive, Zone Management Send and Zone Append.
> 
> Device initialization code has been extended to create a proper
> configuration for zoned operation using device properties.
> 
> Read/Write command handler is modified to only allow writes at the
> write pointer if the namespace is zoned. For Zone Append command,
> writes implicitly happen at the write pointer and the starting write
> pointer value is returned as the result of the command. Write Zeroes
> handler is modified to add zoned checks that are identical to those
> done as a part of Write flow.
> 
> Subsequent commits in this series add ZDE support and checks for
> active and open zone limits.
> 
> Signed-off-by: Niklas Cassel 
> Signed-off-by: Hans Holmberg 
> Signed-off-by: Ajay Joshi 
> Signed-off-by: Chaitanya Kulkarni 
> Signed-off-by: Matias Bjorling 
> Signed-off-by: Aravind Ramesh 
> Signed-off-by: Shin'ichiro Kawasaki 
> Signed-off-by: Adam Manzanares 
> Signed-off-by: Dmitry Fomichev 
> ---
>  block/nvme.c  |   2 +-
>  hw/block/nvme-ns.c| 193 +
>  hw/block/nvme-ns.h|  54 +++
>  hw/block/nvme.c   | 975 --
>  hw/block/nvme.h   |   9 +
>  hw/block/trace-events |  21 +
>  include/block/nvme.h  | 113 -
>  7 files changed, 1339 insertions(+), 28 deletions(-)
> 
> diff --git a/block/nvme.c b/block/nvme.c
> index 05485fdd11..7a513c9a17 100644
> --- a/block/nvme.c
> +++ b/block/nvme.c
> +static void nvme_fill_read_data(NvmeRequest *req, uint64_t offset,
> +uint32_t max_len, uint8_t pattern)
> +{
> +QEMUSGList *qsg = >qsg;
> +QEMUIOVector *iov = >iov;
> +ScatterGatherEntry *entry;
> +uint32_t len, ent_len;
> +
> +if (qsg->nsg > 0) {
> +entry = qsg->sg;
> +len = qsg->size;
> +if (max_len) {
> +len = MIN(len, max_len);
> +}
> +for (; len > 0; len -= ent_len) {
> +ent_len = MIN(len, entry->len);
> +if (offset > ent_len) {
> +offset -= ent_len;
> +} else if (offset != 0) {
> +dma_memory_set(qsg->as, entry->base + offset,
> +   pattern, ent_len - offset);
> +offset = 0;
> +} else {
> +dma_memory_set(qsg->as, entry->base, pattern, ent_len);
> +}
> +entry++;

dma_memory_set can fail. In that case, I think just fail the command
with NVME_DATA_TRAS_ERROR.

But I think this should be removed in any case, see below.

> +static uint16_t nvme_check_zone_read(NvmeNamespace *ns, NvmeZone *zone,
> + uint64_t slba, uint32_t nlb,
> + NvmeReadFillCtx *rfc)
> +{
> +NvmeZone *next_zone;
> +uint64_t bndry = nvme_zone_rd_boundary(ns, zone);
> +uint64_t end = slba + nlb, wp1, wp2;
> +uint16_t status;
> +
> +rfc->pre_rd_fill_slba = ~0ULL;
> +rfc->pre_rd_fill_nlb = 0;
> +rfc->read_slba = slba;
> +rfc->read_nlb = nlb;
> +rfc->post_rd_fill_slba = ~0ULL;
> +rfc->post_rd_fill_nlb = 0;
> +
> +status = nvme_zone_state_ok_to_read(zone);
> +if (status != NVME_SUCCESS) {
> +;
> +} else if (likely(end <= bndry)) {
> +if (end > zone->w_ptr) {
> +wp1 = zone->w_ptr;
> +if (slba >= wp1) {
> +/* No i/o necessary, just fill */
> +rfc->pre_rd_fill_slba = slba;
> +rfc->pre_rd_fill_nlb = nlb;
> +rfc->read_nlb = 0;
> +} else {
> +rfc->read_nlb = wp1 - slba;
> +rfc->post_rd_fill_slba = wp1;
> +rfc->post_rd_fill_nlb = nlb - rfc->read_nlb;
> +   }
> +}
> +} else if (!ns->params.cross_zone_read) {
> +status = NVME_ZONE_BOUNDARY_ERROR;
> +} else {
> +/*
> + * Read across zone boundary, look at the next zone.
> + * Earlier bounds checks ensure that the current zone
> + * is not the last one.
> + */
> +next_zone = zone + 1;
> +status = 

[PATCH] hw/arm/nseries: Fix loading kernel image on n8x0 machines

2020-10-19 Thread Philippe Mathieu-Daudé
Commit 7998beb9c2e removed the ram_size initialization in the
arm_boot_info structure, however it is used by arm_load_kernel().

Initialize the field to fix:

  $ qemu-system-arm -M n800 -append 'console=ttyS1' \
-kernel meego-arm-n8x0-1.0.80.20100712.1431-vmlinuz-2.6.35~rc4-129.1-n8x0
  qemu-system-arm: kernel 
'meego-arm-n8x0-1.0.80.20100712.1431-vmlinuz-2.6.35~rc4-129.1-n8x0' is too 
large to fit in RAM (kernel size 1964608, RAM size 0)

Noticed while running the test introduced in commit 050a82f0c5b
("tests/acceptance: Add a test for the N800 and N810 arm machines").

Fixes: 7998beb9c2e ("arm/nseries: use memdev for RAM")
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/arm/nseries.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index e48092ca047..76fd7fe9854 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -1318,6 +1318,7 @@ static void n8x0_init(MachineState *machine,
 g_free(sz);
 exit(EXIT_FAILURE);
 }
+binfo->ram_size = machine->ram_size;
 
 memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE,
 machine->ram);
-- 
2.26.2




Re: [PULL v2 0/5] 9p queue (previous 2020-10-15)

2020-10-19 Thread Peter Maydell
On Mon, 19 Oct 2020 at 11:19, Christian Schoenebeck
 wrote:
>
> On Montag, 19. Oktober 2020 11:52:38 CEST Peter Maydell wrote:
> > This emits a lot of new warnings during 'make check':
> >
> > PASS 27 qtest-arm: qos-test
> > /arm/virt/virtio-mmio/virtio-bus/virtio-9p-device/virtio-9p/virtio-9p-tests/
> > local/config qemu-system-arm: warning: 9p: degraded performance: a
> > reasonable high msize should be chosen on client/guest side (chosen msize
> > is <= 8192). See https://wiki.qemu.org/Documentation/9psetup#msize for
> > details. PASS 28 qtest-arm: qos-test
> > /arm/virt/virtio-mmio/virtio-bus/virtio-9p-device/virtio-9p/virtio-9p-tests/
> > local/create_dir
> >
> > PASS 54 qtest-i386: qos-test
> > /i386/pc/i440FX-pcihost/pci-bus-pc/pci-bus/virtio-9p-pci/virtio-9p/virtio-9p
> > -tests/local/config qemu-system-i386: warning: 9p: degraded performance: a
> > reasonable high msize should be chosen on client/guest side (chosen msize
> > is <= 8192). See https://wiki.qemu.org/Documentation/9psetup#msize for
> > details. PASS 55 qtest-i386: qos-test
> > /i386/pc/i440FX-pcihost/pci-bus-pc/pci-bus/virtio-9p-pci/virtio-9p/virtio-9p
> > -tests/local/create_dir

> One warning per test suite run (i.e. per architecture due to
> warn_report_once()), yes. That performance warning is meant for end user
> installations to remind them setting some (reasonable high) value for 9p
> client parameter 'msize' on guest OS side. The warning triggers here because
> the 9p test cases intentionally run with a small 'msize' to guard edge cases.
>
> Would it be Ok for you to merge it with this performance warning for now? I
> can take care of silencing it before 5.2 release. It probably requires to
> introduce a new CL option to suppress performance warnings like these, or by
> finding a way to detect that we're currently just running qtests.

The usual approach is to suppress this kind of warning by guarding
it with if (qtest_enabled()) { ... }.

I'm generally reluctant to allow new warnings in, because then they
never go away and my scripts build up a long list of "ignore this
particular warning" exceptions.

thanks
-- PMM



[RFC PATCH v3 1/1] tests/vm: Add Haiku test based on their vagrant images

2020-10-19 Thread Philippe Mathieu-Daudé
From: Alexander von Gluck IV 

Signed-off-by: Alexander von Gluck IV 
[PMD: Avoid to recreate the image each time]
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/keys/vagrant|  27 +
 tests/keys/vagrant.pub|   1 +
 tests/vm/Makefile.include |   3 +-
 tests/vm/basevm.py|   5 +-
 tests/vm/haiku.x86_64 | 116 ++
 5 files changed, 149 insertions(+), 3 deletions(-)
 create mode 100644 tests/keys/vagrant
 create mode 100644 tests/keys/vagrant.pub
 create mode 100755 tests/vm/haiku.x86_64

diff --git a/tests/keys/vagrant b/tests/keys/vagrant
new file mode 100644
index 000..7d6a083909e
--- /dev/null
+++ b/tests/keys/vagrant
@@ -0,0 +1,27 @@
+-BEGIN RSA PRIVATE KEY-
+MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
+w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP
+kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2
+hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO
+Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW
+yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd
+ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1
+Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf
+TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK
+iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A
+sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf
+4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP
+cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk
+EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN
+CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX
+3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG
+YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj
+3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+
+dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz
+6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC
+P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF
+llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ
+kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH
++vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ
+NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
+-END RSA PRIVATE KEY-
diff --git a/tests/keys/vagrant.pub b/tests/keys/vagrant.pub
new file mode 100644
index 000..b8d012d787f
--- /dev/null
+++ b/tests/keys/vagrant.pub
@@ -0,0 +1 @@
+ssh-rsa 
B3NzaC1yc2EBIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==
 well-known vagrant key for qemu-test, do not use on any machine exposed to an 
external network
diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index 61f893ffdc0..e94d95ec541 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -4,7 +4,7 @@
 
 EFI_AARCH64 = $(wildcard $(BUILD_DIR)/pc-bios/edk2-aarch64-code.fd)
 
-IMAGES := freebsd netbsd openbsd centos fedora
+IMAGES := freebsd netbsd openbsd centos fedora haiku.x86_64
 ifneq ($(GENISOIMAGE),)
 IMAGES += ubuntu.i386 centos
 ifneq ($(EFI_AARCH64),)
@@ -41,6 +41,7 @@ endif
 else
@echo "  (install genisoimage to build centos/ubuntu images)"
 endif
+   @echo "  vm-build-haiku.x86_64   - Build QEMU in Haiku VM"
@echo ""
@echo "  vm-build-all- Build QEMU in all VMs"
@echo "  vm-clean-all- Clean up VM images"
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 3fac20e929a..00f1d5ca8da 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -44,6 +44,7 @@
 'machine' : 'pc',
 'guest_user'  : "qemu",
 'guest_pass'  : "qemupass",
+'root_user'   : "root",
 'root_pass'   : "qemupass",
 'ssh_key_file': SSH_KEY_FILE,
 'ssh_pub_key_file': SSH_PUB_KEY_FILE,
@@ -245,13 +246,13 @@ def ssh(self, *cmd):
 return self._ssh_do(self._config["guest_user"], cmd, False)
 
 def ssh_root(self, *cmd):
-return self._ssh_do("root", cmd, False)
+return self._ssh_do(self._config["root_user"], cmd, False)
 
 def ssh_check(self, *cmd):
 self._ssh_do(self._config["guest_user"], cmd, True)
 
 def ssh_root_check(self, *cmd):
-self._ssh_do("root", cmd, True)
+self._ssh_do(self._config["root_user"], cmd, True)
 
 def build_image(self, img):
 raise NotImplementedError
diff --git a/tests/vm/haiku.x86_64 b/tests/vm/haiku.x86_64
new file mode 100755
index 000..634ef774870
--- /dev/null
+++ b/tests/vm/haiku.x86_64
@@ 

Re: [PATCH] configure: Test that gio libs from pkg-config work

2020-10-19 Thread Philippe Mathieu-Daudé

On 9/28/20 6:04 PM, Peter Maydell wrote:

On some hosts (eg Ubuntu Bionic) pkg-config returns a set of
libraries for gio-2.0 which don't actually work when compiling
statically. (Specifically, the returned library string includes
-lmount, but not -lblkid which -lmount depends upon, so linking
fails due to missing symbols.)

Check that the libraries work, and don't enable gio if they don't,
in the same way we do for gnutls.

Signed-off-by: Peter Maydell 
---
I wanted a statically-linked system emulation binary (which, yes,
I know is not really something we support :-)). I got one with
suitably liberal use of --disable-foo configure options, and
this was the only thing I couldn't work around that way.
The patch is needed because there's no --disable-gio. I suppose
we could add that instead (or as well)...
Possibly meson offers a nicer way to do this, but this was
simple and gnutls is doing the check this way already.
---
  configure | 10 +-
  1 file changed, 9 insertions(+), 1 deletion(-)


Reviewed-by: Philippe Mathieu-Daudé 




Re: [PATCH] qemu-img: add support for rate limit in qemu-img convert

2020-10-19 Thread Alberto Garcia
On Sun 18 Oct 2020 08:34:39 AM CEST, Zhengui li wrote:
> @@ -2729,6 +2757,10 @@ out:
>  qemu_opts_del(opts);
>  qemu_opts_free(create_opts);
>  qemu_opts_del(sn_opts);
> +if (s.target && rate_limit &&
> +blk_get_public(s.target)->throttle_group_member.throttle_state) {
> +blk_io_limits_disable(s.target);
> +}
>  qobject_unref(open_opts);
>  blk_unref(s.target);
>  if (s.src) {

Apart from the comments that I wrote to the other patch, which also
apply to this one, blk_delete() already calls blk_io_limits_disable() so
I don't think you need to do it manually here.

Berto



Re: [PATCH v2 0/5] qapi: Restrict machine (and migration) specific commands

2020-10-19 Thread Eduardo Habkost
On Mon, Oct 19, 2020 at 09:55:20AM +0200, Markus Armbruster wrote:
> Eduardo Habkost  writes:
> 
> > On Mon, Oct 12, 2020 at 02:15:31PM +0200, Philippe Mathieu-Daudé wrote:
> >> Reduce the machine code pulled into qemu-storage-daemon.
> >> 
> >> The series is fully Acked, but Markus wants it reviewed
> >> by the Machine core maintainers.
> >
> > I've confirmed that all patches move QAPI schema code without
> > introducing any additional changes.
> >
> > Reviewed-by: Eduardo Habkost 
> 
> I take this as "I agree the things moved to machine.json belong there".
> Holler if I'm mistaken.

I agree machine.json is better than misc.json for them, yes.

I miss short descriptions of the purpose of each file, though.
It would help us decide what's appropriate in the future.

-- 
Eduardo




[PULL v3 1/6] 9pfs: suppress performance warnings on qtest runs

2020-10-19 Thread Christian Schoenebeck
Don't trigger any performance warning if we're just running test cases,
because tests intentionally run for edge cases.

So far performance warnings were suppressed for the 'synth' fs driver
backend only. This patch suppresses them for all 9p fs driver backends.

Signed-off-by: Christian Schoenebeck 
Reviewed-by: Greg Kurz 
Message-Id: 

Signed-off-by: Christian Schoenebeck 
---
 hw/9pfs/9p-synth.c | 2 --
 hw/9pfs/virtio-9p-device.c | 6 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index cec8c0eefc..7eb210ffa8 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -541,8 +541,6 @@ static int synth_init(FsContext *ctx, Error **errp)
 QLIST_INIT(_root.child);
 qemu_mutex_init(_mutex);
 
-ctx->export_flags |= V9FS_NO_PERF_WARN;
-
 /* Add "." and ".." entries for root */
 v9fs_add_dir_node(_root, synth_root.attr->mode,
   "..", synth_root.attr, synth_root.attr->inode);
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 36f3aa9352..14371a78ef 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -21,6 +21,7 @@
 #include "hw/virtio/virtio-access.h"
 #include "qemu/iov.h"
 #include "qemu/module.h"
+#include "sysemu/qtest.h"
 
 static void virtio_9p_push_and_notify(V9fsPDU *pdu)
 {
@@ -199,6 +200,11 @@ static void virtio_9p_device_realize(DeviceState *dev, 
Error **errp)
 VirtIODevice *vdev = VIRTIO_DEVICE(dev);
 V9fsVirtioState *v = VIRTIO_9P(dev);
 V9fsState *s = >state;
+FsDriverEntry *fse = get_fsdev_fsentry(s->fsconf.fsdev_id);
+
+if (qtest_enabled() && fse) {
+fse->export_flags |= V9FS_NO_PERF_WARN;
+}
 
 if (v9fs_device_realize_common(s, _9p_transport, errp)) {
 return;
-- 
2.20.1




[PULL v3 2/6] tests/9pfs: change qtest name prefix to synth

2020-10-19 Thread Christian Schoenebeck
All existing 9pfs test cases are using the 'synth' fs driver so far, which
means they are not accessing real files, but a purely simulated (in RAM
only) file system.

Let's make this clear by changing the prefix of the individual qtest case
names from 'fs/' to 'synth/'. That way they'll be easily distinguishable
from upcoming new 9pfs test cases supposed to be using a different fs
driver.

Signed-off-by: Christian Schoenebeck 
Message-Id: 

Signed-off-by: Christian Schoenebeck 
---
 tests/qtest/virtio-9p-test.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index de30b717b6..3281153b9c 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -897,26 +897,26 @@ static void fs_readdir_split_512(void *obj, void *data,
 
 static void register_virtio_9p_test(void)
 {
-qos_add_test("config", "virtio-9p", pci_config, NULL);
-qos_add_test("fs/version/basic", "virtio-9p", fs_version, NULL);
-qos_add_test("fs/attach/basic", "virtio-9p", fs_attach, NULL);
-qos_add_test("fs/walk/basic", "virtio-9p", fs_walk, NULL);
-qos_add_test("fs/walk/no_slash", "virtio-9p", fs_walk_no_slash,
+qos_add_test("synth/config", "virtio-9p", pci_config, NULL);
+qos_add_test("synth/version/basic", "virtio-9p", fs_version, NULL);
+qos_add_test("synth/attach/basic", "virtio-9p", fs_attach, NULL);
+qos_add_test("synth/walk/basic", "virtio-9p", fs_walk, NULL);
+qos_add_test("synth/walk/no_slash", "virtio-9p", fs_walk_no_slash,
  NULL);
-qos_add_test("fs/walk/dotdot_from_root", "virtio-9p",
+qos_add_test("synth/walk/dotdot_from_root", "virtio-9p",
  fs_walk_dotdot, NULL);
-qos_add_test("fs/lopen/basic", "virtio-9p", fs_lopen, NULL);
-qos_add_test("fs/write/basic", "virtio-9p", fs_write, NULL);
-qos_add_test("fs/flush/success", "virtio-9p", fs_flush_success,
+qos_add_test("synth/lopen/basic", "virtio-9p", fs_lopen, NULL);
+qos_add_test("synth/write/basic", "virtio-9p", fs_write, NULL);
+qos_add_test("synth/flush/success", "virtio-9p", fs_flush_success,
  NULL);
-qos_add_test("fs/flush/ignored", "virtio-9p", fs_flush_ignored,
+qos_add_test("synth/flush/ignored", "virtio-9p", fs_flush_ignored,
  NULL);
-qos_add_test("fs/readdir/basic", "virtio-9p", fs_readdir, NULL);
-qos_add_test("fs/readdir/split_512", "virtio-9p",
+qos_add_test("synth/readdir/basic", "virtio-9p", fs_readdir, NULL);
+qos_add_test("synth/readdir/split_512", "virtio-9p",
  fs_readdir_split_512, NULL);
-qos_add_test("fs/readdir/split_256", "virtio-9p",
+qos_add_test("synth/readdir/split_256", "virtio-9p",
  fs_readdir_split_256, NULL);
-qos_add_test("fs/readdir/split_128", "virtio-9p",
+qos_add_test("synth/readdir/split_128", "virtio-9p",
  fs_readdir_split_128, NULL);
 }
 
-- 
2.20.1




Re: [PATCH v3 12/13] block/qcow2: simplify qcow2_co_invalidate_cache()

2020-10-19 Thread Kevin Wolf
Am 16.10.2020 um 19:10 hat Vladimir Sementsov-Ogievskiy geschrieben:
> qcow2_do_open correctly sets errp on each failure path. So, we can
> simplify code in qcow2_co_invalidate_cache() and drop explicit error
> propagation.

qcow2_update_options_prepare() can return -EINVAL without setting errp:

if (s->crypt_method_header != QCOW_CRYPT_NONE && !r->crypto_opts) {
ret = -EINVAL;
goto fail;
}

This is called indirectly from qcow2_do_open().

Kevin




[PULL v3 5/6] tests/9pfs: add virtio_9p_test_path()

2020-10-19 Thread Christian Schoenebeck
This new public function virtio_9p_test_path() allows 9pfs
'local' tests to translate a path from guest scope to host
scope. For instance by passing an empty string it would
return the root path on host of the exported 9pfs tree.

Signed-off-by: Christian Schoenebeck 
Message-Id: 

Signed-off-by: Christian Schoenebeck 
---
 tests/qtest/libqos/virtio-9p.c | 6 ++
 tests/qtest/libqos/virtio-9p.h | 5 +
 2 files changed, 11 insertions(+)

diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index 8ee2a134bc..d43647b3b7 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -65,6 +65,12 @@ static void remove_local_test_dir(void)
 g_free(cmd);
 }
 
+char *virtio_9p_test_path(const char *path)
+{
+g_assert(local_test_path);
+return concat_path(local_test_path, path);
+}
+
 static void virtio_9p_cleanup(QVirtio9P *interface)
 {
 qvirtqueue_cleanup(interface->vdev->bus, interface->vq, alloc);
diff --git a/tests/qtest/libqos/virtio-9p.h b/tests/qtest/libqos/virtio-9p.h
index 326a603f72..19a4d97454 100644
--- a/tests/qtest/libqos/virtio-9p.h
+++ b/tests/qtest/libqos/virtio-9p.h
@@ -49,4 +49,9 @@ struct QVirtio9PDevice {
  */
 void virtio_9p_assign_local_driver(GString *cmd_line, const char *args);
 
+/**
+ * Returns path on host to the passed guest path. Result must be freed.
+ */
+char *virtio_9p_test_path(const char *path);
+
 #endif
-- 
2.20.1




[PULL v3 4/6] tests/9pfs: wipe local 9pfs test directory

2020-10-19 Thread Christian Schoenebeck
Before running the first 9pfs test case, make sure the test directory
for running the 9pfs 'local' tests on is entirely empty. For that
reason simply delete the test directory (if any) before (re)creating
it on test suite startup.

Note: The preferable precise behaviour would be the test directory
only being wiped once *before* a test suite run. Right now the test
directory is also wiped at the *end* of a test suite run because
libqos is calling the virtio_9p_register_nodes() callback for some
reason also when a test suite completed. This is suboptimal as
developers cannot immediately see what files and directories the
9pfs local tests created precisely after the test suite completed.
But fortunately the test directory is not wiped if some test failed.
So it is probably not worth it drilling another hole into libqos
for this issue.

Signed-off-by: Christian Schoenebeck 
Message-Id: 

Signed-off-by: Christian Schoenebeck 
---
 tests/qtest/libqos/virtio-9p.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index ee331166de..8ee2a134bc 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -53,6 +53,18 @@ static void create_local_test_dir(void)
 g_assert((st.st_mode & S_IFMT) == S_IFDIR);
 }
 
+/* Deletes directory previously created by create_local_test_dir(). */
+static void remove_local_test_dir(void)
+{
+g_assert(local_test_path != NULL);
+char *cmd = g_strdup_printf("rm -r '%s'\n", local_test_path);
+int res = system(cmd);
+if (res < 0) {
+/* ignore error, dummy check to prevent compiler error */
+}
+g_free(cmd);
+}
+
 static void virtio_9p_cleanup(QVirtio9P *interface)
 {
 qvirtqueue_cleanup(interface->vdev->bus, interface->vq, alloc);
@@ -230,6 +242,7 @@ static void virtio_9p_register_nodes(void)
 
 /* make sure test dir for the 'local' tests exists and is clean */
 init_local_test_path();
+remove_local_test_dir();
 create_local_test_dir();
 
 QPCIAddress addr = {
-- 
2.20.1




Re: [PULL 09/14] qmp: Move dispatcher to a coroutine

2020-10-19 Thread Kevin Wolf
Am 17.10.2020 um 10:15 hat Volker Rümelin geschrieben:
> > From: Kevin Wolf 
> >
> > This moves the QMP dispatcher to a coroutine and runs all QMP command
> > handlers that declare 'coroutine': true in coroutine context so they
> > can avoid blocking the main loop while doing I/O or waiting for other
> > events.
> >
> > For commands that are not declared safe to run in a coroutine, the
> > dispatcher drops out of coroutine context by calling the QMP command
> > handler from a bottom half.
> 
> Hi Kevin,
> 
> since commit 9ce44e2ce2 "qmp: Move dispatcher to a coroutine" I see
> the following error on Windows whenever I close the QEMU window or
> shut down the guest.
> 
> $ ./qemu-system-x86_64.exe -machine pc,accel=tcg -display gtk
> **
> ERROR:../qemu/util/aio-win32.c:337:aio_poll: assertion failed: 
> (in_aio_context_home_thread(ctx))
> Bail out! ERROR:../qemu/util/aio-win32.c:337:aio_poll: assertion failed: 
> (in_aio_context_home_thread(ctx))
> 
> I wonder if you forgot to apply the changes to util/aio-posix.c to
> util/aio-win32.c too? This solves the problem on my Windows host. But
> I have to admit I don't know the code here.

Hi Volker,

yes, you're right. The assertion in the Windows code was added only in
commit 5710a3e09f9 after I had posted some versions of the patch series,
so while I did check this initially, I missed during the rebase for
later versions of the series that I would have to update the patches for
Windows.

Would you like to send a patch for this? I could send one myself if you
prefer, but I can only compile-test Windows patches, so I'd have to rely
on your testing anyway.

Kevin

> > diff --git a/util/aio-posix.c b/util/aio-posix.c
> > index 280f27bb99..30f5354b1e 100644
> > --- a/util/aio-posix.c
> > +++ b/util/aio-posix.c
> > @@ -15,6 +15,7 @@
> >  
> >  #include "qemu/osdep.h"
> >  #include "block/block.h"
> > +#include "qemu/main-loop.h"
> >  #include "qemu/rcu.h"
> >  #include "qemu/rcu_queue.h"
> >  #include "qemu/sockets.h"
> > @@ -558,8 +559,13 @@ bool aio_poll(AioContext *ctx, bool blocking)
> >   * There cannot be two concurrent aio_poll calls for the same 
> > AioContext (or
> >   * an aio_poll concurrent with a GSource prepare/check/dispatch 
> > callback).
> >   * We rely on this below to avoid slow locked accesses to 
> > ctx->notify_me.
> > + *
> > + * aio_poll() may only be called in the AioContext's thread. 
> > iohandler_ctx
> > + * is special in that it runs in the main thread, but that thread's 
> > context
> > + * is qemu_aio_context.
> >   */
> > -assert(in_aio_context_home_thread(ctx));
> > +assert(in_aio_context_home_thread(ctx == iohandler_get_aio_context() ?
> > +  qemu_get_aio_context() : ctx));
> >  
> >  qemu_lockcnt_inc(>list_lock);
> >  
> 




Re: [PATCH] docs/system: Deprecate raspi2/raspi3 machine aliases

2020-10-19 Thread Peter Krempa
On Mon, Oct 19, 2020 at 10:21:21 +0200, Philippe Mathieu-Daudé wrote:
> Since commit aa35ec2213b ("hw/arm/raspi: Use more
> specific machine names") the raspi2/raspi3 machines
> have been renamed as raspi2b/raspi3b.
> 
> As more Raspberry Pi 2/3 models are emulated, in order
> to avoid confusion deprecate the raspi2/raspi3 machine
> aliases.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  docs/system/deprecated.rst | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
> index 905628f3a0c..f0c7aaeb2ff 100644
> --- a/docs/system/deprecated.rst
> +++ b/docs/system/deprecated.rst
> @@ -355,6 +355,11 @@ This machine has been renamed ``fuloong2e``.
>  These machine types are very old and likely can not be used for live 
> migration
>  from old QEMU versions anymore. A newer machine type should be used instead.
>  
> +Raspberry Pi ``raspi2`` and ``raspi3`` machines (since 5.2)
> +'
> +
> +These machines have been respectively renamed ``raspi2b`` and ``raspi3b``.
> +

libvirt doesn't do any interpretation for these machine types, so we
don't need to add any compatibility. Obviously users of these machine
types might end up with broken configs if they were using them, but
that's qemu's decision.

On behalf of libvirt:

ACKed-by: Peter Krempa 




Re: [PATCH v4 4/7] keyval: Parse help options

2020-10-19 Thread Markus Armbruster
Eric Blake  writes:

> On 10/11/20 2:35 AM, Markus Armbruster wrote:
>> From: Kevin Wolf 
>> This adds a special meaning for 'help' and '?' as options to the
>> keyval
>> parser. Instead of being an error (because of a missing value) or a
>> value for an implied key, they now request help, which is a new boolean
>> output of the parser in addition to the QDict.
>> A new parameter 'p_help' is added to keyval_parse() that contains on
>> return whether help was requested. If NULL is passed, requesting help
>> results in an error and all other cases work like before.
>> 
>
>> +
>> +/* "help" by itself, without implied key */
>> +qdict = keyval_parse("help", NULL, , _abort);
>> +g_assert_cmpuint(qdict_size(qdict), ==, 0);
>> +g_assert(help);
>> +qobject_unref(qdict);
>> +
>> +/* "help" by itself, with implied key */
>> +qdict = keyval_parse("help", "implied", , _abort);
>> +g_assert_cmpuint(qdict_size(qdict), ==, 0);
>> +g_assert(help);
>> +qobject_unref(qdict);
>> +
>> +/* "help" when no help is available, without implied key */
>> +qdict = keyval_parse("help", NULL, NULL, );
>> +error_free_or_abort();
>> +g_assert(!qdict);
>> +
>> +/* "help" when no help is available, with implied key */
>> +qdict = keyval_parse("help", "implied", NULL, );
>> +error_free_or_abort();
>> +g_assert(!qdict);
>> +
>> +/* Key "help" */
>> +qdict = keyval_parse("help=on", NULL, , _abort);
>> +g_assert_cmpuint(qdict_size(qdict), ==, 1);
>> +g_assert_cmpstr(qdict_get_try_str(qdict, "help"), ==, "on");
>> +g_assert(!help);
>> +qobject_unref(qdict);
>> +
>> +/* "help" followed by crap, without implied key */
>> +qdict = keyval_parse("help.abc", NULL, , );
>> +error_free_or_abort();
>> +g_assert(!qdict);
>> +
>> +/* "help" followed by crap, with implied key */
>> +qdict = keyval_parse("help.abc", "implied", , );
>> +g_assert_cmpuint(qdict_size(qdict), ==, 1);
>> +g_assert_cmpstr(qdict_get_try_str(qdict, "implied"), ==, "help.abc");
>> +g_assert(!help);
>> +qobject_unref(qdict);
>> +
>> +/* "help" with other stuff, without implied key */
>> +qdict = keyval_parse("number=42,help,foo=bar", NULL, , 
>> _abort);
>> +g_assert_cmpuint(qdict_size(qdict), ==, 2);
>> +g_assert_cmpstr(qdict_get_try_str(qdict, "number"), ==, "42");
>> +g_assert_cmpstr(qdict_get_try_str(qdict, "foo"), ==, "bar");
>> +g_assert(help);
>> +qobject_unref(qdict);
>> +
>> +/* "help" with other stuff, with implied key */
>> +qdict = keyval_parse("val,help,foo=bar", "implied", , 
>> _abort);
>> +g_assert_cmpuint(qdict_size(qdict), ==, 2);
>> +g_assert_cmpstr(qdict_get_try_str(qdict, "implied"), ==, "val");
>> +g_assert_cmpstr(qdict_get_try_str(qdict, "foo"), ==, "bar");
>> +g_assert(help);
>> +qobject_unref(qdict);
>
> Is it worth checking that "helper" with implied key is a value, not help?

Case /* "help" followed by crap, with implied key */ covers this,
doesn't it?

>> +++ b/util/keyval.c
>> @@ -14,10 +14,11 @@
>>* KEY=VALUE,... syntax:
>>*
>>*   key-vals = [ key-val { ',' key-val } [ ',' ] ]
>> - *   key-val  = key '=' val
>> + *   key-val  = key '=' val | help
>>*   key  = key-fragment { '.' key-fragment }
>>*   key-fragment = / [^=,.]+ /
>>*   val  = { / [^,]+ / | ',,' }
>> + *   help = 'help | '?'
>
> Missing '

Kevin fixed it up.

> Otherwise
> Reviewed-by: Eric Blake 

Thanks!




Re: [Virtio-fs] [PATCH v3] virtiofsd: add container-friendly -o sandbox=chroot option

2020-10-19 Thread Chirantan Ekbote
On Thu, Oct 8, 2020 at 5:55 PM Stefan Hajnoczi  wrote:
>
> virtiofsd cannot run in a container because CAP_SYS_ADMIN is required to
> create namespaces.
>

In crosvm we deal with this by also creating a user namespace, which
then allows us to create the mount, net, and pid namespaces as well.
Could that also work for virtiofsd?



Re: [PATCH v4 0/3] unbreak non-tcg builds

2020-10-19 Thread Claudio Fontana
Hi all,

anything more for me to do here?

On 10/13/20 9:21 PM, Claudio Fontana wrote:
> This series now unbreaks current non-tcg builds
> (!CONFIG_TCG).
> 
> tests Makefiles need to avoid relying on all non-native
> archs binaries to be present,
> 
> bios-tables-test needs to skip tests that are tcg-only,
> 
> and notably the replay framework needs to consider that
> it might not be functional (or its code present at all)
> without TCG.
> 
> Tested ok target x86_64-softmmu on x86_64 host with:
> 
> ./configure --enable-tcg --disable-kvm
> ./configure --enable-kvm --disable-tcg
> ./configure --enable-tcg --enable-kvm
> 
> running make check-qtest
> 
> v3 => v4:
> * abandon attempts to avoid the code duplication and functional code
> in stubs, just providing the minimal changes to get things working.

Paolo, is the latest respin ok for you?

Thanks,

Claudio

> 
> v2 => v3:
> 
> * do not alter the replay api, provide a block wrapper
> instead to call into replay events handling
> or the normal call flow depending on whether replay events are enabled.
> 
> v1: initial RFC
> 
> Claudio Fontana (2):
>   qtest: unbreak non-TCG builds in bios-tables-test
>   replay: do not build if TCG is not available
> 
> Paolo Bonzini (1):
>   tests/Makefile.include: unbreak non-tcg builds
> 
>  block/meson.build  |  3 +-
>  migration/savevm.c | 11 ++--
>  net/meson.build|  3 +-
>  replay/meson.build |  2 +-
>  replay/replay-input.c  |  4 +-
>  stubs/meson.build  |  1 -
>  stubs/replay-user.c|  9 
>  stubs/replay.c | 98 ++
>  tests/Makefile.include |  2 +-
>  tests/ptimer-test-stubs.c  |  5 --
>  tests/qtest/bios-tables-test.c | 10 
>  tests/qtest/qmp-cmd-test.c |  3 ++
>  ui/input.c | 12 -
>  13 files changed, 136 insertions(+), 27 deletions(-)
>  delete mode 100644 stubs/replay-user.c
> 




Re: [PULL v2 0/5] 9p queue (previous 2020-10-15)

2020-10-19 Thread Christian Schoenebeck
On Montag, 19. Oktober 2020 11:52:38 CEST Peter Maydell wrote:
> On Sat, 17 Oct 2020 at 15:23, Christian Schoenebeck
> 
>  wrote:
> > The following changes since commit 
e12ce85b2c79d83a340953291912875c30b3af06:
> >   Merge remote-tracking branch
> >   'remotes/ehabkost/tags/x86-next-pull-request' into staging (2020-10-16
> >   22:46:28 +0100)> 
> > are available in the Git repository at:
> >   https://github.com/cschoenebeck/qemu.git tags/pull-9p-20201017
> > 
> > for you to fetch changes up to fa4551e3f4416cc8c62086ac430b1ceb4f03eb6b:
> >   tests/9pfs: add local Tmkdir test (2020-10-17 15:58:39 +0200)
> > 
> > 
> > 9pfs: add tests using local fs driver
> > 
> > The currently existing 9pfs test cases are all solely using the 9pfs
> > 'synth' fileystem driver, which is a very simple and purely simulated (in
> > RAM only) filesystem. There are issues though where the 'synth' fs driver
> > is not sufficient. For example the following two bugs need test cases
> > running the 9pfs 'local' fs driver:
> > 
> > https://bugs.launchpad.net/qemu/+bug/1336794
> > https://bugs.launchpad.net/qemu/+bug/1877384
> > 
> > This patch set for that reason introduces 9pfs test cases using the 9pfs
> > 'local' filesystem driver along to the already existing tests on 'synth'.
> 
> This emits a lot of new warnings during 'make check':
> 
> PASS 27 qtest-arm: qos-test
> /arm/virt/virtio-mmio/virtio-bus/virtio-9p-device/virtio-9p/virtio-9p-tests/
> local/config qemu-system-arm: warning: 9p: degraded performance: a
> reasonable high msize should be chosen on client/guest side (chosen msize
> is <= 8192). See https://wiki.qemu.org/Documentation/9psetup#msize for
> details. PASS 28 qtest-arm: qos-test
> /arm/virt/virtio-mmio/virtio-bus/virtio-9p-device/virtio-9p/virtio-9p-tests/
> local/create_dir
> 
> PASS 54 qtest-i386: qos-test
> /i386/pc/i440FX-pcihost/pci-bus-pc/pci-bus/virtio-9p-pci/virtio-9p/virtio-9p
> -tests/local/config qemu-system-i386: warning: 9p: degraded performance: a
> reasonable high msize should be chosen on client/guest side (chosen msize
> is <= 8192). See https://wiki.qemu.org/Documentation/9psetup#msize for
> details. PASS 55 qtest-i386: qos-test
> /i386/pc/i440FX-pcihost/pci-bus-pc/pci-bus/virtio-9p-pci/virtio-9p/virtio-9p
> -tests/local/create_dir
> 
> etc.
> 
> thanks
> -- PMM

One warning per test suite run (i.e. per architecture due to 
warn_report_once()), yes. That performance warning is meant for end user 
installations to remind them setting some (reasonable high) value for 9p 
client parameter 'msize' on guest OS side. The warning triggers here because 
the 9p test cases intentionally run with a small 'msize' to guard edge cases.

Would it be Ok for you to merge it with this performance warning for now? I 
can take care of silencing it before 5.2 release. It probably requires to 
introduce a new CL option to suppress performance warnings like these, or by 
finding a way to detect that we're currently just running qtests.

Best regards,
Christian Schoenebeck





Re: [PATCH v4 4/4] Jobs based on custom runners: add job definitions for QEMU's machines

2020-10-19 Thread Daniel P . Berrangé
On Sun, Oct 18, 2020 at 09:50:03PM -0400, Cleber Rosa wrote:
> The QEMU project has two machines (aarch64 and s390) that can be used
> for jobs that do build and run tests.  This introduces those jobs,
> which are a mapping of custom scripts used for the same purpose.
> 
> Signed-off-by: Cleber Rosa 
> ---
>  .gitlab-ci.d/custom-runners.yml | 192 
>  1 file changed, 192 insertions(+)

Reviewed-by: Daniel P. Berrangé 


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 :|




[PATCH v2 1/5] memory: Rename memory_region_notify_one to memory_region_notify_iommu_one

2020-10-19 Thread Eugenio Pérez
Previous name didn't reflect the iommu operation.

Signed-off-by: Eugenio Pérez 
Reviewed-by: Peter Xu 
Reviewed-by: David Gibson 
Reviewed-by: Juan Quintela 
Reviewed-by: Eric Auger 
---
 include/exec/memory.h | 6 +++---
 hw/arm/smmu-common.c  | 2 +-
 hw/arm/smmuv3.c   | 2 +-
 hw/i386/intel_iommu.c | 4 ++--
 softmmu/memory.c  | 6 +++---
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 622207bde1..ac6bca1ba0 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -221,7 +221,7 @@ enum IOMMUMemoryRegionAttr {
  * The IOMMU implementation must use the IOMMU notifier infrastructure
  * to report whenever mappings are changed, by calling
  * memory_region_notify_iommu() (or, if necessary, by calling
- * memory_region_notify_one() for each registered notifier).
+ * memory_region_notify_iommu_one() for each registered notifier).
  *
  * Conceptually an IOMMU provides a mapping from input address
  * to an output TLB entry. If the IOMMU is aware of memory transaction
@@ -1300,7 +1300,7 @@ void memory_region_notify_iommu(IOMMUMemoryRegion 
*iommu_mr,
 IOMMUTLBEntry entry);
 
 /**
- * memory_region_notify_one: notify a change in an IOMMU translation
+ * memory_region_notify_iommu_one: notify a change in an IOMMU translation
  *   entry to a single notifier
  *
  * This works just like memory_region_notify_iommu(), but it only
@@ -1311,7 +1311,7 @@ void memory_region_notify_iommu(IOMMUMemoryRegion 
*iommu_mr,
  * replaces all old entries for the same virtual I/O address range.
  * Deleted entries have .@perm == 0.
  */
-void memory_region_notify_one(IOMMUNotifier *notifier,
+void memory_region_notify_iommu_one(IOMMUNotifier *notifier,
   IOMMUTLBEntry *entry);
 
 /**
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index 3838db1395..88d2c454f0 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -472,7 +472,7 @@ static void smmu_unmap_notifier_range(IOMMUNotifier *n)
 entry.perm = IOMMU_NONE;
 entry.addr_mask = n->end - n->start;
 
-memory_region_notify_one(n, );
+memory_region_notify_iommu_one(n, );
 }
 
 /* Unmap all notifiers attached to @mr */
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index 0122700e72..0a893ae918 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -827,7 +827,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
 entry.addr_mask = num_pages * (1 << granule) - 1;
 entry.perm = IOMMU_NONE;
 
-memory_region_notify_one(n, );
+memory_region_notify_iommu_one(n, );
 }
 
 /* invalidate an asid/iova range tuple in all mr's */
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 749eb6ad63..56bab589d4 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3497,7 +3497,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, 
IOMMUNotifier *n)
 /* This field is meaningless for unmap */
 entry.translated_addr = 0;
 
-memory_region_notify_one(n, );
+memory_region_notify_iommu_one(n, );
 
 start += mask;
 remain -= mask;
@@ -3535,7 +3535,7 @@ static void vtd_address_space_refresh_all(IntelIOMMUState 
*s)
 
 static int vtd_replay_hook(IOMMUTLBEntry *entry, void *private)
 {
-memory_region_notify_one((IOMMUNotifier *)private, entry);
+memory_region_notify_iommu_one((IOMMUNotifier *)private, entry);
 return 0;
 }
 
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 403ff3abc9..f37a4569ac 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1905,8 +1905,8 @@ void memory_region_unregister_iommu_notifier(MemoryRegion 
*mr,
 memory_region_update_iommu_notify_flags(iommu_mr, NULL);
 }
 
-void memory_region_notify_one(IOMMUNotifier *notifier,
-  IOMMUTLBEntry *entry)
+void memory_region_notify_iommu_one(IOMMUNotifier *notifier,
+IOMMUTLBEntry *entry)
 {
 IOMMUNotifierFlag request_flags;
 hwaddr entry_end = entry->iova + entry->addr_mask;
@@ -1942,7 +1942,7 @@ void memory_region_notify_iommu(IOMMUMemoryRegion 
*iommu_mr,
 
 IOMMU_NOTIFIER_FOREACH(iommu_notifier, iommu_mr) {
 if (iommu_notifier->iommu_idx == iommu_idx) {
-memory_region_notify_one(iommu_notifier, );
+memory_region_notify_iommu_one(iommu_notifier, );
 }
 }
 }
-- 
2.18.1




[PATCH v2 1/5] memory: Rename memory_region_notify_one to memory_region_notify_iommu_one

2020-10-19 Thread Eugenio Pérez
Previous name didn't reflect the iommu operation.

Signed-off-by: Eugenio Pérez 
Reviewed-by: Peter Xu 
Reviewed-by: David Gibson 
Reviewed-by: Juan Quintela 
Reviewed-by: Eric Auger 
---
 include/exec/memory.h | 6 +++---
 hw/arm/smmu-common.c  | 2 +-
 hw/arm/smmuv3.c   | 2 +-
 hw/i386/intel_iommu.c | 4 ++--
 softmmu/memory.c  | 6 +++---
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 622207bde1..ac6bca1ba0 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -221,7 +221,7 @@ enum IOMMUMemoryRegionAttr {
  * The IOMMU implementation must use the IOMMU notifier infrastructure
  * to report whenever mappings are changed, by calling
  * memory_region_notify_iommu() (or, if necessary, by calling
- * memory_region_notify_one() for each registered notifier).
+ * memory_region_notify_iommu_one() for each registered notifier).
  *
  * Conceptually an IOMMU provides a mapping from input address
  * to an output TLB entry. If the IOMMU is aware of memory transaction
@@ -1300,7 +1300,7 @@ void memory_region_notify_iommu(IOMMUMemoryRegion 
*iommu_mr,
 IOMMUTLBEntry entry);
 
 /**
- * memory_region_notify_one: notify a change in an IOMMU translation
+ * memory_region_notify_iommu_one: notify a change in an IOMMU translation
  *   entry to a single notifier
  *
  * This works just like memory_region_notify_iommu(), but it only
@@ -1311,7 +1311,7 @@ void memory_region_notify_iommu(IOMMUMemoryRegion 
*iommu_mr,
  * replaces all old entries for the same virtual I/O address range.
  * Deleted entries have .@perm == 0.
  */
-void memory_region_notify_one(IOMMUNotifier *notifier,
+void memory_region_notify_iommu_one(IOMMUNotifier *notifier,
   IOMMUTLBEntry *entry);
 
 /**
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index 3838db1395..88d2c454f0 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -472,7 +472,7 @@ static void smmu_unmap_notifier_range(IOMMUNotifier *n)
 entry.perm = IOMMU_NONE;
 entry.addr_mask = n->end - n->start;
 
-memory_region_notify_one(n, );
+memory_region_notify_iommu_one(n, );
 }
 
 /* Unmap all notifiers attached to @mr */
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index 0122700e72..0a893ae918 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -827,7 +827,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
 entry.addr_mask = num_pages * (1 << granule) - 1;
 entry.perm = IOMMU_NONE;
 
-memory_region_notify_one(n, );
+memory_region_notify_iommu_one(n, );
 }
 
 /* invalidate an asid/iova range tuple in all mr's */
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 749eb6ad63..56bab589d4 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3497,7 +3497,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, 
IOMMUNotifier *n)
 /* This field is meaningless for unmap */
 entry.translated_addr = 0;
 
-memory_region_notify_one(n, );
+memory_region_notify_iommu_one(n, );
 
 start += mask;
 remain -= mask;
@@ -3535,7 +3535,7 @@ static void vtd_address_space_refresh_all(IntelIOMMUState 
*s)
 
 static int vtd_replay_hook(IOMMUTLBEntry *entry, void *private)
 {
-memory_region_notify_one((IOMMUNotifier *)private, entry);
+memory_region_notify_iommu_one((IOMMUNotifier *)private, entry);
 return 0;
 }
 
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 403ff3abc9..f37a4569ac 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1905,8 +1905,8 @@ void memory_region_unregister_iommu_notifier(MemoryRegion 
*mr,
 memory_region_update_iommu_notify_flags(iommu_mr, NULL);
 }
 
-void memory_region_notify_one(IOMMUNotifier *notifier,
-  IOMMUTLBEntry *entry)
+void memory_region_notify_iommu_one(IOMMUNotifier *notifier,
+IOMMUTLBEntry *entry)
 {
 IOMMUNotifierFlag request_flags;
 hwaddr entry_end = entry->iova + entry->addr_mask;
@@ -1942,7 +1942,7 @@ void memory_region_notify_iommu(IOMMUMemoryRegion 
*iommu_mr,
 
 IOMMU_NOTIFIER_FOREACH(iommu_notifier, iommu_mr) {
 if (iommu_notifier->iommu_idx == iommu_idx) {
-memory_region_notify_one(iommu_notifier, );
+memory_region_notify_iommu_one(iommu_notifier, );
 }
 }
 }
-- 
2.18.1




Re: [PATCH 3/30] crypt: Fix Lesser GPL version number

2020-10-19 Thread Daniel P . Berrangé
On Wed, Oct 14, 2020 at 01:42:48PM +, Chetan Pant wrote:
> There is no "version 2" of the "Lesser" General Public License.
> It is either "GPL version 2.0" or "Lesser GPL version 2.1".
> This patch replaces all occurrences of "Lesser GPL version 2" with
> "Lesser GPL version 2.1" in comment section.
> 
> Signed-off-by: Chetan Pant 
> ---
>  tests/test-crypto-afsplit.c | 2 +-
>  tests/test-crypto-block.c   | 2 +-
>  tests/test-crypto-cipher.c  | 2 +-
>  tests/test-crypto-hash.c| 2 +-
>  tests/test-crypto-ivgen.c   | 2 +-
>  tests/test-crypto-secret.c  | 2 +-
>  tests/test-crypto-xts.c | 2 +-
>  7 files changed, 7 insertions(+), 7 deletions(-)

Acked-by: Daniel P. Berrangé 


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: [PATCH v2 5/8] qemu/bswap: Use compiler __builtin_bswap() on Haiku

2020-10-19 Thread Philippe Mathieu-Daudé

On 9/28/20 4:18 PM, Philippe Mathieu-Daudé wrote:

On 9/28/20 4:13 PM, Daniel P. Berrangé wrote:

On Mon, Sep 28, 2020 at 03:09:01PM +0100, David CARLIER wrote:

Unfortunately it breaks the build.


Can you provide details of the errors seen and toolchain versions.

I notice we don't have any CI support for Haiku right now, nor
any recipe in tests/vm/  for enabling users to setup a VM with
Haiku installed. This very much makes Haiku a second class
citizen right now in terms of QEMU's supported platforms, with
no expectation of whether it'll work at any point in time.


I provided the tests/vm/ build script from Alexander as patch 8/8
of this series:
https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg10022.html

This is what I used to test this patch/series.


I suppose the Haiku VM patch got lost, so I'll repost it separate.

Which tree should I Cc:? Ah, Alex testing tree :)



[Bug 1891748] Re: qemu-arm-static 5.1 can't run gcc

2020-10-19 Thread Mehmet Aydoğdu
** Also affects: charms
   Importance: Undecided
   Status: New

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

Title:
  qemu-arm-static 5.1 can't run gcc

Status in QEMU:
  Fix Committed
Status in Juju Charms Collection:
  New

Bug description:
  Issue discovered while trying to build pikvm (1)

  Long story short: when using qemu-arm-static 5.1, gcc exits whith
  message:

  Allocating guest commpage: Operation not permitted

  
  when using qemu-arm-static v5.0, gcc "works"

  Steps to reproduce will follow

  (1)  https://github.com/pikvm/pikvm/blob/master/pages/building_os.md

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



Re: [PATCH v2 2/9] configure: cross-compiling without cross_prefix

2020-10-19 Thread BALATON Zoltan via

On Mon, 19 Oct 2020, Thomas Huth wrote:

On 19/10/2020 10.07, Thomas Huth wrote:

On 19/10/2020 03.39, Joelle van Dyne wrote:

From: osy 

The iOS toolchain does not use the host prefix naming convention. We add a
new option `--enable-cross-compile` that forces cross-compile even without
a cross_prefix.

Signed-off-by: Joelle van Dyne 
---
 configure | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 3c63879750..46d5db63e8 100755
--- a/configure
+++ b/configure
@@ -234,6 +234,7 @@ cpu=""
 iasl="iasl"
 interp_prefix="/usr/gnemul/qemu-%M"
 static="no"
+cross_compile="no"
 cross_prefix=""
 audio_drv_list=""
 block_drv_rw_whitelist=""
@@ -456,6 +457,11 @@ for opt do
   optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
   case "$opt" in
   --cross-prefix=*) cross_prefix="$optarg"
+cross_compile="yes"
+  ;;
+  --enable-cross-compile) cross_compile="yes"
+  ;;
+  --disable-cross-compile) cross_compile="no"


Can't you simply use --cros-prefix="" instead?


I mean, still introduce the "cross_compile=yes" variable, just omit the new
options.


That seems less intuitive for people trying to find this option. If --help 
lists --enable-cross-compile I can guess what that means but there's no 
way I could guess --cros-prefix="" unless I've been told or searched and 
stumbled upon it. So unless it's a big problem I like the explicit options 
better. Or is that a convention in other projects to use empty prefix to 
enable cross compile that I don't know about?


Regards,
BALATON Zoltan



[PATCH 1/1] 9pfs: suppress performance warnings on qtest runs

2020-10-19 Thread Christian Schoenebeck
Don't trigger any performance warning if we're just running test cases,
because tests intentionally run for edge cases.

So far performance warnings were suppressed for the 'synth' fs driver
backend only. This patch suppresses them for all 9p fs driver backends.

Signed-off-by: Christian Schoenebeck 
---
 hw/9pfs/9p-synth.c | 2 --
 hw/9pfs/virtio-9p-device.c | 6 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index cec8c0eefc..7eb210ffa8 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -541,8 +541,6 @@ static int synth_init(FsContext *ctx, Error **errp)
 QLIST_INIT(_root.child);
 qemu_mutex_init(_mutex);
 
-ctx->export_flags |= V9FS_NO_PERF_WARN;
-
 /* Add "." and ".." entries for root */
 v9fs_add_dir_node(_root, synth_root.attr->mode,
   "..", synth_root.attr, synth_root.attr->inode);
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 36f3aa9352..14371a78ef 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -21,6 +21,7 @@
 #include "hw/virtio/virtio-access.h"
 #include "qemu/iov.h"
 #include "qemu/module.h"
+#include "sysemu/qtest.h"
 
 static void virtio_9p_push_and_notify(V9fsPDU *pdu)
 {
@@ -199,6 +200,11 @@ static void virtio_9p_device_realize(DeviceState *dev, 
Error **errp)
 VirtIODevice *vdev = VIRTIO_DEVICE(dev);
 V9fsVirtioState *v = VIRTIO_9P(dev);
 V9fsState *s = >state;
+FsDriverEntry *fse = get_fsdev_fsentry(s->fsconf.fsdev_id);
+
+if (qtest_enabled() && fse) {
+fse->export_flags |= V9FS_NO_PERF_WARN;
+}
 
 if (v9fs_device_realize_common(s, _9p_transport, errp)) {
 return;
-- 
2.20.1




Re: [PATCH 1/1] 9pfs: suppress performance warnings on qtest runs

2020-10-19 Thread Greg Kurz
On Mon, 19 Oct 2020 13:10:18 +0200
Christian Schoenebeck  wrote:

> Don't trigger any performance warning if we're just running test cases,
> because tests intentionally run for edge cases.
> 
> So far performance warnings were suppressed for the 'synth' fs driver
> backend only. This patch suppresses them for all 9p fs driver backends.
> 
> Signed-off-by: Christian Schoenebeck 
> ---

LGTM

Reviewed-by: Greg Kurz 

>  hw/9pfs/9p-synth.c | 2 --
>  hw/9pfs/virtio-9p-device.c | 6 ++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
> index cec8c0eefc..7eb210ffa8 100644
> --- a/hw/9pfs/9p-synth.c
> +++ b/hw/9pfs/9p-synth.c
> @@ -541,8 +541,6 @@ static int synth_init(FsContext *ctx, Error **errp)
>  QLIST_INIT(_root.child);
>  qemu_mutex_init(_mutex);
>  
> -ctx->export_flags |= V9FS_NO_PERF_WARN;
> -
>  /* Add "." and ".." entries for root */
>  v9fs_add_dir_node(_root, synth_root.attr->mode,
>"..", synth_root.attr, synth_root.attr->inode);
> diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
> index 36f3aa9352..14371a78ef 100644
> --- a/hw/9pfs/virtio-9p-device.c
> +++ b/hw/9pfs/virtio-9p-device.c
> @@ -21,6 +21,7 @@
>  #include "hw/virtio/virtio-access.h"
>  #include "qemu/iov.h"
>  #include "qemu/module.h"
> +#include "sysemu/qtest.h"
>  
>  static void virtio_9p_push_and_notify(V9fsPDU *pdu)
>  {
> @@ -199,6 +200,11 @@ static void virtio_9p_device_realize(DeviceState *dev, 
> Error **errp)
>  VirtIODevice *vdev = VIRTIO_DEVICE(dev);
>  V9fsVirtioState *v = VIRTIO_9P(dev);
>  V9fsState *s = >state;
> +FsDriverEntry *fse = get_fsdev_fsentry(s->fsconf.fsdev_id);
> +
> +if (qtest_enabled() && fse) {
> +fse->export_flags |= V9FS_NO_PERF_WARN;
> +}
>  
>  if (v9fs_device_realize_common(s, _9p_transport, errp)) {
>  return;




Re: [PATCH] do not use colons in test names

2020-10-19 Thread Philippe Mathieu-Daudé

On 10/19/20 1:41 PM, Paolo Bonzini wrote:

Starting with meson 0.56, colons are used to separate the subproject name
from the test name.  Use dash or slash depending on what looks nicer.

Signed-off-by: Paolo Bonzini 


Reviewed-by: Philippe Mathieu-Daudé 


---
  tests/fp/meson.build| 4 ++--
  tests/qtest/meson.build | 2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/fp/meson.build b/tests/fp/meson.build
index 24739ad421..514e345bf5 100644
--- a/tests/fp/meson.build
+++ b/tests/fp/meson.build
@@ -603,7 +603,7 @@ fptest_rounding_args = ['-r', 'all']
  # FIXME: i32_to_extF80 (broken), i64_to_extF80 (broken)
  #extF80_roundToInt (broken)
  foreach k, v : softfloat_conv_tests
-  test('fp-test:' + k, fptest,
+  test('fp-test-' + k, fptest,
 args: fptest_args + fptest_rounding_args + v.split(),
 suite: ['softfloat', 'softfloat-conv'])
  endforeach
@@ -612,7 +612,7 @@ endforeach
  #extF80_{mulAdd} (missing)
  foreach k, v : softfloat_tests
extF80_broken = ['lt_quiet', 'rem'].contains(k)
-  test('fp-test:' + k, fptest,
+  test('fp-test-' + k, fptest,
 args: fptest_args + fptest_rounding_args +
   ['f16_' + k, 'f32_' + k, 'f64_' + k, 'f128_' + k] +
   (extF80_broken ? [] : ['extF80_' + k]),
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 3987f96086..c2822d9de7 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -250,7 +250,7 @@ foreach dir : target_dirs
}
  endif
  # FIXME: missing dependency on the emulator binary and qemu-img
-test('qtest-@0@: @1@'.format(target_base, test),
+test('qtest-@0@/@1@'.format(target_base, test),
   qtest_executables[test],
   depends: [test_deps, qtest_emulator],
   env: qtest_env,






io: Don't use '#' flag of printf format

2020-10-19 Thread AlexChen
Signed-off-by: AlexChen 
---
 io/channel-websock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/io/channel-websock.c b/io/channel-websock.c
index 47a0e941d9..e94a1fcf99 100644
--- a/io/channel-websock.c
+++ b/io/channel-websock.c
@@ -746,7 +746,7 @@ static int 
qio_channel_websock_decode_header(QIOChannelWebsock *ioc,
 opcode != QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE &&
 opcode != QIO_CHANNEL_WEBSOCK_OPCODE_PING &&
 opcode != QIO_CHANNEL_WEBSOCK_OPCODE_PONG) {
-error_setg(errp, "unsupported opcode: %#04x; only binary, close, "
+error_setg(errp, "unsupported opcode: 0x%04x; only binary, close, "
"ping, and pong websocket frames are supported", 
opcode);
 qio_channel_websock_write_close(
 ioc, QIO_CHANNEL_WEBSOCK_STATUS_INVALID_DATA ,
-- 
2.19.1



Re: [PATCH 1/1] 9pfs: suppress performance warnings on qtest runs

2020-10-19 Thread Christian Schoenebeck
On Montag, 19. Oktober 2020 13:48:22 CEST Greg Kurz wrote:
> On Mon, 19 Oct 2020 13:10:18 +0200
> 
> Christian Schoenebeck  wrote:
> > Don't trigger any performance warning if we're just running test cases,
> > because tests intentionally run for edge cases.
> > 
> > So far performance warnings were suppressed for the 'synth' fs driver
> > backend only. This patch suppresses them for all 9p fs driver backends.
> > 
> > Signed-off-by: Christian Schoenebeck 
> > ---
> 
> LGTM
> 
> Reviewed-by: Greg Kurz 

Thanks Greg!

BTW, if you still have something to be merged, keep in mind freeze for 5.2 
starts next monday.

Best regards,
Christian Schoenebeck





Re: io: Don't use '#' flag of printf format

2020-10-19 Thread Daniel P . Berrangé
On Mon, Oct 19, 2020 at 08:12:02PM +0800, AlexChen wrote:
> Signed-off-by: AlexChen 
> ---
>  io/channel-websock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/io/channel-websock.c b/io/channel-websock.c
> index 47a0e941d9..e94a1fcf99 100644
> --- a/io/channel-websock.c
> +++ b/io/channel-websock.c
> @@ -746,7 +746,7 @@ static int 
> qio_channel_websock_decode_header(QIOChannelWebsock *ioc,
>  opcode != QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE &&
>  opcode != QIO_CHANNEL_WEBSOCK_OPCODE_PING &&
>  opcode != QIO_CHANNEL_WEBSOCK_OPCODE_PONG) {
> -error_setg(errp, "unsupported opcode: %#04x; only binary, close, 
> "
> +error_setg(errp, "unsupported opcode: 0x%04x; only binary, 
> close, "
> "ping, and pong websocket frames are supported", 
> opcode);
>  qio_channel_websock_write_close(
>  ioc, QIO_CHANNEL_WEBSOCK_STATUS_INVALID_DATA ,

Acked-by: Daniel P. Berrangé 

and added to my queue

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: [PATCH 8/30] powerpc tcg: Fix Lesser GPL version number

2020-10-19 Thread Thomas Huth
On 19/10/2020 08.11, Chetan Pant wrote:
> There is no "version 2" of the "Lesser" General Public License.
> It is either "GPL version 2.0" or "Lesser GPL version 2.1".
> This patch replaces all occurrences of "Lesser GPL version 2" with
> "Lesser GPL version 2.1" in comment section.
> 
> Signed-off-by: Chetan Pant 
> ---
>  hw/ppc/ppce500_spin.c   | 2 +-
>  target/ppc/compat.c | 2 +-
>  target/ppc/cpu-models.c | 2 +-
>  target/ppc/cpu-models.h | 2 +-
>  target/ppc/cpu.c| 2 +-
>  target/ppc/cpu.h| 2 +-
>  target/ppc/dfp_helper.c | 2 +-
>  target/ppc/excp_helper.c| 2 +-
>  target/ppc/fpu_helper.c | 2 +-
>  target/ppc/gdbstub.c| 2 +-
>  target/ppc/helper_regs.h| 2 +-
>  target/ppc/int_helper.c | 2 +-
>  target/ppc/internal.h   | 2 +-
>  target/ppc/mem_helper.c | 2 +-
>  target/ppc/misc_helper.c| 2 +-
>  target/ppc/mmu-book3s-v3.c  | 2 +-
>  target/ppc/mmu-book3s-v3.h  | 2 +-
>  target/ppc/mmu-hash32.c | 2 +-
>  target/ppc/mmu-hash64.c | 2 +-
>  target/ppc/mmu-radix64.c| 2 +-
>  target/ppc/mmu_helper.c | 2 +-
>  target/ppc/timebase_helper.c| 2 +-
>  target/ppc/translate.c  | 2 +-
>  target/ppc/translate_init.c.inc | 2 +-
>  target/ppc/user_only_helper.c   | 2 +-
>  25 files changed, 25 insertions(+), 25 deletions(-)
> 
> diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c
> index 25c9ce7..d57b199 100644
> --- a/hw/ppc/ppce500_spin.c
> +++ b/hw/ppc/ppce500_spin.c
> @@ -8,7 +8,7 @@
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
>   * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> + * version 2.1 of the License, or (at your option) any later version.
>   *
>   * This library is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
[...]

Reviewed-by: Thomas Huth 




[PULL v3 6/6] tests/9pfs: add local Tmkdir test

2020-10-19 Thread Christian Schoenebeck
This test case uses the 9pfs 'local' driver to create a directory
and then checks if the expected directory was actually created
(as real directory) on host side.

This patch introduces a custom split() implementation, because
the test code requires non empty array elements as result. For
that reason g_strsplit() would not be a good alternative, as
it would require additional filter code for reshuffling the
array, and the resulting code would be even more complex than
this split() function.

Signed-off-by: Christian Schoenebeck 
Message-Id: 

Signed-off-by: Christian Schoenebeck 
---
 tests/qtest/virtio-9p-test.c | 139 +++
 1 file changed, 139 insertions(+)

diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index af7e169d3a..c15908f27b 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -18,6 +18,62 @@
 #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000)
 static QGuestAllocator *alloc;
 
+/*
+ * Used to auto generate new fids. Start with arbitrary high value to avoid
+ * collision with hard coded fids in basic test code.
+ */
+static uint32_t fid_generator = 1000;
+
+static uint32_t genfid(void)
+{
+return fid_generator++;
+}
+
+/**
+ * Splits the @a in string by @a delim into individual (non empty) strings
+ * and outputs them to @a out. The output array @a out is NULL terminated.
+ *
+ * Output array @a out must be freed by calling split_free().
+ *
+ * @returns number of individual elements in output array @a out (without the
+ *  final NULL terminating element)
+ */
+static int split(const char *in, const char *delim, char ***out)
+{
+int n = 0, i = 0;
+char *tmp, *p;
+
+tmp = g_strdup(in);
+for (p = strtok(tmp, delim); p != NULL; p = strtok(NULL, delim)) {
+if (strlen(p) > 0) {
+++n;
+}
+}
+g_free(tmp);
+
+*out = g_new0(char *, n + 1); /* last element NULL delimiter */
+
+tmp = g_strdup(in);
+for (p = strtok(tmp, delim); p != NULL; p = strtok(NULL, delim)) {
+if (strlen(p) > 0) {
+(*out)[i++] = g_strdup(p);
+}
+}
+g_free(tmp);
+
+return n;
+}
+
+static void split_free(char ***out)
+{
+int i;
+for (i = 0; (*out)[i]; ++i) {
+g_free((*out)[i]);
+}
+g_free(*out);
+*out = NULL;
+}
+
 static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc)
 {
 QVirtio9P *v9p = obj;
@@ -201,6 +257,7 @@ static const char *rmessage_name(uint8_t id)
 id == P9_RWALK ? "RWALK" :
 id == P9_RLOPEN ? "RLOPEN" :
 id == P9_RWRITE ? "RWRITE" :
+id == P9_RMKDIR ? "RMKDIR" :
 id == P9_RFLUSH ? "RFLUSH" :
 id == P9_RREADDIR ? "READDIR" :
 "";
@@ -578,6 +635,39 @@ static bool fs_dirents_contain_name(struct V9fsDirent *e, 
const char* name)
 return false;
 }
 
+/* size[4] Tmkdir tag[2] dfid[4] name[s] mode[4] gid[4] */
+static P9Req *v9fs_tmkdir(QVirtio9P *v9p, uint32_t dfid, const char *name,
+  uint32_t mode, uint32_t gid, uint16_t tag)
+{
+P9Req *req;
+
+uint32_t body_size = 4 + 4 + 4;
+uint16_t string_size = v9fs_string_size(name);
+
+g_assert_cmpint(body_size, <=, UINT32_MAX - string_size);
+body_size += string_size;
+
+req = v9fs_req_init(v9p, body_size, P9_TMKDIR, tag);
+v9fs_uint32_write(req, dfid);
+v9fs_string_write(req, name);
+v9fs_uint32_write(req, mode);
+v9fs_uint32_write(req, gid);
+v9fs_req_send(req);
+return req;
+}
+
+/* size[4] Rmkdir tag[2] qid[13] */
+static void v9fs_rmkdir(P9Req *req, v9fs_qid *qid)
+{
+v9fs_req_recv(req, P9_RMKDIR);
+if (qid) {
+v9fs_memread(req, qid, 13);
+} else {
+v9fs_memskip(req, 13);
+}
+v9fs_req_free(req);
+}
+
 /* basic readdir test where reply fits into a single response message */
 static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc)
 {
@@ -877,6 +967,30 @@ static void fs_flush_ignored(void *obj, void *data, 
QGuestAllocator *t_alloc)
 g_free(wnames[0]);
 }
 
+static void fs_mkdir(void *obj, void *data, QGuestAllocator *t_alloc,
+ const char *path, const char *cname)
+{
+QVirtio9P *v9p = obj;
+alloc = t_alloc;
+char **wnames;
+char *const name = g_strdup(cname);
+P9Req *req;
+const uint32_t fid = genfid();
+
+int nwnames = split(path, "/", );
+
+req = v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0);
+v9fs_req_wait_for_reply(req, NULL);
+v9fs_rwalk(req, NULL, NULL);
+
+req = v9fs_tmkdir(v9p, fid, name, 0750, 0, 0);
+v9fs_req_wait_for_reply(req, NULL);
+v9fs_rmkdir(req, NULL);
+
+g_free(name);
+split_free();
+}
+
 static void fs_readdir_split_128(void *obj, void *data,
  QGuestAllocator *t_alloc)
 {
@@ -895,6 +1009,30 @@ static void fs_readdir_split_512(void *obj, void *data,
 fs_readdir_split(obj, data, t_alloc, 512);
 }
 
+
+/* tests using the 9pfs 

[PATCH 5/5] spapr: Simplify error handling in spapr_memory_plug()

2020-10-19 Thread Greg Kurz
As recommended in "qapi/error.h", add a bool return value to
spapr_add_lmbs() and spapr_add_nvdimm(), and use them instead
of local_err in spapr_memory_plug().

This allows to get rid of the error propagation overhead.

Signed-off-by: Greg Kurz 
---
 hw/ppc/spapr.c|   23 ++-
 hw/ppc/spapr_nvdimm.c |5 +++--
 include/hw/ppc/spapr_nvdimm.h |2 +-
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 62f217a6b914..0cc19b5863a4 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3382,7 +3382,7 @@ int spapr_lmb_dt_populate(SpaprDrc *drc, 
SpaprMachineState *spapr,
 return 0;
 }
 
-static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t 
size,
+static bool spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t 
size,
bool dedicated_hp_event_source, Error **errp)
 {
 SpaprDrc *drc;
@@ -3403,7 +3403,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t 
addr_start, uint64_t size,
   addr / SPAPR_MEMORY_BLOCK_SIZE);
 spapr_drc_detach(drc);
 }
-return;
+return false;
 }
 if (!hotplugged) {
 spapr_drc_reset(drc);
@@ -3425,12 +3425,12 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t 
addr_start, uint64_t size,
nr_lmbs);
 }
 }
+return true;
 }
 
 static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
   Error **errp)
 {
-Error *local_err = NULL;
 SpaprMachineState *ms = SPAPR_MACHINE(hotplug_dev);
 PCDIMMDevice *dimm = PC_DIMM(dev);
 uint64_t size, addr;
@@ -3444,27 +3444,24 @@ static void spapr_memory_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
 if (!is_nvdimm) {
 addr = object_property_get_uint(OBJECT(dimm),
 PC_DIMM_ADDR_PROP, _abort);
-spapr_add_lmbs(dev, addr, size,
-   spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT),
-   _err);
+if (!spapr_add_lmbs(dev, addr, size,
+spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT), errp)) {
+goto out_unplug;
+}
 } else {
 slot = object_property_get_int(OBJECT(dimm),
PC_DIMM_SLOT_PROP, _abort);
 /* We should have valid slot number at this point */
 g_assert(slot >= 0);
-spapr_add_nvdimm(dev, slot, _err);
-}
-
-if (local_err) {
-goto out_unplug;
+if (!spapr_add_nvdimm(dev, slot, errp)) {
+goto out_unplug;
+}
 }
 
 return;
 
 out_unplug:
 pc_dimm_unplug(dimm, MACHINE(ms));
-out:
-error_propagate(errp, local_err);
 }
 
 static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState 
*dev,
diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c
index 9e3d94071fe1..a833a63b5ed3 100644
--- a/hw/ppc/spapr_nvdimm.c
+++ b/hw/ppc/spapr_nvdimm.c
@@ -89,7 +89,7 @@ bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, 
NVDIMMDevice *nvdimm,
 }
 
 
-void spapr_add_nvdimm(DeviceState *dev, uint64_t slot, Error **errp)
+bool spapr_add_nvdimm(DeviceState *dev, uint64_t slot, Error **errp)
 {
 SpaprDrc *drc;
 bool hotplugged = spapr_drc_hotplugged(dev);
@@ -98,12 +98,13 @@ void spapr_add_nvdimm(DeviceState *dev, uint64_t slot, 
Error **errp)
 g_assert(drc);
 
 if (!spapr_drc_attach(drc, dev, errp)) {
-return;
+return false;
 }
 
 if (hotplugged) {
 spapr_hotplug_req_add_by_index(drc);
 }
+return true;
 }
 
 static int spapr_dt_nvdimm(SpaprMachineState *spapr, void *fdt,
diff --git a/include/hw/ppc/spapr_nvdimm.h b/include/hw/ppc/spapr_nvdimm.h
index 490b19a009f4..344582d2f5f7 100644
--- a/include/hw/ppc/spapr_nvdimm.h
+++ b/include/hw/ppc/spapr_nvdimm.h
@@ -30,6 +30,6 @@ int spapr_pmem_dt_populate(SpaprDrc *drc, SpaprMachineState 
*spapr,
 void spapr_dt_persistent_memory(SpaprMachineState *spapr, void *fdt);
 bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdimm,
uint64_t size, Error **errp);
-void spapr_add_nvdimm(DeviceState *dev, uint64_t slot, Error **errp);
+bool spapr_add_nvdimm(DeviceState *dev, uint64_t slot, Error **errp);
 
 #endif





[PATCH 3/5] spapr: Use appropriate getter for PC_DIMM_SLOT_PROP

2020-10-19 Thread Greg Kurz
The PC_DIMM_SLOT_PROP property is defined as:

DEFINE_PROP_INT32(PC_DIMM_SLOT_PROP, PCDIMMDevice, slot,
  PC_DIMM_UNASSIGNED_SLOT),

Use object_property_get_int() instead of object_property_get_uint().
Since spapr_memory_plug() only gets called if pc_dimm_pre_plug()
succeeded, we expect to have a valid >= 0 slot number, either because
the user passed a valid slot number or because pc_dimm_get_free_slot()
picked one up for us.

Signed-off-by: Greg Kurz 
---
 hw/ppc/spapr.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 115fc52e3b06..1b173861152f 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3433,7 +3433,8 @@ static void spapr_memory_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
 Error *local_err = NULL;
 SpaprMachineState *ms = SPAPR_MACHINE(hotplug_dev);
 PCDIMMDevice *dimm = PC_DIMM(dev);
-uint64_t size, addr, slot;
+uint64_t size, addr;
+int64_t slot;
 bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
 
 size = memory_device_get_region_size(MEMORY_DEVICE(dev), _abort);
@@ -3450,11 +3451,13 @@ static void spapr_memory_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT),
_err);
 } else {
-slot = object_property_get_uint(OBJECT(dimm),
-PC_DIMM_SLOT_PROP, _err);
+slot = object_property_get_int(OBJECT(dimm),
+   PC_DIMM_SLOT_PROP, _err);
 if (local_err) {
 goto out_unplug;
 }
+/* We should have valid slot number at this point */
+g_assert(slot >= 0);
 spapr_add_nvdimm(dev, slot, _err);
 }
 





Re: io_uring possibly the culprit for qemu hang (linux-5.4.y)

2020-10-19 Thread Pankaj Gupta
@Jack Wang,
Maybe four io_uring patches in 5.4.71 fixes the issue for you as well?

Thanks,
Pankaj

> Hi Jens.
>
> On Sat, Oct 17, 2020 at 3:07 AM Jens Axboe  wrote:
> >
> > Would be great if you could try 5.4.71 and see if that helps for your
> > issue.
> >
>
> Oh wow, yeah it did fix the issue.
>
> I'm able to reliably turn off and start the VM multiple times in a row.
> Double checked by confirming QEMU is dynamically linked to liburing.so.1.
>
> Looks like those 4 io_uring fixes helped.
>
> Thanks!
>



[PATCH] ACPI: Avoid infinite recursion when dump-vmstate

2020-10-19 Thread Peng Liang
There is a field with vmstate_ghes_state as vmsd in vmstate_ghes_state,
which will lead to infinite recursion in dump_vmstate_vmsd.

Fixes: a08a64627b ("ACPI: Record the Generic Error Status Block address")
Reported-by: Euler Robot 
Signed-off-by: Peng Liang 
---
 hw/acpi/generic_event_device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
index 6df400e1ee16..4b6867300a55 100644
--- a/hw/acpi/generic_event_device.c
+++ b/hw/acpi/generic_event_device.c
@@ -334,8 +334,7 @@ static const VMStateDescription vmstate_ghes_state = {
 .minimum_version_id = 1,
 .needed = ghes_needed,
 .fields  = (VMStateField[]) {
-VMSTATE_STRUCT(ghes_state, AcpiGedState, 1,
-   vmstate_ghes_state, AcpiGhesState),
+VMSTATE_UINT64(ghes_state.ghes_addr_le, AcpiGedState),
 VMSTATE_END_OF_LIST()
 }
 };
-- 
2.26.2




Re: [PATCH v4 2/4] Jobs based on custom runners: build environment docs and playbook

2020-10-19 Thread Erik Skultety
...

> diff --git a/scripts/ci/setup/inventory b/scripts/ci/setup/inventory
> new file mode 100644
> index 00..8bb7ba6b33
> --- /dev/null
> +++ b/scripts/ci/setup/inventory
> @@ -0,0 +1,2 @@
> +[local]

Nit pick, is a group for localhost actually needed?

Regards,
Erik




Re: [PATCH 4/30] authz: Fix Lesser GPL version number

2020-10-19 Thread Daniel P . Berrangé
On Wed, Oct 14, 2020 at 01:49:02PM +, Chetan Pant wrote:
> There is no "version 2" of the "Lesser" General Public License.
> It is either "GPL version 2.0" or "Lesser GPL version 2.1".
> This patch replaces all occurrences of "Lesser GPL version 2" with
> "Lesser GPL version 2.1" in comment section.
> 
> Signed-off-by: Chetan Pant 
> ---
>  authz/base.c| 2 +-
>  authz/list.c| 2 +-
>  authz/listfile.c| 2 +-
>  authz/pamacct.c | 2 +-
>  authz/simple.c  | 2 +-
>  include/authz/base.h| 2 +-
>  include/authz/list.h| 2 +-
>  include/authz/listfile.h| 2 +-
>  include/authz/pamacct.h | 2 +-
>  include/authz/simple.h  | 2 +-
>  tests/test-authz-list.c | 2 +-
>  tests/test-authz-listfile.c | 2 +-
>  tests/test-authz-pam.c  | 2 +-
>  tests/test-authz-simple.c   | 2 +-
>  14 files changed, 14 insertions(+), 14 deletions(-)

Acked-by: Daniel P. Berrangé 


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: [PATCH 2/30] io: Fix Lesser GPL version number

2020-10-19 Thread Daniel P . Berrangé
On Wed, Oct 14, 2020 at 01:40:33PM +, Chetan Pant wrote:
> There is no "version 2" of the "Lesser" General Public License.
> It is either "GPL version 2.0" or "Lesser GPL version 2.1".
> This patch replaces all occurrences of "Lesser GPL version 2" with
> "Lesser GPL version 2.1" in comment section.
> 
> Signed-off-by: Chetan Pant 
> ---
>  include/io/channel-buffer.h | 2 +-
>  include/io/channel-command.h| 2 +-
>  include/io/channel-file.h   | 2 +-
>  include/io/channel-socket.h | 2 +-
>  include/io/channel-tls.h| 2 +-
>  include/io/channel-util.h   | 2 +-
>  include/io/channel-watch.h  | 2 +-
>  include/io/channel-websock.h| 2 +-
>  include/io/channel.h| 2 +-
>  include/io/dns-resolver.h   | 2 +-
>  include/io/task.h   | 2 +-
>  io/channel-buffer.c | 2 +-
>  io/channel-command.c| 2 +-
>  io/channel-file.c   | 2 +-
>  io/channel-socket.c | 2 +-
>  io/channel-tls.c| 2 +-
>  io/channel-util.c   | 2 +-
>  io/channel-watch.c  | 2 +-
>  io/channel-websock.c| 2 +-
>  io/channel.c| 2 +-
>  io/dns-resolver.c   | 2 +-
>  io/task.c   | 2 +-
>  tests/test-io-channel-buffer.c  | 2 +-
>  tests/test-io-channel-command.c | 2 +-
>  tests/test-io-channel-file.c| 2 +-
>  tests/test-io-channel-socket.c  | 2 +-
>  tests/test-io-task.c| 2 +-
>  27 files changed, 27 insertions(+), 27 deletions(-)

Acked-by: Daniel P. Berrangé 


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 :|




[PATCH v2 2/5] memory: Add IOMMUTLBEvent

2020-10-19 Thread Eugenio Pérez
This way we can tell between regular IOMMUTLBEntry (entry of IOMMU
hardware) and notifications.

In the notifications, we set explicitly if it is a MAPs or an UNMAP,
instead of trusting in entry permissions to differentiate them.

Signed-off-by: Eugenio Pérez 
Reviewed-by: Peter Xu 
Reviewed-by: Juan Quintela 
---
 include/exec/memory.h | 27 +++--
 hw/arm/smmu-common.c  | 13 ---
 hw/arm/smmuv3.c   | 13 ---
 hw/i386/intel_iommu.c | 88 ---
 hw/misc/tz-mpc.c  | 32 +---
 hw/ppc/spapr_iommu.c  | 15 
 softmmu/memory.c  | 20 +-
 7 files changed, 111 insertions(+), 97 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index ac6bca1ba0..ab60870c76 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -101,6 +101,11 @@ struct IOMMUNotifier {
 };
 typedef struct IOMMUNotifier IOMMUNotifier;
 
+typedef struct IOMMUTLBEvent {
+IOMMUNotifierFlag type;
+IOMMUTLBEntry entry;
+} IOMMUTLBEvent;
+
 /* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */
 #define RAM_PREALLOC   (1 << 0)
 
@@ -1280,24 +1285,18 @@ uint64_t 
memory_region_iommu_get_min_page_size(IOMMUMemoryRegion *iommu_mr);
 /**
  * memory_region_notify_iommu: notify a change in an IOMMU translation entry.
  *
- * The notification type will be decided by entry.perm bits:
- *
- * - For UNMAP (cache invalidation) notifies: set entry.perm to IOMMU_NONE.
- * - For MAP (newly added entry) notifies: set entry.perm to the
- *   permission of the page (which is definitely !IOMMU_NONE).
- *
  * Note: for any IOMMU implementation, an in-place mapping change
  * should be notified with an UNMAP followed by a MAP.
  *
  * @iommu_mr: the memory region that was changed
  * @iommu_idx: the IOMMU index for the translation table which has changed
- * @entry: the new entry in the IOMMU translation table.  The entry
- * replaces all old entries for the same virtual I/O address range.
- * Deleted entries have .@perm == 0.
+ * @event: TLB event with the new entry in the IOMMU translation table.
+ * The entry replaces all old entries for the same virtual I/O address
+ * range.
  */
 void memory_region_notify_iommu(IOMMUMemoryRegion *iommu_mr,
 int iommu_idx,
-IOMMUTLBEntry entry);
+IOMMUTLBEvent event);
 
 /**
  * memory_region_notify_iommu_one: notify a change in an IOMMU translation
@@ -1307,12 +1306,12 @@ void memory_region_notify_iommu(IOMMUMemoryRegion 
*iommu_mr,
  * notifies a specific notifier, not all of them.
  *
  * @notifier: the notifier to be notified
- * @entry: the new entry in the IOMMU translation table.  The entry
- * replaces all old entries for the same virtual I/O address range.
- * Deleted entries have .@perm == 0.
+ * @event: TLB event with the new entry in the IOMMU translation table.
+ * The entry replaces all old entries for the same virtual I/O address
+ * range.
  */
 void memory_region_notify_iommu_one(IOMMUNotifier *notifier,
-  IOMMUTLBEntry *entry);
+IOMMUTLBEvent *event);
 
 /**
  * memory_region_register_iommu_notifier: register a notifier for changes to
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index 88d2c454f0..405d5c5325 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -465,14 +465,15 @@ IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t 
sid)
 /* Unmap the whole notifier's range */
 static void smmu_unmap_notifier_range(IOMMUNotifier *n)
 {
-IOMMUTLBEntry entry;
+IOMMUTLBEvent event;
 
-entry.target_as = _space_memory;
-entry.iova = n->start;
-entry.perm = IOMMU_NONE;
-entry.addr_mask = n->end - n->start;
+event.type = IOMMU_NOTIFIER_UNMAP;
+event.entry.target_as = _space_memory;
+event.entry.iova = n->start;
+event.entry.perm = IOMMU_NONE;
+event.entry.addr_mask = n->end - n->start;
 
-memory_region_notify_iommu_one(n, );
+memory_region_notify_iommu_one(n, );
 }
 
 /* Unmap all notifiers attached to @mr */
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index 0a893ae918..62b0e289ca 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -799,7 +799,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
uint8_t tg, uint64_t num_pages)
 {
 SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
-IOMMUTLBEntry entry;
+IOMMUTLBEvent event;
 uint8_t granule = tg;
 
 if (!tg) {
@@ -822,12 +822,13 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
 granule = tt->granule_sz;
 }
 
-entry.target_as = _space_memory;
-entry.iova = iova;
-entry.addr_mask = num_pages * (1 << granule) - 1;
-entry.perm = IOMMU_NONE;
+event.type = IOMMU_NOTIFIER_UNMAP;
+event.entry.target_as = _space_memory;
+event.entry.iova = 

Re: [PATCH 8/30] powerpc tcg: Fix Lesser GPL version number

2020-10-19 Thread Daniel P . Berrangé
This subject line says 8/30, but I've never received patches
9->30, and I don't see them in the mailing list archive
either...

On Mon, Oct 19, 2020 at 06:11:26AM +, Chetan Pant wrote:
> There is no "version 2" of the "Lesser" General Public License.
> It is either "GPL version 2.0" or "Lesser GPL version 2.1".
> This patch replaces all occurrences of "Lesser GPL version 2" with
> "Lesser GPL version 2.1" in comment section.
> 
> Signed-off-by: Chetan Pant 
> ---
>  hw/ppc/ppce500_spin.c   | 2 +-
>  target/ppc/compat.c | 2 +-
>  target/ppc/cpu-models.c | 2 +-
>  target/ppc/cpu-models.h | 2 +-
>  target/ppc/cpu.c| 2 +-
>  target/ppc/cpu.h| 2 +-
>  target/ppc/dfp_helper.c | 2 +-
>  target/ppc/excp_helper.c| 2 +-
>  target/ppc/fpu_helper.c | 2 +-
>  target/ppc/gdbstub.c| 2 +-
>  target/ppc/helper_regs.h| 2 +-
>  target/ppc/int_helper.c | 2 +-
>  target/ppc/internal.h   | 2 +-
>  target/ppc/mem_helper.c | 2 +-
>  target/ppc/misc_helper.c| 2 +-
>  target/ppc/mmu-book3s-v3.c  | 2 +-
>  target/ppc/mmu-book3s-v3.h  | 2 +-
>  target/ppc/mmu-hash32.c | 2 +-
>  target/ppc/mmu-hash64.c | 2 +-
>  target/ppc/mmu-radix64.c| 2 +-
>  target/ppc/mmu_helper.c | 2 +-
>  target/ppc/timebase_helper.c| 2 +-
>  target/ppc/translate.c  | 2 +-
>  target/ppc/translate_init.c.inc | 2 +-
>  target/ppc/user_only_helper.c   | 2 +-
>  25 files changed, 25 insertions(+), 25 deletions(-)
> 
> diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c
> index 25c9ce7..d57b199 100644
> --- a/hw/ppc/ppce500_spin.c
> +++ b/hw/ppc/ppce500_spin.c
> @@ -8,7 +8,7 @@
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
>   * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> + * version 2.1 of the License, or (at your option) any later version.
>   *
>   * This library is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
> diff --git a/target/ppc/compat.c b/target/ppc/compat.c
> index 08aede8..dd56025 100644
> --- a/target/ppc/compat.c
> +++ b/target/ppc/compat.c
> @@ -6,7 +6,7 @@
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
>   * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> + * version 2.1 of the License, or (at your option) any later version.
>   *
>   * This library is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
> diff --git a/target/ppc/cpu-models.c b/target/ppc/cpu-models.c
> index 4ad1686..87e4228 100644
> --- a/target/ppc/cpu-models.c
> +++ b/target/ppc/cpu-models.c
> @@ -8,7 +8,7 @@
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
>   * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> + * version 2.1 of the License, or (at your option) any later version.
>   *
>   * This library is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
> diff --git a/target/ppc/cpu-models.h b/target/ppc/cpu-models.h
> index ce750b2..fc5e217 100644
> --- a/target/ppc/cpu-models.h
> +++ b/target/ppc/cpu-models.h
> @@ -8,7 +8,7 @@
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
>   * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> + * version 2.1 of the License, or (at your option) any later version.
>   *
>   * This library is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
> diff --git a/target/ppc/cpu.c b/target/ppc/cpu.c
> index 2801166..e501a7f 100644
> --- a/target/ppc/cpu.c
> +++ b/target/ppc/cpu.c
> @@ -6,7 +6,7 @@
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
>   * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> + * version 2.1 of the License, or (at your option) any later version.
>   *
>   * This library is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 766e9c5..9e108ed 100644
> --- a/target/ppc/cpu.h
> +++ 

[PATCH] hw/block/nvme: fix prp mapping status codes

2020-10-19 Thread Klaus Jensen
From: Gollu Appalanaidu 

Differentiate between missing PRPs and misaligned PRPs, return the
relevant status code and streamline the trace event naming.

See NVMe Express v1.3d, Section 4.3 ("Physical Region Page Entry and
List").

Signed-off-by: Gollu Appalanaidu 
Signed-off-by: Klaus Jensen 
---
 include/block/nvme.h  |  1 +
 hw/block/nvme.c   | 22 --
 hw/block/trace-events |  5 +++--
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/include/block/nvme.h b/include/block/nvme.h
index 6de2d5aa75a9..8a46d9cf015f 100644
--- a/include/block/nvme.h
+++ b/include/block/nvme.h
@@ -655,6 +655,7 @@ enum NvmeStatusCodes {
 NVME_MD_SGL_LEN_INVALID = 0x0010,
 NVME_SGL_DESCR_TYPE_INVALID = 0x0011,
 NVME_INVALID_USE_OF_CMB = 0x0012,
+NVME_INVALID_PRP_OFFSET = 0x0013,
 NVME_LBA_RANGE  = 0x0080,
 NVME_CAP_EXCEEDED   = 0x0081,
 NVME_NS_NOT_READY   = 0x0082,
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 9d30ca69dcf1..785a87af0138 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -328,7 +328,7 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, uint64_t prp1, 
uint64_t prp2,
 trace_pci_nvme_map_prp(trans_len, len, prp1, prp2, num_prps);
 
 if (unlikely(!prp1)) {
-trace_pci_nvme_err_invalid_prp();
+trace_pci_nvme_err_invalid_prp1_missing();
 return NVME_INVALID_FIELD | NVME_DNR;
 }
 
@@ -370,11 +370,16 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, uint64_t prp1, 
uint64_t prp2,
 uint64_t prp_ent = le64_to_cpu(prp_list[i]);
 
 if (i == n->max_prp_ents - 1 && len > n->page_size) {
-if (unlikely(!prp_ent || prp_ent & (n->page_size - 1))) {
-trace_pci_nvme_err_invalid_prplist_ent(prp_ent);
+if (unlikely(!prp_ent)) {
+trace_pci_nvme_err_invalid_prplist_ent_missing();
 return NVME_INVALID_FIELD | NVME_DNR;
 }
 
+if (unlikely(prp_ent & (n->page_size - 1))) {
+trace_pci_nvme_err_invalid_prplist_ent(prp_ent);
+return NVME_INVALID_PRP_OFFSET | NVME_DNR;
+}
+
 if (prp_list_in_cmb != nvme_addr_is_cmb(n, prp_ent)) {
 return NVME_INVALID_USE_OF_CMB | NVME_DNR;
 }
@@ -391,11 +396,16 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, uint64_t prp1, 
uint64_t prp2,
 prp_ent = le64_to_cpu(prp_list[i]);
 }
 
-if (unlikely(!prp_ent || prp_ent & (n->page_size - 1))) {
-trace_pci_nvme_err_invalid_prplist_ent(prp_ent);
+if (unlikely(!prp_ent)) {
+trace_pci_nvme_err_invalid_prplist_ent_missing();
 return NVME_INVALID_FIELD | NVME_DNR;
 }
 
+if (unlikely(prp_ent & (n->page_size - 1))) {
+trace_pci_nvme_err_invalid_prplist_ent(prp_ent);
+return NVME_INVALID_PRP_OFFSET | NVME_DNR;
+}
+
 trans_len = MIN(len, n->page_size);
 status = nvme_map_addr(n, qsg, iov, prp_ent, trans_len);
 if (status) {
@@ -408,7 +418,7 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, uint64_t prp1, 
uint64_t prp2,
 } else {
 if (unlikely(prp2 & (n->page_size - 1))) {
 trace_pci_nvme_err_invalid_prp2_align(prp2);
-return NVME_INVALID_FIELD | NVME_DNR;
+return NVME_INVALID_PRP_OFFSET | NVME_DNR;
 }
 status = nvme_map_addr(n, qsg, iov, prp2, len);
 if (status) {
diff --git a/hw/block/trace-events b/hw/block/trace-events
index cab9913b1f2d..2bafbed256e8 100644
--- a/hw/block/trace-events
+++ b/hw/block/trace-events
@@ -97,10 +97,11 @@ pci_nvme_err_invalid_sgld(uint16_t cid, uint8_t typ) "cid 
%"PRIu16" type 0x%"PRI
 pci_nvme_err_invalid_num_sgld(uint16_t cid, uint8_t typ) "cid %"PRIu16" type 
0x%"PRIx8""
 pci_nvme_err_invalid_sgl_excess_length(uint16_t cid) "cid %"PRIu16""
 pci_nvme_err_invalid_dma(void) "PRP/SGL is too small for transfer size"
-pci_nvme_err_invalid_prplist_ent(uint64_t prplist) "PRP list entry is null or 
not page aligned: 0x%"PRIx64""
+pci_nvme_err_invalid_prp1_missing(void) "PRP1 is null"
 pci_nvme_err_invalid_prp2_align(uint64_t prp2) "PRP2 is not page aligned: 
0x%"PRIx64""
 pci_nvme_err_invalid_prp2_missing(void) "PRP2 is null and more data to be 
transferred"
-pci_nvme_err_invalid_prp(void) "invalid PRP"
+pci_nvme_err_invalid_prplist_ent(uint64_t prplist) "PRP list entry not page 
aligned: 0x%"PRIx64""
+pci_nvme_err_invalid_prplist_ent_missing(void) "PRP list entry is null and 
more data to be transferred"
 pci_nvme_err_invalid_opc(uint8_t opc) "invalid opcode 0x%"PRIx8""
 pci_nvme_err_invalid_admin_opc(uint8_t opc) "invalid admin opcode 0x%"PRIx8""
 

Re: [PATCH v7 05/11] hw/block/nvme: Support Zoned Namespace Command Set

2020-10-19 Thread Klaus Jensen
On Oct 19 11:17, Dmitry Fomichev wrote:
> diff --git a/hw/block/nvme-ns.h b/hw/block/nvme-ns.h
> index d6b2808b97..170cbb8cdc 100644
> --- a/hw/block/nvme-ns.h
> +++ b/hw/block/nvme-ns.h
> @@ -34,6 +45,18 @@ typedef struct NvmeNamespace {
>  const uint32_t *iocs;
>  uint8_t  csi;
>  
> +NvmeIdNsZoned   *id_ns_zoned;
> +NvmeZone*zone_array;
> +QTAILQ_HEAD(, NvmeZone) exp_open_zones;
> +QTAILQ_HEAD(, NvmeZone) imp_open_zones;
> +QTAILQ_HEAD(, NvmeZone) closed_zones;
> +QTAILQ_HEAD(, NvmeZone) full_zones;

Apart from the imp_open_zones list that is being used in a later patch
to support Implicitly Opened to Closed transitions, these lists seem
rather pointless. As far as I can tell the only use they have is being
inserted into, removed from and checking if a zone is in one of those
four states?

The Zone Management Receive (and Send with Select All) is just iterating
on all zones and matching on state.


signature.asc
Description: PGP signature


[PATCH 1/5] pc-dimm: Drop @errp argument of pc_dimm_plug()

2020-10-19 Thread Greg Kurz
pc_dimm_plug() doesn't use it. It only aborts on error.

Drop @errp and adapt the callers accordingly.

Signed-off-by: Greg Kurz 
---
 hw/arm/virt.c|9 +
 hw/i386/pc.c |8 +---
 hw/mem/pc-dimm.c |2 +-
 hw/ppc/spapr.c   |5 +
 include/hw/mem/pc-dimm.h |2 +-
 5 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index e465a988d683..27dbeb549ef1 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2261,12 +2261,8 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
 VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
 MachineState *ms = MACHINE(hotplug_dev);
 bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
-Error *local_err = NULL;
 
-pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), _err);
-if (local_err) {
-goto out;
-}
+pc_dimm_plug(PC_DIMM(dev), MACHINE(vms));
 
 if (is_nvdimm) {
 nvdimm_plug(ms->nvdimms_state);
@@ -2274,9 +2270,6 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
 
 hotplug_handler_plug(HOTPLUG_HANDLER(vms->acpi_dev),
  dev, _abort);
-
-out:
-error_propagate(errp, local_err);
 }
 
 static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e87be5d29a01..38b1be78e707 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1265,24 +1265,18 @@ static void pc_memory_pre_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
 static void pc_memory_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
 {
-Error *local_err = NULL;
 PCMachineState *pcms = PC_MACHINE(hotplug_dev);
 X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
 MachineState *ms = MACHINE(hotplug_dev);
 bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
 
-pc_dimm_plug(PC_DIMM(dev), MACHINE(pcms), _err);
-if (local_err) {
-goto out;
-}
+pc_dimm_plug(PC_DIMM(dev), MACHINE(pcms));
 
 if (is_nvdimm) {
 nvdimm_plug(ms->nvdimms_state);
 }
 
 hotplug_handler_plug(x86ms->acpi_dev, dev, _abort);
-out:
-error_propagate(errp, local_err);
 }
 
 static void pc_memory_unplug_request(HotplugHandler *hotplug_dev,
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index c30351070bb8..2ffc986734df 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -64,7 +64,7 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState 
*machine,
errp);
 }
 
-void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine, Error **errp)
+void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine)
 {
 PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
 MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm,
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ee716a12af73..4edd31b86915 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3438,10 +3438,7 @@ static void spapr_memory_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
 
 size = memory_device_get_region_size(MEMORY_DEVICE(dev), _abort);
 
-pc_dimm_plug(dimm, MACHINE(ms), _err);
-if (local_err) {
-goto out;
-}
+pc_dimm_plug(dimm, MACHINE(ms));
 
 if (!is_nvdimm) {
 addr = object_property_get_uint(OBJECT(dimm),
diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index aec9527fdd96..3d3db82641f8 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -72,6 +72,6 @@ struct PCDIMMDeviceClass {
 
 void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,
   const uint64_t *legacy_align, Error **errp);
-void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine, Error **errp);
+void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine);
 void pc_dimm_unplug(PCDIMMDevice *dimm, MachineState *machine);
 #endif





[PATCH 2/5] spapr: Use appropriate getter for PC_DIMM_ADDR_PROP

2020-10-19 Thread Greg Kurz
The PC_DIMM_ADDR_PROP property is defined as:

DEFINE_PROP_UINT64(PC_DIMM_ADDR_PROP, PCDIMMDevice, addr, 0),

Use object_property_get_uint() instead of object_property_get_int().

Signed-off-by: Greg Kurz 
---
 hw/ppc/spapr.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 4edd31b86915..115fc52e3b06 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3572,8 +3572,8 @@ static SpaprDimmState 
*spapr_recover_pending_dimm_state(SpaprMachineState *ms,
 uint64_t addr_start, addr;
 int i;
 
-addr_start = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP,
- _abort);
+addr_start = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
+  _abort);
 
 addr = addr_start;
 for (i = 0; i < nr_lmbs; i++) {





[PATCH 0/5] spapr: Error handling fixes and cleanups (round 3)

2020-10-19 Thread Greg Kurz
Hi,

This is a followup to a previous cleanup for the sPAPR code:

https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg04860.html

The last two patches had to be dropped because they were wrongly assuming
that object_property_get_uint() returning zero meant failure. This led to
a discussion in which arose a consensus that most of the time (not to say
always) object property getters should never fail actually, ie. failure
is very likely the result of a programming error and QEMU should abort.

This series aims at demonstrating a revelant case I've found while auditing
object property getters (this is patch 4 that I've isolated from a huge
50-patch series I haven't dared to post yet). The sPAPR memory hotplug code
is tailored to support either regular PC DIMMs or NVDIMMs, which inherit
from PC DIMMs. They expect to get some properties from the DIMM object,
which happens to be set by default at the PC DIMM class level. It thus
doesn't make sense to pass an error object and propagate it when getting
them since this would lure the user into thinking they did something wrong.

Some preliminary cleanup is done on the way, especially dropping an unused
@errp argument of pc_dimm_plug(). This affects several platforms other than
sPAPR but I guess the patch is trivial enough to go through David's tree
if it gets acks from the relevant maintainers.

---

Greg Kurz (5):
  pc-dimm: Drop @errp argument of pc_dimm_plug()
  spapr: Use appropriate getter for PC_DIMM_ADDR_PROP
  spapr: Use appropriate getter for PC_DIMM_SLOT_PROP
  spapr: Pass _abort when getting some PC DIMM properties
  spapr: Simplify error handling in spapr_memory_plug()


 hw/arm/virt.c |9 +---
 hw/i386/pc.c  |8 +--
 hw/mem/pc-dimm.c  |2 +-
 hw/ppc/spapr.c|   48 +++--
 hw/ppc/spapr_nvdimm.c |5 +++-
 include/hw/mem/pc-dimm.h  |2 +-
 include/hw/ppc/spapr_nvdimm.h |2 +-
 7 files changed, 25 insertions(+), 51 deletions(-)

--
Greg




Re: Kernel patch cases qemu live migration failed.

2020-10-19 Thread Andrew Jones
On Thu, Oct 15, 2020 at 03:57:02PM +0100, Peter Maydell wrote:
> On Thu, 15 Oct 2020 at 15:41, Andrew Jones  wrote:
> > The reporter states neither the source nor destination hardware supports
> > SVE. My guess is that what's happening is the reserved ID register
> > ID_UNALLOCATED(4,4) was showing up in the KVM_GET_REG_LIST count on
> > the old kernel, but the new kernel filters it out. Maybe it is a
> > bug to filter it out of the count, as it's a reserved ID register and
> > I suppose the other reserved ID registers are still showing up?
> 
> Yeah, RES0 ID registers should show up in the list, because otherwise
> userspace has to annoyingly special case them when the architecture
> eventually defines behaviour for them.
> 
> Dave's comment in the kernel commit message
> # ID_AA64ZFR0_EL1 is RO-RAZ for MRS/MSR when SVE is disabled for the
> # guest, but for compatibility with non-SVE aware KVM implementations
> # the register should not be enumerated at all for KVM_GET_REG_LIST
> # in this case.
> seems wrong to me -- for compatibility the register should remain
> present and behave as RAZ/WI if SVE is disabled in the guest,
> the same way it was before the kernel/KVM knew about SVE at all.

Yup, I agree with you and I'll try writing a patch for this.

Thanks,
drew




Re: [PULL 25/33] tests/acceptance: Add a test for the N800 and N810 arm machines

2020-10-19 Thread Philippe Mathieu-Daudé

On 10/19/20 11:30 AM, Philippe Mathieu-Daudé wrote:

On 10/19/20 8:31 AM, Thomas Huth wrote:

On 17/10/2020 19.51, Philippe Mathieu-Daudé wrote:

Hi Peter, Igor, Thomas,

On 2/28/20 5:38 PM, Peter Maydell wrote:

From: Thomas Huth 

Old kernels from the Meego project can be used to check that Linux
is at least starting on these machines.

Signed-off-by: Thomas Huth 
Reviewed-by: Wainer dos Santos Moschetta 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Signed-off-by: Philippe Mathieu-Daudé 
Message-id: 20200225172501.29609-2-phi...@redhat.com
Message-Id: <20200129131920.22302-1-th...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
Signed-off-by: Peter Maydell 
---
   MAINTAINERS  |  1 +
   tests/acceptance/machine_arm_n8x0.py | 49 


   2 files changed, 50 insertions(+)
   create mode 100644 tests/acceptance/machine_arm_n8x0.py

diff --git a/MAINTAINERS b/MAINTAINERS
index b66c46dcb9f..264374adbe8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -686,6 +686,7 @@ F: hw/rtc/twl92230.c
   F: include/hw/display/blizzard.h
   F: include/hw/input/tsc2xxx.h
   F: include/hw/misc/cbus.h
+F: tests/acceptance/machine_arm_n8x0.py
     Palm
   M: Andrzej Zaborowski 
diff --git a/tests/acceptance/machine_arm_n8x0.py
b/tests/acceptance/machine_arm_n8x0.py
new file mode 100644
index 000..e5741f2d8d1
--- /dev/null
+++ b/tests/acceptance/machine_arm_n8x0.py
@@ -0,0 +1,49 @@
+# Functional test that boots a Linux kernel and checks the console
+#
+# Copyright (c) 2020 Red Hat, Inc.
+#
+# Author:
+#  Thomas Huth 
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+import os
+
+from avocado import skipUnless
+from avocado_qemu import Test
+from avocado_qemu import wait_for_console_pattern
+
+class N8x0Machine(Test):
+    """Boots the Linux kernel and checks that the console is 
operational"""

+
+    timeout = 90
+
+    def __do_test_n8x0(self):
+    kernel_url = ('http://stskeeps.subnetmask.net/meego-n8x0/'
+  'meego-arm-n8x0-1.0.80.20100712.1431-'
+  'vmlinuz-2.6.35~rc4-129.1-n8x0')
+    kernel_hash = 'e9d5ab8d7548923a0061b6fbf601465e479ed269'
+    kernel_path = self.fetch_asset(kernel_url, 
asset_hash=kernel_hash)

+
+    self.vm.set_console(console_index=1)
+    self.vm.add_args('-kernel', kernel_path,
+ '-append', 'printk.time=0 console=ttyS1')
+    self.vm.launch()
+    wait_for_console_pattern(self, 'TSC2005 driver initializing')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 
'untrusted code')

+    def test_n800(self):
+    """
+    :avocado: tags=arch:arm
+    :avocado: tags=machine:n800
+    """
+    self.__do_test_n8x0()
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 
'untrusted code')

+    def test_n810(self):
+    """
+    :avocado: tags=arch:arm
+    :avocado: tags=machine:n810
+    """
+    self.__do_test_n8x0()



FYI this test is failing:

qemu-system-arm: kernel 'meego-arm-n8x0-1.0.80.20100712.1431-vml
inuz-2.6.35~rc4-129.1-n8x0' is too large to fit in RAM (kernel size 
1964608,

RAM size 0)


FWIW:

7998beb9c2e280f0b7424223747941f106e2e854 is the first bad commit
commit 7998beb9c2e280f0b7424223747941f106e2e854
Author: Igor Mammedov 
Date:   Wed Feb 19 11:08:59 2020 -0500

     arm/nseries: use memdev for RAM

     memory_region_allocate_system_memory() API is going away, so
     replace it with memdev allocated MemoryRegion. The later is
     initialized by generic code, so board only needs to opt in
     to memdev scheme by providing
   MachineClass::default_ram_id
     and using MachineState::ram instead of manually initializing
     RAM memory region.

     PS:
  while at it add check for user supplied RAM size and error
  out if it mismatches board expected value.

     Signed-off-by: Igor Mammedov 
     Reviewed-by: Andrew Jones 
     Reviewed-by: Richard Henderson 
     Message-Id: <20200219160953.13771-26-imamm...@redhat.com>


This fixes the issue:

-- >8 --
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index e48092ca047..76fd7fe9854 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -1318,6 +1318,7 @@ static void n8x0_init(MachineState *machine,
 g_free(sz);
 exit(EXIT_FAILURE);
 }
+binfo->ram_size = machine->ram_size;

 memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE,
 machine->ram);
---





Alex, Thomas, can we enable AVOCADO_ALLOW_UNTRUSTED_CODE on GitLab
to avoid such regressions?


Yes, please, if you've got some spare minutes to work on such a patch, 
that

would be great! ... I once already wanted to send such a patch, but IIRC
there were some other ALLOW_UNTRUSTED_CODE tests failing at that poing in
time, and I never got around to fix them...

  Thomas








Re: [PATCH v2 3/8] migration: Add spaces around operator

2020-10-19 Thread Bihong Yu
Yes, I used to think "const VMStateDescription *[]" was right, but when I search
similar expressions, most of all are "xxx * []". Such as:
fsdev/qemu-fsdev.c:54:.opts = (const char * [])
hw/intc/s390_flic_kvm.c:567:.subsections = (const VMStateDescription * [])
...

So, I keep the same style. Should I change it to "const VMStateDescription *[]"?

On 2020/10/19 16:24, Markus Armbruster wrote:
> "Dr. David Alan Gilbert"  writes:
> 
>> * Bihong Yu (yubih...@huawei.com) wrote:
>>> Signed-off-by: Bihong Yu 
>>> Reviewed-by: Chuan Zheng 
>>
>> Yes that's OK, I'm a bit sturprised we need the space afte rthe * in the
>> VMStateDescription case, I wouldn't necessarily go and change them all.
> 
> We don't: it's not the binary multiplication operator *, where we want a
> space on both sides, it's a pointer declarator, where we want a space on
> the left only.
> 
> Example:
> 
> int *pa, *pb, *pc;
> *pa = *pb * *pc;
> 
> Note the space on both side of binary operator * (multiplication), but
> only on the left side of the pointer declarator's * and the unary
> operator * (indirection).
> 
>> Reviewed-by: Dr. David Alan Gilbert 
> [...]
>>> diff --git a/migration/savevm.c b/migration/savevm.c
>>> index d2e141f..9e95df1 100644
>>> --- a/migration/savevm.c
>>> +++ b/migration/savevm.c
>>> @@ -521,7 +521,7 @@ static const VMStateDescription vmstate_configuration = 
>>> {
>>>  VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len),
>>>  VMSTATE_END_OF_LIST()
>>>  },
>>> -.subsections = (const VMStateDescription*[]) {
>>> +.subsections = (const VMStateDescription * []) {
>>>  _target_page_bits,
>>>  _capabilites,
>>>  _uuid,
> 
> Should be
> 
>.subsections = (const VMStateDescription *[]) {
> 
> [...]
> 
> .
> 



Re: [PATCH] softfloat: Mark base int-to-float routines QEMU_FLATTEN

2020-10-19 Thread Alex Bennée


Richard Henderson  writes:

> This merges the int_to_float routine and the round_pack_canonical
> routine into the same function, allowing the FloatParts structure
> to be decomposed by the compiler.
>
> This results in a 60-75% speedup of the flattened function.
>
> Leave the narrower integer inputs to tail-call the int64_t version.
>
> Buglink: https://bugs.launchpad.net/qemu/+bug/1892081
> Signed-off-by: Richard Henderson 

Reviewed-by: Alex Bennée 

-- 
Alex Bennée



Re: [PATCH v2 03/15] python: add VERSION file

2020-10-19 Thread Daniel P . Berrangé
On Mon, Oct 19, 2020 at 11:45:09AM +0200, Andrea Bolognani wrote:
> On Wed, 2020-10-14 at 10:29 -0400, John Snow wrote:
> > Python infrastructure as it exists today is not capable reliably of
> > single-sourcing a package version from a parent directory. The authors
> > of pip are working to correct this, but as of today this is not possible
> > to my knowledge.
> > 
> > The problem is that when using pip to build and install a python
> > package, it copies files over to a temporary directory and performs its
> > build there. This loses access to any information in the parent
> > directory, including git itself.
> > 
> > Further, Python versions have a standard (PEP 440) that may or may not
> > follow QEMU's versioning. In general, it does; but naturally QEMU does
> > not follow PEP 440. To avoid any automatically-generated conflict, a
> > manual version file is preferred.
> > 
> > 
> > I am proposing:
> > 
> > - Python core tooling synchronizes with the QEMU version directly
> >   (5.2.0, 5.1.1, 5.3.0, etc.)
> > 
> > - In the event that a Python package needs to be updated independently
> >   of the QEMU version, a pre-release alpha version should be preferred,
> >   but *only* after inclusion to the qemu development or stable branches.
> > 
> >   e.g. 5.2.0a1, 5.2.0a2, and so on should be preferred prior to 5.2.0's
> >   release.
> > 
> > - The Python core tooling makes absolutely no version compatibility
> >   checks or constraints. It *may* work with releases of QEMU from the
> >   past or future, but it is not required to.
> > 
> >   i.e., "qemu.core" will always remain in lock-step with QEMU.
> > 
> > - We reserve the right to split out e.g. qemu.core.qmp to qemu.qmp
> >   and begin indepedently versioning such a package separately from the
> >   QEMU version it accompanies.
> 
> I think this need to be considered very carefully.
> 
> I'm not overly familiar with the Python ecosystem but it would appear
> that, despite PEP 440 not mandating this, many (most?) of the
> packages uploaded to PyPi are using semantic versioning.

  
https://packaging.python.org/guides/distributing-packages-using-setuptools/#choosing-a-versioning-scheme

Semver is the recommended approach, but they explicitly list date
based versioning as a valid alternative

  "Semantic versioning is not a suitable choice for all projects, 
   such as those with a regular time based release cadence and a 
   deprecation process that provides warnings for a number of 
   releases prior to removal of a feature."

That paragraph describes QEMU's scenario.

NB, historically we've made arbitrary changes to the python code
since it was not considered public API. If we make it official
public API, then we would actually need to start following our
deprecation process for the python code too.

> With that in mind, I think it would be unwise for qemu.* not to do
> the same; in particular, using a version number that's not <1.0.0 for
> a package that is very much in flux will almost certainly break
> people's expectations, and is also not something that you can easily
> take back at a later time.

I don't think it is that big a deal, and there is clear benefit to
having the python code version match the QEMU version that it is
the companioon to.

Ultimately the versioning scheme just impacts on the version string
conditionals people list for their dependancies. Apps consuming QEMU
can handle any of the version schemes without much difference.

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 :|




  1   2   3   4   5   >