Re: [Qemu-devel] [PATCH qemu v6] memory/iommu: QOM'fy IOMMU MemoryRegion

2017-05-07 Thread David Gibson
On Fri, May 05, 2017 at 08:19:30PM +1000, Alexey Kardashevskiy wrote:
> This defines new QOM object - IOMMUMemoryRegion - with MemoryRegion
> as a parent.
> 
> This moves IOMMU-related fields from MR to IOMMU MR. However to avoid
> dymanic QOM casting in fast path (address_space_translate, etc),
> this adds an @is_iommu boolean flag to MR and provides new helper to
> do simple cast to IOMMU MR - memory_region_get_iommu. The flag
> is set in the instance init callback. This defines
> memory_region_is_iommu as memory_region_get_iommu()!=NULL.
> 
> This switches MemoryRegion to IOMMUMemoryRegion in most places except
> the ones where MemoryRegion may be an alias.
> 
> This defines memory_region_init_iommu_type() to allow creating
> IOMMUMemoryRegion subclasses. In order to support custom QOM type,
> this splits memory_region_init() to object_initialize() +
> memory_region_do_init.
> 
> Signed-off-by: Alexey Kardashevskiy 

Reviewed-by: David Gibson 

With the caveat that this will conflict with Peter Xu's outstanding
patches which adjust the semantics of the IOMMU translate function.

> ---
> Changes:
> v6:
> * s/\/iommu_mr/g
> 
> v5:
> * fixed sparc64, first time in many years did run "./configure" without
> --target-list :-D Sorry for the noise though :(
> 
> v4:
> * fixed alpha, mips64el and sparc
> 
> v3:
> * rebased on sha1 81b2d5ceb0
> 
> v2:
> * added mr->is_iommu
> * updated i386/x86_64/s390/sun
> ---
>  hw/s390x/s390-pci-bus.h   |   2 +-
>  include/exec/memory.h |  77 +++---
>  include/hw/i386/intel_iommu.h |   2 +-
>  include/hw/mips/mips.h|   2 +-
>  include/hw/ppc/spapr.h|   3 +-
>  include/hw/vfio/vfio-common.h |   2 +-
>  include/qemu/typedefs.h   |   1 +
>  exec.c|  16 +++---
>  hw/alpha/typhoon.c|   8 ++-
>  hw/dma/rc4030.c   |   8 +--
>  hw/i386/amd_iommu.c   |   9 +--
>  hw/i386/intel_iommu.c |  17 +++---
>  hw/mips/mips_jazz.c   |   2 +-
>  hw/pci-host/apb.c |   6 +-
>  hw/ppc/spapr_iommu.c  |  20 ---
>  hw/s390x/s390-pci-bus.c   |   6 +-
>  hw/s390x/s390-pci-inst.c  |   8 +--
>  hw/vfio/common.c  |  12 ++--
>  hw/vfio/spapr.c   |   3 +-
>  memory.c  | 124 
> +-
>  20 files changed, 213 insertions(+), 115 deletions(-)
> 
> diff --git a/hw/s390x/s390-pci-bus.h b/hw/s390x/s390-pci-bus.h
> index cf142a3e68..6a599ed353 100644
> --- a/hw/s390x/s390-pci-bus.h
> +++ b/hw/s390x/s390-pci-bus.h
> @@ -266,7 +266,7 @@ typedef struct S390PCIIOMMU {
>  S390PCIBusDevice *pbdev;
>  AddressSpace as;
>  MemoryRegion mr;
> -MemoryRegion iommu_mr;
> +IOMMUMemoryRegion iommu_mr;
>  bool enabled;
>  uint64_t g_iota;
>  uint64_t pba;
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index 99e0f54d86..3638089c1d 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -37,6 +37,10 @@
>  #define MEMORY_REGION(obj) \
>  OBJECT_CHECK(MemoryRegion, (obj), TYPE_MEMORY_REGION)
>  
> +#define TYPE_IOMMU_MEMORY_REGION "qemu:iommu-memory-region"
> +#define IOMMU_MEMORY_REGION(obj) \
> +OBJECT_CHECK(IOMMUMemoryRegion, (obj), TYPE_IOMMU_MEMORY_REGION)
> +
>  typedef struct MemoryRegionOps MemoryRegionOps;
>  typedef struct MemoryRegionMmio MemoryRegionMmio;
>  
> @@ -186,15 +190,16 @@ typedef struct MemoryRegionIOMMUOps 
> MemoryRegionIOMMUOps;
>  
>  struct MemoryRegionIOMMUOps {
>  /* Return a TLB entry that contains a given address. */
> -IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool 
> is_write);
> +IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr,
> +   bool is_write);
>  /* Returns minimum supported page size */
> -uint64_t (*get_min_page_size)(MemoryRegion *iommu);
> +uint64_t (*get_min_page_size)(IOMMUMemoryRegion *iommu);
>  /* Called when IOMMU Notifier flag changed */
> -void (*notify_flag_changed)(MemoryRegion *iommu,
> +void (*notify_flag_changed)(IOMMUMemoryRegion *iommu,
>  IOMMUNotifierFlag old_flags,
>  IOMMUNotifierFlag new_flags);
>  /* Set this up to provide customized IOMMU replay function */
> -void (*replay)(MemoryRegion *iommu, IOMMUNotifier *notifier);
> +void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier);
>  };
>  
>  typedef struct CoalescedMemoryRange CoalescedMemoryRange;
> @@ -216,7 +221,6 @@ struct MemoryRegion {
>  uint8_t dirty_log_mask;
>  RAMBlock *ram_block;
>  Object *owner;
> -const MemoryRegionIOMMUOps *iommu_ops;
>  
>  const MemoryRegionOps *ops;
>  void *opaque;
> @@ -239,6 +243,13 @@ struct MemoryRegion {
>  const char *name;
>  unsigned ioeventfd_nb;
>  MemoryRegionIoeventfd *ioeventfds;
> +

Re: [Qemu-devel] [RFC PATCH 3/8] memory: rename iommu_notifier_init()

2017-05-07 Thread Peter Xu
On Mon, May 01, 2017 at 02:53:35PM +1000, David Gibson wrote:
> On Thu, Apr 27, 2017 at 05:34:15PM +0800, Peter Xu wrote:
> > It's new name is iommu_mr_notifier_init(). Again, literal changes only.
> > 
> > Signed-off-by: Peter Xu 
> 
> Again, I think this could be folded with the previous two patches.

Sure. I can squash them all after I know whether we'll need this
series.

> 
> Signed-off-by: David Gibson 
> 
> I also note that these patches will conflict with Alexey's proposed
> changes to make IOMMU MR's a QOM subtype of the ordinary MR (thus
> removing some of the MR specific fields from other MRs.

No problem. Due to some reason I just came back to read all the mails,
so haven't read them yet. I can rebase when needed. Thanks,

-- 
Peter Xu



Re: [Qemu-devel] [RFC PATCH 6/8] memory: introduce AddressSpaceOps

2017-05-07 Thread Peter Xu
On Mon, May 01, 2017 at 02:58:22PM +1000, David Gibson wrote:
> On Thu, Apr 27, 2017 at 05:34:18PM +0800, Peter Xu wrote:
> > This is something similar to MemoryRegionOps, it's just for address
> > spaces to store arch-specific hooks.
> > 
> > The first hook I would like to introduce is iommu_get().
> > 
> > For systems that have IOMMUs, we will create a special address space per
> > device which is different from system default address space for
> > it (please refer to pci_device_iommu_address_space()). Normally when
> > that happens, there will be one specific IOMMU (or say, translation
> > unit) stands right behind that new address space.
> > 
> > This iommu_get() fetches that guy behind the address space. Here, the
> > guy is defined as IOMMUObject, which is currently a (void *). In the
> > future, maybe we can make it a better definition, but imho it's good
> > enough for now, considering it's arch-dependent.
> > 
> > Signed-off-by: Peter Xu 
> 
> This doesn't make sense to me.  It would be entirely possible for a
> single address space to have different regions mapped by different
> IOMMUs.  Or some regions mapped by IOMMUs and others direct mapped to
> a device or memory block.

Oh, so it's more complicated than I thought... Then, do we really have
existing use case that one device is managed by more than one IOMMU
(on any of the platform)? Frankly speaking I haven't thought about
complicated scenarios like this, or nested IOMMUs yet.

This patch derived from a requirement in virt-svm project (on x86).
Virt-svm needs some notification mechanism for each IOMMU (or say, the
IOMMU that managers the SVM-enabled device). For now, all IOMMU
notifiers are per-memory-region not per-iommu, and that's imho not
what virt-svm wants. Any suggestions?

Thanks,

-- 
Peter Xu



Re: [Qemu-devel] [PATCH v2 23/24] numa: add '-numa cpu, ...' option for property based node mapping

2017-05-07 Thread David Gibson
On Wed, May 03, 2017 at 02:57:17PM +0200, Igor Mammedov wrote:
> legacy cpu to node mapping is using cpu index values to map
> VCPU to node with help of '-numa node,nodeid=node,cpus=x[-y]'
> option. However cpu index is internal concept and QEMU users
> have to guess /reimplement qemu's logic/ to map it to
> a concrete cpu socket/core/thread to make sane CPUs
> placement across numa nodes.
> 
> This patch allows to map cpu objects to numa nodes using
> the same properties as used for cpus with -device/device_add
> (socket-id/core-id/thread-id/node-id).
> 
> At present valid properties/values to address CPUs could be
> fetched using hotpluggable-cpus monitor/qmp command, it will
> require user to start qemu twice when creating domain to fetch
> possible CPUs for a machine type/-smp layout first and
> then the second time with numa explicit mapping for actual
> usage. The first step results could be saved and reused to
> set/change mapping later as far as machine type/-smp stays
> the same.
> 
> Proposed impl. supports exact and wildcard matching to
> simplify CLI and allow to set mapping for a specific cpu
> or group of cpu objects specified by matched properties.
> 
> For example:
> 
># exact mapping x86
>-numa cpu,node-id=x,socket-id=y,core-id=z,thread-id=n
> 
># exact mapping SPAPR
>-numa cpu,node-id=x,core-id=y
> 
># wildcard mapping, all cpu objects that match socket-id=y
># are mapped to node-id=x
>-numa cpu,node-id=x,socket-id=y
> 
> Signed-off-by: Igor Mammedov 
> ---
> v2:
>   - use new NumaCpuOptions instead of CpuInstanceProperties in
> NumaOptions, so that in future we could decouple both
> if needed. (Eduardo Habkost )
>   - clarify effect of NumaCpuOptions.node-id in qapi-schema.json
> ---
>  numa.c   | 25 +
>  qapi-schema.json | 21 +++--
>  qemu-options.hx  | 23 ++-
>  3 files changed, 66 insertions(+), 3 deletions(-)
> 
> diff --git a/numa.c b/numa.c
> index 40e9f44..61521f5 100644
> --- a/numa.c
> +++ b/numa.c
> @@ -227,6 +227,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error 
> **errp)
>  NumaOptions *object = NULL;
>  MachineState *ms = opaque;
>  Error *err = NULL;
> +CpuInstanceProperties cpu;
>  
>  {
>  Visitor *v = opts_visitor_new(opts);
> @@ -246,6 +247,30 @@ static int parse_numa(void *opaque, QemuOpts *opts, 
> Error **errp)
>  }
>  nb_numa_nodes++;
>  break;
> +case NUMA_OPTIONS_TYPE_CPU:
> +if (!object->u.cpu.has_node_id) {
> +error_setg(, "Missing mandatory node-id property");
> +goto end;
> +}
> +if (!numa_info[object->u.cpu.node_id].present) {
> +error_setg(, "Invalid node-id=%" PRId64 ", NUMA node must be 
> "
> +"defined with -numa node,nodeid=ID before it's used with "
> +"-numa cpu,node-id=ID", object->u.cpu.node_id);
> +goto end;
> +}
> +
> +memset(, 0, sizeof(cpu));
> +cpu.has_node_id = object->u.cpu.has_node_id;
> +cpu.node_id = object->u.cpu.node_id;
> +cpu.has_socket_id = object->u.cpu.has_socket_id;
> +cpu.socket_id = object->u.cpu.socket_id;
> +cpu.has_core_id = object->u.cpu.has_core_id;
> +cpu.core_id = object->u.cpu.core_id;
> +cpu.has_thread_id = object->u.cpu.has_thread_id;
> +cpu.thread_id = object->u.cpu.thread_id;
> +
> +machine_set_cpu_numa_node(ms, , );

It's possible I've confused myself by not looking at this whole series
at once.

But, would it be possible to make a single machine hook which maps a
constructed cpu property set to a "canonical" cpu property set from
the table of CPU slots (or errors, of course).  That would let you do
what you need here, and I suspect in other places, without multiple
hooks.

> +break;
>  default:
>  abort();
>  }
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 76d137d..5baf3a4 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -5680,10 +5680,12 @@
>  ##
>  # @NumaOptionsType:
>  #
> +# @cpu: property based CPU(s) to node mapping (Since: 2.10)
> +#
>  # Since: 2.1
>  ##
>  { 'enum': 'NumaOptionsType',
> -  'data': [ 'node' ] }
> +  'data': [ 'node', 'cpu' ] }
>  
>  ##
>  # @NumaOptions:
> @@ -5696,7 +5698,8 @@
>'base': { 'type': 'NumaOptionsType' },
>'discriminator': 'type',
>'data': {
> -'node': 'NumaNodeOptions' }}
> +'node': 'NumaNodeOptions',
> +'cpu': 'NumaCpuOptions' }}
>  
>  ##
>  # @NumaNodeOptions:
> @@ -5725,6 +5728,20 @@
> '*memdev': 'str' }}
>  
>  ##
> +# @NumaCpuOptions:
> +#
> +# Option "-numa cpu" overrides default cpu to node mapping.
> +# It accepts the same set of cpu properties as returned by
> +# query-hotpluggable-cpus[].props, where node-id could be used to
> +# override default node mapping.
> +#
> +# Since: 2.10
> +##
> 

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

2017-05-07 Thread David Gibson
On Fri, May 05, 2017 at 02:38:08PM -0500, Eric Blake wrote:
> 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]

[snip]

> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index 9f18f75..2735fe9 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -1166,7 +1166,7 @@ static target_ulong 
> h_client_architecture_support(PowerPCCPU *cpu,
>  spapr_ovec_cleanup(ov5_updates);
> 
>  if (spapr->cas_reboot) {
> -qemu_system_reset_request();
> +qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);

I'm not 100% sure about this one, since I'm not sure 100% of how the
different enum values are defined.  This one is tripped when feature
negotiation between firmware and guest can't be satisfied without
rebooting (next time round the firmware will use some different
options).

So it's essentially a firmware/hypervisor triggered reset, but one
that should only ever be tripped during early guest boot.  Is
CAUSE_GUEST_RESET correct for that?

Apart from this, ppc changes

Acked-by: David Gibson 

-- 
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 v7 00/13] basic channel IO passthrough infrastructure based on vfio

2017-05-07 Thread Dong Jia Shi
* Cornelia Huck  [2017-05-05 14:22:34 +0200]:

> On Fri,  5 May 2017 04:03:39 +0200
> Dong Jia Shi  wrote:
> 
> > The patch series introduce a basic channel I/O passthrough
> > infrastructure based on vfio.
> > - Focus on supporting dasd-eckd(cu_type/dev_type = 0x3990/0x3390) as
> >   the target device. 
> > - Support new qemu parameters in the style of:
> > -machine s390-ccw-virtio(,s390-squash-mcss=on|off) \
> > -device vfio-ccw,sysfsdev=$MDEV_PATH
> >   We want to support real (i.e. not virtual) channel devices even for
> >   guests that do not support MCSS-E (where guests may see devices from
> >   any channel subsystem image at once). As all virtio-ccw devices are in
> >   css 0xfe (and show up in the default css 0 for guests not activating
> >   MCSS-E), we need an option to squash e.g. passed-through channel devices
> >   from their real css (0-3, or 0 for hosts not activating MCSS-E) into
> >   the default css, that is what the new machine option s390-squash-css is
> >   added.
> 
> Basically looks good, some small nitpicking and the virtual vs. virtio
> issue I noticed.
Thanks for the review! I replied in the coressponding threads.

> 
> Let's wait if others have more comments. Hopefully, the 3270 changes
> will by then be in master and you can rebase on top of them :)
Roger!

-- 
Dong Jia Shi




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

2017-05-07 Thread Dong Jia Shi
* 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

> 
> 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-07 Thread Dong Jia Shi
* Cornelia Huck  [2017-05-05 14:11:53 +0200]:

> On Fri,  5 May 2017 04:03:44 +0200
> Dong Jia Shi  wrote:
> 
> > The S390 virtual css support already has a mechanism to create a
> > virtual subchannel and provide it to the guest. However, to
> > pass-through subchannels to a guest, we need to introduce a new
> > mechanism to create the subchannel according to the real device
> > information. Thus we reconstruct css_create_virtual_sch to a new
> > css_create_sch function to handl all these cases and do allocation
> 
> s/handl/handle/
> 
Shame on me. :-/

> > and initialization of the subchannel according to the device type
> > and machine configuration.
> > 
> > Reviewed-by: Pierre Morel 
> > Signed-off-by: Dong Jia Shi 
> > ---
> >  hw/s390x/css-bridge.c |  2 ++
> >  hw/s390x/css.c| 45 
> > ---
> >  hw/s390x/s390-virtio-ccw.c| 12 +---
> >  hw/s390x/virtio-ccw.c |  6 +-
> >  include/hw/s390x/css-bridge.h |  1 +
> >  include/hw/s390x/css.h| 25 
> >  6 files changed, 72 insertions(+), 19 deletions(-)
> > 
> 
> > diff --git a/hw/s390x/css.c b/hw/s390x/css.c
> > index 748e2ad..1052eea 100644
> > --- a/hw/s390x/css.c
> > +++ b/hw/s390x/css.c
> > @@ -1924,28 +1924,59 @@ PropertyInfo css_devid_ro_propinfo = {
> >  .get = get_css_devid,
> >  };
> > 
> > -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

> 
> 
> >  return NULL;
> >  }
> > +}
> > +
> > +if (bus_id.valid) {
> > +if (squash_mcss) {
> > +bus_id.cssid = channel_subsys.default_cssid;
> > +} else if (!channel_subsys.css[bus_id.cssid]) {
> > +css_create_css_image(bus_id.cssid, false);
> > +}
> > +
> >  if (!css_find_free_subch_for_devno(bus_id.cssid, bus_id.ssid,
> > bus_id.devid, , errp)) {
> >  return NULL;
> >  }
> > -} else {
> > -bus_id.cssid = VIRTUAL_CSSID;
> > +} else if (squash_mcss || is_virtio) {
> > +bus_id.cssid = channel_subsys.default_cssid;
> > +
> >  if (!css_find_free_subch_and_devno(bus_id.cssid, _id.ssid,
> > _id.devid, , errp)) {
> >  return NULL;
> >  }
> > +} else {
> > +for (bus_id.cssid = 0; bus_id.cssid < MAX_CSSID; ++bus_id.cssid) {
> > +if (bus_id.cssid == VIRTUAL_CSSID) {
> > +continue;
> > +}
> > +
> > +if (!channel_subsys.css[bus_id.cssid]) {
> > +css_create_css_image(bus_id.cssid, false);
> > +}
> > +
> > +if   (css_find_free_subch_and_devno(bus_id.cssid, _id.ssid,
> > +_id.devid, ,
> > +NULL)) {
> > +break  ;
> 
> extra blanks
> 
Shame again...

> > +}
> > +if (bus_id.cssid == MAX_CSSID) {
> > +error_setg(errp, "Virtual channel subsystem is full!");
> > +return NULL;
> > +}
> > +}
> >  }
> > 
> >  sch = g_malloc0(sizeof(*sch));
> > diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> > index cd007ca..735d66d 100644
> > 

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

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

diff --git a/MAINTAINERS b/MAINTAINERS
index 9251f575d8..c7520b76db 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 18/23] shippable: temporary disable mips64el-softmmu build

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

diff --git a/.shippable.yml b/.shippable.yml
index 6601243060..7e714991f9 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -15,8 +15,9 @@ env:
   TARGET_LIST=aarch64-softmmu,aarch64-linux-user
 - IMAGE=debian-s390x-cross
   TARGET_LIST=s390x-softmmu,s390x-linux-user
+# mips64el-softmmu disabled due to libfdt problem
 - IMAGE=debian-mipsel-cross
-  
TARGET_LIST=mipsel-softmmu,mips64el-softmmu,mipsel-linux-user,mips64el-linux-user
+  TARGET_LIST=mipsel-softmmu,mipsel-linux-user,mips64el-linux-user
 build:
   pre_ci:
 - make docker-image-${IMAGE}
-- 
2.11.0




[Qemu-devel] How do you -sd squashfs.img without truncating?

2017-05-07 Thread Rob Landley
As far as I can tell "qemu-system-arm -M vexpress-a9" only implements sd
card, not any conventional hard drive, and it uses an sdcard block size
of 262144 bytes rounded down. This means when I create a squashfs image
and feed it in through the sd card, it truncates it.

Wouldn't -sd rounding _up_ be more useful?

Rob



[Qemu-devel] [PATCH 20/23] shippable: add powerpc target

2017-05-07 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 7e714991f9..3a80165b6a 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -18,6 +18,8 @@ env:
 # mips64el-softmmu disabled due to libfdt problem
 - IMAGE=debian-mipsel-cross
   TARGET_LIST=mipsel-softmmu,mipsel-linux-user,mips64el-linux-user
+- IMAGE=debian-powerpc-cross
+  TARGET_LIST=ppc-softmmu,ppcemb-softmmu,ppc-linux-user
 build:
   pre_ci:
 - make docker-image-${IMAGE}
-- 
2.11.0




[Qemu-devel] [PATCH 22/23] MAINTAINERS: add Shippable automation platform URL

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

diff --git a/MAINTAINERS b/MAINTAINERS
index a1d2b3a4d3..9251f575d8 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 16/23] shippable: do not initialize submodules automatically

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

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

diff --git a/.shippable.yml b/.shippable.yml
index fa2d6a4e9b..b3cbca458c 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -1,4 +1,6 @@
 language: c
+git:
+   submodules: false
 env:
   global:
 - LC_ALL=C
-- 
2.11.0




[Qemu-devel] [PATCH 21/23] docker: fix powerpc debian/stable dependencies problem

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

diff --git a/tests/docker/dockerfiles/debian-powerpc-cross.docker 
b/tests/docker/dockerfiles/debian-powerpc-cross.docker
index 9107ebc2d3..d6e4d1e977 100644
--- a/tests/docker/dockerfiles/debian-powerpc-cross.docker
+++ b/tests/docker/dockerfiles/debian-powerpc-cross.docker
@@ -12,6 +12,13 @@ RUN dpkg --add-architecture powerpc && \
 DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
 crossbuild-essential-powerpc
 
+#  to fix "following packages have unmet dependencies" ...
+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-
 
-- 
2.11.0




[Qemu-devel] [RFC PATCH 13/23] docker: add --include-file argument to 'build' command

2017-05-07 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 ceff2c1654..47978fb56c 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..4c096a8178 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 binary 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




[Qemu-devel] [PATCH 19/23] docker: add powerpc build target

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

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index ca6f57a292..704b74bfbd 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -61,6 +61,7 @@ docker-image-debian: 
EXTRA_FILE:=tests/docker/dockerfiles/debian-apt-fake.sh
 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..9107ebc2d3
--- /dev/null
+++ b/tests/docker/dockerfiles/debian-powerpc-cross.docker
@@ -0,0 +1,23 @@
+#
+# 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
+
+# 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 15/23] docker: fix mipsel debian/stable dependencies problem

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

diff --git a/tests/docker/dockerfiles/debian-mipsel-cross.docker 
b/tests/docker/dockerfiles/debian-mipsel-cross.docker
index c569a2e1b4..3c4945d78e 100644
--- a/tests/docker/dockerfiles/debian-mipsel-cross.docker
+++ b/tests/docker/dockerfiles/debian-mipsel-cross.docker
@@ -12,6 +12,13 @@ RUN dpkg --add-architecture mipsel && \
 DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -y 
--no-install-recommends \
 crossbuild-essential-mipsel
 
+#  to fix "following packages have unmet dependencies" ...
+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-
 
-- 
2.11.0




[Qemu-devel] [PATCH 05/23] docker: compact debian armhf

2017-05-07 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 11/23] shippable: add mipsel target

2017-05-07 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 b661e667b3..fa2d6a4e9b 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -13,6 +13,8 @@ env:
   TARGET_LIST=aarch64-softmmu,aarch64-linux-user
 - IMAGE=debian-s390x-cross
   TARGET_LIST=s390x-softmmu,s390x-linux-user
+- IMAGE=debian-mipsel-cross
+  
TARGET_LIST=mipsel-softmmu,mips64el-softmmu,mipsel-linux-user,mips64el-linux-user
 build:
   pre_ci:
 - make docker-image-${IMAGE}
-- 
2.11.0




[Qemu-devel] [PATCH 17/23] shippable: use dtc submodule if distrib packages are too old

2017-05-07 Thread Philippe Mathieu-Daudé
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

having this too old libfdt version (required version >= 1.4.2):
 # dpkg-query --showformat='${Version}\n' --show libfdt-dev
1.4.0+dfsg-1

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

diff --git a/.shippable.yml b/.shippable.yml
index b3cbca458c..6601243060 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -27,5 +27,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)
-- 
2.11.0




[Qemu-devel] [RFC PATCH 14/23] docker: add 'apt-fake' script which generate fake debian packages

2017-05-07 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/docker/Makefile.include   |  2 ++
 tests/docker/dockerfiles/debian-apt-fake.sh | 46 +
 tests/docker/dockerfiles/debian.docker  |  2 ++
 3 files changed, 50 insertions(+)
 create mode 100755 tests/docker/dockerfiles/debian-apt-fake.sh

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 47978fb56c..ca6f57a292 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -55,6 +55,8 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
$(if $(EXTRA_FILE),--include-file=$(EXTRA_FILE)),\
"BUILD","$*")
 
+docker-image-debian: 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
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
diff --git a/tests/docker/dockerfiles/debian.docker 
b/tests/docker/dockerfiles/debian.docker
index 694f8d3b63..a99396ae8f 100644
--- a/tests/docker/dockerfiles/debian.docker
+++ b/tests/docker/dockerfiles/debian.docker
@@ -22,6 +22,8 @@ RUN apt-get update && \
 # Duplicate deb line as deb-src
 RUN cat /etc/apt/sources.list | sed "s/deb/deb-src/" >> /etc/apt/sources.list
 
+ADD debian-apt-fake.sh /usr/local/bin/apt-fake
+
 # Setup Emdebian
 RUN 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 10/23] docker: add mipsel build target

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

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 03eda37bf4..ceff2c1654 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -57,6 +57,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
 # 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..c569a2e1b4
--- /dev/null
+++ b/tests/docker/dockerfiles/debian-mipsel-cross.docker
@@ -0,0 +1,23 @@
+#
+# 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
+
+# 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 04/23] docker: compact debian base

2017-05-07 Thread Philippe Mathieu-Daudé
- install common/basic tools at once
- one-line Emdebian setup
- use eatmydata and remove apt cache to save space
- add bison and flex and git

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

diff --git a/tests/docker/dockerfiles/debian.docker 
b/tests/docker/dockerfiles/debian.docker
index 52bd79938e..694f8d3b63 100644
--- a/tests/docker/dockerfiles/debian.docker
+++ b/tests/docker/dockerfiles/debian.docker
@@ -9,17 +9,19 @@
 #
 FROM debian:stable-slim
 
-# Setup some basic tools we need
-RUN apt update
-RUN apt install -yy curl aptitude
-
-# 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 -
+# 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 \
+curl aptitude \
+build-essential clang git \
+bison flex && \
+rm -rf /var/lib/apt
 
 # 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
+# Setup Emdebian
+RUN 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 12/23] docker: let _copy_with_mkdir() sub_path argument be optional

2017-05-07 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 09/23] docker: add extra libs to s390x target to extend codebase coverage

2017-05-07 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 00/23] docker/shippable: cross-build mipsel and powerpc targets

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

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

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.

I had some issues in some jobs, git reporting "Problem with the SSL CA cert"
trying to clone from github.com. I enabled GIT_CURL_VERBOSE but didn't want to
spend more time on this right now so I disabled the verification by setting
GIT_SSL_NO_VERIFY. Since we use Shippable services to compile the codebase and
not to release binaries it seemed Ok to me.

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

With the free open source projects service, each arch builds in around ~9min,
the 5 jobs take ~44min in total. It seems each docker image is rebuilt from
scratch, maybe we could save a lot pushing/pulling to a registry.

Regards,

Phil.

Philippe Mathieu-Daudé (23):
  shippable: use C locale to simplify console output
  shippable: build using all available cpus
  shippable: ignore SSL verification
  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
  shippable: add mipsel target
  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: fix mipsel debian/stable dependencies problem
  shippable: do not initialize submodules automatically
  shippable: use dtc submodule if distrib packages are too old
  shippable: temporary disable mips64el-softmmu build
  docker: add powerpc build target
  shippable: add powerpc target
  docker: fix powerpc debian/stable dependencies problem
  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  |  7 +++-
 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  | 30 ++
 .../docker/dockerfiles/debian-powerpc-cross.docker | 30 ++
 tests/docker/dockerfiles/debian-s390x-cross.docker |  6 +++
 tests/docker/dockerfiles/debian.docker | 24 ++-
 11 files changed, 186 insertions(+), 21 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 08/23] docker: add extra libs to arm64 target to extend codebase coverage

2017-05-07 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 07/23] docker: add extra libs to armhf target to extend codebase coverage

2017-05-07 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] [RFC PATCH 03/23] shippable: ignore SSL verification

2017-05-07 Thread Philippe Mathieu-Daudé
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...

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

diff --git a/.shippable.yml b/.shippable.yml
index 5170486ff9..b661e667b3 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -2,6 +2,10 @@ language: c
 env:
   global:
 - LC_ALL=C
+# sometimes Shippable fails to clone from github (git_sync stage):
+# "Problem with the SSL CA cert (path? access rights?)"
+# for now disable SSL verification.
+- GIT_SSL_NO_VERIFY=1
   matrix:
 - IMAGE=debian-armhf-cross
   TARGET_LIST=arm-softmmu,arm-linux-user
-- 
2.11.0




[Qemu-devel] [PATCH 06/23] docker: compact debian arm64

2017-05-07 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 02/23] shippable: build using all available cpus

2017-05-07 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 231c29b620..5170486ff9 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)
-- 
2.11.0




[Qemu-devel] [PATCH 01/23] shippable: use C locale to simplify console output

2017-05-07 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é 
---
 .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] [Bug 1274170] Re: qemu window hides in the background on osx

2017-05-07 Thread Launchpad Bug Tracker
[Expired for QEMU because there has been no activity for 60 days.]

** Changed in: qemu
   Status: Incomplete => Expired

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

Title:
  qemu window hides in the background on osx

Status in QEMU:
  Expired

Bug description:
  When launching qemu on OSX (10.8.5), the window comes up in the
  background.  A bit of googling shows that the addition of [NSApp
  activateIgnoringOtherApps:YES]; before the [NSApp run]; in main fixes
  this.

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



[Qemu-devel] format=raw,readonly errors

2017-05-07 Thread Carl Karsten
juser@gator:~/temp$ qemu-system-x86_64 -m 256 -display curses  -drive
file=disk.cow -drive file=boot.img
WARNING: Image format was not specified for 'boot.img' and probing guessed
raw.
 Automatically detecting the format is dangerous for raw images,
write operations on block 0 will be restricted.
 Specify the 'raw' format explicitly to remove the restrictions.

This is OK, as I don't want anything writing to that thing anyway.  So to
get rid of the waring:

juser@gator:~/temp$ qemu-system-x86_64 -drive
file=boot.img,format=raw,readonly qemu-system-x86_64: Can't use a read-only
drive
qemu-system-x86_64: Initialization of device ide-hd failed: Device
initialization failed.

hmm... one more try:

juser@gator:~/temp$ qemu-system-x86_64 -m 256 -display curses  -drive
file=disk.cow,readonly
qemu-system-x86_64: Can't use a read-only drive
qemu-system-x86_64: Initialization of device ide-hd failed: Device
initialization failed.




-- 
Carl K


Re: [Qemu-devel] boot order=d bug?

2017-05-07 Thread Carl Karsten
neat.  missed that.

except it doesn't work.

juser@gator:~/temp$ qemu-system-x86_64 -drive
file=boot.img,format=raw,bootindex=1
qemu-system-x86_64: -drive file=boot.img,format=raw,bootindex=1: Block
format 'raw' does not support the option 'bootindex'

juser@gator:~/temp$ qemu-system-x86_64 -drive
file=boot.img,bootindex=1WARNING: Image format was not specified for
'boot.img' and probing guessed raw.
 Automatically detecting the format is dangerous for raw images,
write operations on block 0 will be restricted.
 Specify the 'raw' format explicitly to remove the restrictions.
qemu-system-x86_64: -drive file=boot.img,bootindex=1: Block format 'raw'
does not support the option 'bootindex'


Is there a "yes you do --force" option ?


On Sun, May 7, 2017 at 9:02 PM, Thomas Huth  wrote:

> On 07.05.2017 07:42, Carl Karsten wrote:
> > In the real world I will have a machine with a sata hd and boot the
> > installer from a usb stick. I want to test this with 2 disk image files.
> >
> > The usb stick will be built like so:
> > https://github.com/CarlFK/video-stack-deploy/blob/
> usbstick/scripts/mk_usb_installer.sh
> >
> > but this will demo the problem I have run into with qemu:  how do I boot
> > from boot.img without using boot=menu?
>
> Have you already tried to use the bootindex property? See:
>
> http://git.qemu.org/?p=qemu.git;a=blob;f=docs/bootindex.txt
>
>  Thomas
>
>


-- 
Carl K


Re: [Qemu-devel] [RFC PATCH 0/8] Shared Virtual Memory virtualization for VT-d

2017-05-07 Thread Xiao Guangrong


Hi Liu Yi,

I haven't started to read the code yet, however, could you
detail more please? It emulates a SVM capable iommu device in
a VM? Or It speeds up device's DMA access in a VM? Or it is a
new facility introduced for a VM? Could you please add a bit
more for its usage?

Thanks!

On 04/26/2017 06:11 PM, Liu, Yi L wrote:

Hi,

This patchset introduces SVM virtualization for intel_iommu in
IOMMU/VFIO. The total SVM virtualization for intel_iommu touched
Qemu/IOMMU/VFIO.

Another patchset would change the Qemu. It is "[RFC PATCH 0/20] Qemu:
Extend intel_iommu emulator to support Shared Virtual Memory"

In this patchset, it adds two new IOMMU APIs and their implementation
in intel_iommu driver. In VFIO, it adds two IOCTL cmd attached on
container->fd to propagate data from QEMU to kernel space.

[Patch Overview]
* 1 adds iommu API definition for binding guest PASID table
* 2 adds binding PASID table API implementation in VT-d iommu driver
* 3 adds iommu API definition to do IOMMU TLB invalidation from guest
* 4 adds IOMMU TLB invalidation implementation in VT-d iommu driver
* 5 adds VFIO IOCTL for propagating PASID table binding from guest
* 6 adds processing of pasid table binding in vfio_iommu_type1
* 7 adds VFIO IOCTL for propagating IOMMU TLB invalidation from guest
* 8 adds processing of IOMMU TLB invalidation in vfio_iommu_type1

Best Wishes,
Yi L


Jacob Pan (3):
   iommu: Introduce bind_pasid_table API function
   iommu/vt-d: add bind_pasid_table function
   iommu/vt-d: Add iommu do invalidate function

Liu, Yi L (5):
   iommu: Introduce iommu do invalidate API function
   VFIO: Add new IOTCL for PASID Table bind propagation
   VFIO: do pasid table binding
   VFIO: Add new IOCTL for IOMMU TLB invalidate propagation
   VFIO: do IOMMU TLB invalidation from guest

  drivers/iommu/intel-iommu.c | 146 
  drivers/iommu/iommu.c   |  32 +
  drivers/vfio/vfio_iommu_type1.c |  98 +++
  include/linux/dma_remapping.h   |   1 +
  include/linux/intel-iommu.h |  11 +++
  include/linux/iommu.h   |  47 +
  include/uapi/linux/vfio.h   |  26 +++
  7 files changed, 361 insertions(+)





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

2017-05-07 Thread Zhang Chen



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




Thanks



.



--
Thanks
Zhang Chen






Re: [Qemu-devel] [PATCH v7 04/13] s390x/css: realize css_sch_build_schib

2017-05-07 Thread Dong Jia Shi
* Cornelia Huck  [2017-05-05 14:04:20 +0200]:

> On Fri,  5 May 2017 04:03:43 +0200
> Dong Jia Shi  wrote:
> 
> > From: Xiao Feng Ren 
> > 
> > The S390 virtual css support already has a mechanism to build virtual
> > Sub-Channel Information Block and provide virtual subchannels to the
> 
> "to build a virtual subchannel information block (schib) and provide..."
> 
Ok.

> > guest. However, to pass-through subchannels to a guest, we need to
> > introduce a new mechanism to build its schib according to the real
> > device information. Thus we realize a new css_sch_build_schib function
> > to extract the path_masks, chpids, chpid type from sysfs. To reuse
> > the existing code, we refactor css_add_virtual_chpid to css_add_chpid.
> > 
> > Reviewed-by: Pierre Morel 
> > Signed-off-by: Xiao Feng Ren 
> > Signed-off-by: Dong Jia Shi 
> > ---
> >  hw/s390x/css.c | 153 
> > -
> >  include/hw/s390x/css.h |  36 ++--
> >  2 files changed, 169 insertions(+), 20 deletions(-)
> > 
> 
> > +/*
> > + * We currently retrieve the real device information from sysfs to build 
> > the
> > + * guest subchannel information block without considering the migration 
> > feature.
> > + * If migrate, it won't be sure to use the real device information 
> > directly,
> > + * this point will be handled in the future.
> 
> Let's make the second sentence: "We need to revisit this problem when
> we want to add migration support."
> 
Ok.

> > + */
> > +int css_sch_build_schib(SubchDev *sch, CssDevId *dev_id)
> > +{
> > +CssImage *css = channel_subsys.css[sch->cssid];
> > +PMCW *p = >curr_status.pmcw;
> > +SCSW *s = >curr_status.scsw;
> > +uint32_t type;
> > +int i, ret;
> > +
> > +/* We are dealing with I/O subchannels only. */
> 
> Let's move this comment directly before setting dnv; it's a bit
> confusing here.
> 
Ok. I will move it to ...

> > +assert(css != NULL);
> > +memset(p, 0, sizeof(PMCW));
> > +p->flags |= PMCW_FLAGS_MASK_DNV;
... here.

> > +p->devno = sch->devno;
> > +
> > +/* Grab path mask from sysfs. */
> > +ret = css_sch_get_path_masks(sch, dev_id);
> > +if (ret) {
> > +return ret;
> > +}
> > +
> > +/* Grab chpids from sysfs. */
> > +ret = css_sch_get_chpids(sch, dev_id);
> > +if (ret) {
> > +return ret;
> > +}
> > +
> > +   /* Build chpid type. */
> > +for (i = 0; i < ARRAY_SIZE(p->chpid); i++) {
> > +if (p->chpid[i] && !css->chpids[p->chpid[i]].in_use) {
> > +ret = css_sch_get_chpid_type(p->chpid[i], , dev_id);
> > +if (ret) {
> > +return ret;
> > +}
> > +css_add_chpid(sch->cssid, p->chpid[i], type, false);
> > +}
> > +}
> > +
> > +memset(s, 0, sizeof(SCSW));
> > +sch->curr_status.mba = 0;
> > +for (i = 0; i < ARRAY_SIZE(sch->curr_status.mda); i++) {
> > +sch->curr_status.mda[i] = 0;
> > +}
> > +
> > +return 0;
> > +}
[...]

-- 
Dong Jia Shi




Re: [Qemu-devel] boot order=d bug?

2017-05-07 Thread Thomas Huth
On 07.05.2017 07:42, Carl Karsten wrote:
> In the real world I will have a machine with a sata hd and boot the
> installer from a usb stick. I want to test this with 2 disk image files.
> 
> The usb stick will be built like so:
> https://github.com/CarlFK/video-stack-deploy/blob/usbstick/scripts/mk_usb_installer.sh
> 
> but this will demo the problem I have run into with qemu:  how do I boot
> from boot.img without using boot=menu?

Have you already tried to use the bootindex property? See:

http://git.qemu.org/?p=qemu.git;a=blob;f=docs/bootindex.txt

 Thomas




Re: [Qemu-devel] [virtio-dev] Vhost-pci RFC2.0

2017-05-07 Thread Wei Wang

On 05/05/2017 05:18 PM, Jason Wang wrote:



On 2017年05月05日 14:18, Wei Wang wrote:

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



On 2017年04月19日 14:38, Wang, Wei W wrote:

Hi,
We made some design changes to the original vhost-pci design, and 
want to open
a discussion about the latest design (labelled 2.0) and its 
extension (2.1).

2.0 design: One VM shares the entire memory of another VM
2.1 design: One VM uses an intermediate memory shared with another 
VM for

 packet transmission.
For the convenience of discussion, I have some pictures presented 
at this link:
_https://github.com/wei-w-wang/vhost-pci-discussion/blob/master/vhost-pci-rfc2.0.pdf_ 



Hi, is there any doc or pointer that describes the the design in 
detail? E.g patch 4 in v1 
https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg05163.html.


Thanks


That link is kind of obsolete.

We currently only have high level introduction of the design:

For the device part design, please check slide 12:
http://www.linux-kvm.org/images/5/55/02x07A-Wei_Wang-Design_of-Vhost-pci.pdf 

The vhost-pci protocol is changed to be an extension of vhost-user 
protocol.


For the driver part design, please check Fig. 2:

https://github.com/wei-w-wang/vhost-pci-discussion/blob/master/vhost-pci-rfc2.0.pdf 



Thanks for the pointers. It would be nice to have a doc like patch 4 
in v1, this could ease reviewers, otherwise we may guess and ask for 
them.




Thanks for joining the review. I'm preparing the v2 QEMU patches. I will 
have the code sent out first,

which would be helpful for understanding how the design works.

Best,
Wei




[Qemu-devel] 撤回: Why we need redirect the access to bar0 through the PCI config space access function

2017-05-07 Thread wuzongyong (A)
wuzongyong (A) 将撤回邮件“Why we need redirect the access to bar0 through the PCI 
config space access function”。

Re: [Qemu-devel] [virtio-dev] virtio-net: configurable TX queue size

2017-05-07 Thread Wei Wang

On 05/07/2017 08:02 PM, Yan Vugenfirer wrote:

On 5 May 2017, at 12:20, Jason Wang  wrote:



On 2017年05月05日 13:53, Wei Wang wrote:

On 05/05/2017 10:27 AM, Jason Wang wrote:


On 2017年05月04日 18:58, Wang, Wei W wrote:

Hi,

I want to re-open the discussion left long time ago:
https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg06194.html
, and discuss the possibility of changing the hardcoded (256) TX  queue
size to be configurable between 256 and 1024.

Yes, I think we probably need this.

That's great, thanks.


The reason to propose this request is that a severe issue of packet drops in
TX direction was observed with the existing hardcoded 256 queue size,
which causes performance issues for packet drop sensitive guest
applications that cannot use indirect descriptor tables. The issue goes away
with 1K queue size.

Do we need even more, what if we find 1K is even not sufficient in the future? 
Modern nics has size up to ~8192.

Yes. Probably, we can also set the RX queue size to 8192 (currently it's 1K) as 
well.


The concern mentioned in the previous discussion (please check the link
above) is that the number of chained descriptors would exceed
UIO_MAXIOV (1024) supported by the Linux.

We could try to address this limitation but probably need a new feature bit to 
allow more than UIO_MAXIOV sgs.

I think we should first discuss whether it would be an issue below.


 From the code,  I think the number of the chained descriptors is limited to
MAX_SKB_FRAGS + 2 (~18), which is much less than UIO_MAXIOV.

This is the limitation of #page frags for skb, not the iov limitation.

I think the number of page frags are filled into the same number of descriptors
in the virtio-net driver (e.g. use 10 descriptors for 10 page frags). On the 
other
side, the virtio-net backend uses the same number of iov for the descriptors.

Since the number of page frags is limited to 18, I think there wouldn't be more
than 18 iovs to be passed to writev, right?

This limitation assumption is incorrect for Windows. We saw cases (and 
strangely enough with small packets) when Windows returns scatter gather list 
with 32 descriptors or more.

OK, thanks for sharing. Michael has also pointed out the non-linux 
driver cases. We're looking into ways to split the large iov.


Best,
Wei





Re: [Qemu-devel] dns server not working in QEMU using usermode networking (SLIRP)

2017-05-07 Thread Thomas Huth
On 06.05.2017 00:38, FONNEMANN Mark wrote:
>> Could you run tcpdump inside the guest so we are sure what the nslookup call 
>> emits?
> 
> Is there another way to determine this info? My guest OS is an embedded 
> system with BusyBox 1.25 and not much else.

FWIW, QEMU also has a built-in packet-dump functionality. You can use it
like this:

qemu-system-xxx ... -netdev user,id=netuser \
   -object filter-dump,id=dump,netdev=netuser,file=/tmp/dump.dat \
   -device e1000,netdev=netuser,mac=00:11:22:33:44:55

Then run "wireshark -r /tmp/dump.dat" afterwards to have a look at the
packets.

 Thomas




[Qemu-devel] [Bug 1581936] Re: Frozen Windows 7 VMs with VGA CVE-2016-3712 fix (2.6.0 and 2.5.1.1)

2017-05-07 Thread Mathew Hodson
** Changed in: qemu (Ubuntu)
   Importance: Undecided => High

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

Title:
  Frozen Windows 7 VMs with VGA CVE-2016-3712 fix (2.6.0 and 2.5.1.1)

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Triaged
Status in qemu source package in Xenial:
  Triaged

Bug description:
  Hi,

  As already posted on the QEMU devel list [1] I stumbled upon a problem
  with QEMU in version 2.5.1.1 and 2.6.0.

  the VM shows Windows loading
  files for the installation, then the "Starting Windows" screen appears
  here it hangs and never continues.

  Changing the "-vga" option to cirrus solves this, the installation can
  proceed and finish. When changing back to std (or also qxl, vmware) the
  installed VM also hangs on the "Starting Windows" screen while qemu
  showing a little but no excessive load.

  This phenomena appears also with QEMU 2.6.0 but not with 2.6.0-rc4, a
  git bisect shows fd3c136b3e1482cd0ec7285d6bc2a3e6a62c38d7 (vga: make
  sure vga register setup for vbe stays intact (CVE-2016-3712)) as the
  culprit for this regression, as its a fix for a DoS its not an option to
  just revert it, I guess.

  The bisect log is:

  git bisect start
  # bad: [bfc766d38e1fae5767d43845c15c79ac8fa6d6af] Update version for v2.6.0 
release
  git bisect bad bfc766d38e1fae5767d43845c15c79ac8fa6d6af
  # good: [975eb6a547f809608ccb08c221552f11af25] Update version for 
v2.6.0-rc4 release
  git bisect good 975eb6a547f809608ccb08c221552f11af25
  # good: [2068192dcccd8a80dddfcc8df6164cf9c26e0fc4] vga: update vga register 
setup on vbe changes
  git bisect good 2068192dcccd8a80dddfcc8df6164cf9c26e0fc4
  # bad: [53db932604dfa7bb9241d132e0173894cf54261c] Merge remote-tracking 
branch 'remotes/kraxel/tags/pull-vga-20160509-1' into staging
  git bisect bad 53db932604dfa7bb9241d132e0173894cf54261c
  # bad: [fd3c136b3e1482cd0ec7285d6bc2a3e6a62c38d7] vga: make sure vga register 
setup for vbe stays intact (CVE-2016-3712).
  git bisect bad fd3c136b3e1482cd0ec7285d6bc2a3e6a62c38d7
  # first bad commit: [fd3c136b3e1482cd0ec7285d6bc2a3e6a62c38d7] vga: make sure 
vga register setup for vbe stays intact (CVE-2016-3712).

  
  I could reproduce that with QEMU 2.5.1 and QEMU 2.6 on a Debian derivate
  (Promox VE) with 4.4 Kernel and also with QEMU 2.6 on an Arch Linux
  System with a 4.5 Kernel, so it should not be host distro depended. Both
  machines have Intel x86_64 processors.
  The problem should be reproducible with said Versions or a build from
  git including the above mentioned commit (fd3c136) by starting a VM with
  an Windows 7 ISO, e.g.:

  Freezing installation (as vga defaults to std I marked it as optional):
  ./x86_64-softmmu/qemu-system-x86_64 -boot d -cdrom win7.iso -m 1024 [-vga 
(std|qxl|vmware)]

  Working installation:
  ./x86_64-softmmu/qemu-system-x86_64 -boot d -cdrom win7.iso -m 1024 -vga 
cirrus

  If someone has already an installed Windows 7 VM this behaviour should be
  also observable when trying to start it with the new versions of QEMU.

  Noteworthy may be that Windows 10 is working, I do not had time to get
  other Windows versions and test them, I'll do that as soon as possible.
  Various Linux system also seems do work fine, at least I did not ran
  into an issue there yet.

  I also tried testing with SeaBIOS and OVMF as firmware, as initially I
  had no idea what broke, both lead to the same result - without the 
  CVE-2016-3712 fix they both work, with not.
  Further, KVM enabled and disabled does not make any difference.

  
  [1] http://lists.nongnu.org/archive/html/qemu-devel/2016-05/msg02416.html

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



[Qemu-devel] Floating point unit bugs

2017-05-07 Thread G 3
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


Here is the full source code to the 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.
  
 
**/


#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;
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);
}
}


Re: [Qemu-devel] [PATCH] gdbstub: implement remote debugging protocol escapes for command receive

2017-05-07 Thread Doug Gale
Updated patch with comments addressed:

>From 6bce4e5c87c255f10b22d2bf6fc951dde2bbf457 Mon Sep 17 00:00:00 2001
From: Doug Gale 
Date: Mon, 1 May 2017 12:22:10 -0400
Subject: [PATCH] gdbstub: implement remote debugging protocol escapes for
 command receive

- decode escape sequences
- decompress run-length encoding escape sequences
- report command parsing problems to output when debug output is enabled
- reject packet checksums that are not valid hex digits
- compute the checksum based on the packet stream, not based on the
  decoded packet

Tested with GDB and QtCreator integrated debugger on SMP QEMU instance.
Works for me.

Signed-off-by: Doug Gale 
---
 gdbstub.c | 108 --
 1 file changed, 99 insertions(+), 9 deletions(-)

diff --git a/gdbstub.c b/gdbstub.c
index 9911153..3abaf7c 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -286,6 +286,8 @@ enum RSState {
 RS_INACTIVE,
 RS_IDLE,
 RS_GETLINE,
+RS_GETLINE_ESC,
+RS_GETLINE_RLE,
 RS_CHKSUM1,
 RS_CHKSUM2,
 };
@@ -296,7 +298,8 @@ typedef struct GDBState {
 enum RSState state; /* parsing state */
 char line_buf[MAX_PACKET_LENGTH];
 int line_buf_index;
-int line_csum;
+int line_sum; /* running checksum */
+int line_csum; /* checksum at the end of the packet */
 uint8_t last_packet[MAX_PACKET_LENGTH + 4];
 int last_packet_len;
 int signal;
@@ -1508,7 +1511,6 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb,
const char *fmt, ...)

 static void gdb_read_byte(GDBState *s, int ch)
 {
-int i, csum;
 uint8_t reply;

 #ifndef CONFIG_USER_ONLY
@@ -1542,35 +1544,123 @@ static void gdb_read_byte(GDBState *s, int ch)
 switch(s->state) {
 case RS_IDLE:
 if (ch == '$') {
+/* start of command packet */
 s->line_buf_index = 0;
+s->line_sum = 0;
 s->state = RS_GETLINE;
+} else {
+#ifdef DEBUG_GDB
+printf("gdbstub received garbage between packets: 0x%x\n", ch);
+#endif
 }
 break;
 case RS_GETLINE:
+if (ch == '}') {
+/* start escape sequence */
+s->state = RS_GETLINE_ESC;
+s->line_sum += ch;
+} else if (ch == '*') {
+/* start run length encoding sequence */
+s->state = RS_GETLINE_RLE;
+s->line_sum += ch;
+} else if (ch == '#') {
+/* end of command, start of checksum*/
+s->state = RS_CHKSUM1;
+} else if (s->line_buf_index >= sizeof(s->line_buf) - 1) {
+#ifdef DEBUG_GDB
+printf("gdbstub command buffer overrun, dropping command\n");
+#endif
+s->state = RS_IDLE;
+} else {
+/* unescaped command character */
+s->line_buf[s->line_buf_index++] = ch;
+s->line_sum += ch;
+}
+break;
+case RS_GETLINE_ESC:
 if (ch == '#') {
-s->state = RS_CHKSUM1;
+/* unexpected end of command in escape sequence */
+s->state = RS_CHKSUM1;
 } else if (s->line_buf_index >= sizeof(s->line_buf) - 1) {
+/* command buffer overrun */
+#ifdef DEBUG_GDB
+printf("gdbstub command buffer overrun, dropping command\n");
+#endif
 s->state = RS_IDLE;
 } else {
-s->line_buf[s->line_buf_index++] = ch;
+/* parse escaped character and leave escape state */
+s->line_buf[s->line_buf_index++] = ch ^ 0x20;
+s->line_sum += ch;
+s->state = RS_GETLINE;
+}
+break;
+case RS_GETLINE_RLE:
+if (ch < ' ') {
+/* invalid RLE count encoding */
+#ifdef DEBUG_GDB
+printf("gdbstub got invalid RLE count: 0x%x\n", ch);
+#endif
+s->state = RS_GETLINE;
+} else {
+/* decode repeat length */
+int repeat = (unsigned char)ch - ' ' + 3;
+if (s->line_buf_index + repeat >= sizeof(s->line_buf) - 1) {
+/* that many repeats would overrun the command buffer */
+#ifdef DEBUG_GDB
+printf("gdbstub command buffer overrun,"
+   " dropping command\n");
+#endif
+s->state = RS_IDLE;
+} else if (s->line_buf_index < 2) {
+/* got a repeat but we have nothing to repeat */
+#ifdef DEBUG_GDB
+printf("gdbstub got invalid RLE sequence\n");
+#endif
+s->state = RS_GETLINE;
+} else {
+/* repeat the last character */
+memset(s->line_buf + s->line_buf_index,
+   

[Qemu-devel] [PATCH v2 1/3] hw/arm/exynos: Move DRAM initialization next boards

2017-05-07 Thread Krzysztof Kozlowski
Before QOM-ifying the Exynos4 SoC model, move the DRAM initialization
from exynos4210.c to exynos4_boards.c because DRAM is board specific,
not SoC.

Signed-off-by: Krzysztof Kozlowski 
Reviewed-by: Philippe Mathieu-Daudé 
---
 hw/arm/exynos4210.c | 20 +-
 hw/arm/exynos4_boards.c | 50 ++---
 include/hw/arm/exynos4210.h |  5 +
 3 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 960f27e45a36..0da877f8db0a 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -160,13 +160,11 @@ static uint64_t exynos4210_calc_affinity(int cpu)
 return mp_affinity;
 }
 
-Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
-unsigned long ram_size)
+Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
 {
 int i, n;
 Exynos4210State *s = g_new(Exynos4210State, 1);
 qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS];
-unsigned long mem_size;
 DeviceState *dev;
 SysBusDevice *busdev;
 ObjectClass *cpu_oc;
@@ -299,22 +297,6 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
 memory_region_add_subregion(system_mem, EXYNOS4210_IRAM_BASE_ADDR,
 >iram_mem);
 
-/* DRAM */
-mem_size = ram_size;
-if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) {
-memory_region_init_ram(>dram1_mem, NULL, "exynos4210.dram1",
-mem_size - EXYNOS4210_DRAM_MAX_SIZE, _fatal);
-vmstate_register_ram_global(>dram1_mem);
-memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR,
->dram1_mem);
-mem_size = EXYNOS4210_DRAM_MAX_SIZE;
-}
-memory_region_init_ram(>dram0_mem, NULL, "exynos4210.dram0", mem_size,
-   _fatal);
-vmstate_register_ram_global(>dram0_mem);
-memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR,
->dram0_mem);
-
/* PMU.
 * The only reason of existence at the moment is that secondary CPU boot
 * loader uses PMU INFORM5 register as a holding pen.
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index 4853c318023c..6240b26839cd 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -22,6 +22,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -56,6 +57,12 @@ typedef enum Exynos4BoardType {
 EXYNOS4_NUM_OF_BOARDS
 } Exynos4BoardType;
 
+typedef struct Exynos4BoardState {
+Exynos4210State *soc;
+MemoryRegion dram0_mem;
+MemoryRegion dram1_mem;
+} Exynos4BoardState;
+
 static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = {
 [EXYNOS4_BOARD_NURI] = 0xD33,
 [EXYNOS4_BOARD_SMDKC210] = 0xB16,
@@ -96,9 +103,34 @@ static void lan9215_init(uint32_t base, qemu_irq irq)
 }
 }
 
-static Exynos4210State *exynos4_boards_init_common(MachineState *machine,
-   Exynos4BoardType board_type)
+static void exynos4_boards_init_ram(Exynos4BoardState *s,
+MemoryRegion *system_mem,
+unsigned long ram_size)
+{
+unsigned long mem_size = ram_size;
+
+if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) {
+memory_region_init_ram(>dram1_mem, NULL, "exynos4210.dram1",
+   mem_size - EXYNOS4210_DRAM_MAX_SIZE,
+   _fatal);
+vmstate_register_ram_global(>dram1_mem);
+memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR,
+>dram1_mem);
+mem_size = EXYNOS4210_DRAM_MAX_SIZE;
+}
+
+memory_region_init_ram(>dram0_mem, NULL, "exynos4210.dram0", mem_size,
+   _fatal);
+vmstate_register_ram_global(>dram0_mem);
+memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR,
+>dram0_mem);
+}
+
+static Exynos4BoardState *
+exynos4_boards_init_common(MachineState *machine,
+   Exynos4BoardType board_type)
 {
+Exynos4BoardState *s = g_new(Exynos4BoardState, 1);
 MachineClass *mc = MACHINE_GET_CLASS(machine);
 
 if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) {
@@ -127,8 +159,12 @@ static Exynos4210State 
*exynos4_boards_init_common(MachineState *machine,
 machine->kernel_cmdline,
 machine->initrd_filename);
 
-return exynos4210_init(get_system_memory(),
-exynos4_board_ram_size[board_type]);
+exynos4_boards_init_ram(s, get_system_memory(),
+exynos4_board_ram_size[board_type]);
+
+s->soc = exynos4210_init(get_system_memory());
+
+return s;
 }
 
 static void nuri_init(MachineState *machine)
@@ -140,11 +176,11 @@ static void nuri_init(MachineState *machine)
 
 static void 

[Qemu-devel] [PATCH v2 2/3] hw/arm/exynos: Declare local variables in some order

2017-05-07 Thread Krzysztof Kozlowski
Bring some more readability by declaring local function variables: first
initialized ones and then the rest (with reversed-christmas-tree order).

Signed-off-by: Krzysztof Kozlowski 
Reviewed-by: Philippe Mathieu-Daudé 
---
 hw/arm/exynos4210.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 0da877f8db0a..27a7bf28a5a9 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -162,12 +162,12 @@ static uint64_t exynos4210_calc_affinity(int cpu)
 
 Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
 {
-int i, n;
 Exynos4210State *s = g_new(Exynos4210State, 1);
 qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS];
-DeviceState *dev;
 SysBusDevice *busdev;
 ObjectClass *cpu_oc;
+DeviceState *dev;
+int i, n;
 
 cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, "cortex-a9");
 assert(cpu_oc);
-- 
2.9.3




[Qemu-devel] [PATCH v2 3/3] hw/arm/exynos: QOM-ify the SoC

2017-05-07 Thread Krzysztof Kozlowski
Convert the Exynos4210 SoC code into a QOM model which is a preferred
approach instead of directly initializing SoC-related devices from the
board file.

Signed-off-by: Krzysztof Kozlowski 
Reviewed-by: Philippe Mathieu-Daudé 
---
 hw/arm/exynos4210.c | 18 +++---
 hw/arm/exynos4_boards.c |  9 ++---
 include/hw/arm/exynos4210.h |  8 ++--
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 27a7bf28a5a9..034fc8be9d76 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -160,9 +160,10 @@ static uint64_t exynos4210_calc_affinity(int cpu)
 return mp_affinity;
 }
 
-Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
+static void exynos4210_init(Object *obj)
 {
-Exynos4210State *s = g_new(Exynos4210State, 1);
+MemoryRegion *system_mem = get_system_memory();
+Exynos4210State *s = EXYNOS4210(obj);
 qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS];
 SysBusDevice *busdev;
 ObjectClass *cpu_oc;
@@ -402,6 +403,17 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
 
 sysbus_create_simple(TYPE_EXYNOS4210_EHCI, EXYNOS4210_EHCI_BASE_ADDR,
 s->irq_table[exynos4210_get_irq(28, 3)]);
+}
+
+static const TypeInfo exynos4210_type_info = {
+.name = TYPE_EXYNOS4210,
+.parent = TYPE_DEVICE,
+.instance_size = sizeof(Exynos4210State),
+.instance_init = exynos4210_init,
+};
 
-return s;
+static void exynos4210_register_types(void)
+{
+type_register_static(_type_info);
 }
+type_init(exynos4210_register_types)
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index 6240b26839cd..5e7c6b562ae2 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -58,7 +58,7 @@ typedef enum Exynos4BoardType {
 } Exynos4BoardType;
 
 typedef struct Exynos4BoardState {
-Exynos4210State *soc;
+Exynos4210State soc;
 MemoryRegion dram0_mem;
 MemoryRegion dram1_mem;
 } Exynos4BoardState;
@@ -162,7 +162,10 @@ exynos4_boards_init_common(MachineState *machine,
 exynos4_boards_init_ram(s, get_system_memory(),
 exynos4_board_ram_size[board_type]);
 
-s->soc = exynos4210_init(get_system_memory());
+object_initialize(>soc, sizeof(s->soc), TYPE_EXYNOS4210);
+object_property_add_child(OBJECT(machine), "soc", OBJECT(>soc),
+  _abort);
+object_property_set_bool(OBJECT(>soc), true, "realized", _fatal);
 
 return s;
 }
@@ -180,7 +183,7 @@ static void smdkc210_init(MachineState *machine)
   EXYNOS4_BOARD_SMDKC210);
 
 lan9215_init(SMDK_LAN9118_BASE_ADDR,
-qemu_irq_invert(s->soc->irq_table[exynos4210_get_irq(37, 1)]));
+qemu_irq_invert(s->soc.irq_table[exynos4210_get_irq(37, 1)]));
 arm_load_kernel(ARM_CPU(first_cpu), _board_binfo);
 }
 
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
index 098a69ec73d3..116eae62756b 100644
--- a/include/hw/arm/exynos4210.h
+++ b/include/hw/arm/exynos4210.h
@@ -29,6 +29,10 @@
 #include "exec/memory.h"
 #include "target/arm/cpu-qom.h"
 
+#define TYPE_EXYNOS4210 "exynos4210"
+#define EXYNOS4210(obj) \
+OBJECT_CHECK(Exynos4210State, (obj), TYPE_EXYNOS4210)
+
 #define EXYNOS4210_NCPUS2
 
 #define EXYNOS4210_DRAM0_BASE_ADDR  0x4000
@@ -85,6 +89,8 @@ typedef struct Exynos4210Irq {
 } Exynos4210Irq;
 
 typedef struct Exynos4210State {
+DeviceState parent_obj;
+
 ARMCPU *cpu[EXYNOS4210_NCPUS];
 Exynos4210Irq irqs;
 qemu_irq *irq_table;
@@ -101,8 +107,6 @@ typedef struct Exynos4210State {
 void exynos4210_write_secondary(ARMCPU *cpu,
 const struct arm_boot_info *info);
 
-Exynos4210State *exynos4210_init(MemoryRegion *system_mem);
-
 /* Initialize exynos4210 IRQ subsystem stub */
 qemu_irq *exynos4210_init_irq(Exynos4210Irq *env);
 
-- 
2.9.3




[Qemu-devel] [PATCH v2 0/3] hw/arm/exynos: QOM-ify the SoC

2017-05-07 Thread Krzysztof Kozlowski
Hi,

Changes since v1:
=
1. s/RAM/DRAM/ in commit msg of first patch (as suggested by Philippe).
2. Add Philippe's reviewed-by.


Convert the Exynos4210 SoC driver into QOM model.

No external dependencies, rebased on v2.9.0-363-g0de9191deb14.

Best regards,
Krzysztof


Krzysztof Kozlowski (3):
  hw/arm/exynos: Move DRAM initialization next boards
  hw/arm/exynos: Declare local variables in some order
  hw/arm/exynos: QOM-ify the SoC

 hw/arm/exynos4210.c | 40 +++---
 hw/arm/exynos4_boards.c | 53 +++--
 include/hw/arm/exynos4210.h | 11 +-
 3 files changed, 69 insertions(+), 35 deletions(-)

-- 
2.9.3




Re: [Qemu-devel] [Qemu-arm] [PATCH 2/3] hw/intc/exynos: Constify array of combiner interrupts

2017-05-07 Thread Philippe Mathieu-Daudé

On 05/07/2017 08:35 AM, Krzysztof Kozlowski wrote:

The static array of interrupt combiner mappings is not modified so it
can be made const for code safeness.

Signed-off-by: Krzysztof Kozlowski 


Reviewed-by: Philippe Mathieu-Daudé 


---
 hw/intc/exynos4210_gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
index 222cfd6c6387..636dc6dbc1f9 100644
--- a/hw/intc/exynos4210_gic.c
+++ b/hw/intc/exynos4210_gic.c
@@ -116,7 +116,7 @@ enum ExtInt {
  * which is INTG16 in Internal Interrupt Combiner.
  */

-static uint32_t
+static const uint32_t
 combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
 /* int combiner groups 16-19 */
 { }, { }, { }, { },





Re: [Qemu-devel] [Qemu-arm] [PATCH 1/3] hw/arm/exynos: Use type define instead of hard-coded a9mpcore_priv string

2017-05-07 Thread Philippe Mathieu-Daudé

On 05/07/2017 08:35 AM, Krzysztof Kozlowski wrote:

Use a define for a9mpcore_priv device type name instead of hard-coded
string.

Signed-off-by: Krzysztof Kozlowski 


Reviewed-by: Philippe Mathieu-Daudé 


---
 hw/arm/exynos4210.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 034fc8be9d76..a9e221c5b7fe 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -26,6 +26,7 @@
 #include "qemu-common.h"
 #include "qemu/log.h"
 #include "cpu.h"
+#include "hw/cpu/a9mpcore.h"
 #include "hw/boards.h"
 #include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
@@ -212,7 +213,7 @@ static void exynos4210_init(Object *obj)
 }

 /* Private memory region and Internal GIC */
-dev = qdev_create(NULL, "a9mpcore_priv");
+dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV);
 qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS);
 qdev_init_nofail(dev);
 busdev = SYS_BUS_DEVICE(dev);





Re: [Qemu-devel] [PATCH] gdbstub: implement remote debugging protocol escapes for command receive

2017-05-07 Thread Doug Gale
[Oops, forgot to reply all, resending...]

Yes, on second thought, <= 2 is off by one. [0] would be the '$', [1]
would be the repeated character, and [2] would be the '*'.

And yes, there is a missing s->state = RS_IDLE there. Good catch. I'll
post updated patch shortly...

On Fri, May 5, 2017 at 10:45 AM, Stefan Hajnoczi  wrote:
> On Tue, May 02, 2017 at 10:32:40AM -0400, Doug Gale wrote:
>> +} else {
>> +/* decode repeat length */
>> +int repeat = (unsigned char)ch - ' ' + 3;
>> +if (s->line_buf_index + repeat >= sizeof(s->line_buf) - 1) {
>> +/* that many repeats would overrun the command buffer */
>> +#ifdef DEBUG_GDB
>> +printf("gdbstub command buffer overrun,"
>> +   " dropping command\n");
>> +#endif
>> +s->state = RS_IDLE;
>> +} else if (s->line_buf_index <= 2) {
>
> Why s->line_buf_index <= 2?  I expected s->line_buf_index < 1 since we
> just need 1 character to clone for run-length decoding.
>
>> +/* got a repeat but we have nothing to repeat */
>> +#ifdef DEBUG_GDB
>> +printf("gdbstub got invalid RLE sequence\n");
>> +#endif
>> +} else {
>
> Missing s->state = RS_IDLE?



[Qemu-devel] boot order=d bug?

2017-05-07 Thread Carl Karsten
In the real world I will have a machine with a sata hd and boot the
installer from a usb stick. I want to test this with 2 disk image files.

The usb stick will be built like so:
https://github.com/CarlFK/video-stack-deploy/blob/usbstick/scripts/mk_usb_installer.sh

but this will demo the problem I have run into with qemu:  how do I boot
from boot.img without using boot=menu?

# make a blank disk to install to
qemu-img create -f qcow2 disk.cow 8G

# get an installer image
wget
http://ftp.debian.org/debian/dists/stretch/main/installer-amd64/current/images/hd-media/boot.img.gz
gunzip boot.img.gz

qemu-system-x86_64 -m 256 -display curses  \
-drive file=disk.cow,index=0 \
-drive file=boot.img,index=1 \
-boot menu=on

# Hit esc and then #2 to boot the installer.

Press ESC for boot menu.
Select boot device:
1. ata0-0: QEMU HARDDISK ATA-7 Hard-Disk (8192 MiBytes)
2. ata0-1: QEMU HARDDISK ATA-7 Hard-Disk (953 MiBytes)
3. Legacy option rom
4. Floppy [drive A]
5. DVD/CD [ata1-0: QEMU DVD-ROM ATAPI-4 DVD/CD]
6. iPXE (PCI 00:03.0)


juser@gator:~/temp/video-stack-deploy/scripts$ qemu-system-x86_64 -version
QEMU emulator version 2.8.1(Debian 1:2.8+dfsg-4+b1)
Copyright (c) 2003-2016 Fabrice Bellard and the QEMU Project developers


-- 
Carl K


[Qemu-devel] 'blank' address space for unknown arm peripherals?

2017-05-07 Thread Marty Plummer
Greetings.

Its my understanding that for creating machine definitions for qemu one
uses what amount to 'drivers' or 'hardware simulations'. I was wondering
if there was what amounted to a blank or raw memory area one could use
as a placeholder for a peripheral which is currently undocumented and
lacking source code for the linux kernel drivers the vendor ships.

My aim is to simulate as much of the hardware as I've managed to
positively identify (mostly primecell stuff) and use the
blank/placeholder address space to observe the interactions between the
blob drivers with the known address space within a simulated environment
to hopefully deduce the hardware registers for the peripherals (mostly
a/v & h264/jpeg stuff).

Any tips and tricks you could provide I would be greatly appreciative.

Marty.



Re: [Qemu-devel] [virtio-dev] virtio-net: configurable TX queue size

2017-05-07 Thread Yan Vugenfirer

> On 5 May 2017, at 12:20, Jason Wang  wrote:
> 
> 
> 
> On 2017年05月05日 13:53, Wei Wang wrote:
>> On 05/05/2017 10:27 AM, Jason Wang wrote:
>>> 
>>> 
>>> On 2017年05月04日 18:58, Wang, Wei W wrote:
 Hi,
 
 I want to re-open the discussion left long time ago:
 https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg06194.html
 , and discuss the possibility of changing the hardcoded (256) TX  queue
 size to be configurable between 256 and 1024.
>>> 
>>> Yes, I think we probably need this.
>> 
>> That's great, thanks.
>> 
>>> 
 
 The reason to propose this request is that a severe issue of packet drops 
 in
 TX direction was observed with the existing hardcoded 256 queue size,
 which causes performance issues for packet drop sensitive guest
 applications that cannot use indirect descriptor tables. The issue goes 
 away
 with 1K queue size.
>>> 
>>> Do we need even more, what if we find 1K is even not sufficient in the 
>>> future? Modern nics has size up to ~8192.
>> 
>> Yes. Probably, we can also set the RX queue size to 8192 (currently it's 1K) 
>> as well.
>> 
>>> 
 
 The concern mentioned in the previous discussion (please check the link
 above) is that the number of chained descriptors would exceed
 UIO_MAXIOV (1024) supported by the Linux.
>>> 
>>> We could try to address this limitation but probably need a new feature bit 
>>> to allow more than UIO_MAXIOV sgs.
>> 
>> I think we should first discuss whether it would be an issue below.
>> 
>>> 
 
 From the code,  I think the number of the chained descriptors is limited to
 MAX_SKB_FRAGS + 2 (~18), which is much less than UIO_MAXIOV.
>>> 
>>> This is the limitation of #page frags for skb, not the iov limitation.
>> 
>> I think the number of page frags are filled into the same number of 
>> descriptors
>> in the virtio-net driver (e.g. use 10 descriptors for 10 page frags). On the 
>> other
>> side, the virtio-net backend uses the same number of iov for the descriptors.
>> 
>> Since the number of page frags is limited to 18, I think there wouldn't be 
>> more
>> than 18 iovs to be passed to writev, right?
> 
This limitation assumption is incorrect for Windows. We saw cases (and 
strangely enough with small packets) when Windows returns scatter gather list 
with 32 descriptors or more.

Best regards,
Yan.

> Looks not, see skb_copy_datagram_from_iter().

> 
> Thanks
> 
>> 
>> Best,
>> Wei
>> 
>> -
>> To unsubscribe, e-mail: virtio-dev-unsubscr...@lists.oasis-open.org 
>> 
>> For additional commands, e-mail: virtio-dev-h...@lists.oasis-open.org 
>> 
>> 
> 
> 
> -
> To unsubscribe, e-mail: virtio-dev-unsubscr...@lists.oasis-open.org 
> 
> For additional commands, e-mail: virtio-dev-h...@lists.oasis-open.org 
> 


[Qemu-devel] [PATCH 0/3] hw/arm/exynos: Fix poweroff

2017-05-07 Thread Krzysztof Kozlowski
Hi,

Beside two minor cleanups, the patchset implements proper Exynos power off.
Still the GIC [1] fix is needed because the kernel will not reach power off
handlers without it.

[1] http://patchwork.ozlabs.org/patch/738320/

Best regards,
Krzysztof


Krzysztof Kozlowski (3):
  hw/arm/exynos: Use type define instead of hard-coded a9mpcore_priv
string
  hw/intc/exynos: Constify array of combiner interrupts
  hw/arm/exynos: Add support for system poweroff

 hw/arm/exynos4210.c  |  3 ++-
 hw/intc/exynos4210_gic.c |  2 +-
 hw/misc/exynos4210_pmu.c | 14 ++
 3 files changed, 17 insertions(+), 2 deletions(-)

-- 
2.9.3




[Qemu-devel] [PATCH 1/3] hw/arm/exynos: Use type define instead of hard-coded a9mpcore_priv string

2017-05-07 Thread Krzysztof Kozlowski
Use a define for a9mpcore_priv device type name instead of hard-coded
string.

Signed-off-by: Krzysztof Kozlowski 
---
 hw/arm/exynos4210.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 034fc8be9d76..a9e221c5b7fe 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -26,6 +26,7 @@
 #include "qemu-common.h"
 #include "qemu/log.h"
 #include "cpu.h"
+#include "hw/cpu/a9mpcore.h"
 #include "hw/boards.h"
 #include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
@@ -212,7 +213,7 @@ static void exynos4210_init(Object *obj)
 }
 
 /* Private memory region and Internal GIC */
-dev = qdev_create(NULL, "a9mpcore_priv");
+dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV);
 qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS);
 qdev_init_nofail(dev);
 busdev = SYS_BUS_DEVICE(dev);
-- 
2.9.3




[Qemu-devel] [PATCH 2/3] hw/intc/exynos: Constify array of combiner interrupts

2017-05-07 Thread Krzysztof Kozlowski
The static array of interrupt combiner mappings is not modified so it
can be made const for code safeness.

Signed-off-by: Krzysztof Kozlowski 
---
 hw/intc/exynos4210_gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
index 222cfd6c6387..636dc6dbc1f9 100644
--- a/hw/intc/exynos4210_gic.c
+++ b/hw/intc/exynos4210_gic.c
@@ -116,7 +116,7 @@ enum ExtInt {
  * which is INTG16 in Internal Interrupt Combiner.
  */
 
-static uint32_t
+static const uint32_t
 combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = {
 /* int combiner groups 16-19 */
 { }, { }, { }, { },
-- 
2.9.3




[Qemu-devel] [PATCH 3/3] hw/arm/exynos: Add support for system poweroff

2017-05-07 Thread Krzysztof Kozlowski
On all Exynos-based boards, the system powers down itself by driving
PS_HOLD signal low.  Handle writing to respective PMU register to fix
power off failure:

reboot: Power down
Unable to poweroff system
shutdown: 31 output lines suppressed due to ratelimiting
Kernel panic - not syncing: Attempted to kill init! exitcode=0x

CPU: 0 PID: 1 Comm: shutdown Not tainted 4.11.0-rc8 #846
Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[] (unwind_backtrace) from [] (show_stack+0x10/0x14)
[] (show_stack) from [] (dump_stack+0x88/0x9c)
[] (dump_stack) from [] (panic+0xdc/0x268)
[] (panic) from [] (do_exit+0xa90/0xab4)
[] (do_exit) from [] (SyS_reboot+0x164/0x1d0)
[] (SyS_reboot) from [] (ret_fast_syscall+0x0/0x3c)

Signed-off-by: Krzysztof Kozlowski 
---
 hw/misc/exynos4210_pmu.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/hw/misc/exynos4210_pmu.c b/hw/misc/exynos4210_pmu.c
index 63a8ccd35559..2046e6313f10 100644
--- a/hw/misc/exynos4210_pmu.c
+++ b/hw/misc/exynos4210_pmu.c
@@ -26,6 +26,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/sysbus.h"
+#include "sysemu/sysemu.h"
 
 #ifndef DEBUG_PMU
 #define DEBUG_PMU   0
@@ -397,6 +398,12 @@ typedef struct Exynos4210PmuState {
 uint32_t reg[PMU_NUM_OF_REGISTERS];
 } Exynos4210PmuState;
 
+static void exynos4210_pmu_poweroff(void)
+{
+PRINT_DEBUG("QEMU PMU: PS_HOLD bit down, powering off\n");
+qemu_system_shutdown_request();
+}
+
 static uint64_t exynos4210_pmu_read(void *opaque, hwaddr offset,
 unsigned size)
 {
@@ -428,6 +435,13 @@ static void exynos4210_pmu_write(void *opaque, hwaddr 
offset,
 PRINT_DEBUG_EXTEND("%s <0x%04x> <- 0x%04x\n", reg_p->name,
 (uint32_t)offset, (uint32_t)val);
 s->reg[i] = val;
+if ((offset == PS_HOLD_CONTROL) && ((val & BIT(8)) == 0)) {
+/*
+ * We are interested only in setting data bit
+ * of PS_HOLD_CONTROL register to indicate power off request.
+ */
+exynos4210_pmu_poweroff();
+}
 return;
 }
 reg_p++;
-- 
2.9.3




Re: [Qemu-devel] [Qemu-arm] [PATCH v2 1/5] hw/intc/exynos4210_gic: Fix GIC memory mappings for secondary CPU

2017-05-07 Thread Krzysztof Kozlowski
On Mon, Mar 13, 2017 at 04:32:40PM -0300, Philippe Mathieu-Daudé wrote:
> On 03/13/2017 03:04 PM, Krzysztof Kozlowski wrote:
> > Recent Linux kernel (tested next-20170224) was complaining about missing
> > GIC mask and was unable to bring up secondary CPU:
> > 
> > [0.00] NR_IRQS:16 nr_irqs:16 16
> > [0.00] GIC CPU mask not found - kernel will fail to boot.
> > ...
> > [0.400492] smp: Bringing up secondary CPUs ...
> > [1.413184] CPU1: failed to boot: -110
> > [1.423981] smp: Brought up 1 node, 1 CPU
> > 
> > In its instance_init() call, the Exynos GIC driver was setting GIC
> > memory mappings for each CPU, from 1 up to "num-cpu" property.  The
> > Exynos4210 machine init call on the other hand, first created Exynos GIC
> > device and then set the "num-cpu" property which was too late.  The init
> > already happened with default "num-cpu" value of 1 thus GIC mappings
> > were created only for the first CPU.
> > 
> > Split the Exynos GIC init code into realize function so the code will
> > see updated "num-cpu" property.  This fixes the warning and brings
> > second CPU:
> > [0.435780] CPU1: thread -1, cpu 1, socket 9, mpidr 8901
> > [0.451838] smp: Brought up 1 node, 2 CPUs
> > 
> > Signed-off-by: Krzysztof Kozlowski 
> > Reviewed-by: Peter Maydell 
> 
> Reviewed-by: Philippe Mathieu-Daudé 

Beside bringing secondary CPU, this patch fixes also Software Generated
Interrupts. Without it, none of the SGIs are coming (except CPU wakeup):
  IPI0:       6281  CPU wakeup interrupts
  IPI1:          0  Timer broadcast interrupts
  IPI2:          0  Rescheduling interrupts
  IPI3:          0  Function call interrupts
  IPI4:          0  CPU stop interrupts
  IPI5:          0  IRQ work interrupts
  IPI6:          0  completion interrupts

This is pretty annoying because lack of SGIs means lack of IPIs thus for
example IRQ work cannot be executed. Without IRQ work, the kernel hangs
on power down on cpufreq shutdown because in cpufreq_dbs_governor_stop()
there is irq_work_sync() but none of irq_work interrupts were handled.

I still did not solve the issue with cpuidle (AFTR). I am trying to
implement CPU power off (needed for AFTR) but it is one-way so far (no
wakeup). Anyway the workaround is to just disable cpuidle.

Overall, what is the status of this patch? Should I resend? I can also
extend the commit description with paragraph about SGI/IPI.

Best regards,
Krzysztof




Re: [Qemu-devel] [PULL 00/23] Trivial patches for 2017-05-07

2017-05-07 Thread no-reply
Hi,

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

Message-id: cover.1494140527.git@msgid.tls.msk.ru
Subject: [Qemu-devel] [PULL 00/23] Trivial patches for 2017-05-07
Type: series

=== 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
Switched to a new branch 'test'
8acf5d3 tests: Remove redundant assignment
0f494a6 MAINTAINERS: Update paths for AioContext implementation
9974be0 MAINTAINERS: Update paths for main loop
3e8c3af jazz_led: fix bad snprintf
8f753b9 tests: Ignore another built executable (test-hmp)
7d5489d scripts: Switch to more portable Perl shebang
536d031 scripts/qemu-binfmt-conf.sh: Fix shell portability issue
a3e0b2b virtfs: allow a device id to be specified in the -virtfs option
3227c55 hw/core/generic-loader: Fix crash when running without CPU
22bf6ca virtio-blk: Remove useless condition around g_free()
65fe06c qemu-doc: Fix broken URLs of amnhltm.zip and dosidle210.zip
1f55ac0 use _Static_assert in QEMU_BUILD_BUG_ON
58005fb channel-file: fix wrong parameter comments
9029b8b block: Make 'replication_state' an enum
d5f07f0 util: Use g_malloc/g_free in envlist.c
e1d8273 qga: fix compiler warnings (clang 5)
077a79e device_tree: fix compiler warnings (clang 5)
965b305 usb-ccid: make ccid_write_data_block() cope with null buffers
3b19d93 tests: Ignore more test executables
296cc0d Add 'none' as type for drive's if option
708674a doc: fix function spelling
afcc583 ppc_booke: drop useless assignment
8b94589 Remove reduntant qemu: from error functions

=== OUTPUT BEGIN ===
Checking PATCH 1/23: Remove reduntant qemu: from error functions...
Checking PATCH 2/23: ppc_booke: drop useless assignment...
Checking PATCH 3/23: doc: fix function spelling...
Checking PATCH 4/23: Add 'none' as type for drive's if option...
Checking PATCH 5/23: tests: Ignore more test executables...
Checking PATCH 6/23: usb-ccid: make ccid_write_data_block() cope with null 
buffers...
Checking PATCH 7/23: device_tree: fix compiler warnings (clang 5)...
Checking PATCH 8/23: qga: fix compiler warnings (clang 5)...
Checking PATCH 9/23: util: Use g_malloc/g_free in envlist.c...
ERROR: code indent should never use tabs
#116: FILE: util/envlist.c:27:
+^Ienvlist = g_malloc(sizeof(*envlist));$

ERROR: code indent should never use tabs
#126: FILE: util/envlist.c:49:
+^I^Ig_free((char *)entry->ev_var);$

ERROR: code indent should never use tabs
#127: FILE: util/envlist.c:50:
+^I^Ig_free(entry);$

ERROR: code indent should never use tabs
#130: FILE: util/envlist.c:52:
+^Ig_free(envlist);$

ERROR: code indent should never use tabs
#140: FILE: util/envlist.c:102:
+^Itmpenv = g_strdup(env);$

ERROR: code indent should never use tabs
#159: FILE: util/envlist.c:155:
+^I^Ig_free((char *)entry->ev_var);$

ERROR: code indent should never use tabs
#160: FILE: util/envlist.c:156:
+^I^Ig_free(entry);$

ERROR: code indent should never use tabs
#171: FILE: util/envlist.c:161:
+^Ientry = g_malloc(sizeof(*entry));$

ERROR: code indent should never use tabs
#172: FILE: util/envlist.c:162:
+^Ientry->ev_var = g_strdup(env);$

ERROR: code indent should never use tabs
#182: FILE: util/envlist.c:197:
+^I^Ig_free((char *)entry->ev_var);$

ERROR: code indent should never use tabs
#183: FILE: util/envlist.c:198:
+^I^Ig_free(entry);$

ERROR: code indent should never use tabs
#211: FILE: util/envlist.c:221:
+^Ipenv = env = g_malloc((envlist->el_count + 1) * sizeof(char *));$

ERROR: code indent should never use tabs
#216: FILE: util/envlist.c:225:
+^I^I*(penv++) = g_strdup(entry->ev_var);$

total: 13 errors, 0 warnings, 168 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 10/23: block: Make 'replication_state' an enum...
Checking PATCH 11/23: channel-file: fix wrong parameter comments...
Checking PATCH 12/23: use _Static_assert in QEMU_BUILD_BUG_ON...
Checking PATCH 13/23: qemu-doc: Fix broken URLs of amnhltm.zip and 
dosidle210.zip...
Checking PATCH 14/23: virtio-blk: Remove useless condition around g_free()...
Checking PATCH 15/23: hw/core/generic-loader: Fix crash when running without 
CPU...
Checking PATCH 16/23: virtfs: allow a device id to be specified in the -virtfs 
option...
Checking PATCH 17/23: scripts/qemu-binfmt-conf.sh: Fix shell portability 
issue...
Checking PATCH 18/23: scripts: Switch to more portable Perl shebang...
Checking PATCH 19/23: tests: Ignore another built 

[Qemu-devel] [PULL 16/23] virtfs: allow a device id to be specified in the -virtfs option

2017-05-07 Thread Michael Tokarev
From: Chris Webb 

When using a virtfs root filesystem, the mount_tag needs to be set to
/dev/root. This can be done long-hand as

  -fsdev local,id=root,path=/path/to/rootfs,...
  -device virtio-9p-pci,fsdev=root,mount_tag=/dev/root

but the -virtfs shortcut cannot be used as it hard-codes the device identifier
to match the mount_tag, and device identifiers may not contain '/':

  $ qemu-system-x86_64 -virtfs 
local,path=/foo,mount_tag=/dev/root,security_model=passthrough
  qemu-system-x86_64: -virtfs 
local,path=/foo,mount_tag=/dev/root,security_model=passthrough: duplicate fsdev 
id: /dev/root

To support this case using -virtfs, we allow the device identifier to be
specified explicitly when the mount_tag is not suitable:

  -virtfs local,id=root,path=/path/to/rootfs,mount_tag=/dev/root,...

Signed-off-by: Chris Webb 
Signed-off-by: Michael Tokarev 
---
 qemu-options.hx | 2 +-
 vl.c| 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index a24fef2107..a5b0589cb7 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -876,7 +876,7 @@ ETEXI
 
 DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
 "-virtfs 
local,path=path,mount_tag=tag,security_model=[mapped-xattr|mapped-file|passthrough|none]\n"
-"
[,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd]\n",
+"
[,id=id][,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd]\n",
 QEMU_ARCH_ALL)
 
 STEXI
diff --git a/vl.c b/vl.c
index 42d4bce439..10f3afd860 100644
--- a/vl.c
+++ b/vl.c
@@ -3524,10 +3524,11 @@ int main(int argc, char **argv, char **envp)
 exit(1);
 }
 fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
+ qemu_opts_id(opts) ?:
  qemu_opt_get(opts, "mount_tag"),
  1, NULL);
 if (!fsdev) {
-error_report("duplicate fsdev id: %s",
+error_report("duplicate or invalid fsdev id: %s",
  qemu_opt_get(opts, "mount_tag"));
 exit(1);
 }
@@ -3565,7 +3566,7 @@ int main(int argc, char **argv, char **envp)
   _abort);
 qemu_opt_set(device, "driver", "virtio-9p-pci", _abort);
 qemu_opt_set(device, "fsdev",
- qemu_opt_get(opts, "mount_tag"), _abort);
+ qemu_opts_id(fsdev), _abort);
 qemu_opt_set(device, "mount_tag",
  qemu_opt_get(opts, "mount_tag"), _abort);
 break;
-- 
2.11.0




[Qemu-devel] [PULL 03/23] doc: fix function spelling

2017-05-07 Thread Michael Tokarev
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Stefan Hajnoczi 
Signed-off-by: Michael Tokarev 
---
 include/io/channel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/io/channel.h b/include/io/channel.h
index 5d48906998..db9bb022a1 100644
--- a/include/io/channel.h
+++ b/include/io/channel.h
@@ -315,7 +315,7 @@ ssize_t qio_channel_read(QIOChannel *ioc,
  Error **errp);
 
 /**
- * qio_channel_writev:
+ * qio_channel_write:
  * @ioc: the channel object
  * @buf: the memory regions to send data from
  * @buflen: the length of @buf
-- 
2.11.0




[Qemu-devel] [PULL 05/23] tests: Ignore more test executables

2017-05-07 Thread Michael Tokarev
From: Eric Blake 

Ignore test executables when building in-tree:
test-arm-mptimer introduced in commit 882fac3
test-crypto-hmac introduced in commit 4fd460b
test-aio-multithread introduced in commit 0c330a7

Signed-off-by: Eric Blake 
Reviewed-by: Laurent Vivier 
Signed-off-by: Michael Tokarev 
---
 tests/.gitignore | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index a966740c2c..5ab00a9c95 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -11,6 +11,8 @@ check-qom-proplist
 qht-bench
 rcutorture
 test-aio
+test-aio-multithread
+test-arm-mptimer
 test-base64
 test-bitops
 test-bitcnt
@@ -24,6 +26,7 @@ test-crypto-afsplit
 test-crypto-block
 test-crypto-cipher
 test-crypto-hash
+test-crypto-hmac
 test-crypto-ivgen
 test-crypto-pbkdf
 test-crypto-secret
-- 
2.11.0




[Qemu-devel] [PULL 20/23] jazz_led: fix bad snprintf

2017-05-07 Thread Michael Tokarev
From: Paolo Bonzini 

Detected by GCC 7's -Wformat-truncation.  snprintf writes at most
2 bytes here including the terminating NUL, so the result is
truncated.  In addition, the newline at the end is pointless.
Fix the buffer size and the format string.

Signed-off-by: Paolo Bonzini 
Reviewed-by: Markus Armbruster 
Reviewed-by: Laurent Vivier 
Signed-off-by: Michael Tokarev 
---
 hw/display/jazz_led.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c
index b72fdb1717..3c97d56434 100644
--- a/hw/display/jazz_led.c
+++ b/hw/display/jazz_led.c
@@ -227,13 +227,13 @@ static void jazz_led_invalidate_display(void *opaque)
 static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
 {
 LedState *s = opaque;
-char buf[2];
+char buf[3];
 
 dpy_text_cursor(s->con, -1, -1);
 qemu_console_resize(s->con, 2, 1);
 
 /* TODO: draw the segments */
-snprintf(buf, 2, "%02hhx\n", s->segments);
+snprintf(buf, 3, "%02hhx", s->segments);
 console_write_ch(chardata++, ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE,
  QEMU_COLOR_BLACK, 1));
 console_write_ch(chardata++, ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE,
-- 
2.11.0




[Qemu-devel] [PULL 17/23] scripts/qemu-binfmt-conf.sh: Fix shell portability issue

2017-05-07 Thread Michael Tokarev
From: Kamil Rytarowski 

Appease pkgsrc and use portable shell variable comparison.
This switches "==" to "=". It should not be a functional change.

Signed-off-by: Kamil Rytarowski 
Reviewed-by: Peter Maydell 
Reviewed-by: Laurent Vivier 
Signed-off-by: Michael Tokarev 
---
 scripts/qemu-binfmt-conf.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index 0f1aa63872..8afc3eb5bb 100755
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -284,12 +284,12 @@ while true ; do
 shift
 # check given cpu is in the supported CPU list
 for cpu in ${qemu_target_list} ; do
-if [ "$cpu" == "$1" ] ; then
+if [ "$cpu" = "$1" ] ; then
 break
 fi
 done
 
-if [ "$cpu" == "$1" ] ; then
+if [ "$cpu" = "$1" ] ; then
 qemu_target_list="$1"
 else
 echo "ERROR: unknown CPU \"$1\"" 1>&2
-- 
2.11.0




[Qemu-devel] [PULL 21/23] MAINTAINERS: Update paths for main loop

2017-05-07 Thread Michael Tokarev
From: Paolo Bonzini 

Moved by c2b38b2 ("block: move AioContext, QEMUTimer, main-loop to
libqemuutil"), let's update MAINTAINERS too.

Reported-by: Laurent Vivier 
Signed-off-by: Paolo Bonzini 
Reviewed-by: Alex Bennée 
Signed-off-by: Michael Tokarev 
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index a1d2b3a4d3..e6822b23bf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1305,8 +1305,8 @@ Main loop
 M: Paolo Bonzini 
 S: Maintained
 F: cpus.c
-F: main-loop.c
-F: qemu-timer.c
+F: util/main-loop.c
+F: util/qemu-timer.c
 F: vl.c
 
 Human Monitor (HMP)
-- 
2.11.0




[Qemu-devel] [PULL 18/23] scripts: Switch to more portable Perl shebang

2017-05-07 Thread Michael Tokarev
From: Kamil Rytarowski 

The default NetBSD package manager is pkgsrc and it installs Perl
along other third party programs under custom and configurable prefix.
The default prefix for binary prebuilt packages is /usr/pkg, and the
Perl executable lands in /usr/pkg/bin/perl.

This change switches "/usr/bin/perl" to "/usr/bin/env perl" as it's
the most portable solution that should work for almost everybody.
Perl's executable is detected automatically.

This change switches -w option passed to the executable with more
modern "use warnings;" approach. There is no functional change to the
default behavior.

Signed-off-by: Kamil Rytarowski 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Michael Tokarev 
---
 scripts/checkpatch.pl   | 3 ++-
 scripts/clean-header-guards.pl  | 3 ++-
 scripts/cleanup-trace-events.pl | 2 +-
 scripts/disas-objdump.pl| 4 +++-
 scripts/get_maintainer.pl   | 3 ++-
 scripts/shaderinclude.pl| 2 +-
 scripts/switch-timer-api| 2 +-
 scripts/texi2pod.pl | 4 +++-
 8 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f084542934..3bb6fc95bd 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # (c) 2001, Dave Jones. (the file handling bit)
 # (c) 2005, Joel Schopp  (the ugly bit)
 # (c) 2007,2008, Andy Whitcroft  (new conditions, test suite)
@@ -6,6 +6,7 @@
 # Licensed under the terms of the GNU GPL License version 2
 
 use strict;
+use warnings;
 
 my $P = $0;
 $P =~ s@.*/@@g;
diff --git a/scripts/clean-header-guards.pl b/scripts/clean-header-guards.pl
index 54ab99ae29..5e67f1998c 100755
--- a/scripts/clean-header-guards.pl
+++ b/scripts/clean-header-guards.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Clean up include guards in headers
 #
@@ -28,6 +28,7 @@
 #   "cc -E -DGUARD_H -c -P -", and fed the test program on stdin.
 
 use strict;
+use warnings;
 use Getopt::Std;
 
 # Stuff we don't want to clean because we import it into our tree:
diff --git a/scripts/cleanup-trace-events.pl b/scripts/cleanup-trace-events.pl
index 7e808efb6a..e93abc00da 100755
--- a/scripts/cleanup-trace-events.pl
+++ b/scripts/cleanup-trace-events.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2013 Red Hat, Inc.
 #
 # Authors:
diff --git a/scripts/disas-objdump.pl b/scripts/disas-objdump.pl
index 8f7e8182a1..bec905f04b 100755
--- a/scripts/disas-objdump.pl
+++ b/scripts/disas-objdump.pl
@@ -1,4 +1,6 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
+
+use warnings;
 
 use File::Temp qw/ tempfile /;
 use Getopt::Long;
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 8261bcb1ad..d7c2311123 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # (c) 2007, Joe Perches 
 #   created from checkpatch.pl
 #
@@ -11,6 +11,7 @@
 # Licensed under the terms of the GNU GPL License version 2
 
 use strict;
+use warnings;
 
 my $P = $0;
 my $V = '0.26';
diff --git a/scripts/shaderinclude.pl b/scripts/shaderinclude.pl
index 81b5146332..cd3bb40b12 100644
--- a/scripts/shaderinclude.pl
+++ b/scripts/shaderinclude.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 use strict;
 use warnings;
 
diff --git a/scripts/switch-timer-api b/scripts/switch-timer-api
index b0e230b9f1..41736d11dd 100755
--- a/scripts/switch-timer-api
+++ b/scripts/switch-timer-api
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
diff --git a/scripts/texi2pod.pl b/scripts/texi2pod.pl
index 6e8fec41a1..39ce584a32 100755
--- a/scripts/texi2pod.pl
+++ b/scripts/texi2pod.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/env perl
 
 #   Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
 
@@ -22,6 +22,8 @@
 # markup to Perl POD format.  It's intended to be used to extract
 # something suitable for a manpage from a Texinfo document.
 
+use warnings;
+
 $output = 0;
 $skipping = 0;
 %sects = ();
-- 
2.11.0




[Qemu-devel] [PULL 07/23] device_tree: fix compiler warnings (clang 5)

2017-05-07 Thread Michael Tokarev
From: Philippe Mathieu-Daudé 

static code analyzer complain:

device_tree.c:155:18: warning: Null pointer passed as an argument to a 
'nonnull' parameter
while ((de = readdir(d)) != NULL) {
 ^~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Marc-André Lureau 
Signed-off-by: Michael Tokarev 
---
 device_tree.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/device_tree.c b/device_tree.c
index 6e06320830..a24ddff02b 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -148,6 +148,7 @@ static void read_fstree(void *fdt, const char *dirname)
 d = opendir(dirname);
 if (!d) {
 error_setg(_fatal, "%s cannot open %s", __func__, dirname);
+return;
 }
 
 while ((de = readdir(d)) != NULL) {
-- 
2.11.0




[Qemu-devel] [PULL 02/23] ppc_booke: drop useless assignment

2017-05-07 Thread Michael Tokarev
From: KONRAD Frederic 

The tb_env variable is set two lines above. So just drop the double assignment.

Signed-off-by: KONRAD Frederic 
Reviewed-by: Laurent Vivier 
Signed-off-by: Michael Tokarev 
---
 hw/ppc/ppc_booke.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/ppc/ppc_booke.c b/hw/ppc/ppc_booke.c
index 60baffaf1d..23bcf1b138 100644
--- a/hw/ppc/ppc_booke.c
+++ b/hw/ppc/ppc_booke.c
@@ -282,7 +282,6 @@ void store_booke_tcr(CPUPPCState *env, target_ulong val)
 ppc_tb_t *tb_env = env->tb_env;
 booke_timer_t *booke_timer = tb_env->opaque;
 
-tb_env = env->tb_env;
 env->spr[SPR_BOOKE_TCR] = val;
 kvmppc_set_tcr(cpu);
 
-- 
2.11.0




[Qemu-devel] [PULL 10/23] block: Make 'replication_state' an enum

2017-05-07 Thread Michael Tokarev
From: Fam Zheng 

BDRVReplicationState.replication_state is a name with a bit of
duplication, plus it could be an enum like BDRVReplicationState.mode,
which is more readable and also more straightforward in a debugger.

Rename it, and improve the type while at it.

Signed-off-by: Fam Zheng 
Reviewed-by: Eric Blake 
Signed-off-by: Michael Tokarev 
---
 block/replication.c | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/block/replication.c b/block/replication.c
index d300c15475..3885f04c31 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -22,9 +22,17 @@
 #include "qapi/error.h"
 #include "replication.h"
 
+typedef enum {
+BLOCK_REPLICATION_NONE, /* block replication is not started */
+BLOCK_REPLICATION_RUNNING,  /* block replication is running */
+BLOCK_REPLICATION_FAILOVER, /* failover is running in background */
+BLOCK_REPLICATION_FAILOVER_FAILED,  /* failover failed */
+BLOCK_REPLICATION_DONE, /* block replication is done */
+} ReplicationStage;
+
 typedef struct BDRVReplicationState {
 ReplicationMode mode;
-int replication_state;
+ReplicationStage stage;
 BdrvChild *active_disk;
 BdrvChild *hidden_disk;
 BdrvChild *secondary_disk;
@@ -36,14 +44,6 @@ typedef struct BDRVReplicationState {
 int error;
 } BDRVReplicationState;
 
-enum {
-BLOCK_REPLICATION_NONE, /* block replication is not started */
-BLOCK_REPLICATION_RUNNING,  /* block replication is running */
-BLOCK_REPLICATION_FAILOVER, /* failover is running in background */
-BLOCK_REPLICATION_FAILOVER_FAILED,  /* failover failed */
-BLOCK_REPLICATION_DONE, /* block replication is done */
-};
-
 static void replication_start(ReplicationState *rs, ReplicationMode mode,
   Error **errp);
 static void replication_do_checkpoint(ReplicationState *rs, Error **errp);
@@ -141,10 +141,10 @@ static void replication_close(BlockDriverState *bs)
 {
 BDRVReplicationState *s = bs->opaque;
 
-if (s->replication_state == BLOCK_REPLICATION_RUNNING) {
+if (s->stage == BLOCK_REPLICATION_RUNNING) {
 replication_stop(s->rs, false, NULL);
 }
-if (s->replication_state == BLOCK_REPLICATION_FAILOVER) {
+if (s->stage == BLOCK_REPLICATION_FAILOVER) {
 block_job_cancel_sync(s->active_disk->bs->job);
 }
 
@@ -174,7 +174,7 @@ static int64_t replication_getlength(BlockDriverState *bs)
 
 static int replication_get_io_status(BDRVReplicationState *s)
 {
-switch (s->replication_state) {
+switch (s->stage) {
 case BLOCK_REPLICATION_NONE:
 return -EIO;
 case BLOCK_REPLICATION_RUNNING:
@@ -403,7 +403,7 @@ static void backup_job_completed(void *opaque, int ret)
 BlockDriverState *bs = opaque;
 BDRVReplicationState *s = bs->opaque;
 
-if (s->replication_state != BLOCK_REPLICATION_FAILOVER) {
+if (s->stage != BLOCK_REPLICATION_FAILOVER) {
 /* The backup job is cancelled unexpectedly */
 s->error = -EIO;
 }
@@ -445,7 +445,7 @@ static void replication_start(ReplicationState *rs, 
ReplicationMode mode,
 aio_context_acquire(aio_context);
 s = bs->opaque;
 
-if (s->replication_state != BLOCK_REPLICATION_NONE) {
+if (s->stage != BLOCK_REPLICATION_NONE) {
 error_setg(errp, "Block replication is running or done");
 aio_context_release(aio_context);
 return;
@@ -545,7 +545,7 @@ static void replication_start(ReplicationState *rs, 
ReplicationMode mode,
 abort();
 }
 
-s->replication_state = BLOCK_REPLICATION_RUNNING;
+s->stage = BLOCK_REPLICATION_RUNNING;
 
 if (s->mode == REPLICATION_MODE_SECONDARY) {
 secondary_do_checkpoint(s, errp);
@@ -581,7 +581,7 @@ static void replication_get_error(ReplicationState *rs, 
Error **errp)
 aio_context_acquire(aio_context);
 s = bs->opaque;
 
-if (s->replication_state != BLOCK_REPLICATION_RUNNING) {
+if (s->stage != BLOCK_REPLICATION_RUNNING) {
 error_setg(errp, "Block replication is not running");
 aio_context_release(aio_context);
 return;
@@ -601,7 +601,7 @@ static void replication_done(void *opaque, int ret)
 BDRVReplicationState *s = bs->opaque;
 
 if (ret == 0) {
-s->replication_state = BLOCK_REPLICATION_DONE;
+s->stage = BLOCK_REPLICATION_DONE;
 
 /* refresh top bs's filename */
 bdrv_refresh_filename(bs);
@@ -610,7 +610,7 @@ static void replication_done(void *opaque, int ret)
 s->hidden_disk = NULL;
 s->error = 0;
 } else {
-s->replication_state = BLOCK_REPLICATION_FAILOVER_FAILED;
+s->stage = BLOCK_REPLICATION_FAILOVER_FAILED;
 s->error = -EIO;
 }
 }
@@ -625,7 +625,7 @@ static void replication_stop(ReplicationState *rs, bool 
failover, 

[Qemu-devel] [PULL 04/23] Add 'none' as type for drive's if option

2017-05-07 Thread Michael Tokarev
From: Craig Jellick 

Signed-off-by: Craig Jellick 
Reviewed-by: Stefan Hajnoczi 
Signed-off-by: Michael Tokarev 
---
 qemu-options.hx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index f68829f3b0..a24fef2107 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -604,7 +604,7 @@ Special files such as iSCSI devices can be specified using 
protocol
 specific URLs. See the section for "Device URL Syntax" for more information.
 @item if=@var{interface}
 This option defines on which type on interface the drive is connected.
-Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
+Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio, none.
 @item bus=@var{bus},unit=@var{unit}
 These options define where is connected the drive by defining the bus number 
and
 the unit id.
-- 
2.11.0




[Qemu-devel] [PULL 22/23] MAINTAINERS: Update paths for AioContext implementation

2017-05-07 Thread Michael Tokarev
From: Paolo Bonzini 

Moved by c2b38b2
("block: move AioContext, QEMUTimer, main-loop to libqemuutil")

Signed-off-by: Paolo Bonzini 
Reviewed-by: Laurent Vivier 
Signed-off-by: Michael Tokarev 
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e6822b23bf..e79ffb3f8a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1175,8 +1175,8 @@ M: Stefan Hajnoczi 
 M: Fam Zheng 
 L: qemu-bl...@nongnu.org
 S: Supported
-F: async.c
-F: aio-*.c
+F: util/async.c
+F: util/aio-*.c
 F: block/io.c
 F: migration/block*
 F: include/block/aio.h
-- 
2.11.0




[Qemu-devel] [PULL 06/23] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-05-07 Thread Michael Tokarev
From: Philippe Mathieu-Daudé 

static code analyzer complain:

hw/usb/dev-smartcard-reader.c:816:5: warning: Null pointer passed as an 
argument to a 'nonnull' parameter
memcpy(p->abData, data, len);
^~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé 
Signed-off-by: Michael Tokarev 
---
 hw/usb/dev-smartcard-reader.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 757b8b3f5a..49cb1829b5 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -813,7 +813,10 @@ static void ccid_write_data_block(USBCCIDState *s, uint8_t 
slot, uint8_t seq,
 if (p->b.bError) {
 DPRINTF(s, D_VERBOSE, "error %d\n", p->b.bError);
 }
-memcpy(p->abData, data, len);
+if (len) {
+g_assert_nonnull(data);
+memcpy(p->abData, data, len);
+}
 ccid_reset_error_status(s);
 usb_wakeup(s->bulk, 0);
 }
-- 
2.11.0




[Qemu-devel] [PULL 13/23] qemu-doc: Fix broken URLs of amnhltm.zip and dosidle210.zip

2017-05-07 Thread Michael Tokarev
From: Thomas Huth 

There are some broken URLs in the qemu-doc which reference tools that
are not available at their original location anymore. Fortunately, they
have been mirrored to archive.org, so point to that location instead.

Signed-off-by: Thomas Huth 
Reviewed-by: Laurent Vivier 
Signed-off-by: Michael Tokarev 
---
 qemu-doc.texi | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/qemu-doc.texi b/qemu-doc.texi
index 794ab4a080..50411bc0ff 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -1878,8 +1878,8 @@ resolution modes which the Cirrus Logic BIOS does not 
support (i.e. >=
 Windows 9x does not correctly use the CPU HLT
 instruction. The result is that it takes host CPU cycles even when
 idle. You can install the utility from
-@url{http://www.user.cityline.ru/~maxamn/amnhltm.zip} to solve this
-problem. Note that no such tool is needed for NT, 2000 or XP.
+@url{http://web.archive.org/web/20060212132151/http://www.user.cityline.ru/~maxamn/amnhltm.zip}
+to solve this problem. Note that no such tool is needed for NT, 2000 or XP.
 
 @subsubsection Windows 2000 disk full problem
 
@@ -1927,9 +1927,9 @@ vvfat block device ("-hdb 
fat:directory_which_holds_the_SP").
 @subsubsection CPU usage reduction
 
 DOS does not correctly use the CPU HLT instruction. The result is that
-it takes host CPU cycles even when idle. You can install the utility
-from @url{http://www.vmware.com/software/dosidle210.zip} to solve this
-problem.
+it takes host CPU cycles even when idle. You can install the utility from
+@url{http://web.archive.org/web/20051222085335/http://www.vmware.com/software/dosidle210.zip}
+to solve this problem.
 
 @node QEMU System emulator for non PC targets
 @chapter QEMU System emulator for non PC targets
-- 
2.11.0




[Qemu-devel] [PULL 23/23] tests: Remove redundant assignment

2017-05-07 Thread Michael Tokarev
From: Fam Zheng 

Signed-off-by: Fam Zheng 
Reviewed-by: Eric Blake 
Signed-off-by: Michael Tokarev 
---
 tests/postcopy-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c
index de35a18903..e86f87656a 100644
--- a/tests/postcopy-test.c
+++ b/tests/postcopy-test.c
@@ -41,7 +41,7 @@ static bool ufd_version_check(void)
 struct uffdio_api api_struct;
 uint64_t ioctl_mask;
 
-int ufd = ufd = syscall(__NR_userfaultfd, O_CLOEXEC);
+int ufd = syscall(__NR_userfaultfd, O_CLOEXEC);
 
 if (ufd == -1) {
 g_test_message("Skipping test: userfaultfd not available");
-- 
2.11.0




[Qemu-devel] [PULL 19/23] tests: Ignore another built executable (test-hmp)

2017-05-07 Thread Michael Tokarev
From: Eric Blake 

Commit 78f86a2b7 added a new test, but forgot to exclude the built
binary from version control.

Signed-off-by: Eric Blake 
Reviewed-by: Thomas Huth 
Signed-off-by: Michael Tokarev 
---
 tests/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index 5ab00a9c95..40c2e3e757 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -40,6 +40,7 @@ test-crypto-tlssession-server/
 test-crypto-xts
 test-cutils
 test-hbitmap
+test-hmp
 test-int128
 test-iov
 test-io-channel-buffer
-- 
2.11.0




[Qemu-devel] [PULL 15/23] hw/core/generic-loader: Fix crash when running without CPU

2017-05-07 Thread Michael Tokarev
From: Thomas Huth 

When running QEMU with "-M none -device loader,file=kernel.elf", it
currently crashes with a segmentation fault, because the "none"-machine
does not have any CPU by default and the generic loader code tries
to dereference s->cpu. Fix it by adding an appropriate check for a
NULL pointer.

Reported-by: Laurent Vivier 
Signed-off-by: Thomas Huth 
Reviewed-by: Laurent Vivier 
Reviewed-by: Alistair Francis 
Signed-off-by: Michael Tokarev 
---
 hw/core/generic-loader.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
index 58f1f02902..46012673c3 100644
--- a/hw/core/generic-loader.c
+++ b/hw/core/generic-loader.c
@@ -137,20 +137,21 @@ static void generic_loader_realize(DeviceState *dev, 
Error **errp)
 #endif
 
 if (s->file) {
+AddressSpace *as = s->cpu ? s->cpu->as :  NULL;
+
 if (!s->force_raw) {
 size = load_elf_as(s->file, NULL, NULL, , NULL, NULL,
-   big_endian, 0, 0, 0, s->cpu->as);
+   big_endian, 0, 0, 0, as);
 
 if (size < 0) {
 size = load_uimage_as(s->file, , NULL, NULL, NULL, NULL,
-  s->cpu->as);
+  as);
 }
 }
 
 if (size < 0 || s->force_raw) {
 /* Default to the maximum size being the machine's ram size */
-size = load_image_targphys_as(s->file, s->addr, ram_size,
-  s->cpu->as);
+size = load_image_targphys_as(s->file, s->addr, ram_size, as);
 } else {
 s->addr = entry;
 }
-- 
2.11.0




[Qemu-devel] [PULL 09/23] util: Use g_malloc/g_free in envlist.c

2017-05-07 Thread Michael Tokarev
From: Saurav Sachidanand 

Change malloc/strdup/free to g_malloc/g_strdup/g_free in
util/envlist.c.

Remove NULL checks for pointers returned from g_malloc and g_strdup
as they exit in case of failure. Also, update calls to envlist_create
to reflect this.

Free array and array contents returned by envlist_to_environ using
g_free in bsd-user/main.c and linux-user/main.c.

Update comments to reflect change in semantics.

Signed-off-by: Saurav Sachidanand 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Michael Tokarev 
---
 bsd-user/main.c   | 14 --
 linux-user/main.c |  9 +++--
 util/envlist.c| 47 +++
 3 files changed, 26 insertions(+), 44 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 714a692e6f..04f95ddd54 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -744,10 +744,7 @@ int main(int argc, char **argv)
 qemu_init_cpu_list();
 module_call_init(MODULE_INIT_QOM);
 
-if ((envlist = envlist_create()) == NULL) {
-(void) fprintf(stderr, "Unable to allocate envlist\n");
-exit(1);
-}
+envlist = envlist_create();
 
 /* add current environment into the list */
 for (wrk = environ; *wrk != NULL; wrk++) {
@@ -785,10 +782,7 @@ int main(int argc, char **argv)
 usage();
 } else if (!strcmp(r, "ignore-environment")) {
 envlist_free(envlist);
-if ((envlist = envlist_create()) == NULL) {
-(void) fprintf(stderr, "Unable to allocate envlist\n");
-exit(1);
-}
+envlist = envlist_create();
 } else if (!strcmp(r, "U")) {
 r = argv[optind++];
 if (envlist_unsetenv(envlist, r) != 0)
@@ -956,10 +950,10 @@ int main(int argc, char **argv)
 }
 
 for (wrk = target_environ; *wrk; wrk++) {
-free(*wrk);
+g_free(*wrk);
 }
 
-free(target_environ);
+g_free(target_environ);
 
 if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
 qemu_log("guest_base  0x%lx\n", guest_base);
diff --git a/linux-user/main.c b/linux-user/main.c
index 10a3bb3a12..5f20769cb9 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4229,10 +4229,7 @@ int main(int argc, char **argv, char **envp)
 qemu_init_cpu_list();
 module_call_init(MODULE_INIT_QOM);
 
-if ((envlist = envlist_create()) == NULL) {
-(void) fprintf(stderr, "Unable to allocate envlist\n");
-exit(EXIT_FAILURE);
-}
+envlist = envlist_create();
 
 /* add current environment into the list */
 for (wrk = environ; *wrk != NULL; wrk++) {
@@ -4429,10 +4426,10 @@ int main(int argc, char **argv, char **envp)
 }
 
 for (wrk = target_environ; *wrk; wrk++) {
-free(*wrk);
+g_free(*wrk);
 }
 
-free(target_environ);
+g_free(target_environ);
 
 if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
 qemu_log("guest_base  0x%lx\n", guest_base);
diff --git a/util/envlist.c b/util/envlist.c
index e86857e70a..1eeb7fca87 100644
--- a/util/envlist.c
+++ b/util/envlist.c
@@ -17,16 +17,14 @@ static int envlist_parse(envlist_t *envlist,
 const char *env, int (*)(envlist_t *, const char *));
 
 /*
- * Allocates new envlist and returns pointer to that or
- * NULL in case of error.
+ * Allocates new envlist and returns pointer to it.
  */
 envlist_t *
 envlist_create(void)
 {
envlist_t *envlist;
 
-   if ((envlist = malloc(sizeof (*envlist))) == NULL)
-   return (NULL);
+   envlist = g_malloc(sizeof(*envlist));
 
QLIST_INIT(>el_entries);
envlist->el_count = 0;
@@ -48,10 +46,10 @@ envlist_free(envlist_t *envlist)
entry = envlist->el_entries.lh_first;
QLIST_REMOVE(entry, ev_link);
 
-   free((char *)entry->ev_var);
-   free(entry);
+   g_free((char *)entry->ev_var);
+   g_free(entry);
}
-   free(envlist);
+   g_free(envlist);
 }
 
 /*
@@ -101,8 +99,7 @@ envlist_parse(envlist_t *envlist, const char *env,
if ((envlist == NULL) || (env == NULL))
return (EINVAL);
 
-   if ((tmpenv = strdup(env)) == NULL)
-   return (errno);
+   tmpenv = g_strdup(env);
 envsave = tmpenv;
 
 do {
@@ -117,7 +114,7 @@ envlist_parse(envlist_t *envlist, const char *env,
 tmpenv = envvar + 1;
 } while (envvar != NULL);
 
-free(envsave);
+g_free(envsave);
 return ret;
 }
 
@@ -155,18 +152,14 @@ envlist_setenv(envlist_t *envlist, const char *env)
 
if (entry != NULL) {
QLIST_REMOVE(entry, ev_link);
-   free((char *)entry->ev_var);
-   free(entry);
+   g_free((char *)entry->ev_var);
+   g_free(entry);
} else {
envlist->el_count++;
 

[Qemu-devel] [PULL 00/23] Trivial patches for 2017-05-07

2017-05-07 Thread Michael Tokarev
The following changes since commit 12a95f320a36ef66f724a49bb05e4fb553ac5dbe:

  Merge remote-tracking branch 'kwolf/tags/for-upstream' into staging 
(2017-05-04 13:44:32 +0100)

are available in the git repository at:

  git://git.corpit.ru/qemu.git tags/trivial-patches-fetch

for you to fetch changes up to 311875781e549af91a3216d34c6ef40420bab435:

  tests: Remove redundant assignment (2017-05-07 09:57:51 +0300)


trivial patches for 2017-05-07


Andreas Grapentin (1):
  use _Static_assert in QEMU_BUILD_BUG_ON

Chris Webb (1):
  virtfs: allow a device id to be specified in the -virtfs option

Craig Jellick (1):
  Add 'none' as type for drive's if option

Eric Blake (2):
  tests: Ignore more test executables
  tests: Ignore another built executable (test-hmp)

Fam Zheng (3):
  block: Make 'replication_state' an enum
  virtio-blk: Remove useless condition around g_free()
  tests: Remove redundant assignment

Ishani Chugh (1):
  Remove reduntant qemu: from error functions

KONRAD Frederic (1):
  ppc_booke: drop useless assignment

Kamil Rytarowski (2):
  scripts/qemu-binfmt-conf.sh: Fix shell portability issue
  scripts: Switch to more portable Perl shebang

Marc-André Lureau (1):
  doc: fix function spelling

Paolo Bonzini (3):
  jazz_led: fix bad snprintf
  MAINTAINERS: Update paths for main loop
  MAINTAINERS: Update paths for AioContext implementation

Philippe Mathieu-Daudé (3):
  usb-ccid: make ccid_write_data_block() cope with null buffers
  device_tree: fix compiler warnings (clang 5)
  qga: fix compiler warnings (clang 5)

Saurav Sachidanand (1):
  util: Use g_malloc/g_free in envlist.c

Thomas Huth (2):
  qemu-doc: Fix broken URLs of amnhltm.zip and dosidle210.zip
  hw/core/generic-loader: Fix crash when running without CPU

sochin.jiang fix wrong parameter comments in channel-file.h (1):
  channel-file: fix wrong parameter comments

 MAINTAINERS |  8 +++
 block/replication.c | 44 +++---
 bsd-user/main.c | 14 
 configure   | 18 
 device_tree.c   |  1 +
 hw/block/virtio-blk.c   |  4 +---
 hw/core/generic-loader.c|  9 
 hw/display/jazz_led.c   |  4 ++--
 hw/microblaze/boot.c|  2 +-
 hw/nios2/boot.c |  2 +-
 hw/ppc/pnv.c|  2 +-
 hw/ppc/ppc_booke.c  |  1 -
 hw/s390x/sclp.c |  4 ++--
 hw/tricore/tricore_testboard.c  |  2 +-
 hw/usb/dev-smartcard-reader.c   |  5 -
 include/io/channel-file.h   |  2 +-
 include/io/channel.h|  2 +-
 include/qemu/compiler.h |  4 +++-
 linux-user/main.c   |  9 +++-
 numa.c  |  4 ++--
 qemu-doc.texi   | 10 -
 qemu-options.hx |  4 ++--
 qga/commands-posix.c|  8 ---
 scripts/checkpatch.pl   |  3 ++-
 scripts/clean-header-guards.pl  |  3 ++-
 scripts/cleanup-trace-events.pl |  2 +-
 scripts/disas-objdump.pl|  4 +++-
 scripts/get_maintainer.pl   |  3 ++-
 scripts/qemu-binfmt-conf.sh |  4 ++--
 scripts/shaderinclude.pl|  2 +-
 scripts/switch-timer-api|  2 +-
 scripts/texi2pod.pl |  4 +++-
 tests/.gitignore|  4 
 tests/postcopy-test.c   |  2 +-
 util/envlist.c  | 47 +
 vl.c|  5 +++--
 36 files changed, 133 insertions(+), 115 deletions(-)



[Qemu-devel] [PULL 14/23] virtio-blk: Remove useless condition around g_free()

2017-05-07 Thread Michael Tokarev
From: Fam Zheng 

Laszlo spotted and studied this wasteful "if". He pointed out:

The original virtio_blk_free_request needed an "if" as it accesses one
field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to
pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed
VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became
embedded, so the "if" became unnecessary (at which point we were using
g_slice_free(), but it is the same.

Now drop it.

Reported-by: Laszlo Ersek 
Signed-off-by: Fam Zheng 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Stefan Hajnoczi 
Signed-off-by: Michael Tokarev 
---
 hw/block/virtio-blk.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 98c16a7a9a..604d37dfc8 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -42,9 +42,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue 
*vq,
 
 static void virtio_blk_free_request(VirtIOBlockReq *req)
 {
-if (req) {
-g_free(req);
-}
+g_free(req);
 }
 
 static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
-- 
2.11.0




[Qemu-devel] [PULL 01/23] Remove reduntant qemu: from error functions

2017-05-07 Thread Michael Tokarev
From: Ishani Chugh 

This patch removes redundant "qemu:" from error functions. The link to the 
bitesized task is:
http://wiki.qemu-project.org/Contribute/BiteSizedTasks#Error_checking

Signed-off-by: Ishani Chugh 
Reviewed-by: Eduardo Habkost 
Reviewed-by: David Gibson 
Signed-off-by: Michael Tokarev 
---
 hw/microblaze/boot.c   | 2 +-
 hw/nios2/boot.c| 2 +-
 hw/ppc/pnv.c   | 2 +-
 hw/s390x/sclp.c| 4 ++--
 hw/tricore/tricore_testboard.c | 2 +-
 numa.c | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index 1834d22a61..457a08a2fe 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -189,7 +189,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr 
ddr_base,
   ram_size - initrd_offset);
 }
 if (initrd_size < 0) {
-error_report("qemu: could not load initrd '%s'",
+error_report("could not load initrd '%s'",
  initrd_filename);
 exit(EXIT_FAILURE);
 }
diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c
index e0a9aff2f4..2b31f5b844 100644
--- a/hw/nios2/boot.c
+++ b/hw/nios2/boot.c
@@ -197,7 +197,7 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
   ram_size - initrd_offset);
 }
 if (initrd_size < 0) {
-error_report("qemu: could not load initrd '%s'",
+error_report("could not load initrd '%s'",
  initrd_filename);
 exit(EXIT_FAILURE);
 }
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index d4bcdb027f..6a498565c7 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -610,7 +610,7 @@ static void ppc_powernv_init(MachineState *machine)
 /* Create the processor chips */
 chip_typename = g_strdup_printf(TYPE_PNV_CHIP "-%s", machine->cpu_model);
 if (!object_class_by_name(chip_typename)) {
-error_report("qemu: invalid CPU model '%s' for %s machine",
+error_report("invalid CPU model '%s' for %s machine",
  machine->cpu_model, MACHINE_GET_CLASS(machine)->name);
 exit(1);
 }
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index e741da1141..6996088584 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -496,10 +496,10 @@ static void sclp_realize(DeviceState *dev, Error **errp)
 
 ret = s390_set_memory_limit(machine->maxram_size, _limit);
 if (ret == -E2BIG) {
-error_setg(, "qemu: host supports a maximum of %" PRIu64 " GB",
+error_setg(, "host supports a maximum of %" PRIu64 " GB",
hw_limit >> 30);
 } else if (ret) {
-error_setg(, "qemu: setting the guest size failed");
+error_setg(, "setting the guest size failed");
 }
 
 out:
diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c
index 19dd587207..8910bf0f27 100644
--- a/hw/tricore/tricore_testboard.c
+++ b/hw/tricore/tricore_testboard.c
@@ -50,7 +50,7 @@ static void tricore_load_kernel(CPUTriCoreState *env)
NULL, 0,
EM_TRICORE, 1, 0);
 if (kernel_size <= 0) {
-error_report("qemu: no kernel file '%s'",
+error_report("no kernel file '%s'",
 tricoretb_binfo.kernel_filename);
 exit(1);
 }
diff --git a/numa.c b/numa.c
index 6fc2393ddd..39b743bd94 100644
--- a/numa.c
+++ b/numa.c
@@ -174,7 +174,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts 
*opts, Error **errp)
 }
 
 if (node->has_mem && node->has_memdev) {
-error_setg(errp, "qemu: cannot specify both mem= and memdev=");
+error_setg(errp, "cannot specify both mem= and memdev=");
 return;
 }
 
@@ -182,7 +182,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts 
*opts, Error **errp)
 have_memdevs = node->has_memdev;
 }
 if (node->has_memdev != have_memdevs) {
-error_setg(errp, "qemu: memdev option must be specified for either "
+error_setg(errp, "memdev option must be specified for either "
"all or no nodes");
 return;
 }
-- 
2.11.0




[Qemu-devel] [PULL 11/23] channel-file: fix wrong parameter comments

2017-05-07 Thread Michael Tokarev
From: "sochin.jiang fix wrong parameter comments in channel-file.h" 


Signed-off-by: sochin.jiang 
Reviewed-by: Marc-André Lureau 
Signed-off-by: Michael Tokarev 
---
 include/io/channel-file.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/io/channel-file.h b/include/io/channel-file.h
index d2462c2ed7..79245f1183 100644
--- a/include/io/channel-file.h
+++ b/include/io/channel-file.h
@@ -71,7 +71,7 @@ qio_channel_file_new_fd(int fd);
 
 /**
  * qio_channel_file_new_path:
- * @fd: the file descriptor
+ * @path: the file path
  * @flags: the open flags (O_RDONLY|O_WRONLY|O_RDWR, etc)
  * @mode: the file creation mode if O_WRONLY is set in @flags
  * @errp: pointer to initialized error object
-- 
2.11.0




[Qemu-devel] [PULL 12/23] use _Static_assert in QEMU_BUILD_BUG_ON

2017-05-07 Thread Michael Tokarev
From: Andreas Grapentin 

QEMU_BUILD_BUG_ON should use C11's _Static_assert, if the compiler supports it,
to provide more readable messages on failure.

We check for _Static_assert in configure, and set CONFIG_STATIC_ASSERT
accordingly. QEMU_BUILD_BUG_ON invokes _Static_assert if CONFIG_STATIC_ASSERT
is defined, and reverts to the old way otherwise.

That way, systems without C11 conforming compiler will still have the old
messages, as verified by intentionally breaking the configure check.

the following example output was generated by inverting the condition in
QEMU_BUILD_BUG_ON:

without _Static_assert:

> In file included from /qemu/include/qemu/osdep.h:36:0,
>  from /qemu/qga/commands.c:13:
> /qemu/qga/commands.c: In function ‘qmp_guest_exec_status’:
> /qemu/include/qemu/compiler.h:89:12: error: negative width in bit-field 
> ‘’
>  struct { \
> ^
> /qemu/include/qemu/compiler.h:96:38: note: in expansion of macro  
> QEMU_BUILD_BUG_ON_STRUCT’
>  #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
>   ^~~~
> /qemu/include/qemu/atomic.h:146:5: note: in expansion of macro 
> ‘QEMU_BUILD_BUG_ON’
>  QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *));   \
>  ^
> /qemu/include/qemu/atomic.h:417:5: note: in expansion of macro 
> ‘atomic_load_acquire’
>  atomic_load_acquire(ptr)
>  ^~~
> /qemu/qga/commands.c:160:21: note: in expansion of macro ‘atomic_mb_read’
>  bool finished = atomic_mb_read(>finished);
>  ^~

with _Static_assert:

> In file included from /qemu/include/qemu/osdep.h:36:0,
>  from /qemu/qga/commands.c:13:
> /qemu/qga/commands.c: In function ‘qmp_guest_exec_status’:
> /qemu/include/qemu/compiler.h:94:30: error: static assertion failed: "not 
> expecting: sizeof(*>finished) > sizeof(void *)"
>  #define QEMU_BUILD_BUG_ON(x) _Static_assert(!(x), #x)
>   ^
> /qemu/include/qemu/atomic.h:146:5: note: in expansion of macro 
> ‘QEMU_BUILD_BUG_ON’
>  QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *));   \
>  ^
> /qemu/include/qemu/atomic.h:417:5: note: in expansion of macro 
> ‘atomic_load_acquire’
>  atomic_load_acquire(ptr)
>  ^~~
> /qemu/qga/commands.c:160:21: note: in expansion of macro ‘atomic_mb_read’
>  bool finished = atomic_mb_read(>finished);
>  ^~

Signed-off-by: Andreas Grapentin 
Reviewed-by: Eric Blake 
Reviewed-by: Richard Henderson 
Signed-off-by: Michael Tokarev 
---
 configure   | 18 ++
 include/qemu/compiler.h |  4 +++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 48a9370cc6..39aadba813 100755
--- a/configure
+++ b/configure
@@ -4853,6 +4853,20 @@ EOF
 fi
 
 ##
+# check for _Static_assert()
+
+have_static_assert=no
+cat > $TMPC << EOF
+_Static_assert(1, "success");
+int main(void) {
+return 0;
+}
+EOF
+if compile_prog "" "" ; then
+have_static_assert=yes
+fi
+
+##
 # End of CC checks
 # After here, no more $cc or $ld runs
 
@@ -5848,6 +5862,10 @@ if test "$have_sysmacros" = "yes" ; then
   echo "CONFIG_SYSMACROS=y" >> $config_host_mak
 fi
 
+if test "$have_static_assert" = "yes" ; then
+  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
+fi
+
 # Hold two types of flag:
 #   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
 # a thread we have a handle to
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 18e610083a..340e5fdc09 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -82,7 +82,9 @@
 int:(x) ? -1 : 1; \
 }
 
-#ifdef __COUNTER__
+#if defined(CONFIG_STATIC_ASSERT)
+#define QEMU_BUILD_BUG_ON(x) _Static_assert(!(x), "not expecting: " #x)
+#elif defined(__COUNTER__)
 #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
 glue(qemu_build_bug_on__, __COUNTER__) __attribute__((unused))
 #else
-- 
2.11.0




[Qemu-devel] [PULL 08/23] qga: fix compiler warnings (clang 5)

2017-05-07 Thread Michael Tokarev
From: Philippe Mathieu-Daudé 

static code analyzer complain:

qga/commands-posix.c:2127:9: warning: Null pointer passed as an argument to a 
'nonnull' parameter
closedir(dp);
^~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Marc-André Lureau 
Reviewed-by: Michael Roth 
Signed-off-by: Michael Tokarev 
---
 qga/commands-posix.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index ba06be4c86..284ecc6d7e 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -2125,9 +2125,11 @@ static void transfer_memory_block(GuestMemoryBlock 
*mem_blk, bool sys2memblk,
  * we think this VM does not support online/offline memory block,
  * any other solution?
  */
-if (!dp && errno == ENOENT) {
-result->response =
-GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_NOT_SUPPORTED;
+if (!dp) {
+if (errno == ENOENT) {
+result->response =
+GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_NOT_SUPPORTED;
+}
 goto out1;
 }
 closedir(dp);
-- 
2.11.0