Re: [Qemu-devel] [PATCH v8 00/16] cpu-exec: Safe work in quiescent state

2016-09-25 Thread Alex Bennée

Paolo Bonzini  writes:

> Changes from v7

Looks good to my testing:

Tested-by: Alex Bennée 

>
> patch 1: one more instance to change
>
> patch 4: rename cpu_list_mutex to cpu_list_lock [Emilio]
>  avoid problems from spurious wakeups [me]
>
> patch 6: rename qemu_cpu_list_mutex to qemu_cpu_list_lock (ripples
>  to other patches afterwards) [Emilio]
>
> patch 13: adjust comments on top of start_exclusive/end_exclusive [Emilio]
>
> patch 14: do not set wi->exclusive [Emilio]
>
> patch 16: use atomics for pending_cpus and cpu->running
>   (not for cpu->has_waiter) [Emilio]
>
>
> Alex Bennée (1):
>   cpus: pass CPUState to run_on_cpu helpers
>
> Paolo Bonzini (9):
>   cpus-common: move CPU list management to common code
>   cpus-common: fix uninitialized variable use in run_on_cpu
>   cpus-common: move exclusive work infrastructure from linux-user
>   docs: include formal model for TCG exclusive sections
>   cpus-common: always defer async_run_on_cpu work items
>   cpus-common: remove redundant call to exclusive_idle()
>   cpus-common: simplify locking for start_exclusive/end_exclusive
>   cpus-common: Introduce async_safe_run_on_cpu()
>   cpus-common: lock-free fast path for cpu_exec_start/end
>
> Sergey Fedorov (6):
>   cpus: Move common code out of {async_, }run_on_cpu()
>   cpus: Rename flush_queued_work()
>   linux-user: Use QemuMutex and QemuCond
>   linux-user: Add qemu_cpu_is_self() and qemu_cpu_kick()
>   cpus-common: move CPU work item management to common code
>   tcg: Make tb_flush() thread safe
>
>  Makefile.objs  |   2 +-
>  bsd-user/main.c|  33 ++---
>  cpu-exec.c |  12 +-
>  cpus-common.c  | 352 
> +
>  cpus.c |  99 +
>  docs/tcg-exclusive.promela | 224 +
>  exec.c |  37 +
>  hw/i386/kvm/apic.c |   5 +-
>  hw/i386/kvmvapic.c |   6 +-
>  hw/ppc/ppce500_spin.c  |  31 ++--
>  hw/ppc/spapr.c |   6 +-
>  hw/ppc/spapr_hcall.c   |  17 +--
>  include/exec/cpu-common.h  |   5 +
>  include/exec/exec-all.h|  11 --
>  include/exec/tb-context.h  |   2 +-
>  include/qom/cpu.h  | 102 +++--
>  kvm-all.c  |  21 +--
>  linux-user/main.c  | 130 +
>  target-i386/helper.c   |  19 ++-
>  target-i386/kvm.c  |   6 +-
>  target-s390x/cpu.c |   4 +-
>  target-s390x/cpu.h |   7 +-
>  target-s390x/kvm.c |  98 ++---
>  target-s390x/misc_helper.c |   4 +-
>  translate-all.c|  38 +++--
>  vl.c   |   1 +
>  26 files changed, 856 insertions(+), 416 deletions(-)
>  create mode 100644 cpus-common.c
>  create mode 100644 docs/tcg-exclusive.promela


--
Alex Bennée



Re: [Qemu-devel] [PULL 00/44] ppc-for-2.8 queue 20160922

2016-09-25 Thread David Gibson
On Sat, Sep 24, 2016 at 03:31:36PM +0100, Alex Bennée wrote:
> 
> David Gibson  writes:
> 
> > On Fri, Sep 23, 2016 at 08:42:22AM +0100, Alex Bennée wrote:
> >>
> >> David Gibson  writes:
> >>
> >> > On Thu, Sep 22, 2016 at 03:03:50PM +0100, Peter Maydell wrote:
> >> >> On 22 September 2016 at 07:36, David Gibson 
> >> >>  wrote:
> >> >> > The following changes since commit 
> >> >> > a008535b9fa396226ff9cf78b8ac5f3584bda58e:
> >> >> >
> >> >> >   build-sys: fix make install regression (2016-09-20 11:32:43 +0100)
> >> >> >
> >> >> > are available in the git repository at:
> >> >> >
> >> >> >   git://github.com/dgibson/qemu.git tags/ppc-for-2.8-20160922
> >> >> >
> >> >> > for you to fetch changes up to 
> >> >> > 2832da4b6fc549d5feb2cf9fe53ad98cee894327:
> >> >> >
> >> >> >   monitor: fix crash for platforms without a CPU 0 (2016-09-22 
> >> >> > 15:53:01 +1000)
> >> >> >
> >> >> > 
> >> >> > ppc patch queue 2016-09-22
> >> >> >
> >> >> > This is my second pull request of ppc and spapr related patches for
> >> >> > qemu-2.8.  Included here are
> >> >> > * TCG implementations for more POWER9 instructions
> >> >> > * Some preliminary XICS fixes in preparataion for the pnv machine 
> >> >> > type
> >> >> > * A significant ADB (Macintosh kbd/mouse) cleanup
> >> >> > * Some conversions to use trace instead of debug macros
> >> >> > * Fixes to correctly handle global TLB flush synchronization in
> >> >> >   TCG.  This is already a bug, but it will have much more impact
> >> >> >   when we get MTTCG
> >> >> > * Add more qtest testcases for Power
> >> >> > * Some MAINTAINERS updates
> >> >> > * Assorted bugfixes
> >> >> >
> >> >> > This touches some test files and monitor.c which are technically
> >> >> > outside the ppc code, but coming through this tree because the changes
> >> >> > are primarily of interest to ppc.
> >> >> >
> >> >> > 
> >> >>
> >> >> I'm afraid this fails to build with clang:
> >> >>
> >> >> /home/petmay01/linaro/qemu-for-merges/target-ppc/translate.c:532:16:
> >> >> error: unused function 'L' [-Werro
> >> >> r,-Wunused-function]
> >> >> EXTRACT_HELPER(L, 16, 2);
> >> >>^
> >> >> 1 error generated.
> >> >
> >> > Drat, I wonder why travis didn't catch that for me.
> >>
> >> Maybe a version thing? I've got a patch in flight for building with the
> >> ThreadSanitizer which threw up some compiler warnings but that uses GCC.
> >> Maybe a more recent clang build should be added as well?
> >
> > That'd be nice if possible .  However, I think we're restricted to
> > what's in the not terribly up-to-date Ubuntu image that Travis uses
> > for its containers, so we might not be able to get something new
> > enough to trip this warning.
> 
> The base containers are 12.04 but there is a Trusty VM and for the
> ThreadSanitizer patches I added the Ubuntu Toolchain PPA which is fairly
> upto date.

Ah, nice.

-- 
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] [RFC/PATCH] migration: SMRAM dirty bitmap not fetched from kvm-kmod and not send to destination

2016-09-25 Thread Herongguang (Stephen)



On 2016/9/23 15:17, Paolo Bonzini wrote:



On 22/09/2016 15:16, Herongguang (Stephen) wrote:

I have some concern:
1. For example, vhost does not know about as_id, I wonder if guests in
SMM can operate disk or ether card, as in
that case vhost would not logging dirty pages correctly, without knowing
as_id.


In the end memory is logged by ram_addr_t, not by address space.  So if
vhost_sync_dirty_bitmap is called on the right region everything works.

Guests in SMM can operate on storage devices, but storage devices cannot
write to 0xA-0xB so that's safe.


2. If a memory region is disabled/enabled/disabled frequently, since
disabled memory regions would be removed
from memory slots in kvm-kmod, dirty pages would be discarded in
kvm-kmod and qemu when disabled, thus missing.
Is my assumption correct?


As you found, this is handled by kvm_set_phys_mem:

 if (mem->flags & KVM_MEM_LOG_DIRTY_PAGES) {
 kvm_physical_sync_dirty_bitmap(kml, section);
 }


3. I agree your opinion that the right solution is to get dirty-page
information for all memory region from
kvm-kmod. But I found it’s somewhat hard to implement since
kvm_log_sync() expects a MemoryRegionSection*
parameter. Do you have good idea?


You're right, memory_region_sync_dirty_bitmap handles this but it's
inefficient.

So your patch is correct, but it breaks for !x86 as you probably know.
We need to look at the address spaces which have a listener that
implements log_sync.


As to all the ram memory regions, I think they are all in the
ram_list.blocks, so there is no need to create
a notifier, is this correct?


Yes, makes sense.

The patch here is a bit of a hack but is efficient.  It looks at
each address space just once and calls log_sync just once per
FlatRange.

Paolo

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 3e4d416..23b086d 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1154,12 +1154,11 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr,
 hwaddr addr, uint64_t size);

  /**
- * address_space_sync_dirty_bitmap: synchronize the dirty log for all memory
+ * memory_global_dirty_log_sync: synchronize the dirty log for all memory
   *
- * Synchronizes the dirty page log for an entire address space.
- * @as: the address space that contains the memory being synchronized
+ * Synchronizes the dirty page log for all address spaces.
   */
-void address_space_sync_dirty_bitmap(AddressSpace *as);
+void memory_global_dirty_log_sync(void);

  /**
   * memory_region_transaction_begin: Start a transaction.
diff --git a/memory.c b/memory.c
index 1a1baf5..6cac674 100644
--- a/memory.c
+++ b/memory.c
@@ -158,15 +158,11 @@ static bool memory_listener_match(MemoryListener 
*listener,

  /* No need to ref/unref .mr, the FlatRange keeps it alive.  */
  #define MEMORY_LISTENER_UPDATE_REGION(fr, as, dir, callback, _args...)  \
-MEMORY_LISTENER_CALL(callback, dir, (&(MemoryRegionSection) {   \
-.mr = (fr)->mr, \
-.address_space = (as),  \
-.offset_within_region = (fr)->offset_in_region, \
-.size = (fr)->addr.size,\
-.offset_within_address_space = int128_get64((fr)->addr.start),  \
-.readonly = (fr)->readonly, \
-  }), ##_args)
-
+do {\
+MemoryRegionSection mrs = section_from_flat_range(fr, as);  \
+MEMORY_LISTENER_CALL(callback, dir, &mrs, ##_args); \
+} while(0)
+
  struct CoalescedMemoryRange {
  AddrRange addr;
  QTAILQ_ENTRY(CoalescedMemoryRange) link;
@@ -245,6 +241,19 @@ typedef struct AddressSpaceOps AddressSpaceOps;
  #define FOR_EACH_FLAT_RANGE(var, view)  \
  for (var = (view)->ranges; var < (view)->ranges + (view)->nr; ++var)

+static inline MemoryRegionSection
+section_from_flat_range(FlatRange *fr, AddressSpace *as)
+{
+return (MemoryRegionSection) {
+.mr = fr->mr,
+.address_space = as,
+.offset_within_region = fr->offset_in_region,
+.size = fr->addr.size,
+.offset_within_address_space = int128_get64(fr->addr.start),
+.readonly = fr->readonly,
+};
+}
+
  static bool flatrange_equal(FlatRange *a, FlatRange *b)
  {
  return a->mr == b->mr
@@ -2124,16 +2133,25 @@ bool memory_region_present(MemoryRegion *container, 
hwaddr addr)
  return mr && mr != container;
  }

-void address_space_sync_dirty_bitmap(AddressSpace *as)
+void memory_global_dirty_log_sync(void)
  {
+MemoryListener *listener;
+AddressSpace *as;
  FlatView *view;
  FlatRange *fr;

-view = address_space_get_flatview(as);
-FOR_EACH_FLAT_RANGE(fr, view) {
-MEMORY_LISTENER_UPDATE_REGION(fr, as, Forward, log_sync);
+

[Qemu-devel] Migration dirty bitmap: should only mark pages as dirty after they have been sent

2016-09-25 Thread Chunguang Li
Hi all!
I have some confusion about the dirty bitmap during migration. I have digged 
into the code. I figure out that every now and then during migration, the dirty 
bitmap will be grabbed from the kernel space through ioctl(KVM_GET_DIRTY_LOG), 
and then be used to update qemu's dirty bitmap. However I think this mechanism 
leads to resendness of some NON-dirty pages.

Take the first iteration of precopy for instance, during which all the pages 
will be sent. Before that during the migration setup, the 
ioctl(KVM_GET_DIRTY_LOG) is called once, so the kernel begins to produce the 
dirty bitmap from this moment. When the pages "that haven't been sent" are 
written, the kernel space marks them as dirty. However I don't think this is 
correct, because these pages will be sent during this and the next iterations 
with the same content (if they are not written again after they are sent). It 
only makes sense to mark the pages which have already been sent during one 
iteration as dirty when they are written.


Am I right about this consideration? If I am right, is there some advice to 
improve this?


Thanks,
Chunguang Li


Re: [Qemu-devel] [PATCH v2 1/9] log: Add new IOMMU type

2016-09-25 Thread Edgar E. Iglesias
On Tue, Sep 13, 2016 at 01:53:39AM +0530, Prem Mallappa wrote:
> On Fri, Sep 9, 2016 at 9:06 PM, Auger Eric  wrote:
> 
> > Hi Prem,
> >
> > Missing commit message
> >
> > > Signed-off-by: Prem Mallappa 
> > > ---
> > >  include/qemu/log.h | 1 +
> > >  util/log.c | 2 ++
> > >  2 files changed, 3 insertions(+)
> > >
> > > diff --git a/include/qemu/log.h b/include/qemu/log.h
> > > index 234fa81..3dd2131 100644
> > > --- a/include/qemu/log.h
> > > +++ b/include/qemu/log.h
> > > @@ -42,6 +42,7 @@ static inline bool qemu_log_separate(void)
> > >  #define CPU_LOG_TB_NOCHAIN (1 << 13)
> > >  #define CPU_LOG_PAGE   (1 << 14)
> > >  #define LOG_TRACE  (1 << 15)
> > > +#define CPU_LOG_IOMMU  (1 << 16)
> > why is it prefixed with CPU_ ?
> > besides all arm gic devices seem to use LOG_GUEST_ERROR. what is the
> > rationale behind introducing a new enum?
> >
> 
> Will change this to LOG_GUEST_ERROR, if others on the list are okay.

Hi,

LOG_GUEST_ERROR is used for cases when the guest programs things in bad
way. E.g sets up a register in an invalid manner or writes to regs that
don't exist.

In this case we're logging information for valid translation steps, I
would prefer if we could use something else than LOG_GUEST_ERROR.
An IOMMU logging class sounds good to me.

Best regards,
Edgar



Re: [Qemu-devel] [PATCH v2 3/9] hw: arm: SMMUv3 emulation model

2016-09-25 Thread Edgar E. Iglesias
On Mon, Aug 22, 2016 at 09:47:34PM +0530, Prem Mallappa wrote:
> Big patch adds SMMUv3 model to Qemu
>   - As per SMMUv3 spec 16.0
>   - Works with SMMUv3 driver in Linux 4.7rc1
>   - Only LPAE mode translation supported
>   - BE mode is not supported yet
>   - Stage1, Stage2 and S1+S2
>   - Suspend/resume not tested

Thanks Prem,

I'm going to look at the PCI parts and get back to you with
comments on that.

I've put another round of comments inline:


> 
> Signed-off-by: Prem Mallappa 
> ---
>  hw/arm/smmu-common.c |  152 +
>  hw/arm/smmu-common.h |  141 +
>  hw/arm/smmu-v3.c | 1369 
> ++
>  hw/arm/smmuv3-internal.h |  432 +++
>  hw/vfio/common.c |2 +-
>  5 files changed, 2095 insertions(+), 1 deletion(-)
>  create mode 100644 hw/arm/smmu-common.c
>  create mode 100644 hw/arm/smmu-common.h
>  create mode 100644 hw/arm/smmu-v3.c
>  create mode 100644 hw/arm/smmuv3-internal.h
> 
> diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
> new file mode 100644
> index 000..bf2039b
> --- /dev/null
> +++ b/hw/arm/smmu-common.c
> @@ -0,0 +1,152 @@
> +/*
> + * Copyright (C) 2014-2016 Broadcom Corporation
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> + *
> + * Author: Prem Mallappa 
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include "sysemu/sysemu.h"
> +#include "exec/address-spaces.h"
> +
> +#include "smmu-common.h"
> +
> +inline MemTxResult smmu_read_sysmem(hwaddr addr, void *buf, int len,
> +bool secure)
> +{
> +MemTxAttrs attrs = {.unspecified = 1, .secure = secure};
> +
> +switch (len) {
> +case 4:
> +*(uint32_t *)buf = ldl_le_phys(&address_space_memory, addr);
> +break;
> +case 8:
> +*(uint64_t *)buf = ldq_le_phys(&address_space_memory, addr);
> +break;
> +default:
> +return address_space_rw(&address_space_memory, addr,
> +attrs, buf, len, false);
> +}
> +return MEMTX_OK;
> +}
> +
> +inline void
> +smmu_write_sysmem(hwaddr addr, void *buf, int len, bool secure)
> +{
> +MemTxAttrs attrs = {.unspecified = 1, .secure = secure};
> +
> +switch (len) {
> +case 4:
> +stl_le_phys(&address_space_memory, addr, *(uint32_t *)buf);
> +break;
> +case 8:
> +stq_le_phys(&address_space_memory, addr, *(uint64_t *)buf);
> +break;
> +default:
> +address_space_rw(&address_space_memory, addr,
> + attrs, buf, len, true);
> +}
> +}

Thinking about this, I think you should just remove these functions and
always call dma_memory_read/write directly.

It would be nice if you could add a property/link so that machine code
can specify the MemoryRegion/address space to be used. You'll need a
link to allow setup of the MemoryRegion and also some code to create
an address space from the selected MR.

You can have a look at the following code to see how it's done:
exec.c cpu_exec_init()see object_property_add_link
cpus.c qemu_init_vcpu()   see address_space_init_shareable



> +
> +SMMUTransErr
> +smmu_translate_64(SMMUTransCfg *cfg, uint32_t *pagesize,
> +  uint32_t *perm, bool is_write)
> +{
> +int ret, level;
> +int stage  = cfg->stage;
> +int granule_sz = cfg->granule_sz[stage];
> +int va_size= cfg->va_size[stage];
> +hwaddr  va, addr, mask;
> +hwaddr *outaddr;
> +
> +
> +va = addr = cfg->va;/* or ipa in Stage2 */
> +SMMU_DPRINTF(TT_1, "stage:%d\n", stage);
> +assert(va_size == 64);  /* We dont support 32-bit yet */
> +/* same location, for clearity */
> +outaddr = &cfg->pa;
> +
> +level = 4 - (va_size - cfg->tsz[stage] - 4) / granule_sz;
> +
> +mask = (1ULL << (granule_sz + 3)) - 1;
> +
> +addr = extract64(cfg->ttbr[stage], 0, 48);
> +addr &= ~((1ULL << (va_size - cfg->tsz[stage] -
> +(granule_sz * (4 - level - 1);
> +
> +for (;;) {
> +uint64_t desc;
> +#ifdef ARM_SMMU_DEBUG
> +uint64_t ored = (va >> (granule_sz * (4 - level))) & mask;
> +SMMU_DPRINTF(TT_1,
> + "Level: %d va:%lx addr:%lx ored:%lx\n",
> + level, va, addr, ored);
> +#endif
> +addr |= (va >> (granule_s

[Qemu-devel] [PATCH v2 01/11] qapi: add qapi2texi script

2016-09-25 Thread Marc-André Lureau
As the name suggests, the qapi2texi script converts JSON QAPI
description into a standalone texi file suitable for different target
formats.

It parses the following kind of blocks with some little variations:

  ##
  # = Section
  # == Subsection
  #
  # Some text foo with *emphasis*
  # 1. with a list
  # 2. like that
  #
  # And some code:
  # | $ echo foo
  # | <- do this
  # | -> get that
  #
  ##

  ##
  # @symbol
  #
  # Symbol body ditto ergo sum. Foo bar
  # baz ding.
  #
  # @arg: foo
  # @arg: #optional foo
  #
  # Returns: returns bla bla
  #
  #  Or bla blah
  #
  # Since: version
  # Notes: notes, comments can have
  #- itemized list
  #- like this
  #
  #and continue...
  #
  # Example:
  #
  # <- { "execute": "quit" }
  # -> { "return": {} }
  #
  ##

Thanks to the json declaration, it's able to give extra information
about the type of arguments and return value expected.

Signed-off-by: Marc-André Lureau 
---
 scripts/qapi.py| 100 +++-
 scripts/qapi2texi.py   | 314 +
 docs/qapi-code-gen.txt |  44 +--
 3 files changed, 446 insertions(+), 12 deletions(-)
 create mode 100755 scripts/qapi2texi.py

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 21bc32f..4efc7e7 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -122,6 +122,79 @@ class QAPIExprError(Exception):
 "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg)
 
 
+class QAPIDoc:
+def __init__(self, comment):
+self.symbol = None
+self.comment = "" # the main symbol comment
+self.args = OrderedDict()
+# meta is for Since:, Notes:, Examples:, Returns:...
+self.meta = OrderedDict()
+# the current section to populate, array of [dict, key, comment...]
+self.section = None
+
+for line in comment.split('\n'):
+# remove multiple spaces
+sline = ' '.join(line.split())
+# take the first word out
+split = sline.split(' ', 1)
+key = split[0]
+
+if key.startswith("@"):
+key = key[1:].rstrip(':')
+sline = split[1] if len(split) > 1 else ""
+if self.symbol is None:
+# the first is the section symbol
+self.symbol = key
+else:
+# else an arg
+self.start_section(self.args, key)
+elif self.symbol and \
+key in ("Returns:",
+# special case for Since often used without:
+"Since:", "Since",
+# those are often singular or plural
+"Note:", "Notes:",
+"Example:", "Examples:"):
+sline = split[1] if len(split) > 1 else ""
+line = None
+# new "meta" section
+self.start_section(self.meta, key.rstrip(':'))
+
+if self.section and self.section[1].startswith("Example"):
+# example is verbatim
+self.append_comment(line)
+else:
+self.append_comment(sline)
+
+self.end_section()
+
+def append_comment(self, line):
+"""Adds a comment to the current section, or the symbol comment"""
+if line is None:
+return
+if self.section is not None:
+if self.section[-1] == "" and line == "":
+self.end_section()
+else:
+self.section.append(line)
+elif self.comment == "":
+self.comment = line
+else:
+self.comment += "\n" + line
+
+def end_section(self):
+if self.section is not None:
+dic = self.section[0]
+key = self.section[1]
+doc = "\n".join(self.section[2:])
+dic[key] = doc
+self.section = None
+
+def start_section(self, dic, key):
+self.end_section()
+self.section = [dic, key]  # .. remaining elems will be the doc
+
+
 class QAPISchemaParser(object):
 
 def __init__(self, fp, previously_included=[], incl_info=None):
@@ -137,11 +210,14 @@ class QAPISchemaParser(object):
 self.line = 1
 self.line_pos = 0
 self.exprs = []
+self.comment = None
+self.apidoc = incl_info['doc'] if incl_info else []
 self.accept()
 
 while self.tok is not None:
 expr_info = {'file': fname, 'line': self.line,
- 'parent': self.incl_info}
+ 'parent': self.incl_info, 'doc': self.apidoc}
+self.apidoc = []
 expr = self.get_expr(False)
 if isinstance(expr, dict) and "include" in expr:
 if len(expr) != 1:
@@ -162,6 +238,8 @@ class QAPISchemaParser(object):
 inf = inf['parent']

[Qemu-devel] [PATCH v2 00/11] qapi doc generation (whole version, squashed)

2016-09-25 Thread Marc-André Lureau
Hi,

Add a qapi2texi script to generate the documentation from the qapi
schemas. Build various new documentation targets for it: pdf, man,
txt. The 7th patch in this series is a squashed version of the
documentation move from qmp-commands.txt to the schemas. The whole
version (not sent on the ML to avoid spamming) is in the following git
branch: https://github.com/elmarco/qemu/commits/qapi-doc

v1->v2:
- change licence to be lgpl2+
- fix some comments & commit message
- add more code comments
- improve the doc parsing to treat only "Since" as a special case not
  requiring ":" (common notation in the doc)
- include some early schema doc fixes (to fix generated doc)
- include the squashed version of the doc move
- include the man page and installation build changes

Marc-André Lureau (11):
  qapi: add qapi2texi script
  qapi: fix schema symbol sections
  qapi: fix missing symbol @prefix
  qapi: fix @ACPI sections
  docs: add qapi texi template
  build-sys: add qapi doc generation targets
  (SQUASHED) qmp-commands docs move to schema
  qapi: add some sections in docs and fix
  qga: fix guest-get-memory-block-info doc
  texi2pod: learn quotation, deftp and deftypefn
  build-sys: make and install the generated schema docs

 Makefile|   47 +-
 scripts/qapi.py |  100 +-
 scripts/qapi2texi.py|  314 
 scripts/texi2pod.pl |   44 +-
 docs/qapi-code-gen.txt  |   44 +-
 docs/qemu-ga-qapi.template.texi |   58 +
 docs/qemu-qapi.template.texi|  148 ++
 docs/qmp-commands.txt   | 3802 ---
 docs/qmp-events.txt |  719 
 docs/qmp-intro.txt  |   87 -
 qapi-schema.json| 1291 -
 qapi/block-core.json|  675 ++-
 qapi/block.json |   60 +-
 qapi/common.json|   43 +-
 qapi/crypto.json|   40 +-
 qapi/event.json |  245 +++
 qapi/rocker.json|   60 +-
 qapi/trace.json |   16 +
 qga/qapi-schema.json|4 +-
 19 files changed, 3089 insertions(+), 4708 deletions(-)
 create mode 100755 scripts/qapi2texi.py
 create mode 100644 docs/qemu-ga-qapi.template.texi
 create mode 100644 docs/qemu-qapi.template.texi
 delete mode 100644 docs/qmp-intro.txt

-- 
2.10.0




[Qemu-devel] [PATCH v2 08/11] qapi: add some sections in docs and fix

2016-09-25 Thread Marc-André Lureau
Add some more section title, and misc fixes.

Signed-off-by: Marc-André Lureau 
---
 qapi-schema.json | 3 +++
 qapi/block-core.json | 5 +++--
 qapi/block.json  | 5 +++--
 qapi/common.json | 5 +++--
 qapi/crypto.json | 4 +++-
 qapi/event.json  | 5 +
 qapi/rocker.json | 3 +++
 qapi/trace.json  | 2 ++
 8 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 250baee..9d9d410 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -66,6 +66,9 @@
 # QAPI introspection
 { 'include': 'qapi/introspect.json' }
 
+##
+# = QMP commands
+
 ##
 # @qmp_capabilities:
 #
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 06bf1d0..d69a678 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1,6 +1,7 @@
 # -*- Mode: Python -*-
-#
-# QAPI block core definitions (vm unrelated)
+
+##
+# == QAPI block core definitions (vm unrelated)
 
 # QAPI common definitions
 { 'include': 'common.json' }
diff --git a/qapi/block.json b/qapi/block.json
index b88ab3c..c26c82f 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -1,6 +1,7 @@
 # -*- Mode: Python -*-
-#
-# QAPI block definitions (vm related)
+
+##
+# = QAPI block definitions (vm related)
 
 # QAPI block core definitions
 { 'include': 'block-core.json' }
diff --git a/qapi/common.json b/qapi/common.json
index 927d621..4887430 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -1,6 +1,7 @@
 # -*- Mode: Python -*-
-#
-# QAPI common definitions
+
+##
+# = QAPI common definitions
 
 ##
 # @QapiErrorClass
diff --git a/qapi/crypto.json b/qapi/crypto.json
index 4ac3034..a22a9dc 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -1,6 +1,8 @@
 # -*- Mode: Python -*-
 #
-# QAPI crypto definitions
+
+##
+# = QAPI crypto definitions
 
 ##
 # @QCryptoTLSCredsEndpoint:
diff --git a/qapi/event.json b/qapi/event.json
index 51205b8..55b9d06 100644
--- a/qapi/event.json
+++ b/qapi/event.json
@@ -1,3 +1,8 @@
+# -*- Mode: Python -*-
+
+##
+# = Events
+
 ##
 # @SHUTDOWN
 #
diff --git a/qapi/rocker.json b/qapi/rocker.json
index 9ed233c..e986486 100644
--- a/qapi/rocker.json
+++ b/qapi/rocker.json
@@ -1,4 +1,7 @@
 ##
+# = Rocker API
+
+##
 # @Rocker:
 #
 # Rocker switch information.
diff --git a/qapi/trace.json b/qapi/trace.json
index 63410f8..770fef5 100644
--- a/qapi/trace.json
+++ b/qapi/trace.json
@@ -5,6 +5,8 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+##
+# = Tracing commands
 
 ##
 # @TraceEventState:
-- 
2.10.0




[Qemu-devel] [PATCH v2 04/11] qapi: fix @ACPI sections

2016-09-25 Thread Marc-André Lureau
This helps the doc parser.

Signed-off-by: Marc-André Lureau 
---
 qapi-schema.json | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 3091993..3ac8637 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4414,14 +4414,16 @@
 ##
 { 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] }
 
-## @ACPISlotType
+##
+# @ACPISlotType
 #
 # @DIMM: memory slot
 # @CPU: logical CPU slot (since 2.7)
 #
 { 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] }
 
-## @ACPIOSTInfo
+##
+# @ACPIOSTInfo
 #
 # OSPM Status Indication for a device
 # For description of possible values of @source and @status fields
-- 
2.10.0




[Qemu-devel] [PATCH v2 02/11] qapi: fix schema symbol sections

2016-09-25 Thread Marc-André Lureau
According to documentation, there needs to be '##' to start a symbol
section, that's also what the documentation parser expects.

Signed-off-by: Marc-André Lureau 
---
 qapi-schema.json | 9 +++--
 qapi/block-core.json | 1 +
 qga/qapi-schema.json | 3 +++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index e507061..f07ffd7 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -65,6 +65,7 @@
 { 'enum': 'LostTickPolicy',
   'data': ['discard', 'delay', 'merge', 'slew' ] }
 
+##
 # @add_client
 #
 # Allow client connections for VNC, Spice and socket based
@@ -439,6 +440,7 @@
'cache-miss': 'int', 'cache-miss-rate': 'number',
'overflow': 'int' } }
 
+##
 # @MigrationStatus:
 #
 # An enumeration of migration status.
@@ -617,6 +619,7 @@
 ##
 { 'command': 'query-migrate-capabilities', 'returns':   
['MigrationCapabilityStatus']}
 
+##
 # @MigrationParameter
 #
 # Migration parameters enumeration
@@ -665,7 +668,7 @@
'cpu-throttle-initial', 'cpu-throttle-increment',
'tls-creds', 'tls-hostname'] }
 
-#
+##
 # @migrate-set-parameters
 #
 # Set the following migration parameters
@@ -710,7 +713,7 @@
 '*tls-creds': 'str',
 '*tls-hostname': 'str'} }
 
-#
+##
 # @MigrationParameters
 #
 # @compress-level: compression level
@@ -2172,6 +2175,7 @@
 ##
 { 'command': 'migrate-incoming', 'data': {'uri': 'str' } }
 
+##
 # @xen-save-devices-state:
 #
 # Save the state of all devices to file. The RAM and the block devices
@@ -3359,6 +3363,7 @@
 'modelb': 'CpuModelInfo' },
   'returns': 'CpuModelBaselineInfo' }
 
+##
 # @AddfdInfo:
 #
 # Information about a file descriptor that was added to an fd set.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 92193ab..cf8e980 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2665,6 +2665,7 @@
 'offset': 'int',
 'speed' : 'int' } }
 
+##
 # @PreallocMode
 #
 # Preallocation mode of QEMU image file
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index c21f308..09c9728 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -837,6 +837,7 @@
 { 'command': 'guest-set-user-password',
   'data': { 'username': 'str', 'password': 'str', 'crypted': 'bool' } }
 
+##
 # @GuestMemoryBlock:
 #
 # @phys-index: Arbitrary guest-specific unique identifier of the MEMORY BLOCK.
@@ -936,6 +937,7 @@
   'data':{'mem-blks': ['GuestMemoryBlock'] },
   'returns': ['GuestMemoryBlockResponse'] }
 
+##
 # @GuestMemoryBlockInfo:
 #
 # @size: the size (in bytes) of the guest memory blocks,
@@ -960,6 +962,7 @@
 { 'command': 'guest-get-memory-block-info',
   'returns': 'GuestMemoryBlockInfo' }
 
+##
 # @GuestExecStatus:
 #
 # @exited: true if process has already terminated.
-- 
2.10.0




[Qemu-devel] [PATCH v2 06/11] build-sys: add qapi doc generation targets

2016-09-25 Thread Marc-André Lureau
Add qapi doc generation targets, qemu-qapi.texi, qemu-ga-qapi.texi
(implicit pdf works too) and qemu-qapi.txt. The generated
documentation isn't complete yet, so don't bother to build it by
default or install it yet.

Signed-off-by: Marc-André Lureau 
---
 Makefile | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/Makefile b/Makefile
index f103616..6e00559 100644
--- a/Makefile
+++ b/Makefile
@@ -269,6 +269,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
 gen-out-type = $(subst .,-,$(suffix $@))
 
 qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
+qapi-py += $(SRC_PATH)/scripts/qapi2texi.py
 
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
@@ -558,9 +559,23 @@ qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx 
$(SRC_PATH)/scripts/hxtool
 qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx 
$(SRC_PATH)/scripts/hxtool
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN  
 $@")
 
+qemu-qapi.txt: qemu-qapi.texi
+   $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --plaintext 
$< -o $@,\
+   "  GEN   $@")
+
 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN  
 $@")
 
+qemu-qapi.texi: $(qapi-modules) $(qapi-py) \
+   $(SRC_PATH)/docs/qemu-qapi.template.texi
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py \
+   $(SRC_PATH)/docs/qemu-qapi.template.texi $(VERSION) $< > $@,"  GEN   
$@")
+
+qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py) \
+   $(SRC_PATH)/docs/qemu-ga-qapi.template.texi
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py \
+   $(SRC_PATH)/docs/qemu-ga-qapi.template.texi $(VERSION) $< > $@,"  GEN   
$@")
+
 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi 
qemu-monitor-info.texi
$(call quiet-command, \
  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
-- 
2.10.0




[Qemu-devel] [PATCH v2 11/11] build-sys: make and install the generated schema docs

2016-09-25 Thread Marc-André Lureau
Signed-off-by: Marc-André Lureau 
---
 Makefile | 34 --
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 6e00559..5d8d0c3 100644
--- a/Makefile
+++ b/Makefile
@@ -94,6 +94,9 @@ HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
 
 ifdef BUILD_DOCS
 DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8
+DOCS+=docs/qemu-qapi.txt qemu-qapi.7
+DOCS+=docs/qemu-ga-qapi.txt qemu-ga-qapi.7
+DOCS+=qemu-qapi.pdf qemu-ga-qapi.pdf
 ifdef CONFIG_VIRTFS
 DOCS+=fsdev/virtfs-proxy-helper.1
 endif
@@ -400,6 +403,9 @@ distclean: clean
rm -f config.log
rm -f linux-headers/asm
rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi 
qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf 
qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr
+   rm -f qemu-qapi.info qemu-qapi.aux qemu-qapi.cp qemu-qapi.dvi 
qemu-qapi.fn qemu-qapi.info qemu-qapi.ky qemu-qapi.log qemu-qapi.pdf 
qemu-qapi.pg qemu-qapi.toc qemu-qapi.tp qemu-qapi.vr qemu-ga-qapi.info 
qemu-ga-qapi.aux qemu-ga-qapi.cp qemu-ga-qapi.dvi qemu-ga-qapi.fn 
qemu-ga-qapi.info qemu-ga-qapi.ky qemu-ga-qapi.log qemu-ga-qapi.pdf 
qemu-ga-qapi.pg qemu-ga-qapi.toc qemu-ga-qapi.tp qemu-ga-qapi.vr
+   rm -f qemu-qapi.7 qemu-ga-qapi.7
+   rm -f docs/qemu-qapi.txt
for d in $(TARGET_DIRS); do \
rm -rf $$d || exit 1 ; \
 done
@@ -436,10 +442,12 @@ endif
 install-doc: $(DOCS)
$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
$(INSTALL_DATA) qemu-doc.html  qemu-tech.html "$(DESTDIR)$(qemu_docdir)"
-   $(INSTALL_DATA) $(SRC_PATH)/docs/qmp-commands.txt 
"$(DESTDIR)$(qemu_docdir)"
+   $(INSTALL_DATA) docs/qemu-qapi.txt "$(DESTDIR)$(qemu_docdir)"
 ifdef CONFIG_POSIX
$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
$(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
+   $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
+   $(INSTALL_DATA) qemu-qapi.7 "$(DESTDIR)$(mandir)/man7"
 ifneq ($(TOOLS),)
$(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
@@ -447,6 +455,8 @@ ifneq ($(TOOLS),)
 endif
 ifneq (,$(findstring qemu-ga,$(TOOLS)))
$(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
+   $(INSTALL_DATA) docs/qemu-ga-qapi.txt "$(DESTDIR)$(qemu_docdir)"
+   $(INSTALL_DATA) qemu-ga-qapi.7 "$(DESTDIR)$(mandir)/man7"
 endif
 endif
 ifdef CONFIG_VIRTFS
@@ -559,7 +569,7 @@ qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx 
$(SRC_PATH)/scripts/hxtool
 qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx 
$(SRC_PATH)/scripts/hxtool
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN  
 $@")
 
-qemu-qapi.txt: qemu-qapi.texi
+docs/%-qapi.txt: %-qapi.texi
$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --plaintext 
$< -o $@,\
"  GEN   $@")
 
@@ -607,10 +617,22 @@ qemu-ga.8: qemu-ga.texi
  $(POD2MAN) --section=8 --center=" " --release=" " qemu-ga.pod > $@, \
  "  GEN   $@")
 
-dvi: qemu-doc.dvi qemu-tech.dvi
-html: qemu-doc.html qemu-tech.html
-info: qemu-doc.info qemu-tech.info
-pdf: qemu-doc.pdf qemu-tech.pdf
+qemu-qapi.7: qemu-qapi.texi
+   $(call quiet-command, \
+perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-qapi.pod && \
+$(POD2MAN) --section=7 --center=" " --release=" " qemu-qapi.pod > $@, \
+"  GEN   $@")
+
+qemu-ga-qapi.7: qemu-ga-qapi.texi
+   $(call quiet-command, \
+perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-ga-qapi.pod && \
+$(POD2MAN) --section=7 --center=" " --release=" " qemu-ga-qapi.pod > 
$@, \
+"  GEN   $@")
+
+dvi: qemu-doc.dvi qemu-tech.dvi qemu-qapi.dvi qemu-ga-qapi.dvi
+html: qemu-doc.html qemu-tech.html qemu-qapi.html qemu-ga-qapi.html
+info: qemu-doc.info qemu-tech.info qemu-qapi.info qemu-ga-qapi.info
+pdf: qemu-doc.pdf qemu-tech.pdf qemu-qapi.pdf qemu-ga-qapi.pdf
 
 qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-option-trace.texi \
-- 
2.10.0




[Qemu-devel] [PATCH v2 05/11] docs: add qapi texi template

2016-09-25 Thread Marc-André Lureau
The qapi2texi scripts uses a template for the texi file. Since we are
going to generate the documentation in multiple formats, move qmp-intro
to qemu-qapi template. (it would be nice to write something similar for
qemu-ga, but this is left for a future patch)

Signed-off-by: Marc-André Lureau 
---
 docs/qemu-ga-qapi.template.texi |  58 
 docs/qemu-qapi.template.texi| 148 
 docs/qmp-intro.txt  |  87 ---
 3 files changed, 206 insertions(+), 87 deletions(-)
 create mode 100644 docs/qemu-ga-qapi.template.texi
 create mode 100644 docs/qemu-qapi.template.texi
 delete mode 100644 docs/qmp-intro.txt

diff --git a/docs/qemu-ga-qapi.template.texi b/docs/qemu-ga-qapi.template.texi
new file mode 100644
index 000..3ddbf56
--- /dev/null
+++ b/docs/qemu-ga-qapi.template.texi
@@ -0,0 +1,58 @@
+\input texinfo
+@setfilename qemu-ga-qapi
+@documentlanguage en
+@exampleindent 0
+@paragraphindent 0
+
+@settitle QEMU-GA QAPI Reference Manual
+
+@ifinfo
+@direntry
+* QEMU-GA-QAPI: (qemu-doc).QEMU-GA QAPI Reference Manual
+@end direntry
+@end ifinfo
+
+@iftex
+@titlepage
+@sp 7
+@center @titlefont{{QEMU Guest Agent {version}}}
+@sp 1
+@center @titlefont{{QAPI Reference Manual}}
+@sp 3
+@end titlepage
+@end iftex
+
+@ifnottex
+@node Top
+@top
+
+This is the QEMU Guest Agent QAPI reference for QEMU {version}.
+
+@menu
+* API Reference::
+* Commands and Events Index::
+* Data Types Index::
+@end menu
+
+@end ifnottex
+
+@contents
+
+@node API Reference
+@chapter API Reference
+
+@c man begin DESCRIPTION
+{qapi}
+@c man end
+
+@c man begin SEEALSO
+The HTML documentation of QEMU for more precise information.
+@c man end
+
+@node Commands and Events Index
+@unnumbered Commands and Events Index
+@printindex fn
+@node Data Types Index
+@unnumbered Data Types Index
+@printindex tp
+@bye
diff --git a/docs/qemu-qapi.template.texi b/docs/qemu-qapi.template.texi
new file mode 100644
index 000..102c8d9
--- /dev/null
+++ b/docs/qemu-qapi.template.texi
@@ -0,0 +1,148 @@
+\input texinfo
+@setfilename qemu-qapi
+@documentlanguage en
+@exampleindent 0
+@paragraphindent 0
+
+@settitle QEMU QAPI Reference Manual
+
+@ifinfo
+@direntry
+* QEMU: (qemu-doc).QEMU QAPI Reference Manual
+@end direntry
+@end ifinfo
+
+@iftex
+@titlepage
+@sp 7
+@center @titlefont{{QEMU Emulator {version}}}
+@sp 1
+@center @titlefont{{QAPI Reference Manual}}
+@sp 3
+@end titlepage
+@end iftex
+
+@ifnottex
+@node Top
+@top
+
+This is the QMP QAPI reference for QEMU {version}.
+
+@menu
+* Introduction::
+* API Reference::
+* Commands and Events Index::
+* Data Types Index::
+@end menu
+
+@end ifnottex
+
+@contents
+
+@node Introduction
+@chapter Introduction
+
+The QEMU Machine Protocol (@acronym{{QMP}}) allows applications to
+operate a QEMU instance.
+
+QMP is @uref{{http://www.json.org, JSON}} based and features the
+following:
+
+@itemize @minus
+@item
+Lightweight, text-based, easy to parse data format
+@item
+Asynchronous messages support (ie. events)
+@item
+Capabilities Negotiation
+@end itemize
+
+For detailed information on QEMU Machine Protocol, the specification
+is in @file{{qmp-spec.txt}}.
+
+@section Usage
+
+You can use the @option{{-qmp}} option to enable QMP. For example, the
+following makes QMP available on localhost port :
+
+@example
+$ qemu [...] -qmp tcp:localhost:,server,nowait
+@end example
+
+However, for more flexibility and to make use of more options, the
+@option{{-mon}} command-line option should be used. For instance, the
+following example creates one HMP instance (human monitor) on stdio
+and one QMP instance on localhost port :
+
+@example
+$ qemu [...] -chardev stdio,id=mon0 -mon chardev=mon0,mode=readline \
+ -chardev socket,id=mon1,host=localhost,port=,server,nowait \
+ -mon chardev=mon1,mode=control,pretty=on
+@end example
+
+Please, refer to QEMU's manpage for more information.
+
+@section Simple testing
+
+To manually test QMP one can connect with telnet and issue commands by
+hand:
+
+@example
+$ telnet localhost 
+Trying 127.0.0.1...
+Connected to localhost.
+Escape character is '^]'.
+@{{
+"QMP": @{{
+"version": @{{
+"qemu": @{{
+"micro": 50,
+"minor": 6,
+"major": 1
+@}},
+"package": ""
+@}},
+"capabilities": [
+]
+@}}
+@}}
+
+@{{ "execute": "qmp_capabilities" @}}
+@{{
+"return": @{{
+@}}
+@}}
+
+@{{ "execute": "query-status" @}}
+@{{
+"return": @{{
+"status": "prelaunch",
+"singlestep": false,
+"running": false
+@}}
+@}}
+@end example
+
+@section Wiki
+
+Please refer to the @uref{{http://wiki.qemu-project.org/QMP, QMP QEMU
+ wiki page}} for more details on QMP.
+
+@node API Reference
+@chapter API Reference
+
+@c man begin DESCRIPTION
+{qapi}
+@c man end
+
+@c man begin SEEALSO
+The HTML documentation of QEMU for more pr

[Qemu-devel] [PATCH v2 03/11] qapi: fix missing symbol @prefix

2016-09-25 Thread Marc-André Lureau
Signed-off-by: Marc-André Lureau 
---
 qapi-schema.json |  4 ++--
 qapi/block-core.json |  4 ++--
 qapi/crypto.json | 36 ++--
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index f07ffd7..3091993 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4526,7 +4526,7 @@
 { 'include': 'qapi/rocker.json' }
 
 ##
-# ReplayMode:
+# @ReplayMode:
 #
 # Mode of the replay subsystem.
 #
@@ -4594,7 +4594,7 @@
 { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] }
 
 ##
-# CpuInstanceProperties
+# @CpuInstanceProperties
 #
 # List of properties to be used for hotplugging a CPU instance,
 # it should be passed by management with device_add command when
diff --git a/qapi/block-core.json b/qapi/block-core.json
index cf8e980..73f4180 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1149,7 +1149,7 @@
   'data': 'DriveMirror' }
 
 ##
-# DriveMirror
+# @DriveMirror
 #
 # A set of parameters describing drive mirror setup.
 #
@@ -1373,7 +1373,7 @@
   'data': 'BlockIOThrottle' }
 
 ##
-# BlockIOThrottle
+# @BlockIOThrottle
 #
 # A set of parameters describing block throttling.
 #
diff --git a/qapi/crypto.json b/qapi/crypto.json
index 6933b13..4ac3034 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -3,7 +3,7 @@
 # QAPI crypto definitions
 
 ##
-# QCryptoTLSCredsEndpoint:
+# @QCryptoTLSCredsEndpoint:
 #
 # The type of network endpoint that will be using the credentials.
 # Most types of credential require different setup / structures
@@ -22,7 +22,7 @@
 
 
 ##
-# QCryptoSecretFormat:
+# @QCryptoSecretFormat:
 #
 # The data format that the secret is provided in
 #
@@ -36,7 +36,7 @@
 
 
 ##
-# QCryptoHashAlgorithm:
+# @QCryptoHashAlgorithm:
 #
 # The supported algorithms for computing content digests
 #
@@ -55,7 +55,7 @@
 
 
 ##
-# QCryptoCipherAlgorithm:
+# @QCryptoCipherAlgorithm:
 #
 # The supported algorithms for content encryption ciphers
 #
@@ -82,7 +82,7 @@
 
 
 ##
-# QCryptoCipherMode:
+# @QCryptoCipherMode:
 #
 # The supported modes for content encryption ciphers
 #
@@ -97,7 +97,7 @@
 
 
 ##
-# QCryptoIVGenAlgorithm:
+# @QCryptoIVGenAlgorithm:
 #
 # The supported algorithms for generating initialization
 # vectors for full disk encryption. The 'plain' generator
@@ -115,7 +115,7 @@
   'data': ['plain', 'plain64', 'essiv']}
 
 ##
-# QCryptoBlockFormat:
+# @QCryptoBlockFormat:
 #
 # The supported full disk encryption formats
 #
@@ -130,7 +130,7 @@
   'data': ['qcow', 'luks']}
 
 ##
-# QCryptoBlockOptionsBase:
+# @QCryptoBlockOptionsBase:
 #
 # The common options that apply to all full disk
 # encryption formats
@@ -143,7 +143,7 @@
   'data': { 'format': 'QCryptoBlockFormat' }}
 
 ##
-# QCryptoBlockOptionsQCow:
+# @QCryptoBlockOptionsQCow:
 #
 # The options that apply to QCow/QCow2 AES-CBC encryption format
 #
@@ -157,7 +157,7 @@
   'data': { '*key-secret': 'str' }}
 
 ##
-# QCryptoBlockOptionsLUKS:
+# @QCryptoBlockOptionsLUKS:
 #
 # The options that apply to LUKS encryption format
 #
@@ -171,7 +171,7 @@
 
 
 ##
-# QCryptoBlockCreateOptionsLUKS:
+# @QCryptoBlockCreateOptionsLUKS:
 #
 # The options that apply to LUKS encryption format initialization
 #
@@ -201,7 +201,7 @@
 
 
 ##
-# QCryptoBlockOpenOptions:
+# @QCryptoBlockOpenOptions:
 #
 # The options that are available for all encryption formats
 # when opening an existing volume
@@ -216,7 +216,7 @@
 
 
 ##
-# QCryptoBlockCreateOptions:
+# @QCryptoBlockCreateOptions:
 #
 # The options that are available for all encryption formats
 # when initializing a new volume
@@ -231,7 +231,7 @@
 
 
 ##
-# QCryptoBlockInfoBase:
+# @QCryptoBlockInfoBase:
 #
 # The common information that applies to all full disk
 # encryption formats
@@ -245,7 +245,7 @@
 
 
 ##
-# QCryptoBlockInfoLUKSSlot:
+# @QCryptoBlockInfoLUKSSlot:
 #
 # Information about the LUKS block encryption key
 # slot options
@@ -265,7 +265,7 @@
 
 
 ##
-# QCryptoBlockInfoLUKS:
+# @QCryptoBlockInfoLUKS:
 #
 # Information about the LUKS block encryption options
 #
@@ -293,7 +293,7 @@
'slots': [ 'QCryptoBlockInfoLUKSSlot' ] }}
 
 ##
-# QCryptoBlockInfoQCow:
+# @QCryptoBlockInfoQCow:
 #
 # Information about the QCow block encryption options
 #
@@ -304,7 +304,7 @@
 
 
 ##
-# QCryptoBlockInfo:
+# @QCryptoBlockInfo:
 #
 # Information about the block encryption options
 #
-- 
2.10.0




[Qemu-devel] [PATCH v2 09/11] qga: fix guest-get-memory-block-info doc

2016-09-25 Thread Marc-André Lureau
Signed-off-by: Marc-André Lureau 
---
 qga/qapi-schema.json | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 09c9728..7a35267 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -954,7 +954,6 @@
 #
 # Get information relating to guest memory blocks.
 #
-# Returns: memory block size in bytes.
 # Returns: @GuestMemoryBlockInfo
 #
 # Since 2.3
-- 
2.10.0




[Qemu-devel] [PATCH v2 10/11] texi2pod: learn quotation, deftp and deftypefn

2016-09-25 Thread Marc-André Lureau
Learn a few more markups used for API documentation.

Signed-off-by: Marc-André Lureau 
---
 scripts/texi2pod.pl | 44 +++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/scripts/texi2pod.pl b/scripts/texi2pod.pl
index 8767662..5df4b5f 100755
--- a/scripts/texi2pod.pl
+++ b/scripts/texi2pod.pl
@@ -37,6 +37,7 @@ $inf = "";
 $ibase = "";
 @ipath = ();
 $encoding = undef;
+@args = ();
 
 while ($_ = shift) {
 if (/^-D(.*)$/) {
@@ -162,7 +163,8 @@ while(<$inf>) {
if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) {
$skipping = pop @skstack;
next;
-   } elsif ($ended =~ /^(?:example|smallexample|display)$/) {
+   } elsif ($ended =~ /^(?:example|smallexample|display
+|quotation|deftp|deftypefn)$/x) {
$shift = "";
$_ = "";# need a paragraph break
} elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
@@ -323,6 +325,46 @@ while(<$inf>) {
$_ = "\n=item ".join (" : ", @columns)."\n";
 };
 
+/^\@(quotation)\s*(.+)?$/ and do {
+push @endwstack, $endw;
+$endw = $1;
+$_ = "\n$2:"
+};
+
+/^{(.*)}$|^(.*)$/ and $#args > 0 and do {
+$kind = $args[0];
+$arguments = $1 // "";
+if ($endw eq "deftypefn") {
+$ret = $args[1];
+$fname = "B<$args[2]>";
+$_ = $ret ? "$ret " : "";
+$_ .= "$fname $arguments ($kind)";
+} else {
+$_ = "B<$args[1]> ($kind)\n\n$arguments";
+}
+@args = ();
+};
+
+/^\@(deftp)\s*(.+)?$/ and do {
+push @endwstack, $endw;
+$endw = $1;
+$arg = $2;
+$arg =~ s/{([^}]*)}/$1/g;
+$arg =~ s/\@$//;
+@args = split (/ /, $arg);
+$_ = "";
+};
+
+/^\@(deftypefn)\s*(.+)?$/ and do {
+push @endwstack, $endw;
+$endw = $1;
+$arg = $2;
+$arg =~ s/{([^}]*)}/$1/g;
+$arg =~ s/\@$//;
+@args = split (/ /, $arg);
+$_ = "";
+};
+
 /^\@itemx?\s*(.+)?$/ and do {
if (defined $1) {
# Entity escapes prevent munging by the <> processing below.
-- 
2.10.0




[Qemu-devel] [PATCH 4/6] intc/lm32_pic: implement IntCtrl interface

2016-09-25 Thread Hervé Poussineau
We have to change the vmstate version due to changes in statistics counters.

Signed-off-by: Hervé Poussineau 
---
 hw/intc/lm32_pic.c | 32 
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/hw/intc/lm32_pic.c b/hw/intc/lm32_pic.c
index 3dad01c..411bf67 100644
--- a/hw/intc/lm32_pic.c
+++ b/hw/intc/lm32_pic.c
@@ -25,6 +25,7 @@
 #include "hw/sysbus.h"
 #include "trace.h"
 #include "hw/lm32/lm32_pic.h"
+#include "hw/intc/intc.h"
 
 #define TYPE_LM32_PIC "lm32-pic"
 #define LM32_PIC(obj) OBJECT_CHECK(LM32PicState, (obj), TYPE_LM32_PIC)
@@ -38,7 +39,7 @@ struct LM32PicState {
 uint32_t irq_state;
 
 /* statistics */
-uint32_t stats_irq_count[32];
+uint64_t stats_irq_count[32];
 };
 typedef struct LM32PicState LM32PicState;
 
@@ -152,6 +153,22 @@ static void pic_reset(DeviceState *d)
 }
 }
 
+static bool lm32_get_statistics(IntCtrl *obj, uint64_t **irq_counts,
+unsigned int *nb_irqs)
+{
+LM32PicState *s = LM32_PIC(obj);
+*irq_counts = s->stats_irq_count;
+*nb_irqs = ARRAY_SIZE(s->stats_irq_count);
+return true;
+}
+
+static void lm32_print_info(IntCtrl *obj, Monitor *mon)
+{
+LM32PicState *s = LM32_PIC(obj);
+monitor_printf(mon, "lm32-pic: im=%08x ip=%08x irq_state=%08x\n",
+s->im, s->ip, s->irq_state);
+}
+
 static void lm32_pic_init(Object *obj)
 {
 DeviceState *dev = DEVICE(obj);
@@ -166,13 +183,13 @@ static void lm32_pic_init(Object *obj)
 
 static const VMStateDescription vmstate_lm32_pic = {
 .name = "lm32-pic",
-.version_id = 1,
-.minimum_version_id = 1,
+.version_id = 2,
+.minimum_version_id = 2,
 .fields = (VMStateField[]) {
 VMSTATE_UINT32(im, LM32PicState),
 VMSTATE_UINT32(ip, LM32PicState),
 VMSTATE_UINT32(irq_state, LM32PicState),
-VMSTATE_UINT32_ARRAY(stats_irq_count, LM32PicState, 32),
+VMSTATE_UINT64_ARRAY(stats_irq_count, LM32PicState, 32),
 VMSTATE_END_OF_LIST()
 }
 };
@@ -180,9 +197,12 @@ static const VMStateDescription vmstate_lm32_pic = {
 static void lm32_pic_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
+IntCtrlClass *ic = INTCTRL_CLASS(klass);
 
 dc->reset = pic_reset;
 dc->vmsd = &vmstate_lm32_pic;
+ic->get_statistics = lm32_get_statistics;
+ic->print_info = lm32_print_info;
 }
 
 static const TypeInfo lm32_pic_info = {
@@ -191,6 +211,10 @@ static const TypeInfo lm32_pic_info = {
 .instance_size = sizeof(LM32PicState),
 .instance_init = lm32_pic_init,
 .class_init= lm32_pic_class_init,
+.interfaces = (InterfaceInfo[]) {
+{ TYPE_INTCTRL },
+{ }
+},
 };
 
 static void lm32_pic_register_types(void)
-- 
2.1.4




[Qemu-devel] [PATCH 6/6] intc: make HMP 'info irq' and 'info pic' commands available on all targets

2016-09-25 Thread Hervé Poussineau
Signed-off-by: Hervé Poussineau 
---
 hmp-commands-info.hx | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 6a7c476..55d50c4 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -172,8 +172,6 @@ STEXI
 Show the command line history.
 ETEXI
 
-#if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_MIPS) || \
-defined(TARGET_LM32) || (defined(TARGET_SPARC) && !defined(TARGET_SPARC64))
 {
 .name   = "irq",
 .args_type  = "",
@@ -192,10 +190,9 @@ ETEXI
 .name   = "pic",
 .args_type  = "",
 .params = "",
-.help   = "show i8259 (PIC) state",
+.help   = "show PIC state",
 .cmd= hmp_info_pic,
 },
-#endif
 
 STEXI
 @item info pic
-- 
2.1.4




[Qemu-devel] [PATCH 3/6] intc/slavio_intctl: implement IntCtrl interface

2016-09-25 Thread Hervé Poussineau
Signed-off-by: Hervé Poussineau 
---
 hw/intc/slavio_intctl.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/hw/intc/slavio_intctl.c b/hw/intc/slavio_intctl.c
index e82e893..6caa414 100644
--- a/hw/intc/slavio_intctl.c
+++ b/hw/intc/slavio_intctl.c
@@ -26,6 +26,7 @@
 #include "hw/sparc/sun4m.h"
 #include "monitor/monitor.h"
 #include "hw/sysbus.h"
+#include "hw/intc/intc.h"
 #include "trace.h"
 
 //#define DEBUG_IRQ_COUNT
@@ -418,6 +419,31 @@ static void slavio_intctl_reset(DeviceState *d)
 slavio_check_interrupts(s, 0);
 }
 
+#ifdef DEBUG_IRQ_COUNT
+static bool slavio_intctl_get_statistics(IntCtrl *obj,
+ uint64_t **irq_counts,
+ unsigned int *nb_irqs)
+{
+SLAVIO_INTCTLState *s = SLAVIO_INTCTL(obj);
+*irq_counts = s->irq_count;
+*nb_irqs = ARRAY_SIZE(s->irq_count);
+return true;
+}
+#endif
+
+static void slavio_intctl_print_info(IntCtrl *obj, Monitor *mon)
+{
+SLAVIO_INTCTLState *s = SLAVIO_INTCTL(obj);
+int i;
+
+for (i = 0; i < MAX_CPUS; i++) {
+monitor_printf(mon, "per-cpu %d: pending 0x%08x\n", i,
+   s->slaves[i].intreg_pending);
+}
+monitor_printf(mon, "master: pending 0x%08x, disabled 0x%08x\n",
+   s->intregm_pending, s->intregm_disabled);
+}
+
 static void slavio_intctl_init(Object *obj)
 {
 DeviceState *dev = DEVICE(obj);
@@ -449,9 +475,14 @@ static void slavio_intctl_init(Object *obj)
 static void slavio_intctl_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
+IntCtrlClass *ic = INTCTRL_CLASS(klass);
 
 dc->reset = slavio_intctl_reset;
 dc->vmsd = &vmstate_intctl;
+#ifdef DEBUG_IRQ_COUNT
+ic->get_statistics = slavio_intctl_get_statistics;
+#endif
+ic->print_info = slavio_intctl_print_info;
 }
 
 static const TypeInfo slavio_intctl_info = {
@@ -460,6 +491,10 @@ static const TypeInfo slavio_intctl_info = {
 .instance_size = sizeof(SLAVIO_INTCTLState),
 .instance_init = slavio_intctl_init,
 .class_init= slavio_intctl_class_init,
+.interfaces = (InterfaceInfo[]) {
+{ TYPE_INTCTRL },
+{ }
+},
 };
 
 static void slavio_intctl_register_types(void)
-- 
2.1.4




[Qemu-devel] [PATCH 0/6] intc: change 'info irq' and 'info pic' to be target-agnostic

2016-09-25 Thread Hervé Poussineau
Hi,

This patchset aims at genericizing the 'info irq' and 'info pic' HMP commands, 
so
that it is available on all machines and can display details about more than one
interrupt controller per machine.

Patch 1 adds a new interface IntCtrl, which is used to:
- gather statistics for the 'info irq' command
- print some text when 'info pic' is called

Patches 2 to 4 implement IntCtrl interface on interrupt controllers which have
ad-hock code to handle 'info irq'/'info pic' commands.

Patch 5 removes ad-hock code, and replaces it by a generic version. You can get
details about multiple interrupt controllers per machine starting here.

Patch 6 makes 'info irq'/'info pic' commands available on all architectures.
For example, Alpha clipper machine is now able to display details about the
i8259 interrupt controller.

Hervé

Hervé Poussineau (6):
  intc: add an interface to gather statistics/informations on interrupt
controllers
  intc/i8259: implement IntCtrl interface
  intc/slavio_intctl: implement IntCtrl interface
  intc/lm32_pic: implement IntCtrl interface
  intc: make HMP 'info irq' and 'info pic' commands use IntCtrl
interface instead of ad-hock code
  intc: make HMP 'info irq' and 'info pic' commands available on all
targets

 hmp-commands-info.hx   | 17 +--
 hmp.c  | 61 ++
 hmp.h  |  2 ++
 hw/intc/Makefile.objs  |  1 +
 hw/intc/i8259.c| 73 +++---
 hw/intc/intc.c | 41 ++
 hw/intc/lm32_pic.c | 63 ++-
 hw/intc/slavio_intctl.c| 67 ++
 hw/sparc/sun4m.c   | 15 +-
 include/hw/i386/pc.h   |  2 --
 include/hw/intc/intc.h | 27 +
 include/hw/lm32/lm32_pic.h |  3 --
 include/hw/sparc/sun4m.h   |  8 -
 monitor.c  |  6 
 14 files changed, 234 insertions(+), 152 deletions(-)
 create mode 100644 hw/intc/intc.c
 create mode 100644 include/hw/intc/intc.h

-- 
2.1.4




[Qemu-devel] [PATCH 1/6] intc: add an interface to gather statistics/informations on interrupt controllers

2016-09-25 Thread Hervé Poussineau
This interface will be used by HMP commands 'info irq' and 'info pic'.

Signed-off-by: Hervé Poussineau 
---
 hw/intc/Makefile.objs  |  1 +
 hw/intc/intc.c | 41 +
 include/hw/intc/intc.h | 27 +++
 3 files changed, 69 insertions(+)
 create mode 100644 hw/intc/intc.c
 create mode 100644 include/hw/intc/intc.h

diff --git a/hw/intc/Makefile.objs b/hw/intc/Makefile.objs
index 05ec21b..f24c837 100644
--- a/hw/intc/Makefile.objs
+++ b/hw/intc/Makefile.objs
@@ -17,6 +17,7 @@ common-obj-$(CONFIG_ARM_GIC) += arm_gicv3.o
 common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_dist.o
 common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_redist.o
 common-obj-$(CONFIG_OPENPIC) += openpic.o
+common-obj-y += intc.o
 
 obj-$(CONFIG_APIC) += apic.o apic_common.o
 obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o
diff --git a/hw/intc/intc.c b/hw/intc/intc.c
new file mode 100644
index 000..1ac0585
--- /dev/null
+++ b/hw/intc/intc.c
@@ -0,0 +1,41 @@
+/*
+ * QEMU Generic Interrupt Controller
+ *
+ * Copyright (c) 2016 Hervé Poussineau
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/intc/intc.h"
+#include "qemu/module.h"
+
+static const TypeInfo intctrl_info = {
+.name = TYPE_INTCTRL,
+.parent = TYPE_INTERFACE,
+.class_size = sizeof(IntCtrlClass),
+};
+
+static void intc_register_types(void)
+{
+type_register_static(&intctrl_info);
+}
+
+type_init(intc_register_types)
+
diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h
new file mode 100644
index 000..7602bf9
--- /dev/null
+++ b/include/hw/intc/intc.h
@@ -0,0 +1,27 @@
+#ifndef INTC_H
+#define INTC_H
+
+#include "qom/object.h"
+
+#define TYPE_INTCTRL "intctrl"
+
+#define INTCTRL_CLASS(klass) \
+OBJECT_CLASS_CHECK(IntCtrlClass, (klass), TYPE_INTCTRL)
+#define INTCTRL_GET_CLASS(obj) \
+OBJECT_GET_CLASS(IntCtrlClass, (obj), TYPE_INTCTRL)
+#define INTCTRL(obj) \
+INTERFACE_CHECK(IntCtrl, (obj), TYPE_INTCTRL)
+
+typedef struct IntCtrl {
+Object parent;
+} IntCtrl;
+
+typedef struct IntCtrlClass {
+InterfaceClass parent;
+
+bool (*get_statistics)(IntCtrl *obj, uint64_t **irq_counts,
+   unsigned int *nb_irqs);
+void (*print_info)(IntCtrl *obj, Monitor *mon);
+} IntCtrlClass;
+
+#endif
-- 
2.1.4




[Qemu-devel] [PATCH 2/6] intc/i8259: implement IntCtrl interface

2016-09-25 Thread Hervé Poussineau
Signed-off-by: Hervé Poussineau 
---
 hw/intc/i8259.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index c2607a5..c778b5d 100644
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -29,6 +29,7 @@
 #include "qemu/timer.h"
 #include "qemu/log.h"
 #include "hw/isa/i8259_internal.h"
+#include "hw/intc/intc.h"
 
 /* debug PIC */
 //#define DEBUG_PIC
@@ -251,6 +252,35 @@ static void pic_reset(DeviceState *dev)
 pic_init_reset(s);
 }
 
+static bool pic_get_statistics(IntCtrl *obj, uint64_t **irq_counts,
+   unsigned int *nb_irqs)
+{
+PICCommonState *s = PIC_COMMON(obj);
+
+if (s->master) {
+#ifdef DEBUG_IRQ_COUNT
+*irq_counts = irq_count;
+*nb_irqs = ARRAY_SIZE(irq_count);
+#else
+return false;
+#endif
+} else {
+*irq_counts = NULL;
+*nb_irqs = 0;
+}
+return true;
+}
+
+static void pic_print_info(IntCtrl *obj, Monitor *mon)
+{
+PICCommonState *s = PIC_COMMON(obj);
+monitor_printf(mon, "pic%d: irr=%02x imr=%02x isr=%02x hprio=%d "
+   "irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n",
+   s->master ? 0 : 1, s->irr, s->imr, s->isr, s->priority_add,
+   s->irq_base, s->read_reg_select, s->elcr,
+   s->special_fully_nested_mode);
+}
+
 static void pic_ioport_write(void *opaque, hwaddr addr64,
  uint64_t val64, unsigned size)
 {
@@ -503,10 +533,13 @@ static void i8259_class_init(ObjectClass *klass, void 
*data)
 {
 PICClass *k = PIC_CLASS(klass);
 DeviceClass *dc = DEVICE_CLASS(klass);
+IntCtrlClass *ic = INTCTRL_CLASS(klass);
 
 k->parent_realize = dc->realize;
 dc->realize = pic_realize;
 dc->reset = pic_reset;
+ic->get_statistics = pic_get_statistics;
+ic->print_info = pic_print_info;
 }
 
 static const TypeInfo i8259_info = {
@@ -515,6 +548,10 @@ static const TypeInfo i8259_info = {
 .parent = TYPE_PIC_COMMON,
 .class_init = i8259_class_init,
 .class_size = sizeof(PICClass),
+.interfaces = (InterfaceInfo[]) {
+{ TYPE_INTCTRL },
+{ }
+},
 };
 
 static void pic_register_types(void)
-- 
2.1.4




[Qemu-devel] [PATCH 5/6] intc: make HMP 'info irq' and 'info pic' commands use IntCtrl interface instead of ad-hock code

2016-09-25 Thread Hervé Poussineau
Signed-off-by: Hervé Poussineau 
---
 hmp-commands-info.hx   | 12 -
 hmp.c  | 61 ++
 hmp.h  |  2 ++
 hw/intc/i8259.c| 36 ---
 hw/intc/lm32_pic.c | 31 ---
 hw/intc/slavio_intctl.c| 32 
 hw/sparc/sun4m.c   | 15 +---
 include/hw/i386/pc.h   |  2 --
 include/hw/lm32/lm32_pic.h |  3 ---
 include/hw/sparc/sun4m.h   |  8 --
 monitor.c  |  6 -
 11 files changed, 64 insertions(+), 144 deletions(-)

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 19729e5..6a7c476 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -179,13 +179,7 @@ ETEXI
 .args_type  = "",
 .params = "",
 .help   = "show the interrupts statistics (if available)",
-#ifdef TARGET_SPARC
-.cmd= sun4m_hmp_info_irq,
-#elif defined(TARGET_LM32)
-.cmd= lm32_hmp_info_irq,
-#else
 .cmd= hmp_info_irq,
-#endif
 },
 
 STEXI
@@ -199,13 +193,7 @@ ETEXI
 .args_type  = "",
 .params = "",
 .help   = "show i8259 (PIC) state",
-#ifdef TARGET_SPARC
-.cmd= sun4m_hmp_info_pic,
-#elif defined(TARGET_LM32)
-.cmd= lm32_hmp_info_pic,
-#else
 .cmd= hmp_info_pic,
-#endif
 },
 #endif
 
diff --git a/hmp.c b/hmp.c
index 336e7bf..11c7016 100644
--- a/hmp.c
+++ b/hmp.c
@@ -36,6 +36,7 @@
 #include "qemu-io.h"
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
+#include "hw/intc/intc.h"
 
 #ifdef CONFIG_SPICE
 #include 
@@ -787,6 +788,66 @@ static void hmp_info_pci_device(Monitor *mon, const 
PciDeviceInfo *dev)
 }
 }
 
+static int hmp_info_irq_foreach(Object *obj, void *opaque)
+{
+IntCtrl *intc = INTCTRL(object_dynamic_cast(obj, TYPE_INTCTRL));
+Monitor *mon = opaque;
+
+if (intc) {
+IntCtrlClass *k = INTCTRL_GET_CLASS(obj);
+uint64_t *irq_counts;
+unsigned int nb_irqs, i;
+if (k->get_statistics &&
+k->get_statistics(intc, &irq_counts, &nb_irqs)) {
+if (nb_irqs > 0) {
+monitor_printf(mon, "IRQ statistics for %s:\n",
+   object_get_typename(obj));
+for (i = 0; i < nb_irqs; i++) {
+if (irq_counts[i] > 0) {
+monitor_printf(mon, "%2d: %" PRId64 "\n", i,
+   irq_counts[i]);
+}
+}
+}
+} else {
+monitor_printf(mon, "IRQ statistics not available for %s.\n",
+   object_get_typename(obj));
+}
+}
+
+return 0;
+}
+
+void hmp_info_irq(Monitor *mon, const QDict *qdict)
+{
+object_child_foreach_recursive(object_get_root(),
+   hmp_info_irq_foreach, mon);
+}
+
+static int hmp_info_pic_foreach(Object *obj, void *opaque)
+{
+IntCtrl *intc = INTCTRL(object_dynamic_cast(obj, TYPE_INTCTRL));
+Monitor *mon = opaque;
+
+if (intc) {
+IntCtrlClass *k = INTCTRL_GET_CLASS(obj);
+if (k->print_info) {
+k->print_info(intc, mon);
+} else {
+monitor_printf(mon, "PIC informations not available for %s.\n",
+   object_get_typename(obj));
+}
+}
+
+return 0;
+}
+
+void hmp_info_pic(Monitor *mon, const QDict *qdict)
+{
+object_child_foreach_recursive(object_get_root(),
+   hmp_info_pic_foreach, mon);
+}
+
 void hmp_info_pci(Monitor *mon, const QDict *qdict)
 {
 PciInfoList *info_list, *info;
diff --git a/hmp.h b/hmp.h
index 0876ec0..184769c 100644
--- a/hmp.h
+++ b/hmp.h
@@ -36,6 +36,8 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
 void hmp_info_vnc(Monitor *mon, const QDict *qdict);
 void hmp_info_spice(Monitor *mon, const QDict *qdict);
 void hmp_info_balloon(Monitor *mon, const QDict *qdict);
+void hmp_info_irq(Monitor *mon, const QDict *qdict);
+void hmp_info_pic(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index c778b5d..44c32ac 100644
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -461,42 +461,6 @@ static void pic_realize(DeviceState *dev, Error **errp)
 pc->parent_realize(dev, errp);
 }
 
-void hmp_info_pic(Monitor *mon, const QDict *qdict)
-{
-int i;
-PICCommonState *s;
-
-if (!isa_pic) {
-return;
-}
-for (i = 0; i < 2; i++) {
-s = i == 0 ? PIC_COMMON(isa_pic) : slave_pic;
-monitor_printf(mon, "pic%d: irr=%02x imr=%02x isr=%02x hprio=%d "
-   "irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n",
-   i, 

Re: [Qemu-devel] [PATCH] hw/arm: Fix Integrator/CP memsz initialization

2016-09-25 Thread Jakub Jermář
On 09/20/2016 07:34 PM, Peter Maydell wrote:
> On 19 September 2016 at 20:54, Jakub Jermář  wrote:
>>
>> * Do not assume memsz is already initialized in integratorcm_init
>> * Calculate memsz directly from MachineState
>> * Get rid of the now unused memsz property
>>
>> Signed-off-by: Jakub Jermar 
> 
> Thanks for this patch; this is definitely a bug but I think
> this is not the best way to fix it.
> 
> What we should do is add a realize function to the IntegratorCM
> device, and move the code that depends on the value of memsz
> from the init function to the realize function. That way the
> device doesn't have to know anything about the machine.

Thanks, I will be sending a reworked patch shortly.

Jakub



[Qemu-devel] [PATCH] linux-user: add RTA_PRIORITY in netlink

2016-09-25 Thread Laurent Vivier
Used by fedora21 on ppc64 in the network initialization

Signed-off-by: Laurent Vivier 
---
 linux-user/syscall.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0815f30..d21d901 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2591,6 +2591,7 @@ static abi_long target_to_host_data_route_rtattr(struct 
rtattr *rtattr)
 case RTA_GATEWAY:
 break;
 /* u32 */
+case RTA_PRIORITY:
 case RTA_OIF:
 u32 = RTA_DATA(rtattr);
 *u32 = tswap32(*u32);
-- 
2.7.4




[Qemu-devel] [PATCH] linux-user: add kcmp() syscall

2016-09-25 Thread Laurent Vivier
Signed-off-by: Laurent Vivier 
---
 linux-user/syscall.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d21d901..a32386e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -304,6 +304,11 @@ _syscall3(int, ioprio_set, int, which, int, who, int, 
ioprio)
 _syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags)
 #endif
 
+#if defined(TARGET_NR_kcmp) && defined(__NR_kcmp)
+_syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type,
+  unsigned long, idx1, unsigned long, idx2)
+#endif
+
 static bitmask_transtbl fcntl_flags_tbl[] = {
   { TARGET_O_ACCMODE,   TARGET_O_WRONLY,O_ACCMODE,   O_WRONLY,},
   { TARGET_O_ACCMODE,   TARGET_O_RDWR,  O_ACCMODE,   O_RDWR,  },
@@ -11943,6 +11948,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 ret = get_errno(unshare(arg1));
 break;
 #endif
+#if defined(TARGET_NR_kcmp) && defined(__NR_kcmp)
+case TARGET_NR_kcmp:
+ret = get_errno(kcmp(arg1, arg2, arg3, arg4, arg5));
+break;
+#endif
 
 default:
 unimplemented:
-- 
2.7.4




Re: [Qemu-devel] [PATCH] linux-user: add kcmp() syscall

2016-09-25 Thread no-reply
Hi,

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

Message-id: 1474834820-24198-1-git-send-email-laur...@vivier.eu
Type: series
Subject: [Qemu-devel] [PATCH] linux-user: add kcmp() syscall

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

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

# Useful git options
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 show --no-patch --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag] 
patchew/1474834820-24198-1-git-send-email-laur...@vivier.eu -> 
patchew/1474834820-24198-1-git-send-email-laur...@vivier.eu
Switched to a new branch 'test'
75f537b linux-user: add kcmp() syscall

=== OUTPUT BEGIN ===
Checking PATCH 1/1: linux-user: add kcmp() syscall...
ERROR: architecture specific defines should be avoided
#17: FILE: linux-user/syscall.c:307:
+#if defined(TARGET_NR_kcmp) && defined(__NR_kcmp)

ERROR: architecture specific defines should be avoided
#29: FILE: linux-user/syscall.c:11950:
+#if defined(TARGET_NR_kcmp) && defined(__NR_kcmp)

total: 2 errors, 0 warnings, 22 lines checked

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

=== OUTPUT END ===

Test command exited with code: 1


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

[Qemu-devel] [PATCH v2] hw/arm: Fix Integrator/CM initialization

2016-09-25 Thread Jakub Jermář

Initialization of a class instance cannot depend on its own properties
as these are not yet set.  Move parts of integratorcm_init() that depend
on the "memsz" property to the newly added integratorcm_realize().

This fixes: https://bugs.launchpad.net/qemu/+bug/1624726

Signed-off-by: Jakub Jermar 
---
 hw/arm/integratorcp.c | 35 +--
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 96dc150..039812a 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -252,6 +252,26 @@ static void integratorcm_init(Object *obj)
 /* ??? What should the high bits of this value be?  */
 s->cm_auxosc = 0x0007feff;
 s->cm_sdram = 0x00011122;
+memcpy(integrator_spd + 73, "QEMU-MEMORY", 11);
+s->cm_init = 0x0112;
+s->cm_refcnt_offset = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), 24,
+   1000);
+memory_region_init_ram(&s->flash, obj, "integrator.flash", 0x10,
+   &error_fatal);
+vmstate_register_ram_global(&s->flash);
+
+memory_region_init_io(&s->iomem, obj, &integratorcm_ops, s,
+  "integratorcm", 0x0080);
+sysbus_init_mmio(dev, &s->iomem);
+
+integratorcm_do_remap(s);
+/* ??? Save/restore.  */
+}
+
+static void integratorcm_realize(DeviceState *d, Error **errp)
+{
+IntegratorCMState *s = INTEGRATOR_CM(d);
+
 if (s->memsz >= 256) {
 integrator_spd[31] = 64;
 s->cm_sdram |= 0x10;
@@ -267,20 +287,6 @@ static void integratorcm_init(Object *obj)
 } else {
 integrator_spd[31] = 2;
 }
-memcpy(integrator_spd + 73, "QEMU-MEMORY", 11);
-s->cm_init = 0x0112;
-s->cm_refcnt_offset = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), 24,
-   1000);
-memory_region_init_ram(&s->flash, obj, "integrator.flash", 0x10,
-   &error_fatal);
-vmstate_register_ram_global(&s->flash);
-
-memory_region_init_io(&s->iomem, obj, &integratorcm_ops, s,
-  "integratorcm", 0x0080);
-sysbus_init_mmio(dev, &s->iomem);
-
-integratorcm_do_remap(s);
-/* ??? Save/restore.  */
 }
 
 /* Integrator/CP hardware emulation.  */
@@ -633,6 +639,7 @@ static void core_class_init(ObjectClass *klass, void *data)
 DeviceClass *dc = DEVICE_CLASS(klass);
 
 dc->props = core_properties;
+dc->realize = integratorcm_realize;
 }
 
 static const TypeInfo core_info = {


Re: [Qemu-devel] vhost-user-test failure

2016-09-25 Thread Marc-André Lureau
Hi

- Original Message -
> This time with Marc-André in cc:...
> 
> On 09/23/2016 07:40 PM, Maxime Coquelin wrote:
> >
> >
> > On 09/23/2016 05:41 PM, Michael S. Tsirkin wrote:
> >> On Fri, Sep 23, 2016 at 12:36:12PM -0300, Eduardo Habkost wrote:
> >>> Hi,
> >>>
> >>> I hit a weird vhost-user-test failure on travis-ci recently, on a
> >>> branch where I didn't touch any vhost-related code. From a quick
> >>> look at the code, it looks like the vhost-user code is unhappy to
> >>> see a disconnected socket.
> >>>
> >>> I wasn't able to reproduce it. It seems to be a hard to reproduce
> >>> race between vhost-user code and socket reconnection.
> >>>
> >>> The failure can be seen at:
> >>>
> >>> https://travis-ci.org/ehabkost/qemu-hacks/jobs/162077239
> >>
> >> Maxime looked at something similiar. Any idea?
> > No, not really.
> > Marc-André contributed a lot to these tests, I add him in cc: in case
> > he has an idea.
> >
> > I will have a look in the mean time.
> >

I am unable to reproduce locally (over 500x iterations), and I have no clue 
what's going on: the warnings there aren't the problem (that's the main reason 
why we use the subprocess, to silence those). Do you have a local reproducer or 
is it only on travis? Afaik, there are no other reports of this test failing, 
are you sure its not related to changes on your branch?

thanks



[Qemu-devel] [PATCH 1/2] build-sys: remove unused GLIB_CFLAGS

2016-09-25 Thread Marc-André Lureau
---
 configure | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configure b/configure
index 8fa62ad..c831600 100755
--- a/configure
+++ b/configure
@@ -5140,7 +5140,6 @@ fi
 if test "$glib_subprocess" = "yes" ; then
   echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
 fi
-echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 if test "$gtk" = "yes" ; then
   echo "CONFIG_GTK=y" >> $config_host_mak
   echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
-- 
2.10.0




[Qemu-devel] [PATCH 2/2] build-sys: put glib_cflags in QEMU_CFLAGS

2016-09-25 Thread Marc-André Lureau
This way, overriding CFLAGS on make command line keeps glib-cflags
and doesn't break the build.

Signed-off-by: Marc-André Lureau 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index c831600..5412d4f 100755
--- a/configure
+++ b/configure
@@ -2933,7 +2933,7 @@ for i in $glib_modules; do
 if $pkg_config --atleast-version=$glib_req_ver $i; then
 glib_cflags=$($pkg_config --cflags $i)
 glib_libs=$($pkg_config --libs $i)
-CFLAGS="$glib_cflags $CFLAGS"
+QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
 LIBS="$glib_libs $LIBS"
 libs_qga="$glib_libs $libs_qga"
 else
-- 
2.10.0




Re: [Qemu-devel] [PATCH v10 0/2] virtio-crypto: virtio crypto device specification

2016-09-25 Thread Gonglei (Arei)
Hi,

Virtio-1 device (virtio_pci_modern) is supported since 2015 in Linux kernel, so
that lots of existing Guest can't support virtio-1.0 device. But the scenario of
virtio crypto device is mostly NFV, which require the existing Guest can't need 
to do any changes to support virtio crypto, so that they can easily migrate the
existing network units to VM. That's also a basic requirement came from our
customers.

So I'd like to emulate the virtio crypto device as a transitional device by 
default
(Of course you can easily emulate it as a modern device by
'disable-legacy=on disable-modren = off'), then it's require a transitional PCI 
device ID.
I want to reserve 0x1014 (20) because virtio crypto device ID is 20.

What's your opinion? Thanks!

If your don't object it, I'll add this in next virtio crypto spec version and 
update
corresponding code in QEMU.

Regards,
-Gonglei



> -Original Message-
> From: Gonglei (Arei)
> Sent: Tuesday, September 20, 2016 5:46 PM
> To: qemu-devel@nongnu.org; virtio-...@lists.oasis-open.org
> Cc: Huangpeng (Peter); Luonengjun; m...@redhat.com;
> cornelia.h...@de.ibm.com; stefa...@redhat.com;
> denglin...@chinamobile.com; Jani Kokkonen; ola.liljed...@arm.com;
> varun.se...@freescale.com; xin.z...@intel.com; brian.a.keat...@intel.com;
> liang.j...@intel.com; john.grif...@intel.com; Hanweidong (Randy);
> Huangweidong (C); mike.cara...@nxp.com; ag...@suse.de; Claudio Fontana;
> Zhoujian (jay, Euler); nmo...@kalray.eu; vincent.jar...@6wind.com; Wubin (H);
> Gonglei (Arei)
> Subject: [PATCH v10 0/2] virtio-crypto: virtio crypto device specification
> 
> This is the specification about a new virtio crypto device.
> 
> You can get the source code from the below website:
> 
> [PATCH v3 00/10] virtio-crypto: introduce framework and device emulation
>  https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg04132.html
> 
> Please help to review, thanks.
> 
> CC: Michael S. Tsirkin 
> CC: Cornelia Huck 
> CC: Stefan Hajnoczi 
> CC: Lingli Deng 
> CC: Jani Kokkonen 
> CC: Ola Liljedahl 
> CC: Varun Sethi 
> CC: Zeng Xin 
> CC: Keating Brian 
> CC: Ma Liang J 
> CC: Griffin John 
> CC: Hanweidong 
> CC: Mihai Claudiu Caraman 
> 
> Changes since v9:
>  - request a native speaker go over the text and fix corresponding grammar
> issues. [mst]
>  - make some description more appropriated over here and there. [mst]
>  - rewrite some requirement for both device and driver. [mst]
>  - use RFC 2119 keywords. [mst]
>  - fix some complaints by Xelatex and typoes. [Xin Zeng]
>  - add scatter/getter chain support for possible large block data.
> 
> Thanks for your review, Michael and Xin.
> 
> Changes from v8:
>  - add additional auth gpa and length to struct virtio_crypto_sym_data_req;
>  - add definition of op in struct virtio_crypto_cipher_session_para,
>   VIRTIO_CRYPTO_OP_ENCRYPT and VIRTIO_CRYPTO_OP_DECRYPT;
>  - make all structures 64bit aligned in order to support different
>   architectures more conveniently [Alex & Stefan]
>  - change to devicenormative{\subsection} and \drivernormative{\subsection}
> in some sections [Stefan]
>  - driver does not have to initialize all data virtqueues if it wants to use 
> fewer
> [Stefan]
>  - drop VIRTIO_CRYPTO_NO_SERVICE definition [Stefan]
>  - many grammatical problems and typos. [Stefan]
>  - rename VIRTIO_CRYPTO_MAC_CMAC_KASUMI_F9 to
> VIRTIO_CRYPTO_MAC_CMAC_KASUMI_F9,
>   and VIRTIO_CRYPTO_MAC_CMAC_SNOW3G_UIA2 to
> VIRTIO_CRYPTO_MAC_SNOW3G_UIA2. [Liang Ma]
>  - drop queue_id property of struct virtio_crypto_op_data_req.
>  - reconstruct some structures about session operation request.
>  - introduce struct virtio_crypto_alg_chain_session_req and struct
> virtio_crypto_alg_chain_data_req,
>   introduce chain para, output, input structures as well.
>  - change some sections' layout for better compatibility, for asymmetric 
> algos.
> [Xin Zeng]
> 
> Changes from v7:
>  - fix some grammar or typo problems.
>  - add more detailed description at steps of encryption section.
> 
> Changes from v6:
>  - drop verion filed in struct virtio_crypto_config. [Michael & Cornelia]
>  - change the incorrect description in initialization routine. [Zeng Xin]
>  - redefine flag u16 to make structure alignment. [Zeng Xin]
>  - move the content of virtio_crypto_hash_session_para into
>virtio_crypto_hash_session_input directly, Same to MAC/SYM/AEAD
> session creation. [Zeng Xin]
>  - adjuest the sequence of idata and odata refer to the virtio scsi parts,
>meanwhile add the comments of device-readable/writable for them.
>  - add restrictive documents for the guest memory in some structure, which
>MUST be gauranted to be allocated and physically-contiguous.
> 
> Changes from v5:
>  - add conformance clauses for virtio crypto device. [Michael]
>  - drop VIRTIO_CRYPTO_S_STARTED. [Michael]
>  - fix some characters problems. [Stefan]
>  - add a MAC algorithm, named VIRTIO_CRYPTO_MAC_ZUC_EIA3. [Zeng Xin]
>  - add the fourth return code, named VIRTIO_CRYPTO_OP

Re: [Qemu-devel] [PATCH RFC v1 01/29] target-arc: initial commit

2016-09-25 Thread Max Filippov
Hello,

On Tue, Sep 20, 2016 at 4:31 PM, Richard Henderson  wrote:
>> +if (ctx.npc == env->lpe) {
> You can't look at the contents of ENV during translation.
>
> You'll need to implement this feature similar to how it's done for xtensa.
> See helper_wsr_lbeg, helper_wsr_lend, and gen_check_loop_end.

I think it's fairly expensive solution, as it allows to have only one TB with
zero overhead loop at a time. I'm looking at ways to optimize it,
perhaps recording lbeg in the TB's cs_base.

-- 
Thanks.
-- Max



[Qemu-devel] [PATCH] tap-bsd: OpenBSD uses tap(4) now

2016-09-25 Thread Brad Smith
Update the tap-bsd code now that OpenBSD uses tap(4).

Signed-off-by: Brad Smith 


diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index c506ac3..8d0f049 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -55,11 +55,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
 if (*ifname) {
 snprintf(dname, sizeof dname, "/dev/%s", ifname);
 } else {
-#if defined(__OpenBSD__)
-snprintf(dname, sizeof dname, "/dev/tun%d", i);
-#else
 snprintf(dname, sizeof dname, "/dev/tap%d", i);
-#endif
 }
 TFR(fd = open(dname, O_RDWR));
 if (fd >= 0) {



[Qemu-devel] How does a guest OS differentiate between a Reboot/Shutdown ACPI event

2016-09-25 Thread Srinivasan J
Hi,

I have Ubuntu 14.04.1 (ubuntu-14.04.1-server-amd64.iso) guest running
in a KVM host. The host is running Ubuntu 16.04. I'm trying to find
out how Ubuntu 14.04.1 differentiates between virsh shutdown and virsh
reboot commands issued in the host. I see that in both cases the ACPI
event seen at the guest are exactly same. The guest however correctly
shuts down on issuing "virsh shutdown" and correctly reboots on
issuing "virsh reboot".

syslog:Sep 25 12:33:51 ubuntu acpid: waiting for events: event logging is on
syslog:Sep 25 12:34:46 ubuntu acpid: received input layer event
"button/power PBTN 0080 "
syslog:Sep 25 12:34:46 ubuntu acpid: rule from /etc/acpi/events/powerbtn matched
syslog:Sep 25 12:34:46 ubuntu acpid: executing action "/etc/acpi/powerbtn.sh"
syslog:Sep 25 12:34:46 ubuntu acpid: action exited with status 0
syslog:Sep 25 12:34:46 ubuntu acpid: 1 total rule matched
syslog:Sep 25 12:34:46 ubuntu acpid: completed input layer event
"button/power PBTN 0080 "
syslog:Sep 25 12:34:46 ubuntu acpid: received netlink event
"button/power LNXPWRBN:00 0080 0001"
syslog:Sep 25 12:34:46 ubuntu acpid: rule from /etc/acpi/events/powerbtn matched
syslog:Sep 25 12:34:46 ubuntu acpid: executing action "/etc/acpi/powerbtn.sh"
syslog:Sep 25 12:34:46 ubuntu acpid: action exited with status 0
syslog:Sep 25 12:34:46 ubuntu acpid: 1 total rule matched
syslog:Sep 25 12:34:46 ubuntu acpid: completed netlink event
"button/power LNXPWRBN:00 0080 0001"
syslog:Sep 25 12:35:02 ubuntu acpid: starting up with netlink and the
input layer
syslog:Sep 25 12:35:02 ubuntu acpid: 1 rule loaded
syslog:Sep 25 12:35:02 ubuntu acpid: waiting for events: event logging is on
syslog:Sep 25 12:36:13 ubuntu acpid: received input layer event
"button/power PBTN 0080 "
syslog:Sep 25 12:36:13 ubuntu acpid: rule from /etc/acpi/events/powerbtn matched
syslog:Sep 25 12:36:13 ubuntu acpid: executing action "/etc/acpi/powerbtn.sh"
syslog:Sep 25 12:36:13 ubuntu acpid: action exited with status 0
syslog:Sep 25 12:36:13 ubuntu acpid: 1 total rule matched
syslog:Sep 25 12:36:13 ubuntu acpid: completed input layer event
"button/power PBTN 0080 "
syslog:Sep 25 12:36:13 ubuntu acpid: received netlink event
"button/power LNXPWRBN:00 0080 0001"
syslog:Sep 25 12:36:13 ubuntu acpid: rule from /etc/acpi/events/powerbtn matched
syslog:Sep 25 12:36:13 ubuntu acpid: executing action "/etc/acpi/powerbtn.sh"
syslog:Sep 25 12:36:13 ubuntu acpid: action exited with status 0
syslog:Sep 25 12:36:13 ubuntu acpid: 1 total rule matched
syslog:Sep 25 12:36:13 ubuntu acpid: completed netlink event
"button/power LNXPWRBN:00 0080 0001"
syslog:Sep 25 12:36:27 ubuntu acpid: starting up with netlink and the
input layer
syslog:Sep 25 12:36:27 ubuntu acpid: 1 rule loaded
syslog:Sep 25 12:36:27 ubuntu acpid: waiting for events: event logging is on


Guest details:

srinij@ubuntu:/$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:Ubuntu 14.04.1 LTS
Release:14.04
Codename:   trusty

Host details:

srinij@ubuntu-server-16x:~/Downloads$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:Ubuntu 16.04 LTS
Release:16.04
Codename:   xenial
srinij@ubuntu-server-16x:~/Downloads$ virsh version
Compiled against library: libvirt 1.3.1
Using library: libvirt 1.3.1
Using API: QEMU 1.3.1
Running hypervisor: QEMU 2.5.0

Regards,
Srini



Re: [Qemu-devel] [PATCH v10 0/2] virtio-crypto: virtio crypto device specification

2016-09-25 Thread Michael S. Tsirkin
On Mon, Sep 26, 2016 at 01:15:48AM +, Gonglei (Arei) wrote:
> Hi,
> 
> Virtio-1 device (virtio_pci_modern) is supported since 2015 in Linux kernel, 
> so
> that lots of existing Guest can't support virtio-1.0 device.
> But the scenario of
> virtio crypto device is mostly NFV, which require the existing Guest can't 
> need 
> to do any changes to support virtio crypto, so that they can easily migrate 
> the
> existing network units to VM. That's also a basic requirement came from our
> customers.

If you require support for existing guests, you need to emulate a
device they already support. Whatever you do with virtio crypto
spec won't achieve this.

Hopefully you can load a virtio crypto driver module in the guest.
If you can, load a 1.1 driver. If you can't you can't use the device
whatever we do in the spec.

> So I'd like to emulate the virtio crypto device as a transitional device by 
> default
> (Of course you can easily emulate it as a modern device by
> 'disable-legacy=on disable-modren = off'), then it's require a transitional 
> PCI device ID.
> I want to reserve 0x1014 (20) because virtio crypto device ID is 20.
> 
> What's your opinion? Thanks!
> 
> If your don't object it, I'll add this in next virtio crypto spec version and 
> update
> corresponding code in QEMU.
> 
> Regards,
> -Gonglei

Legacy is for existing devices, we don't want to add to this baggage IMHO.

In particular, guests should be able to assume that all legacy and
transitional device IDs are known and listed in spec 1.0, chapter Device
Requirements: PCI Device Discovery.

> 
> 
> > -Original Message-
> > From: Gonglei (Arei)
> > Sent: Tuesday, September 20, 2016 5:46 PM
> > To: qemu-devel@nongnu.org; virtio-...@lists.oasis-open.org
> > Cc: Huangpeng (Peter); Luonengjun; m...@redhat.com;
> > cornelia.h...@de.ibm.com; stefa...@redhat.com;
> > denglin...@chinamobile.com; Jani Kokkonen; ola.liljed...@arm.com;
> > varun.se...@freescale.com; xin.z...@intel.com; brian.a.keat...@intel.com;
> > liang.j...@intel.com; john.grif...@intel.com; Hanweidong (Randy);
> > Huangweidong (C); mike.cara...@nxp.com; ag...@suse.de; Claudio Fontana;
> > Zhoujian (jay, Euler); nmo...@kalray.eu; vincent.jar...@6wind.com; Wubin 
> > (H);
> > Gonglei (Arei)
> > Subject: [PATCH v10 0/2] virtio-crypto: virtio crypto device specification
> > 
> > This is the specification about a new virtio crypto device.
> > 
> > You can get the source code from the below website:
> > 
> > [PATCH v3 00/10] virtio-crypto: introduce framework and device emulation
> >  https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg04132.html
> > 
> > Please help to review, thanks.
> > 
> > CC: Michael S. Tsirkin 
> > CC: Cornelia Huck 
> > CC: Stefan Hajnoczi 
> > CC: Lingli Deng 
> > CC: Jani Kokkonen 
> > CC: Ola Liljedahl 
> > CC: Varun Sethi 
> > CC: Zeng Xin 
> > CC: Keating Brian 
> > CC: Ma Liang J 
> > CC: Griffin John 
> > CC: Hanweidong 
> > CC: Mihai Claudiu Caraman 
> > 
> > Changes since v9:
> >  - request a native speaker go over the text and fix corresponding grammar
> > issues. [mst]
> >  - make some description more appropriated over here and there. [mst]
> >  - rewrite some requirement for both device and driver. [mst]
> >  - use RFC 2119 keywords. [mst]
> >  - fix some complaints by Xelatex and typoes. [Xin Zeng]
> >  - add scatter/getter chain support for possible large block data.
> > 
> > Thanks for your review, Michael and Xin.
> > 
> > Changes from v8:
> >  - add additional auth gpa and length to struct virtio_crypto_sym_data_req;
> >  - add definition of op in struct virtio_crypto_cipher_session_para,
> >   VIRTIO_CRYPTO_OP_ENCRYPT and VIRTIO_CRYPTO_OP_DECRYPT;
> >  - make all structures 64bit aligned in order to support different
> >   architectures more conveniently [Alex & Stefan]
> >  - change to devicenormative{\subsection} and \drivernormative{\subsection}
> > in some sections [Stefan]
> >  - driver does not have to initialize all data virtqueues if it wants to 
> > use fewer
> > [Stefan]
> >  - drop VIRTIO_CRYPTO_NO_SERVICE definition [Stefan]
> >  - many grammatical problems and typos. [Stefan]
> >  - rename VIRTIO_CRYPTO_MAC_CMAC_KASUMI_F9 to
> > VIRTIO_CRYPTO_MAC_CMAC_KASUMI_F9,
> >   and VIRTIO_CRYPTO_MAC_CMAC_SNOW3G_UIA2 to
> > VIRTIO_CRYPTO_MAC_SNOW3G_UIA2. [Liang Ma]
> >  - drop queue_id property of struct virtio_crypto_op_data_req.
> >  - reconstruct some structures about session operation request.
> >  - introduce struct virtio_crypto_alg_chain_session_req and struct
> > virtio_crypto_alg_chain_data_req,
> >   introduce chain para, output, input structures as well.
> >  - change some sections' layout for better compatibility, for asymmetric 
> > algos.
> > [Xin Zeng]
> > 
> > Changes from v7:
> >  - fix some grammar or typo problems.
> >  - add more detailed description at steps of encryption section.
> > 
> > Changes from v6:
> >  - drop verion filed in struct virtio_crypto_config. [Michael & Cornelia]
> >  - change the incorrect d

Re: [Qemu-devel] [virtio-dev] Re: [PATCH v10 0/2] virtio-crypto: virtio crypto device specification

2016-09-25 Thread Gonglei (Arei)
Hi Michael,

Thanks for your feedback.

> From: virtio-...@lists.oasis-open.org [mailto:virtio-...@lists.oasis-open.org]
> On Behalf Of Michael S. Tsirkin
> Sent: Monday, September 26, 2016 10:58 AM
> Subject: [virtio-dev] Re: [PATCH v10 0/2] virtio-crypto: virtio crypto device
> specification
> 
> On Mon, Sep 26, 2016 at 01:15:48AM +, Gonglei (Arei) wrote:
> > Hi,
> >
> > Virtio-1 device (virtio_pci_modern) is supported since 2015 in Linux 
> > kernel, so
> > that lots of existing Guest can't support virtio-1.0 device.
> > But the scenario of
> > virtio crypto device is mostly NFV, which require the existing Guest can't 
> > need
> > to do any changes to support virtio crypto, so that they can easily migrate 
> > the
> > existing network units to VM. That's also a basic requirement came from our
> > customers.
> 
> If you require support for existing guests, you need to emulate a
> device they already support. Whatever you do with virtio crypto
> spec won't achieve this.
> 
> Hopefully you can load a virtio crypto driver module in the guest.
> If you can, load a 1.1 driver. If you can't you can't use the device
> whatever we do in the spec.
> 

For virtio crypto driver, we can both support virtio-1.0 or earlier. But
Virtio pci driver module can't discovery the virtio-1.0 devices in the
existing Guests. So, If we want do this, we have to require the customers
change the virtio pci module for existing guests influence all virtio devices,
which is too difficult. 

> > So I'd like to emulate the virtio crypto device as a transitional device by
> default
> > (Of course you can easily emulate it as a modern device by
> > 'disable-legacy=on disable-modren = off'), then it's require a transitional 
> > PCI
> device ID.
> > I want to reserve 0x1014 (20) because virtio crypto device ID is 20.
> >
> > What's your opinion? Thanks!
> >
> > If your don't object it, I'll add this in next virtio crypto spec version 
> > and update
> > corresponding code in QEMU.
> >
> > Regards,
> > -Gonglei
> 
> Legacy is for existing devices, we don't want to add to this baggage IMHO.
> 
> In particular, guests should be able to assume that all legacy and
> transitional device IDs are known and listed in spec 1.0, chapter Device
> Requirements: PCI Device Discovery.
> 

So can we don't change the spec, only assign the virito crypto pci ID in Qemu?
Just like what virtio vsock does?

Regards,
-Gonglei

> >
> >
> > > -Original Message-
> > > From: Gonglei (Arei)
> > > Sent: Tuesday, September 20, 2016 5:46 PM
> > > To: qemu-devel@nongnu.org; virtio-...@lists.oasis-open.org
> > > Cc: Huangpeng (Peter); Luonengjun; m...@redhat.com;
> > > cornelia.h...@de.ibm.com; stefa...@redhat.com;
> > > denglin...@chinamobile.com; Jani Kokkonen; ola.liljed...@arm.com;
> > > varun.se...@freescale.com; xin.z...@intel.com;
> brian.a.keat...@intel.com;
> > > liang.j...@intel.com; john.grif...@intel.com; Hanweidong (Randy);
> > > Huangweidong (C); mike.cara...@nxp.com; ag...@suse.de; Claudio
> Fontana;
> > > Zhoujian (jay, Euler); nmo...@kalray.eu; vincent.jar...@6wind.com; Wubin
> (H);
> > > Gonglei (Arei)
> > > Subject: [PATCH v10 0/2] virtio-crypto: virtio crypto device specification
> > >
> > > This is the specification about a new virtio crypto device.
> > >
> > > You can get the source code from the below website:
> > >
> > > [PATCH v3 00/10] virtio-crypto: introduce framework and device emulation
> > >  https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg04132.html
> > >
> > > Please help to review, thanks.
> > >
> > > CC: Michael S. Tsirkin 
> > > CC: Cornelia Huck 
> > > CC: Stefan Hajnoczi 
> > > CC: Lingli Deng 
> > > CC: Jani Kokkonen 
> > > CC: Ola Liljedahl 
> > > CC: Varun Sethi 
> > > CC: Zeng Xin 
> > > CC: Keating Brian 
> > > CC: Ma Liang J 
> > > CC: Griffin John 
> > > CC: Hanweidong 
> > > CC: Mihai Claudiu Caraman 
> > >
> > > Changes since v9:
> > >  - request a native speaker go over the text and fix corresponding
> grammar
> > > issues. [mst]
> > >  - make some description more appropriated over here and there. [mst]
> > >  - rewrite some requirement for both device and driver. [mst]
> > >  - use RFC 2119 keywords. [mst]
> > >  - fix some complaints by Xelatex and typoes. [Xin Zeng]
> > >  - add scatter/getter chain support for possible large block data.
> > >
> > > Thanks for your review, Michael and Xin.
> > >
> > > Changes from v8:
> > >  - add additional auth gpa and length to struct
> virtio_crypto_sym_data_req;
> > >  - add definition of op in struct virtio_crypto_cipher_session_para,
> > >   VIRTIO_CRYPTO_OP_ENCRYPT and VIRTIO_CRYPTO_OP_DECRYPT;
> > >  - make all structures 64bit aligned in order to support different
> > >   architectures more conveniently [Alex & Stefan]
> > >  - change to devicenormative{\subsection} and
> \drivernormative{\subsection}
> > > in some sections [Stefan]
> > >  - driver does not have to initialize all data virtqueues if it wants to 
> > > use
> fewer
> > > [Stefan]
> > >  - drop

[Qemu-devel] [PATCH v2]MC146818 RTC: coordinate guest clock base to destination host after migration

2016-09-25 Thread zhong...@sangfor.com.cn
Hi, Paolo
This is a simplified patch according to your advice. Would you please reiview 
it again.


separation 
line


MC146818 RTC: coordinate guest clock base to destination host after migration

qemu tracks guest time based on vector [base_rtc, last_update], in which
last_update stands for a monotonic tick which is actually uptime of the host.
according to rtc implementation codes of recent releases and upstream, after
migration, the time base vector [base_rtc, last_update] isn't updated to
coordinate with the destionation host, ie. qemu doesnt update last_update to
uptime of the destination host.
what problem have we got because of this bug? after migration, guest time may
jump back to several days ago, that will make some critical business 
applications,
such as lotus notes, malfunction.
this patch is trying to fix the problem. first, when vmsave in progress, we 
rtc_update_time to refresh time stamp in cmos array, then during vmrestore,
we rtc_set_time to update qemu base_rtc and last_update variable according to 
time
stamp in cmos array.

Signed-off-by: Junlian Bell 
---
 hw/timer/mc146818rtc.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index ea625f2..1df17af 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -717,15 +717,20 @@ static void rtc_set_date_from_host(ISADevice *dev)
 rtc_set_cmos(s, &tm);
 }
 
+static void rtc_pre_save(void *opaque) 
+{
+RTCState *s = opaque;
+
+rtc_update_time(s);
+}
+
 static int rtc_post_load(void *opaque, int version_id)
 {
 RTCState *s = opaque;
 
-if (version_id <= 2) {
-rtc_set_time(s);
-s->offset = 0;
-check_update_timer(s);
-}
+rtc_set_time(s);
+s->offset = 0;
+check_update_timer(s);
 
 uint64_t now = qemu_clock_get_ns(rtc_clock);
 if (now < s->next_periodic_time ||
-- 
2.9.0.windows.1



[Qemu-devel] [PATCH]MC146818 RTC: Get correct guest time when irq coalesced

2016-09-25 Thread zhong...@sangfor.com.cn
Hi, Paolo
This is another patch arround RTC. Would you please have a review.

--separation-

MC146818 RTC: Get correct guest time when irq coalesced

When irq coalesce occurred, irq_coalesced actually store the seconds
that the time sawn in guest lags behind real guest virtual time.
At this time , if guest read cmos for virtual time, it shouldn't see
those delayed seconds, so we must substract irq_coalesced from guest 
virtual time. Otherwise, after seconds queued in irq_coalesced applied
to guest, time in guest will go ahead of time it should be.

---
 hw/timer/mc146818rtc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 1df17af..4cb8e5e 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -549,6 +549,8 @@ static void rtc_set_time(RTCState *s)
 rtc_get_time(s, &tm);
 s->base_rtc = mktimegm(&tm);
 s->last_update = qemu_clock_get_ns(rtc_clock);
+ s->irq_coalesced = 0;
+ s->irq_reinject_on_ack_count = 0;
 
 qapi_event_send_rtc_change(qemu_timedate_diff(&tm), &error_abort);
 }
@@ -585,6 +587,7 @@ static void rtc_update_time(RTCState *s)
 
 guest_nsec = get_guest_rtc_ns(s);
 guest_sec = guest_nsec / NANOSECONDS_PER_SECOND;
+ guest_sec -= s->irq_coalesced;
 gmtime_r(&guest_sec, &ret);
 
 /* Is SET flag of Register B disabled? */
-- 
2.9.0.windows.1


[Qemu-devel] [PATCH 1/1] dtc: Update dtc / libfdt submodule to version 1.4.2

2016-09-25 Thread Jeff Cody
There are some patch series which rely on version 1.4.2 of dtc, so
update the submodule version.

Signed-off-by: Jeff Cody 
---
 dtc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dtc b/dtc
index 65cc4d2..ec02b34 16
--- a/dtc
+++ b/dtc
@@ -1 +1 @@
-Subproject commit 65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf
+Subproject commit ec02b34c05be04f249ffaaca4b666f5246877dea
-- 
2.7.4




Re: [Qemu-devel] QEMU dtc submodule

2016-09-25 Thread Jeff Cody
On Sat, Sep 24, 2016 at 11:21:18AM +1000, David Gibson wrote:
> On Fri, Sep 23, 2016 at 03:23:26PM +0100, Paul Burton wrote:
> > On Friday, 23 September 2016 09:13:51 BST Jeff Cody wrote:
> > > > Leon: Please give the git URL and branch that should be mirrored.  It
> > > > cannot be a tag since that is immutable.  Instead it should be the
> > > > dtc development/release tree that will be updated in the future.
> > > 
> > > Yes, once I get the git URL I'll update it on the server.  I presume it is
> > > 'master' on git://git.kernel.org/pub/scm/utils/dtc/dtc.git, but I will 
> > > wait
> > > for confirmation before I do anything.
> > > 
> > > Thanks,
> > > Jeff
> > 
> > Hi Jeff,
> > 
> > That would be the right branch for DTC, but sadly the master branch doesn't 
> > contain the 
> > actual commit that was tagged as the v1.4.2 release. v1.4.2 tags this 
> > commit:
> > 
> > https://git.kernel.org/cgit/utils/dtc/dtc.git/commit/?
> > h=v1.4.2&id=ec02b34c05be04f249ffaaca4b666f5246877dea[1] 
> > 
> > Its parent commit is in the master branch, but it isn't. So simply 
> > mirroring the master 
> > branch wouldn't be enough, you'd need to include the v1.4.2 tag 
> > specifically. I've CC'd David 
> > Gibson who tagged DTC v1.4.2 in case he has input or can rectify this 
> > (which would 
> > probably be either a rebase & force push of the last 2 commits on the 
> > master branch atop 
> > v1.4.2, or a new release).
> 
> Oops.. that's my mistake (with my upstream dtc maintainer hat on).
> 
> Not sure quite how I managed that, but yes, master branches off just
> before the v1.4.2 release, instead of just after.  I've merged them
> back together now, so that master should include v1.4.2 now.
> 

Thanks,

I've updated the git server, and submitted a patch to move the QEMU dtc
submodule version to 1.4.2.

Thanks,
Jeff



Re: [Qemu-devel] [PATCH v2 3/9] hw: arm: SMMUv3 emulation model

2016-09-25 Thread Prem Mallappa
Hi Edger,

I'm going to look at the PCI parts and get back to you with
> comments on that.
>
> Please do, by the time, I'll address your and Eric's comments.


> I've put another round of comments inline:
>
> Thanks



> > +inline void
> > +smmu_write_sysmem(hwaddr addr, void *buf, int len, bool secure)
> > +{
> > +MemTxAttrs attrs = {.unspecified = 1, .secure = secure};
> > +
> > +switch (len) {
> > +case 4:
> > +stl_le_phys(&address_space_memory, addr, *(uint32_t *)buf);
> > +break;
> > +case 8:
> > +stq_le_phys(&address_space_memory, addr, *(uint64_t *)buf);
> > +break;
> > +default:
> > +address_space_rw(&address_space_memory, addr,
> > + attrs, buf, len, true);
> > +}
> > +}
>
> Thinking about this, I think you should just remove these functions and
> always call dma_memory_read/write directly.
>
> It would be nice if you could add a property/link so that machine code
> can specify the MemoryRegion/address space to be used. You'll need a
> link to allow setup of the MemoryRegion and also some code to create
> an address space from the selected MR.
>
> You can have a look at the following code to see how it's done:
> exec.c cpu_exec_init()see object_property_add_link
> cpus.c qemu_init_vcpu()   see address_space_init_shareable
>
>
Sure, will do.


> > +#define smmu_evt_irq_enabled(s)   \
> > +__smmu_irq_enabled(s, SMMU_IRQ_CTRL_EVENT_EN)
> > +#define smmu_gerror_irq_enabled(s)  \
> > +__smmu_irq_enabled(s, SMMU_IRQ_CTRL_GERROR_EN)
> > +#define smmu_pri_irq_enabled(s) \
> > +__smmu_irq_enabled(s, SMMU_IRQ_CTRL_PRI_EN)
>
> Please drop the __ prefix on functions. _ prefixed functions are reserved
> and
> we usually avoid them.
>
> I don't think smmu_evt_irq_enabled() is very useful,
> smmu_irq_enabled(s, SMMU_IRQ_CTRL_EVENT_EN) is readable enough.
>
>
Got it.


> > +
> > +/*
> > + * MMIO Register
> > + */
> > +enum {
> > +SMMU_REG_IDR0= 0x0,
>
> For all regs, I think you should prefix regs with R_.
> And also do / 4, e.g:
>
> R_SMMU_REG_IDR1= 0x4 / 4,
>
> That way you can do s->regs[R_SMMU_REG_IDR1] and remove smmu_read32_reg.
> If you use the REG32 and FIELD macros from the register API you'll
> also be able to use the FIELD_ family of macros (e.g ARRAY_FIELD_EX32)
> to extract fields from regs.
>
> Will change this


> > +struct SMMUQueue {
> > + hwaddr base;
> > + uint32_t prod;
> > + uint32_t cons;
> > + union {
> > +  struct {
> > +   uint8_t prod:1;
> > +   uint8_t cons:1;
>
> Hi, Peter generally doesn't like bitfields. I'd stay away form
> them unless you have a good case. Just change them too bool.
>
>
This a wrap field, and used as a circular buffer full/empty indicator.
changing it to bool would loose its meaning, I'll change if its too much
off the
coding standard.



>
> > +
> > +typedef struct __smmu_data2  STEDesc; /* STE Level 1 Descriptor */
> > +typedef struct __smmu_data16 Ste; /* Stream Table Entry(STE) */
> > +typedef struct __smmu_data2  CDDesc;  /* CD Level 1 Descriptor */
> > +typedef struct __smmu_data16 Cd;  /* Context Descriptor(CD) */
> > +
> > +typedef struct __smmu_data4  Cmd; /* Command Entry */
> > +typedef struct __smmu_data8  Evt; /* Event Entry */
> > +typedef struct __smmu_data4  Pri; /* PRI entry */
>
>
> For all of these, I think it would be more useful if you would declare
> structs with actual fields representing the data structures.
> You can then declare load functions that load the STE from memory and
> decode the fields.
>
> E.g:
>
> typedef struct SMMUv3_STEDesc {
> bool valid;
>  etc...
> } SMMUv3_STEDesc;
>
> void smmuv3_load_ste(AddressSpace *as, dma_addr_t addr, SMMUv3_STEDesc
> *ste)
> {
> uint32_t buf[16];
> dma_memory_read(as, addr, buf, sizeof(*buf));
>
> ste->valid = extract32(buf[0], 0, 1);
> }
>
>
> Then, instead of for example doing STE_VALID(x), you can do ste->valid.
>
>
Thanks
I'll change it to appropriate names and delete where possible.


>
> > +#endif
> > diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > index e51ed3a..96da537 100644
> > --- a/hw/vfio/common.c
> > +++ b/hw/vfio/common.c
> > @@ -412,10 +412,10 @@ static void vfio_listener_region_add(MemoryListener
> *listener,
> >
> >  ret = vfio_dma_map(container, iova, int128_get64(llsize),
> > vaddr, section->readonly);
> > -if (ret) {
> >  error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
> >   "0x%"HWADDR_PRIx", %p) = %d (%m)",
> >   container, iova, int128_get64(llsize), vaddr, ret);
> > +if (ret) {
> >  goto fail;
> >  }
>
>
> Shouldn't this be in a separate patch?
>
>
>
Will do this, thanks for your time


-- 
Cheers,
/Prem


[Qemu-devel] [PATCH] iothread: check iothread->ctx before aio_context_unref to avoid assertion

2016-09-25 Thread Lin Ma
if iothread->ctx is set to NULL, aio_context_unref triggers the assertion:
g_source_unref: assertion 'source != NULL' failed.
The patch fixes it.

Signed-off-by: Lin Ma 
---
 iothread.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/iothread.c b/iothread.c
index fb08a60..fbeb8de 100644
--- a/iothread.c
+++ b/iothread.c
@@ -75,6 +75,9 @@ static void iothread_instance_finalize(Object *obj)
 iothread_stop(obj, NULL);
 qemu_cond_destroy(&iothread->init_done_cond);
 qemu_mutex_destroy(&iothread->init_done_lock);
+if (!iothread->ctx) {
+return;
+}
 aio_context_unref(iothread->ctx);
 }
 
-- 
2.9.2




Re: [Qemu-devel] proposal: drop linux-user unicore32 support from QEMU

2016-09-25 Thread Xuetao Guan
> On Thu, Sep 22, 2016 at 11:09:55PM +0800, MPRC wrote:
>> Hi, I'm fixing the syscall problem for linux-user/unicore32 in qemu.
>>
>> I write a "hello world" program to test linux-user/unicore32 in qemu 2.7
>> with toolchain of uc4-1.0.5(you can download it through
>> http://mprc.pku.edu.cn/~guanxuetao/linux/uc4-1.0.5-hard.tgz). And it's
>> just OK.
>> It goes well in the old version qemu that we using, also.
>>
>> Can you discribe the bug more detailed? Or how do you find that the
>> unicore32 don't use the real syscall numbers?
>> How should test this? By Linux Test Project? It's not necessary to do
>> all test in LTP.
>
> The problem we see is that the system call numbers in qemus
> unicore32/syscall_nr.h dont match what is linux mainline kernel. From the
> toolchain linked, you seem to have kernel headers and syscall numbers
> based on a custom 2.6.32 fork. If one builds unicore32 binaries based on
> Linux 4.4 kernel headers, they will not work qemu. OTOH the binary built
> with the toolchain you linked, would not work with linux 4.4. This
> disparity is what we'd like to get fixed.
>
> Riku
>
OK, I see.
I'd send kernel-patches merge request to linus, but the patches hadn't be
merged.
I'll work on it. Hopefully it'll be done before mid Oct.

Thanks Riku and Peter

Guan Xuetao




Re: [Qemu-devel] [PATCH] usb: ehci: fix memory leak in ehci_process_itd

2016-09-25 Thread 李强
Ping!

2016-09-19 10:48 GMT+08:00 Li Qiang :

> From: Li Qiang 
>
> While processing isochronous transfer descriptors(iTD), if the page
> select(PG) field value is out of bands it will return. In this
> situation the ehci's sg list doesn't be freed thus leading a memory
> leak issue. This patch avoid this.
>
> Signed-off-by: Li Qiang 
> ---
>  hw/usb/hcd-ehci.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
> index b093db7..f4ece9a 100644
> --- a/hw/usb/hcd-ehci.c
> +++ b/hw/usb/hcd-ehci.c
> @@ -1426,6 +1426,7 @@ static int ehci_process_itd(EHCIState *ehci,
>  if (off + len > 4096) {
>  /* transfer crosses page border */
>  if (pg == 6) {
> +qemu_sglist_destroy(&ehci->isgl);
>  return -1;  /* avoid page pg + 1 */
>  }
>  ptr2 = (itd->bufptr[pg + 1] & ITD_BUFPTR_MASK);
> --
> 1.8.3.1
>
>


Re: [Qemu-devel] [PATCH v2 1/9] log: Add new IOMMU type

2016-09-25 Thread Auger Eric
Hi Edgar, Prem,

On 25/09/2016 16:58, Edgar E. Iglesias wrote:
> On Tue, Sep 13, 2016 at 01:53:39AM +0530, Prem Mallappa wrote:
>> On Fri, Sep 9, 2016 at 9:06 PM, Auger Eric  wrote:
>>
>>> Hi Prem,
>>>
>>> Missing commit message
>>>
 Signed-off-by: Prem Mallappa 
 ---
  include/qemu/log.h | 1 +
  util/log.c | 2 ++
  2 files changed, 3 insertions(+)

 diff --git a/include/qemu/log.h b/include/qemu/log.h
 index 234fa81..3dd2131 100644
 --- a/include/qemu/log.h
 +++ b/include/qemu/log.h
 @@ -42,6 +42,7 @@ static inline bool qemu_log_separate(void)
  #define CPU_LOG_TB_NOCHAIN (1 << 13)
  #define CPU_LOG_PAGE   (1 << 14)
  #define LOG_TRACE  (1 << 15)
 +#define CPU_LOG_IOMMU  (1 << 16)
>>> why is it prefixed with CPU_ ?
>>> besides all arm gic devices seem to use LOG_GUEST_ERROR. what is the
>>> rationale behind introducing a new enum?
>>>
>>
>> Will change this to LOG_GUEST_ERROR, if others on the list are okay.
> 
> Hi,
> 
> LOG_GUEST_ERROR is used for cases when the guest programs things in bad
> way. E.g sets up a register in an invalid manner or writes to regs that
> don't exist.
> 
> In this case we're logging information for valid translation steps, I
> would prefer if we could use something else than LOG_GUEST_ERROR.
> An IOMMU logging class sounds good to me.

Thank you for the clarification; so indeed LOG_GUEST_ERROR which was my
suggestion is not a good idea. With respect to that patch I was also
wondering whether the CPU_ prefix was relevant.

Thanks

Eric
> 
> Best regards,
> Edgar
>