Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 1/3] audio: Move arch_init audio code to hw/audio/soundhw.c

2017-05-08 Thread Thomas Huth
On 08.05.2017 22:57, Eduardo Habkost wrote:
> There's no reason to keep the soundhw table in arch_init.c. Move
> that code to a new hw/audio/soundhw.c file.
> 
> While moving the code, trivial coding style issues were fixed.
> 
> Signed-off-by: Eduardo Habkost 
> ---
> Changes v2 -> v3:
> * Update hw/ppc/prep.c to include hw/audio/audio.h too
> 
> Changes v1 -> v2:
> * Rebase to latest qemu.git master
> ---
>  include/hw/audio/audio.h   |   3 +
>  include/sysemu/arch_init.h |   2 -
>  arch_init.c| 124 ---
>  hw/audio/soundhw.c | 156 
> +
>  hw/ppc/prep.c  |   1 +
>  vl.c   |   1 +
>  hw/audio/Makefile.objs |   2 +
>  7 files changed, 163 insertions(+), 126 deletions(-)
>  create mode 100644 hw/audio/soundhw.c

Good idea!

Reviewed-by: Thomas Huth 




Re: [Qemu-devel] [PATCH] spapr: Don't accidentally advertise HTM support on POWER9

2017-05-08 Thread Thomas Huth
On 09.05.2017 07:04, David Gibson wrote:
> Logic in spapr_populate_pa_features() enables the bit advertising
> Hardware Transactional Memory (HTM) in the guest's device tree only when
> KVM advertises its availability with the KVM_CAP_PPC_HTM feature.
> 
> However, this assumes that the HTM bit is off in the base template used for
> the device tree value.  That is true for POWER8, but not for POWER9.
> 
> It looks like that was accidentally changed in 9fb4541 "spapr: Enable ISA
> 3.0 MMU mode selection via CAS".
> 
> Fixes: 9fb4541f5803f8d2ba116b12113386e26482ba30
> 
> Signed-off-by: David Gibson 
> ---
>  hw/ppc/spapr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index e2dc77c..1b7cada 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -219,7 +219,7 @@ static void spapr_populate_pa_features(CPUPPCState *env, 
> void *fdt, int offset,
>  /* 16: Vector */
>  0x00, 0x00, 0x00, 0x00, 0x80, 0x00, /* 12 - 17 */
>  /* 18: Vec. Scalar, 20: Vec. XOR, 22: HTM */
> -0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 18 - 23 */
> +0x80, 0x00, 0x80, 0x00, 0x00, 0x00, /* 18 - 23 */
>  /* 24: Ext. Dec, 26: 64 bit ftrs, 28: PM ftrs */
>  0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 24 - 29 */
>  /* 30: MMR, 32: LE atomic, 34: EBB + ext EBB */
> 

Reviewed-by: Thomas Huth 




Re: [Qemu-devel] [PATCH V3 05/10] net/net.c: Add vnet header length to SocketReadState

2017-05-08 Thread Jason Wang



On 2017年05月09日 12:03, Zhang Chen wrote:



On 05/09/2017 10:40 AM, Jason Wang wrote:



On 2017年05月08日 11:47, Zhang Chen wrote:



On 05/03/2017 06:42 PM, Jason Wang wrote:



On 2017年05月03日 11:43, Zhang Chen wrote:



On 05/02/2017 12:53 PM, Jason Wang wrote:



On 2017年04月28日 17:47, Zhang Chen wrote:
Address Jason Wang's comments add vnet header length to 
SocketReadState.


Instead of saying this, you can add "Suggested-by: Jason Wang 
" above your sign-off.


OK.




So we change net_fill_rstate() to read
struct  {int size; int vnet_hdr_len; const uint8_t buf[];}.


This makes me thinking about the backward compatibility. I think 
we'd better try to keep it as much as possible. E.g how about 
pack vnet_hdr_len into higher bits of size?




Do you means split uint32_t size to uint16_t size and uint16_t 
vnet_hdr_len ?

If yes, we also can't keep compatibility with old version.
Old code send a uint32_t size, we read it as uint16_t size is 
always wrong.


Thanks
Zhang Chen


Consider it's unlikely to send or receive packet >= 64K, we can 
reuse higher bits (e.g highest 8 bits). Then we can still read 
uint32_t and then check its highest 8 bits. If it was zero, we know 
vnet header is zero, if not it could be read as vnet header length.


I got your point, but in this way, packet size must < 64K, if size 
>=64K we still can't maintain the backward compatibility,
For the packet sender that didn't know the potential packet size 
limit, I think we should make code explicitly declared like
currently code. Otherwise we will make other people confused and 
make code difficult to maintain.


Thanks
Zhang Chen



Yes, this is an possible issue in the future. Rethink about this, 
what if we just compare vnet header? Is there any issue of doing 
this? (Sorry, I remember this is a reason, but forget now).


Yes, we can compare all packet with vnet header, the compare 
performance is very low. but we can't parse raw packet to tcp/udp/icmp 
packet, because we didn't know the vnet_hdr_len as the offset.


Thanks
Zhang Chen


Aha, so I think it's time to use the new format but:

- probably need a new option to enable this support for filter
- let's don't touch socket backend, and make it still can work with 
filters whose vnet_hder is off


Thanks





Thanks


.








Re: [Qemu-devel] [PATCH] Revert "target-ppc/kvm: Enable in-kernel TCE acceleration for multi-tce"

2017-05-08 Thread David Gibson
On Tue, May 09, 2017 at 07:25:51AM +1000, Alexey Kardashevskiy wrote:
> On 09/05/17 06:17, Jose Ricardo Ziviani wrote:
> > This reverts commit 3dc410ae83e6cb76c81ea30a05d62596092b3165.
> > 
> > Booting a radix guest in Power9 with that commit throws a host kernel
> > oops:
> > 
> > [17582052553.360178] Unable to handle kernel paging request for data at 
> > address 0xe64bb17da64ab078
> > [17582052553.360420] Faulting instruction address: 0xc02c3ddc
> > [17582052553.360533] Oops: Kernel access of bad area, sig: 11 [#1]
> > [17582052553.360643] SMP NR_CPUS=1024
> > [17582052553.360645] NUMA
> > [17582052553.360712] PowerNV
> > [17582052553.360804] Modules linked in: vhost_net vhost tap xt_CHECKSUM 
> > ipt_MASQUERADE nf_nat_masquerade_ipv4 ip6t_rpfilter ip6t_REJECT 
> > nf_reject_ipv6 nf_conntrack_ipv6 nf_defrag_ipv6 xt_conntrack ip_set 
> > nfnetlink ebtable_nat ebtable_broute bridge stp llc ip6table_mangle 
> > ip6table_security ip6table_raw iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 
> > nf_nat_ipv4 nf_nat nf_conntrack libcrc32c iptable_mangle iptable_security 
> > iptable_raw ebtable_filter ebtables ip6table_filter ip6_tables ses 
> > enclosure scsi_transport_sas ipmi_powernv powernv_op_panel ipmi_devintf 
> > ipmi_msghandler nfsd kvm_hv auth_rpcgss oid_registry nfs_acl lockd grace 
> > sunrpc kvm tg3 ptp pps_core
> > [17582052553.361797] CPU: 5 PID: 4966 Comm: qemu-system-ppc Not tainted 
> > 4.11.0-1.git4a6869a.el7.centos.ppc64le #1
> > [17582052553.361972] task: c003c5e90a80 task.stack: c003c5f6c000
> > [17582052553.362082] NIP: c02c3ddc LR: c02c3e80 CTR: 
> > c00ce2e0
> > [17582052553.362214] REGS: c003c5f6f150 TRAP: 0380   Not tainted  
> > (4.11.0-1.git4a6869a.el7.centos.ppc64le)
> > [17582052553.362467] MSR: 90001031 
> > [17582052553.362480]   CR: 44008024  XER: 2000
> > [17582052553.362822] CFAR: c02c3e7c SOFTE: 1
> > [17582052553.362822] GPR00: 018f c003c5f6f3d0 
> > c131fd00 
> > [17582052553.362822] GPR04: 0005 01ff 
> >  7db04aa67db14ba6
> > [17582052553.362822] GPR08: 264bb17da64ab000 e64bb17da64ab000 
> > 0078 
> > [17582052553.362822] GPR12: c003bdb98008 cfdc2d00 
> > c000e148 
> > [17582052553.362822] GPR16: 0800 2000 
> >  c003c5f6f4c0
> > [17582052553.362822] GPR20: c0019440 c001fd033280 
> > c001fd0342a0 c001f24efff8
> > [17582052553.362822] GPR24: 0200 0001f24f 
> > 0010 0002
> > [17582052553.362822] GPR28: 0800 0001f24f 
> > 7db04aa6 a64ab07d
> > [17582052553.365148] NIP [c02c3ddc] vmalloc_to_page+0x19c/0x220
> > [17582052553.365365] LR [c02c3e80] vmalloc_to_pfn+0x20/0x50
> > [17582052553.365582] Call Trace:
> > [17582052553.365720] [c003c5f6f3d0] [7265677368657265] 
> > 0x7265677368657265 (unreliable)
> > [17582052553.365982] [c003c5f6f400] [c02c3e80] 
> > vmalloc_to_pfn+0x20/0x50
> > [17582052553.366245] [c003c5f6f420] [c00637e8] 
> > vmalloc_to_phys+0x28/0x60
> > [17582052553.366508] [c003c5f6f450] [c00ce480] 
> > kvmppc_rm_h_put_tce_indirect+0x1a0/0x540
> > [17582052553.366812] [c003c5f6f590] [c00d0314] 
> > hcall_try_real_mode+0x60/0x7c
> > [17582052553.367074] [c003c5f6f600] [c00cefac] 
> > kvmppc_call_hv_entry+0x8/0x17c
> > [17582052553.367346] [c003c5f6f670] [c0080375a970] 
> > __kvmppc_vcore_entry+0x13c/0x1ac [kvm_hv]
> > [17582052553.367652] [c003c5f6f840] [c008037574a8] 
> > kvmppc_run_core+0x788/0x1650 [kvm_hv]
> > [17582052553.367965] [c003c5f6fa00] [c008037590b8] 
> > kvmppc_vcpu_run_hv+0x388/0x1200 [kvm_hv]
> > [17582052553.368287] [c003c5f6fb30] [c00803274684] 
> > kvmppc_vcpu_run+0x34/0x50 [kvm]
> > [17582052553.368558] [c003c5f6fb50] [c00803270b54] 
> > kvm_arch_vcpu_ioctl_run+0x114/0x2a0 [kvm]
> > [17582052553.368870] [c003c5f6fbd0] [c00803263dd8] 
> > kvm_vcpu_ioctl+0x5e8/0x7c0 [kvm]
> > [17582052553.369132] [c003c5f6fd40] [c0350b50] 
> > do_vfs_ioctl+0xd0/0x8c0
> > [17582052553.369395] [c003c5f6fde0] [c0351414] 
> > SyS_ioctl+0xd4/0xf0
> > [17582052553.369615] [c003c5f6fe30] [c000b8e0] 
> > system_call+0x38/0xfc
> > [17582052553.369875] Instruction dump:
> > [17582052553.370011] 53dfc42e 790807c6 394a 7d08fb78 78638402 79081764 
> > 7d4a07b4 7c6a5038
> > [17582052553.370281] 7908f5e6 7d094b78 794a1f24 3860 <7d2a482a> 
> > 7924cfe3 41820040 79260022
> > [17582052553.370599] ---[ end trace 9470442ed18ae727 ]---
> > 
> > As soon as we identify and fix the issue that's causing such problem
> > I'll re-send the referred patch to re-enable TCE.

This is a serious host kernel security bug.  Modifying qemu not to
trigger it is not a 

Re: [Qemu-devel] [RFC PATCH 02/11] hw/pci: define msi_nonbroken in pci-stub

2017-05-08 Thread Thomas Huth
On 09.05.2017 01:39, Philippe Mathieu-Daudé wrote:
> This field is accessed in hw/intc/arm_gicv[23*].c

default-configs/arm-softmmu.mak sets CONFIG_PCI, so this should not be
necessary, I think. Otherwise, you should extend your patch description,
to elaborate on what you're trying to do here.

 Thomas




[Qemu-devel] [PATCH] spapr: Don't accidentally advertise HTM support on POWER9

2017-05-08 Thread David Gibson
Logic in spapr_populate_pa_features() enables the bit advertising
Hardware Transactional Memory (HTM) in the guest's device tree only when
KVM advertises its availability with the KVM_CAP_PPC_HTM feature.

However, this assumes that the HTM bit is off in the base template used for
the device tree value.  That is true for POWER8, but not for POWER9.

It looks like that was accidentally changed in 9fb4541 "spapr: Enable ISA
3.0 MMU mode selection via CAS".

Fixes: 9fb4541f5803f8d2ba116b12113386e26482ba30

Signed-off-by: David Gibson 
---
 hw/ppc/spapr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e2dc77c..1b7cada 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -219,7 +219,7 @@ static void spapr_populate_pa_features(CPUPPCState *env, 
void *fdt, int offset,
 /* 16: Vector */
 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, /* 12 - 17 */
 /* 18: Vec. Scalar, 20: Vec. XOR, 22: HTM */
-0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 18 - 23 */
+0x80, 0x00, 0x80, 0x00, 0x00, 0x00, /* 18 - 23 */
 /* 24: Ext. Dec, 26: 64 bit ftrs, 28: PM ftrs */
 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 24 - 29 */
 /* 30: MMR, 32: LE atomic, 34: EBB + ext EBB */
-- 
2.9.3




Re: [Qemu-devel] [Qemu-ppc] [PATCH] target/ppc: Avoid printing wrong aliases in CPU help text

2017-05-08 Thread Thomas Huth
On 08.03.2017 20:05, Thomas Huth wrote:
> When running with KVM, we update the "family" CPU alias to point
> to the right host CPU type, so that it is for example possible to
> use "-cpu POWER8" on a POWER8NVL host. However, the function for
> printing the list of available CPU models is called earlier than
> the KVM setup code, so the output of "-cpu help" is wrong in that
> case. Since it would be somewhat ugly anyway to have different
> help texts depending on whether "-enable-kvm" has been specified
> or not, we should better always print the same text, so fix this
> issue by printing "alias for preferred XXX CPU" instead.
> 
> Signed-off-by: Thomas Huth 
> ---
>  target/ppc/cpu.h|  1 +
>  target/ppc/kvm.c| 12 
>  target/ppc/translate_init.c | 27 +--
>  3 files changed, 26 insertions(+), 14 deletions(-)
> 
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 7c4a1f5..21752ff 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1216,6 +1216,7 @@ static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState 
> *env)
>  
>  PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr);
>  PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr);
> +PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc);
>  
>  struct PPCVirtualHypervisor {
>  Object parent;
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 9f1f132..585e6d3 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2304,18 +2304,6 @@ bool kvmppc_has_cap_htm(void)
>  return cap_htm;
>  }
>  
> -static PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc)
> -{
> -ObjectClass *oc = OBJECT_CLASS(pcc);
> -
> -while (oc && !object_class_is_abstract(oc)) {
> -oc = object_class_get_parent(oc);
> -}
> -assert(oc);
> -
> -return POWERPC_CPU_CLASS(oc);
> -}
> -
>  PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
>  {
>  uint32_t host_pvr = mfpvr();
> diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
> index c1a9014..9e9c37f 100644
> --- a/target/ppc/translate_init.c
> +++ b/target/ppc/translate_init.c
> @@ -10249,6 +10249,18 @@ PowerPCCPU *cpu_ppc_init(const char *cpu_model)
>  return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model));
>  }
>  
> +PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc)
> +{
> +ObjectClass *oc = OBJECT_CLASS(pcc);
> +
> +while (oc && !object_class_is_abstract(oc)) {
> +oc = object_class_get_parent(oc);
> +}
> +assert(oc);
> +
> +return POWERPC_CPU_CLASS(oc);
> +}
> +
>  /* Sort by PVR, ordering special case "host" last. */
>  static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b)
>  {
> @@ -10280,6 +10292,7 @@ static void ppc_cpu_list_entry(gpointer data, 
> gpointer user_data)
>  ObjectClass *oc = data;
>  CPUListState *s = user_data;
>  PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
> +DeviceClass *family = DEVICE_CLASS(ppc_cpu_get_family_class(pcc));
>  const char *typename = object_class_get_name(oc);
>  char *name;
>  int i;
> @@ -10302,8 +10315,18 @@ static void ppc_cpu_list_entry(gpointer data, 
> gpointer user_data)
>  if (alias_oc != oc) {
>  continue;
>  }
> -(*s->cpu_fprintf)(s->file, "PowerPC %-16s (alias for %s)\n",
> -  alias->alias, name);
> +/*
> + * If running with KVM, we might update the family alias later, so
> + * avoid printing the wrong alias here and use "preferred" instead
> + */
> +if (strcmp(alias->alias, family->desc) == 0) {
> +(*s->cpu_fprintf)(s->file,
> +  "PowerPC %-16s (alias for preferred %s CPU)\n",
> +  alias->alias, family->desc);
> +} else {
> +(*s->cpu_fprintf)(s->file, "PowerPC %-16s (alias for %s)\n",
> +  alias->alias, name);
> +}
>  }
>  g_free(name);
>  }
> 

Ping!

... I think this got somehow lost in the 2.9 rush ...

 Thomas




Re: [Qemu-devel] [PATCH 0/3] kvm: irqchip: skip msi update when msi disabled

2017-05-08 Thread no-reply
Hi,

This series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.

Subject: [Qemu-devel] [PATCH 0/3] kvm: irqchip: skip msi update when msi 
disabled
Type: series
Message-id: 1494304108-9805-1-git-send-email-pet...@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-mingw@fedora
time make docker-test-build@min-glib
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag] patchew/1494304108-9805-1-git-send-email-pet...@redhat.com 
-> patchew/1494304108-9805-1-git-send-email-pet...@redhat.com
 - [tag update]  patchew/20170508180705.20609-1-stefa...@redhat.com -> 
patchew/20170508180705.20609-1-stefa...@redhat.com
Switched to a new branch 'test'
a0142b6 kvm: irqchip: skip update msi when disabled
76598e9 msix: trace control bit write op
ba36235 kvm: irqchip: trace changes on msi add/remove

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-u9m5b1f4/src/dtc'...
Submodule path 'dtc': checked out '558cd81bdd432769b59bff01240c44f82cfb1a9d'
  BUILD   centos6
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-u9m5b1f4/src'
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  COPYRUNNER
RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
gcc-4.4.7-17.el6.x86_64
git-1.7.1-4.el6_7.1.x86_64
glib2-devel-2.28.8-5.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=libfdt-devel ccache tar git make gcc g++ zlib-devel 
glib2-devel SDL-devel pixman-devel epel-release
HOSTNAME=05429a3bc711
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu 
--prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code
Install prefix/var/tmp/qemu-build/install
BIOS directory/var/tmp/qemu-build/install/share/qemu
binary directory  /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib
module directory  /var/tmp/qemu-build/install/lib/qemu
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory  /var/tmp/qemu-build/install/etc
local state directory   /var/tmp/qemu-build/install/var
Manual directory  /var/tmp/qemu-build/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path   /tmp/qemu-test/src
C compilercc
Host C compiler   cc
C++ compiler  
Objective-C compiler cc
ARFLAGS   rv
CFLAGS-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g 
QEMU_CFLAGS   -I/usr/include/pixman-1   -I$(SRC_PATH)/dtc/libfdt -pthread 
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -fPIE -DPIE -m64 -mcx16 
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
-fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels 
-Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security 
-Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration 
-Wold-style-definition -Wtype-limits -fstack-protector-all
LDFLAGS   -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
make  make
install   install
pythonpython -B
smbd  /usr/sbin/smbd
module supportno
host CPU  x86_64
host big endian   no
target list   x86_64-softmmu aarch64-softmmu
tcg debug enabled no
gprof enabled no
sparse enabledno
strip binariesyes
profiler  no
static build  no
pixmansystem
SDL support   yes (1.2.14)
GTK support   no 
GTK GL supportno
VTE support   no 
TLS priority  NORMAL
GNUTLS supportno
GNUTLS rndno
libgcrypt no
libgcrypt kdf no
nettleno 
nettle kdfno
libtasn1  no
curses supportno
virgl support no
curl support  no
mingw32 support   no
Audio drivers oss
Block whitelist (rw) 
Block whitelist (ro) 
VirtFS supportno
VNC 

Re: [Qemu-devel] [PATCH v3 2/3] audio: Rename audio_init() to soundhw_init()

2017-05-08 Thread Hervé Poussineau

Le 08/05/2017 à 22:57, Eduardo Habkost a écrit :

To make it consistent with the remaining soundhw.c functions and
avoid confusion with the audio_init() function in audio/audio.c,
rename audio_init() to soundhw_init().

Signed-off-by: Eduardo Habkost 


You should probably add a patch before 1/3 to remove the two 
audio_init()/soundhw_init() calls in hw/ppc/prep.c.
That way, you won't need to change hw/ppc/prep.c in 1/3 and 2/3.

Regards,

Hervé

---
Changes v2 -> v3:
* Update hw/ppc/prep.c audio_init() call too

Changes v1 -> v2:
* Rebase to latest qemu.git master
---
 include/hw/audio/audio.h | 2 +-
 hw/audio/soundhw.c   | 2 +-
 hw/ppc/prep.c| 2 +-
 vl.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/hw/audio/audio.h b/include/hw/audio/audio.h
index 259bb2cf96..119f7d78d5 100644
--- a/include/hw/audio/audio.h
+++ b/include/hw/audio/audio.h
@@ -7,7 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
 void pci_register_soundhw(const char *name, const char *descr,
   int (*init_pci)(PCIBus *bus));

-void audio_init(void);
+void soundhw_init(void);
 void select_soundhw(const char *optarg);

 #endif
diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c
index 5e96b73c81..29565da93d 100644
--- a/hw/audio/soundhw.c
+++ b/hw/audio/soundhw.c
@@ -129,7 +129,7 @@ void select_soundhw(const char *optarg)
 }
 }

-void audio_init(void)
+void soundhw_init(void)
 {
 struct soundhw *c;
 ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, 
NULL);
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 96a4813b3f..4a7d2cfbe0 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -783,7 +783,7 @@ static void ibm_40p_init(MachineState *machine)
_checksum);

 /* initialize audio subsystem */
-audio_init();
+soundhw_init();

 /* add some more devices */
 if (defaults_enabled()) {
diff --git a/vl.c b/vl.c
index a2400e1ab6..42fd66ac0d 100644
--- a/vl.c
+++ b/vl.c
@@ -4569,7 +4569,7 @@ int main(int argc, char **argv, char **envp)

 realtime_init();

-audio_init();
+soundhw_init();

 if (hax_enabled()) {
 hax_sync_vcpus();






Re: [Qemu-devel] [PATCH] target/ppc: Allow workarounds for POWER9 DD1

2017-05-08 Thread Thomas Huth
On 09.05.2017 05:45, David Gibson wrote:
> POWER9 DD1 silicon has some bugs which mean it a) isn't really compliant
> with the ISA v3.00 and b) require a number of special workarounds in the
> kernel.
> 
> At the moment, qemu isn't aware of DD1.  For TCG we don't really want it to
> be (why bother emulating buggy silicon).  But with KVM, the guest does need
> to be aware of DD1 so it can apply the necessary workarounds.
> 
> Meanwhile, the feature negotiation between qemu and the guest strongly
> favours architected compatibility modes to "raw" CPU modes.  In combination
> with the above, this means the guest sees architected POWER9 mode, and
> doesn't apply the DD1 workarounds.  Well, unless it has yet another
> workaround to partially ignore what qemu tells it.
> 
> This patch addresses this by disabling support for compatibility modes when
> using KVM on a POWER9 DD1 host.

I first though: Hey, it should be fixed in the guest kernel instead, but
thinking about this twice, I think you're right. If the CPU is not fully
compatible to the ISA, we really should not announce it as "architected
/ compatible POWER9" in QEMU.
So basically ACK to your patch, I've just got a cosmetic request below...

> Signed-off-by: David Gibson 
> ---
>  target/ppc/kvm.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 8574c36..591b5b5 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2380,6 +2380,17 @@ static void kvmppc_host_cpu_class_init(ObjectClass 
> *oc, void *data)
>  
>  #if defined(TARGET_PPC64)
>  pcc->radix_page_info = kvm_get_radix_page_info();
> +
> +if ((pcc->pvr & 0xff00) == 0x004e0100) {

Could you please add a proper #define for that magic DD1.0 value to
cpu-models.h, please?

 Thanks,
  Thomas




Re: [Qemu-devel] [PATCH v3 3/3] audio: Rename hw/audio/audio.h to hw/audio/soundhw.h

2017-05-08 Thread Hervé Poussineau

Le 08/05/2017 à 22:57, Eduardo Habkost a écrit :

All the functions in hw/audio/audio.h are called "soundhw_*()"
and live in hw/audio/audiohw.c. Rename the header file for
consistency.

Signed-off-by: Eduardo Habkost 


Reviewed-by: Hervé Poussineau 


---
Changes v2 -> v3:
* Update header name at hw/ppc/prep.c too

Changes v1 -> v2:
* Rebase to latest qemu.git master
---
 include/hw/audio/{audio.h => soundhw.h} | 0
 arch_init.c | 2 +-
 hw/audio/ac97.c | 2 +-
 hw/audio/adlib.c| 2 +-
 hw/audio/cs4231a.c  | 2 +-
 hw/audio/es1370.c   | 2 +-
 hw/audio/gus.c  | 2 +-
 hw/audio/intel-hda.c| 2 +-
 hw/audio/pcspk.c| 2 +-
 hw/audio/sb16.c | 2 +-
 hw/audio/soundhw.c  | 2 +-
 hw/ppc/prep.c   | 2 +-
 vl.c| 2 +-
 13 files changed, 12 insertions(+), 12 deletions(-)
 rename include/hw/audio/{audio.h => soundhw.h} (100%)

diff --git a/include/hw/audio/audio.h b/include/hw/audio/soundhw.h
similarity index 100%
rename from include/hw/audio/audio.h
rename to include/hw/audio/soundhw.h
diff --git a/arch_init.c b/arch_init.c
index 74ca62f508..a0b8ed6167 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -27,7 +27,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/arch_init.h"
 #include "hw/pci/pci.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "qmp-commands.h"
diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
index c30657501c..959c786261 100644
--- a/hw/audio/ac97.c
+++ b/hw/audio/ac97.c
@@ -19,7 +19,7 @@

 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/pci/pci.h"
 #include "sysemu/dma.h"
diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c
index 09b8248cda..c6e0f10c16 100644
--- a/hw/audio/adlib.c
+++ b/hw/audio/adlib.c
@@ -25,7 +25,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"

diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
index 3ecd0582bf..096e8e98d7 100644
--- a/hw/audio/cs4231a.c
+++ b/hw/audio/cs4231a.c
@@ -23,7 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev.h"
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index fe64c1ac37..dd7c23d185 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -28,7 +28,7 @@

 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/pci/pci.h"
 #include "sysemu/dma.h"
diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index ec103a4db9..3e864cd36d 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -24,7 +24,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "gusemu.h"
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 2c497eb174..06acc98f7b 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -22,7 +22,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/msi.h"
 #include "qemu/timer.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "intel-hda.h"
 #include "intel-hda-defs.h"
 #include "sysemu/dma.h"
diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index 798002277b..c815a2b9ca 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -26,7 +26,7 @@
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "qemu/timer.h"
 #include "hw/timer/i8254.h"
diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 6b4427f242..6ab2f6f89a 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -23,7 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev.h"
diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c
index 29565da93d..e698909d34 100644
--- a/hw/audio/soundhw.c
+++ b/hw/audio/soundhw.c
@@ -28,7 +28,7 @@
 #include "qom/object.h"
 #include "hw/isa/isa.h"
 #include "hw/pci/pci.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"

 struct soundhw {
 const char *name;
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 4a7d2cfbe0..d16646c95d 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -36,7 +36,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/ppc.h"
 #include "hw/boards.h"
-#include "hw/audio/audio.h"

[Qemu-devel] timer configure for QEMU versatilepb

2017-05-08 Thread heavybird
Hi Peter and qemu-devel,

I am trying to port one simple RTOS to QEMU versatilepb,  however, i found the 
SIC address(actually PIC) is different from the PIC in the integratorcp.c even 
though they are same arm926, besides, the PIC register bit definition is some 
different between versatilepb and integratorcp compared by the 
icp_pic_read/icp_pic_read interface.

1 address defferent between versatilepb and integratorcp
  versatilepb integratorcp
TIMER_0 adress 0x101e2000   0x1300
ADDRESS_PIC 0x10003000 0x1400

i had tried the 2 address above to turn on the timer0 but it is failed with 
versatilepb, it is ok to turn on the integratorcp timer0 with 0x1300 timer0 
addr and 0x1400 for PIC.

2 PIC register bit difference after bit8


2.1 intergratorcp definition
case 8: /* FRQ_STATUS */
return s->level & s->fiq_enabled;
case 9: /* FRQ_RAWSTAT */
return s->level;
case 10: /* FRQ_ENABLESET */
return s->fiq_enabled;
case 11: /* FRQ_ENABLECLR */

   versatilepb SIC definition 
case 8: /* PICENABLE */
return s->pic_enable;
case 9: /* PICENCLR */
s->pic_enable &= ~value;
vpb_sic_update_pic(s);
break;

Could you confirm for me PIC register bit definition and the PIC address/timer0 
address in the versatilepb QEMU or where i can find some information exactly.

thanks
jason

[Qemu-devel] [PATCH 3/3] kvm: irqchip: skip update msi when disabled

2017-05-08 Thread Peter Xu
It's possible that one device kept its irqfd/virq there even when
MSI/MSIX was disabled globally for that device. One example is
virtio-net-pci (see commit f1d0f15a6 and virtio_pci_vq_vector_mask()).
It is used as a fast path to avoid allocate/release irqfd/virq
frequently when guest enables/disables MSIX.

However, this fast path brought a problem to msi_route_list, that the
device MSIRouteEntry is still dangling there even if MSIX disabled -
then we cannot know which message to fetch, even if we can, the messages
are meaningless. In this case, we can just simply ignore this entry.

It's safe, since when MSIX is enabled again, we'll rebuild them no
matter what.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1448813

Signed-off-by: Peter Xu 
---
 target/i386/kvm.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 55865db..3a85b54 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -3510,12 +3510,16 @@ static void kvm_update_msi_routes_all(void *private, 
bool global,
 int cnt = 0;
 MSIRouteEntry *entry;
 MSIMessage msg;
+PCIDevice *dev;
+
 /* TODO: explicit route update */
 QLIST_FOREACH(entry, _route_list, list) {
-cnt++;
-msg = pci_get_msi_message(entry->dev, entry->vector);
-kvm_irqchip_update_msi_route(kvm_state, entry->virq,
- msg, entry->dev);
+dev = entry->dev;
+if (!msix_enabled(dev) && !msi_enabled(dev)) {
+continue;
+}
+msg = pci_get_msi_message(dev, entry->vector);
+kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev);
 }
 kvm_irqchip_commit_routes(kvm_state);
 trace_kvm_x86_update_msi_routes(cnt);
-- 
2.7.4




[Qemu-devel] [PATCH 1/3] kvm: irqchip: trace changes on msi add/remove

2017-05-08 Thread Peter Xu
It'll be nice to know which virq belongs to which device/vector when
adding msi routes, so adding two more parameters for the add trace.

Meanwhile, releasing virq has no tracing before. Add one for it.

Signed-off-by: Peter Xu 
---
 kvm-all.c| 4 +++-
 trace-events | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 90b8573..2598b1f 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1144,6 +1144,7 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)
 }
 clear_gsi(s, virq);
 kvm_arch_release_virq_post(virq);
+trace_kvm_irqchip_release_virq(virq);
 }
 
 static unsigned int kvm_hash_msi(uint32_t data)
@@ -1287,7 +1288,8 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, 
PCIDevice *dev)
 return -EINVAL;
 }
 
-trace_kvm_irqchip_add_msi_route(virq);
+trace_kvm_irqchip_add_msi_route(dev ? dev->name : (char *)"N/A",
+vector, virq);
 
 kvm_add_routing_entry(s, );
 kvm_arch_add_msi_route_post(, vector, dev);
diff --git a/trace-events b/trace-events
index e582d63..f01ec05 100644
--- a/trace-events
+++ b/trace-events
@@ -69,8 +69,9 @@ kvm_device_ioctl(int fd, int type, void *arg) "dev fd %d, 
type 0x%x, arg %p"
 kvm_failed_reg_get(uint64_t id, const char *msg) "Warning: Unable to retrieve 
ONEREG %" PRIu64 " from KVM: %s"
 kvm_failed_reg_set(uint64_t id, const char *msg) "Warning: Unable to set 
ONEREG %" PRIu64 " to KVM: %s"
 kvm_irqchip_commit_routes(void) ""
-kvm_irqchip_add_msi_route(int virq) "Adding MSI route virq=%d"
+kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector %d 
virq %d"
 kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=%d"
+kvm_irqchip_release_virq(int virq) "virq %d"
 
 # TCG related tracing (mostly disabled by default)
 # cpu-exec.c
-- 
2.7.4




[Qemu-devel] [PATCH 0/3] kvm: irqchip: skip msi update when msi disabled

2017-05-08 Thread Peter Xu
First two patches are new traces, please collect them if needed.

The third patch is a fix to a qemu crash reported here:

  https://bugzilla.redhat.com/show_bug.cgi?id=1448813

Please see its commit message for more information.

Please review. Thanks.

Peter Xu (3):
  kvm: irqchip: trace changes on msi add/remove
  msix: trace control bit write op
  kvm: irqchip: skip update msi when disabled

 hw/pci/msix.c   | 11 +--
 hw/pci/trace-events |  3 +++
 kvm-all.c   |  4 +++-
 target/i386/kvm.c   | 12 
 trace-events|  3 ++-
 5 files changed, 25 insertions(+), 8 deletions(-)

-- 
2.7.4




[Qemu-devel] [PATCH 2/3] msix: trace control bit write op

2017-05-08 Thread Peter Xu
Meanwhile, abstract a function to detect msix masked bit.

Signed-off-by: Peter Xu 
---
 hw/pci/msix.c   | 11 +--
 hw/pci/trace-events |  3 +++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index bb54e8b..fc5fe51 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -22,6 +22,7 @@
 #include "hw/xen/xen.h"
 #include "qemu/range.h"
 #include "qapi/error.h"
+#include "trace.h"
 
 #define MSIX_CAP_LENGTH 12
 
@@ -130,10 +131,14 @@ static void msix_handle_mask_update(PCIDevice *dev, int 
vector, bool was_masked)
 }
 }
 
+static bool msix_masked(PCIDevice *dev)
+{
+return dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] & 
MSIX_MASKALL_MASK;
+}
+
 static void msix_update_function_masked(PCIDevice *dev)
 {
-dev->msix_function_masked = !msix_enabled(dev) ||
-(dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] & MSIX_MASKALL_MASK);
+dev->msix_function_masked = !msix_enabled(dev) || msix_masked(dev);
 }
 
 /* Handle MSI-X capability config write. */
@@ -148,6 +153,8 @@ void msix_write_config(PCIDevice *dev, uint32_t addr,
 return;
 }
 
+trace_msix_write_config(dev->name, msix_enabled(dev), msix_masked(dev));
+
 was_masked = dev->msix_function_masked;
 msix_update_function_masked(dev);
 
diff --git a/hw/pci/trace-events b/hw/pci/trace-events
index 2b9cf24..83c8f5a 100644
--- a/hw/pci/trace-events
+++ b/hw/pci/trace-events
@@ -7,3 +7,6 @@ pci_update_mappings_add(void *d, uint32_t bus, uint32_t slot, 
uint32_t func, int
 # hw/pci/pci_host.c
 pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs, 
unsigned val) "%s %02u:%u @0x%x -> 0x%x"
 pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned offs, 
unsigned val) "%s %02u:%u @0x%x <- 0x%x"
+
+# hw/pci/msix.c
+msix_write_config(char *name, bool enabled, bool masked) "dev %s enabled %d 
masked %d"
-- 
2.7.4




Re: [Qemu-devel] [PATCH v3] aio: add missing aio_notify() to aio_enable_external()

2017-05-08 Thread Fam Zheng
On Mon, 05/08 14:07, Stefan Hajnoczi wrote:
> The main loop uses aio_disable_external()/aio_enable_external() to
> temporarily disable processing of external AioContext clients like
> device emulation.
> 
> This allows monitor commands to quiesce I/O and prevent the guest from
> submitting new requests while a monitor command is in progress.
> 
> The aio_enable_external() API is currently broken when an IOThread is in
> aio_poll() waiting for fd activity when the main loop re-enables
> external clients.  Incrementing ctx->external_disable_cnt does not wake
> the IOThread from ppoll(2) so fd processing remains suspended and leads
> to unresponsive emulated devices.
> 
> This patch adds an aio_notify() call to aio_enable_external() so the
> IOThread is kicked out of ppoll(2) and will re-arm the file descriptors.
> 
> The bug can be reproduced as follows:
> 
>   $ qemu -M accel=kvm -m 1024 \
>  -object iothread,id=iothread0 \
>  -device virtio-scsi-pci,iothread=iothread0,id=virtio-scsi-pci0 \
>  -drive 
> if=none,id=drive0,aio=native,cache=none,format=raw,file=test.img \
>  -device scsi-hd,id=scsi-hd0,drive=drive0 \
>  -qmp tcp::,server,nowait
> 
>   $ scripts/qmp/qmp-shell localhost:
>   (qemu) blockdev-snapshot-sync device=drive0 snapshot-file=sn1.qcow2
>  mode=absolute-paths format=qcow2
> 
> After blockdev-snapshot-sync completes the SCSI disk will be
> unresponsive.  This leads to request timeouts inside the guest.
> 
> Reported-by: Qianqian Zhu 
> Suggested-by: Fam Zheng 
> Signed-off-by: Stefan Hajnoczi 
> ---
> v3:
>  * s/dec_fetch/fetch_dec/ [Fam]
> ---
>  include/block/aio.h | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/include/block/aio.h b/include/block/aio.h
> index 406e323..e9aeeae 100644
> --- a/include/block/aio.h
> +++ b/include/block/aio.h
> @@ -454,8 +454,14 @@ static inline void aio_disable_external(AioContext *ctx)
>   */
>  static inline void aio_enable_external(AioContext *ctx)
>  {
> -assert(ctx->external_disable_cnt > 0);
> -atomic_dec(>external_disable_cnt);
> +int old;
> +
> +old = atomic_fetch_dec(>external_disable_cnt);
> +assert(old > 0);
> +if (old == 1) {
> +/* Kick event loop so it re-arms file descriptors */
> +aio_notify(ctx);
> +}
>  }
>  
>  /**
> -- 
> 2.9.3
> 

The patchew failure doesn't seem to relate to this patch, at least I cannot
reproduce it. The patch looks good to me now!

Reviewed-by: Fam Zheng 



Re: [Qemu-devel] [PATCH v2 05/21] docker: compact debian base

2017-05-08 Thread Fam Zheng
On Mon, 05/08 19:17, Philippe Mathieu-Daudé wrote:
> - install common/basic tools at once
> - use eatmydata and remove apt cache to save space
> - add bison and flex and git
> - create deb-src entry and setup Emdebian in the same layer
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  tests/docker/dockerfiles/debian.docker | 26 +-
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/tests/docker/dockerfiles/debian.docker 
> b/tests/docker/dockerfiles/debian.docker
> index d08def6a8d..dcded3ce84 100644
> --- a/tests/docker/dockerfiles/debian.docker
> +++ b/tests/docker/dockerfiles/debian.docker
> @@ -9,17 +9,17 @@
>  #
>  FROM debian:stable-slim
>  
> -# Setup some basic tools we need
> -RUN apt update
> -RUN apt install -yy aptitude ca-certificates curl
> +# Install some basic tools and common build utilities
> +RUN apt-get update && \
> +DEBIAN_FRONTEND=noninteractive apt-get install -yy \
> +eatmydata && \
> +DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
> --no-install-recommends \
> +aptitude ca-certificates curl \
> +build-essential clang git \
> +bison flex && \
> +apt-get clean

Any particular reason to make multiple "RUN" directives into one?

Fam

>  
> -# Setup Emdebian
> -RUN echo "deb http://emdebian.org/tools/debian/ jessie main" >> 
> /etc/apt/sources.list
> -RUN curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | 
> apt-key add -
> -
> -# Duplicate deb line as deb-src
> -RUN cat /etc/apt/sources.list | sed "s/deb/deb-src/" >> /etc/apt/sources.list
> -
> -# Install common build utilities
> -RUN apt update
> -RUN apt install -yy build-essential clang
> +# Duplicate deb line as deb-src, setup Emdebian
> +RUN cat /etc/apt/sources.list | sed "s/deb/deb-src/" >> 
> /etc/apt/sources.list && \
> +echo "deb http://emdebian.org/tools/debian/ jessie main" >> 
> /etc/apt/sources.list && \
> +curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | 
> apt-key add -
> -- 
> 2.11.0
> 



Re: [Qemu-devel] [PATCH V3 05/10] net/net.c: Add vnet header length to SocketReadState

2017-05-08 Thread Zhang Chen



On 05/09/2017 10:40 AM, Jason Wang wrote:



On 2017年05月08日 11:47, Zhang Chen wrote:



On 05/03/2017 06:42 PM, Jason Wang wrote:



On 2017年05月03日 11:43, Zhang Chen wrote:



On 05/02/2017 12:53 PM, Jason Wang wrote:



On 2017年04月28日 17:47, Zhang Chen wrote:
Address Jason Wang's comments add vnet header length to 
SocketReadState.


Instead of saying this, you can add "Suggested-by: Jason Wang 
" above your sign-off.


OK.




So we change net_fill_rstate() to read
struct  {int size; int vnet_hdr_len; const uint8_t buf[];}.


This makes me thinking about the backward compatibility. I think 
we'd better try to keep it as much as possible. E.g how about pack 
vnet_hdr_len into higher bits of size?




Do you means split uint32_t size to uint16_t size and uint16_t 
vnet_hdr_len ?

If yes, we also can't keep compatibility with old version.
Old code send a uint32_t size, we read it as uint16_t size is 
always wrong.


Thanks
Zhang Chen


Consider it's unlikely to send or receive packet >= 64K, we can 
reuse higher bits (e.g highest 8 bits). Then we can still read 
uint32_t and then check its highest 8 bits. If it was zero, we know 
vnet header is zero, if not it could be read as vnet header length.


I got your point, but in this way, packet size must < 64K, if size 
>=64K we still can't maintain the backward compatibility,
For the packet sender that didn't know the potential packet size 
limit, I think we should make code explicitly declared like
currently code. Otherwise we will make other people confused and make 
code difficult to maintain.


Thanks
Zhang Chen



Yes, this is an possible issue in the future. Rethink about this, what 
if we just compare vnet header? Is there any issue of doing this? 
(Sorry, I remember this is a reason, but forget now).


Yes, we can compare all packet with vnet header, the compare performance 
is very low. but we can't parse raw packet to tcp/udp/icmp packet, 
because we didn't know the vnet_hdr_len as the offset.


Thanks
Zhang Chen



Thanks


.



--
Thanks
Zhang Chen






Re: [Qemu-devel] [PATCH v2 02/21] docker: add --include-file argument to 'build' command

2017-05-08 Thread Fam Zheng
On Mon, 05/08 19:17, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  tests/docker/Makefile.include | 3 ++-
>  tests/docker/docker.py| 5 +
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
> index 03eda37bf4..c99ce702ea 100644
> --- a/tests/docker/Makefile.include
> +++ b/tests/docker/Makefile.include
> @@ -51,7 +51,8 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
>   $(SRC_PATH)/tests/docker/docker.py build qemu:$* $< \
>   $(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \
>   $(if $(NOUSER),,--add-current-user) \
> - $(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\
> + $(if $(EXECUTABLE),--include-executable=$(EXECUTABLE))\
> + $(if $(EXTRA_FILE),--include-file=$(EXTRA_FILE)),\
>   "BUILD","$*")
>  
>  # Enforce dependancies for composite images
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 6ddc6e4c2a..90520e4bca 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -237,6 +237,9 @@ class BuildCommand(SubCommand):
>  help="""Specify a binary that will be copied to 
> the
>  container together with all its dependent
>  libraries""")
> +parser.add_argument("--include-file", "-f",
> +help="""Specify a file that will be copied to the
> +container""")

Is it more useful if it's '--include-files' that accepts multiple files? Or
alternatively allow this option to be use multiple times:

-f foo -f bar -f ...

Similarly, should EXTRA_FILE be EXTRA_FILES or something?

We are already lacking this with --include-executable's documentation, but
please also document "where" is it copied to in the container's filesystem.

Fam

>  parser.add_argument("--add-current-user", "-u", dest="user",
>  action="store_true",
>  help="Add the current user to image's passwd")
> @@ -274,6 +277,8 @@ class BuildCommand(SubCommand):
>  if args.include_executable:
>  _copy_binary_with_libs(args.include_executable,
> docker_dir)
> +if args.include_file:
> +_copy_with_mkdir(args.include_file, docker_dir)
>  
>  argv += ["--build-arg=" + k.lower() + "=" + v
>  for k, v in os.environ.iteritems()
> -- 
> 2.11.0
> 




[Qemu-devel] [PATCH] target/ppc: Allow workarounds for POWER9 DD1

2017-05-08 Thread David Gibson
POWER9 DD1 silicon has some bugs which mean it a) isn't really compliant
with the ISA v3.00 and b) require a number of special workarounds in the
kernel.

At the moment, qemu isn't aware of DD1.  For TCG we don't really want it to
be (why bother emulating buggy silicon).  But with KVM, the guest does need
to be aware of DD1 so it can apply the necessary workarounds.

Meanwhile, the feature negotiation between qemu and the guest strongly
favours architected compatibility modes to "raw" CPU modes.  In combination
with the above, this means the guest sees architected POWER9 mode, and
doesn't apply the DD1 workarounds.  Well, unless it has yet another
workaround to partially ignore what qemu tells it.

This patch addresses this by disabling support for compatibility modes when
using KVM on a POWER9 DD1 host.

Signed-off-by: David Gibson 
---
 target/ppc/kvm.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 8574c36..591b5b5 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2380,6 +2380,17 @@ static void kvmppc_host_cpu_class_init(ObjectClass *oc, 
void *data)
 
 #if defined(TARGET_PPC64)
 pcc->radix_page_info = kvm_get_radix_page_info();
+
+if ((pcc->pvr & 0xff00) == 0x004e0100) {
+/*
+ * POWER9 DD1 has some bugs which make it not really ISA 3.00
+ * compliant.  More importantly, advertising ISA 3.00
+ * architected mode may prevent guests from activating
+ * necessary DD1 workarounds.
+ */
+pcc->pcr_supported &= ~(PCR_COMPAT_3_00 | PCR_COMPAT_2_07
+| PCR_COMPAT_2_06 | PCR_COMPAT_2_05);
+}
 #endif /* defined(TARGET_PPC64) */
 }
 
-- 
2.9.3




Re: [Qemu-devel] [PATCH v3 0/3] arch_init: Move soundhw code to hw/audio/soundhw.c

2017-05-08 Thread Eduardo Habkost
On Mon, May 08, 2017 at 03:54:18PM -0700, no-re...@patchew.org wrote:
[...]
> === OUTPUT BEGIN ===
> Checking PATCH 1/3: audio: Move arch_init audio code to hw/audio/soundhw.c...
> ERROR: suspect code indent for conditional statements (8, 13)
> #240: FILE: hw/audio/soundhw.c:76:
> +if (soundhw_count) {
> + printf("Valid sound card names (comma separated):\n");
> 
> ERROR: suspect code indent for conditional statements (13, 17)
> #242: FILE: hw/audio/soundhw.c:78:
> + for (c = soundhw; c->name; ++c) {
> + printf ("%-11s %s\n", c->name, c->descr);
> 
> ERROR: space prohibited between function name and open parenthesis '('
> #243: FILE: hw/audio/soundhw.c:79:
> + printf ("%-11s %s\n", c->name, c->descr);
> 
> ERROR: else should follow close brace '}'
> #252: FILE: hw/audio/soundhw.c:88:
> +}
> +else {
> 
> ERROR: else should follow close brace '}'
> #281: FILE: hw/audio/soundhw.c:117:
> +}
> +else {
> 
> WARNING: line over 80 characters
> #299: FILE: hw/audio/soundhw.c:135:
> +ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, 
> NULL);
> 
> WARNING: line over 80 characters
> #300: FILE: hw/audio/soundhw.c:136:
> +PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, 
> NULL);
> 
> total: 5 errors, 2 warnings, 320 lines checked
> 
> Your patch has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.

The style problems are not in new code, but in code being moved
to another file. If anybody wants to volunteer to fix those
issues, they should be addressed in follow-up patches.

-- 
Eduardo



Re: [Qemu-devel] [PATCH v3 3/3] audio: Rename hw/audio/audio.h to hw/audio/soundhw.h

2017-05-08 Thread David Gibson
On Mon, May 08, 2017 at 05:57:35PM -0300, Eduardo Habkost wrote:
> All the functions in hw/audio/audio.h are called "soundhw_*()"
> and live in hw/audio/audiohw.c. Rename the header file for
> consistency.
> 
> Signed-off-by: Eduardo Habkost 

Reviewed-by: David Gibson 

> ---
> Changes v2 -> v3:
> * Update header name at hw/ppc/prep.c too
> 
> Changes v1 -> v2:
> * Rebase to latest qemu.git master
> ---
>  include/hw/audio/{audio.h => soundhw.h} | 0
>  arch_init.c | 2 +-
>  hw/audio/ac97.c | 2 +-
>  hw/audio/adlib.c| 2 +-
>  hw/audio/cs4231a.c  | 2 +-
>  hw/audio/es1370.c   | 2 +-
>  hw/audio/gus.c  | 2 +-
>  hw/audio/intel-hda.c| 2 +-
>  hw/audio/pcspk.c| 2 +-
>  hw/audio/sb16.c | 2 +-
>  hw/audio/soundhw.c  | 2 +-
>  hw/ppc/prep.c   | 2 +-
>  vl.c| 2 +-
>  13 files changed, 12 insertions(+), 12 deletions(-)
>  rename include/hw/audio/{audio.h => soundhw.h} (100%)
> 
> diff --git a/include/hw/audio/audio.h b/include/hw/audio/soundhw.h
> similarity index 100%
> rename from include/hw/audio/audio.h
> rename to include/hw/audio/soundhw.h
> diff --git a/arch_init.c b/arch_init.c
> index 74ca62f508..a0b8ed6167 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -27,7 +27,7 @@
>  #include "sysemu/sysemu.h"
>  #include "sysemu/arch_init.h"
>  #include "hw/pci/pci.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "qemu/config-file.h"
>  #include "qemu/error-report.h"
>  #include "qmp-commands.h"
> diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
> index c30657501c..959c786261 100644
> --- a/hw/audio/ac97.c
> +++ b/hw/audio/ac97.c
> @@ -19,7 +19,7 @@
>  
>  #include "qemu/osdep.h"
>  #include "hw/hw.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "audio/audio.h"
>  #include "hw/pci/pci.h"
>  #include "sysemu/dma.h"
> diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c
> index 09b8248cda..c6e0f10c16 100644
> --- a/hw/audio/adlib.c
> +++ b/hw/audio/adlib.c
> @@ -25,7 +25,7 @@
>  #include "qemu/osdep.h"
>  #include "qapi/error.h"
>  #include "hw/hw.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "audio/audio.h"
>  #include "hw/isa/isa.h"
>  
> diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
> index 3ecd0582bf..096e8e98d7 100644
> --- a/hw/audio/cs4231a.c
> +++ b/hw/audio/cs4231a.c
> @@ -23,7 +23,7 @@
>   */
>  #include "qemu/osdep.h"
>  #include "hw/hw.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "audio/audio.h"
>  #include "hw/isa/isa.h"
>  #include "hw/qdev.h"
> diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
> index fe64c1ac37..dd7c23d185 100644
> --- a/hw/audio/es1370.c
> +++ b/hw/audio/es1370.c
> @@ -28,7 +28,7 @@
>  
>  #include "qemu/osdep.h"
>  #include "hw/hw.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "audio/audio.h"
>  #include "hw/pci/pci.h"
>  #include "sysemu/dma.h"
> diff --git a/hw/audio/gus.c b/hw/audio/gus.c
> index ec103a4db9..3e864cd36d 100644
> --- a/hw/audio/gus.c
> +++ b/hw/audio/gus.c
> @@ -24,7 +24,7 @@
>  #include "qemu/osdep.h"
>  #include "qapi/error.h"
>  #include "hw/hw.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "audio/audio.h"
>  #include "hw/isa/isa.h"
>  #include "gusemu.h"
> diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
> index 2c497eb174..06acc98f7b 100644
> --- a/hw/audio/intel-hda.c
> +++ b/hw/audio/intel-hda.c
> @@ -22,7 +22,7 @@
>  #include "hw/pci/pci.h"
>  #include "hw/pci/msi.h"
>  #include "qemu/timer.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "intel-hda.h"
>  #include "intel-hda-defs.h"
>  #include "sysemu/dma.h"
> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
> index 798002277b..c815a2b9ca 100644
> --- a/hw/audio/pcspk.c
> +++ b/hw/audio/pcspk.c
> @@ -26,7 +26,7 @@
>  #include "hw/hw.h"
>  #include "hw/i386/pc.h"
>  #include "hw/isa/isa.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "audio/audio.h"
>  #include "qemu/timer.h"
>  #include "hw/timer/i8254.h"
> diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
> index 6b4427f242..6ab2f6f89a 100644
> --- a/hw/audio/sb16.c
> +++ b/hw/audio/sb16.c
> @@ -23,7 +23,7 @@
>   */
>  #include "qemu/osdep.h"
>  #include "hw/hw.h"
> -#include "hw/audio/audio.h"
> +#include "hw/audio/soundhw.h"
>  #include "audio/audio.h"
>  #include "hw/isa/isa.h"
>  #include "hw/qdev.h"
> diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c
> index 29565da93d..e698909d34 100644
> --- a/hw/audio/soundhw.c
> +++ b/hw/audio/soundhw.c
> @@ -28,7 +28,7 @@
>  #include "qom/object.h"
>  #include "hw/isa/isa.h"
>  #include "hw/pci/pci.h"
> -#include 

Re: [Qemu-devel] [PATCH v3 2/3] audio: Rename audio_init() to soundhw_init()

2017-05-08 Thread David Gibson
On Mon, May 08, 2017 at 05:57:34PM -0300, Eduardo Habkost wrote:
> To make it consistent with the remaining soundhw.c functions and
> avoid confusion with the audio_init() function in audio/audio.c,
> rename audio_init() to soundhw_init().
> 
> Signed-off-by: Eduardo Habkost 

Reviewed-by: David Gibson 

> ---
> Changes v2 -> v3:
> * Update hw/ppc/prep.c audio_init() call too
> 
> Changes v1 -> v2:
> * Rebase to latest qemu.git master
> ---
>  include/hw/audio/audio.h | 2 +-
>  hw/audio/soundhw.c   | 2 +-
>  hw/ppc/prep.c| 2 +-
>  vl.c | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/hw/audio/audio.h b/include/hw/audio/audio.h
> index 259bb2cf96..119f7d78d5 100644
> --- a/include/hw/audio/audio.h
> +++ b/include/hw/audio/audio.h
> @@ -7,7 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
>  void pci_register_soundhw(const char *name, const char *descr,
>int (*init_pci)(PCIBus *bus));
>  
> -void audio_init(void);
> +void soundhw_init(void);
>  void select_soundhw(const char *optarg);
>  
>  #endif
> diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c
> index 5e96b73c81..29565da93d 100644
> --- a/hw/audio/soundhw.c
> +++ b/hw/audio/soundhw.c
> @@ -129,7 +129,7 @@ void select_soundhw(const char *optarg)
>  }
>  }
>  
> -void audio_init(void)
> +void soundhw_init(void)
>  {
>  struct soundhw *c;
>  ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, 
> NULL);
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 96a4813b3f..4a7d2cfbe0 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -783,7 +783,7 @@ static void ibm_40p_init(MachineState *machine)
> _checksum);
>  
>  /* initialize audio subsystem */
> -audio_init();
> +soundhw_init();
>  
>  /* add some more devices */
>  if (defaults_enabled()) {
> diff --git a/vl.c b/vl.c
> index a2400e1ab6..42fd66ac0d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4569,7 +4569,7 @@ int main(int argc, char **argv, char **envp)
>  
>  realtime_init();
>  
> -audio_init();
> +soundhw_init();
>  
>  if (hax_enabled()) {
>  hax_sync_vcpus();

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


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v3 1/3] audio: Move arch_init audio code to hw/audio/soundhw.c

2017-05-08 Thread David Gibson
On Mon, May 08, 2017 at 05:57:33PM -0300, Eduardo Habkost wrote:
> There's no reason to keep the soundhw table in arch_init.c. Move
> that code to a new hw/audio/soundhw.c file.
> 
> While moving the code, trivial coding style issues were fixed.
> 
> Signed-off-by: Eduardo Habkost 

Reviewed-by: David Gibson 

> ---
> Changes v2 -> v3:
> * Update hw/ppc/prep.c to include hw/audio/audio.h too
> 
> Changes v1 -> v2:
> * Rebase to latest qemu.git master
> ---
>  include/hw/audio/audio.h   |   3 +
>  include/sysemu/arch_init.h |   2 -
>  arch_init.c| 124 ---
>  hw/audio/soundhw.c | 156 
> +
>  hw/ppc/prep.c  |   1 +
>  vl.c   |   1 +
>  hw/audio/Makefile.objs |   2 +
>  7 files changed, 163 insertions(+), 126 deletions(-)
>  create mode 100644 hw/audio/soundhw.c
> 
> diff --git a/include/hw/audio/audio.h b/include/hw/audio/audio.h
> index 55d40f71bf..259bb2cf96 100644
> --- a/include/hw/audio/audio.h
> +++ b/include/hw/audio/audio.h
> @@ -7,4 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
>  void pci_register_soundhw(const char *name, const char *descr,
>int (*init_pci)(PCIBus *bus));
>  
> +void audio_init(void);
> +void select_soundhw(const char *optarg);
> +
>  #endif
> diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
> index 2bf16b203c..8751c468ed 100644
> --- a/include/sysemu/arch_init.h
> +++ b/include/sysemu/arch_init.h
> @@ -28,8 +28,6 @@ enum {
>  
>  extern const uint32_t arch_type;
>  
> -void select_soundhw(const char *optarg);
> -void audio_init(void);
>  int kvm_available(void);
>  int xen_available(void);
>  
> diff --git a/arch_init.c b/arch_init.c
> index 0810116144..74ca62f508 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -85,130 +85,6 @@ int graphic_depth = 32;
>  
>  const uint32_t arch_type = QEMU_ARCH;
>  
> -struct soundhw {
> -const char *name;
> -const char *descr;
> -int enabled;
> -int isa;
> -union {
> -int (*init_isa) (ISABus *bus);
> -int (*init_pci) (PCIBus *bus);
> -} init;
> -};
> -
> -static struct soundhw soundhw[9];
> -static int soundhw_count;
> -
> -void isa_register_soundhw(const char *name, const char *descr,
> -  int (*init_isa)(ISABus *bus))
> -{
> -assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
> -soundhw[soundhw_count].name = name;
> -soundhw[soundhw_count].descr = descr;
> -soundhw[soundhw_count].isa = 1;
> -soundhw[soundhw_count].init.init_isa = init_isa;
> -soundhw_count++;
> -}
> -
> -void pci_register_soundhw(const char *name, const char *descr,
> -  int (*init_pci)(PCIBus *bus))
> -{
> -assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
> -soundhw[soundhw_count].name = name;
> -soundhw[soundhw_count].descr = descr;
> -soundhw[soundhw_count].isa = 0;
> -soundhw[soundhw_count].init.init_pci = init_pci;
> -soundhw_count++;
> -}
> -
> -void select_soundhw(const char *optarg)
> -{
> -struct soundhw *c;
> -
> -if (is_help_option(optarg)) {
> -show_valid_cards:
> -
> -if (soundhw_count) {
> - printf("Valid sound card names (comma separated):\n");
> - for (c = soundhw; c->name; ++c) {
> - printf ("%-11s %s\n", c->name, c->descr);
> - }
> - printf("\n-soundhw all will enable all of the above\n");
> -} else {
> - printf("Machine has no user-selectable audio hardware "
> -"(it may or may not have always-present audio 
> hardware).\n");
> -}
> -exit(!is_help_option(optarg));
> -}
> -else {
> -size_t l;
> -const char *p;
> -char *e;
> -int bad_card = 0;
> -
> -if (!strcmp(optarg, "all")) {
> -for (c = soundhw; c->name; ++c) {
> -c->enabled = 1;
> -}
> -return;
> -}
> -
> -p = optarg;
> -while (*p) {
> -e = strchr(p, ',');
> -l = !e ? strlen(p) : (size_t) (e - p);
> -
> -for (c = soundhw; c->name; ++c) {
> -if (!strncmp(c->name, p, l) && !c->name[l]) {
> -c->enabled = 1;
> -break;
> -}
> -}
> -
> -if (!c->name) {
> -if (l > 80) {
> -error_report("Unknown sound card name (too big to 
> show)");
> -}
> -else {
> -error_report("Unknown sound card name `%.*s'",
> - (int) l, p);
> -}
> -bad_card = 1;
> -}
> -p += l + (e != NULL);
> -}
> -
> -if (bad_card) {
> -goto show_valid_cards;
> -}
> 

Re: [Qemu-devel] [PATCH] Revert "Change net/socket.c to use socket_*() functions" again

2017-05-08 Thread Jason Wang



On 2017年05月06日 03:36, no-re...@patchew.org wrote:

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Subject: [Qemu-devel] [PATCH] Revert "Change net/socket.c to use socket_*() 
functions" again
Message-id: 20170505162305.15763-1-berra...@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
 echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
 if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; 
then
 failed=1
 echo
 fi
 n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
 From https://github.com/patchew-project/qemu
  - [tag update]  patchew/20170504173745.27414-1-ebl...@redhat.com -> 
patchew/20170504173745.27414-1-ebl...@redhat.com
Switched to a new branch 'test'
89f6b9d Revert "Change net/socket.c to use socket_*() functions" again

=== OUTPUT BEGIN ===
Checking PATCH 1/1: Revert "Change net/socket.c to use socket_*() functions" 
again...
ERROR: braces {} are necessary for all arms of this statement
#56: FILE: net/socket.c:495:
+if (parse_host_port(, host_str) < 0)
[...]

ERROR: braces {} are necessary for all arms of this statement
#159: FILE: net/socket.c:540:
+if (parse_host_port(, host_str) < 0)
[...]

ERROR: space required before the open parenthesis '('
#172: FILE: net/socket.c:551:
+for(;;) {

ERROR: braces {} are necessary for all arms of this statement
#192: FILE: net/socket.c:571:
+if (!s)
[...]

total: 4 errors, 0 warnings, 162 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@freelists.org


Acked-by: Jason Wang 



Re: [Qemu-devel] [virtio-dev] Re: [PATCH v9 2/5] virtio-balloon: VIRTIO_BALLOON_F_BALLOON_CHUNKS

2017-05-08 Thread Wei Wang

On 05/09/2017 01:40 AM, Michael S. Tsirkin wrote:

On Sun, May 07, 2017 at 04:19:28AM +, Wang, Wei W wrote:

On 05/06/2017 06:26 AM, Michael S. Tsirkin wrote:

On Thu, Apr 27, 2017 at 02:31:49PM +0800, Wei Wang wrote:

On 04/27/2017 07:20 AM, Michael S. Tsirkin wrote:

On Wed, Apr 26, 2017 at 11:03:34AM +, Wang, Wei W wrote:

Hi Michael, could you please give some feedback?

I'm sorry, I'm not sure feedback on what you are requesting.

Oh, just some trivial things (e.g. use a field in the header,
hdr->chunks to indicate the number of chunks in the payload) that
wasn't confirmed.

I will prepare the new version with fixing the agreed issues, and we
can continue to discuss those parts if you still find them improper.



The interface looks reasonable now, even though there's a way to
make it even simpler if we can limit chunk size to 2G (in fact 4G -
1). Do you think we can live with this limitation?

Yes, I think we can. So, is it good to change to use the previous
64-bit chunk format (52-bit base + 12-bit size)?

This isn't what I meant. virtio ring has descriptors with a 64 bit address and 
32 bit
size.

If size < 4g is not a significant limitation, why not just use that to pass
address/size in a standard s/g list, possibly using INDIRECT?

OK, I see your point, thanks. Post the two options here for an analysis:
Option1 (what we have now):
struct virtio_balloon_page_chunk {
 __le64 chunk_num;
 struct virtio_balloon_page_chunk_entry entry[];
};
Option2:
struct virtio_balloon_page_chunk {
 __le64 chunk_num;
 struct scatterlist entry[];
};

This isn't what I meant really :) I meant vring_desc.


OK. Repost the code change:

Option2:
struct virtio_balloon_page_chunk {
__le64 chunk_num;
struct ving_desc entry[];
};

We pre-allocate a table of desc, and each desc is used to hold a chunk.

In that case, the virtqueue_add() function, which deals with sg, is not
usable for us. We may need to add a new one,
virtqueue_add_indirect_desc(),
to add a pre-allocated indirect descriptor table to vring.





I don't have an issue to change it to Option2, but I would prefer Option1,
because I think there is no be obvious difference between the two options,
while Option1 appears to have little advantages here:
1) "struct virtio_balloon_page_chunk_entry" has smaller size than
"struct scatterlist", so the same size of allocated page chunk buffer
can hold more entry[] using Option1;
2) INDIRECT needs on demand kmalloc();

Within alloc_indirect?  We can fix that with a separate patch.



3) no 4G size limit;

Do you see lots of >=4g chunks in practice?

It wouldn't be much in practice, but we still need the extra code to
handle the case - break larger chunks into less-than 4g ones.

Best,
Wei



Re: [Qemu-devel] [PATCH V3 05/10] net/net.c: Add vnet header length to SocketReadState

2017-05-08 Thread Jason Wang



On 2017年05月08日 11:47, Zhang Chen wrote:



On 05/03/2017 06:42 PM, Jason Wang wrote:



On 2017年05月03日 11:43, Zhang Chen wrote:



On 05/02/2017 12:53 PM, Jason Wang wrote:



On 2017年04月28日 17:47, Zhang Chen wrote:
Address Jason Wang's comments add vnet header length to 
SocketReadState.


Instead of saying this, you can add "Suggested-by: Jason Wang 
" above your sign-off.


OK.




So we change net_fill_rstate() to read
struct  {int size; int vnet_hdr_len; const uint8_t buf[];}.


This makes me thinking about the backward compatibility. I think 
we'd better try to keep it as much as possible. E.g how about pack 
vnet_hdr_len into higher bits of size?




Do you means split uint32_t size to uint16_t size and uint16_t 
vnet_hdr_len ?

If yes, we also can't keep compatibility with old version.
Old code send a uint32_t size, we read it as uint16_t size is always 
wrong.


Thanks
Zhang Chen


Consider it's unlikely to send or receive packet >= 64K, we can reuse 
higher bits (e.g highest 8 bits). Then we can still read uint32_t and 
then check its highest 8 bits. If it was zero, we know vnet header is 
zero, if not it could be read as vnet header length.


I got your point, but in this way, packet size must < 64K, if size 
>=64K we still can't maintain the backward compatibility,
For the packet sender that didn't know the potential packet size 
limit, I think we should make code explicitly declared like
currently code. Otherwise we will make other people confused and make 
code difficult to maintain.


Thanks
Zhang Chen



Yes, this is an possible issue in the future. Rethink about this, what 
if we just compare vnet header? Is there any issue of doing this? 
(Sorry, I remember this is a reason, but forget now).


Thanks



Re: [Qemu-devel] Future of SoftFloat use in QEMU

2017-05-08 Thread Richard Henderson

On 05/08/2017 07:58 AM, Alex Bennée wrote:

Hi,

We've got a task coming up to implement half-precision floating point
(FP16) for ARMv8.2. As you know pretty much all our floating point in
QEMU is handled by our internal fork of John R. Hauser's BSD SoftFloat
library. Our current implementation is based on version 2a which doesn't
support FP16.

As it happens there has been a new release of SoftFloat recently.
Version 3 is a complete re-write which made a number of changes, some
notable ones being:

   - Complete rewrite, different use license than earlier releases.
   - Renaming most types and functions, upgrading some algorithms
 - restructuring the source files, and making SoftFloat into a true library.


But also now using thread-local globals instead of passing in a structure with 
all of the parameters.  So, really, we'd probably wind up touching every 
function if we were to import it.



So what else can we do?

We could investigate having both libraries included in QEMU. It seems
the API has changed quite a bit so that might be possible although there
would be hackage involved in having two different softfloat.h's
involved.

This would be useful if we wanted to take a piecemeal approach to
updating the library. For example we could just use softfloat3 when we
need the newer features (e.g. FP16).

Or we could convert one architecture at a time so each qemu binary links
against either a version 2 or version 3 softfloat library. Of course
that does run the risk of permanently holding two versions of softfloat
in the code if the less maintained guest architectures don't convert
quickly.


Another possibility is the code that's shared between the linux kernel 
(include/math-emu) and glibc (soft-fp).  The glibc version has support for f16 
while the kernel doesn't.  But the glibc version is LGPL 2.1, which I'd expect 
to be ok.


It is mildly nasty in that it's a collection of macros, but that's how we 
managed really good performance with the compiler tech of 15 years ago.  On the 
other hand, it would be fairly easy to adjust the support macros to achive 
source compatibility with our current code.


Just a thought...


r~



Re: [Qemu-devel] [PATCH v7 13/13] MAINTAINERS: Add vfio-ccw maintainer

2017-05-08 Thread Dong Jia Shi
* Cornelia Huck  [2017-05-08 11:09:27 +0200]:

> On Mon, 8 May 2017 13:29:27 +0800
> Dong Jia Shi  wrote:
> 
> > * Cornelia Huck  [2017-05-05 14:20:14 +0200]:
> > 
> > > On Fri,  5 May 2017 04:03:52 +0200
> > > Dong Jia Shi  wrote:
> > > 
> > > > Add Cornelia Huck as the vfio-ccw maintainer.
> > > > 
> > > > Signed-off-by: Dong Jia Shi 
> > > > ---
> > > >  MAINTAINERS | 5 +
> > > >  1 file changed, 5 insertions(+)
> > > > 
> > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > index cae3b09..c1f9917 100644
> > > > --- a/MAINTAINERS
> > > > +++ b/MAINTAINERS
> > > > @@ -999,6 +999,11 @@ S: Supported
> > > >  F: hw/vfio/*
> > > >  F: include/hw/vfio/
> > > > 
> > > > +vfio-ccw
> > > > +M: Cornelia Huck 
> > > > +S: Supported
> > > > +F: hw/vfio/ccw.c
> > > 
> > > The other code related to vfio-ccw is entangled with the other virtual
> > > css code, so this is probably really the only file that needs to be
> > > listed separately.
> > "hw/s390x/" and "include/hw/s390x/" are listed under the "S390 Machines"
> > part.
> > 
> > Maybe you would like to list the following files separately here:
> > hw/s390x/s390-ccw.c
> > hw/s390x/s390-ccw.h
> 
> Yes, that makes sense.
> 
> But seeing the path name here: Should s390-ccw.h rather go into
> include/hw/s390x/ (even if hw/s390x/ already contains several .h
> files...)?
Ok. You will find it in include/hw/s390x/ in next version.

Would you like me making a sepate patch to move all of the other .h
files to the include folder?

> 
> > 
> > > 
> > > I will likely take any vfio-ccw changes together with the other code I
> > > take through s390-next. I'll add the respective line when I apply.
> > Ok. Leave this to you. :>
> > 
> > > 
> > > > +
> > > >  vhost
> > > >  M: Michael S. Tsirkin 
> > > >  S: Supported
> > > 
> > 
> 

-- 
Dong Jia Shi




Re: [Qemu-devel] [PATCH v7 05/13] s390x/css: realize css_create_sch

2017-05-08 Thread Dong Jia Shi
* Cornelia Huck  [2017-05-08 12:50:40 +0200]:

> On Mon, 8 May 2017 13:18:22 +0800
> Dong Jia Shi  wrote:
> 
> > * Cornelia Huck  [2017-05-05 14:11:53 +0200]:
> > 
> > > On Fri,  5 May 2017 04:03:44 +0200
> > > Dong Jia Shi  wrote:
> 
> > > > -SubchDev *css_create_virtual_sch(CssDevId bus_id, Error **errp)
> > > > +SubchDev *css_create_sch(CssDevId bus_id, bool is_virtio, bool 
> > > > squash_mcss,
> > > > + Error **errp)
> > > >  {
> > > >  uint16_t schid = 0;
> > > >  SubchDev *sch;
> > > > 
> > > >  if (bus_id.valid) {
> > > > -/* Enforce use of virtual cssid. */
> > > > -if (bus_id.cssid != VIRTUAL_CSSID) {
> > > > -error_setg(errp, "cssid %hhx not valid for virtual 
> > > > devices",
> > > > -   bus_id.cssid);
> > > > +if (is_virtio != (bus_id.cssid == VIRTUAL_CSSID)) {
> > > > +error_setg(errp, "cssid %hhx not valid for %s devices",
> > > > +   bus_id.cssid,
> > > > +   (is_virtio ? "virtio" : "non-virtio"));
> > > 
> > > This reminds me of something else: virtual 3270 devices will use the
> > > virtual channel subsystem by default. I think this is fine: Even though
> > > they are not virtio devices, they are fully virtual constructs, and it
> > > does not make sense to artificially shove them into another css.
> > VIRTUAL CSS (0xFE) is reserved for virtio devices only, no? This is what
> > I understood... So we should not put any non-virtio devices into CSS
> > 0xFE.
> > 
> > If my understanding is not right before, I agree that we put non-virtio
> > (e.g. 3270) devices into CSS 0xFE, and ...
> > 
> > > 
> > > But this means the distinction should be virtual vs. non-virtual and
> > > not virtio vs. non-virtio, and the squashing is only applicable to
> > > non-virtual devices. Mainly a naming thing.
> > ... do the following modifications here:
> > s/virtio/virtual
> > s/non-virtio/non-virtual
> > s/is_virtio/is_virtual
> 
> I realize that I wanted to treat css 0xfe as virtio-only initially;
Aha, here is the origination of my former understanding.

> but I think the virtual/non-virtual distinction actually makes more
> sense.
Agreed. And since we do not have legacy problem that stops us from doing
this, I will fix according to your comments.

> 
> - For devices that don't have a hardware equivalent at all (like
> virtio-ccw), it's clear that they should be in the virtual css.
Nod.

> 
> - For devices that are always fully emulated (because there's no device
> that could be passthroughed), I'd argue that they should be treated as
> fully virtual as well. This means 3270, and would include things like a
> card punch should anyone feel an urge to emulate that one :)
Nod.

> 
> - An emulation of a device that could also be passthroughed is a bit of
> a grey area. One could argue to put it either with the virtual devices
> or with the non-virtual ones. But I think we can ignore that for now
> (until someone decides that a dasd emulation is a thing qemu urgently
> needs...)
Ok.

-- 
Dong Jia Shi




Re: [Qemu-devel] [PATCH v2 0/4] Convert non-blocking connect and fix its error reporting

2017-05-08 Thread Mao Zhongyi



On 05/06/2017 12:39 AM, Daniel P. Berrange wrote:

On Wed, Apr 26, 2017 at 04:04:14PM +0800, Mao Zhongyi wrote:

v2:
* PATCH 02 reworking of patch 2 following Markus's suggestion that convert 
error_report()
  in the function called by net_socket_*_init() to Error. Also add many error 
handling
  information.
* PATCH 03 net_socket_mcast_create(), net_socket_fd_init_dgram() and 
net_socket_fd_init()
  use the function such as fprintf, perror to report an error message. Convert 
it to Error.
* PATCH 04 parse_host_port() may fail without reporting an error. Now, fix it 
to set an
  error when it fails.


FYI, I discovered that previous change

  commit 883e4f7624e10b98d16d9adaffb8b1795664d899
  Author: Marc-André Lureau 
  Date:   Sat Jun 18 13:24:02 2016 +0530

Change net/socket.c to use socket_*() functions

has seriously broken the current code because net_socket_fd_init()
was not called from the right place. Fixing the current code is
somewhat painful, so I've sent a revert of that broken patch.

To demo the problem first run:

  $ ./x86_64-softmmu/qemu-system-x86_64  \
  -device e1000,id=e0,netdev=user.0,mac=DE:AD:BE:EF:AF:04 \
  -netdev socket,id=user.0,listen=:1234

and then run:

   $ ./x86_64-softmmu/qemu-system-x86_64 \
   -device e1000,id=e0,netdev=hn0,mac=DE:AD:BE:EF:AF:05 \
   -netdev socket,id=hn0,connect=localhost:1234

currently the second command fails with

  qemu-system-x86_64: -device e1000,id=e0,netdev=hn0,mac=DE:AD:BE:EF:AF:05: 
Property 'e1000.netdev' can't find value 'hn0'

and my revert fixes that. Just something for you to test with your
new patch series...

Regards,
Daniel


Hi, Daniel

According to your latest advice, run these two commands in my new
patch, the second command reported the same error.

Now, you sent a revert of that broken patch to avoid this problem.
It also means that my first patch based on socket_*() is disabled.
Currently, there is no good way to convert it use QIOchannel. So I
have an idea to use the reverted patch instead of the first of my
series, and then based on the first to fix the rest. Latter I will
convert it to QIOchannel in a separated patch. Do you think that's
ok?

Looking forward to your opinion.

Thanks
Mao






Re: [Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

2017-05-08 Thread Philippe Mathieu-Daudé

On 05/08/2017 08:56 PM, Eric Blake wrote:

On 05/08/2017 06:39 PM, Philippe Mathieu-Daudé wrote:

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/misc/unimp.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h
index 3462d85836..353ee19abf 100644
--- a/include/hw/misc/unimp.h
+++ b/include/hw/misc/unimp.h
@@ -8,6 +8,9 @@
 #ifndef HW_MISC_UNIMP_H
 #define HW_MISC_UNIMP_H

+#include "qemu/osdep.h"


NACK. .h files should not include osdep.h, because the .c file that is
using the .h file should have already done so.  This is mentioned in
HACKING.


Ok! Indeed my .c doesn't include osdep.h, sorry for the noise.



Re: [Qemu-devel] [PATCH 09/11] target/sparc: fix DEBUG_MMU DPRINTF() arguments

2017-05-08 Thread Philippe Mathieu-Daudé

On 05/08/2017 09:00 PM, Eric Blake wrote:

On 05/08/2017 06:39 PM, Philippe Mathieu-Daudé wrote:

invalid since 96df2bc99f9

Signed-off-by: Philippe Mathieu-Daudé 
---
 target/sparc/ldst_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index 57968d9143..aa83a49a88 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -1631,7 +1631,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, 
target_ulong val,

 if (oldreg != env->immu.mmuregs[reg]) {
 DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016"
-PRIx64 "\n", reg, oldreg, env->immuregs[reg]);
+PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]);


Please take this opportunity to fix the broken definitions of
DPRINTF_MMU() and friends so that they don't bit-rot when not defined.
There are plenty of other examples of re-writing broken #defines to
instead favor an if (0) { printf(...) } to benefit from -Wformat
checking even when the debugging is disabled.


Sure, will do it.




Re: [Qemu-devel] [PATCH 10/11] register: display register prefix (name) since it is available

2017-05-08 Thread Alistair Francis
On Mon, May 8, 2017 at 4:39 PM, Philippe Mathieu-Daudé  wrote:
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Thanks,

Alistair

> ---
>  hw/core/register.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/core/register.c b/hw/core/register.c
> index dc335a79a9..b5988c9cc3 100644
> --- a/hw/core/register.c
> +++ b/hw/core/register.c
> @@ -195,8 +195,8 @@ void register_write_memory(void *opaque, hwaddr addr,
>  }
>
>  if (!reg) {
> -qemu_log_mask(LOG_GUEST_ERROR, "Write to unimplemented register at " 
> \
> -  "address: %#" PRIx64 "\n", addr);
> +qemu_log_mask(LOG_GUEST_ERROR, "%s: write to unimplemented register 
> " \
> +  "at address: %#" PRIx64 "\n", reg_array->prefix, addr);
>  return;
>  }
>
> @@ -224,8 +224,8 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,
>  }
>
>  if (!reg) {
> -qemu_log_mask(LOG_GUEST_ERROR, "Read to unimplemented register at " \
> -  "address: %#" PRIx64 "\n", addr);
> +qemu_log_mask(LOG_GUEST_ERROR, "%s:  read to unimplemented register 
> " \
> +  "at address: %#" PRIx64 "\n", reg_array->prefix, addr);
>  return 0;
>  }
>
> --
> 2.11.0
>
>



Re: [Qemu-devel] [PATCH 09/11] target/sparc: fix DEBUG_MMU DPRINTF() arguments

2017-05-08 Thread Eric Blake
On 05/08/2017 06:39 PM, Philippe Mathieu-Daudé wrote:
> invalid since 96df2bc99f9
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  target/sparc/ldst_helper.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
> index 57968d9143..aa83a49a88 100644
> --- a/target/sparc/ldst_helper.c
> +++ b/target/sparc/ldst_helper.c
> @@ -1631,7 +1631,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong 
> addr, target_ulong val,
>  
>  if (oldreg != env->immu.mmuregs[reg]) {
>  DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016"
> -PRIx64 "\n", reg, oldreg, env->immuregs[reg]);
> +PRIx64 "\n", reg, oldreg, 
> env->immu.mmuregs[reg]);

Please take this opportunity to fix the broken definitions of
DPRINTF_MMU() and friends so that they don't bit-rot when not defined.
There are plenty of other examples of re-writing broken #defines to
instead favor an if (0) { printf(...) } to benefit from -Wformat
checking even when the debugging is disabled.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 04/11] ide/ahci: add missing includes

2017-05-08 Thread Eric Blake
On 05/08/2017 06:39 PM, Philippe Mathieu-Daudé wrote:
> qemu/include/hw/ide/ahci.h:260:16: error: field ‘sglist’ has incomplete type
>  QEMUSGList sglist;
> ^~

What are you doing to get this compilation error (configure options,
platform, compiler, etc)?  I can't reproduce it. Is it something that
pops up later when you remove includes from somewhere else, and you're
just pre-emptively adding includes here to allow removal of includes later?

> /qemu/include/hw/ide/ahci.h:272:5: error: unknown type name ‘IDEDMA’
>  IDEDMA dma;
>  ^~
> qemu/include/hw/ide/ahci.h:273:5: error: unknown type name ‘IDEBus’
>  IDEBus port;
>  ^~
> qemu/include/hw/ide/ahci.h:305:15: error: field ‘parent_obj’ has incomplete 
> type
>  PCIDevice parent_obj;
>^~
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  include/hw/ide/ahci.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/hw/ide/ahci.h b/include/hw/ide/ahci.h
> index 0ca7c65820..293f9ebcd0 100644
> --- a/include/hw/ide/ahci.h
> +++ b/include/hw/ide/ahci.h
> @@ -25,6 +25,8 @@
>  #define HW_IDE_AHCI_H
>  
>  #include "hw/sysbus.h"
> +#include "hw/ide/internal.h"
> +#include "sysemu/dma.h"
>  
>  #define AHCI_MEM_BAR_SIZE 0x1000
>  #define AHCI_MAX_PORTS32
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2 6/6] target/s390x: Use atomic operations for LOAD AND OP

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 08:17, Richard Henderson wrote:
> Signed-off-by: Richard Henderson 
> ---
>  target/s390x/insn-data.def | 20 ++--
>  target/s390x/translate.c   | 78 
> +-
>  2 files changed, 60 insertions(+), 38 deletions(-)

Reviewed-by: Aurelien Jarno 

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

2017-05-08 Thread Eric Blake
On 05/08/2017 06:39 PM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  include/hw/misc/unimp.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h
> index 3462d85836..353ee19abf 100644
> --- a/include/hw/misc/unimp.h
> +++ b/include/hw/misc/unimp.h
> @@ -8,6 +8,9 @@
>  #ifndef HW_MISC_UNIMP_H
>  #define HW_MISC_UNIMP_H
>  
> +#include "qemu/osdep.h"

NACK. .h files should not include osdep.h, because the .c file that is
using the .h file should have already done so.  This is mentioned in
HACKING.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2 4/6] target/s390x: Implement LOAD PAIR DISJOINT

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 08:17, Richard Henderson wrote:
> From: Eric Bischoff 
> 
> Signed-off-by: Eric Bischoff 
> Message-Id: <20170228120134.7921-1-ebisch...@suse.com>
> [rth: Combine the two via insn->data; free the address temps.]
> Signed-off-by: Richard Henderson 
> ---
>  target/s390x/insn-data.def |  4 +++-
>  target/s390x/translate.c   | 42 ++
>  2 files changed, 45 insertions(+), 1 deletion(-)

Reviewed-by: Aurelien Jarno 

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH v2 5/6] target/s390x: Use atomic operations for COMPARE SWAP

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 08:17, Richard Henderson wrote:
> Signed-off-by: Richard Henderson 
> ---
>  target/s390x/helper.h |  1 +
>  target/s390x/mem_helper.c | 39 ++
>  target/s390x/translate.c  | 83 
> +--
>  3 files changed, 55 insertions(+), 68 deletions(-)

Reviewed-by: Aurelien Jarno 

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH v2 2/6] target/s390x: Implement LOAD PROGRAM PARAMETER

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 08:17, Richard Henderson wrote:
> From: Miroslav Benes 
> 
> Linux arch/s390/kernel/head(64).S uses LPP instruction if it is
> available in facilities list provided by stfl/stfle instruction.
> This is the case of newer z/System generations and their qemu
> definition.
> 
> The description of LPP is at
> http://www-01.ibm.com/support/docview.wss?uid=isg26fcd1cc32246f4c8852574ce0044734a
> 
> Signed-off-by: Miroslav Benes 
> Message-Id: <20170227085353.20787-1-mbe...@suse.cz>
> Signed-off-by: Richard Henderson 
> ---
>  target/s390x/insn-data.def | 2 ++
>  target/s390x/translate.c   | 9 +
>  2 files changed, 11 insertions(+)

Reviewed-by: Aurelien Jarno 

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH v2 3/6] target/s390x: Diagnose specification exception for atomics

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 08:17, Richard Henderson wrote:
> All of the interlocked access facility instructions raise a
> specification exception for unaligned accesses.  Do this by
> using the (previously unused) unaligned_access hook.
> 
> Signed-off-by: Richard Henderson 
> ---
>  target/s390x/cpu.c|  1 +
>  target/s390x/cpu.h|  3 +++
>  target/s390x/helper.c | 16 
>  3 files changed, 20 insertions(+)
> 
> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index 066dcd1..a1bf2ba 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -430,6 +430,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void 
> *data)
>  cc->write_elf64_note = s390_cpu_write_elf64_note;
>  cc->cpu_exec_interrupt = s390_cpu_exec_interrupt;
>  cc->debug_excp_handler = s390x_cpu_debug_excp_handler;
> +cc->do_unaligned_access = s390x_cpu_do_unaligned_access;
>  #endif
>  cc->disas_set_info = s390_cpu_disas_set_info;
>  
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index 058ddad..bbed320 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -480,6 +480,9 @@ int s390_cpu_handle_mmu_fault(CPUState *cpu, vaddr 
> address, int rw,
>  
>  #ifndef CONFIG_USER_ONLY
>  void do_restart_interrupt(CPUS390XState *env);
> +void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
> +   MMUAccessType access_type,
> +   int mmu_idx, uintptr_t retaddr);
>  
>  static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb,
> uint8_t *ar)
> diff --git a/target/s390x/helper.c b/target/s390x/helper.c
> index 68bd2f9..9978490 100644
> --- a/target/s390x/helper.c
> +++ b/target/s390x/helper.c
> @@ -718,4 +718,20 @@ void s390x_cpu_debug_excp_handler(CPUState *cs)
>  cpu_loop_exit_noexc(cs);
>  }
>  }
> +
> +/* Unaligned accesses are only diagnosed with MO_ALIGN.  At the moment,
> +   this is only for the atomic operations, for which we want to raise a
> +   specification exception.  */
> +void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
> +   MMUAccessType access_type,
> +   int mmu_idx, uintptr_t retaddr)
> +{
> +S390CPU *cpu = S390_CPU(cs);
> +CPUS390XState *env = >env;
> +
> +if (retaddr) {
> +cpu_restore_state(cs, retaddr);
> +}
> +program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER);
> +}
>  #endif /* CONFIG_USER_ONLY */

Reviewed-by: Aurelien Jarno 

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH 05/11] hw/mips: add missing include

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 20:39, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  include/hw/mips/mips.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/hw/mips/mips.h b/include/hw/mips/mips.h
> index e0065ce808..16412dc150 100644
> --- a/include/hw/mips/mips.h
> +++ b/include/hw/mips/mips.h
> @@ -6,6 +6,7 @@
>  #define INITRD_PAGE_MASK (~((1 << 16) - 1))
>  
>  #include "exec/memory.h"
> +#include "hw/irq.h"
>  
>  /* gt64xxx.c */
>  PCIBus *gt64120_register(qemu_irq *pic);

Acked-by: Aurelien Jarno 

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



[Qemu-devel] [PATCH 10/11] register: display register prefix (name) since it is available

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/core/register.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/core/register.c b/hw/core/register.c
index dc335a79a9..b5988c9cc3 100644
--- a/hw/core/register.c
+++ b/hw/core/register.c
@@ -195,8 +195,8 @@ void register_write_memory(void *opaque, hwaddr addr,
 }
 
 if (!reg) {
-qemu_log_mask(LOG_GUEST_ERROR, "Write to unimplemented register at " \
-  "address: %#" PRIx64 "\n", addr);
+qemu_log_mask(LOG_GUEST_ERROR, "%s: write to unimplemented register " \
+  "at address: %#" PRIx64 "\n", reg_array->prefix, addr);
 return;
 }
 
@@ -224,8 +224,8 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,
 }
 
 if (!reg) {
-qemu_log_mask(LOG_GUEST_ERROR, "Read to unimplemented register at " \
-  "address: %#" PRIx64 "\n", addr);
+qemu_log_mask(LOG_GUEST_ERROR, "%s:  read to unimplemented register " \
+  "at address: %#" PRIx64 "\n", reg_array->prefix, addr);
 return 0;
 }
 
-- 
2.11.0




[Qemu-devel] [PATCH 09/11] target/sparc: fix DEBUG_MMU DPRINTF() arguments

2017-05-08 Thread Philippe Mathieu-Daudé
invalid since 96df2bc99f9

Signed-off-by: Philippe Mathieu-Daudé 
---
 target/sparc/ldst_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index 57968d9143..aa83a49a88 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -1631,7 +1631,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, 
target_ulong val,
 
 if (oldreg != env->immu.mmuregs[reg]) {
 DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016"
-PRIx64 "\n", reg, oldreg, env->immuregs[reg]);
+PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]);
 }
 #ifdef DEBUG_MMU
 dump_mmu(stdout, fprintf, env);
@@ -1715,7 +1715,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, 
target_ulong val,
 
 if (oldreg != env->dmmu.mmuregs[reg]) {
 DPRINTF_MMU("dmmu change reg[%d]: 0x%016" PRIx64 " -> 0x%016"
-PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]);
+PRIx64 "\n", reg, oldreg, env->dmmu.mmuregs[reg]);
 }
 #ifdef DEBUG_MMU
 dump_mmu(stdout, fprintf, env);
-- 
2.11.0




[Qemu-devel] [PATCH 08/11] hw/sparc: use ARRAY_SIZE() macro

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/sparc64/sun4u.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index d347b6616d..525d6f44a0 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -214,7 +214,7 @@ static void isa_irq_handler(void *opaque, int n, int level)
 qemu_irq *irqs = opaque;
 int ivec;
 
-assert(n < 16);
+assert(n < ARRAY_SIZE(isa_irq_to_ivec));
 ivec = isa_irq_to_ivec[n];
 EBUS_DPRINTF("Set ISA IRQ %d level %d -> ivec 0x%x\n", n, level, ivec);
 if (ivec) {
-- 
2.11.0




[Qemu-devel] [PATCH 11/11] MAINTAINERS: self-appoint me as reviewer of the Register API

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index efdec47319..de32165059 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1431,6 +1431,7 @@ T: git git://repo.or.cz/qemu/armbru.git qapi-next
 
 Register API
 M: Alistair Francis 
+R: Philippe Mathieu-Daudé 
 S: Maintained
 F: hw/core/register.c
 F: include/hw/register.h
-- 
2.11.0




Re: [Qemu-devel] Floating point unit bugs

2017-05-08 Thread G 3

Here is version two of the floating point test program:

/ 
 
**

 * File: main.c
 * Date: 4-30-2017
 * Description: Implement a test program for various floating point  
instructions.

 * Note: tests made to work with PowerPC G3 and G5 only.
 * Compiling on Mac OS X: use gcc-3.3 -force_cpusubtype_ALL
 * Note: fsqrt test will not work on PowerPC G3.
 * Version: 2
  
 
**/


#include 
#include 
#include 
#include 
#include 

// Used to convert unsigned integer <--> double
union Converter
{
double d;
uint64_t i;
};

typedef union Converter Converter;

/* Describes the name and description of each bit of the FPSCR */
struct fpscr_info
{
char name[8];
char description[100];
};

struct fpscr_info finfo[] =
{
"FX", "Floating-point exception summary",
"FEX", "Floating-point enabled exception summary",
"VX", "Floating-point invalid operation exception summary",
"OX", "Floating-point overflow exception",
"UX", "Floating-point underflow exception",
"ZX", "Floating-point zero divide exception",
"XX", "Floating-point inexact exception",
"VXSNAN", "Floating-point invalid operation exception for SNaN",
"VXISI", "Floating-point invalid operation exception for ∞ - ∞",
"VXIDI", "Floating-point invalid operation exception for ∞/∞",
"VXZDZ", "Floating-point invalid operation exception for 0/0",
"VXIMZ", "Floating-point invalid operation exception for ∞ * 0",
"VXVC", "Floating-point invalid operation exception for invalid  
compare",

"FR", "Floating-point fraction rounded",
"FI", "Floating-point fraction inexact",
"FPRF", "Floating-point result class descriptor ",
"FPRF", "Floating-point less than or negative",
"FPRF", "Floating-point greater than or positive",
"FPRF", "Floating-point equal or zero",
"FPRF", "Floating-point unordered or NaN",
"NO NAME", "Reserved - you shouldn't be seeing this",
"VXSOFT", "Floating-point invalid operation exception for  
software request",
"VXSQRT", "Floating-point invalid operation exception for  
invalid square root",
"VXCVI", "Floating-point invalid operation exception for invalid  
integer convert",

"VE", "Floating-point invalid operation exception enable",
"OE", "IEEE floating-point overflow exception enable",
"UE", "IEEE floating-point underflow exception enable",
"ZE", "IEEE floating-point zero divide exception enable",
"XE", "Floating-point inexact exception enable",
"NI", "Floating-point non-IEEE mode",
"RN", "Rounding bit 0",
"RN", "Rounding bit 1",
};

// Prints all the FPSCR settings that are set in the input
void print_fpscr_settings(uint32_t fpscr)
{
int i;
for (i = 0; i < 32; i++) {
if ((fpscr >> i) & 0x1 == 1) {
/* right description = 31 - i  Oddity of IBM  
documentation */
printf("bit %d: %s - %s\n", 31-i, finfo[31-i].name, finfo 
[31-i].description);

}
}
}


#define ZE 27
#define set_fpscr_bit(x) asm volatile ("mtfsb1 %0" : : "i"(x))

/* Keeps track of the number of tests that failed */
int failed_tests = 0;

// Reset the FPSCR
void reset_fpscr()
{
asm volatile("mtfsb0 0");
asm volatile("mtfsb0 1");
asm volatile("mtfsb0 2");
asm volatile("mtfsb0 3");
asm volatile("mtfsb0 4");
asm volatile("mtfsb0 5");
asm volatile("mtfsb0 6");
asm volatile("mtfsb0 7");
asm volatile("mtfsb0 8");
asm volatile("mtfsb0 9");
asm volatile("mtfsb0 10");
asm volatile("mtfsb0 11");
asm volatile("mtfsb0 12");
asm volatile("mtfsb0 13");
asm volatile("mtfsb0 14");
asm volatile("mtfsb0 15");
asm volatile("mtfsb0 16");
asm volatile("mtfsb0 17");
asm volatile("mtfsb0 18");
asm volatile("mtfsb0 19");
asm volatile("mtfsb0 20");
asm volatile("mtfsb0 21");
asm volatile("mtfsb0 22");
asm volatile("mtfsb0 23");
asm volatile("mtfsb0 24");
asm volatile("mtfsb0 25");
asm volatile("mtfsb0 26");
asm volatile("mtfsb0 27");
asm volatile("mtfsb0 28");
asm volatile("mtfsb0 29");
asm volatile("mtfsb0 30");
asm volatile("mtfsb0 31");

/* Check if everything is alright */
uint32_t fpscr;
Converter c;
asm volatile("mffs %0" : "=f"(c.d));
fpscr = (uint32_t)c.i;
if (fpscr != 0) {
printf("Warning: fpscr not equal to zero: 0x%x\n", fpscr);
}
}

/*
 * The action to take if a test fails
 * Input one: message string
 * Input two: actual fpscr value
 * Input three: expected fpscr value
 * Input four: actual answer
 * Input five: expected answer
 */
 void test_failed(const char *message, uint32_t actual_fpscr,  
uint32_t expected_fpscr,

  uint64_t actual_answer, uint64_t expected_answer)
 {
printf("%s\n", message);
printf("expected answer: 0x%" PRIx64 " (%f)\n", expected_answer,  

[Qemu-devel] [PATCH 05/11] hw/mips: add missing include

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/mips/mips.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/hw/mips/mips.h b/include/hw/mips/mips.h
index e0065ce808..16412dc150 100644
--- a/include/hw/mips/mips.h
+++ b/include/hw/mips/mips.h
@@ -6,6 +6,7 @@
 #define INITRD_PAGE_MASK (~((1 << 16) - 1))
 
 #include "exec/memory.h"
+#include "hw/irq.h"
 
 /* gt64xxx.c */
 PCIBus *gt64120_register(qemu_irq *pic);
-- 
2.11.0




[Qemu-devel] [PATCH 06/11] hw/arm: removed unnecessary include

2017-05-08 Thread Philippe Mathieu-Daudé
"exec/memory.h" already includes it.

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/arm/arm.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h
index a3f79d3379..b9c11d3fb8 100644
--- a/include/hw/arm/arm.h
+++ b/include/hw/arm/arm.h
@@ -14,7 +14,6 @@
 #include "exec/memory.h"
 #include "target/arm/cpu-qom.h"
 #include "hw/irq.h"
-#include "qemu/notify.h"
 
 typedef enum {
 ARM_ENDIANNESS_UNKNOWN = 0,
-- 
2.11.0




[Qemu-devel] [PATCH 04/11] ide/ahci: add missing includes

2017-05-08 Thread Philippe Mathieu-Daudé
qemu/include/hw/ide/ahci.h:260:16: error: field ‘sglist’ has incomplete type
 QEMUSGList sglist;
^~
/qemu/include/hw/ide/ahci.h:272:5: error: unknown type name ‘IDEDMA’
 IDEDMA dma;
 ^~
qemu/include/hw/ide/ahci.h:273:5: error: unknown type name ‘IDEBus’
 IDEBus port;
 ^~
qemu/include/hw/ide/ahci.h:305:15: error: field ‘parent_obj’ has incomplete type
 PCIDevice parent_obj;
   ^~

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/ide/ahci.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/hw/ide/ahci.h b/include/hw/ide/ahci.h
index 0ca7c65820..293f9ebcd0 100644
--- a/include/hw/ide/ahci.h
+++ b/include/hw/ide/ahci.h
@@ -25,6 +25,8 @@
 #define HW_IDE_AHCI_H
 
 #include "hw/sysbus.h"
+#include "hw/ide/internal.h"
+#include "sysemu/dma.h"
 
 #define AHCI_MEM_BAR_SIZE 0x1000
 #define AHCI_MAX_PORTS32
-- 
2.11.0




[Qemu-devel] [PATCH 01/11] hw/net: removed obsolete comments

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/net/pcnet-pci.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
index 0acf8a4879..bdb533436e 100644
--- a/hw/net/pcnet-pci.c
+++ b/hw/net/pcnet-pci.c
@@ -38,14 +38,6 @@
 
 #include "pcnet.h"
 
-//#define PCNET_DEBUG
-//#define PCNET_DEBUG_IO
-//#define PCNET_DEBUG_BCR
-//#define PCNET_DEBUG_CSR
-//#define PCNET_DEBUG_RMD
-//#define PCNET_DEBUG_TMD
-//#define PCNET_DEBUG_MATCH
-
 #define TYPE_PCI_PCNET "pcnet"
 
 #define PCI_PCNET(obj) \
@@ -239,8 +231,6 @@ static const VMStateDescription vmstate_pci_pcnet = {
 }
 };
 
-/* PCI interface */
-
 static const MemoryRegionOps pcnet_mmio_ops = {
 .old_mmio = {
 .read = { pcnet_mmio_readb, pcnet_mmio_readw, pcnet_mmio_readl },
-- 
2.11.0




[Qemu-devel] [RFC PATCH 02/11] hw/pci: define msi_nonbroken in pci-stub

2017-05-08 Thread Philippe Mathieu-Daudé
This field is accessed in hw/intc/arm_gicv[23*].c

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/pci/pci-stub.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index 36d2c430c5..ecad664946 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -24,6 +24,9 @@
 #include "qapi/qmp/qerror.h"
 #include "hw/pci/pci.h"
 #include "qmp-commands.h"
+#include "hw/pci/msi.h"
+
+bool msi_nonbroken;
 
 PciInfoList *qmp_query_pci(Error **errp)
 {
-- 
2.11.0




[Qemu-devel] [PATCH 00/11] various easy cleanups

2017-05-08 Thread Philippe Mathieu-Daudé
various easy patchs added while coding around:
- remove old comments
- add/remove includes
- use TYPE_ names when available
- use ARRAY_SIZE() macro

Philippe Mathieu-Daudé (11):
  hw/net: removed obsolete comments
  hw/pci: define msi_nonbroken in pci-stub
  hw/misc: add missing includes
  ide/ahci: add missing includes
  hw/mips: add missing include
  hw/arm: removed unnecessary include
  hw/arm: use defined type name instead of hard-coded string.
  hw/sparc: use ARRAY_SIZE() macro
  target/sparc: fix DEBUG_MMU DPRINTF() arguments
  register: display register prefix (name) since it is available
  MAINTAINERS: self-appoint me as reviewer of the Register API

 MAINTAINERS|  1 +
 hw/arm/armv7m.c|  4 ++--
 hw/arm/exynos4210.c|  4 ++--
 hw/arm/highbank.c  | 11 +++
 hw/arm/realview.c  |  6 --
 hw/arm/vexpress.c  |  6 --
 hw/arm/xilinx_zynq.c   | 14 --
 hw/core/register.c |  8 
 hw/net/pcnet-pci.c | 10 --
 hw/pci/pci-stub.c  |  3 +++
 hw/sparc64/sun4u.c |  2 +-
 include/hw/arm/arm.h   |  1 -
 include/hw/ide/ahci.h  |  2 ++
 include/hw/mips/mips.h |  1 +
 include/hw/misc/unimp.h|  3 +++
 target/sparc/ldst_helper.c |  4 ++--
 16 files changed, 44 insertions(+), 36 deletions(-)

-- 
2.11.0




[Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/misc/unimp.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h
index 3462d85836..353ee19abf 100644
--- a/include/hw/misc/unimp.h
+++ b/include/hw/misc/unimp.h
@@ -8,6 +8,9 @@
 #ifndef HW_MISC_UNIMP_H
 #define HW_MISC_UNIMP_H
 
+#include "qemu/osdep.h"
+#include "hw/sysbus.h"
+
 #define TYPE_UNIMPLEMENTED_DEVICE "unimplemented-device"
 
 /**
-- 
2.11.0




Re: [Qemu-devel] [PATCH v3 0/3] arch_init: Move soundhw code to hw/audio/soundhw.c

2017-05-08 Thread no-reply
Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH v3 0/3] arch_init: Move soundhw code to 
hw/audio/soundhw.c
Type: series
Message-id: 20170508205735.23444-1-ehabk...@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag] patchew/20170508221759.15616-1-f4...@amsat.org -> 
patchew/20170508221759.15616-1-f4...@amsat.org
Switched to a new branch 'test'
ca059cc audio: Rename hw/audio/audio.h to hw/audio/soundhw.h
8cc8396 audio: Rename audio_init() to soundhw_init()
e19b303 audio: Move arch_init audio code to hw/audio/soundhw.c

=== OUTPUT BEGIN ===
Checking PATCH 1/3: audio: Move arch_init audio code to hw/audio/soundhw.c...
ERROR: suspect code indent for conditional statements (8, 13)
#240: FILE: hw/audio/soundhw.c:76:
+if (soundhw_count) {
+ printf("Valid sound card names (comma separated):\n");

ERROR: suspect code indent for conditional statements (13, 17)
#242: FILE: hw/audio/soundhw.c:78:
+ for (c = soundhw; c->name; ++c) {
+ printf ("%-11s %s\n", c->name, c->descr);

ERROR: space prohibited between function name and open parenthesis '('
#243: FILE: hw/audio/soundhw.c:79:
+ printf ("%-11s %s\n", c->name, c->descr);

ERROR: else should follow close brace '}'
#252: FILE: hw/audio/soundhw.c:88:
+}
+else {

ERROR: else should follow close brace '}'
#281: FILE: hw/audio/soundhw.c:117:
+}
+else {

WARNING: line over 80 characters
#299: FILE: hw/audio/soundhw.c:135:
+ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, 
NULL);

WARNING: line over 80 characters
#300: FILE: hw/audio/soundhw.c:136:
+PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, 
NULL);

total: 5 errors, 2 warnings, 320 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 2/3: audio: Rename audio_init() to soundhw_init()...
Checking PATCH 3/3: audio: Rename hw/audio/audio.h to hw/audio/soundhw.h...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@freelists.org

Re: [Qemu-devel] [PATCH 0/5] 9pfs: local: fix metadata of mapped-file security mode

2017-05-08 Thread Leo Gaspard
Greg,

I just tested on 2.9.0 with the 5 patches applied, and it appears to
work on my setup, thanks!

Just a side note: .virtfs_metadata_root is set as u=rwx on the host file
system (the "ret = fchmod(map_fd, 0700);" line in patch 4 I guess),
while u=rw would be more appropriate, I think.

Thank you,
Leo


On 05/05/2017 04:36 PM, Greg Kurz wrote:
> This series fixes two issues in the local backend when using the mapped-file
> security mode:
> - allow chmod and chown to succeed on the virtfs root (patch 4)
> - completely hide the metadata files from the client (patch 5)
> 
> Patch 2 resolves '.' and '..' in paths, and patch 3 reworks the way we open
> files accordingly. They could be squashed together in a single patch (this
> was the case in earlier versions actually), but I decided to separate them
> for easier review.
> 
> Léo,
> 
> I'd appreciate if you could test this series (especially patch 4) on your
> setup.
> 
> Cheers.
> 
> --
> Greg
> 
> ---
> 
> Greg Kurz (5):
>   9pfs: check return value of v9fs_co_name_to_path()
>   9pfs: local: resolve special directories in paths
>   9pfs: local: simplify file opening
>   9pfs: local: metadata file for the VirtFS root
>   9pfs: local: forbid client access to metadata
> 
> 
>  hw/9pfs/9p-local.c |  164 
> 
>  hw/9pfs/9p-util.c  |   26 +++-
>  hw/9pfs/9p.c   |   36 ---
>  3 files changed, 160 insertions(+), 66 deletions(-)
> 



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] Floating point unit bugs

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 18:36, G 3 wrote:
> 
> On May 8, 2017, at 6:13 PM, Aurelien Jarno wrote:
> 
> > On 2017-05-07 17:48, G 3 wrote:
> > > I made a diagnostic program for the floating point unit. It will test
> > > various PowerPC floating point instructions for compatibility with
> > > the
> > > PowerPC G3 processor. It was tested on a PowerPC G3 and G5 system.
> > > The
> > > results of the program in qemu-system-ppc were pretty bad. About
> > > every
> > > instruction tested is not implemented correctly.
> > > 
> > > Here is the download link to the program: 
> > > http://www.mediafire.com/file/6j9tqubvk73lkw1/floating_point_test_program.zip
> > 
> > Some comments on the code.
> > > 
> > > /* Check if everything is alright */
> > > uint32_t fpscr;
> > > asm volatile("mffs f0");
> > > asm volatile("stfd f0, 40(r1)");
> > > asm volatile("lwz %0, 44(r1)" : "=r"(fpscr));
> > > if (fpscr != 0) {
> > > printf("Warning: fpscr not equal to zero: 0x%x\n", fpscr);
> > > }
> > 
> > This is overly complicated and just doesn't compile with recent GCC
> > versions.
> 
> Which version of GCC had the problem? GCC 5.2 and GCC 3.3 seems to work
> fine. GCC 4.0 did not work. Could you send me the error message?

I tried with GCC 4.9. Actually the error message is coming from
binutils:

| main.c:34:5: warning: missing braces around initializer [-Wmissing-braces]
|  "FX", "Floating-point exception summary",
|  ^
| main.c:34:5: warning: (near initialization for 'finfo[0]') [-Wmissing-braces]
| main.c: In function 'print_fpscr_settings':
| main.c:73:26: warning: suggest parentheses around comparison in operand of 
'&' [-Wparentheses]
|  if ((fpscr >> i) & 0x1 == 1) {
|   ^
| main.c: In function 'test_failed':
| main.c:146:5: warning: format '%llx' expects argument of type 'long long 
unsigned int', but argument 2 has type 'uint32_t' [-Wformat=]
|  printf("  actual answer: 0x%" PRIx64 "\n", actual_fpscr);
|  ^
| /tmp/cctHPRx4.s: Assembler messages:
| /tmp/cctHPRx4.s:315: Error: unsupported relocation against f0
| /tmp/cctHPRx4.s:318: Error: unsupported relocation against f0
| /tmp/cctHPRx4.s:318: Error: unsupported relocation against r1
| /tmp/cctHPRx4.s:321: Error: unsupported relocation against r1
| /tmp/cctHPRx4.s:438: Error: unsupported relocation against f0
| /tmp/cctHPRx4.s:441: Error: unsupported relocation against f0
| /tmp/cctHPRx4.s:441: Error: unsupported relocation against r1
| /tmp/cctHPRx4.s:444: Error: unsupported relocation against r1

> > What about something like:
> > 
> > Converter c;
> > asm volatile("mffs %0" : "=f"(c.d));
> > fpscr = (uint32_t)c.i;
> 
> This way does work also.
> 
> > 
> > 
> > > /*
> > >  * The action to take if a test fails
> > >  * Input one: message string
> > >  * Input two: actual fpscr value
> > >  * Input three: expected fpscr value
> > >  * Input four: actual answer
> > >  * Input five: expected answer
> > >  */
> > >  void test_failed(const char *message, uint32_t actual_fpscr,
> > > uint32_t
> > > expected_fpscr,
> > >   uint64_t actual_answer, uint64_t expected_answer)
> > >  {
> > > printf("%s\n", message);
> > > printf("expected answer: 0x%" PRIx64 "\n", expected_answer);
> > > printf("  actual answer: 0x%" PRIx64 "\n", actual_fpscr);
> > 
> > This is wrong. It should be actual_answer instead of actual_fpscr. That
> > is why all the instructions seems totally wrongly implemented.
> 
> Thanks for catching this error. Actually this would only effect the "actual
> answer:" output field. The comparison between expected_answer and
> actual_answer in each individual test is still valid.

Indeed, but I guess it gives "better" results than what it looks when
looking at your mail where the values are totally wrong.

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] Floating point unit bugs

2017-05-08 Thread G 3


On May 8, 2017, at 6:13 PM, Aurelien Jarno wrote:


On 2017-05-07 17:48, G 3 wrote:

I made a diagnostic program for the floating point unit. It will test
various PowerPC floating point instructions for compatibility with  
the
PowerPC G3 processor. It was tested on a PowerPC G3 and G5 system.  
The
results of the program in qemu-system-ppc were pretty bad. About  
every

instruction tested is not implemented correctly.

Here is the download link to the program: http://www.mediafire.com/ 
file/6j9tqubvk73lkw1/floating_point_test_program.zip


Some comments on the code.


/* Check if everything is alright */
uint32_t fpscr;
asm volatile("mffs f0");
asm volatile("stfd f0, 40(r1)");
asm volatile("lwz %0, 44(r1)" : "=r"(fpscr));
if (fpscr != 0) {
printf("Warning: fpscr not equal to zero: 0x%x\n", fpscr);
}


This is overly complicated and just doesn't compile with recent GCC
versions.


Which version of GCC had the problem? GCC 5.2 and GCC 3.3 seems to  
work fine. GCC 4.0 did not work. Could you send me the error message?



What about something like:

Converter c;
asm volatile("mffs %0" : "=f"(c.d));
fpscr = (uint32_t)c.i;


This way does work also.





/*
 * The action to take if a test fails
 * Input one: message string
 * Input two: actual fpscr value
 * Input three: expected fpscr value
 * Input four: actual answer
 * Input five: expected answer
 */
 void test_failed(const char *message, uint32_t actual_fpscr,  
uint32_t

expected_fpscr,
  uint64_t actual_answer, uint64_t expected_answer)
 {
printf("%s\n", message);
printf("expected answer: 0x%" PRIx64 "\n", expected_answer);
printf("  actual answer: 0x%" PRIx64 "\n", actual_fpscr);


This is wrong. It should be actual_answer instead of actual_fpscr.  
That

is why all the instructions seems totally wrongly implemented.


Thanks for catching this error. Actually this would only effect the  
"actual answer:" output field. The comparison between expected_answer  
and actual_answer in each individual test is still valid.



Note that
compiling with -Wall would give you a warning:

| main.c: In function ‘test_failed’:
| main.c:146:5: warning: format ‘%llx’ expects argument of type  
‘long long unsigned int’, but argument 2 has type ‘uint32_t’ [- 
Wformat=]

|  printf("  actual answer: 0x%" PRIx64 "\n", actual_fpscr);
|  ^



Replacing actual_fpscr with actual_answer should solve this problem.




Re: [Qemu-devel] Floating point unit bugs

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 18:09, G 3 wrote:
> 
> On May 8, 2017, at 5:54 PM, Aurelien Jarno wrote:
> 
> > On 2017-05-07 17:48, G 3 wrote:
> > > I made a diagnostic program for the floating point unit. It will test
> > > various PowerPC floating point instructions for compatibility with
> > > the
> > > PowerPC G3 processor. It was tested on a PowerPC G3 and G5 system.
> > > The
> > > results of the program in qemu-system-ppc were pretty bad. About
> > > every
> > > instruction tested is not implemented correctly.
> > 
> > I don't say that qemu-system-ppc is bug free, but this looks suspicious
> > that about every instruction is buggy.
> 
> I really hope you don't think I'm blaming anyone. I'm only reporting the
> results of the test.
> 
> > Have you tried to run your
> > program on a real G3 or G5 system?
> 
> Yes. I made sure it ran on a real G3 and G5 system without problem before
> testing it on QEMU. I suspect the Motorola designed G4 processor will not be
> compatible. I don't have a working G4 system to verify this unfortunately.
> 
> > 
> > [ snip ]
> > 
> > > 
> > > Here is the full test results after running this program in 
> > > qemu-system-ppc
> > > with a Mac OS 10.4 guest:
> > > 
> > > 
> > > 
> > > 
> > > fadd test failed
> > > expected answer: 0x3ff4
> > >   actual answer: 0x82004024
> > > expected fpscr: 0x82064000
> > >   actual fpscr: 0x82004000
> > 
> > This looks highly suspicious that the actual answer match the expected
> > answer.
> 
> You can use this web page to find the decimal value: 
> http://www6.uniovi.es/~antonio/uned/ieee754/IEEE-754hex64.html
> 
> 0x3ff4 = 1.2002
> 0x82004024 = -4.8529708162167760e-299
> 
> The expected answer and actual answer are very far from each other.

Yes, I made a typo in my comment. I wanted to say that I found very
suspicious that the actual answer match the actual fpscr. See my other
mail for the reason.

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



[Qemu-devel] [PATCH v2 21/21] MAINTAINERS: self-appoint me as reviewer in build/test automation

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Alex Bennée 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6d0770fdd0..d61380837a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1827,6 +1827,7 @@ Build and test automation
 -
 M: Alex Bennée 
 M: Fam Zheng 
+R: Philippe Mathieu-Daudé 
 L: qemu-devel@nongnu.org
 S: Maintained
 F: .travis.yml
-- 
2.11.0




[Qemu-devel] [PATCH v2 17/21] shippable: add armeb-linux-user target

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 .shippable.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.shippable.yml b/.shippable.yml
index fe360f85cb..2070c4d827 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -6,7 +6,7 @@ env:
 - LC_ALL=C
   matrix:
 - IMAGE=debian-armhf-cross
-  TARGET_LIST=arm-softmmu,arm-linux-user
+  TARGET_LIST=arm-softmmu,arm-linux-user,armeb-linux-user
 - IMAGE=debian-arm64-cross
   TARGET_LIST=aarch64-softmmu,aarch64-linux-user
 - IMAGE=debian-s390x-cross
-- 
2.11.0




[Qemu-devel] [PATCH v2 20/21] MAINTAINERS: add Shippable automation platform URL

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Alex Bennée 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index efdec47319..6d0770fdd0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1833,6 +1833,7 @@ F: .travis.yml
 F: .shippable.yml
 F: tests/docker/
 W: https://travis-ci.org/qemu/qemu
+W: https://app.shippable.com/github/qemu/qemu
 W: http://patchew.org/QEMU/
 
 Documentation
-- 
2.11.0




[Qemu-devel] [PATCH v2 15/21] shippable: do not initialize submodules automatically

2017-05-08 Thread Philippe Mathieu-Daudé
instead do it in the 'ci' target when needed.

for mips64el-softmmu target:
use dtc submodule if distrib packages are too old.

example with outdated libfdt on mips64el-softmmu target (required is >= 1.4.2):
 # dpkg-query --showformat='${Version}\n' --show libfdt-dev
 1.4.0+dfsg-1

shippable output:

  LINKmips64el-softmmu/qemu-system-mips64el
../hw/core/loader-fit.o: In function `load_fit':
/root/src/github.com/philmd/qemu/hw/core/loader-fit.c:278: undefined reference 
to `fdt_first_subnode'
/root/src/github.com/philmd/qemu/hw/core/loader-fit.c:286: undefined reference 
to `fdt_next_subnode'
/root/src/github.com/philmd/qemu/hw/core/loader-fit.c:277: undefined reference 
to `fdt_first_subnode'
collect2: error: ld returned 1 exit status
Makefile:201: recipe for target 'qemu-system-mips64el' failed
make[1]: *** [qemu-system-mips64el] Error 1
Makefile:327: recipe for target 'subdir-mips64el-softmmu' failed
make: *** [subdir-mips64el-softmmu] Error 2

Signed-off-by: Philippe Mathieu-Daudé 
---
 .shippable.yml | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/.shippable.yml b/.shippable.yml
index 1e3ae35dd9..46adfa030f 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -1,4 +1,6 @@
 language: c
+git:
+   submodules: false
 env:
   global:
 - LC_ALL=C
@@ -19,5 +21,13 @@ build:
 options: "-e HOME=/root"
   ci:
 - unset CC
+# some targets require newer up to date packages, for example TARGET_LIST 
matching
+# 
aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
+# see the configure script:
+#error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:"
+#"  (1) Preferred: Install the DTC (libfdt) devel package"
+#"  (2) Fetch the DTC submodule, using:"
+#"  git submodule update --init dtc"
+- dpkg --compare-versions `dpkg-query --showformat='${Version}' --show 
libfdt-dev` ge 1.4.2 || git submodule update --init dtc
 - ./configure ${QEMU_CONFIGURE_OPTS} --target-list=${TARGET_LIST}
 - make -j$(($(getconf _NPROCESSORS_ONLN) + 1))
-- 
2.11.0




[Qemu-devel] [PATCH v2 12/21] docker: add powerpc build target

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/Makefile.include  |  2 ++
 .../docker/dockerfiles/debian-powerpc-cross.docker | 31 ++
 2 files changed, 33 insertions(+)
 create mode 100644 tests/docker/dockerfiles/debian-powerpc-cross.docker

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index f34282a2cb..417d8ea576 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -56,11 +56,13 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
"BUILD","$*")
 
 docker-image-debian-mipsel-cross: 
EXTRA_FILE:=tests/docker/dockerfiles/debian-apt-fake.sh
+docker-image-debian-powerpc-cross: 
EXTRA_FILE:=tests/docker/dockerfiles/debian-apt-fake.sh
 
 # Enforce dependancies for composite images
 docker-image-debian-armhf-cross: docker-image-debian
 docker-image-debian-arm64-cross: docker-image-debian
 docker-image-debian-mipsel-cross: docker-image-debian
+docker-image-debian-powerpc-cross: docker-image-debian
 
 # Expand all the pre-requistes for each docker image and test combination
 $(foreach i,$(DOCKER_IMAGES), \
diff --git a/tests/docker/dockerfiles/debian-powerpc-cross.docker 
b/tests/docker/dockerfiles/debian-powerpc-cross.docker
new file mode 100644
index 00..e0d4c454cc
--- /dev/null
+++ b/tests/docker/dockerfiles/debian-powerpc-cross.docker
@@ -0,0 +1,31 @@
+#
+# Docker powerpc cross-compiler target
+#
+# This docker target builds on the base debian image.
+#
+FROM qemu:debian
+MAINTAINER Philippe Mathieu-Daudé 
+
+# Add the foreign architecture we want and install dependencies
+RUN dpkg --add-architecture powerpc && \
+apt-get update && \
+DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
+crossbuild-essential-powerpc
+
+#  to fix "following packages have unmet dependencies" ...
+ADD debian-apt-fake.sh /usr/local/bin/apt-fake
+RUN apt-get install -y --no-install-recommends equivs pkg-config && \
+apt-fake install pkg-config:powerpc=0.28-1.1-fake && \
+ln -s pkg-config /usr/bin/powerpc-linux-gnu-pkg-config
+ENV PKG_CONFIG_PATH /usr/lib/powerpc-linux-gnu/pkgconfig
+# 
+
+# Specify the cross prefix for this image (see tests/docker/common.rc)
+ENV QEMU_CONFIGURE_OPTS --cross-prefix=powerpc-linux-gnu-
+
+RUN DEBIAN_FRONTEND=noninteractive eatmydata apt-get build-dep -yy -a powerpc 
qemu && \
+DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
+glusterfs-common:powerpc \
+libncursesw5-dev:powerpc libnfs-dev:powerpc \
+libbz2-dev:powerpc liblzo2-dev:powerpc \
+libsnappy-dev:powerpc librdmacm-dev:powerpc
-- 
2.11.0




[Qemu-devel] [PATCH v2 18/21] shippable: add powerpc target

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 .shippable.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.shippable.yml b/.shippable.yml
index 2070c4d827..aad66ec5ec 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -11,6 +11,8 @@ env:
   TARGET_LIST=aarch64-softmmu,aarch64-linux-user
 - IMAGE=debian-s390x-cross
   TARGET_LIST=s390x-softmmu,s390x-linux-user
+- IMAGE=debian-powerpc-cross
+  TARGET_LIST=ppc-softmmu,ppcemb-softmmu,ppc-linux-user
 build:
   pre_ci:
 - make docker-image-${IMAGE} V=1
-- 
2.11.0




[Qemu-devel] [PATCH v2 14/21] shippable: build using all available cpus

2017-05-08 Thread Philippe Mathieu-Daudé
As of this commit:

$ echo "container proc:" `getconf _NPROCESSORS_ONLN` `getconf _NPROCESSORS_CONF`
container proc: 2 2

Signed-off-by: Philippe Mathieu-Daudé 
---
 .shippable.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.shippable.yml b/.shippable.yml
index 231c29b620..1e3ae35dd9 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -20,4 +20,4 @@ build:
   ci:
 - unset CC
 - ./configure ${QEMU_CONFIGURE_OPTS} --target-list=${TARGET_LIST}
-- make -j2
+- make -j$(($(getconf _NPROCESSORS_ONLN) + 1))
-- 
2.11.0




[Qemu-devel] [PATCH v2 19/21] shippable: add mipsel target

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 .shippable.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.shippable.yml b/.shippable.yml
index aad66ec5ec..75c2895a21 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -13,6 +13,9 @@ env:
   TARGET_LIST=s390x-softmmu,s390x-linux-user
 - IMAGE=debian-powerpc-cross
   TARGET_LIST=ppc-softmmu,ppcemb-softmmu,ppc-linux-user
+# mips64el-softmmu disabled due to libfdt problem
+- IMAGE=debian-mipsel-cross
+  TARGET_LIST=mipsel-softmmu,mipsel-linux-user,mips64el-linux-user
 build:
   pre_ci:
 - make docker-image-${IMAGE} V=1
-- 
2.11.0




[Qemu-devel] [PATCH v2 08/21] docker: add extra libs to armhf target to extend codebase coverage

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/dockerfiles/debian-armhf-cross.docker | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/docker/dockerfiles/debian-armhf-cross.docker 
b/tests/docker/dockerfiles/debian-armhf-cross.docker
index 533e525971..01d9fcb7f2 100644
--- a/tests/docker/dockerfiles/debian-armhf-cross.docker
+++ b/tests/docker/dockerfiles/debian-armhf-cross.docker
@@ -14,4 +14,10 @@ RUN dpkg --add-architecture armhf && \
 # Specify the cross prefix for this image (see tests/docker/common.rc)
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=arm-linux-gnueabihf-
 
-RUN DEBIAN_FRONTEND=noninteractive eatmydata apt-get build-dep -yy -a armhf 
qemu
+RUN DEBIAN_FRONTEND=noninteractive eatmydata apt-get build-dep -yy -a armhf 
qemu && \
+DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
+glusterfs-common:armhf \
+libncursesw5-dev:armhf libnfs-dev:armhf \
+libbz2-dev:armhf liblzo2-dev:armhf \
+libsnappy-dev:armhf librdmacm-dev:armhf \
+libxen-dev:armhf
-- 
2.11.0




[Qemu-devel] [PATCH v2 10/21] docker: add extra libs to s390x target to extend codebase coverage

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/dockerfiles/debian-s390x-cross.docker | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tests/docker/dockerfiles/debian-s390x-cross.docker 
b/tests/docker/dockerfiles/debian-s390x-cross.docker
index 3a687feda0..119b152971 100644
--- a/tests/docker/dockerfiles/debian-s390x-cross.docker
+++ b/tests/docker/dockerfiles/debian-s390x-cross.docker
@@ -20,3 +20,9 @@ RUN apt install -yy gcc-multilib-s390x-linux-gnu 
binutils-multiarch
 
 # Specify the cross prefix for this image (see tests/docker/common.rc)
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=s390x-linux-gnu-
+
+RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
+glusterfs-common:s390x \
+libncursesw5-dev:s390x libnfs-dev:s390x \
+libbz2-dev:s390x liblzo2-dev:s390x \
+libsnappy-dev:s390x librdmacm-dev:s390x
-- 
2.11.0




[Qemu-devel] [PATCH v2 13/21] shippable: use C locale to simplify console output

2017-05-08 Thread Philippe Mathieu-Daudé
remove this noise:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_CTYPE = "en_US.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Alex Bennée 
---
 .shippable.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.shippable.yml b/.shippable.yml
index 653bd750fe..231c29b620 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -1,5 +1,7 @@
 language: c
 env:
+  global:
+- LC_ALL=C
   matrix:
 - IMAGE=debian-armhf-cross
   TARGET_LIST=arm-softmmu,arm-linux-user
-- 
2.11.0




[Qemu-devel] [PATCH v2 16/21] shippable: be verbose while building docker images

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 .shippable.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.shippable.yml b/.shippable.yml
index 46adfa030f..fe360f85cb 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -13,7 +13,7 @@ env:
   TARGET_LIST=s390x-softmmu,s390x-linux-user
 build:
   pre_ci:
-- make docker-image-${IMAGE}
+- make docker-image-${IMAGE} V=1
   pre_ci_boot:
 image_name: qemu
 image_tag: ${IMAGE}
-- 
2.11.0




[Qemu-devel] [PATCH v2 06/21] docker: compact debian armhf

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/dockerfiles/debian-armhf-cross.docker | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/docker/dockerfiles/debian-armhf-cross.docker 
b/tests/docker/dockerfiles/debian-armhf-cross.docker
index 668d60aeb3..533e525971 100644
--- a/tests/docker/dockerfiles/debian-armhf-cross.docker
+++ b/tests/docker/dockerfiles/debian-armhf-cross.docker
@@ -6,10 +6,12 @@
 FROM qemu:debian
 
 # Add the foreign architecture we want and install dependencies
-RUN dpkg --add-architecture armhf
-RUN apt update
-RUN apt install -yy crossbuild-essential-armhf
-RUN apt-get build-dep -yy -a armhf qemu
+RUN dpkg --add-architecture armhf && \
+apt-get update && \
+DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
+crossbuild-essential-armhf
 
 # Specify the cross prefix for this image (see tests/docker/common.rc)
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=arm-linux-gnueabihf-
+
+RUN DEBIAN_FRONTEND=noninteractive eatmydata apt-get build-dep -yy -a armhf 
qemu
-- 
2.11.0




[Qemu-devel] [PATCH v2 04/21] docker: install ca-certificates package in base image

2017-05-08 Thread Philippe Mathieu-Daudé
Resolve SSL verification issue at shippable container's git_sync stage:

shippable logs:
--
git_sync
- ssh-agent bash -c 'ssh-add /tmp/ssh/01_deploy; git clone 
https://github.com/philmd/qemu.git /root/src/github.com/philmd/qemu'
Identity added: /tmp/ssh/01_deploy (rsa w/o comment)
Cloning into '/root/src/github.com/philmd/qemu'...
fatal: unable to access 'https://github.com/philmd/qemu.git/': Problem with the 
SSL CA cert (path? access rights?)
retrying 1 of 3 times...

Suggested-by: Alex Bennée 
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/dockerfiles/debian.docker | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/docker/dockerfiles/debian.docker 
b/tests/docker/dockerfiles/debian.docker
index 52bd79938e..d08def6a8d 100644
--- a/tests/docker/dockerfiles/debian.docker
+++ b/tests/docker/dockerfiles/debian.docker
@@ -11,7 +11,7 @@ FROM debian:stable-slim
 
 # Setup some basic tools we need
 RUN apt update
-RUN apt install -yy curl aptitude
+RUN apt install -yy aptitude ca-certificates curl
 
 # Setup Emdebian
 RUN echo "deb http://emdebian.org/tools/debian/ jessie main" >> 
/etc/apt/sources.list
-- 
2.11.0




[Qemu-devel] [PATCH v2 11/21] docker: add mipsel build target

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/Makefile.include  |  3 +++
 .../docker/dockerfiles/debian-mipsel-cross.docker  | 31 ++
 2 files changed, 34 insertions(+)
 create mode 100644 tests/docker/dockerfiles/debian-mipsel-cross.docker

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index c99ce702ea..f34282a2cb 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -55,9 +55,12 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
$(if $(EXTRA_FILE),--include-file=$(EXTRA_FILE)),\
"BUILD","$*")
 
+docker-image-debian-mipsel-cross: 
EXTRA_FILE:=tests/docker/dockerfiles/debian-apt-fake.sh
+
 # Enforce dependancies for composite images
 docker-image-debian-armhf-cross: docker-image-debian
 docker-image-debian-arm64-cross: docker-image-debian
+docker-image-debian-mipsel-cross: docker-image-debian
 
 # Expand all the pre-requistes for each docker image and test combination
 $(foreach i,$(DOCKER_IMAGES), \
diff --git a/tests/docker/dockerfiles/debian-mipsel-cross.docker 
b/tests/docker/dockerfiles/debian-mipsel-cross.docker
new file mode 100644
index 00..e4e8d22a7c
--- /dev/null
+++ b/tests/docker/dockerfiles/debian-mipsel-cross.docker
@@ -0,0 +1,31 @@
+#
+# Docker mipsel cross-compiler target
+#
+# This docker target builds on the base debian image.
+#
+FROM qemu:debian
+MAINTAINER Philippe Mathieu-Daudé 
+
+# Add the foreign architecture we want and install dependencies
+RUN dpkg --add-architecture mipsel && \
+apt-get update && \
+DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
+crossbuild-essential-mipsel
+
+#  to fix "following packages have unmet dependencies" ...
+ADD debian-apt-fake.sh /usr/local/bin/apt-fake
+RUN apt-get install -y --no-install-recommends equivs pkg-config && \
+apt-fake install pkgconf:mipsel=0.9.7-fake pkg-config:mipsel=0.28-1.1-fake 
&& \
+ln -s pkg-config /usr/bin/mipsel-linux-gnu-pkg-config
+ENV PKG_CONFIG_PATH /usr/lib/mipsel-linux-gnu/pkgconfig
+# 
+
+# Specify the cross prefix for this image (see tests/docker/common.rc)
+ENV QEMU_CONFIGURE_OPTS --cross-prefix=mipsel-linux-gnu-
+
+RUN DEBIAN_FRONTEND=noninteractive eatmydata apt-get build-dep -yy -a mipsel 
qemu && \
+DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
+glusterfs-common:mipsel \
+libncursesw5-dev:mipsel libnfs-dev:mipsel \
+libbz2-dev:mipsel liblzo2-dev:mipsel \
+libsnappy-dev:mipsel librdmacm-dev:mipsel
-- 
2.11.0




[Qemu-devel] [PATCH v2 05/21] docker: compact debian base

2017-05-08 Thread Philippe Mathieu-Daudé
- install common/basic tools at once
- use eatmydata and remove apt cache to save space
- add bison and flex and git
- create deb-src entry and setup Emdebian in the same layer

Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/dockerfiles/debian.docker | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/tests/docker/dockerfiles/debian.docker 
b/tests/docker/dockerfiles/debian.docker
index d08def6a8d..dcded3ce84 100644
--- a/tests/docker/dockerfiles/debian.docker
+++ b/tests/docker/dockerfiles/debian.docker
@@ -9,17 +9,17 @@
 #
 FROM debian:stable-slim
 
-# Setup some basic tools we need
-RUN apt update
-RUN apt install -yy aptitude ca-certificates curl
+# Install some basic tools and common build utilities
+RUN apt-get update && \
+DEBIAN_FRONTEND=noninteractive apt-get install -yy \
+eatmydata && \
+DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
+aptitude ca-certificates curl \
+build-essential clang git \
+bison flex && \
+apt-get clean
 
-# Setup Emdebian
-RUN echo "deb http://emdebian.org/tools/debian/ jessie main" >> 
/etc/apt/sources.list
-RUN curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | 
apt-key add -
-
-# Duplicate deb line as deb-src
-RUN cat /etc/apt/sources.list | sed "s/deb/deb-src/" >> /etc/apt/sources.list
-
-# Install common build utilities
-RUN apt update
-RUN apt install -yy build-essential clang
+# Duplicate deb line as deb-src, setup Emdebian
+RUN cat /etc/apt/sources.list | sed "s/deb/deb-src/" >> /etc/apt/sources.list 
&& \
+echo "deb http://emdebian.org/tools/debian/ jessie main" >> 
/etc/apt/sources.list && \
+curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | 
apt-key add -
-- 
2.11.0




[Qemu-devel] [PATCH v2 03/21] docker: add 'apt-fake' script which generate fake debian packages

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/dockerfiles/debian-apt-fake.sh | 46 +
 1 file changed, 46 insertions(+)
 create mode 100755 tests/docker/dockerfiles/debian-apt-fake.sh

diff --git a/tests/docker/dockerfiles/debian-apt-fake.sh 
b/tests/docker/dockerfiles/debian-apt-fake.sh
new file mode 100755
index 00..387522c174
--- /dev/null
+++ b/tests/docker/dockerfiles/debian-apt-fake.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+#
+# Generate fake debian package to resolve unimportant unmet dependencies held
+# by upstream multiarch broken packages.
+#
+# Copyright (c) 2017 Philippe Mathieu-Daudé 
+#
+# This work is licensed under the terms of the GNU GPL, version 2
+# or (at your option) any later version. See the COPYING file in
+# the top-level directory.
+
+test $1 = "install" && shift 1
+
+fake_install()
+{
+echo "Generating fake $2 $1 $3 ..."
+(cd /var/cache/apt/archives
+(cat << 'EOF'
+Section: misc
+Priority: optional
+Standards-Version: 3.9.2
+
+Package: NAME
+Version: VERSION
+Maintainer: qemu-devel@nongnu.org
+Architecture: any
+Multi-Arch: same
+Description: fake NAME
+EOF
+) | sed s/NAME/$2/g | sed s/VERSION/$3/g > $2.control
+equivs-build -a $1 $2.control 1>/dev/null 2>/dev/null
+dpkg -i $2_$3_$1.deb
+)
+}
+
+try_install()
+{
+name=$(echo $1|sed "s/\(.*\):\(.*\)=\(.*\)/\1/")
+arch=$(echo $1|sed "s/\(.*\):\(.*\)=\(.*\)/\2/")
+vers=$(echo $1|sed "s/\(.*\):\(.*\)=\(.*\)/\3/")
+apt-get install -q -yy $1 || fake_install $arch $name $vers
+}
+
+for package in $*; do
+try_install $package
+done
-- 
2.11.0




[Qemu-devel] [PATCH v2 09/21] docker: add extra libs to arm64 target to extend codebase coverage

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/dockerfiles/debian-arm64-cross.docker | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/docker/dockerfiles/debian-arm64-cross.docker 
b/tests/docker/dockerfiles/debian-arm64-cross.docker
index 12b30aae54..5e0036917b 100644
--- a/tests/docker/dockerfiles/debian-arm64-cross.docker
+++ b/tests/docker/dockerfiles/debian-arm64-cross.docker
@@ -14,4 +14,10 @@ RUN dpkg --add-architecture arm64 && \
 # Specify the cross prefix for this image (see tests/docker/common.rc)
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=aarch64-linux-gnu-
 
-RUN DEBIAN_FRONTEND=noninteractive eatmydata apt-get build-dep -yy -a arm64 
qemu
+RUN DEBIAN_FRONTEND=noninteractive eatmydata apt-get build-dep -yy -a arm64 
qemu && \
+DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
+glusterfs-common:arm64 \
+libncursesw5-dev:arm64 libnfs-dev:arm64 \
+libbz2-dev:arm64 liblzo2-dev:arm64 \
+libsnappy-dev:arm64 librdmacm-dev:arm64 \
+libxen-dev:arm64
-- 
2.11.0




[Qemu-devel] [PATCH v2 07/21] docker: compact debian arm64

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/dockerfiles/debian-arm64-cross.docker | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/docker/dockerfiles/debian-arm64-cross.docker 
b/tests/docker/dockerfiles/debian-arm64-cross.docker
index 592b5d7055..12b30aae54 100644
--- a/tests/docker/dockerfiles/debian-arm64-cross.docker
+++ b/tests/docker/dockerfiles/debian-arm64-cross.docker
@@ -6,10 +6,12 @@
 FROM qemu:debian
 
 # Add the foreign architecture we want and install dependencies
-RUN dpkg --add-architecture arm64
-RUN apt update
-RUN apt install -yy crossbuild-essential-arm64
-RUN apt-get build-dep -yy -a arm64 qemu
+RUN dpkg --add-architecture arm64 && \
+apt-get update && \
+DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
+crossbuild-essential-arm64
 
 # Specify the cross prefix for this image (see tests/docker/common.rc)
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=aarch64-linux-gnu-
+
+RUN DEBIAN_FRONTEND=noninteractive eatmydata apt-get build-dep -yy -a arm64 
qemu
-- 
2.11.0




[Qemu-devel] [PATCH v2 00/21] docker/shippable: cross-build mipsel and powerpc targets

2017-05-08 Thread Philippe Mathieu-Daudé
This patchset add 2 more architectures to the cross-build farm.

There is still some issue trying to cross-build mips64el-softmmu, it seems the
cross tools use the system outdated libfdt instead of the one checkouted in the
dtc submodule. I disabled this target for now.

The branch https://github.com/philmd/qemu/tree/docker_shippable_v2 can be
checked at Shippable:
  https://app.shippable.com/github/philmd/qemu/status/dashboard

With the free open source projects service, each arch builds in around ~8min,
the 5 jobs take ~38min in total.

v2:
- Addressed review feedback from Alex, added his R-B
- Fixed the "Problem with the SSL CA cert" problem while cloning from github.com
  installing the ca-certificates package.
- Squashed/split some commits
- use 'apt-get clean' instead of brutal 'rm -rf'
- checked how many cores are available on Shippable and use them fully
  (reduced total time from 44min to 38min)
- build armeb-linux-user target

v1:
- Reorganize Dockerfiles to use less layers, resulting in smaller images.
  This also reduce time of image transfer, for example while using:
  `docker save qemu:debian | ssh remote docker load`
- Install more debian packages so the configure script enable more features and
  more code can be compiled/covered.
- There are still some incorrect multiarch packages on debian/jessie used in
  the docker images, add a script to generate fake packages and avoid
  dependencies issues.
- Modify the docker.py script to include an extra file while building images.

Regards,

Phil.

Philippe Mathieu-Daudé (21):
  docker: let _copy_with_mkdir() sub_path argument be optional
  docker: add --include-file argument to 'build' command
  docker: add 'apt-fake' script which generate fake debian packages
  docker: install ca-certificates package in base image
  docker: compact debian base
  docker: compact debian armhf
  docker: compact debian arm64
  docker: add extra libs to armhf target to extend codebase coverage
  docker: add extra libs to arm64 target to extend codebase coverage
  docker: add extra libs to s390x target to extend codebase coverage
  docker: add mipsel build target
  docker: add powerpc build target
  shippable: use C locale to simplify console output
  shippable: build using all available cpus
  shippable: do not initialize submodules automatically
  shippable: be verbose while building docker images
  shippable: add armeb-linux-user target
  shippable: add powerpc target
  shippable: add mipsel target
  MAINTAINERS: add Shippable automation platform URL
  MAINTAINERS: self-appoint me as reviewer in build/test automation

 .shippable.yml | 23 +--
 MAINTAINERS|  2 +
 tests/docker/Makefile.include  |  8 +++-
 tests/docker/docker.py |  7 +++-
 tests/docker/dockerfiles/debian-apt-fake.sh| 46 ++
 tests/docker/dockerfiles/debian-arm64-cross.docker | 16 ++--
 tests/docker/dockerfiles/debian-armhf-cross.docker | 16 ++--
 .../docker/dockerfiles/debian-mipsel-cross.docker  | 31 +++
 .../docker/dockerfiles/debian-powerpc-cross.docker | 31 +++
 tests/docker/dockerfiles/debian-s390x-cross.docker |  6 +++
 tests/docker/dockerfiles/debian.docker | 26 ++--
 11 files changed, 186 insertions(+), 26 deletions(-)
 create mode 100755 tests/docker/dockerfiles/debian-apt-fake.sh
 create mode 100644 tests/docker/dockerfiles/debian-mipsel-cross.docker
 create mode 100644 tests/docker/dockerfiles/debian-powerpc-cross.docker

-- 
2.11.0




[Qemu-devel] [PATCH v2 01/21] docker: let _copy_with_mkdir() sub_path argument be optional

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/docker.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 8747f6a440..6ddc6e4c2a 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -52,7 +52,7 @@ def _guess_docker_command():
 raise Exception("Cannot find working docker command. Tried:\n%s" % \
 commands_txt)
 
-def _copy_with_mkdir(src, root_dir, sub_path):
+def _copy_with_mkdir(src, root_dir, sub_path='.'):
 """Copy src into root_dir, creating sub_path as needed."""
 dest_dir = os.path.normpath("%s/%s" % (root_dir, sub_path))
 try:
-- 
2.11.0




[Qemu-devel] [PATCH v2 02/21] docker: add --include-file argument to 'build' command

2017-05-08 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/Makefile.include | 3 ++-
 tests/docker/docker.py| 5 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 03eda37bf4..c99ce702ea 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -51,7 +51,8 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
$(SRC_PATH)/tests/docker/docker.py build qemu:$* $< \
$(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \
$(if $(NOUSER),,--add-current-user) \
-   $(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\
+   $(if $(EXECUTABLE),--include-executable=$(EXECUTABLE))\
+   $(if $(EXTRA_FILE),--include-file=$(EXTRA_FILE)),\
"BUILD","$*")
 
 # Enforce dependancies for composite images
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 6ddc6e4c2a..90520e4bca 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -237,6 +237,9 @@ class BuildCommand(SubCommand):
 help="""Specify a binary that will be copied to the
 container together with all its dependent
 libraries""")
+parser.add_argument("--include-file", "-f",
+help="""Specify a file that will be copied to the
+container""")
 parser.add_argument("--add-current-user", "-u", dest="user",
 action="store_true",
 help="Add the current user to image's passwd")
@@ -274,6 +277,8 @@ class BuildCommand(SubCommand):
 if args.include_executable:
 _copy_binary_with_libs(args.include_executable,
docker_dir)
+if args.include_file:
+_copy_with_mkdir(args.include_file, docker_dir)
 
 argv += ["--build-arg=" + k.lower() + "=" + v
 for k, v in os.environ.iteritems()
-- 
2.11.0




Re: [Qemu-devel] Floating point unit bugs

2017-05-08 Thread Aurelien Jarno
On 2017-05-07 17:48, G 3 wrote:
> I made a diagnostic program for the floating point unit. It will test
> various PowerPC floating point instructions for compatibility with the
> PowerPC G3 processor. It was tested on a PowerPC G3 and G5 system. The
> results of the program in qemu-system-ppc were pretty bad. About every
> instruction tested is not implemented correctly.
> 
> Here is the download link to the program: 
> http://www.mediafire.com/file/6j9tqubvk73lkw1/floating_point_test_program.zip

Some comments on the code.
> 
> /* Check if everything is alright */
> uint32_t fpscr;
> asm volatile("mffs f0");
> asm volatile("stfd f0, 40(r1)");
> asm volatile("lwz %0, 44(r1)" : "=r"(fpscr));
> if (fpscr != 0) {
> printf("Warning: fpscr not equal to zero: 0x%x\n", fpscr);
> }

This is overly complicated and just doesn't compile with recent GCC
versions. What about something like:

Converter c;
asm volatile("mffs %0" : "=f"(c.d));
fpscr = (uint32_t)c.i;


> /*
>  * The action to take if a test fails
>  * Input one: message string
>  * Input two: actual fpscr value
>  * Input three: expected fpscr value
>  * Input four: actual answer
>  * Input five: expected answer
>  */
>  void test_failed(const char *message, uint32_t actual_fpscr, uint32_t
> expected_fpscr,
>   uint64_t actual_answer, uint64_t expected_answer)
>  {
> printf("%s\n", message);
> printf("expected answer: 0x%" PRIx64 "\n", expected_answer);
> printf("  actual answer: 0x%" PRIx64 "\n", actual_fpscr);

This is wrong. It should be actual_answer instead of actual_fpscr. That
is why all the instructions seems totally wrongly implemented. Note that
compiling with -Wall would give you a warning:

| main.c: In function ‘test_failed’:
| main.c:146:5: warning: format ‘%llx’ expects argument of type ‘long long 
unsigned int’, but argument 2 has type ‘uint32_t’ [-Wformat=]
|  printf("  actual answer: 0x%" PRIx64 "\n", actual_fpscr);
|  ^

So I think the cone needs to be improved a bit before we can conclude
anything.

Aurelien

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] Floating point unit bugs

2017-05-08 Thread G 3


On May 8, 2017, at 5:54 PM, Aurelien Jarno wrote:


On 2017-05-07 17:48, G 3 wrote:

I made a diagnostic program for the floating point unit. It will test
various PowerPC floating point instructions for compatibility with  
the
PowerPC G3 processor. It was tested on a PowerPC G3 and G5 system.  
The
results of the program in qemu-system-ppc were pretty bad. About  
every

instruction tested is not implemented correctly.


I don't say that qemu-system-ppc is bug free, but this looks  
suspicious

that about every instruction is buggy.


I really hope you don't think I'm blaming anyone. I'm only reporting  
the results of the test.



Have you tried to run your
program on a real G3 or G5 system?


Yes. I made sure it ran on a real G3 and G5 system without problem  
before testing it on QEMU. I suspect the Motorola designed G4  
processor will not be compatible. I don't have a working G4 system to  
verify this unfortunately.




[ snip ]



Here is the full test results after running this program in qemu- 
system-ppc

with a Mac OS 10.4 guest:




fadd test failed
expected answer: 0x3ff4
  actual answer: 0x82004024
expected fpscr: 0x82064000
  actual fpscr: 0x82004000


This looks highly suspicious that the actual answer match the expected
answer.


You can use this web page to find the decimal value: http:// 
www6.uniovi.es/~antonio/uned/ieee754/IEEE-754hex64.html


0x3ff4 = 1.2002
0x82004024 = -4.8529708162167760e-299

The expected answer and actual answer are very far from each other.





Re: [Qemu-devel] [PATCH] Fix issues affecting Xen 9pfs discovered by Coverity

2017-05-08 Thread Eric Blake
On 05/08/2017 05:00 PM, Stefano Stabellini wrote:

>>> Directly calling fcntl(F_SETFD) without first reading fcntl(F_GETFD) is
>>> (theoretically) incorrect.  Better might be using qemu_set_cloexec()
>>> instead of open-coding something.
>>
>> Makes sense but the unchecked return of fcntl, discovered by Coverity,
>> would remain unfixed by calling qemu_set_cloexec here. I don't think I
>> am up for fixing all the call sites of qemu_set_cloexec.
>>
>> I am going to drop this change, and resend this patch was only the other
>> two fixes, fixing 1374836 only.
> 
> Unless you would be fine with:
> 
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 4d9189e..16894ad 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -182,7 +182,9 @@ void qemu_set_cloexec(int fd)
>  {
>  int f;
>  f = fcntl(fd, F_GETFD);
> -fcntl(fd, F_SETFD, f | FD_CLOEXEC);
> +assert(f != -1);
> +f = fcntl(fd, F_SETFD, f | FD_CLOEXEC);
> +assert(f != -1);

Seems reasonable to me, but I don't know if anyone else would object.

Changes semantics if someone ever calls qemu_set_cloexec(-1) (previously
it would ignore the EBADF failures, now it will abort) - such callers
are arguably broken, so that's okay by me.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] Fix issues affecting Xen 9pfs discovered by Coverity

2017-05-08 Thread Stefano Stabellini
On Mon, 8 May 2017, Stefano Stabellini wrote:
> On Mon, 8 May 2017, Eric Blake wrote:
> > On 05/08/2017 03:45 PM, Stefano Stabellini wrote:
> > > Fix two resource leaks on error paths, discovered by Coverity.
> > > Check for errors returned by fcntl, also found by Coverity.
> > > 
> > > CID:1374836
> > > CID:1374831
> > > 
> > 
> > > @@ -378,7 +380,10 @@ static int xen_9pfs_connect(struct XenDevice *xendev)
> > >  if (xen_9pdev->rings[i].evtchndev == NULL) {
> > >  goto out;
> > >  }
> > > -fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev), F_SETFD, 
> > > FD_CLOEXEC);
> > > +if (fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),
> > > +  F_SETFD, FD_CLOEXEC) == -1) {
> > > +goto out;
> > 
> > Directly calling fcntl(F_SETFD) without first reading fcntl(F_GETFD) is
> > (theoretically) incorrect.  Better might be using qemu_set_cloexec()
> > instead of open-coding something.
> 
> Makes sense but the unchecked return of fcntl, discovered by Coverity,
> would remain unfixed by calling qemu_set_cloexec here. I don't think I
> am up for fixing all the call sites of qemu_set_cloexec.
> 
> I am going to drop this change, and resend this patch was only the other
> two fixes, fixing 1374836 only.

Unless you would be fine with:

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 4d9189e..16894ad 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -182,7 +182,9 @@ void qemu_set_cloexec(int fd)
 {
 int f;
 f = fcntl(fd, F_GETFD);
-fcntl(fd, F_SETFD, f | FD_CLOEXEC);
+assert(f != -1);
+f = fcntl(fd, F_SETFD, f | FD_CLOEXEC);
+assert(f != -1);
 }
 
 /*



Re: [Qemu-devel] [PATCH] Fix issues affecting Xen 9pfs discovered by Coverity

2017-05-08 Thread Stefano Stabellini
On Mon, 8 May 2017, Eric Blake wrote:
> On 05/08/2017 03:45 PM, Stefano Stabellini wrote:
> > Fix two resource leaks on error paths, discovered by Coverity.
> > Check for errors returned by fcntl, also found by Coverity.
> > 
> > CID:1374836
> > CID:1374831
> > 
> 
> > @@ -378,7 +380,10 @@ static int xen_9pfs_connect(struct XenDevice *xendev)
> >  if (xen_9pdev->rings[i].evtchndev == NULL) {
> >  goto out;
> >  }
> > -fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev), F_SETFD, 
> > FD_CLOEXEC);
> > +if (fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),
> > +  F_SETFD, FD_CLOEXEC) == -1) {
> > +goto out;
> 
> Directly calling fcntl(F_SETFD) without first reading fcntl(F_GETFD) is
> (theoretically) incorrect.  Better might be using qemu_set_cloexec()
> instead of open-coding something.

Makes sense but the unchecked return of fcntl, discovered by Coverity,
would remain unfixed by calling qemu_set_cloexec here. I don't think I
am up for fixing all the call sites of qemu_set_cloexec.

I am going to drop this change, and resend this patch was only the other
two fixes, fixing 1374836 only.



Re: [Qemu-devel] Floating point unit bugs

2017-05-08 Thread Aurelien Jarno
On 2017-05-07 17:48, G 3 wrote:
> I made a diagnostic program for the floating point unit. It will test
> various PowerPC floating point instructions for compatibility with the
> PowerPC G3 processor. It was tested on a PowerPC G3 and G5 system. The
> results of the program in qemu-system-ppc were pretty bad. About every
> instruction tested is not implemented correctly.

I don't say that qemu-system-ppc is bug free, but this looks suspicious
that about every instruction is buggy. Have you tried to run your
program on a real G3 or G5 system?

[ snip ]

> 
> Here is the full test results after running this program in qemu-system-ppc
> with a Mac OS 10.4 guest:
> 
> 
> 
> 
> fadd test failed
> expected answer: 0x3ff4
>   actual answer: 0x82004024
> expected fpscr: 0x82064000
>   actual fpscr: 0x82004000

This looks highly suspicious that the actual answer match the expected
answer.

> actual FPSCR bits set:
> bit 17: FPRF - Floating-point greater than or positive
> bit 6: XX - Floating-point inexact exception
> bit 0: FX - Floating-point exception summary
> 
> expected FPSCR bits set:
> bit 17: FPRF - Floating-point greater than or positive
> bit 14: FI - Floating-point fraction inexact
> bit 13: FR - Floating-point fraction rounded
> bit 6: XX - Floating-point inexact exception
> bit 0: FX - Floating-point exception summary
> 
> fadds test failed
> expected answer: 0x407024d5
>   actual answer: 0x82004024
> expected fpscr: 0x82064000
>   actual fpscr: 0x82004000

Ditto.

> actual FPSCR bits set:
> bit 17: FPRF - Floating-point greater than or positive
> bit 6: XX - Floating-point inexact exception
> bit 0: FX - Floating-point exception summary
> 
> expected FPSCR bits set:
> bit 17: FPRF - Floating-point greater than or positive
> bit 14: FI - Floating-point fraction inexact
> bit 13: FR - Floating-point fraction rounded
> bit 6: XX - Floating-point inexact exception
> bit 0: FX - Floating-point exception summary
> 
> fsub test passed
> fsubs test passed
> fmul test failed
> expected answer: 0x40365c28f5c28f5c
>   actual answer: 0x82004024
> expected fpscr: 0x82024000
>   actual fpscr: 0x82004000

Ditto.

> actual FPSCR bits set:
> bit 17: FPRF - Floating-point greater than or positive
> bit 6: XX - Floating-point inexact exception
> bit 0: FX - Floating-point exception summary
> 
> expected FPSCR bits set:
> bit 17: FPRF - Floating-point greater than or positive
> bit 14: FI - Floating-point fraction inexact
> bit 6: XX - Floating-point inexact exception
> bit 0: FX - Floating-point exception summary
> 
> fmuls test failed
> expected answer: 0x412135a4a000
>   actual answer: 0x82004024
> expected fpscr: 0x82024000
>   actual fpscr: 0x82004000
> 
> actual FPSCR bits set:
> bit 17: FPRF - Floating-point greater than or positive
> bit 6: XX - Floating-point inexact exception
> bit 0: FX - Floating-point exception summary
> 
> expected FPSCR bits set:
> bit 17: FPRF - Floating-point greater than or positive
> bit 14: FI - Floating-point fraction inexact
> bit 6: XX - Floating-point inexact exception
> bit 0: FX - Floating-point exception summary
> 
> fdiv test failed
> expected answer: 0x40059f38ee13b48b
>   actual answer: 0x82004024
> expected fpscr: 0x82064000
>   actual fpscr: 0x82004000

Ditto.

And so on...

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] Future of SoftFloat use in QEMU

2017-05-08 Thread Aurelien Jarno
On 2017-05-08 17:58, Thomas Huth wrote:
> On 08.05.2017 17:36, Aurelien Jarno wrote:
> > Hi,
> > 
> > On 2017-05-08 15:58, Alex Bennée wrote:
> >> Hi,
> >>
> >> We've got a task coming up to implement half-precision floating point
> >> (FP16) for ARMv8.2. As you know pretty much all our floating point in
> >> QEMU is handled by our internal fork of John R. Hauser's BSD SoftFloat
> >> library. Our current implementation is based on version 2a which doesn't
> >> support FP16.
> >>
> >> As it happens there has been a new release of SoftFloat recently.
> >> Version 3 is a complete re-write which made a number of changes, some
> >> notable ones being:
> >>
> >>   - Complete rewrite, different use license than earlier releases.
> >>   - Renaming most types and functions, upgrading some algorithms
> >> - restructuring the source files, and making SoftFloat into a true 
> >> library.
> >>   - Added functions to convert between floating-point and unsigned 
> >> integers, both 32-bit and 64-bit (uint32_t and uint64_t).
> >>   - Added functions for fused multiply-add, for all supported 
> >> floating-point formats except 80-bit double-extended-precision.
> >>   - Added support for a fifth rounding mode, near_maxMag (round to 
> >> nearest, with ties to maximum magnitude, away from zero).
> >>
> >> And in the most recent release as of February 2017, 3c:
> >>
> >>   - Added optional rounding mode odd (round to odd, also known as jamming).
> >>   - Implemented the common 16-bit “half-precision” floating-point format 
> >> (float16_t)
> >>
> >> See: 
> >> http://www.jhauser.us/arithmetic/SoftFloat-3c/doc/SoftFloat-history.html
> >>
> >> Of course the softfloat in QEMU's tree hasn't been static either. We've
> >> made numerous changes over the years to add and fix various features,
> >> including features that have since been added to the upstream softfloat.
> >> It seems unlikely we could switch to the newer softfloat without risking
> >> breaking something. However if we look at back-porting stuff from the
> >> newer library we essentially get to own our version of softfloat
> >> forever.
> > 
> > There have been many many changes in our forked version of softfloat:
> > qNaN/sNaN, IEEE754-2008 functions, squash input denormal, many floatx80
> > fixes, ...
> 
> Note that we've apparently also got plenty of bugs in our version of
> softloat left, for example:

I don't say that our version of softfloat is bug free, but I would not
blame softfloat without further investigation:

> - https://bugs.launchpad.net/qemu/+bug/645662

qemu/i386 doesn't use softfloat for many instructions, but rather rely
on the float/double type of the host. This is mostly because softfloat
doesn't provide directly usable trigonometric functions. There are also
a few simple ones that might be more easily converted to softfloat.

> - http://lists.nongnu.org/archive/html/qemu-ppc/2017-05/msg00187.html
> 
> ... would be interesting to know whether such issues are fixed with the
> newer version of softfloat...

The exception flags are likely to be a bug in the PowerPC
implementation, as this CPU provides more fine grained exception than
what softfloat provides. The actual wrong answers which match the
expected fpscr value look very suspicious to me.

Aurelien

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH 6/6] prep: add IBM RS/6000 7020 (40p) machine emulation

2017-05-08 Thread Hervé Poussineau

Le 08/05/2017 à 22:49, Eduardo Habkost a écrit :

Hi,

I stumbled upon this code while working on arch_init.c cleanups:

On Thu, Dec 29, 2016 at 11:12:16PM +0100, Hervé Poussineau wrote:
[...]

+static void ibm_40p_init(MachineState *machine)
+{

[...]

+/* initialize audio subsystem */
+audio_init();


Why exactly did you need this, if main() already calls
audio_init()?


Because prep machine was doing it?
Anyway, it also works without it.



[...]

+static void ibm_40p_machine_init(MachineClass *mc)
+{
+mc->desc = "IBM RS/6000 7020 (40p)",
+mc->init = ibm_40p_init;
+mc->max_cpus = 1;
+mc->pci_allow_0_address = true;
+mc->default_ram_size = 128 * M_BYTE;
+mc->block_default_type = IF_SCSI;
+mc->default_display = "std"; /* FIXME: should be S3 Trio */
+mc->default_boot_order = "c";
+}
+
+DEFINE_MACHINE("40p", ibm_40p_machine_init)
 DEFINE_MACHINE("prep", prep_machine_init)
--
2.1.4









Re: [Qemu-devel] [PATCH v6 4/9] qcow2: make refcount size calculation conservative

2017-05-08 Thread Max Reitz
On 08.05.2017 16:15, Stefan Hajnoczi wrote:
> The refcount metadata size calculation is inaccurate and can produce
> numbers that are too small.  This is bad because we should calculate a
> conservative number - one that is guaranteed to be large enough.
> 
> This patch switches the approach to a fixed point calculation because
> the existing equation is hard to solve when inaccuracies are taken care
> of.
> 
> Signed-off-by: Stefan Hajnoczi 
> Reviewed-by: Alberto Garcia 
> ---
>  block/qcow2.c | 82 
> ++-
>  1 file changed, 42 insertions(+), 40 deletions(-)
> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 5569b63..ff0d825 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -2095,6 +2095,43 @@ static int preallocate(BlockDriverState *bs)
>  return 0;
>  }
>  
> +/* qcow2_refcount_metadata_size:
> + * @clusters: number of clusters to refcount (including data and L1/L2 
> tables)
> + * @cluster_size: size of a cluster, in bytes
> + * @refcount_order: refcount bits power-of-2 exponent
> + *
> + * Returns: Number of bytes required for refcount blocks and table metadata.
> + */
> +static int64_t qcow2_refcount_metadata_size(int64_t clusters,
> +size_t cluster_size,
> +int refcount_order)
> +{
> +/*
> + * Every host cluster is reference-counted, including metadata (even
> + * refcount metadata is recursively included).
> + *
> + * An accurate formula for the size of refcount metadata size is 
> difficult
> + * to derive.

Oh, by the way:

https://lists.nongnu.org/archive/html/qemu-devel/2014-04/msg04820.html

*cough* *cough*

(No, this is not the formula that was used for this preallocation.
Otherwise, it would have been correct. O:-))

Max

> An easier method of calculation is finding the fixed point
> + * where no further refcount blocks or table clusters are required to
> + * reference count every cluster.
> + */
> +int64_t blocks_per_table_cluster = cluster_size / sizeof(uint64_t);
> +int64_t refcounts_per_block = cluster_size * 8 / (1 << refcount_order);
> +int64_t table = 0;  /* number of refcount table clusters */
> +int64_t blocks = 0; /* number of refcount block clusters */
> +int64_t last;
> +int64_t n = 0;
> +
> +do {
> +last = n;
> +blocks = DIV_ROUND_UP(clusters + table + blocks, 
> refcounts_per_block);
> +table = DIV_ROUND_UP(blocks, blocks_per_table_cluster);
> +n = clusters + blocks + table;
> +} while (n != last);
> +
> +return (blocks + table) * cluster_size;
> +}
> +
>  /**
>   * qcow2_calc_prealloc_size:
>   * @total_size: virtual disk size in bytes



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] Revert "target-ppc/kvm: Enable in-kernel TCE acceleration for multi-tce"

2017-05-08 Thread Alexey Kardashevskiy
On 09/05/17 06:17, Jose Ricardo Ziviani wrote:
> This reverts commit 3dc410ae83e6cb76c81ea30a05d62596092b3165.
> 
> Booting a radix guest in Power9 with that commit throws a host kernel
> oops:
> 
> [17582052553.360178] Unable to handle kernel paging request for data at 
> address 0xe64bb17da64ab078
> [17582052553.360420] Faulting instruction address: 0xc02c3ddc
> [17582052553.360533] Oops: Kernel access of bad area, sig: 11 [#1]
> [17582052553.360643] SMP NR_CPUS=1024
> [17582052553.360645] NUMA
> [17582052553.360712] PowerNV
> [17582052553.360804] Modules linked in: vhost_net vhost tap xt_CHECKSUM 
> ipt_MASQUERADE nf_nat_masquerade_ipv4 ip6t_rpfilter ip6t_REJECT 
> nf_reject_ipv6 nf_conntrack_ipv6 nf_defrag_ipv6 xt_conntrack ip_set nfnetlink 
> ebtable_nat ebtable_broute bridge stp llc ip6table_mangle ip6table_security 
> ip6table_raw iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat 
> nf_conntrack libcrc32c iptable_mangle iptable_security iptable_raw 
> ebtable_filter ebtables ip6table_filter ip6_tables ses enclosure 
> scsi_transport_sas ipmi_powernv powernv_op_panel ipmi_devintf ipmi_msghandler 
> nfsd kvm_hv auth_rpcgss oid_registry nfs_acl lockd grace sunrpc kvm tg3 ptp 
> pps_core
> [17582052553.361797] CPU: 5 PID: 4966 Comm: qemu-system-ppc Not tainted 
> 4.11.0-1.git4a6869a.el7.centos.ppc64le #1
> [17582052553.361972] task: c003c5e90a80 task.stack: c003c5f6c000
> [17582052553.362082] NIP: c02c3ddc LR: c02c3e80 CTR: 
> c00ce2e0
> [17582052553.362214] REGS: c003c5f6f150 TRAP: 0380   Not tainted  
> (4.11.0-1.git4a6869a.el7.centos.ppc64le)
> [17582052553.362467] MSR: 90001031 
> [17582052553.362480]   CR: 44008024  XER: 2000
> [17582052553.362822] CFAR: c02c3e7c SOFTE: 1
> [17582052553.362822] GPR00: 018f c003c5f6f3d0 
> c131fd00 
> [17582052553.362822] GPR04: 0005 01ff 
>  7db04aa67db14ba6
> [17582052553.362822] GPR08: 264bb17da64ab000 e64bb17da64ab000 
> 0078 
> [17582052553.362822] GPR12: c003bdb98008 cfdc2d00 
> c000e148 
> [17582052553.362822] GPR16: 0800 2000 
>  c003c5f6f4c0
> [17582052553.362822] GPR20: c0019440 c001fd033280 
> c001fd0342a0 c001f24efff8
> [17582052553.362822] GPR24: 0200 0001f24f 
> 0010 0002
> [17582052553.362822] GPR28: 0800 0001f24f 
> 7db04aa6 a64ab07d
> [17582052553.365148] NIP [c02c3ddc] vmalloc_to_page+0x19c/0x220
> [17582052553.365365] LR [c02c3e80] vmalloc_to_pfn+0x20/0x50
> [17582052553.365582] Call Trace:
> [17582052553.365720] [c003c5f6f3d0] [7265677368657265] 0x7265677368657265 
> (unreliable)
> [17582052553.365982] [c003c5f6f400] [c02c3e80] 
> vmalloc_to_pfn+0x20/0x50
> [17582052553.366245] [c003c5f6f420] [c00637e8] 
> vmalloc_to_phys+0x28/0x60
> [17582052553.366508] [c003c5f6f450] [c00ce480] 
> kvmppc_rm_h_put_tce_indirect+0x1a0/0x540
> [17582052553.366812] [c003c5f6f590] [c00d0314] 
> hcall_try_real_mode+0x60/0x7c
> [17582052553.367074] [c003c5f6f600] [c00cefac] 
> kvmppc_call_hv_entry+0x8/0x17c
> [17582052553.367346] [c003c5f6f670] [c0080375a970] 
> __kvmppc_vcore_entry+0x13c/0x1ac [kvm_hv]
> [17582052553.367652] [c003c5f6f840] [c008037574a8] 
> kvmppc_run_core+0x788/0x1650 [kvm_hv]
> [17582052553.367965] [c003c5f6fa00] [c008037590b8] 
> kvmppc_vcpu_run_hv+0x388/0x1200 [kvm_hv]
> [17582052553.368287] [c003c5f6fb30] [c00803274684] 
> kvmppc_vcpu_run+0x34/0x50 [kvm]
> [17582052553.368558] [c003c5f6fb50] [c00803270b54] 
> kvm_arch_vcpu_ioctl_run+0x114/0x2a0 [kvm]
> [17582052553.368870] [c003c5f6fbd0] [c00803263dd8] 
> kvm_vcpu_ioctl+0x5e8/0x7c0 [kvm]
> [17582052553.369132] [c003c5f6fd40] [c0350b50] 
> do_vfs_ioctl+0xd0/0x8c0
> [17582052553.369395] [c003c5f6fde0] [c0351414] SyS_ioctl+0xd4/0xf0
> [17582052553.369615] [c003c5f6fe30] [c000b8e0] 
> system_call+0x38/0xfc
> [17582052553.369875] Instruction dump:
> [17582052553.370011] 53dfc42e 790807c6 394a 7d08fb78 78638402 79081764 
> 7d4a07b4 7c6a5038
> [17582052553.370281] 7908f5e6 7d094b78 794a1f24 3860 <7d2a482a> 7924cfe3 
> 41820040 79260022
> [17582052553.370599] ---[ end trace 9470442ed18ae727 ]---
> 
> As soon as we identify and fix the issue that's causing such problem
> I'll re-send the referred patch to re-enable TCE.


The proper fix is to change the host kernel to not advertise
KVM_CAP_SPAPR_MULTITCE for radix guest.


> 
> Signed-off-by: Jose Ricardo Ziviani 
> CC: Bharata B Rao 
> ---
>  hw/ppc/spapr.c   |  4 +---
>  target/ppc/kvm.c | 14 --
>  target/ppc/kvm_ppc.h |  6 --
> 

[Qemu-devel] [PATCH v7 5/5] shutdown: Expose bool cause in SHUTDOWN and RESET events

2017-05-08 Thread Eric Blake
Libvirt would like to be able to distinguish between a SHUTDOWN
event triggered solely by guest request and one triggered by a
SIGTERM or other action on the host.  While qemu_kill_report() was
already able to give different output to stderr based on whether a
shutdown was triggered by a host signal (but NOT by a host UI event,
such as clicking the X on the window), that information was then
lost to management.  The previous patches improved things to use an
enum throughout all callsites, so now we have something ready to
expose through QMP.

Note that for now, the decision was to expose ONLY a boolean,
rather than promoting ShutdownCause to a QAPI enum; this is because
libvirt has not expressed an interest in anything finer-grained.
We can still add additional details, in a backwards-compatible
manner, if a need later arises (if the addition happens before 2.10,
we can replace the bool with an enum; otherwise, the enum will have
to be in addition to the bool).

Update expected iotest outputs to match the new data (complete
coverage of the affected tests is obtained by -raw, -qcow2, and -nbd).

Here is output from 'virsh qemu-monitor-event --loop' with the
patch installed:

event SHUTDOWN at 1492639680.731251 for domain fedora_13: {"guest":true}
event STOP at 1492639680.732116 for domain fedora_13: 
event SHUTDOWN at 1492639680.732830 for domain fedora_13: {"guest":false}

Note that libvirt runs qemu with -no-quit: the first SHUTDOWN event
was triggered by an action I took directly in the guest (shutdown -h),
at which point qemu stops the vcpus and waits for libvirt to do any
final cleanups; the second SHUTDOWN event is the result of libvirt
sending SIGTERM now that it has completed cleanup.

See also https://bugzilla.redhat.com/1384007

Signed-off-by: Eric Blake 

---
v7: rebase to context
v6: split out from 'shutdown: Add source information to SHUTDOWN and RESET'
---
 qapi/event.json| 17 +
 vl.c   |  8 
 tests/qemu-iotests/071.out |  4 ++--
 tests/qemu-iotests/081.out |  2 +-
 tests/qemu-iotests/087.out | 12 ++--
 tests/qemu-iotests/094.out |  2 +-
 tests/qemu-iotests/117.out |  2 +-
 tests/qemu-iotests/119.out |  2 +-
 tests/qemu-iotests/120.out |  2 +-
 tests/qemu-iotests/140.out |  2 +-
 tests/qemu-iotests/143.out |  2 +-
 tests/qemu-iotests/156.out |  2 +-
 12 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/qapi/event.json b/qapi/event.json
index e80f3f4..6d22b02 100644
--- a/qapi/event.json
+++ b/qapi/event.json
@@ -10,6 +10,10 @@
 # Emitted when the virtual machine has shut down, indicating that qemu is
 # about to exit.
 #
+# @guest: If true, the shutdown was triggered by a guest request (such as
+# a guest-initiated ACPI shutdown request or other hardware-specific action)
+# rather than a host request (such as sending qemu a SIGINT). (since 2.10)
+#
 # Note: If the command-line option "-no-shutdown" has been specified, qemu will
 # not exit, and a STOP event will eventually follow the SHUTDOWN event
 #
@@ -17,11 +21,11 @@
 #
 # Example:
 #
-# <- { "event": "SHUTDOWN",
+# <- { "event": "SHUTDOWN", "data": { "guest": true },
 #  "timestamp": { "seconds": 1267040730, "microseconds": 682951 } }
 #
 ##
-{ 'event': 'SHUTDOWN' }
+{ 'event': 'SHUTDOWN', 'data': { 'guest': 'bool' } }

 ##
 # @POWERDOWN:
@@ -44,15 +48,20 @@
 #
 # Emitted when the virtual machine is reset
 #
+# @guest: If true, the reset was triggered by a guest request (such as
+# a guest-initiated ACPI reboot request or other hardware-specific action)
+# rather than a host request (such as the QMP command system_reset).
+# (since 2.10)
+#
 # Since: 0.12.0
 #
 # Example:
 #
-# <- { "event": "RESET",
+# <- { "event": "RESET", "data": { "guest": false },
 #  "timestamp": { "seconds": 1267041653, "microseconds": 9518 } }
 #
 ##
-{ 'event': 'RESET' }
+{ 'event': 'RESET', 'data': { 'guest': 'bool' } }

 ##
 # @STOP:
diff --git a/vl.c b/vl.c
index 65487d9..5fd0e8f 100644
--- a/vl.c
+++ b/vl.c
@@ -1705,8 +1705,8 @@ void qemu_system_reset(ShutdownCause reason)
 qemu_devices_reset();
 }
 if (reason) {
-/* FIXME update event based on reason */
-qapi_event_send_reset(_abort);
+qapi_event_send_reset(reason >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN,
+  _abort);
 }
 cpu_synchronize_all_post_reset();
 }
@@ -1863,8 +1863,8 @@ static bool main_loop_should_exit(void)
 request = qemu_shutdown_requested();
 if (request) {
 qemu_kill_report();
-/* FIXME update event based on request */
-qapi_event_send_shutdown(_abort);
+qapi_event_send_shutdown(request >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN,
+ _abort);
 if (no_shutdown) {
 vm_stop(RUN_STATE_SHUTDOWN);
 } else {
diff --git a/tests/qemu-iotests/071.out b/tests/qemu-iotests/071.out
index dd879f1..1d5e28d 100644
--- a/tests/qemu-iotests/071.out
+++ 

[Qemu-devel] [PATCH v7 3/5] shutdown: Add source information to SHUTDOWN and RESET

2017-05-08 Thread Eric Blake
Time to wire up all the call sites that request a shutdown or
reset to use the enum added in the previous patch.

It would have been less churn to keep the common case with no
arguments as meaning guest-triggered, and only modified the
host-triggered code paths, via a wrapper function, but then we'd
still have to audit that I didn't miss any host-triggered spots;
changing the signature forces us to double-check that I correctly
categorized all callers.

Since command line options can change whether a guest reset request
causes an actual reset vs. a shutdown, it's easy to also add the
information to reset requests.

Replay adds a FIXME to preserve the cause across the replay stream,
that will be tackled in the next patch.

Signed-off-by: Eric Blake 
Acked-by: David Gibson  [ppc parts]
Reviewed-by: Mark Cave-Ayland  [SPARC part]

---
v7: no change
v6: defer event additions to later, add reviews of unchanged portions
v5: drop accidental addition of unrelated files
v4: s/ShutdownType/ShutdownCause/, no thanks to mingw header pollution
v3: retitle again, fix qemu-iotests, use enum rather than raw bool
in all callers
v2: retitle (was "event: Add signal information to SHUTDOWN"),
completely rework to post bool based on whether it is guest-initiated
v1: initial submission, exposing just Unix signals from host
---
 include/sysemu/sysemu.h |  4 ++--
 vl.c| 17 -
 hw/acpi/core.c  |  4 ++--
 hw/arm/highbank.c   |  4 ++--
 hw/arm/integratorcp.c   |  2 +-
 hw/arm/musicpal.c   |  2 +-
 hw/arm/omap1.c  | 10 ++
 hw/arm/omap2.c  |  2 +-
 hw/arm/spitz.c  |  2 +-
 hw/arm/stellaris.c  |  2 +-
 hw/arm/tosa.c   |  2 +-
 hw/i386/pc.c|  2 +-
 hw/i386/xen/xen-hvm.c   |  2 +-
 hw/input/pckbd.c|  4 ++--
 hw/ipmi/ipmi.c  |  4 ++--
 hw/isa/lpc_ich9.c   |  2 +-
 hw/mips/boston.c|  2 +-
 hw/mips/mips_malta.c|  2 +-
 hw/mips/mips_r4k.c  |  4 ++--
 hw/misc/arm_sysctl.c|  8 
 hw/misc/cbus.c  |  2 +-
 hw/misc/macio/cuda.c|  4 ++--
 hw/misc/slavio_misc.c   |  4 ++--
 hw/misc/zynq_slcr.c |  2 +-
 hw/pci-host/apb.c   |  4 ++--
 hw/pci-host/bonito.c|  2 +-
 hw/pci-host/piix.c  |  2 +-
 hw/ppc/e500.c   |  2 +-
 hw/ppc/mpc8544_guts.c   |  2 +-
 hw/ppc/ppc.c|  2 +-
 hw/ppc/ppc405_uc.c  |  2 +-
 hw/ppc/spapr_hcall.c|  2 +-
 hw/ppc/spapr_rtas.c |  4 ++--
 hw/s390x/ipl.c  |  2 +-
 hw/sh4/r2d.c|  2 +-
 hw/timer/etraxfs_timer.c|  2 +-
 hw/timer/m48t59.c   |  4 ++--
 hw/timer/milkymist-sysctl.c |  4 ++--
 hw/timer/pxa2xx_timer.c |  2 +-
 hw/watchdog/watchdog.c  |  2 +-
 hw/xenpv/xen_domainbuild.c  |  2 +-
 hw/xtensa/xtfpga.c  |  2 +-
 kvm-all.c   |  6 +++---
 os-win32.c  |  2 +-
 qmp.c   |  4 ++--
 replay/replay.c |  3 ++-
 target/alpha/sys_helper.c   |  4 ++--
 target/arm/psci.c   |  4 ++--
 target/i386/excp_helper.c   |  2 +-
 target/i386/hax-all.c   |  6 +++---
 target/i386/helper.c|  2 +-
 target/i386/kvm.c   |  2 +-
 target/s390x/helper.c   |  2 +-
 target/s390x/kvm.c  |  4 ++--
 target/s390x/misc_helper.c  |  4 ++--
 target/sparc/int32_helper.c |  2 +-
 ui/sdl.c|  2 +-
 ui/sdl2.c   |  4 ++--
 trace-events|  2 +-
 ui/cocoa.m  |  2 +-
 60 files changed, 98 insertions(+), 96 deletions(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 98b3274..fe197aa 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -61,13 +61,13 @@ typedef enum WakeupReason {
 QEMU_WAKEUP_REASON_OTHER,
 } WakeupReason;

-void qemu_system_reset_request(void);
+void qemu_system_reset_request(ShutdownCause reason);
 void qemu_system_suspend_request(void);
 void qemu_register_suspend_notifier(Notifier *notifier);
 void qemu_system_wakeup_request(WakeupReason reason);
 void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
 void qemu_register_wakeup_notifier(Notifier *notifier);
-void qemu_system_shutdown_request(void);
+void qemu_system_shutdown_request(ShutdownCause reason);
 void qemu_system_powerdown_request(void);
 void qemu_register_powerdown_notifier(Notifier *notifier);
 void qemu_system_debug_request(void);
diff --git a/vl.c b/vl.c
index 8df886e..2d546460 100644
--- a/vl.c
+++ b/vl.c
@@ -1724,7 +1724,7 @@ void qemu_system_guest_panicked(GuestPanicInformation 
*info)
 if (!no_shutdown) {
 qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF,
!!info, info, _abort);
-qemu_system_shutdown_request();
+

[Qemu-devel] [PATCH v7 2/5] shutdown: Prepare for use of an enum in reset/shutdown_request

2017-05-08 Thread Eric Blake
We want to track why a guest was shutdown; in particular, being able
to tell the difference between a guest request (such as ACPI request)
and host request (such as SIGINT) will prove useful to libvirt.
Since all requests eventually end up changing shutdown_requested in
vl.c, the logical change is to make that value track the reason,
rather than its current 0/1 contents.

Since command-line options control whether a reset request is turned
into a shutdown request instead, the same treatment is given to
reset_requested.

This patch adds an internal enum ShutdownCause that describes reasons
that a shutdown can be requested, and changes qemu_system_reset() to
pass the reason through, although for now nothing is actually changed
with regards to what gets reported.  The enum could be exported via
QAPI at a later date, if deemed necessary, but for now, there has not
been a request to expose that much detail to end clients.

For the most part, we turn 0 into SHUTDOWN_CAUSE_NONE, and 1 into
SHUTDOWN_CAUSE_HOST_ERROR; the only specific case where we have enough
information right now to use a different value is when we are reacting
to a host signal.  It will take a further patch to edit all call-sites
that can trigger a reset or shutdown request to properly pass in any
other reasons; this patch includes FIXMEs to point such places out.

qemu_system_reset() trades its 'bool report' parameter for a
'ShutdownCause reason', with all non-zero values having the same
effect; this lets us get rid of the weird #defines for VMRESET_*
as synonyms for bools.

Signed-off-by: Eric Blake 

---
v7: drop 'bool report' from qemu_system_reset(), reorder enum to put
HOST_ERROR == 1, improve commit message
v6: make ShutdownCause internal-only, add SHUTDOWN_CAUSE_NONE so that
comparison to 0 still works, tweak initial FIXME values
v5: no change
v4: s/ShutdownType/ShutdownCause/, no thanks to mingw header pollution
v3: new patch
---
 include/sysemu/sysemu.h | 22 +++-
 vl.c| 53 ++---
 hw/i386/xen/xen-hvm.c   |  7 +--
 migration/colo.c|  2 +-
 migration/savevm.c  |  2 +-
 5 files changed, 57 insertions(+), 29 deletions(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 15656b7..98b3274 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -33,8 +33,20 @@ VMChangeStateEntry 
*qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
 void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
 void vm_state_notify(int running, RunState state);

-#define VMRESET_SILENT   false
-#define VMRESET_REPORT   true
+/* Enumeration of various causes for shutdown. */
+typedef enum ShutdownCause {
+SHUTDOWN_CAUSE_NONE,  /* No shutdown request pending */
+SHUTDOWN_CAUSE_HOST_ERROR,/* An error prevents further use of guest */
+SHUTDOWN_CAUSE_HOST_QMP,  /* Reaction to a QMP command, like 'quit' */
+SHUTDOWN_CAUSE_HOST_SIGNAL,   /* Reaction to a signal, such as SIGINT */
+SHUTDOWN_CAUSE_HOST_UI,   /* Reaction to UI event, like window close */
+SHUTDOWN_CAUSE_GUEST_SHUTDOWN,/* Guest requested shutdown, such as via
+ ACPI or other hardware-specific means */
+SHUTDOWN_CAUSE_GUEST_RESET,   /* Guest requested reset, and command line
+ turns that into a shutdown */
+SHUTDOWN_CAUSE_GUEST_PANIC,   /* Guest panicked, and command line turns
+ that into a shutdown */
+} ShutdownCause;

 void vm_start(void);
 int vm_prepare_start(void);
@@ -62,10 +74,10 @@ void qemu_system_debug_request(void);
 void qemu_system_vmstop_request(RunState reason);
 void qemu_system_vmstop_request_prepare(void);
 bool qemu_vmstop_requested(RunState *r);
-int qemu_shutdown_requested_get(void);
-int qemu_reset_requested_get(void);
+ShutdownCause qemu_shutdown_requested_get(void);
+ShutdownCause qemu_reset_requested_get(void);
 void qemu_system_killed(int signal, pid_t pid);
-void qemu_system_reset(bool report);
+void qemu_system_reset(ShutdownCause reason);
 void qemu_system_guest_panicked(GuestPanicInformation *info);
 size_t qemu_target_page_size(void);

diff --git a/vl.c b/vl.c
index 7a205e0..8df886e 100644
--- a/vl.c
+++ b/vl.c
@@ -1597,8 +1597,9 @@ void vm_state_notify(int running, RunState state)
 }
 }

-static int reset_requested;
-static int shutdown_requested, shutdown_signal;
+static ShutdownCause reset_requested;
+static ShutdownCause shutdown_requested;
+static int shutdown_signal;
 static pid_t shutdown_pid;
 static int powerdown_requested;
 static int debug_requested;
@@ -1612,19 +1613,19 @@ static NotifierList wakeup_notifiers =
 NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
 static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);

-int qemu_shutdown_requested_get(void)
+ShutdownCause qemu_shutdown_requested_get(void)
 {
 return 

[Qemu-devel] [PATCH v7 4/5] shutdown: Preserve shutdown cause through replay

2017-05-08 Thread Eric Blake
With the recent addition of ShutdownCause, we want to be able to pass
a cause through any shutdown request, and then faithfully replay that
cause when later replaying the same sequence.  The easiest way is to
expand the reply event mechanism to track a series of values for
EVENT_SHUTDOWN, one corresponding to each value of ShutdownCause.

We are free to change the replay stream as needed, since there are
already no guarantees about being able to use a replay stream by
any other version of qemu than the one that generated it.

Signed-off-by: Eric Blake 

---
v7: rebase to context
v6: new patch
---
 include/sysemu/replay.h  |  3 ++-
 include/sysemu/sysemu.h  |  1 +
 replay/replay-internal.h |  3 ++-
 vl.c |  3 +--
 replay/replay.c  | 10 +-
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
index f1c0712..fa14d0e 100644
--- a/include/sysemu/replay.h
+++ b/include/sysemu/replay.h
@@ -13,6 +13,7 @@
  */

 #include "qapi-types.h"
+#include "sysemu.h"

 /* replay clock kinds */
 enum ReplayClockKind {
@@ -98,7 +99,7 @@ int64_t replay_read_clock(ReplayClockKind kind);
 /* Events */

 /*! Called when qemu shutdown is requested. */
-void replay_shutdown_request(void);
+void replay_shutdown_request(ShutdownCause cause);
 /*! Should be called at check points in the execution.
 These check points are skipped, if they were not met.
 Saves checkpoint in the SAVE mode and validates in the PLAY mode.
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index fe197aa..e0cbab1 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -46,6 +46,7 @@ typedef enum ShutdownCause {
  turns that into a shutdown */
 SHUTDOWN_CAUSE_GUEST_PANIC,   /* Guest panicked, and command line turns
  that into a shutdown */
+SHUTDOWN_CAUSE__MAX,
 } ShutdownCause;

 void vm_start(void);
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index ed66ed8..3ebb199 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -22,8 +22,9 @@ enum ReplayEvents {
 EVENT_EXCEPTION,
 /* for async events */
 EVENT_ASYNC,
-/* for shutdown request */
+/* for shutdown requests, range allows recovery of ShutdownCause */
 EVENT_SHUTDOWN,
+EVENT_SHUTDOWN_LAST = EVENT_SHUTDOWN + SHUTDOWN_CAUSE__MAX,
 /* for character device write event */
 EVENT_CHAR_WRITE,
 /* for character device read all event */
diff --git a/vl.c b/vl.c
index 2d546460..65487d9 100644
--- a/vl.c
+++ b/vl.c
@@ -1820,8 +1820,7 @@ void qemu_system_killed(int signal, pid_t pid)
 void qemu_system_shutdown_request(ShutdownCause reason)
 {
 trace_qemu_system_shutdown_request(reason);
-/* FIXME - add a parameter to let replay preserve reason */
-replay_shutdown_request();
+replay_shutdown_request(reason);
 shutdown_requested = reason;
 qemu_notify_event();
 }
diff --git a/replay/replay.c b/replay/replay.c
index 604fa4f..ff58a5a 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -49,10 +49,10 @@ bool replay_next_event_is(int event)
 res = true;
 }
 switch (replay_state.data_kind) {
-case EVENT_SHUTDOWN:
+case EVENT_SHUTDOWN ... EVENT_SHUTDOWN_LAST:
 replay_finish_event();
-/* FIXME - store actual reason */
-qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR);
+qemu_system_shutdown_request(replay_state.data_kind -
+ EVENT_SHUTDOWN);
 break;
 default:
 /* clock, time_t, checkpoint and other events */
@@ -171,11 +171,11 @@ bool replay_has_interrupt(void)
 return res;
 }

-void replay_shutdown_request(void)
+void replay_shutdown_request(ShutdownCause cause)
 {
 if (replay_mode == REPLAY_MODE_RECORD) {
 replay_mutex_lock();
-replay_put_event(EVENT_SHUTDOWN);
+replay_put_event(EVENT_SHUTDOWN + cause);
 replay_mutex_unlock();
 }
 }
-- 
2.9.3




[Qemu-devel] [PATCH v7 0/5] event: Add source information to SHUTDOWN

2017-05-08 Thread Eric Blake
v6 was here:
https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg01380.html

Since then:
- another simplification to qemu_system_reset()
- minor tweaks suggested by Markus

001/5:[] [--] 'shutdown: Simplify shutdown_signal'
002/5:[0038] [FC] 'shutdown: Prepare for use of an enum in 
reset/shutdown_request'
003/5:[] [--] 'shutdown: Add source information to SHUTDOWN and RESET'
004/5:[] [-C] 'shutdown: Preserve shutdown cause through replay'
005/5:[0002] [FC] 'shutdown: Expose bool cause in SHUTDOWN and RESET events'

Eric Blake (5):
  shutdown: Simplify shutdown_signal
  shutdown: Prepare for use of an enum in reset/shutdown_request
  shutdown: Add source information to SHUTDOWN and RESET
  shutdown: Preserve shutdown cause through replay
  shutdown: Expose bool cause in SHUTDOWN and RESET events

 qapi/event.json | 17 ---
 include/sysemu/replay.h |  3 +-
 include/sysemu/sysemu.h | 27 +-
 replay/replay-internal.h|  3 +-
 vl.c| 69 ++---
 hw/acpi/core.c  |  4 +--
 hw/arm/highbank.c   |  4 +--
 hw/arm/integratorcp.c   |  2 +-
 hw/arm/musicpal.c   |  2 +-
 hw/arm/omap1.c  | 10 ---
 hw/arm/omap2.c  |  2 +-
 hw/arm/spitz.c  |  2 +-
 hw/arm/stellaris.c  |  2 +-
 hw/arm/tosa.c   |  2 +-
 hw/i386/pc.c|  2 +-
 hw/i386/xen/xen-hvm.c   |  9 --
 hw/input/pckbd.c|  4 +--
 hw/ipmi/ipmi.c  |  4 +--
 hw/isa/lpc_ich9.c   |  2 +-
 hw/mips/boston.c|  2 +-
 hw/mips/mips_malta.c|  2 +-
 hw/mips/mips_r4k.c  |  4 +--
 hw/misc/arm_sysctl.c|  8 +++---
 hw/misc/cbus.c  |  2 +-
 hw/misc/macio/cuda.c|  4 +--
 hw/misc/slavio_misc.c   |  4 +--
 hw/misc/zynq_slcr.c |  2 +-
 hw/pci-host/apb.c   |  4 +--
 hw/pci-host/bonito.c|  2 +-
 hw/pci-host/piix.c  |  2 +-
 hw/ppc/e500.c   |  2 +-
 hw/ppc/mpc8544_guts.c   |  2 +-
 hw/ppc/ppc.c|  2 +-
 hw/ppc/ppc405_uc.c  |  2 +-
 hw/ppc/spapr_hcall.c|  2 +-
 hw/ppc/spapr_rtas.c |  4 +--
 hw/s390x/ipl.c  |  2 +-
 hw/sh4/r2d.c|  2 +-
 hw/timer/etraxfs_timer.c|  2 +-
 hw/timer/m48t59.c   |  4 +--
 hw/timer/milkymist-sysctl.c |  4 +--
 hw/timer/pxa2xx_timer.c |  2 +-
 hw/watchdog/watchdog.c  |  2 +-
 hw/xenpv/xen_domainbuild.c  |  2 +-
 hw/xtensa/xtfpga.c  |  2 +-
 kvm-all.c   |  6 ++--
 migration/colo.c|  2 +-
 migration/savevm.c  |  2 +-
 os-win32.c  |  2 +-
 qmp.c   |  4 +--
 replay/replay.c |  9 +++---
 target/alpha/sys_helper.c   |  4 +--
 target/arm/psci.c   |  4 +--
 target/i386/excp_helper.c   |  2 +-
 target/i386/hax-all.c   |  6 ++--
 target/i386/helper.c|  2 +-
 target/i386/kvm.c   |  2 +-
 target/s390x/helper.c   |  2 +-
 target/s390x/kvm.c  |  4 +--
 target/s390x/misc_helper.c  |  4 +--
 target/sparc/int32_helper.c |  2 +-
 ui/sdl.c|  2 +-
 ui/sdl2.c   |  4 +--
 tests/qemu-iotests/071.out  |  4 +--
 tests/qemu-iotests/081.out  |  2 +-
 tests/qemu-iotests/087.out  | 12 
 tests/qemu-iotests/094.out  |  2 +-
 tests/qemu-iotests/117.out  |  2 +-
 tests/qemu-iotests/119.out  |  2 +-
 tests/qemu-iotests/120.out  |  2 +-
 tests/qemu-iotests/140.out  |  2 +-
 tests/qemu-iotests/143.out  |  2 +-
 tests/qemu-iotests/156.out  |  2 +-
 trace-events|  2 +-
 ui/cocoa.m  |  2 +-
 75 files changed, 191 insertions(+), 150 deletions(-)

-- 
2.9.3




[Qemu-devel] [PATCH v7 1/5] shutdown: Simplify shutdown_signal

2017-05-08 Thread Eric Blake
There is no signal 0 (kill(pid, 0) has special semantics to probe whether
a process is alive), rather than actually sending a signal 0).  So we
can use the simpler 0, instead of -1, for our sentinel of whether a
shutdown request due to a signal has happened.

Suggested-by: Markus Armbruster 
Signed-off-by: Eric Blake 
Reviewed-by: Markus Armbruster 
Reviewed-by: Alistair Francis 

---
v4-v7: no change
v3: new patch
---
 vl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/vl.c b/vl.c
index acc6e21..7a205e0 100644
--- a/vl.c
+++ b/vl.c
@@ -1598,7 +1598,7 @@ void vm_state_notify(int running, RunState state)
 }

 static int reset_requested;
-static int shutdown_requested, shutdown_signal = -1;
+static int shutdown_requested, shutdown_signal;
 static pid_t shutdown_pid;
 static int powerdown_requested;
 static int debug_requested;
@@ -1629,7 +1629,7 @@ static int qemu_shutdown_requested(void)

 static void qemu_kill_report(void)
 {
-if (!qtest_driver() && shutdown_signal != -1) {
+if (!qtest_driver() && shutdown_signal) {
 if (shutdown_pid == 0) {
 /* This happens for eg ^C at the terminal, so it's worth
  * avoiding printing an odd message in that case.
@@ -1643,7 +1643,7 @@ static void qemu_kill_report(void)
  shutdown_cmd ? shutdown_cmd : "");
 g_free(shutdown_cmd);
 }
-shutdown_signal = -1;
+shutdown_signal = 0;
 }
 }

-- 
2.9.3




Re: [Qemu-devel] [PATCH] migration/block: optimize the performance by coalescing the same write type

2017-05-08 Thread Stefan Hajnoczi
On Mon, Apr 24, 2017 at 09:55:40PM +0800, jemmy858...@gmail.com wrote:
> From: Lidong Chen 
> 
> This patch optimizes the performance by coalescing the same write type.
> When the zero/non-zero state changes, perform the write for the accumulated
> cluster count.
> 
> Signed-off-by: Lidong Chen 
> ---
> Thanks Fam Zheng and Stefan's advice.
> ---
>  migration/block.c | 66 
> +--
>  1 file changed, 49 insertions(+), 17 deletions(-)
> 
> diff --git a/migration/block.c b/migration/block.c
> index 060087f..e9c5e21 100644
> --- a/migration/block.c
> +++ b/migration/block.c
> @@ -40,6 +40,8 @@
>  
>  #define MAX_INFLIGHT_IO 512
>  
> +#define MIN_CLUSTER_SIZE 8192

The loop accumulates adjacent zero/non-zero regions.  What is the point
of this constant?

I guess you are trying to reduce the number of loop iterations when
cluster size is small (e.g. 512).  Do you have performance results
showing that this really makes a difference?

It would be simpler to remove MIN_CLUSTER_SIZE.  Unless there is
evidence showing it's necessary simpler code is better.

> @@ -943,29 +946,58 @@ static int block_load(QEMUFile *f, void *opaque, int 
> version_id)
>  nr_sectors * BDRV_SECTOR_SIZE,
>  BDRV_REQ_MAY_UNMAP);
>  } else {
> -int i;
> -int64_t cur_addr;
> -uint8_t *cur_buf;
> +int64_t cur_addr = addr * BDRV_SECTOR_SIZE;
> +uint8_t *cur_buf = NULL;
> +int64_t last_addr = addr * BDRV_SECTOR_SIZE;
> +uint8_t *last_buf = NULL;
> +int64_t end_addr = addr * BDRV_SECTOR_SIZE + BLOCK_SIZE;
>  
>  buf = g_malloc(BLOCK_SIZE);
>  qemu_get_buffer(f, buf, BLOCK_SIZE);
> -for (i = 0; i < BLOCK_SIZE / cluster_size; i++) {
> -cur_addr = addr * BDRV_SECTOR_SIZE + i * cluster_size;
> -cur_buf = buf + i * cluster_size;
> -
> -if ((!block_mig_state.zero_blocks ||
> -cluster_size < BLOCK_SIZE) &&
> -buffer_is_zero(cur_buf, cluster_size)) {
> -ret = blk_pwrite_zeroes(blk, cur_addr,
> -cluster_size,
> +cur_buf = buf;
> +last_buf = buf;
> +
> +while (last_addr < end_addr) {
> +int is_zero = 0;

Please use bool for boolean values.


signature.asc
Description: PGP signature


  1   2   3   4   >