[Qemu-devel] [PATCH 2/4] tpm: wrap stX_be_p in tpm_cmd_set_XYZ functions

2018-02-02 Thread Stefan Berger
Wrap the calls to stl_be_p and stw_be_p in tpm_cmd_set_XYZ functions
that are similar to existing getters.

Signed-off-by: Stefan Berger 
Reviewed-by: Marc-André Lureau 
---
 hw/tpm/tpm_util.c |  6 +++---
 hw/tpm/tpm_util.h | 15 +++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c
index 8abde59..2de52a0 100644
--- a/hw/tpm/tpm_util.c
+++ b/hw/tpm/tpm_util.c
@@ -106,9 +106,9 @@ const PropertyInfo qdev_prop_tpm = {
 void tpm_util_write_fatal_error_response(uint8_t *out, uint32_t out_len)
 {
 if (out_len >= sizeof(struct tpm_resp_hdr)) {
-stw_be_p(out, TPM_TAG_RSP_COMMAND);
-stl_be_p(out + 2, sizeof(struct tpm_resp_hdr));
-stl_be_p(out + 6, TPM_FAIL);
+tpm_cmd_set_tag(out, TPM_TAG_RSP_COMMAND);
+tpm_cmd_set_size(out, sizeof(struct tpm_resp_hdr));
+tpm_cmd_set_error(out, TPM_FAIL);
 }
 }
 
diff --git a/hw/tpm/tpm_util.h b/hw/tpm/tpm_util.h
index f003d15..f397ac2 100644
--- a/hw/tpm/tpm_util.h
+++ b/hw/tpm/tpm_util.h
@@ -36,11 +36,21 @@ static inline uint16_t tpm_cmd_get_tag(const void *b)
 return lduw_be_p(b);
 }
 
+static inline void tpm_cmd_set_tag(void *b, uint16_t tag)
+{
+stw_be_p(b, tag);
+}
+
 static inline uint32_t tpm_cmd_get_size(const void *b)
 {
 return ldl_be_p(b + 2);
 }
 
+static inline void tpm_cmd_set_size(void *b, uint32_t size)
+{
+stl_be_p(b + 2, size);
+}
+
 static inline uint32_t tpm_cmd_get_ordinal(const void *b)
 {
 return ldl_be_p(b + 6);
@@ -51,6 +61,11 @@ static inline uint32_t tpm_cmd_get_errcode(const void *b)
 return ldl_be_p(b + 6);
 }
 
+static inline void tpm_cmd_set_error(void *b, uint32_t error)
+{
+stl_be_p(b + 6, error);
+}
+
 int tpm_util_get_buffer_size(int tpm_fd, TPMVersion tpm_version,
  size_t *buffersize);
 
-- 
2.5.5




Re: [Qemu-devel] [PATCH 3/3] target/ppc: generalize check on radix when in HV mode

2018-02-02 Thread Cédric Le Goater
On 02/02/2018 03:43 AM, Suraj Jitindar Singh wrote:
> On Wed, 2018-01-31 at 09:27 +0100, Cédric Le Goater wrote:
>> On a POWER9 processor, the first doubleword of the PTCR indicates
>> whether the partition uses HPT or Radix Trees translation. Use that
>> bit to check for radix mode on powernv QEMU machines.
> 
> The above isn't quite right.
> 
> On a POWER9 processor, the first doubleword of the partition table
> entry (as pointed to by the PTCR) indicates whether the host uses HPT
> or Radix Tree translation for that partition.

yes. This is better.

>>
>> Signed-off-by: Cédric Le Goater 
>> ---
>>  target/ppc/mmu-book3s-v3.c  | 17 -
>>  target/ppc/mmu-book3s-v3.h  |  8 +---
>>  target/ppc/mmu-hash64.h |  1 +
>>  target/ppc/mmu_helper.c |  4 ++--
>>  target/ppc/translate_init.c |  2 +-
>>  5 files changed, 21 insertions(+), 11 deletions(-)
>>
>> diff --git a/target/ppc/mmu-book3s-v3.c b/target/ppc/mmu-book3s-v3.c
>> index e7798b3582b0..50b60fca3445 100644
>> --- a/target/ppc/mmu-book3s-v3.c
>> +++ b/target/ppc/mmu-book3s-v3.c
>> @@ -24,10 +24,25 @@
>>  #include "mmu-book3s-v3.h"
>>  #include "mmu-radix64.h"
>>  
>> +bool ppc64_radix(PowerPCCPU *cpu)
>> +{
>> +CPUPPCState *env = >env;
>> +
>> +if (msr_hv) {
> 
> I would prefer something like:
> 
> uint64_t prtbe0 = ldq_phys(...);
> return prtbe0 & HR;

I will add a helper to retrieve the first partition table entry,
as we need it in other places in patch 2. 

>> +return ldq_phys(CPU(cpu)->as, cpu->env.spr[SPR_PTCR] &
>> +PTCR_PTAB) & PTCR_PTAB_HR;
>> +} else  {
>> +PPCVirtualHypervisorClass *vhc =
>> +PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
>> +
>> +return !!(vhc->get_patbe(cpu->vhyp) & PATBE1_GR);
>> +}
>> +}
>> +
>>  int ppc64_v3_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx,
>>int mmu_idx)
>>  {
>> -if (ppc64_radix_guest(cpu)) { /* Guest uses radix */
>> +if (ppc64_radix(cpu)) { /* radix mode */
>>  return ppc_radix64_handle_mmu_fault(cpu, eaddr, rwx,
>> mmu_idx);
>>  } else { /* Guest uses hash */
>>  return ppc_hash64_handle_mmu_fault(cpu, eaddr, rwx,
>> mmu_idx);
>> diff --git a/target/ppc/mmu-book3s-v3.h b/target/ppc/mmu-book3s-v3.h
>> index 56095dab522c..3876cb51b35c 100644
>> --- a/target/ppc/mmu-book3s-v3.h
>> +++ b/target/ppc/mmu-book3s-v3.h
>> @@ -37,13 +37,7 @@ static inline bool ppc64_use_proc_tbl(PowerPCCPU
>> *cpu)
>>  return !!(cpu->env.spr[SPR_LPCR] & LPCR_UPRT);
>>  }
>>  
>> -static inline bool ppc64_radix_guest(PowerPCCPU *cpu)
>> -{
>> -PPCVirtualHypervisorClass *vhc =
>> -PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
>> -
>> -return !!(vhc->get_patbe(cpu->vhyp) & PATBE1_GR);
>> -}
>> +bool ppc64_radix(PowerPCCPU *cpu);
>>  
>>  int ppc64_v3_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx,
>>int mmu_idx);
>> diff --git a/target/ppc/mmu-hash64.h b/target/ppc/mmu-hash64.h
>> index 4dc6b3968ec0..7e2ac64b6eeb 100644
>> --- a/target/ppc/mmu-hash64.h
>> +++ b/target/ppc/mmu-hash64.h
>> @@ -106,6 +106,7 @@ void ppc_hash64_update_rmls(CPUPPCState *env);
>>  /*
>>   * Partition table definitions
>>   */
>> +#define PTCR_PTAB_HRPPC_BIT(0)/* 1:Host 
> 
> This isn't a bit in the partition table register, it is a bit in the
> partition table entry. It should be defined in target/ppc/mmu-book3s-
> v3.h as part of "/* Partition Table Entry Fields */"
> 
> Also to follow the naming, please call it:
> #define PATBE0_HR PPC_BIT(0)
> 
> :)

yeah sure.

Thanks,

C. 

>> Radix 0:HPT   */
>>  #define PTCR_PTAB   0x0000ULL /* Partition
>> Table Base */
>>  #define PTCR_PTAS   0x001FULL /* Partition
>> Table Size */
>>  
>> diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
>> index b1e660a4d16a..059863b99b2e 100644
>> --- a/target/ppc/mmu_helper.c
>> +++ b/target/ppc/mmu_helper.c
>> @@ -1286,7 +1286,7 @@ void dump_mmu(FILE *f, fprintf_function
>> cpu_fprintf, CPUPPCState *env)
>>  dump_slb(f, cpu_fprintf, ppc_env_get_cpu(env));
>>  break;
>>  case POWERPC_MMU_VER_3_00:
>> -if (ppc64_radix_guest(ppc_env_get_cpu(env))) {
>> +if (ppc64_radix(ppc_env_get_cpu(env))) {
>>  /* TODO - Unsupported */
>>  } else {
>>  dump_slb(f, cpu_fprintf, ppc_env_get_cpu(env));
>> @@ -1432,7 +1432,7 @@ hwaddr ppc_cpu_get_phys_page_debug(CPUState
>> *cs, vaddr addr)
>>  case POWERPC_MMU_VER_2_07:
>>  return ppc_hash64_get_phys_page_debug(cpu, addr);
>>  case POWERPC_MMU_VER_3_00:
>> -if (ppc64_radix_guest(ppc_env_get_cpu(env))) {
>> +if (ppc64_radix(ppc_env_get_cpu(env))) {
>>  return ppc_radix64_get_phys_page_debug(cpu, addr);
>>  } else {
>>  return ppc_hash64_get_phys_page_debug(cpu, addr);
>> diff --git 

[Qemu-devel] [PATCH v3 06/12] vl: drop no_quit variable

2018-02-02 Thread Gerd Hoffmann
Not used any more, delete it.

Signed-off-by: Gerd Hoffmann 
---
 vl.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/vl.c b/vl.c
index 25e784be63..c17dedfa4e 100644
--- a/vl.c
+++ b/vl.c
@@ -152,7 +152,6 @@ int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
 static DisplayOptions dpy;
 int no_frame;
-int no_quit = 0;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 Chardev *virtcon_hds[MAX_VIRTIO_CONSOLES];
@@ -2141,10 +2140,8 @@ static LegacyDisplayType select_display(const char *p)
 opts = nextopt;
 dpy.has_window_close = true;
 if (strstart(opts, "on", )) {
-no_quit = 0;
 dpy.window_close = true;
 } else if (strstart(opts, "off", )) {
-no_quit = 1;
 dpy.window_close = false;
 } else {
 goto invalid_sdl_args;
@@ -3679,7 +3676,6 @@ int main(int argc, char **argv, char **envp)
 ctrl_grab = 1;
 break;
 case QEMU_OPTION_no_quit:
-no_quit = 1;
 dpy.has_window_close = true;
 dpy.window_close = false;
 break;
@@ -4368,7 +4364,8 @@ int main(int argc, char **argv, char **envp)
 error_report("-no-frame, -alt-grab and -ctrl-grab are only valid "
  "for SDL, ignoring option");
 }
-if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) {
+if (dpy.has_window_close &&
+(display_type != DT_GTK && display_type != DT_SDL)) {
 error_report("-no-quit is only valid for GTK and SDL, "
  "ignoring option");
 }
-- 
2.9.3




[Qemu-devel] [PATCH v3 07/12] egl-headless: use DisplayOptions

2018-02-02 Thread Gerd Hoffmann
Switch egl-headless ui to use qapi DisplayOptions for configuration.

Signed-off-by: Gerd Hoffmann 
---
 include/ui/console.h | 2 +-
 ui/egl-headless.c| 2 +-
 vl.c | 3 ++-
 qapi/ui.json | 5 +++--
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index deee5bb606..4cb623112e 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -530,6 +530,6 @@ static inline void early_gtk_display_init(DisplayOptions 
*opts)
 #endif
 
 /* egl-headless.c */
-void egl_headless_init(void);
+void egl_headless_init(DisplayOptions *opts);
 
 #endif
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 5d50226869..38b3766548 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -154,7 +154,7 @@ static const DisplayChangeListenerOps egl_ops = {
 .dpy_gl_update   = egl_scanout_flush,
 };
 
-void egl_headless_init(void)
+void egl_headless_init(DisplayOptions *opts)
 {
 QemuConsole *con;
 egl_dpy *edpy;
diff --git a/vl.c b/vl.c
index c17dedfa4e..1d801dd96d 100644
--- a/vl.c
+++ b/vl.c
@@ -2181,6 +2181,7 @@ static LegacyDisplayType select_display(const char *p)
 request_opengl = 1;
 display_opengl = 1;
 display = DT_EGL;
+dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
 #else
 fprintf(stderr, "egl support is disabled\n");
 exit(1);
@@ -4737,7 +4738,7 @@ int main(int argc, char **argv, char **envp)
 
 #ifdef CONFIG_OPENGL_DMABUF
 if (display_type == DT_EGL) {
-egl_headless_init();
+egl_headless_init();
 }
 #endif
 
diff --git a/qapi/ui.json b/qapi/ui.json
index 52220ed373..cc489b7856 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1017,7 +1017,7 @@
 #
 ##
 { 'enum': 'DisplayType',
-  'data': [ 'none', 'gtk', 'sdl' ] }
+  'data': [ 'none', 'gtk', 'sdl', 'egl-headless' ] }
 
 ##
 # @DisplayOptions:
@@ -1040,4 +1040,5 @@
   'discriminator' : 'type',
   'data': { 'none'   : 'DisplayNoOpts',
 'gtk': 'DisplayGTK',
-'sdl': 'DisplayNoOpts' } }
+'sdl': 'DisplayNoOpts',
+'egl-headless'   : 'DisplayNoOpts' } }
-- 
2.9.3




Re: [Qemu-devel] [PATCH v3 24/50] qapi: add some struct member tests

2018-02-02 Thread Markus Armbruster
Marc-André Lureau  writes:

> Hi
>
> On Sat, Dec 9, 2017 at 10:07 AM, Markus Armbruster  wrote:
>> Marc-André Lureau  writes:
[...]
>>> diff --git a/tests/qapi-schema/struct-member-type.json 
>>> b/tests/qapi-schema/struct-member-type.json
>>> new file mode 100644
>>> index 00..8b33027817
>>> --- /dev/null
>>> +++ b/tests/qapi-schema/struct-member-type.json
>>> @@ -0,0 +1,2 @@
>>> +# check member 'a' with 'type' key only
>>> +{ 'struct': 'foo', 'data': { 'a': { 'type': 'str' } } }
>>> diff --git a/tests/qapi-schema/struct-member-type.out 
>>> b/tests/qapi-schema/struct-member-type.out
>>> new file mode 100644
>>> index 00..04b969d2e3
>>> --- /dev/null
>>> +++ b/tests/qapi-schema/struct-member-type.out
>>> @@ -0,0 +1,12 @@
>>> +enum QType
>>> +prefix QTYPE
>>> +member none:
>>> +member qnull:
>>> +member qnum:
>>> +member qstring:
>>> +member qdict:
>>> +member qlist:
>>> +member qbool:
>>> +object foo
>>> +member a: str optional=False
>>> +object q_empty
>>
>> This is a positive test, isn't it?  Positive tests go into
>> qapi-schema-test.json.
>>
>
> Right, I wonder why we have .exit files then. Perhaps the few ones
> that return 0 shouldn't exist.

There are a few legitimate positive test cases, such as empty.json and
doc-good.json.

Moreover, we occasionally add negative test cases that fail to fail,
demonstrating a bug.  Example: quoted-structural-chars in commit
98626572f1, fixed in commit c7a3f25200.



Re: [Qemu-devel] [PATCH v3 17/50] qapi: do not define enumeration value explicitely

2018-02-02 Thread Markus Armbruster
Marc-André Lureau  writes:

> Hi
>
> On Fri, Dec 8, 2017 at 8:50 AM, Markus Armbruster  wrote:
>> Marc-André Lureau  writes:
>>
>>> On Thu, Dec 7, 2017 at 5:23 PM, Markus Armbruster  wrote:
 Marc-André Lureau  writes:

> The C standard has the initial value at 0 and the subsequent values
> incremented by 1. No need to set this explicitely.
>
> This will prevent from artificial "gaps" when compiling out some enum
> values and having unnecessarily large MAX values & enums arrays.
>
> Signed-off-by: Marc-André Lureau 
> ---
>  scripts/qapi.py | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 94b735d8d6..074ee221a1 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -1985,14 +1985,11 @@ typedef enum %(c_name)s {
>  ''',
>  c_name=c_name(name))
>
> -i = 0
>  for value in enum_values:
>  ret += mcgen('''
> -%(c_enum)s = %(i)d,
> +%(c_enum)s,
>  ''',
> - c_enum=c_enum_const(name, value, prefix),
> - i=i)
> -i += 1
> + c_enum=c_enum_const(name, value, prefix))
>
>  ret += mcgen('''
>  } %(c_name)s;

 Recapitulate review of v2: this risks entertaining mishaps like
 compiling this one

 typedef enum Color {
 COLOR_WHITE,
 #if defined(NEED_CPU_H)
 #if defined(TARGET_S390X)
 COLOR_BLUE,
 #endif /* defined(TARGET_S390X) */
 #endif /* defined(NEED_CPU_H) */
 COLOR_BLACK,
 } Color;

 in s390x-code (COLOR_BLACK = 2) and in target-independent code
 (COLOR_BLACK = 1), then linking the two together.

 Same issue for struct members and such (previous patch).

 What's our story on preventing disaster here?

 In the long run, we want to split the generated code so that
 target-specific and target-independent code are separate, and each part
 is always compiled with consistent preprocessor symbols.  But I'm afraid
 that's not in the card right now.
>>>
>>> Eh, I need to refresh my memories about that series, but I think
>>> that's what I did in v3
>>>
>>> It doesn't use the NEED_CPU_H trick. It has a seperate per-target 
>>> target.json
>>
>> Looking... aha!  target.json appears in PATCH 44 (which I haven't even
>> glanced at, yet).  The problem appears in PATCH 16, though.  Perhaps a
>> bit of patch reshuffling would do.
>
> What problem appears in patch 16? Some code could be introduced using
> NEED_CPU_H and link arch & independent code together?

It's been a while...

Generated headers using conditionals must include the headers providing
the symbols used in conditionals.  Not doing so is an open death trap.

PATCH 16 sets up the first instance of the death trap.  Or maybe it's
PATCH 13.

However, including these headers only becomes possible *after* you split
off the target-specific stuff in PATCH 44.

Do I make any sense?

>   It is still true
> after patch 44. If necessary, I can work on a split-qapi series before
> the conditionals are added. But the real benefit is only apparent
> after the conditional are introduced, so I am not motivated to
> reorder.

Understand.

As a maintainer, I can ask for improvements, but the only lever I have
is saying no.  Which should be reserved for cases that are actually
wrong, or create inacceptable technical debt.  Temporary death traps
don't count as either.  For cases I merely hate, when asking doesn't
help, all I can do is do the work myself.  So I did:

[PATCH RFC 00/21] Modularize generated QAPI code
Message-Id: <20180202130336.24719-1-arm...@redhat.com>

[...]



[Qemu-devel] [PATCH v3] linux-user: Fix register used for 6th and 7th syscall argument on aarch64

2018-02-02 Thread Guido Günther
This unbreaks the testcase from

http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html

Thanks to Laurent Vivier for spotting the 7th one.

Signed-off-by: Guido Günther 
Tested-by: Philippe Mathieu-Daudé 
Suggested-by: Laurent Vivier 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Richard Henderson 
---
v3 collects *-by: replies. Anything else I can do to get this applied?

 linux-user/host/aarch64/safe-syscall.inc.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/linux-user/host/aarch64/safe-syscall.inc.S 
b/linux-user/host/aarch64/safe-syscall.inc.S
index 58a2329b37..bc1f5a9792 100644
--- a/linux-user/host/aarch64/safe-syscall.inc.S
+++ b/linux-user/host/aarch64/safe-syscall.inc.S
@@ -36,7 +36,7 @@ safe_syscall_base:
 *   and return the result in x0
 * and the syscall instruction needs
 *   x8 == syscall number
-*   x0 ... x7 == syscall arguments
+*   x0 ... x6 == syscall arguments
 *   and returns the result in x0
 * Shuffle everything around appropriately.
 */
@@ -47,8 +47,8 @@ safe_syscall_base:
mov x2, x4
mov x3, x5
mov x4, x6
-   mov x6, x7
-   ldr x7, [sp]
+   mov x5, x7
+   ldr x6, [sp]
 
/* This next sequence of code works in conjunction with the
 * rewind_if_safe_syscall_function(). If a signal is taken
-- 
2.15.1




[Qemu-devel] [PATCH v3 10/12] vl: drop full_screen variable

2018-02-02 Thread Gerd Hoffmann
Not used any more, delete it.

Signed-off-by: Gerd Hoffmann 
---
 vl.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/vl.c b/vl.c
index eb8aca9479..899fcad75e 100644
--- a/vl.c
+++ b/vl.c
@@ -149,7 +149,6 @@ static int rtc_utc = 1;
 static int rtc_date_offset = -1; /* -1 means no change */
 QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
-static int full_screen = 0;
 static DisplayOptions dpy;
 int no_frame;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
@@ -3659,7 +3658,6 @@ int main(int argc, char **argv, char **envp)
 loadvm = optarg;
 break;
 case QEMU_OPTION_full_screen:
-full_screen = 1;
 dpy.has_full_screen = true;
 dpy.full_screen = true;
 break;
-- 
2.9.3




Re: [Qemu-devel] [RFC] kvm: x86: export vCPU halted state to sysfs

2018-02-02 Thread Eduardo Habkost
(CCing qemu-devel)

On Fri, Feb 02, 2018 at 09:21:59AM -0500, Luiz Capitulino wrote:
> On Fri, 2 Feb 2018 14:19:38 +
> Daniel P. Berrangé  wrote:
> > On Fri, Feb 02, 2018 at 12:15:54PM -0200, Eduardo Habkost wrote:
[...]
> > > It would be also interesting to update QEMU QMP documentation to
> > > clarify the arch-specific semantics of "halted".  
> > 
> > Any also especially clarify the awful performance implications of running
> > this particular query command. In general I would not expect query-xxx
> > monitor commands to interrupt all vcpus, so we should clearly warn about
> > this !
> 
> Or deprecate it...

We could deprecate the expensive fields on query-cpus, and move
them to a more expensive query-cpu-state command.  I believe most
users of query-cpus are only interested in qom_path, thread_id,
and topology info.

Markus, Eric: from the QAPI point of view, is it OK to remove
fields between QEMU versions, as long as we follow our
deprecation policy?

-- 
Eduardo



Re: [Qemu-devel] [PATCH 1/2] qcow2: add overlap check for bitmap directory

2018-02-02 Thread Vladimir Sementsov-Ogievskiy

02.02.2018 16:00, Max Reitz wrote:

On 2018-02-02 13:07, Vladimir Sementsov-Ogievskiy wrote:

29.01.2018 18:34, Max Reitz wrote:

On 2017-11-30 17:47, Vladimir Sementsov-Ogievskiy wrote:

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
   block/qcow2.h  |  7 +--
   block/qcow2-refcount.c | 12 
   block/qcow2.c  |  6 ++
   3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index 6f0ff15dd0..8f226a3609 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -98,6 +98,7 @@
   #define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE
"overlap-check.snapshot-table"
   #define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1"
   #define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2"
+#define QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY
"overlap-check.bitmap-directory"
   #define QCOW2_OPT_CACHE_SIZE "cache-size"
   #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size"
   #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size"
@@ -406,8 +407,9 @@ typedef enum QCow2MetadataOverlap {
   QCOW2_OL_SNAPSHOT_TABLE_BITNR = 5,
   QCOW2_OL_INACTIVE_L1_BITNR    = 6,
   QCOW2_OL_INACTIVE_L2_BITNR    = 7,
+    QCOW2_OL_BITMAP_DIRECTORY_BITNR = 8,
   -    QCOW2_OL_MAX_BITNR    = 8,
+    QCOW2_OL_MAX_BITNR  = 9,
     QCOW2_OL_NONE   = 0,
   QCOW2_OL_MAIN_HEADER    = (1 << QCOW2_OL_MAIN_HEADER_BITNR),
@@ -420,12 +422,13 @@ typedef enum QCow2MetadataOverlap {
   /* NOTE: Checking overlaps with inactive L2 tables will result
in bdrv
    * reads. */
   QCOW2_OL_INACTIVE_L2    = (1 << QCOW2_OL_INACTIVE_L2_BITNR),
+    QCOW2_OL_BITMAP_DIRECTORY = (1 << QCOW2_OL_BITMAP_DIRECTORY_BITNR),
   } QCow2MetadataOverlap;
     /* Perform all overlap checks which can be done in constant time */
   #define QCOW2_OL_CONSTANT \
   (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 |
QCOW2_OL_REFCOUNT_TABLE | \
- QCOW2_OL_SNAPSHOT_TABLE)
+ QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_BITMAP_DIRECTORY)
     /* Perform all overlap checks which don't require disk access */
   #define QCOW2_OL_CACHED \
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 3de1ab51ba..a7a2703f26 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -2585,6 +2585,18 @@ int
qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t
offset,
   }
   }
   +    if ((chk & QCOW2_OL_BITMAP_DIRECTORY) &&
+    (s->autoclear_features & QCOW2_AUTOCLEAR_BITMAPS))
+    {
+    /* update_ext_header_and_dir_in_place firstly drop autoclear
flag,
+ * so it will not fail */

That's really not an argument.  bitmap_list_store() has to pass
QCOW2_OL_BITMAP_DIRECTORY to @ign anyway.  (Because there is no reason
not to.)

in_place is a reason. When we store directory in_place, it definitely
overlaps with current directory.

Well, then you just pass QCOW2_OL_BITMAP_DIRECTORY to @ign, which is
what that argument is for? :-)


hmm. but actually, I should not, because of zeroed autoclear flag. So,
do you think, it is better to pass it, anyway?



Max


But this is done with cleared autoclear flag (to make it safe), so we
will skip this check and will not
fail.



--
Best regards,
Vladimir




Re: [Qemu-devel] [PATCH 1/3] target/ppc: add basic support for PTCR on POWER9

2018-02-02 Thread Cédric Le Goater
On 02/02/2018 03:41 AM, Suraj Jitindar Singh wrote:
>>> +/*
>>> + * Partition table definitions
>>> + */
>>> +#define PTCR_PTAB   0x0000ULL /* Partition
>>> Table Base */
>>> +#define PTCR_PTAS   0x001FULL /* Partition
>>> Table Size */
>>> +
>> s/PTCR_PTAB/PTCR_PATB
>> s/PTCR_PTAS/PTCR_PATS
>> To match the ISA?
>
> Also these should be in target/ppc/mmu-book3s-v3.h, they're not hash
> specific
> 

OK. I Will fix that. 

Thanks,

C. 



Re: [Qemu-devel] [PATCH] pcie-root-port: let it has higher migrate priority

2018-02-02 Thread Peter Xu
On Thu, Feb 01, 2018 at 07:51:31PM +, Dr. David Alan Gilbert wrote:
> * Peter Xu (pet...@redhat.com) wrote:
> > In the past, we prioritized IOMMU migration so that we have such a
> > priority order:
> > 
> > IOMMU > PCI Devices
> > 
> > When migrating a guest with both vIOMMU and pcie-root-port, we'll always
> > migrate vIOMMU first, since pcie-root-port will be seen to have the same
> > priority of general PCI devices.
> > 
> > That's problematic.
> > 
> > The thing is that PCI bus number information is stored in the root port,
> > and that is needed by vIOMMU during post_load(), e.g., to figure out
> > context entry for a device.  If we don't have correct bus numbers for
> > devices, we won't be able to recover device state of the DMAR memory
> > regions, and things will be messed up.
> > 
> > So let's boost the PCIe root ports to be even with higher priority:
> > 
> >PCIe Root Port > IOMMU > PCI Devices
> > 
> > A smoke test shows that this patch fixes bug 1538953.
> 
> Two questions (partially overlapping with what I replied to Michaels):
>   a) What happens with multiple IOMMUs?

If there are more IOMMUs, then the patch will let all the vIOMMUs be
migrated after pcie root ports.

But a more true answer is that: I don't really know. :)

Because I even don't know how multiple vIOMMUs will coop with each
other, especially nested.  In nested case, maybe there will be
dependency between vIOMMUs, but I'll avoid thinking about that until
we support more than one vIOMMUs.

>   b) What happens with multiple root ports?

Same answer as previous one: all of them will be migrated before any
vIOMMUs.

Note that IMHO we don't care which pcie root port is migrated first -
IMHO they should not depend on each other, but Marcel may correct me.

>   c) How correct is this ordering on different implementations 
> (e.g. ARM/Power/etc)

Currently it won't affect since Intel IOMMU is the only user for
MIG_PRI_IOMMU.  After SMMU is merged it may affect (if it uses this
bit), but IMHO it's fine too as long as pcie root ports won't depend
on anything related to SMMU.

Thanks,

-- 
Peter Xu



[Qemu-devel] [PATCH v2 0/2] Add git-publish config file

2018-02-02 Thread Fam Zheng
v2: Add README paragraph [Marc-André, Stefan]
Fix 'trivial' profile [Marc-André]
Rename profiles [Stefan]

Fam Zheng (2):
  Add a git-publish configuration file
  README: Document 'git-publish' workflow

 .gitpublish | 58 ++
 README  | 30 +-
 2 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 .gitpublish

-- 
2.14.3




[Qemu-devel] [PULL 0/2] Audio 20180202 patches

2018-02-02 Thread Gerd Hoffmann
The following changes since commit b05631954d6dfe93340d516660397e2c1a2a5dd6:

  Merge remote-tracking branch 'remotes/rth/tags/pull-hppa-20180131' into 
staging (2018-01-31 15:50:29 +)

are available in the git repository at:

  git://git.kraxel.org/qemu tags/audio-20180202-pull-request

for you to fetch changes up to 8ec660b80ed511fa333679e38bf0cf714799d6fa:

  hw/audio/sb16.c: change dolog() to qemu_log_mask() (2018-02-02 08:19:47 +0100)


audio: two small fixes.



John Arbuckle (1):
  hw/audio/sb16.c: change dolog() to qemu_log_mask()

Philippe Mathieu-Daudé (1):
  hw/audio/wm8750: move WM8750 declarations from i2c/i2c.h to
audio/wm8750.h

 include/hw/audio/wm8750.h  | 30 ++
 include/hw/i2c/i2c.h   |  9 --
 hw/arm/musicpal.c  |  3 +-
 hw/arm/spitz.c |  3 +-
 hw/arm/z2.c|  3 +-
 hw/audio/marvell_88w8618.c |  1 +
 hw/audio/sb16.c| 79 +-
 hw/audio/wm8750.c  |  6 ++--
 8 files changed, 82 insertions(+), 52 deletions(-)
 create mode 100644 include/hw/audio/wm8750.h

-- 
2.9.3




Re: [Qemu-devel] [PATCH v6 13/23] hmp: display memory encryption support in 'info kvm'

2018-02-02 Thread Brijesh Singh


On 2/2/18 7:08 AM, Daniel P. Berrangé wrote:
> On Thu, Feb 01, 2018 at 08:04:43PM +, Dr. David Alan Gilbert wrote:
>> * Brijesh Singh (brijesh.si...@amd.com) wrote:
>>>
>>> On 2/1/18 11:58 AM, Dr. David Alan Gilbert wrote:
 * Brijesh Singh (brijesh.si...@amd.com) wrote:
> update 'info kvm' to display the memory encryption support.
>
> (qemu) info kvm
> kvm support: enabled
> memory encryption: disabled
 As Markus said, this should be split qmp/hmp; but something else to
 think about is whether this is a boolean or needs to be an enum;  do
 you have one version of encryption or are we going to need to flag up
 versions or the features of the encryption?
>>> In future I could see us providing encrypted state status when we
>>> implement SEV-ES support, something like
>>>
>>> (qemu) info kvm
>>> kvm support: enabled
>>> memory encryption: enabled
>>> cpu register state: encrypted
>>>
>>> but so far I do not see need to provide the version string. If user
>>> wants to know the SEV version then it can open /dev/sev device to get
>>> platform status and more.
>> Yes, I was worried a bit more about how general that was going to be
>> or whether we're collecting a lot of architecture specific fields here.
>> So I wondered, if it was an enum, whether that would be come:
>>
>> memory encryption: none
>>
>> memory encryption: SEV
>>
>> memory encryption: SEV-ES
>>
>> (I'm not too sure whether that's better or not, just a suggestion)
> I wonder if it is is even appropriate to have under 'info kvm', since
> 'info kvm' is architecture independant and SEV is specific to AMD x86_64
> only. It might suggest an 'info sev' command is better ?

The reason I kept under 'info kvm' is because now KVM has a ioctl for
memory encryption operation, I like your suggestion for  introducing
'info sev' -- the command can be used to provide additional SEV specific
details (e.g SEV FW state, SEV FW version, SEV active policy etc).

>
> Regards,
> Daniel




Re: [Qemu-devel] [Qemu-ppc] [PATCH] spapr: add missing break in h_get_cpu_characteristics()

2018-02-02 Thread Daniel Henrique Barboza



On 02/01/2018 05:47 PM, Greg Kurz wrote:

Detected by Coverity (CID 1385702). This fixes the recently added hypercall
to let guests properly apply Spectre and Meltdown workarounds.


Paolo Bonzini reported this error in a reply to the pull request that
added the patch:

"Re: [Qemu-ppc] [Qemu-devel] [PULL 12/12] target/ppc/spapr: Add H-Call 
H_GET_CPU_CHARACTERISTICS


On 28/01/2018 22:28, David Gibson wrote:


+switch (safe_indirect_branch) {
+case SPAPR_CAP_FIXED:
+characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;


Missing "break;" here.

Paolo

"

I think it is nice to mention in the commit msg that Paolo also detected 
this same error,

specially given that his email was sent before this patch.


Thanks,


Daniel




Fixes: c59704b25473 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS"
Signed-off-by: Greg Kurz 
---
  hw/ppc/spapr_hcall.c |1 +
  1 file changed, 1 insertion(+)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 4d0e6eb0cf1d..596f58378a40 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1697,6 +1697,7 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU 
*cpu,
  switch (safe_indirect_branch) {
  case SPAPR_CAP_FIXED:
  characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
+break;
  default: /* broken */
  assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
  break;






[Qemu-devel] [PATCH v3 01/12] vl: deprecate -no-frame

2018-02-02 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 vl.c  | 4 
 qemu-doc.texi | 7 +++
 2 files changed, 11 insertions(+)

diff --git a/vl.c b/vl.c
index e517a8d995..ac0efca708 100644
--- a/vl.c
+++ b/vl.c
@@ -2104,6 +2104,8 @@ static DisplayType select_display(const char *p)
 const char *nextopt;
 
 if (strstart(opts, ",frame=", )) {
+g_printerr("The frame= sdl option is deprecated, and will be\n"
+   "removed in a future release.\n");
 opts = nextopt;
 if (strstart(opts, "on", )) {
 no_frame = 0;
@@ -3642,6 +3644,8 @@ int main(int argc, char **argv, char **envp)
 full_screen = 1;
 break;
 case QEMU_OPTION_no_frame:
+g_printerr("The -no-frame switch is deprecated, and will be\n"
+   "removed in a future release.\n");
 no_frame = 1;
 break;
 case QEMU_OPTION_alt_grab:
diff --git a/qemu-doc.texi b/qemu-doc.texi
index 19a82bfea3..aa7180a3d9 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -2749,6 +2749,13 @@ filesystem test suite. Also it requires the 
CAP_DAC_READ_SEARCH capability,
 which is not the recommended way to run QEMU. This backend should not be
 used and it will be removed with no replacement.
 
+@subsection -no-frame (since 2.12.0)
+
+The ``-no-frame'' argument works with SDL 1.2 only.  SDL 2.0 lacks
+support for frameless windows, and the other user interfaces never
+implemented this in the first place.  So this will be removed together
+with SDL 1.2 support.
+
 @section qemu-img command line arguments
 
 @subsection convert -s (since 2.0.0)
-- 
2.9.3




[Qemu-devel] [PATCH v3 03/12] vl: rename DisplayType to LegacyDisplayType

2018-02-02 Thread Gerd Hoffmann
qapi DisplayType will replace the current enum.  For the transition both
will coexist though, so rename it so we don't have a name clash.

Signed-off-by: Gerd Hoffmann 
---
 vl.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/vl.c b/vl.c
index fa19a61500..a2478412c7 100644
--- a/vl.c
+++ b/vl.c
@@ -2082,7 +2082,7 @@ static void select_vgahw(const char *p)
 }
 }
 
-typedef enum DisplayType {
+typedef enum LegacyDisplayType {
 DT_DEFAULT,
 DT_CURSES,
 DT_SDL,
@@ -2090,12 +2090,12 @@ typedef enum DisplayType {
 DT_GTK,
 DT_EGL,
 DT_NONE,
-} DisplayType;
+} LegacyDisplayType;
 
-static DisplayType select_display(const char *p)
+static LegacyDisplayType select_display(const char *p)
 {
 const char *opts;
-DisplayType display = DT_DEFAULT;
+LegacyDisplayType display = DT_DEFAULT;
 
 if (strstart(p, "sdl", )) {
 #ifdef CONFIG_SDL
@@ -3058,7 +3058,7 @@ int main(int argc, char **argv, char **envp)
 const char *incoming = NULL;
 bool userconfig = true;
 bool nographic = false;
-DisplayType display_type = DT_DEFAULT;
+LegacyDisplayType display_type = DT_DEFAULT;
 int display_remote = 0;
 const char *log_mask = NULL;
 const char *log_file = NULL;
-- 
2.9.3




[Qemu-devel] [PATCH v3 05/12] sdl: use DisplayOptions

2018-02-02 Thread Gerd Hoffmann
Switch sdl ui to use qapi DisplayOptions for configuration.

Signed-off-by: Gerd Hoffmann 
---
 include/ui/console.h |  8 
 ui/sdl.c | 19 +--
 ui/sdl2.c| 33 +++--
 vl.c | 13 +++--
 qapi/ui.json |  5 +++--
 5 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 58d1a3d27c..deee5bb606 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -435,16 +435,16 @@ void surface_gl_setup_viewport(QemuGLShader *gls,
 
 /* sdl.c */
 #ifdef CONFIG_SDL
-void sdl_display_early_init(int opengl);
-void sdl_display_init(DisplayState *ds, int full_screen);
+void sdl_display_early_init(DisplayOptions *opts);
+void sdl_display_init(DisplayState *ds, DisplayOptions *opts);
 #else
-static inline void sdl_display_early_init(int opengl)
+static inline void sdl_display_early_init(DisplayOptions *opts)
 {
 /* This must never be called if CONFIG_SDL is disabled */
 error_report("SDL support is disabled");
 abort();
 }
-static inline void sdl_display_init(DisplayState *ds, int full_screen)
+static inline void sdl_display_init(DisplayState *ds, DisplayOptions *opts)
 {
 /* This must never be called if CONFIG_SDL is disabled */
 error_report("SDL support is disabled");
diff --git a/ui/sdl.c b/ui/sdl.c
index c8f102bb9f..ca27e40299 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -41,6 +41,7 @@
 
 static DisplayChangeListener *dcl;
 static DisplaySurface *surface;
+static DisplayOptions *opts;
 static SDL_Surface *real_screen;
 static SDL_Surface *guest_screen = NULL;
 static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
@@ -762,6 +763,7 @@ static void handle_activation(SDL_Event *ev)
 static void sdl_refresh(DisplayChangeListener *dcl)
 {
 SDL_Event ev1, *ev = 
+bool allow_close = true;
 int idle = 1;
 
 if (last_vm_running != runstate_is_running()) {
@@ -786,7 +788,10 @@ static void sdl_refresh(DisplayChangeListener *dcl)
 handle_keyup(ev);
 break;
 case SDL_QUIT:
-if (!no_quit) {
+if (opts->has_window_close && !opts->window_close) {
+allow_close = false;
+}
+if (allow_close) {
 no_shutdown = 0;
 qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
 }
@@ -885,9 +890,9 @@ static const DisplayChangeListenerOps dcl_ops = {
 .dpy_cursor_define= sdl_mouse_define,
 };
 
-void sdl_display_early_init(int opengl)
+void sdl_display_early_init(DisplayOptions *opts)
 {
-if (opengl == 1 /* on */) {
+if (opts->has_gl && opts->gl) {
 fprintf(stderr,
 "SDL1 display code has no opengl support.\n"
 "Please recompile qemu with SDL2, using\n"
@@ -895,7 +900,7 @@ void sdl_display_early_init(int opengl)
 }
 }
 
-void sdl_display_init(DisplayState *ds, int full_screen)
+void sdl_display_init(DisplayState *ds, DisplayOptions *o)
 {
 int flags;
 uint8_t data = 0;
@@ -903,6 +908,8 @@ void sdl_display_init(DisplayState *ds, int full_screen)
 SDL_SysWMinfo info;
 char *filename;
 
+assert(o->type == DISPLAY_TYPE_SDL);
+opts = o;
 #if defined(__APPLE__)
 /* always use generic keymaps */
 if (!keyboard_layout)
@@ -917,7 +924,7 @@ void sdl_display_init(DisplayState *ds, int full_screen)
 g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n"
"in a future release. Please switch to SDL 2.0 instead\n");
 
-if (!full_screen) {
+if (opts->has_full_screen && opts->full_screen) {
 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
 }
 #ifdef __linux__
@@ -960,7 +967,7 @@ void sdl_display_init(DisplayState *ds, int full_screen)
 g_free(filename);
 }
 
-if (full_screen) {
+if (opts->has_full_screen && opts->full_screen) {
 gui_fullscreen = 1;
 sdl_grab_start();
 }
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 812c315891..094782e36c 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -32,6 +32,7 @@
 
 static int sdl2_num_outputs;
 static struct sdl2_console *sdl2_console;
+static DisplayOptions *opts;
 
 static SDL_Surface *guest_sprite_surface;
 static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
@@ -525,6 +526,7 @@ static void handle_mousewheel(SDL_Event *ev)
 static void handle_windowevent(SDL_Event *ev)
 {
 struct sdl2_console *scon = get_scon_from_window(ev->window.windowID);
+bool allow_close = true;
 
 if (!scon) {
 return;
@@ -571,7 +573,10 @@ static void handle_windowevent(SDL_Event *ev)
 break;
 case SDL_WINDOWEVENT_CLOSE:
 if (qemu_console_is_graphic(scon->dcl.con)) {
-if (!no_quit) {
+if (opts->has_window_close && !opts->window_close) {
+allow_close = false;
+}
+if (allow_close) {
 

Re: [Qemu-devel] [PATCH 1/1] nbd: implement bdrv_get_info callback

2018-02-02 Thread Edgar Kaziakhmedov



On 01/26/2018 05:28 PM, Eric Blake wrote:

On 01/26/2018 06:39 AM, Edgar Kaziakhmedov wrote:

PIng

So, let me know if I need to make any changes in patch

On 1/18/18 1:09 PM, Paolo Bonzini wrote:

On 18/01/2018 12:51, Edgar Kaziakhmedov wrote:

+static int nbd_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+{
+    if (bs->supported_zero_flags & BDRV_REQ_MAY_UNMAP) {
+    bdi->can_write_zeroes_with_unmap = true;
+    }
+    return 0;
+}
+

Other drivers set the flag always, while NBD only sets it if the server
knows the flag.

Well, other drivers may be able to always implement it (NBD can only
implement it if the server supports WRITE_ZEROES - and I'm even in the
middle of working up an nbdkit patch [1] that makes it easier to write
an NBD server that specifically does not support WRITE_ZEROES to make
code paths like this easier to test)

[1]


I think NBD is more correct, so:

Reviewed-by: Paolo Bonzini 

Agreed; I'm fine queueing this on my NBD queue, except I'd first like to
hear Kevin's opinion:


However, it would be nice to remove can_write_zeroes_with_unmap from
BlockDriverInfo, and make bdrv_can_write_zeroes_with_unmap just return
!!(bs->supported_zero_flags & BDRV_REQ_MAY_UNMAP).  Kevin, what do you
think?

Actually, I may even just give a shot at writing this alternative patch,
to make Kevin's decision easier.
But actually qcow2 performs some checks for version inside get_info 
callback before setting can_write_zeroes_with_unmap flag,
so we can't take into account such checks in 
bdrv_can_write_zeroes_with_unmap subroutine. Therefore, I don't think it 
is possible to do it like that.





[Qemu-devel] [PATCH] s390x/sclp: fix event mask handling

2018-02-02 Thread Christian Borntraeger
commit 67915de9f038 ("s390x/event-facility: variable-length event
masks") switches the sclp receive/send mask. This broke the sclp
lm console.

Signed-off-by: Christian Borntraeger 
Fixes: commit 67915de9f038 ("s390x/event-facility: variable-length event masks")
Cc: Cornelia Huck 
Cc: Jason J. Herne 
Cc: qemu-sta...@nongnu.org
---
 hw/s390x/event-facility.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index b0f71f4554..155a69467b 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -293,10 +293,10 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB 
*sccb)
 ef->receive_mask = be32_to_cpu(tmp_mask);
 
 /* return the SCLP's capability masks to the guest */
-tmp_mask = cpu_to_be32(get_host_send_mask(ef));
+tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
 copy_mask(WEM_RECEIVE_MASK(we_mask, mask_length), (uint8_t *)_mask,
   mask_length, sizeof(tmp_mask));
-tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
+tmp_mask = cpu_to_be32(get_host_send_mask(ef));
 copy_mask(WEM_SEND_MASK(we_mask, mask_length), (uint8_t *)_mask,
   mask_length, sizeof(tmp_mask));
 
-- 
2.14.3




Re: [Qemu-devel] [PATCH v2 0/6] qmp dirty bitmap API

2018-02-02 Thread Vladimir Sementsov-Ogievskiy

22.01.2018 20:23, John Snow wrote:


On 01/22/2018 07:22 AM, Vladimir Sementsov-Ogievskiy wrote:

22.01.2018 12:20, Vladimir Sementsov-Ogievskiy wrote:

20.01.2018 02:30, John Snow wrote:

On 01/16/2018 07:54 AM, Vladimir Sementsov-Ogievskiy wrote:

Hi all.

There are three qmp commands, needed to implement external backup API.

Using these three commands, client may do all needed bitmap
management by
hand:

on backup start we need to do a transaction:
   {disable old bitmap, create new bitmap}

on backup success:
   drop old bitmap

on backup fail:
   enable old bitmap
   merge new bitmap to old bitmap
   drop new bitmap

v2: fix merge command deadlock
    add new patches: 1 and 6

Vladimir Sementsov-Ogievskiy (6):
    block: maintain persistent disabled bitmaps
    block/dirty-bitmap: add lock to bdrv_enable/disable_dirty_bitmap
    qapi: add block-dirty-bitmap-enable/disable
    qmp: transaction support for block-dirty-bitmap-enable/disable
    qapi: add block-dirty-bitmap-merge
    qapi: add disabled parameter to block-dirty-bitmap-add

   qapi/block-core.json |  92 ++-
   qapi/transaction.json    |   4 +
   block/qcow2.h    |   2 +-
   include/block/dirty-bitmap.h |   3 +-
   block/dirty-bitmap.c |  42 ++-
   block/qcow2-bitmap.c |  12 +--
   block/qcow2.c    |   2 +-
   blockdev.c   | 169
+--
   8 files changed, 287 insertions(+), 39 deletions(-)


Fails to apply to master (b384cd95) on patch four and five. Only
contextual problems, I've patched it up and I'll review that.

(mirrored here if you want to check my rebase work:
https://github.com/jnsnow/qemu/tree/vlad-review)

Since I was full of such bad and stupid ideas last time, I'd like
someone else to look over this one for design and I'll just review it
for accuracy.

--js

Thank you for review, John!

Ok, so, I'll going to:

- take patch 1 into migration and respin it today (I hope) with test
about qcow2-based bitmap migration disabled.
- separate fixes and refactoring from here (locking + _bitmap_clear
transaction), send them separately
- than, make test for external backup and respin these series with it


changed to:

1. send patch 1/6 separately with the whole reasoning[done], as it
blocks two series, wait for accepting
2. respin postcopy series
3. finish up discussion on bitmap locking under "[PATCH v9 03/13]
block/dirty-bitmap: add _locked version of bdrv_reclaim_dirty_bitmap"
4. separate fixes and refactoring from here (locking + _bitmap_clear
transaction), send them separately
5. make test for external backup and respin these series with it

2 depends on 1
4 depends on 3
5 depends on 1 and 4


Great, thanks!


Sorry for long delay, I was ill. Now I'm returning to these plans.

--
Best regards,
Vladimir




[Qemu-devel] [PATCH v3 09/12] cocoa: use DisplayOptions

2018-02-02 Thread Gerd Hoffmann
Switch cocoa ui to use qapi DisplayOptions for configuration.

Signed-off-by: Gerd Hoffmann 
---
 include/ui/console.h | 4 ++--
 vl.c | 3 ++-
 qapi/ui.json | 6 --
 ui/cocoa.m   | 4 ++--
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 9749503aa7..f96fd907d0 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -454,9 +454,9 @@ static inline void sdl_display_init(DisplayState *ds, 
DisplayOptions *opts)
 
 /* cocoa.m */
 #ifdef CONFIG_COCOA
-void cocoa_display_init(DisplayState *ds, int full_screen);
+void cocoa_display_init(DisplayState *ds, DisplayOptions *opts);
 #else
-static inline void cocoa_display_init(DisplayState *ds, int full_screen)
+static inline void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
 {
 /* This must never be called if CONFIG_COCOA is disabled */
 error_report("Cocoa support is disabled");
diff --git a/vl.c b/vl.c
index 6fa65c0dbd..eb8aca9479 100644
--- a/vl.c
+++ b/vl.c
@@ -4355,6 +4355,7 @@ int main(int argc, char **argv, char **envp)
 dpy.type = DISPLAY_TYPE_SDL;
 #elif defined(CONFIG_COCOA)
 display_type = DT_COCOA;
+dpy.type = DISPLAY_TYPE_COCOA;
 #elif defined(CONFIG_VNC)
 vnc_parse("localhost:0,to=99,id=default", _abort);
 #else
@@ -4716,7 +4717,7 @@ int main(int argc, char **argv, char **envp)
 sdl_display_init(ds, );
 break;
 case DT_COCOA:
-cocoa_display_init(ds, full_screen);
+cocoa_display_init(ds, );
 break;
 case DT_GTK:
 gtk_display_init(ds, );
diff --git a/qapi/ui.json b/qapi/ui.json
index 59597cfb3b..aca5402746 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1017,7 +1017,8 @@
 #
 ##
 { 'enum': 'DisplayType',
-  'data': [ 'none', 'gtk', 'sdl', 'egl-headless', 'curses' ] }
+  'data': [ 'none', 'gtk', 'sdl',
+'egl-headless', 'curses', 'cocoa' ] }
 
 ##
 # @DisplayOptions:
@@ -1042,4 +1043,5 @@
 'gtk': 'DisplayGTK',
 'sdl': 'DisplayNoOpts',
 'egl-headless'   : 'DisplayNoOpts',
-'curses' : 'DisplayNoOpts' } }
+'curses' : 'DisplayNoOpts',
+'cocoa'  : 'DisplayNoOpts' } }
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 6be9848391..3e34d15716 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1682,12 +1682,12 @@ static void addRemovableDevicesMenuItems(void)
 qapi_free_BlockInfoList(pointerToFree);
 }
 
-void cocoa_display_init(DisplayState *ds, int full_screen)
+void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
 {
 COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n");
 
 /* if fullscreen mode is to be used */
-if (full_screen == true) {
+if (opts->has_full_screen && opts->full_screen) {
 [NSApp activateIgnoringOtherApps: YES];
 [(QemuCocoaAppController *)[[NSApplication sharedApplication] 
delegate] toggleFullScreen: nil];
 }
-- 
2.9.3




Re: [Qemu-devel] [PATCH] s390x/sclp: fix event mask handling

2018-02-02 Thread Christian Borntraeger


On 02/02/2018 10:42 AM, Christian Borntraeger wrote:
> commit 67915de9f038 ("s390x/event-facility: variable-length event
> masks") switches the sclp receive/send mask. This broke the sclp
> lm console.
> 
> Signed-off-by: Christian Borntraeger 
> Fixes: commit 67915de9f038 ("s390x/event-facility: variable-length event 
> masks")
> Cc: Cornelia Huck 

opps. Please fixup yourself Conny :-)

> Cc: Jason J. Herne 
> Cc: qemu-sta...@nongnu.org
> ---
>  hw/s390x/event-facility.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index b0f71f4554..155a69467b 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -293,10 +293,10 @@ static void write_event_mask(SCLPEventFacility *ef, 
> SCCB *sccb)
>  ef->receive_mask = be32_to_cpu(tmp_mask);
> 
>  /* return the SCLP's capability masks to the guest */
> -tmp_mask = cpu_to_be32(get_host_send_mask(ef));
> +tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
>  copy_mask(WEM_RECEIVE_MASK(we_mask, mask_length), (uint8_t *)_mask,
>mask_length, sizeof(tmp_mask));
> -tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
> +tmp_mask = cpu_to_be32(get_host_send_mask(ef));
>  copy_mask(WEM_SEND_MASK(we_mask, mask_length), (uint8_t *)_mask,
>mask_length, sizeof(tmp_mask));
> 




[Qemu-devel] [PATCH v2 2/2] README: Document 'git-publish' workflow

2018-02-02 Thread Fam Zheng
Signed-off-by: Fam Zheng 
---
 .gitpublish |  1 +
 README  | 30 +-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/.gitpublish b/.gitpublish
index 170bd2ed48..7542e878fc 100644
--- a/.gitpublish
+++ b/.gitpublish
@@ -26,6 +26,7 @@ cccmd = scripts/get_maintainer.pl --noroles --norolestats 
--nogit --nogit-fallba
 base = master
 prefix = PATCH
 to = qemu-devel@nongnu.org
+cc = qemu-triv...@nongnu.org
 cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
 
 [gitpublishprofile "block"]
diff --git a/README b/README
index b92a07a61a..d1a944ce20 100644
--- a/README
+++ b/README
@@ -56,7 +56,7 @@ The QEMU source code is maintained under the GIT version 
control system.
 
git clone git://git.qemu.org/qemu.git
 
-When submitting patches, the preferred approach is to use 'git
+When submitting patches, one common approach is to use 'git
 format-patch' and/or 'git send-email' to format & send the mail to the
 qemu-devel@nongnu.org mailing list. All patches submitted must contain
 a 'Signed-off-by' line from the author. Patches should follow the
@@ -68,6 +68,34 @@ the QEMU website
   https://qemu.org/Contribute/SubmitAPatch
   https://qemu.org/Contribute/TrivialPatches
 
+A 'git-profile' utility was created to make above process less
+cumbersome, and is highly recommended for making regular contributions,
+or even just for sending consecutive patch series revisions. It also
+requires a working 'git send-email' setup, and by default doesn't
+automate everything, so you may want to go through the above steps
+manually for once.
+
+For installation instructions, please go to
+
+  https://github.com/stefanha/git-publish
+
+The workflow with 'git-publish' is:
+
+  $ git checkout master -b my-feature
+  $ # work on new commits, add your 'Signed-off-by' lines to each
+  $ git publish
+
+Your patch series will be sent and tagged as my-feature-v1 if you need to refer
+back to it in the future.
+
+Sending v2:
+
+  $ git checkout my-feature # same topic branch
+  $ # making changes to the commits (using 'git rebase', for example)
+  $ git publish
+
+Your patch series will be sent with 'v2' tag in the subject and the git tip
+will be tagged as my-feature-v2.
 
 Bug reporting
 =
-- 
2.14.3




Re: [Qemu-devel] [PATCH V9 3/4] pvrdma: initial implementation

2018-02-02 Thread Marcel Apfelbaum
On 02/02/2018 14:08, Dotan Barak wrote:
> Reviewed-by: Dotan Barak 
> 

The Mellanox review for the RDMA code is very much appreciated!

Thanks Dotan, we know you put much effort into it and the V9
re-spin quality just went up :)
Marcel


> 
> *From:* Marcel Apfelbaum 
> *To:* qemu-devel@nongnu.org
> *Cc:* ehabk...@redhat.com; yuval.sh...@oracle.com; mar...@redhat.com; 
> pbonz...@redhat.com; m...@redhat.com;
> coh...@redhat.com; dotan...@yahoo.com
> *Sent:* Thursday, February 1, 2018 10:55 PM
> *Subject:* [Qemu-devel] [PATCH V9 3/4] pvrdma: initial implementation
> 
> From: Yuval Shaia >
> 
> PVRDMA is the QEMU implementation of VMware's paravirtualized RDMA device.
> It works with its Linux Kernel driver AS IS, no need for any special guest
> modifications.
> 
> While it complies with the VMware device, it can also communicate with bare
> metal RDMA-enabled machines and does not require an RDMA HCA in the host, it
> can work with Soft-RoCE (rxe).
> 
> It does not require the whole guest RAM to be pinned allowing memory
> over-commit and, even if not implemented yet, migration support will be
> possible with some HW assistance.
> 
> Signed-off-by: Yuval Shaia  >
> Signed-off-by: Marcel Apfelbaum >
> 
> 
> 




Re: [Qemu-devel] [PATCH v3 1/1] s390x/cpu: expose the guest crash information

2018-02-02 Thread Eric Blake
On 02/02/2018 08:37 AM, Christian Borntraeger wrote:
> This patch is the s390 implementation of guest crash information,
> similar to commit d187e08dc4 ("i386/cpu: add crash-information QOM
> property") and the related commits. We will detect several crash
> reasons, with the "disabled wait" being the most important one, since
> this is used by all s390 guests as a "panic like" notification.
> 
> Demonstrate these ways with examples as follows.
> 
>   1. crash-information QOM property;

> 
> Co-authored-by: Jing Liu 
> Signed-off-by: Christian Borntraeger 
> ---
>  qapi/run-state.json   | 29 --

QAPI changes look reasonable; I'll leave the review of the
target-specific code to those more familiar with the target.

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH v3 08/12] curses: use DisplayOptions

2018-02-02 Thread Gerd Hoffmann
Switch curses ui to use qapi DisplayOptions for configuration.

Signed-off-by: Gerd Hoffmann 
---
 include/ui/console.h | 4 ++--
 ui/curses.c  | 2 +-
 vl.c | 4 +++-
 qapi/ui.json | 5 +++--
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 4cb623112e..9749503aa7 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -496,9 +496,9 @@ static inline int vnc_init_func(void *opaque, QemuOpts 
*opts, Error **errp)
 
 /* curses.c */
 #ifdef CONFIG_CURSES
-void curses_display_init(DisplayState *ds, int full_screen);
+void curses_display_init(DisplayState *ds, DisplayOptions *opts);
 #else
-static inline void curses_display_init(DisplayState *ds, int full_screen)
+static inline void curses_display_init(DisplayState *ds, DisplayOptions *opts)
 {
 /* This must never be called if CONFIG_CURSES is disabled */
 error_report("curses support is disabled");
diff --git a/ui/curses.c b/ui/curses.c
index 85503876c0..479b77bd03 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -434,7 +434,7 @@ static const DisplayChangeListenerOps dcl_ops = {
 .dpy_text_cursor = curses_cursor_position,
 };
 
-void curses_display_init(DisplayState *ds, int full_screen)
+void curses_display_init(DisplayState *ds, DisplayOptions *opts)
 {
 #ifndef _WIN32
 if (!isatty(1)) {
diff --git a/vl.c b/vl.c
index 1d801dd96d..6fa65c0dbd 100644
--- a/vl.c
+++ b/vl.c
@@ -2189,6 +2189,7 @@ static LegacyDisplayType select_display(const char *p)
 } else if (strstart(p, "curses", )) {
 #ifdef CONFIG_CURSES
 display = DT_CURSES;
+dpy.type = DISPLAY_TYPE_CURSES;
 #else
 error_report("curses support is disabled");
 exit(1);
@@ -3275,6 +3276,7 @@ int main(int argc, char **argv, char **envp)
 case QEMU_OPTION_curses:
 #ifdef CONFIG_CURSES
 display_type = DT_CURSES;
+dpy.type = DISPLAY_TYPE_CURSES;
 #else
 error_report("curses support is disabled");
 exit(1);
@@ -4708,7 +4710,7 @@ int main(int argc, char **argv, char **envp)
 /* init local displays */
 switch (display_type) {
 case DT_CURSES:
-curses_display_init(ds, full_screen);
+curses_display_init(ds, );
 break;
 case DT_SDL:
 sdl_display_init(ds, );
diff --git a/qapi/ui.json b/qapi/ui.json
index cc489b7856..59597cfb3b 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1017,7 +1017,7 @@
 #
 ##
 { 'enum': 'DisplayType',
-  'data': [ 'none', 'gtk', 'sdl', 'egl-headless' ] }
+  'data': [ 'none', 'gtk', 'sdl', 'egl-headless', 'curses' ] }
 
 ##
 # @DisplayOptions:
@@ -1041,4 +1041,5 @@
   'data': { 'none'   : 'DisplayNoOpts',
 'gtk': 'DisplayGTK',
 'sdl': 'DisplayNoOpts',
-'egl-headless'   : 'DisplayNoOpts' } }
+'egl-headless'   : 'DisplayNoOpts',
+'curses' : 'DisplayNoOpts' } }
-- 
2.9.3




Re: [Qemu-devel] [PATCH 1/1] nbd: implement bdrv_get_info callback

2018-02-02 Thread Edgar Kaziakhmedov



On 02/02/2018 05:15 PM, Eric Blake wrote:

On 02/02/2018 08:06 AM, Edgar Kaziakhmedov wrote:


However, it would be nice to remove can_write_zeroes_with_unmap from
BlockDriverInfo, and make bdrv_can_write_zeroes_with_unmap just return
!!(bs->supported_zero_flags & BDRV_REQ_MAY_UNMAP).  Kevin, what do you
think?

Actually, I may even just give a shot at writing this alternative patch,
to make Kevin's decision easier.

But actually qcow2 performs some checks for version inside get_info
callback before setting can_write_zeroes_with_unmap flag,
so we can't take into account such checks in
bdrv_can_write_zeroes_with_unmap subroutine. Therefore, I don't think it
is possible to do it like that.

Here's the patch I proposed (it looks like I forgot to CC you):

https://lists.gnu.org/archive/html/qemu-devel/2018-01/msg06471.html


Yes, it was possible to move check to open, ok, get it.



[Qemu-devel] [PATCH v3 02/12] vl: deprecate -alt-grab and -ctrl-grab

2018-02-02 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 vl.c  | 8 
 qemu-doc.texi | 6 ++
 2 files changed, 14 insertions(+)

diff --git a/vl.c b/vl.c
index ac0efca708..fa19a61500 100644
--- a/vl.c
+++ b/vl.c
@@ -2115,6 +2115,8 @@ static DisplayType select_display(const char *p)
 goto invalid_sdl_args;
 }
 } else if (strstart(opts, ",alt_grab=", )) {
+g_printerr("The alt_grab= sdl option is deprecated, and will 
be\n"
+   "removed in a future release.\n");
 opts = nextopt;
 if (strstart(opts, "on", )) {
 alt_grab = 1;
@@ -2124,6 +2126,8 @@ static DisplayType select_display(const char *p)
 goto invalid_sdl_args;
 }
 } else if (strstart(opts, ",ctrl_grab=", )) {
+g_printerr("The ctrl_grab= sdl option is deprecated, and will 
be\n"
+   "removed in a future release.\n");
 opts = nextopt;
 if (strstart(opts, "on", )) {
 ctrl_grab = 1;
@@ -3649,9 +3653,13 @@ int main(int argc, char **argv, char **envp)
 no_frame = 1;
 break;
 case QEMU_OPTION_alt_grab:
+g_printerr("The -alt-grab switch is deprecated, and will be\n"
+   "removed in a future release.\n");
 alt_grab = 1;
 break;
 case QEMU_OPTION_ctrl_grab:
+g_printerr("The -ctrl-grab switch is deprecated, and will be\n"
+   "removed in a future release.\n");
 ctrl_grab = 1;
 break;
 case QEMU_OPTION_no_quit:
diff --git a/qemu-doc.texi b/qemu-doc.texi
index aa7180a3d9..5961c7a211 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -2756,6 +2756,12 @@ support for frameless windows, and the other user 
interfaces never
 implemented this in the first place.  So this will be removed together
 with SDL 1.2 support.
 
+@subsection -alt-grab and -ctrl-grab (since 2.12.0)
+
+The ``-alt-grab'' and ``-ctrl-grab'' arguments are deprecated.  They
+work with SDL only.  They will eventually replaced with a new way to
+configure hotkeys which works consistently across all user interfaces.
+
 @section qemu-img command line arguments
 
 @subsection convert -s (since 2.0.0)
-- 
2.9.3




[Qemu-devel] [PATCH 3/4] MAINTAINERS: add pointer to tpm-next repository

2018-02-02 Thread Stefan Berger
Signed-off-by: Stefan Berger 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index f8deaf6..d352d16 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1593,6 +1593,7 @@ F: include/hw/acpi/tpm.h
 F: include/sysemu/tpm*
 F: qapi/tpm.json
 F: backends/tpm.c
+T: git git://github.com/stefanberger/qemu-tpm.git tpm-next
 
 Checkpatch
 S: Odd Fixes
-- 
2.5.5




Re: [Qemu-devel] [PATCH 1/2] qcow2: add overlap check for bitmap directory

2018-02-02 Thread Vladimir Sementsov-Ogievskiy

02.02.2018 16:53, Max Reitz wrote:

On 2018-02-02 14:48, Vladimir Sementsov-Ogievskiy wrote:

02.02.2018 16:00, Max Reitz wrote:

On 2018-02-02 13:07, Vladimir Sementsov-Ogievskiy wrote:

29.01.2018 18:34, Max Reitz wrote:

On 2017-11-30 17:47, Vladimir Sementsov-Ogievskiy wrote:

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
    block/qcow2.h  |  7 +--
    block/qcow2-refcount.c | 12 
    block/qcow2.c  |  6 ++
    3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index 6f0ff15dd0..8f226a3609 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -98,6 +98,7 @@
    #define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE
"overlap-check.snapshot-table"
    #define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1"
    #define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2"
+#define QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY
"overlap-check.bitmap-directory"
    #define QCOW2_OPT_CACHE_SIZE "cache-size"
    #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size"
    #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size"
@@ -406,8 +407,9 @@ typedef enum QCow2MetadataOverlap {
    QCOW2_OL_SNAPSHOT_TABLE_BITNR = 5,
    QCOW2_OL_INACTIVE_L1_BITNR    = 6,
    QCOW2_OL_INACTIVE_L2_BITNR    = 7,
+    QCOW2_OL_BITMAP_DIRECTORY_BITNR = 8,
    -    QCOW2_OL_MAX_BITNR    = 8,
+    QCOW2_OL_MAX_BITNR  = 9,
      QCOW2_OL_NONE   = 0,
    QCOW2_OL_MAIN_HEADER    = (1 << QCOW2_OL_MAIN_HEADER_BITNR),
@@ -420,12 +422,13 @@ typedef enum QCow2MetadataOverlap {
    /* NOTE: Checking overlaps with inactive L2 tables will result
in bdrv
     * reads. */
    QCOW2_OL_INACTIVE_L2    = (1 << QCOW2_OL_INACTIVE_L2_BITNR),
+    QCOW2_OL_BITMAP_DIRECTORY = (1 <<
QCOW2_OL_BITMAP_DIRECTORY_BITNR),
    } QCow2MetadataOverlap;
      /* Perform all overlap checks which can be done in constant
time */
    #define QCOW2_OL_CONSTANT \
    (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 |
QCOW2_OL_REFCOUNT_TABLE | \
- QCOW2_OL_SNAPSHOT_TABLE)
+ QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_BITMAP_DIRECTORY)
      /* Perform all overlap checks which don't require disk access */
    #define QCOW2_OL_CACHED \
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 3de1ab51ba..a7a2703f26 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -2585,6 +2585,18 @@ int
qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t
offset,
    }
    }
    +    if ((chk & QCOW2_OL_BITMAP_DIRECTORY) &&
+    (s->autoclear_features & QCOW2_AUTOCLEAR_BITMAPS))
+    {
+    /* update_ext_header_and_dir_in_place firstly drop autoclear
flag,
+ * so it will not fail */

That's really not an argument.  bitmap_list_store() has to pass
QCOW2_OL_BITMAP_DIRECTORY to @ign anyway.  (Because there is no reason
not to.)

in_place is a reason. When we store directory in_place, it definitely
overlaps with current directory.

Well, then you just pass QCOW2_OL_BITMAP_DIRECTORY to @ign, which is
what that argument is for? :-)

hmm. but actually, I should not, because of zeroed autoclear flag. So,
do you think, it is better to pass it, anyway?

Yes.  That flag describes what kind of metadata structures you are
planning to overwrite, and you *are* planning to overwrite the bitmap
directory, so you should set it.

Max



Ok, reasonable. I'll respin with that fixed.

--
Best regards,
Vladimir




Re: [Qemu-devel] [PATCH 1/3] target/ppc: add basic support for PTCR on POWER9

2018-02-02 Thread Cédric Le Goater
On 02/02/2018 03:34 AM, Suraj Jitindar Singh wrote:
> On Wed, 2018-01-31 at 09:27 +0100, Cédric Le Goater wrote:
>> The Partition Table Control Register (PTCR) is a hypervisor
>> privileged
>> SPR. It contains the host real address of the Partition Table and its
>> size.
>>
>> Signed-off-by: Cédric Le Goater 
>> ---
>>  target/ppc/cpu.h|  2 ++
>>  target/ppc/helper.h |  1 +
>>  target/ppc/misc_helper.c| 12 
>>  target/ppc/mmu-hash64.h |  6 ++
>>  target/ppc/mmu_helper.c | 28 
>>  target/ppc/translate.c  |  3 +++
>>  target/ppc/translate_init.c | 18 ++
>>  7 files changed, 70 insertions(+)
>>
>> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
>> index 9f8cbbe7aa4d..53061229a0a8 100644
>> --- a/target/ppc/cpu.h
>> +++ b/target/ppc/cpu.h
>> @@ -1314,6 +1314,7 @@ int ppc_cpu_handle_mmu_fault(CPUState *cpu,
>> vaddr address, int size, int rw,
>>  
>>  #if !defined(CONFIG_USER_ONLY)
>>  void ppc_store_sdr1 (CPUPPCState *env, target_ulong value);
>> +void ppc_store_ptcr(CPUPPCState *env, target_ulong value);
>>  #endif /* !defined(CONFIG_USER_ONLY) */
>>  void ppc_store_msr (CPUPPCState *env, target_ulong value);
>>  
>> @@ -1605,6 +1606,7 @@ void ppc_compat_add_property(Object *obj, const
>> char *name,
>>  #define SPR_BOOKE_GIVOR13 (0x1BC)
>>  #define SPR_BOOKE_GIVOR14 (0x1BD)
>>  #define SPR_TIR   (0x1BE)
>> +#define SPR_PTCR  (0x1D0)
>>  #define SPR_BOOKE_SPEFSCR (0x200)
>>  #define SPR_Exxx_BBEAR(0x201)
>>  #define SPR_Exxx_BBTAR(0x202)
>> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
>> index 5b739179b8b5..19453c68138a 100644
>> --- a/target/ppc/helper.h
>> +++ b/target/ppc/helper.h
>> @@ -709,6 +709,7 @@ DEF_HELPER_FLAGS_1(load_601_rtcu,
>> TCG_CALL_NO_RWG, tl, env)
>>  #if !defined(CONFIG_USER_ONLY)
>>  #if defined(TARGET_PPC64)
>>  DEF_HELPER_FLAGS_1(load_purr, TCG_CALL_NO_RWG, tl, env)
>> +DEF_HELPER_2(store_ptcr, void, env, tl)
>>  #endif
>>  DEF_HELPER_2(store_sdr1, void, env, tl)
>>  DEF_HELPER_2(store_pidr, void, env, tl)
>> diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c
>> index 0e4217821b8e..8c8cba5cc6f1 100644
>> --- a/target/ppc/misc_helper.c
>> +++ b/target/ppc/misc_helper.c
>> @@ -88,6 +88,18 @@ void helper_store_sdr1(CPUPPCState *env,
>> target_ulong val)
>>  }
>>  }
>>  
>> +#if defined(TARGET_PPC64)
>> +void helper_store_ptcr(CPUPPCState *env, target_ulong val)
>> +{
>> +PowerPCCPU *cpu = ppc_env_get_cpu(env);
>> +
>> +if (env->spr[SPR_PTCR] != val) {
>> +ppc_store_ptcr(env, val);
>> +tlb_flush(CPU(cpu));
>> +}
>> +}
>> +#endif /* defined(TARGET_PPC64) */
>> +
>>  void helper_store_pidr(CPUPPCState *env, target_ulong val)
>>  {
>>  PowerPCCPU *cpu = ppc_env_get_cpu(env);
>> diff --git a/target/ppc/mmu-hash64.h b/target/ppc/mmu-hash64.h
>> index d297b97d3773..4fb00ac17abb 100644
>> --- a/target/ppc/mmu-hash64.h
>> +++ b/target/ppc/mmu-hash64.h
>> @@ -98,6 +98,12 @@ void ppc_hash64_update_rmls(CPUPPCState *env);
>>  #define HPTE64_V_1TB_SEG0x4000ULL
>>  #define HPTE64_V_VRMA_MASK  0x4001ff00ULL
>>  
>> +/*
>> + * Partition table definitions
>> + */
>> +#define PTCR_PTAB   0x0000ULL /* Partition
>> Table Base */
>> +#define PTCR_PTAS   0x001FULL /* Partition
>> Table Size */
>> +
> 
> s/PTCR_PTAB/PTCR_PATB
> s/PTCR_PTAS/PTCR_PATS
> To match the ISA?

yes. My bad.

>>  static inline hwaddr ppc_hash64_hpt_base(PowerPCCPU *cpu)
>>  {
>>  return cpu->env.spr[SPR_SDR1] & SDR_64_HTABORG;
>> diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
>> index 16ef5acaa28f..b1e660a4d16a 100644
>> --- a/target/ppc/mmu_helper.c
>> +++ b/target/ppc/mmu_helper.c
>> @@ -2029,6 +2029,34 @@ void ppc_store_sdr1(CPUPPCState *env,
>> target_ulong value)
>>  env->spr[SPR_SDR1] = value;
>>  }
>>  
>> +#if defined(TARGET_PPC64)
>> +void ppc_store_ptcr(CPUPPCState *env, target_ulong value)
>> +{
>> +PowerPCCPU *cpu = ppc_env_get_cpu(env);
>> +qemu_log_mask(CPU_LOG_MMU, "%s: " TARGET_FMT_lx "\n", __func__,
>> value);
>> +
>> +assert(!cpu->vhyp);
>> +
>> +if (env->mmu_model & POWERPC_MMU_V3) {
>> +target_ulong ptcr_mask = PTCR_PTAB | PTCR_PTAS;
>> +target_ulong ptas = value & PTCR_PTAS;
>> +
>> +if (value & ~ptcr_mask) {
>> +error_report("Invalid bits 0x"TARGET_FMT_lx" set in
>> PTCR",
>> + value & ~ptcr_mask);
>> +value &= ptcr_mask;
>> +}
>> +if (ptas > 28) {
>> +error_report("Invalid PTAS 0x" TARGET_FMT_lx" stored in
>> PTCR",
>> + ptas);
>> +return;
>> +}
>> +}
> 
> Should we throw some error if the ptcr is being accessed on a non-
> power9 machine?

The SPR is only added for POWER9 processor. We should be fine.

Thanks,

C. 

> 
>> +

[Qemu-devel] [PATCH 4/4] tpm: tis: move one-line function into caller

2018-02-02 Thread Stefan Berger
Signed-off-by: Stefan Berger 
---
 hw/tpm/tpm_tis.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 08f41d2..f81168a 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -946,11 +946,6 @@ static const MemoryRegionOps tpm_tis_memory_ops = {
 },
 };
 
-static int tpm_tis_do_startup_tpm(TPMState *s, size_t buffersize)
-{
-return tpm_backend_startup_tpm(s->be_driver, buffersize);
-}
-
 /*
  * Get the TPMVersion of the backend device being used
  */
@@ -1005,7 +1000,7 @@ static void tpm_tis_reset(DeviceState *dev)
 s->rw_offset = 0;
 }
 
-tpm_tis_do_startup_tpm(s, s->be_buffer_size);
+tpm_backend_startup_tpm(s->be_driver, s->be_buffer_size);
 }
 
 static const VMStateDescription vmstate_tpm_tis = {
-- 
2.5.5




Re: [Qemu-devel] [PATCH] pcie-root-port: let it has higher migrate priority

2018-02-02 Thread Marcel Apfelbaum
On 02/02/2018 12:04, Peter Xu wrote:
> On Thu, Feb 01, 2018 at 10:01:31PM +0200, Marcel Apfelbaum wrote:
> 
> [...]
> 
>> Root ports can't be nested, anyway, I suppose the migration should
>> follow the bus numbering order.
> 
> Could I ask whether this is a must?  And if yes, why?
> 

Not sure. The above will ensure that if a device needs some parent/bus
info at load time, the information will be valid.
But if it worked until now, maybe most of the devices do not need that.

>>
>> The question now is what happens if the migration is happening before
>> the guest firmware finishes assigning numbers to buses...
> 
> Do you mean that vIOMMU may fetch wrong context entries too?
> 

No, only that the bus number will not be available at load time.
In this case is OK since the firmware will continue to
assign bus numbers at target side.

Thanks,
Marcel

> Note that as long as vIOMMU DMAR is off globally, vIOMMU will not
> fetch context entries at all.  So IMHO this problem should not happen
> during the firmware execution time (assuming that the firmware should
> not enable vIOMMU at all).
> 
> Thanks,
> 




[Qemu-devel] [PATCH 1/4] tpm: Split off tpm_crb_reset function

2018-02-02 Thread Stefan Berger
Split off the tpm_crb_reset function part from tpm_crb_realize
that we need to run every time the machine resets.

Also register our reset function with the system since TYPE_DEVICE
seems to not get a reset otherwise.

Signed-off-by: Stefan Berger 

---
 v1->v2: register reset function with qemu_register_reset since
 TYPE_DEVICE seems to not get a reset otherwise
---
 hw/tpm/tpm_crb.c | 48 
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index 687d255..b5b8256 100644
--- a/hw/tpm/tpm_crb.c
+++ b/hw/tpm/tpm_crb.c
@@ -26,6 +26,7 @@
 #include "hw/acpi/tpm.h"
 #include "migration/vmstate.h"
 #include "sysemu/tpm_backend.h"
+#include "sysemu/reset.h"
 #include "tpm_int.h"
 #include "tpm_util.h"
 
@@ -210,29 +211,10 @@ static Property tpm_crb_properties[] = {
 DEFINE_PROP_END_OF_LIST(),
 };
 
-static void tpm_crb_realize(DeviceState *dev, Error **errp)
+static void tpm_crb_reset(void *dev)
 {
 CRBState *s = CRB(dev);
 
-if (!tpm_find()) {
-error_setg(errp, "at most one TPM device is permitted");
-return;
-}
-if (!s->tpmbe) {
-error_setg(errp, "'tpmdev' property is required");
-return;
-}
-
-memory_region_init_io(>mmio, OBJECT(s), _crb_memory_ops, s,
-"tpm-crb-mmio", sizeof(s->regs));
-memory_region_init_ram(>cmdmem, OBJECT(s),
-"tpm-crb-cmd", CRB_CTRL_CMD_SIZE, errp);
-
-memory_region_add_subregion(get_system_memory(),
-TPM_CRB_ADDR_BASE, >mmio);
-memory_region_add_subregion(get_system_memory(),
-TPM_CRB_ADDR_BASE + sizeof(s->regs), >cmdmem);
-
 tpm_backend_reset(s->tpmbe);
 
 ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
@@ -267,6 +249,32 @@ static void tpm_crb_realize(DeviceState *dev, Error **errp)
 tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size);
 }
 
+static void tpm_crb_realize(DeviceState *dev, Error **errp)
+{
+CRBState *s = CRB(dev);
+
+if (!tpm_find()) {
+error_setg(errp, "at most one TPM device is permitted");
+return;
+}
+if (!s->tpmbe) {
+error_setg(errp, "'tpmdev' property is required");
+return;
+}
+
+memory_region_init_io(>mmio, OBJECT(s), _crb_memory_ops, s,
+"tpm-crb-mmio", sizeof(s->regs));
+memory_region_init_ram(>cmdmem, OBJECT(s),
+"tpm-crb-cmd", CRB_CTRL_CMD_SIZE, errp);
+
+memory_region_add_subregion(get_system_memory(),
+TPM_CRB_ADDR_BASE, >mmio);
+memory_region_add_subregion(get_system_memory(),
+TPM_CRB_ADDR_BASE + sizeof(s->regs), >cmdmem);
+
+qemu_register_reset(tpm_crb_reset, dev);
+}
+
 static void tpm_crb_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
-- 
2.5.5




Re: [Qemu-devel] [RFC PATCH qemu] qmp: Add qom-list-properties to list QOM object properties

2018-02-02 Thread Markus Armbruster
Alexey Kardashevskiy  writes:

> On 01/02/18 04:22, Markus Armbruster wrote:
>> Alexey Kardashevskiy  writes:
>> 
>>> There is already 'device-list-properties' which does most of the job,
>>> however it does not handle everything returned by qom-list-types such
>>> as machines as they inherit directly from TYPE_OBJECT and not TYPE_DEVICE.
>>>
>>> This adds a new qom-list-properties command which prints properties
>>> of a specific class and its instance. It is pretty much a simplified copy
>>> of the device-list-properties handler.
>>>
>>> Since it creates an object instance, device properties should appear
>>> in the output as they are copied to QOM properties at the instance_init
>>> hook.
>>>
>>> Signed-off-by: Alexey Kardashevskiy 
>> 
>> Related: qom-list, which lists "any properties of a object given a path
>> in the object model."  qom-list-properties takes a type name, which
>> qom-list takes the path to an instance.  In other words,
>> qom-list-properties is like instantiate with default configuration and
>> without realizing + qom-list + destroy.
>
>
> True. Same as device-list-properties.

device-list-properties does a bit more, like skipping "uninteresting"
properties, and special magic for qdev properties (that's the
make_device_property_info() you asked about below).  But that's detail.

>> We need to instantiate because QOM properties are dynamic: they aren't
>> specified by data (which qom-list-properties could simply read), they
>> are created by (instantiation) code (which qom-list-properties has to
>> run).
>
> Correct.
>
>> Properties created only after instantiation (by realize, perhaps) aren't
>> visible in qom-list-properties.  Do such properties exist?
>
> No idea but if they do, then this issue already exists in
> device-list-properties.
>
>> Properties created only in non-default configuration aren't visible
>> either.  Such properties have to exist, or else dynamic property
>> creation would be idiotic.

Thus, qom-list-properties design limitation: the result need not reflect
properties of instantiated objects.  It usually does, as most QOM
properties behave as if they were static.  But when it doesn't, what
then?  How are users of qom-list-properties supposed to deal with such
inaccurate / incorrect information?  Do they just have to know which
properties aren't visible in qom-list-properties, and which properties
are, but cannot be trusted?

I posit that right now *nobody* knows.

Would such a command be useful anyway?

>> Likewise for properties created differently (say with a different type)
>> in non-default configuration.  We can hope that no such beasts exist.
>> Since properties get created by code, and code can do anything, we're
>> reduced to hope.  Data is so much easier to reason about than code.
>> 
>> Three building blocks: instantiate, qom-list, destroy.  Do we want the
>> building blocks, or do we want their combination qom-list-properties?
>
>
> Building blocks as QEMU internal helpers to split my
> qmp_qom_list_properties() into? These are not going to be huge and
> "destroy" is literally object_unref(obj) which does not seem very useful.
> Or I missed the point here?

My question is whether the QMP interface should provide the building
blocks, or only compositions.

>>> ---
>>>
>>> I am missing the point of make_device_property_info().
>>> qmp_device_list_properties() creates the instance which copies everything
>>> to QOM properties hashtable and commenting out the do{}while() in
>>> make_device_property_info() does not seem to change a thing, what case
>>> am I missing here?
>> 
>> git-blame points to Stefan.  Stefan, can you help?



[Qemu-devel] [PATCH v3 11/12] vl: drop request_opengl variable

2018-02-02 Thread Gerd Hoffmann
Switch over the one leftover user to qapi DisplayType.
The delete the unused request_opengl variable.

Signed-off-by: Gerd Hoffmann 
---
 vl.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/vl.c b/vl.c
index 899fcad75e..4ef774e783 100644
--- a/vl.c
+++ b/vl.c
@@ -135,7 +135,6 @@ static const char *data_dir[16];
 static int data_dir_idx;
 const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
-int request_opengl = -1;
 int display_opengl;
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
@@ -2149,10 +2148,8 @@ static LegacyDisplayType select_display(const char *p)
 opts = nextopt;
 dpy.has_gl = true;
 if (strstart(opts, "on", )) {
-request_opengl = 1;
 dpy.gl = true;
 } else if (strstart(opts, "off", )) {
-request_opengl = 0;
 dpy.gl = false;
 } else {
 goto invalid_sdl_args;
@@ -2177,7 +2174,6 @@ static LegacyDisplayType select_display(const char *p)
 }
 } else if (strstart(p, "egl-headless", )) {
 #ifdef CONFIG_OPENGL_DMABUF
-request_opengl = 1;
 display_opengl = 1;
 display = DT_EGL;
 dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
@@ -2214,10 +2210,8 @@ static LegacyDisplayType select_display(const char *p)
 opts = nextopt;
 dpy.has_gl = true;
 if (strstart(opts, "on", )) {
-request_opengl = 1;
 dpy.gl = true;
 } else if (strstart(opts, "off", )) {
-request_opengl = 0;
 dpy.gl = false;
 } else {
 goto invalid_gtk_args;
@@ -4382,7 +4376,7 @@ int main(int argc, char **argv, char **envp)
 
 qemu_console_early_init();
 
-if (request_opengl == 1 && display_opengl == 0) {
+if (dpy.has_gl && dpy.gl && display_opengl == 0) {
 #if defined(CONFIG_OPENGL)
 error_report("OpenGL is not supported by the display");
 #else
-- 
2.9.3




[Qemu-devel] [PATCH v3 00/12] rework display initialization, part one

2018-02-02 Thread Gerd Hoffmann
  Hi,

This series is the first part of my the qemu display initialization
update.  Changes:

  * Create a QAPI DisplayOptions type for display configuration.
  * Switch all display initialization calls to accept DisplayOptions
instead of a bunch of bools.

v2: add 'default' in the patch shich actually uses it (markus).

cheers,
  Gerd

Gerd Hoffmann (12):
  vl: deprecate -no-frame
  vl: deprecate -alt-grab and -ctrl-grab
  vl: rename DisplayType to LegacyDisplayType
  gtk: add and use DisplayOptions + DisplayGTK
  sdl: use DisplayOptions
  vl: drop no_quit variable
  egl-headless: use DisplayOptions
  curses: use DisplayOptions
  cocoa: use DisplayOptions
  vl: drop full_screen variable
  vl: drop request_opengl variable
  vl: drop display_type variable

 include/ui/console.h |  27 ++-
 ui/curses.c  |   2 +-
 ui/egl-headless.c|   2 +-
 ui/gtk.c |  32 +++--
 ui/sdl.c |  19 +---
 ui/sdl2.c|  33 +++--
 vl.c | 127 ++-
 qapi/ui.json |  64 ++
 qemu-doc.texi|  13 ++
 ui/cocoa.m   |   4 +-
 10 files changed, 208 insertions(+), 115 deletions(-)

-- 
2.9.3




Re: [Qemu-devel] [Qemu-ppc] [PATCH] spapr: add missing break in h_get_cpu_characteristics()

2018-02-02 Thread Greg Kurz
On Fri, 2 Feb 2018 07:11:08 -0200
Daniel Henrique Barboza  wrote:

> On 02/01/2018 05:47 PM, Greg Kurz wrote:
> > Detected by Coverity (CID 1385702). This fixes the recently added hypercall
> > to let guests properly apply Spectre and Meltdown workarounds.  
> 
> Paolo Bonzini reported this error in a reply to the pull request that
> added the patch:
> 
> "Re: [Qemu-ppc] [Qemu-devel] [PULL 12/12] target/ppc/spapr: Add H-Call 
> H_GET_CPU_CHARACTERISTICS
> 
> On 28/01/2018 22:28, David Gibson wrote:
> 
> > +switch (safe_indirect_branch) {
> > +case SPAPR_CAP_FIXED:
> > +characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;  
> 
> Missing "break;" here.
> 
> Paolo
> 
> "
> 
> I think it is nice to mention in the commit msg that Paolo also detected 
> this same error,
> specially given that his email was sent before this patch.
> 

Heh, Paolo's mail landed in the pull req thread in my mail client and I saw
it after sending the patch :P ... also I'm pretty sure Paolo was made aware
of this issue by Coverity, just as I was :)

From: scan-ad...@coverity.com
To: gr...@kaod.org
Subject: New Defects reported by Coverity Scan for QEMU
Date: Thu, 01 Feb 2018 18:11:33 + (UTC)

Hi,

Please find the latest report on new defect(s) introduced to QEMU found with
Coverity Scan.

...

*** CID 1385702:  Control flow issues  (MISSING_BREAK)
/hw/ppc/spapr_hcall.c: 1700 in h_get_cpu_characteristics()
1694 break;
1695 }
1696 
1697 switch (safe_indirect_branch) {
1698 case SPAPR_CAP_FIXED:
1699 characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
>>> CID 1385702:  Control flow issues  (MISSING_BREAK)
>>> The above case falls through to this one.  
1700 default: /* broken */
1701 assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
1702 break;
1703 }
1704 
1705 args[0] = characteristics;


No big deal I guess :)

> 
> Thanks,
> 
> 
> Daniel
> 
> 
> >
> > Fixes: c59704b25473 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS"
> > Signed-off-by: Greg Kurz 
> > ---
> >   hw/ppc/spapr_hcall.c |1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> > index 4d0e6eb0cf1d..596f58378a40 100644
> > --- a/hw/ppc/spapr_hcall.c
> > +++ b/hw/ppc/spapr_hcall.c
> > @@ -1697,6 +1697,7 @@ static target_ulong 
> > h_get_cpu_characteristics(PowerPCCPU *cpu,
> >   switch (safe_indirect_branch) {
> >   case SPAPR_CAP_FIXED:
> >   characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
> > +break;
> >   default: /* broken */
> >   assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
> >   break;
> >
> >  
> 




[Qemu-devel] [PATCH v3 04/12] gtk: add and use DisplayOptions + DisplayGTK

2018-02-02 Thread Gerd Hoffmann
Add QAPI DisplayType enum, DisplayOptions union and DisplayGTK struct.
Switch gtk configuration to use the qapi type.

Some bookkeeping (fullscreen for example) is done twice now, this is
temporary until more/all UIs are switched over to qapi configuration.

Signed-off-by: Gerd Hoffmann 
---
 include/ui/console.h |  9 
 ui/gtk.c | 32 -
 vl.c | 23 -
 qapi/ui.json | 58 
 4 files changed, 98 insertions(+), 24 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 7b35778444..58d1a3d27c 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -511,18 +511,17 @@ int index_from_key(const char *key, size_t key_length);
 
 /* gtk.c */
 #ifdef CONFIG_GTK
-void early_gtk_display_init(int opengl);
-void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover);
+void early_gtk_display_init(DisplayOptions *opts);
+void gtk_display_init(DisplayState *ds, DisplayOptions *opts);
 #else
-static inline void gtk_display_init(DisplayState *ds, bool full_screen,
-bool grab_on_hover)
+static inline void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
 {
 /* This must never be called if CONFIG_GTK is disabled */
 error_report("GTK support is disabled");
 abort();
 }
 
-static inline void early_gtk_display_init(int opengl)
+static inline void early_gtk_display_init(DisplayOptions *opts)
 {
 /* This must never be called if CONFIG_GTK is disabled */
 error_report("GTK support is disabled");
diff --git a/ui/gtk.c b/ui/gtk.c
index f0ad63e431..c12d5e020c 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -229,6 +229,8 @@ struct GtkDisplayState {
 
 bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
 bool ignore_keys;
+
+DisplayOptions *opts;
 };
 
 typedef struct VCChardev {
@@ -777,9 +779,14 @@ static gboolean gd_window_close(GtkWidget *widget, 
GdkEvent *event,
 void *opaque)
 {
 GtkDisplayState *s = opaque;
+bool allow_close = true;
 int i;
 
-if (!no_quit) {
+if (s->opts->has_window_close && !s->opts->window_close) {
+allow_close = false;
+}
+
+if (allow_close) {
 for (i = 0; i < s->nb_vcs; i++) {
 if (s->vc[i].type != GD_VC_GFX) {
 continue;
@@ -2289,7 +2296,7 @@ static void gd_create_menus(GtkDisplayState *s)
 
 static gboolean gtkinit;
 
-void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
+void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
 {
 VirtualConsole *vc;
 
@@ -2301,6 +2308,8 @@ void gtk_display_init(DisplayState *ds, bool full_screen, 
bool grab_on_hover)
 fprintf(stderr, "gtk initialization failed\n");
 exit(1);
 }
+assert(opts->type == DISPLAY_TYPE_GTK);
+s->opts = opts;
 
 #if !GTK_CHECK_VERSION(3, 0, 0)
 g_printerr("Running QEMU with GTK 2.x is deprecated, and will be removed\n"
@@ -2387,15 +2396,17 @@ void gtk_display_init(DisplayState *ds, bool 
full_screen, bool grab_on_hover)
  vc && vc->type == GD_VC_VTE);
 #endif
 
-if (full_screen) {
+if (opts->has_full_screen &&
+opts->full_screen) {
 gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
 }
-if (grab_on_hover) {
+if (opts->u.gtk.has_grab_on_hover &&
+opts->u.gtk.grab_on_hover) {
 gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
 }
 }
 
-void early_gtk_display_init(int opengl)
+void early_gtk_display_init(DisplayOptions *opts)
 {
 /* The QEMU code relies on the assumption that it's always run in
  * the C locale. Therefore it is not prepared to deal with
@@ -2421,11 +2432,8 @@ void early_gtk_display_init(int opengl)
 return;
 }
 
-switch (opengl) {
-case -1: /* default */
-case 0:  /* off */
-break;
-case 1: /* on */
+assert(opts->type == DISPLAY_TYPE_GTK);
+if (opts->has_gl && opts->gl) {
 #if defined(CONFIG_OPENGL)
 #if defined(CONFIG_GTK_GL)
 gtk_gl_area_init();
@@ -2433,10 +2441,6 @@ void early_gtk_display_init(int opengl)
 gtk_egl_init();
 #endif
 #endif
-break;
-default:
-g_assert_not_reached();
-break;
 }
 
 keycode_map = gd_get_keymap(_maplen);
diff --git a/vl.c b/vl.c
index a2478412c7..4a555de0cf 100644
--- a/vl.c
+++ b/vl.c
@@ -150,9 +150,9 @@ static int rtc_date_offset = -1; /* -1 means no change */
 QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
+static DisplayOptions dpy;
 int no_frame;
 int no_quit = 0;
-static bool grab_on_hover;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 Chardev *virtcon_hds[MAX_VIRTIO_CONSOLES];
@@ -2191,24 +2191,29 @@ static LegacyDisplayType select_display(const char *p)
 } else if 

[Qemu-devel] [PATCH v3] iotests: Fix CID for VMDK afl image

2018-02-02 Thread Fam Zheng
This reverts commit 76bf133c4 which updated the reference output, and
fixed the reference image, because the code path we want to exercise is
actually the invalid image size.

The descriptor block in the image, which includes the CID to verify, has been
invalid since the reference image was added. Since commit 9877860e7bd we report
this error earlier than the "file too large", so 059.out mismatches.

The binary change is generated along the operations of:

  $ bunzip2 afl9.vmdk.bz2
  $ qemu-img create -f vmdk fix.vmdk 1G
  $ dd if=afl9.vmdk of=fix.vmdk bs=512 count=1 conv=notrunc
  $ mv fix.vmdk afl9.vmdk
  $ bzip2 afl9.vmdk

Signed-off-by: Fam Zheng 

---

v3: Skip test when ENOMEM. [Max, Eric]

v2: Fix commit message "qcow2 -> vmdk". [Kevin]
Revert 76bf133c4.
---
 tests/qemu-iotests/059 |   5 ++---
 tests/qemu-iotests/059.out |   2 +-
 tests/qemu-iotests/sample_images/afl9.vmdk.bz2 | Bin 178 -> 618 bytes
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
index 40f89eae18..530bbbe6ce 100755
--- a/tests/qemu-iotests/059
+++ b/tests/qemu-iotests/059
@@ -152,9 +152,8 @@ done
 echo
 echo "=== Testing afl image with a very large capacity ==="
 _use_sample_img afl9.vmdk.bz2
-# The sed makes this test pass on machines with little RAM
-# (and also with 32 bit builds)
-_img_info | sed -e 's/Cannot allocate memory/Invalid argument/'
+_img_info | grep -q 'Cannot allocate memory' && _notrun "Insufficent memory, 
skipped test"
+_img_info
 _cleanup_test_img
 
 # success, all done
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
index 1ac5d56233..f6dce7947c 100644
--- a/tests/qemu-iotests/059.out
+++ b/tests/qemu-iotests/059.out
@@ -2358,5 +2358,5 @@ Offset  Length  Mapped to   File
 0x14000 0x1 0x5 TEST_DIR/t-s003.vmdk
 
 === Testing afl image with a very large capacity ===
-qemu-img: Could not open 'TEST_DIR/afl9.IMGFMT': Could not open 
'TEST_DIR/afl9.IMGFMT': Invalid argument
+qemu-img: Can't get image size 'TEST_DIR/afl9.IMGFMT': File too large
 *** done
diff --git a/tests/qemu-iotests/sample_images/afl9.vmdk.bz2 
b/tests/qemu-iotests/sample_images/afl9.vmdk.bz2
index 
03615d36a12425cf4240bab86f4cfe648db14572..9fcd0af45a815431acf4689e0845ecf2d333cd58
 100644
GIT binary patch
literal 618
zcmV-w0+szjT4*^jL0KkKSvgW7ssIN3|NsBH-Q9UpfAhclU70`s-*NE~5QvC~h=_=Y
zh>D2n*q*=vygR634445h35k;?00h9835kMW4$iPepVE{Bqk)uhJ^wfGLr=)3s
zhM5CR88jLh7)B;cA*K)*6GmuECPU3o4NWG5O#pg>Ak#xY8Z^CrMt}oD38Ns$
z02n}M0LdjZ&}cLPqd+nPKmn$j0iXe(02%-d27nnJriN-uE+X@Bj4BBfd|yV!NB
zwqkL}nW3AI5x^jp=t%^F1pxqp)v#n#)j$zcm1xqv(!$2d*5%vF{5RPWnOV8-^tE<(
zU~%&}Y0uNu*9Wt=yS^8PkC%IG;aD{l#sG`m4Ho*fsHXdM

[Qemu-devel] [PATCH v2 1/2] Add a git-publish configuration file

2018-02-02 Thread Fam Zheng
git-publish [1] is a convenient tool to send patches and has been
popular among QEMU developers.  Recently it has been made available in
Fedora official repo thanks to Stefan's work.

One nice feature of the tool is a per-project configuration with
profiles, especially in which the cccmd option is a handy method to
create the Cc list.

[1]: https://github.com/stefanha/git-publish

Signed-off-by: Fam Zheng 
---
 .gitpublish | 57 +
 1 file changed, 57 insertions(+)
 create mode 100644 .gitpublish

diff --git a/.gitpublish b/.gitpublish
new file mode 100644
index 00..170bd2ed48
--- /dev/null
+++ b/.gitpublish
@@ -0,0 +1,57 @@
+#
+# Common git-publish profiles that can be used to send patches to QEMU 
upstream.
+#
+# See https://github.com/stefanha/git-publish for more information
+#
+[gitpublishprofile "default"]
+base = master
+prefix = PATCH
+to = qemu-devel@nongnu.org
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
+
+[gitpublishprofile "rfc"]
+base = master
+prefix = RFC PATCH
+to = qemu-devel@nongnu.org
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
+
+[gitpublishprofile "stable"]
+base = master
+prefix = PATCH
+to = qemu-devel@nongnu.org
+cc = qemu-sta...@nongnu.org
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
+
+[gitpublishprofile "trivial"]
+base = master
+prefix = PATCH
+to = qemu-devel@nongnu.org
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
+
+[gitpublishprofile "block"]
+base = master
+prefix = PATCH
+to = qemu-devel@nongnu.org
+cc = qemu-bl...@nongnu.org
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
+
+[gitpublishprofile "arm"]
+base = master
+prefix = PATCH
+to = qemu-devel@nongnu.org
+cc = qemu-...@nongnu.org
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
+
+[gitpublishprofile "s390"]
+base = master
+prefix = PATCH
+to = qemu-devel@nongnu.org
+cc = qemu-s...@nongnu.org
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
+
+[gitpublishprofile "ppc"]
+base = master
+prefix = PATCH
+to = qemu-devel@nongnu.org
+cc = qemu-...@nongnu.org
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
--nogit-fallback 2>/dev/null
-- 
2.14.3




Re: [Qemu-devel] [PATCH v3] iotests: Fix CID for VMDK afl image

2018-02-02 Thread Max Reitz
On 2018-02-02 06:23, Fam Zheng wrote:
> This reverts commit 76bf133c4 which updated the reference output, and
> fixed the reference image, because the code path we want to exercise is
> actually the invalid image size.
> 
> The descriptor block in the image, which includes the CID to verify, has been
> invalid since the reference image was added. Since commit 9877860e7bd we 
> report
> this error earlier than the "file too large", so 059.out mismatches.
> 
> The binary change is generated along the operations of:
> 
>   $ bunzip2 afl9.vmdk.bz2
>   $ qemu-img create -f vmdk fix.vmdk 1G
>   $ dd if=afl9.vmdk of=fix.vmdk bs=512 count=1 conv=notrunc
>   $ mv fix.vmdk afl9.vmdk
>   $ bzip2 afl9.vmdk
> 
> Signed-off-by: Fam Zheng 
> 
> ---
> 
> v3: Skip test when ENOMEM. [Max, Eric]
> 
> v2: Fix commit message "qcow2 -> vmdk". [Kevin]
> Revert 76bf133c4.
> ---
>  tests/qemu-iotests/059 |   5 ++---
>  tests/qemu-iotests/059.out |   2 +-
>  tests/qemu-iotests/sample_images/afl9.vmdk.bz2 | Bin 178 -> 618 bytes
>  3 files changed, 3 insertions(+), 4 deletions(-)

Nice, thanks.

Reviewed-by: Max Reitz 



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 1/2] qcow2: add overlap check for bitmap directory

2018-02-02 Thread Vladimir Sementsov-Ogievskiy

29.01.2018 18:34, Max Reitz wrote:

On 2017-11-30 17:47, Vladimir Sementsov-Ogievskiy wrote:

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
  block/qcow2.h  |  7 +--
  block/qcow2-refcount.c | 12 
  block/qcow2.c  |  6 ++
  3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index 6f0ff15dd0..8f226a3609 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -98,6 +98,7 @@
  #define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE "overlap-check.snapshot-table"
  #define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1"
  #define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2"
+#define QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY "overlap-check.bitmap-directory"
  #define QCOW2_OPT_CACHE_SIZE "cache-size"
  #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size"
  #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size"
@@ -406,8 +407,9 @@ typedef enum QCow2MetadataOverlap {
  QCOW2_OL_SNAPSHOT_TABLE_BITNR = 5,
  QCOW2_OL_INACTIVE_L1_BITNR= 6,
  QCOW2_OL_INACTIVE_L2_BITNR= 7,
+QCOW2_OL_BITMAP_DIRECTORY_BITNR = 8,
  
-QCOW2_OL_MAX_BITNR= 8,

+QCOW2_OL_MAX_BITNR  = 9,
  
  QCOW2_OL_NONE   = 0,

  QCOW2_OL_MAIN_HEADER= (1 << QCOW2_OL_MAIN_HEADER_BITNR),
@@ -420,12 +422,13 @@ typedef enum QCow2MetadataOverlap {
  /* NOTE: Checking overlaps with inactive L2 tables will result in bdrv
   * reads. */
  QCOW2_OL_INACTIVE_L2= (1 << QCOW2_OL_INACTIVE_L2_BITNR),
+QCOW2_OL_BITMAP_DIRECTORY = (1 << QCOW2_OL_BITMAP_DIRECTORY_BITNR),
  } QCow2MetadataOverlap;
  
  /* Perform all overlap checks which can be done in constant time */

  #define QCOW2_OL_CONSTANT \
  (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_REFCOUNT_TABLE | \
- QCOW2_OL_SNAPSHOT_TABLE)
+ QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_BITMAP_DIRECTORY)
  
  /* Perform all overlap checks which don't require disk access */

  #define QCOW2_OL_CACHED \
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 3de1ab51ba..a7a2703f26 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -2585,6 +2585,18 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, 
int ign, int64_t offset,
  }
  }
  
+if ((chk & QCOW2_OL_BITMAP_DIRECTORY) &&

+(s->autoclear_features & QCOW2_AUTOCLEAR_BITMAPS))
+{
+/* update_ext_header_and_dir_in_place firstly drop autoclear flag,
+ * so it will not fail */

That's really not an argument.  bitmap_list_store() has to pass
QCOW2_OL_BITMAP_DIRECTORY to @ign anyway.  (Because there is no reason
not to.)


in_place is a reason. When we store directory in_place, it definitely 
overlaps with current directory.
But this is done with cleared autoclear flag (to make it safe), so we 
will skip this check and will not

fail.



Max


+if (overlaps_with(s->bitmap_directory_offset,
+  s->bitmap_directory_size))
+{
+return QCOW2_OL_BITMAP_DIRECTORY;
+}
+}
+
  return 0;
  }
  
diff --git a/block/qcow2.c b/block/qcow2.c

index 1914a940e5..8278c0e124 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -655,6 +655,11 @@ static QemuOptsList qcow2_runtime_opts = {
  .help = "Check for unintended writes into an inactive L2 table",
  },
  {
+.name = QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY,
+.type = QEMU_OPT_BOOL,
+.help = "Check for unintended writes into the bitmap directory",
+},
+{
  .name = QCOW2_OPT_CACHE_SIZE,
  .type = QEMU_OPT_SIZE,
  .help = "Maximum combined metadata (L2 tables and refcount blocks) 
"
@@ -690,6 +695,7 @@ static const char 
*overlap_bool_option_names[QCOW2_OL_MAX_BITNR] = {
  [QCOW2_OL_SNAPSHOT_TABLE_BITNR] = QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE,
  [QCOW2_OL_INACTIVE_L1_BITNR]= QCOW2_OPT_OVERLAP_INACTIVE_L1,
  [QCOW2_OL_INACTIVE_L2_BITNR]= QCOW2_OPT_OVERLAP_INACTIVE_L2,
+[QCOW2_OL_BITMAP_DIRECTORY_BITNR] = QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY,
  };
  
  static void cache_clean_timer_cb(void *opaque)







--
Best regards,
Vladimir




[Qemu-devel] [PATCH 0/4] tpm: A fix and cleanups

2018-02-02 Thread Stefan Berger
The following patches fix the resetting of the CRB interface and wrap
calls to st{w,l}_be_p in tpm_cmd_set_XYZ functions. We also clean up
a one-liner in the TIS.

   Stefan

Stefan Berger (4):
  tpm: Split off tpm_crb_reset function
  tpm: wrap stX_be_p in tpm_cmd_set_XYZ functions
  MAINTAINERS: add pointer to tpm-next repository
  tpm: tis: move one-line function into caller

 MAINTAINERS   |  1 +
 hw/tpm/tpm_crb.c  | 48 
 hw/tpm/tpm_tis.c  |  7 +--
 hw/tpm/tpm_util.c |  6 +++---
 hw/tpm/tpm_util.h | 15 +++
 5 files changed, 48 insertions(+), 29 deletions(-)

-- 
2.5.5




[Qemu-devel] [PATCH v3 12/12] vl: drop display_type variable

2018-02-02 Thread Gerd Hoffmann
Switch over all leftover users to qapi DisplayType.
Then delete the unused display_type variable.

Add 'default' DisplayType, which isn't an actual display type but
a placeholder for "user didn't specify a display".  It will be replaced
by the DisplayType actually used, which in turn depends on the
DisplayTypes availabel in the particular build.

Signed-off-by: Gerd Hoffmann 
---
 vl.c | 54 ++
 qapi/ui.json |  5 +++--
 2 files changed, 17 insertions(+), 42 deletions(-)

diff --git a/vl.c b/vl.c
index 4ef774e783..42867d60f8 100644
--- a/vl.c
+++ b/vl.c
@@ -2079,24 +2079,12 @@ static void select_vgahw(const char *p)
 }
 }
 
-typedef enum LegacyDisplayType {
-DT_DEFAULT,
-DT_CURSES,
-DT_SDL,
-DT_COCOA,
-DT_GTK,
-DT_EGL,
-DT_NONE,
-} LegacyDisplayType;
-
-static LegacyDisplayType select_display(const char *p)
+static void parse_display(const char *p)
 {
 const char *opts;
-LegacyDisplayType display = DT_DEFAULT;
 
 if (strstart(p, "sdl", )) {
 #ifdef CONFIG_SDL
-display = DT_SDL;
 dpy.type = DISPLAY_TYPE_SDL;
 while (*opts) {
 const char *nextopt;
@@ -2175,7 +2163,6 @@ static LegacyDisplayType select_display(const char *p)
 } else if (strstart(p, "egl-headless", )) {
 #ifdef CONFIG_OPENGL_DMABUF
 display_opengl = 1;
-display = DT_EGL;
 dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
 #else
 fprintf(stderr, "egl support is disabled\n");
@@ -2183,7 +2170,6 @@ static LegacyDisplayType select_display(const char *p)
 #endif
 } else if (strstart(p, "curses", )) {
 #ifdef CONFIG_CURSES
-display = DT_CURSES;
 dpy.type = DISPLAY_TYPE_CURSES;
 #else
 error_report("curses support is disabled");
@@ -2191,7 +2177,6 @@ static LegacyDisplayType select_display(const char *p)
 #endif
 } else if (strstart(p, "gtk", )) {
 #ifdef CONFIG_GTK
-display = DT_GTK;
 dpy.type = DISPLAY_TYPE_GTK;
 while (*opts) {
 const char *nextopt;
@@ -2228,14 +2213,11 @@ static LegacyDisplayType select_display(const char *p)
 exit(1);
 #endif
 } else if (strstart(p, "none", )) {
-display = DT_NONE;
 dpy.type = DISPLAY_TYPE_NONE;
 } else {
 error_report("unknown display type");
 exit(1);
 }
-
-return display;
 }
 
 static int balloon_parse(const char *arg)
@@ -3063,7 +3045,6 @@ int main(int argc, char **argv, char **envp)
 const char *incoming = NULL;
 bool userconfig = true;
 bool nographic = false;
-LegacyDisplayType display_type = DT_DEFAULT;
 int display_remote = 0;
 const char *log_mask = NULL;
 const char *log_file = NULL;
@@ -3257,18 +3238,16 @@ int main(int argc, char **argv, char **envp)
 }
 break;
 case QEMU_OPTION_display:
-display_type = select_display(optarg);
+parse_display(optarg);
 break;
 case QEMU_OPTION_nographic:
 olist = qemu_find_opts("machine");
 qemu_opts_parse_noisily(olist, "graphics=off", false);
 nographic = true;
-display_type = DT_NONE;
 dpy.type = DISPLAY_TYPE_NONE;
 break;
 case QEMU_OPTION_curses:
 #ifdef CONFIG_CURSES
-display_type = DT_CURSES;
 dpy.type = DISPLAY_TYPE_CURSES;
 #else
 error_report("curses support is disabled");
@@ -3676,7 +3655,6 @@ int main(int argc, char **argv, char **envp)
 break;
 case QEMU_OPTION_sdl:
 #ifdef CONFIG_SDL
-display_type = DT_SDL;
 dpy.type = DISPLAY_TYPE_SDL;
 break;
 #else
@@ -4292,7 +4270,7 @@ int main(int argc, char **argv, char **envp)
 exit(1);
 }
 #ifdef CONFIG_CURSES
-if (display_type == DT_CURSES) {
+if (dpy.type == DISPLAY_TYPE_CURSES) {
 error_report("curses display cannot be used with -daemonize");
 exit(1);
 }
@@ -4338,39 +4316,35 @@ int main(int argc, char **argv, char **envp)
 display_remote++;
 }
 #endif
-if (display_type == DT_DEFAULT && !display_remote) {
+if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) {
 #if defined(CONFIG_GTK)
-display_type = DT_GTK;
 dpy.type = DISPLAY_TYPE_GTK;
 #elif defined(CONFIG_SDL)
-display_type = DT_SDL;
 dpy.type = DISPLAY_TYPE_SDL;
 #elif defined(CONFIG_COCOA)
-display_type = DT_COCOA;
 dpy.type = DISPLAY_TYPE_COCOA;
 #elif defined(CONFIG_VNC)
 vnc_parse("localhost:0,to=99,id=default", _abort);
 #else
-display_type = DT_NONE;
 dpy.type = DISPLAY_TYPE_NONE;
 #endif
 }
 
-if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) {
+if ((no_frame || alt_grab || ctrl_grab) && dpy.type != 

[Qemu-devel] [PULL 1/2] hw/audio/wm8750: move WM8750 declarations from i2c/i2c.h to audio/wm8750.h

2018-02-02 Thread Gerd Hoffmann
From: Philippe Mathieu-Daudé 

while here use TYPE_WM8750 and declare a data_req_cb() typedef.

Signed-off-by: Philippe Mathieu-Daudé 
Message-id: 20170919123053.32675-1-f4...@amsat.org
Signed-off-by: Gerd Hoffmann 
---
 include/hw/audio/wm8750.h  | 30 ++
 include/hw/i2c/i2c.h   |  9 -
 hw/arm/musicpal.c  |  3 ++-
 hw/arm/spitz.c |  3 ++-
 hw/arm/z2.c|  3 ++-
 hw/audio/marvell_88w8618.c |  1 +
 hw/audio/wm8750.c  |  6 ++
 7 files changed, 39 insertions(+), 16 deletions(-)
 create mode 100644 include/hw/audio/wm8750.h

diff --git a/include/hw/audio/wm8750.h b/include/hw/audio/wm8750.h
new file mode 100644
index 00..84e7a119bb
--- /dev/null
+++ b/include/hw/audio/wm8750.h
@@ -0,0 +1,30 @@
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2 or later, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+#ifndef HW_DAC_WM8750_H
+#define HW_DAC_WM8750_H
+
+#include "hw/hw.h"
+
+#define TYPE_WM8750 "wm8750"
+
+typedef void data_req_cb(void *opaque, int free_out, int free_in);
+
+void wm8750_data_req_set(DeviceState *dev, data_req_cb *data_req, void 
*opaque);
+void wm8750_dac_dat(void *opaque, uint32_t sample);
+uint32_t wm8750_adc_dat(void *opaque);
+void *wm8750_dac_buffer(void *opaque, int samples);
+void wm8750_dac_commit(void *opaque);
+void wm8750_set_bclk_in(void *opaque, int new_hz);
+
+#endif
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index 2ce611d4c8..24e95d0155 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -70,15 +70,6 @@ int i2c_recv(I2CBus *bus);
 
 DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
 
-/* wm8750.c */
-void wm8750_data_req_set(DeviceState *dev,
-void (*data_req)(void *, int, int), void *opaque);
-void wm8750_dac_dat(void *opaque, uint32_t sample);
-uint32_t wm8750_adc_dat(void *opaque);
-void *wm8750_dac_buffer(void *opaque, int samples);
-void wm8750_dac_commit(void *opaque);
-void wm8750_set_bclk_in(void *opaque, int new_hz);
-
 /* lm832x.c */
 void lm832x_key_event(DeviceState *dev, int key, int state);
 
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index b648770882..4172caf5db 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -25,6 +25,7 @@
 #include "hw/block/flash.h"
 #include "ui/console.h"
 #include "hw/i2c/i2c.h"
+#include "hw/audio/wm8750.h"
 #include "sysemu/block-backend.h"
 #include "exec/address-spaces.h"
 #include "ui/pixel_ops.h"
@@ -1691,7 +1692,7 @@ static void musicpal_init(MachineState *machine)
 qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
 }
 
-wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
+wm8750_dev = i2c_create_slave(i2c, TYPE_WM8750, MP_WM_ADDR);
 dev = qdev_create(NULL, "mv88w8618_audio");
 s = SYS_BUS_DEVICE(dev);
 qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index ac1e15cbbc..e419e3c00e 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -24,6 +24,7 @@
 #include "hw/devices.h"
 #include "hw/arm/sharpsl.h"
 #include "ui/console.h"
+#include "hw/audio/wm8750.h"
 #include "audio/audio.h"
 #include "hw/boards.h"
 #include "sysemu/block-backend.h"
@@ -745,7 +746,7 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
 DeviceState *wm;
 
 /* Attach a WM8750 to the bus */
-wm = i2c_create_slave(bus, "wm8750", 0);
+wm = i2c_create_slave(bus, TYPE_WM8750, 0);
 
 spitz_wm8750_addr(wm, 0, 0);
 qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM,
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 60561c7b7c..300e933c82 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -23,6 +23,7 @@
 #include "hw/block/flash.h"
 #include "sysemu/block-backend.h"
 #include "ui/console.h"
+#include "hw/audio/wm8750.h"
 #include "audio/audio.h"
 #include "exec/address-spaces.h"
 #include "sysemu/qtest.h"
@@ -346,7 +347,7 @@ static void z2_init(MachineState *machine)
 z2_lcd = ssi_create_slave(mpu->ssp[1], "zipit-lcd");
 bus = pxa2xx_i2c_bus(mpu->i2c[0]);
 i2c_create_slave(bus, TYPE_AER915, 0x55);
-wm = i2c_create_slave(bus, "wm8750", 0x1b);
+wm = i2c_create_slave(bus, TYPE_WM8750, 0x1b);
 mpu->i2s->opaque = wm;
 mpu->i2s->codec_out = wm8750_dac_dat;
 mpu->i2s->codec_in = wm8750_adc_dat;
diff --git a/hw/audio/marvell_88w8618.c b/hw/audio/marvell_88w8618.c
index 4f65f8c199..e546892d3c 100644
--- 

Re: [Qemu-devel] [PATCH V9 3/4] pvrdma: initial implementation

2018-02-02 Thread Dotan Barak via Qemu-devel
Reviewed-by: Dotan Barak 

  From: Marcel Apfelbaum 
 To: qemu-devel@nongnu.org 
Cc: ehabk...@redhat.com; yuval.sh...@oracle.com; mar...@redhat.com; 
pbonz...@redhat.com; m...@redhat.com; coh...@redhat.com; dotan...@yahoo.com
 Sent: Thursday, February 1, 2018 10:55 PM
 Subject: [Qemu-devel] [PATCH V9 3/4] pvrdma: initial implementation
   
From: Yuval Shaia 

PVRDMA is the QEMU implementation of VMware's paravirtualized RDMA device.
It works with its Linux Kernel driver AS IS, no need for any special guest
modifications.

While it complies with the VMware device, it can also communicate with bare
metal RDMA-enabled machines and does not require an RDMA HCA in the host, it
can work with Soft-RoCE (rxe).

It does not require the whole guest RAM to be pinned allowing memory
over-commit and, even if not implemented yet, migration support will be
possible with some HW assistance.

Signed-off-by: Yuval Shaia 
Signed-off-by: Marcel Apfelbaum 


   


Re: [Qemu-devel] [PATCH v6 18/23] sev: emit the SEV_MEASUREMENT event

2018-02-02 Thread Daniel P . Berrangé
On Fri, Feb 02, 2018 at 09:11:41AM -0600, Brijesh Singh wrote:
> 
> 
> On 02/01/2018 11:27 AM, Dr. David Alan Gilbert wrote:
> > * Brijesh Singh (brijesh.si...@amd.com) wrote:
> > > 
> > > 
> > > On 1/30/18 2:08 PM, Dr. David Alan Gilbert wrote:
> > > > * Brijesh Singh (brijesh.si...@amd.com) wrote:
> > > > > During machine creation we encrypted the guest bios image, the
> > > > > LAUNCH_MEASURE command can be used to retrieve the measurement of
> > > > > the encrypted memory region. Emit the SEV_MEASUREMENT event so that
> > > > > libvirt can grab the measurement value as soon as we are done with
> > > > > creating the encrypted machine.
> > > > Can you ust clarify what happens if the libvirt has disconnected and
> > > > reconnected to qemu and so didn't see the event?  Can the reconnecting
> > > > libvirt query it and find out it's ready/not ready yet?
> > > 
> > > Dave,
> > > 
> > > I have not looked into details between libvirt and qemu interaction to
> > > comment how and when the events will be delivered. Recently, one of my
> > > colleague was implementing libvirt interface for the SEV guest and ran
> > > into somewhat a similar challenge and posted question on libvirt mailing
> > > list [1].
> > > 
> > > In previous discussion on qemu mailing list, we agreed to implement SEV
> > > MEASUREMENT event which can be seen by libvirt. That's what this patch
> > > is doing.
> > > 
> > > But during the libvirt implementation it seems that qemu monitor
> > > silently drops all the events before it get the first qmp_capabilities
> > > command. At a quick glance it seems on reconnect, libvirt issues
> > > qmp_capabilities command and any event issued before the
> > > qmp_capabilities command will never to delivered to libvirt. we are
> > > looking for  help from libvirt/qemu monitor experts on how we solve this
> > > problem. Our goal is to provide the measurement to libvirt before
> > > libvirt issues "continue" command. Since event can't be seen by libvirt
> > > before it resumes the guest hence I was wondering if we should we should
> > > drop the SEV measurement event and consider adding a new QMP command to
> > > query the SEV measurement.
> > 
> > Yep, I'll leave it to the libvirt contacts for the best way they'd like
> > to see that, as Eric says there's nothing wrong with having both the
> > command and event if useful.  Also keep in mind coping with a guest that
> > crashes early or that measurement never arrives.
> > 
> 
> Yep, lets see what libvirt experts say about it.
> 
> Hi Daniel,
> 
> Do you have any recommendation on whether we should consider adding a new
> QMP to retrieve the measurement or we do event or both? Please note that the
> launch measurement is generate only once for the lifetime of the guest. The
> measurement will be available after qmeu encrypts the guest bios during the
> machine initialization time.

IIUC, the measurement event is only required during the initial QEMU
startup sequence. Once the guest CPUs are running this info is not needed
any more.

If libvirtd crashes/restarts in the middle of QEMU startup sequence it is
game over from libvirt's POV. Libvirtd won't try to carry on starting that
guest when it restarts. So I don't think there's a compelling need for a
command to query the measurement from libvirt's POV, the event is fine.

That all said, I think it might be useful to have a command to query the
SEV measurement purely as a debugging aid, if some admin / support person
wants to get hold of this info for some reason...

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



Re: [Qemu-devel] [Qemu-ppc] [PATCH] spapr: add missing break in h_get_cpu_characteristics()

2018-02-02 Thread Daniel Henrique Barboza



On 02/02/2018 08:00 AM, Greg Kurz wrote:

On Fri, 2 Feb 2018 07:11:08 -0200
Daniel Henrique Barboza  wrote:


On 02/01/2018 05:47 PM, Greg Kurz wrote:

Detected by Coverity (CID 1385702). This fixes the recently added hypercall
to let guests properly apply Spectre and Meltdown workarounds.

Paolo Bonzini reported this error in a reply to the pull request that
added the patch:

"Re: [Qemu-ppc] [Qemu-devel] [PULL 12/12] target/ppc/spapr: Add H-Call
H_GET_CPU_CHARACTERISTICS

On 28/01/2018 22:28, David Gibson wrote:


+switch (safe_indirect_branch) {
+case SPAPR_CAP_FIXED:
+characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;

Missing "break;" here.

Paolo

"

I think it is nice to mention in the commit msg that Paolo also detected
this same error,
specially given that his email was sent before this patch.


Heh, Paolo's mail landed in the pull req thread in my mail client and I saw
it after sending the patch :P ... also I'm pretty sure Paolo was made aware
of this issue by Coverity, just as I was :)

From: scan-ad...@coverity.com
To: gr...@kaod.org
Subject: New Defects reported by Coverity Scan for QEMU
Date: Thu, 01 Feb 2018 18:11:33 + (UTC)

Hi,

Please find the latest report on new defect(s) introduced to QEMU found with
Coverity Scan.

...

*** CID 1385702:  Control flow issues  (MISSING_BREAK)
/hw/ppc/spapr_hcall.c: 1700 in h_get_cpu_characteristics()
1694 break;
1695 }
1696
1697 switch (safe_indirect_branch) {
1698 case SPAPR_CAP_FIXED:
1699 characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;

 CID 1385702:  Control flow issues  (MISSING_BREAK)
 The above case falls through to this one.

1700 default: /* broken */
1701 assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
1702 break;
1703 }
1704
1705 args[0] = characteristics;


No big deal I guess :)


Roger that!




Thanks,


Daniel



Fixes: c59704b25473 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS"
Signed-off-by: Greg Kurz 
---
   hw/ppc/spapr_hcall.c |1 +
   1 file changed, 1 insertion(+)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 4d0e6eb0cf1d..596f58378a40 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1697,6 +1697,7 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU 
*cpu,
   switch (safe_indirect_branch) {
   case SPAPR_CAP_FIXED:
   characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
+break;
   default: /* broken */
   assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
   break;

  





Re: [Qemu-devel] [PATCH v2] block: maintain persistent disabled bitmaps

2018-02-02 Thread Vladimir Sementsov-Ogievskiy

31.01.2018 22:04, Max Reitz wrote:

On 2018-01-29 19:43, Max Reitz wrote:

On 2018-01-22 11:41, Vladimir Sementsov-Ogievskiy wrote:

To maintain load/store disabled bitmap there is new approach:

  - deprecate @autoload flag of block-dirty-bitmap-add, make it ignored
  - store enabled bitmaps as "auto" to qcow2
  - store disabled bitmaps without "auto" flag to qcow2
  - on qcow2 open load "auto" bitmaps as enabled and others
as disabled (except in_use bitmaps)

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: John Snow 
---

Thanks, looks very reasonable.  Applied to my block branch:

https://github.com/XanClic/qemu/commits/block

...aaand I've only just now seen that iotest 176 will need to be fixed
along with this, so I'm going to unqueue this patch for now.


ohh, sorry for that. Will resend today.



And when I'm already at it: Should we add deprecation information to
qemu-doc.texi?


didn't find anything in qemu-doc.texi about dirty bitmaps, so I think, no.

Is there a way to generate some documentation files from qapi comments? 
Where is it?




Max





--
Best regards,
Vladimir




Re: [Qemu-devel] [PATCH] s390x/sclp: fix event mask handling

2018-02-02 Thread Cornelia Huck
On Fri, 2 Feb 2018 10:43:18 +0100
Christian Borntraeger  wrote:

> On 02/02/2018 10:42 AM, Christian Borntraeger wrote:
> > commit 67915de9f038 ("s390x/event-facility: variable-length event
> > masks") switches the sclp receive/send mask. This broke the sclp
> > lm console.

Hum. Probably should add sclp-lm to my test setup.

> > 
> > Signed-off-by: Christian Borntraeger 
> > Fixes: commit 67915de9f038 ("s390x/event-facility: variable-length event 
> > masks")
> > Cc: Cornelia Huck   
> 
> opps. Please fixup yourself Conny :-)

Well, you did cc: the original author :)

> 
> > Cc: Jason J. Herne 
> > Cc: qemu-sta...@nongnu.org
> > ---
> >  hw/s390x/event-facility.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> > index b0f71f4554..155a69467b 100644
> > --- a/hw/s390x/event-facility.c
> > +++ b/hw/s390x/event-facility.c
> > @@ -293,10 +293,10 @@ static void write_event_mask(SCLPEventFacility *ef, 
> > SCCB *sccb)
> >  ef->receive_mask = be32_to_cpu(tmp_mask);
> > 
> >  /* return the SCLP's capability masks to the guest */
> > -tmp_mask = cpu_to_be32(get_host_send_mask(ef));
> > +tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
> >  copy_mask(WEM_RECEIVE_MASK(we_mask, mask_length), (uint8_t *)_mask,
> >mask_length, sizeof(tmp_mask));
> > -tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
> > +tmp_mask = cpu_to_be32(get_host_send_mask(ef));
> >  copy_mask(WEM_SEND_MASK(we_mask, mask_length), (uint8_t *)_mask,
> >mask_length, sizeof(tmp_mask));
> >   
> 

Thanks, applied.



[Qemu-devel] [PATCH RFC 00/21] Modularize generated QAPI code

2018-02-02 Thread Markus Armbruster
Our qapi-schema.json is composed of modules connected by include
directives, but the generated code is monolithic all the same: one
qapi-types.h with all the types, one qapi-visit.h with all the
visitors, and so forth.  These monolithic headers get included all
over the place.  In my "build everyhing" tree, adding a QAPI type
recompiles about 4500 out of 4800 objects.

Nobody would write such monolithic headers by hand.  It stands to
reason that one shouldn't generate them, either.

This series' basic idea is to split up generated headers to mirror the
schema's modular structure: one header per module.  That way, you can
include just what you need.

The series is RFC for a number of reasons:

* The split is implemented only for qapi-types.h.  That one should
  provide the biggest benefits, though.

* There's a bit of code duplication.

* I haven't re-read my patches, yet.

Even in this incomplete state, the compile-time improvements can be
massive.  Before this series, any QAPI schema change recompiles some
4500 out of 4800 objects in my "build everything" tree.  Afterwards,
adding a type to qapi/migration.json recompiles less than 400, adding
a QMP event recompiles less than 200, and a documentation change no
longer recompiles anything.

Related: Marc-André's 'unit' pragma proposal.  That's a different way
to split off parts of the generated code, motivated by the desire to
use poisoned identifiers such as TARGET_I386.  I noted in my review of
v3 that I "can either accept it, or come up with a better solution."
This is my attempt at a better solution.  It's a bit more ambitious,
and thus more useful (I hope).  The pragma has one theoretical
advantage, though: you can modularize the generated output in
different ways than the input.  The patches using don't do that,
however.

Based-on: <2018020846.21846-1-arm...@redhat.com>
[PATCH v3 00/19] Clean up includes to reduce compile time

Markus Armbruster (21):
  qapi: Streamline boilerplate comment generation
  qapi: Generate up-to-date copyright notice
  qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc
  qapi: Reduce use of global variables in generators some
  qapi: Turn generators into modules
  qapi-gen: New common driver for code and doc generators
  qapi: Move parse_command_line() next to its only use
  qapi: Touch generated files only when they change
  qapi: Don't absolutize include file name in error messages
  qapi/common: Eliminate QAPISchema.exprs
  qapi: Lift error reporting from QAPISchema.__init__() to callers
  qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()
  qapi: Record 'include' directives in parse tree
  qapi: Generate in source order
  qapi: Record 'include' directives in intermediate representation
  qapi/types qapi/visit: Make visitors use QAPIGen more
  qapi/types qapi/visit: Generate built-in stuff into separate files
  qapi/common: Fix guardname() for funny filenames
  qapi/types: Generate separate .h, .c for each module
  Include less of qapi-types.h
  qapi: Empty out qapi-schema.json

 Makefile   |  131 +-
 Makefile.objs  |   20 +-
 crypto/cipherpriv.h|2 +-
 hw/block/block.c   |1 +
 hw/block/hd-geometry.c |1 +
 hw/net/rocker/rocker_fp.c  |2 +-
 include/block/block.h  |2 +-
 include/block/dirty-bitmap.h   |2 +-
 include/chardev/char.h |1 +
 include/crypto/cipher.h|2 +-
 include/crypto/hash.h  |2 +-
 include/crypto/hmac.h  |2 +-
 include/crypto/secret.h|1 +
 include/crypto/tlscreds.h  |1 +
 include/hw/block/block.h   |2 +-
 include/hw/block/fdc.h |2 +-
 include/hw/ppc/spapr_drc.h |1 +
 include/hw/qdev-properties.h   |2 +
 include/io/dns-resolver.h  |1 +
 include/migration/colo.h   |2 +-
 include/migration/failover.h   |2 +-
 include/migration/global_state.h   |1 +
 include/monitor/monitor.h  |1 +
 include/net/filter.h   |1 +
 include/net/net.h  |2 +-
 include/qapi/error.h   |2 +-
 include/qapi/qmp/qobject.h |2 +-
 include/qapi/visitor.h |2 +-
 include/qemu/sockets.h |2 +-
 include/qemu/throttle.h|2 +-
 include/qom/cpu.h  |1 +
 include/qom/object.h   |   

[Qemu-devel] [PULL 1/3] ui: fix mixup between qnum and qcode in SDL1 key handling

2018-02-02 Thread Gerd Hoffmann
From: Daniel P. Berrangé 

The previous commit:

  commit 2ec78706d188df7d3dab43d07b19b05ef7800a44
  Author: Daniel P. Berrange 
  Date:   Wed Jan 17 16:47:15 2018 +

ui: convert GTK and SDL1 frontends to keycodemapdb

changed the x_keymap.c keymap so that its target was qcodes instead of
qnums. It updated the GTK frontend to take account of this change, but
forgot to update the SDL1 frontend. Thus the SDL frontend was getting
qcodes but dispatching them as if they were qnums. IOW, keyboard input
was completely hosed with SDL1. Since the keyboard layout tables are
still all based on qnums, it is easier to just keep SDL1 using qnums as
it will be deleted in a few releases time.

Reported-by: BALATON Zoltan 
Signed-off-by: Daniel P. Berrangé 
Tested-by: BALATON Zoltan 
Message-id: 20180201180033.14255-1-berra...@redhat.com
Signed-off-by: Gerd Hoffmann 
---
 ui/sdl.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index c8f102bb9f..a6bff301eb 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -242,6 +242,7 @@ static const guint16 *sdl_get_keymap(size_t *maplen)
 
 static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
 {
+int qcode;
 if (!keycode_map) {
 return 0;
 }
@@ -249,7 +250,13 @@ static uint8_t sdl_keyevent_to_keycode(const 
SDL_KeyboardEvent *ev)
 return 0;
 }
 
-return keycode_map[ev->keysym.scancode];
+qcode = keycode_map[ev->keysym.scancode];
+
+if (qcode > qemu_input_map_qcode_to_qnum_len) {
+return 0;
+}
+
+return qemu_input_map_qcode_to_qnum[qcode];
 }
 
 static void reset_keys(void)
-- 
2.9.3




Re: [Qemu-devel] [RFC] kvm: x86: export vCPU halted state to sysfs

2018-02-02 Thread Eduardo Habkost
On Fri, Feb 02, 2018 at 03:07:18PM +, Daniel P. Berrangé wrote:
> On Fri, Feb 02, 2018 at 12:50:14PM -0200, Eduardo Habkost wrote:
> > (CCing qemu-devel)
> > 
> > On Fri, Feb 02, 2018 at 09:21:59AM -0500, Luiz Capitulino wrote:
> > > On Fri, 2 Feb 2018 14:19:38 +
> > > Daniel P. Berrangé  wrote:
> > > > On Fri, Feb 02, 2018 at 12:15:54PM -0200, Eduardo Habkost wrote:
> > [...]
> > > > > It would be also interesting to update QEMU QMP documentation to
> > > > > clarify the arch-specific semantics of "halted".  
> > > > 
> > > > Any also especially clarify the awful performance implications of 
> > > > running
> > > > this particular query command. In general I would not expect query-xxx
> > > > monitor commands to interrupt all vcpus, so we should clearly warn about
> > > > this !
> > > 
> > > Or deprecate it...
> > 
> > We could deprecate the expensive fields on query-cpus, and move
> > them to a more expensive query-cpu-state command.  I believe most
> > users of query-cpus are only interested in qom_path, thread_id,
> > and topology info.
> > 
> > Markus, Eric: from the QAPI point of view, is it OK to remove
> > fields between QEMU versions, as long as we follow our
> > deprecation policy?
> 
> I would expect that to not be OK.  A fully backwards compatible way to
> deal with this would just be to add a flag to the query-cpus command
> eg something like
> 
> query-cpus arch-specific=false
> 
> to turn off all this arch specific state, and just report the cheap
> generic info. If it defaults to arch-specific=true when omitted, then
> there's no compat problems.

This would work, too.  I would name it "full-state",
"extended-state" or something similar, though.  Not all
arch-specific data is expensive to fetch, and not all
non-arch-specific data is unexpensive.

But I'd like to confirm if it's OK to make existing non-optional
struct fields optional in the QAPI schema.  Markus, Eric?

-- 
Eduardo



[Qemu-devel] [PATCH RFC 20/21] Include less of qapi-types.h

2018-02-02 Thread Markus Armbruster
In my "build everything" tree, a change to the types in
qapi-schema.json triggers a recompile of about 4500 out of 4800
objects.

The previous commit split up the generated qapi-types.h.  Replace
includes of qapi-types.h (i.e. all types) by includes of parts where
possible.

To illustrate the benefits: adding a type to qapi/migration.json now
recompiles some 2300 instead of 4500 objects.  The next commit will
improve it further.

Signed-off-by: Markus Armbruster 
---
 crypto/cipherpriv.h  | 2 +-
 hw/block/block.c | 1 +
 hw/block/hd-geometry.c   | 1 +
 hw/net/rocker/rocker_fp.c| 2 +-
 include/block/block.h| 2 +-
 include/block/dirty-bitmap.h | 2 +-
 include/chardev/char.h   | 1 +
 include/crypto/cipher.h  | 2 +-
 include/crypto/hash.h| 2 +-
 include/crypto/hmac.h| 2 +-
 include/crypto/secret.h  | 1 +
 include/crypto/tlscreds.h| 1 +
 include/hw/block/block.h | 2 +-
 include/hw/block/fdc.h   | 2 +-
 include/hw/ppc/spapr_drc.h   | 1 +
 include/hw/qdev-properties.h | 1 +
 include/io/dns-resolver.h| 1 +
 include/migration/colo.h | 2 +-
 include/migration/failover.h | 2 +-
 include/migration/global_state.h | 1 +
 include/monitor/monitor.h| 1 +
 include/net/filter.h | 1 +
 include/net/net.h| 2 +-
 include/qapi/error.h | 2 +-
 include/qapi/qmp/qobject.h   | 2 +-
 include/qapi/visitor.h   | 2 +-
 include/qemu/sockets.h   | 2 +-
 include/qemu/throttle.h  | 2 +-
 include/qom/cpu.h| 1 +
 include/qom/object.h | 2 +-
 include/sysemu/dump.h| 2 ++
 include/sysemu/hostmem.h | 1 +
 include/sysemu/replay.h  | 1 +
 include/sysemu/sysemu.h  | 1 +
 include/sysemu/tpm.h | 1 +
 include/sysemu/watchdog.h| 2 +-
 include/ui/input.h   | 2 +-
 migration/migration.h| 1 +
 migration/ram.h  | 2 +-
 net/tap_int.h| 2 +-
 replication.h| 1 +
 ui/vnc.h | 1 +
 42 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/crypto/cipherpriv.h b/crypto/cipherpriv.h
index 77da4c2f32..0823239f41 100644
--- a/crypto/cipherpriv.h
+++ b/crypto/cipherpriv.h
@@ -15,7 +15,7 @@
 #ifndef QCRYPTO_CIPHERPRIV_H
 #define QCRYPTO_CIPHERPRIV_H
 
-#include "qapi-types.h"
+#include "qapi/qapi-types-crypto.h"
 
 typedef struct QCryptoCipherDriver QCryptoCipherDriver;
 
diff --git a/hw/block/block.c b/hw/block/block.c
index b0269c857f..b91e2b6d7e 100644
--- a/hw/block/block.c
+++ b/hw/block/block.c
@@ -12,6 +12,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/block/block.h"
 #include "qapi/error.h"
+#include "qapi/qapi-types-block.h"
 #include "qemu/error-report.h"
 
 void blkconf_serial(BlockConf *conf, char **serial)
diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c
index 57ad5012a7..79384a2b0a 100644
--- a/hw/block/hd-geometry.c
+++ b/hw/block/hd-geometry.c
@@ -32,6 +32,7 @@
 
 #include "qemu/osdep.h"
 #include "sysemu/block-backend.h"
+#include "qapi/qapi-types-block.h"
 #include "qemu/bswap.h"
 #include "hw/block/block.h"
 #include "trace.h"
diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c
index 4b3c9847db..27b17c890f 100644
--- a/hw/net/rocker/rocker_fp.c
+++ b/hw/net/rocker/rocker_fp.c
@@ -16,7 +16,7 @@
 
 #include "qemu/osdep.h"
 #include "net/clients.h"
-
+#include "qapi/qapi-types-rocker.h"
 #include "rocker.h"
 #include "rocker_hw.h"
 #include "rocker_fp.h"
diff --git a/include/block/block.h b/include/block/block.h
index ae1517f32d..70b90cd767 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -2,7 +2,7 @@
 #define BLOCK_H
 
 #include "block/aio.h"
-#include "qapi-types.h"
+#include "qapi/qapi-types-block-core.h"
 #include "qemu/iov.h"
 #include "qemu/coroutine.h"
 #include "block/accounting.h"
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 3da8486ab1..1454be358d 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -2,7 +2,7 @@
 #define BLOCK_DIRTY_BITMAP_H
 
 #include "qemu-common.h"
-#include "qapi-types.h"
+#include "qapi/qapi-types-block-core.h"
 #include "qemu/hbitmap.h"
 
 BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
diff --git a/include/chardev/char.h b/include/chardev/char.h
index a381dc3df8..ebf1e0ba04 100644
--- a/include/chardev/char.h
+++ b/include/chardev/char.h
@@ -1,6 +1,7 @@
 #ifndef QEMU_CHAR_H
 #define QEMU_CHAR_H
 
+#include "qapi/qapi-types-char.h"
 #include "qemu/main-loop.h"
 #include "qemu/bitmap.h"
 #include "qom/object.h"
diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h
index 984fb8243f..bce2d4c8e4 100644
--- a/include/crypto/cipher.h
+++ b/include/crypto/cipher.h
@@ -21,7 +21,7 @@
 #ifndef QCRYPTO_CIPHER_H
 #define QCRYPTO_CIPHER_H
 
-#include 

[Qemu-devel] [PULL 3/3] ui: correctly advance output buffer when writing SASL data

2018-02-02 Thread Gerd Hoffmann
From: Daniel P. Berrangé 

In this previous commit:

  commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
  Author: Daniel P. Berrange 
  Date:   Mon Dec 18 19:12:20 2017 +

ui: track how much decoded data we consumed when doing SASL encoding

I attempted to fix a flaw with tracking how much data had actually been
processed when encoding with SASL. With that flaw, the VNC server could
mistakenly discard queued data that had not been sent.

The fix was not quite right though, because it merely decremented the
vs->output.offset value. This is effectively discarding data from the
end of the pending output buffer. We actually need to discard data from
the start of the pending output buffer. We also want to free memory that
is no longer required. The correct way to handle this is to use the
buffer_advance() helper method instead of directly manipulating the
offset value.

Reported-by: Laszlo Ersek 
Signed-off-by: Daniel P. Berrangé 
Reviewed-by: Eric Blake 
Reviewed-by: Laszlo Ersek 
Message-id: 20180201155841.27509-1-berra...@redhat.com
Signed-off-by: Gerd Hoffmann 
---
 ui/vnc-auth-sasl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
index 74a5f513f2..fbccca8c8a 100644
--- a/ui/vnc-auth-sasl.c
+++ b/ui/vnc-auth-sasl.c
@@ -84,7 +84,7 @@ size_t vnc_client_write_sasl(VncState *vs)
 } else {
 vs->force_update_offset -= vs->sasl.encodedRawLength;
 }
-vs->output.offset -= vs->sasl.encodedRawLength;
+buffer_advance(>output, vs->sasl.encodedRawLength);
 vs->sasl.encoded = NULL;
 vs->sasl.encodedOffset = vs->sasl.encodedLength = 0;
 }
-- 
2.9.3




Re: [Qemu-devel] Qemu Trace

2018-02-02 Thread Peter Maydell
On 2 February 2018 at 10:08, Stefan Hajnoczi  wrote:
> On Thu, Feb 01, 2018 at 04:30:10PM +0100, Nesrine Zouari wrote:
>> I am a computer engineering student and I am actually working on my
>> graduation project at Lauterbach company. The project is about Qemu Trace
>> and as a future I would like to contribute this work to the main line.
>>
>> My project is divided into two parts:
>>
>> 1/ Collecting the Guest trace data : The trace solution should be able to
>> provide:
>>
>> a/ Instruction flow Trace
>>
>> b/ Memory read/write access
>>
>> c/ Time Stamps.
>>
>> d/ For tracing rich operating systems that are using MMU, we
>> additionally need to trace the task switches.
>
> Lluìs has done the most instrumentation work in qemu.git and can explain
> the current status.

I think at the moment the status is that we're still discussing
what the trace plugin API should be... there are some mailing
list threads on the subject from I think last year some time.

thanks
-- PMM



[Qemu-devel] [PATCH RFC 05/21] qapi: Turn generators into modules

2018-02-02 Thread Markus Armbruster
The next commit will introduce a common driver program for all
generators.  The generators need to be modules for that.  qapi2texi.py
already is.  Make the other generators follow suit.

The changes are actually trivial.  Obvious in the diffs once you view
them with whitespace changes ignored.

Signed-off-by: Markus Armbruster 
---
 scripts/qapi-commands.py   | 43 ++--
 scripts/qapi-event.py  | 43 ++--
 scripts/qapi-introspect.py | 54 ++--
 scripts/qapi-types.py  | 56 ++---
 scripts/qapi-visit.py  | 62 +-
 5 files changed, 143 insertions(+), 115 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index d229537659..331b58670e 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -255,16 +255,17 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
 self._regy += gen_register_command(name, success_response)
 
 
-(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
+def main(argv):
+(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
 
-blurb = '''
+blurb = '''
  * Schema-defined QAPI/QMP commands
 '''
 
-genc = QAPIGenC(blurb, __doc__)
-genh = QAPIGenH(blurb, __doc__)
+genc = QAPIGenC(blurb, __doc__)
+genh = QAPIGenH(blurb, __doc__)
 
-genc.body(mcgen('''
+genc.body(mcgen('''
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/module.h"
@@ -278,24 +279,28 @@ genc.body(mcgen('''
 #include "%(prefix)sqmp-commands.h"
 
 ''',
-prefix=prefix))
+prefix=prefix))
 
-genh.body(mcgen('''
+genh.body(mcgen('''
 #include "%(prefix)sqapi-types.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/dispatch.h"
 
 void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
 ''',
-prefix=prefix, c_prefix=c_name(prefix, protect=False)))
-
-schema = QAPISchema(input_file)
-vis = QAPISchemaGenCommandVisitor(prefix)
-schema.visit(vis)
-genc.body(vis.defn)
-genh.body(vis.decl)
-
-if do_c:
-genc.write(output_dir, prefix + 'qmp-marshal.c')
-if do_h:
-genh.write(output_dir, prefix + 'qmp-commands.h')
+prefix=prefix, c_prefix=c_name(prefix, protect=False)))
+
+schema = QAPISchema(input_file)
+vis = QAPISchemaGenCommandVisitor(prefix)
+schema.visit(vis)
+genc.body(vis.defn)
+genh.body(vis.decl)
+
+if do_c:
+genc.write(output_dir, prefix + 'qmp-marshal.c')
+if do_h:
+genh.write(output_dir, prefix + 'qmp-commands.h')
+
+
+if __name__ == '__main__':
+main(sys.argv)
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 1af21b580a..5b33c694d4 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -171,16 +171,17 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
 self._event_names.append(name)
 
 
-(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
+def main(argv):
+(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
 
-blurb = '''
+blurb = '''
  * Schema-defined QAPI/QMP events
 '''
 
-genc = QAPIGenC(blurb, __doc__)
-genh = QAPIGenH(blurb, __doc__)
+genc = QAPIGenC(blurb, __doc__)
+genh = QAPIGenH(blurb, __doc__)
 
-genc.body(mcgen('''
+genc.body(mcgen('''
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "%(prefix)sqapi-event.h"
@@ -190,23 +191,27 @@ genc.body(mcgen('''
 #include "qapi/qmp-event.h"
 
 ''',
-prefix=prefix))
+prefix=prefix))
 
-genh.body(mcgen('''
+genh.body(mcgen('''
 #include "qapi/util.h"
 #include "qapi/qmp/qdict.h"
 #include "%(prefix)sqapi-types.h"
 
 ''',
-prefix=prefix))
-
-schema = QAPISchema(input_file)
-vis = QAPISchemaGenEventVisitor(prefix)
-schema.visit(vis)
-genc.body(vis.defn)
-genh.body(vis.decl)
-
-if do_c:
-genc.write(output_dir, prefix + 'qapi-event.c')
-if do_h:
-genh.write(output_dir, prefix + 'qapi-event.h')
+prefix=prefix))
+
+schema = QAPISchema(input_file)
+vis = QAPISchemaGenEventVisitor(prefix)
+schema.visit(vis)
+genc.body(vis.defn)
+genh.body(vis.decl)
+
+if do_c:
+genc.write(output_dir, prefix + 'qapi-event.c')
+if do_h:
+genh.write(output_dir, prefix + 'qapi-event.h')
+
+
+if __name__ == '__main__':
+main(sys.argv)
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 8d4e3c1c3a..09e7d1f140 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -167,38 +167,44 @@ const char %(c_name)s[] = %(c_string)s;
 arg_type = arg_type or self._schema.the_empty_object_type
 self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type)})
 
-# Debugging aid: unmask QAPI schema's type names
-# We normally mask them, because they're not QMP wire ABI

[Qemu-devel] [PULL v2 04/10] tests: virtio-9p: wait for completion in the test code

2018-02-02 Thread Greg Kurz
In order to test request cancellation, we will need to send multiple
requests and wait for the associated replies. Since we poll the ISR
to know if a request completed, we may have several replies to parse
when we detect ISR was set to 1.

This patch moves the waiting out of the reply parsing path, up into
the functional tests.

Signed-off-by: Greg Kurz 
Reviewed-by: Stefan Hajnoczi 
---
 tests/virtio-9p-test.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index 5ada2839b9ae..cb086315a36e 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -246,13 +246,17 @@ static const char *rmessage_name(uint8_t id)
 "";
 }
 
-static void v9fs_req_recv(P9Req *req, uint8_t id)
+static void v9fs_req_wait_for_reply(P9Req *req)
 {
 QVirtIO9P *v9p = req->v9p;
-P9Hdr hdr;
 
 qvirtio_wait_used_elem(v9p->dev, v9p->vq, req->free_head,
QVIRTIO_9P_TIMEOUT_US);
+}
+
+static void v9fs_req_recv(P9Req *req, uint8_t id)
+{
+P9Hdr hdr;
 
 v9fs_memread(req, , 7);
 hdr.size = ldl_le_p();
@@ -398,6 +402,7 @@ static void fs_version(QVirtIO9P *v9p)
 P9Req *req;
 
 req = v9fs_tversion(v9p, P9_MAX_SIZE, version, P9_NOTAG);
+v9fs_req_wait_for_reply(req);
 v9fs_rversion(req, _len, _version);
 
 g_assert_cmpmem(server_version, server_len, version, strlen(version));
@@ -411,6 +416,7 @@ static void fs_attach(QVirtIO9P *v9p)
 
 fs_version(v9p);
 req = v9fs_tattach(v9p, 0, getuid(), 0);
+v9fs_req_wait_for_reply(req);
 v9fs_rattach(req, NULL);
 }
 
@@ -431,6 +437,7 @@ static void fs_walk(QVirtIO9P *v9p)
 
 fs_attach(v9p);
 req = v9fs_twalk(v9p, 0, 1, P9_MAXWELEM, wnames, 0);
+v9fs_req_wait_for_reply(req);
 v9fs_rwalk(req, , );
 
 g_assert_cmpint(nwqid, ==, P9_MAXWELEM);
@@ -452,6 +459,7 @@ static void fs_walk_no_slash(QVirtIO9P *v9p)
 
 fs_attach(v9p);
 req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
+v9fs_req_wait_for_reply(req);
 v9fs_rlerror(req, );
 
 g_assert_cmpint(err, ==, ENOENT);
@@ -467,9 +475,11 @@ static void fs_walk_dotdot(QVirtIO9P *v9p)
 
 fs_version(v9p);
 req = v9fs_tattach(v9p, 0, getuid(), 0);
+v9fs_req_wait_for_reply(req);
 v9fs_rattach(req, _qid);
 
 req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
+v9fs_req_wait_for_reply(req);
 v9fs_rwalk(req, NULL, ); /* We now we'll get one qid */
 
 g_assert_cmpmem(_qid, 13, wqid[0], 13);
-- 
2.13.6




[Qemu-devel] [PULL v2 00/10] 9p patches for 2.12 20180202

2018-02-02 Thread Greg Kurz
The following changes since commit b05631954d6dfe93340d516660397e2c1a2a5dd6:

  Merge remote-tracking branch 'remotes/rth/tags/pull-hppa-20180131' into 
staging (2018-01-31 15:50:29 +)

are available in the git repository at:

  https://github.com/gkurz/qemu.git tags/for-upstream

for you to fetch changes up to 9ea776ee7d4061c043d0fbf89aa85f86ec0cf8a2:

  tests/virtio-9p: explicitly handle potential integer overflows (2018-02-02 
11:15:34 +0100)


This series is mostly about 9p request cancellation. It fixes a
long standing bug (read "specification violation") where the server
would send an invalid response when the client has cancelled an
in-flight request. This was causing annoying spurious EINTR returns
in linux. The fix comes with some related testing in QTEST.

Other patches are code cleanup and improvements.

v2: fix the alignment issue that was presumably causing make check to
fail on sparc hosts


Greg Kurz (9):
  9pfs: drop v9fs_register_transport()
  tests: virtio-9p: move request tag to the test functions
  tests: virtio-9p: wait for completion in the test code
  tests: virtio-9p: use the synth backend
  tests: virtio-9p: add LOPEN operation test
  tests: virtio-9p: add WRITE operation test
  libqos/virtio: return length written into used descriptor
  tests: virtio-9p: add FLUSH operation test
  tests/virtio-9p: explicitly handle potential integer overflows

Keno Fischer (1):
  9pfs: Correctly handle cancelled requests

 hw/9pfs/9p-synth.c |  52 
 hw/9pfs/9p-synth.h |  13 ++
 hw/9pfs/9p.c   |  25 +++-
 hw/9pfs/9p.h   |  10 +-
 hw/9pfs/trace-events   |   1 +
 hw/9pfs/virtio-9p-device.c |   8 +-
 hw/9pfs/xen-9p-backend.c   |   3 +-
 tests/libqos/virtio.c  |  25 ++--
 tests/libqos/virtio.h  |   3 +-
 tests/virtio-9p-test.c | 294 ++---
 tests/virtio-blk-test.c|  24 ++--
 tests/virtio-net-test.c|   6 +-
 tests/virtio-scsi-test.c   |   3 +-
 13 files changed, 385 insertions(+), 82 deletions(-)
-- 
2.13.6




[Qemu-devel] [PULL v2 03/10] tests: virtio-9p: move request tag to the test functions

2018-02-02 Thread Greg Kurz
It doesn't really makes sense to hide the request tag from the test
functions. It prevents to test the 9p server behavior when passed
a wrong tag (ie, still in use or different from P9_NOTAG for a
version request). Also the spec says that a tag is reusable as soon
as the corresponding request was replied or flushed: no need to
always increment tags like we do now. And finaly, an upcoming test
of the flush command will need to manipulate tags explicitely.

This simply changes all request functions to have a tag argument.
Except for the version request which needs P9_NOTAG, all other
tests can pass 0 since they wait for the reply before sending
another request.

Signed-off-by: Greg Kurz 
Reviewed-by: Stefan Hajnoczi 
---
 tests/virtio-9p-test.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index 00f00f7246e9..5ada2839b9ae 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -27,7 +27,6 @@ typedef struct {
 QOSState *qs;
 QVirtQueue *vq;
 char *test_share;
-uint16_t p9_req_tag;
 } QVirtIO9P;
 
 static QVirtIO9P *qvirtio_9p_start(const char *driver)
@@ -294,10 +293,11 @@ static void v9fs_rlerror(P9Req *req, uint32_t *err)
 }
 
 /* size[4] Tversion tag[2] msize[4] version[s] */
-static P9Req *v9fs_tversion(QVirtIO9P *v9p, uint32_t msize, const char 
*version)
+static P9Req *v9fs_tversion(QVirtIO9P *v9p, uint32_t msize, const char 
*version,
+uint16_t tag)
 {
 P9Req *req = v9fs_req_init(v9p, 4 + v9fs_string_size(version), P9_TVERSION,
-   P9_NOTAG);
+   tag);
 
 v9fs_uint32_write(req, msize);
 v9fs_string_write(req, version);
@@ -323,12 +323,12 @@ static void v9fs_rversion(P9Req *req, uint16_t *len, char 
**version)
 }
 
 /* size[4] Tattach tag[2] fid[4] afid[4] uname[s] aname[s] n_uname[4] */
-static P9Req *v9fs_tattach(QVirtIO9P *v9p, uint32_t fid, uint32_t n_uname)
+static P9Req *v9fs_tattach(QVirtIO9P *v9p, uint32_t fid, uint32_t n_uname,
+   uint16_t tag)
 {
 const char *uname = ""; /* ignored by QEMU */
 const char *aname = ""; /* ignored by QEMU */
-P9Req *req = v9fs_req_init(v9p, 4 + 4 + 2 + 2 + 4, P9_TATTACH,
-   ++(v9p->p9_req_tag));
+P9Req *req = v9fs_req_init(v9p, 4 + 4 + 2 + 2 + 4, P9_TATTACH, tag);
 
 v9fs_uint32_write(req, fid);
 v9fs_uint32_write(req, P9_NOFID);
@@ -353,7 +353,7 @@ static void v9fs_rattach(P9Req *req, v9fs_qid *qid)
 
 /* size[4] Twalk tag[2] fid[4] newfid[4] nwname[2] nwname*(wname[s]) */
 static P9Req *v9fs_twalk(QVirtIO9P *v9p, uint32_t fid, uint32_t newfid,
- uint16_t nwname, char *const wnames[])
+ uint16_t nwname, char *const wnames[], uint16_t tag)
 {
 P9Req *req;
 int i;
@@ -362,7 +362,7 @@ static P9Req *v9fs_twalk(QVirtIO9P *v9p, uint32_t fid, 
uint32_t newfid,
 for (i = 0; i < nwname; i++) {
 size += v9fs_string_size(wnames[i]);
 }
-req = v9fs_req_init(v9p,  size, P9_TWALK, ++(v9p->p9_req_tag));
+req = v9fs_req_init(v9p,  size, P9_TWALK, tag);
 v9fs_uint32_write(req, fid);
 v9fs_uint32_write(req, newfid);
 v9fs_uint16_write(req, nwname);
@@ -397,7 +397,7 @@ static void fs_version(QVirtIO9P *v9p)
 char *server_version;
 P9Req *req;
 
-req = v9fs_tversion(v9p, P9_MAX_SIZE, version);
+req = v9fs_tversion(v9p, P9_MAX_SIZE, version, P9_NOTAG);
 v9fs_rversion(req, _len, _version);
 
 g_assert_cmpmem(server_version, server_len, version, strlen(version));
@@ -410,7 +410,7 @@ static void fs_attach(QVirtIO9P *v9p)
 P9Req *req;
 
 fs_version(v9p);
-req = v9fs_tattach(v9p, 0, getuid());
+req = v9fs_tattach(v9p, 0, getuid(), 0);
 v9fs_rattach(req, NULL);
 }
 
@@ -430,7 +430,7 @@ static void fs_walk(QVirtIO9P *v9p)
 }
 
 fs_attach(v9p);
-req = v9fs_twalk(v9p, 0, 1, P9_MAXWELEM, wnames);
+req = v9fs_twalk(v9p, 0, 1, P9_MAXWELEM, wnames, 0);
 v9fs_rwalk(req, , );
 
 g_assert_cmpint(nwqid, ==, P9_MAXWELEM);
@@ -451,7 +451,7 @@ static void fs_walk_no_slash(QVirtIO9P *v9p)
 uint32_t err;
 
 fs_attach(v9p);
-req = v9fs_twalk(v9p, 0, 1, 1, wnames);
+req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
 v9fs_rlerror(req, );
 
 g_assert_cmpint(err, ==, ENOENT);
@@ -466,10 +466,10 @@ static void fs_walk_dotdot(QVirtIO9P *v9p)
 P9Req *req;
 
 fs_version(v9p);
-req = v9fs_tattach(v9p, 0, getuid());
+req = v9fs_tattach(v9p, 0, getuid(), 0);
 v9fs_rattach(req, _qid);
 
-req = v9fs_twalk(v9p, 0, 1, 1, wnames);
+req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
 v9fs_rwalk(req, NULL, ); /* We now we'll get one qid */
 
 g_assert_cmpmem(_qid, 13, wqid[0], 13);
-- 
2.13.6




Re: [Qemu-devel] [PATCH] pcie-root-port: let it has higher migrate priority

2018-02-02 Thread Peter Xu
On Thu, Feb 01, 2018 at 10:01:31PM +0200, Marcel Apfelbaum wrote:

[...]

> Root ports can't be nested, anyway, I suppose the migration should
> follow the bus numbering order.

Could I ask whether this is a must?  And if yes, why?

> 
> The question now is what happens if the migration is happening before
> the guest firmware finishes assigning numbers to buses...

Do you mean that vIOMMU may fetch wrong context entries too?

Note that as long as vIOMMU DMAR is off globally, vIOMMU will not
fetch context entries at all.  So IMHO this problem should not happen
during the firmware execution time (assuming that the firmware should
not enable vIOMMU at all).

Thanks,

-- 
Peter Xu



Re: [Qemu-devel] [PATCH 3/4] MAINTAINERS: add pointer to tpm-next repository

2018-02-02 Thread Eric Blake
On 02/02/2018 08:44 AM, Stefan Berger wrote:
> Signed-off-by: Stefan Berger 
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Eric Blake 

> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f8deaf6..d352d16 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1593,6 +1593,7 @@ F: include/hw/acpi/tpm.h
>  F: include/sysemu/tpm*
>  F: qapi/tpm.json
>  F: backends/tpm.c
> +T: git git://github.com/stefanberger/qemu-tpm.git tpm-next
>  
>  Checkpatch
>  S: Odd Fixes
> 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [RFC] kvm: x86: export vCPU halted state to sysfs

2018-02-02 Thread Eric Blake
On 02/02/2018 08:50 AM, Eduardo Habkost wrote:
> (CCing qemu-devel)
> 
> On Fri, Feb 02, 2018 at 09:21:59AM -0500, Luiz Capitulino wrote:
>> On Fri, 2 Feb 2018 14:19:38 +
>> Daniel P. Berrangé  wrote:
>>> On Fri, Feb 02, 2018 at 12:15:54PM -0200, Eduardo Habkost wrote:
> [...]
 It would be also interesting to update QEMU QMP documentation to
 clarify the arch-specific semantics of "halted".  
>>>
>>> Any also especially clarify the awful performance implications of running
>>> this particular query command. In general I would not expect query-xxx
>>> monitor commands to interrupt all vcpus, so we should clearly warn about
>>> this !
>>
>> Or deprecate it...
> 
> We could deprecate the expensive fields on query-cpus, and move
> them to a more expensive query-cpu-state command.  I believe most
> users of query-cpus are only interested in qom_path, thread_id,
> and topology info.
> 
> Markus, Eric: from the QAPI point of view, is it OK to remove
> fields between QEMU versions, as long as we follow our
> deprecation policy?

Removing an output field outright may break a client that depended on
the field; so a deprecation period is definitely required there.  But it
is okay, documentation-wise, to state that a field is output always as 0
for back-compatibility reasons and that modern clients should ignore it
(which would then let old clients still parse the field, but no longer
see a non-zero value), whether or not we also pursue the deprecation
course and eventually remove the field after more releases.

See CpuInfo::current, for an example.

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH RFC 06/21] qapi-gen: New common driver for code and doc generators

2018-02-02 Thread Markus Armbruster
Whenever qapi-schema.json changes, we run six programs eleven times to
update eleven files.  This is silly.  Replace the six programs by a
single program that spits out all eleven files.

Signed-off-by: Markus Armbruster 
---
 Makefile   | 86 ++
 scripts/qapi-gen.py| 41 +++
 scripts/qapi/__init__.py   |  0
 scripts/{qapi-commands.py => qapi/commands.py} | 23 ++
 scripts/{qapi.py => qapi/common.py}|  0
 scripts/{qapi2texi.py => qapi/doc.py}  | 29 ++--
 scripts/{qapi-event.py => qapi/events.py}  | 23 ++
 scripts/{qapi-introspect.py => qapi/introspect.py} | 32 ++--
 scripts/{qapi-types.py => qapi/types.py}   | 34 ++---
 scripts/{qapi-visit.py => qapi/visit.py}   | 34 ++---
 tests/Makefile.include | 56 +++---
 tests/qapi-schema/test-qapi.py |  2 +-
 12 files changed, 140 insertions(+), 220 deletions(-)
 create mode 100755 scripts/qapi-gen.py
 create mode 100644 scripts/qapi/__init__.py
 rename scripts/{qapi-commands.py => qapi/commands.py} (94%)
 rename scripts/{qapi.py => qapi/common.py} (100%)
 rename scripts/{qapi2texi.py => qapi/doc.py} (92%)
 mode change 100755 => 100644
 rename scripts/{qapi-event.py => qapi/events.py} (92%)
 rename scripts/{qapi-introspect.py => qapi/introspect.py} (90%)
 rename scripts/{qapi-types.py => qapi/types.py} (90%)
 rename scripts/{qapi-visit.py => qapi/visit.py} (92%)

diff --git a/Makefile b/Makefile
index af31e8981f..e02f0c13ef 100644
--- a/Makefile
+++ b/Makefile
@@ -92,6 +92,7 @@ GENERATED_FILES += qmp-commands.h qapi-types.h qapi-visit.h 
qapi-event.h
 GENERATED_FILES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
 GENERATED_FILES += qmp-introspect.h
 GENERATED_FILES += qmp-introspect.c
+GENERATED_FILES += qapi.texi
 
 GENERATED_FILES += trace/generated-tcg-tracers.h
 
@@ -477,25 +478,26 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
 qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
 qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
 
-gen-out-type = $(subst .,-,$(suffix $@))
+qapi-py = $(SRC_PATH)/scripts/qapi/commands.py \
+$(SRC_PATH)/scripts/qapi/events.py \
+$(SRC_PATH)/scripts/qapi/introspect.py \
+$(SRC_PATH)/scripts/qapi/types.py \
+$(SRC_PATH)/scripts/qapi/visit.py \
+$(SRC_PATH)/scripts/qapi/common.py \
+$(SRC_PATH)/scripts/qapi/doc.py \
+$(SRC_PATH)/scripts/ordereddict.py \
+$(SRC_PATH)/scripts/qapi-gen.py
 
-qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.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)
-   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
-   $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
-   "GEN","$@")
-qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
-$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
-   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
-   $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
-   "GEN","$@")
-qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
-$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py 
$(qapi-py)
-   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
-   $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
-   "GEN","$@")
+qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
+qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
+qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c \
+qga/qapi-generated/qga-qapi.texi: \
+qga/qapi-generated/qapi-gen-timestamp ;
+qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json 
$(qapi-py)
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
+   -o qga/qapi-generated -p "qga-" $<, \
+   "GEN","$(@:%-timestamp=%)")
+   @>$@
 
 qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
$(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
@@ -512,31 +514,18 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json 
$(SRC_PATH)/qapi/common.json \
$(SRC_PATH)/qapi/transaction.json \
$(SRC_PATH)/qapi/ui.json
 
-qapi-types.c qapi-types.h :\
-$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
-   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
-   $(gen-out-type) -o "." -b $<, \
-   "GEN","$@")
-qapi-visit.c qapi-visit.h :\
-$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
-   $(call quiet-command,$(PYTHON) 

[Qemu-devel] [PATCH RFC 02/21] qapi: Generate up-to-date copyright notice

2018-02-02 Thread Markus Armbruster
Each generator carries a copyright notice for the generator itself,
and another one for the files it generates.  Only the former have been
updated along the way, the latter have not, and are all out of date.

Fix by copying the generator's copyright notice to the generated files
instead.

Signed-off-by: Markus Armbruster 
---
 scripts/qapi-commands.py   | 34 +++---
 scripts/qapi-event.py  | 32 ++--
 scripts/qapi-introspect.py | 25 -
 scripts/qapi-types.py  | 32 ++--
 scripts/qapi-visit.py  | 34 +++---
 scripts/qapi.py|  7 +--
 6 files changed, 75 insertions(+), 89 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 25ac52503a..a861ac52e7 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -1,16 +1,17 @@
-#
-# QAPI command marshaller generator
-#
-# Copyright IBM, Corp. 2011
-# Copyright (C) 2014-2016 Red Hat, Inc.
-#
-# Authors:
-#  Anthony Liguori 
-#  Michael Roth
-#  Markus Armbruster 
-#
-# This work is licensed under the terms of the GNU GPL, version 2.
-# See the COPYING file in the top-level directory.
+"""
+QAPI command marshaller generator
+
+Copyright IBM, Corp. 2011
+Copyright (C) 2014-2018 Red Hat, Inc.
+
+Authors:
+ Anthony Liguori 
+ Michael Roth 
+ Markus Armbruster 
+
+This work is licensed under the terms of the GNU GPL, version 2.
+See the COPYING file in the top-level directory.
+"""
 
 from qapi import *
 
@@ -257,16 +258,11 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
 
 blurb = '''
  * Schema-defined QAPI/QMP commands
- *
- * Copyright IBM, Corp. 2011
- *
- * Authors:
- *  Anthony Liguori   
 '''
 
 (fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
 'qmp-marshal.c', 'qmp-commands.h',
-blurb)
+blurb, __doc__)
 
 fdef.write(mcgen('''
 
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 31faedc689..b1d611c5ea 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -1,15 +1,16 @@
-#
-# QAPI event generator
-#
-# Copyright (c) 2014 Wenchao Xia
-# Copyright (c) 2015-2016 Red Hat Inc.
-#
-# Authors:
-#  Wenchao Xia 
-#  Markus Armbruster 
-#
-# This work is licensed under the terms of the GNU GPL, version 2.
-# See the COPYING file in the top-level directory.
+"""
+QAPI event generator
+
+Copyright (c) 2014 Wenchao Xia
+Copyright (c) 2015-2018 Red Hat Inc.
+
+Authors:
+ Wenchao Xia 
+ Markus Armbruster 
+
+This work is licensed under the terms of the GNU GPL, version 2.
+See the COPYING file in the top-level directory.
+"""
 
 from qapi import *
 
@@ -173,16 +174,11 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
 
 blurb = '''
  * Schema-defined QAPI/QMP events
- *
- * Copyright (c) 2014 Wenchao Xia
- *
- * Authors:
- *  Wenchao Xia   
 '''
 
 (fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
 'qapi-event.c', 'qapi-event.h',
-blurb)
+blurb, __doc__)
 
 fdef.write(mcgen('''
 #include "qemu/osdep.h"
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 83da2bdb94..bd9253a172 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -1,13 +1,14 @@
-#
-# QAPI introspection generator
-#
-# Copyright (C) 2015-2016 Red Hat, Inc.
-#
-# Authors:
-#  Markus Armbruster 
-#
-# This work is licensed under the terms of the GNU GPL, version 2.
-# See the COPYING file in the top-level directory.
+"""
+QAPI introspection generator
+
+Copyright (C) 2015-2018 Red Hat, Inc.
+
+Authors:
+ Markus Armbruster 
+
+This work is licensed under the terms of the GNU GPL, version 2.
+See the COPYING file in the top-level directory.
+"""
 
 from qapi import *
 
@@ -178,13 +179,11 @@ for o, a in opts:
 
 blurb = '''
  * QAPI/QMP schema introspection
- *
- * Copyright (C) 2015 Red Hat, Inc.
 '''
 
 (fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
 'qmp-introspect.c', 'qmp-introspect.h',
-blurb)
+blurb, __doc__)
 
 fdef.write(mcgen('''
 #include "qemu/osdep.h"
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 86afc57f92..1103dbda2d 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -1,15 +1,17 @@
-#
-# QAPI types generator
-#
-# Copyright IBM, Corp. 2011
-# Copyright (c) 2013-2016 Red Hat Inc.
-#
-# Authors:
-#  Anthony Liguori 
-#  Markus Armbruster 
-#
-# This work 

[Qemu-devel] [PATCH RFC 07/21] qapi: Move parse_command_line() next to its only use

2018-02-02 Thread Markus Armbruster
Signed-off-by: Markus Armbruster 
---
 scripts/qapi-gen.py| 52 +++-
 scripts/qapi/common.py | 54 --
 2 files changed, 51 insertions(+), 55 deletions(-)

diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py
index 575c938a1b..6302fd0d55 100755
--- a/scripts/qapi-gen.py
+++ b/scripts/qapi-gen.py
@@ -4,8 +4,10 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+import getopt
+import re
 import sys
-from qapi.common import parse_command_line, QAPISchema
+from qapi.common import QAPISchema
 from qapi.types import gen_types
 from qapi.visit import gen_visit
 from qapi.commands import gen_commands
@@ -14,6 +16,54 @@ from qapi.introspect import gen_introspect
 from qapi.doc import gen_doc
 
 
+def parse_command_line(extra_options='', extra_long_options=[]):
+
+try:
+opts, args = getopt.gnu_getopt(sys.argv[1:],
+   'chp:o:' + extra_options,
+   ['source', 'header', 'prefix=',
+'output-dir='] + extra_long_options)
+except getopt.GetoptError as err:
+print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err))
+sys.exit(1)
+
+output_dir = ''
+prefix = ''
+do_c = False
+do_h = False
+extra_opts = []
+
+for oa in opts:
+o, a = oa
+if o in ('-p', '--prefix'):
+match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
+if match.end() != len(a):
+print >>sys.stderr, \
+"%s: 'funny character '%s' in argument of --prefix" \
+% (sys.argv[0], a[match.end()])
+sys.exit(1)
+prefix = a
+elif o in ('-o', '--output-dir'):
+output_dir = a + '/'
+elif o in ('-c', '--source'):
+do_c = True
+elif o in ('-h', '--header'):
+do_h = True
+else:
+extra_opts.append(oa)
+
+if not do_c and not do_h:
+do_c = True
+do_h = True
+
+if len(args) != 1:
+print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0]
+sys.exit(1)
+fname = args[0]
+
+return (fname, output_dir, do_c, do_h, prefix, extra_opts)
+
+
 def main(argv):
 (input_file, output_dir, do_c, do_h, prefix, opts) = \
 parse_command_line('bu', ['builtins', 'unmask-non-abi-names'])
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index d73ef618e2..cfa2671ca3 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -12,7 +12,6 @@
 # See the COPYING file in the top-level directory.
 
 import errno
-import getopt
 import os
 import re
 import string
@@ -1917,59 +1916,6 @@ def build_params(arg_type, boxed, extra):
 
 
 #
-# Common command line parsing
-#
-
-
-def parse_command_line(extra_options='', extra_long_options=[]):
-
-try:
-opts, args = getopt.gnu_getopt(sys.argv[1:],
-   'chp:o:' + extra_options,
-   ['source', 'header', 'prefix=',
-'output-dir='] + extra_long_options)
-except getopt.GetoptError as err:
-print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err))
-sys.exit(1)
-
-output_dir = ''
-prefix = ''
-do_c = False
-do_h = False
-extra_opts = []
-
-for oa in opts:
-o, a = oa
-if o in ('-p', '--prefix'):
-match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
-if match.end() != len(a):
-print >>sys.stderr, \
-"%s: 'funny character '%s' in argument of --prefix" \
-% (sys.argv[0], a[match.end()])
-sys.exit(1)
-prefix = a
-elif o in ('-o', '--output-dir'):
-output_dir = a + '/'
-elif o in ('-c', '--source'):
-do_c = True
-elif o in ('-h', '--header'):
-do_h = True
-else:
-extra_opts.append(oa)
-
-if not do_c and not do_h:
-do_c = True
-do_h = True
-
-if len(args) != 1:
-print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0]
-sys.exit(1)
-fname = args[0]
-
-return (fname, output_dir, do_c, do_h, prefix, extra_opts)
-
-
-#
 # Accumulate and write output
 #
 
-- 
2.13.6




Re: [Qemu-devel] [PATCH RFC 03/21] qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> These classes encapsulate accumulating and writing output.
> 
> Convert C code generation to QAPIGenC and QAPIGenH.  The conversion is
> rather shallow: most of the output accumulation is not converted.
> Left for later.
> 
> The indentation machinery uses a single global variable indent_level,
> even though we generally interleave creation of a .c and its .h.  It
> should become instance variable of QAPIGenC.  Also left for later.
> 
> Documentation generation isn't converted, and QAPIGenDoc isn't used.
> This will change shortly.
> 
> Signed-off-by: Markus Armbruster 
> ---
>  scripts/qapi-commands.py   | 27 ++---
>  scripts/qapi-event.py  | 26 +++--
>  scripts/qapi-introspect.py | 22 ++-
>  scripts/qapi-types.py  | 26 +++--
>  scripts/qapi-visit.py  | 26 +++--
>  scripts/qapi.py| 96 
> ++
>  6 files changed, 122 insertions(+), 101 deletions(-)
> 

A little bit longer due to more structure, but reasonable diffstat in
that it shows the conversion is fairly straightforward and opens the
doors for later patches to use the new structures more effectively.

>  
>  schema = QAPISchema(input_file)
> -gen = QAPISchemaGenEventVisitor()
> -schema.visit(gen)
> -fdef.write(gen.defn)
> -fdecl.write(gen.decl)
> +vis = QAPISchemaGenEventVisitor()
> +schema.visit(vis)
> +genc.body(vis.defn)
> +genh.body(vis.decl)

I don't know if it is worth a sentence in the commit message that the
visitor variable is renamed from 'gen' to 'vis' for less confusion with
the new class instances 'genc' and 'genh'.

> +++ b/scripts/qapi-types.py
> @@ -180,7 +180,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>  self.decl = ''
>  self.defn = ''
>  self._fwdecl = ''
> -self._btin = guardstart('QAPI_TYPES_BUILTIN')
> +self._btin = '\n' + guardstart('QAPI_TYPES_BUILTIN')

Tweaks like this means you were paying attention to still producing
identical generated files; always a good sign.

Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH RFC 02/21] qapi: Generate up-to-date copyright notice

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> Each generator carries a copyright notice for the generator itself,
> and another one for the files it generates.  Only the former have been
> updated along the way, the latter have not, and are all out of date.
> 
> Fix by copying the generator's copyright notice to the generated files
> instead.
> 
> Signed-off-by: Markus Armbruster 
> ---

> +++ b/scripts/qapi-commands.py
> @@ -1,16 +1,17 @@
> -#
> -# QAPI command marshaller generator
> -#
> -# Copyright IBM, Corp. 2011
> -# Copyright (C) 2014-2016 Red Hat, Inc.
> -#
> -# Authors:
> -#  Anthony Liguori 
> -#  Michael Roth
> -#  Markus Armbruster 
> -#
> -# This work is licensed under the terms of the GNU GPL, version 2.
> -# See the COPYING file in the top-level directory.
> +"""
> +QAPI command marshaller generator
> +
> +Copyright IBM, Corp. 2011
> +Copyright (C) 2014-2018 Red Hat, Inc.
> +
> +Authors:
> + Anthony Liguori 
> + Michael Roth 
> + Markus Armbruster 
> +
> +This work is licensed under the terms of the GNU GPL, version 2.
> +See the COPYING file in the top-level directory.
> +"""

So python lets you start a file with a string constant that is not
associated with any variable name?

>  
>  (fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
>  'qmp-marshal.c', 'qmp-commands.h',
> -blurb)
> +blurb, __doc__)

Ah, and there's what I was missing - python auto-assigns such an initial
string to a magic automatic variable.  Cool language feature I hadn't
seen before!

Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH RFC 04/21] qapi: Reduce use of global variables in generators some

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> In preparation of the next commit, which will turn the generators into
> modules.  These global variables will become local to main() then.
> 
> Signed-off-by: Markus Armbruster 
> ---
Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PULL v2 01/10] 9pfs: drop v9fs_register_transport()

2018-02-02 Thread Greg Kurz
No good reasons to do this outside of v9fs_device_realize_common().

Signed-off-by: Greg Kurz 
Reviewed-by: Stefano Stabellini 
---
 hw/9pfs/9p.c   |  6 +-
 hw/9pfs/9p.h   | 10 ++
 hw/9pfs/virtio-9p-device.c |  8 ++--
 hw/9pfs/xen-9p-backend.c   |  3 +--
 4 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 909a61139405..364c7cb44628 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -3485,7 +3485,8 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr)
 }
 
 /* Returns 0 on success, 1 on failure. */
-int v9fs_device_realize_common(V9fsState *s, Error **errp)
+int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
+   Error **errp)
 {
 int i, len;
 struct stat stat;
@@ -3493,6 +3494,9 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)
 V9fsPath path;
 int rc = 1;
 
+assert(!s->transport);
+s->transport = t;
+
 /* initialize pdu allocator */
 QLIST_INIT(>free_list);
 QLIST_INIT(>active_list);
diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
index ffe658ab8975..5ced427d861b 100644
--- a/hw/9pfs/9p.h
+++ b/hw/9pfs/9p.h
@@ -346,7 +346,8 @@ void v9fs_path_sprintf(V9fsPath *path, const char *fmt, 
...);
 void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs);
 int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
   const char *name, V9fsPath *path);
-int v9fs_device_realize_common(V9fsState *s, Error **errp);
+int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
+   Error **errp);
 void v9fs_device_unrealize_common(V9fsState *s, Error **errp);
 
 V9fsPDU *pdu_alloc(V9fsState *s);
@@ -366,11 +367,4 @@ struct V9fsTransport {
 void(*push_and_notify)(V9fsPDU *pdu);
 };
 
-static inline int v9fs_register_transport(V9fsState *s, const V9fsTransport *t)
-{
-assert(!s->transport);
-s->transport = t;
-return 0;
-}
-
 #endif
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 43f4e53f336f..775e8ff76671 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -198,17 +198,13 @@ static void virtio_9p_device_realize(DeviceState *dev, 
Error **errp)
 V9fsVirtioState *v = VIRTIO_9P(dev);
 V9fsState *s = >state;
 
-if (v9fs_device_realize_common(s, errp)) {
-goto out;
+if (v9fs_device_realize_common(s, _9p_transport, errp)) {
+return;
 }
 
 v->config_size = sizeof(struct virtio_9p_config) + strlen(s->fsconf.tag);
 virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size);
 v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
-v9fs_register_transport(s, _9p_transport);
-
-out:
-return;
 }
 
 static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp)
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index df2a4100bf55..14f0d6a50e75 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -446,7 +446,6 @@ static int xen_9pfs_connect(struct XenDevice *xendev)
 xen_9pdev->id = s->fsconf.fsdev_id =
 g_strdup_printf("xen9p%d", xendev->dev);
 xen_9pdev->tag = s->fsconf.tag = xenstore_read_fe_str(xendev, "tag");
-v9fs_register_transport(s, _9p_transport);
 fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
 s->fsconf.tag,
 1, NULL);
@@ -455,7 +454,7 @@ static int xen_9pfs_connect(struct XenDevice *xendev)
 qemu_opt_set(fsdev, "security_model", xen_9pdev->security_model, NULL);
 qemu_opts_set_id(fsdev, s->fsconf.fsdev_id);
 qemu_fsdev_add(fsdev);
-v9fs_device_realize_common(s, NULL);
+v9fs_device_realize_common(s, _9p_transport, NULL);
 
 return 0;
 
-- 
2.13.6




Re: [Qemu-devel] [PATCH v5 1/6] machine: Convert the valid cpu types to use cpu_model

2018-02-02 Thread Eduardo Habkost
On Thu, Feb 01, 2018 at 04:42:05PM -0800, Alistair Francis wrote:
> As cpu_type is not a user visible string let's convert the
> valid_cpu_types to compare against cpu_model instead. This way we have a
> user friendly string to report back.
> 
> Once we have a cpu_type to cpu_model conversion this patch should be
> reverted and we should use cpu_type instead.
> 
> Signed-off-by: Alistair Francis 
> ---
> 
>  hw/core/machine.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index cdc1163dc6..de5bac1c84 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -776,13 +776,12 @@ void machine_run_board_init(MachineState *machine)
>  /* If the machine supports the valid_cpu_types check and the user
>   * specified a CPU with -cpu check here that the user CPU is supported.
>   */
> -if (machine_class->valid_cpu_types && machine->cpu_type) {
> -ObjectClass *class = object_class_by_name(machine->cpu_type);
> +if (machine_class->valid_cpu_types && machine->cpu_model) {
>  int i;
>  
>  for (i = 0; machine_class->valid_cpu_types[i]; i++) {
> -if (object_class_dynamic_cast(class,
> -  
> machine_class->valid_cpu_types[i])) {
> +if (!strcmp(machine->cpu_model,
> +machine_class->valid_cpu_types[i])) {

I would rename valid_cpu_types to valid_cpu_models to make the
new semantics clearer.

Anyway, I have bad and good news:

The bad news is Igor already sent patches last week that remove
MachineState::cpu_model, so this conflicts with his series.  Now
parse_cpu_model() will be the only place where the original CPU model name is
available, but the function needs to work on *-user too.  See:
"[PATCH v3 23/25] Use cpu_create(type) instead of cpu_init(cpu_model)".

The good news is that I think we can fix this very easily if
validation is done at the same place where parse_cpu_model() is
called.  e.g.:

current_machine->cpu_type = machine_class->default_cpu_type;
if (cpu_model) {
current_machine->cpu_type = parse_cpu_model(cpu_model);

if (machine_class->valid_cpu_models) {
ObjectClass *class = object_class_by_name(machine->cpu_type);
int i;

for (i = 0; machine_class->valid_cpu_models[i]; i++) {
const char *valid_model = machine_class->valid_cpu_models[i];
ObjectClass *valid_class = cpu_class_by_name(machine->cpu_type, 
valid_model);
if (object_class_dynamic_cast(class,
  
object_class_get_name(valid_class))) {
 /* Valid CPU type, we're good to go */
 break;
}
}
if (!machine_class->valid_cpu_models[i]) {
error_report("Invalid CPU model: %s", cpu_model);
error_printf("The valid CPU models are: %s",
 machine_class->valid_cpu_models[0]);
for (i = 1; machine_class->valid_cpu_models[i]; i++) {
error_printf(", %s", machine_class->valid_cpu_models[i]);
}
error_printf("\n");
exit(1);
}
}
}

This can be done inside main(), or moved inside
machine_run_board_init() if main() pass cpu_model as argument to
the function.

On either case, I think it's a good idea to do validation and
printing of error messages closer to the code that parses the
command-line options.  This way we separate parsing/validation
from initialization.

>  /* The user specificed CPU is in the valid field, we are
>   * good to go.
>   */
> @@ -792,8 +791,8 @@ void machine_run_board_init(MachineState *machine)
>  
>  if (!machine_class->valid_cpu_types[i]) {
>  /* The user specified CPU is not valid */
> -error_report("Invalid CPU type: %s", machine->cpu_type);
> -error_printf("The valid types are: %s",
> +error_report("Invalid CPU model: %s", machine->cpu_model);
> +error_printf("The valid models are: %s",
>   machine_class->valid_cpu_types[0]);
>  for (i = 1; machine_class->valid_cpu_types[i]; i++) {
>  error_printf(", %s", machine_class->valid_cpu_types[i]);
> -- 
> 2.14.1
> 
> 

-- 
Eduardo



[Qemu-devel] [PULL v2 05/10] tests: virtio-9p: use the synth backend

2018-02-02 Thread Greg Kurz
The purpose of virtio-9p-test is to test the virtio-9p device, especially
the 9p server state machine. We don't really care what fsdev backend we're
using. Moreover, if we want to be able to test the flush request or a
device reset with in-flights I/O, it is close to impossible to achieve
with a physical backend because we cannot ask it reliably to put an I/O
on hold at a specific point in time.

Fortunately, we can do that with the synthetic backend, which allows to
register callbacks on read/write accesses to a specific file. This will
be used by a later patch to test the 9P flush request.

The walk request test is converted to using the synth backend.

Signed-off-by: Greg Kurz 
Reviewed-by: Stefan Hajnoczi 
---
 hw/9pfs/9p-synth.c | 16 
 hw/9pfs/9p-synth.h |  4 
 tests/virtio-9p-test.c | 22 ++
 3 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index 8f255e91c00f..dcbd320da17a 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -19,6 +19,7 @@
 #include "qemu/rcu.h"
 #include "qemu/rcu_queue.h"
 #include "qemu/cutils.h"
+#include "sysemu/qtest.h"
 
 /* Root node for synth file system */
 static V9fsSynthNode synth_root = {
@@ -527,6 +528,21 @@ static int synth_init(FsContext *ctx, Error **errp)
 
 /* Mark the subsystem is ready for use */
 synth_fs = 1;
+
+if (qtest_enabled()) {
+V9fsSynthNode *node = NULL;
+int i, ret;
+
+/* Directory hierarchy for WALK test */
+for (i = 0; i < P9_MAXWELEM; i++) {
+char *name = g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i);
+
+ret = qemu_v9fs_synth_mkdir(node, 0700, name, );
+assert(!ret);
+g_free(name);
+}
+}
+
 return 0;
 }
 
diff --git a/hw/9pfs/9p-synth.h b/hw/9pfs/9p-synth.h
index 49c2fc7b274e..876b4ef58288 100644
--- a/hw/9pfs/9p-synth.h
+++ b/hw/9pfs/9p-synth.h
@@ -49,4 +49,8 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
  const char *name, v9fs_synth_read read,
  v9fs_synth_write write, void *arg);
 
+/* qtest stuff */
+
+#define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d"
+
 #endif
diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index cb086315a36e..652198156731 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -17,6 +17,7 @@
 #include "standard-headers/linux/virtio_ids.h"
 #include "standard-headers/linux/virtio_pci.h"
 #include "hw/9pfs/9p.h"
+#include "hw/9pfs/9p-synth.h"
 
 #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000)
 
@@ -26,23 +27,19 @@ typedef struct {
 QVirtioDevice *dev;
 QOSState *qs;
 QVirtQueue *vq;
-char *test_share;
 } QVirtIO9P;
 
 static QVirtIO9P *qvirtio_9p_start(const char *driver)
 {
 const char *arch = qtest_get_arch();
-const char *cmd = "-fsdev local,id=fsdev0,security_model=none,path=%s "
+const char *cmd = "-fsdev synth,id=fsdev0 "
   "-device %s,fsdev=fsdev0,mount_tag=%s";
 QVirtIO9P *v9p = g_new0(QVirtIO9P, 1);
 
-v9p->test_share = g_strdup("/tmp/qtest.XX");
-g_assert_nonnull(mkdtemp(v9p->test_share));
-
 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-v9p->qs = qtest_pc_boot(cmd, v9p->test_share, driver, mount_tag);
+v9p->qs = qtest_pc_boot(cmd, driver, mount_tag);
 } else if (strcmp(arch, "ppc64") == 0) {
-v9p->qs = qtest_spapr_boot(cmd, v9p->test_share, driver, mount_tag);
+v9p->qs = qtest_spapr_boot(cmd, driver, mount_tag);
 } else {
 g_printerr("virtio-9p tests are only available on x86 or ppc64\n");
 exit(EXIT_FAILURE);
@@ -54,8 +51,6 @@ static QVirtIO9P *qvirtio_9p_start(const char *driver)
 static void qvirtio_9p_stop(QVirtIO9P *v9p)
 {
 qtest_shutdown(v9p->qs);
-rmdir(v9p->test_share);
-g_free(v9p->test_share);
 g_free(v9p);
 }
 
@@ -422,17 +417,14 @@ static void fs_attach(QVirtIO9P *v9p)
 
 static void fs_walk(QVirtIO9P *v9p)
 {
-char *wnames[P9_MAXWELEM], *paths[P9_MAXWELEM];
-char *last_path = v9p->test_share;
+char *wnames[P9_MAXWELEM];
 uint16_t nwqid;
 v9fs_qid *wqid;
 int i;
 P9Req *req;
 
 for (i = 0; i < P9_MAXWELEM; i++) {
-wnames[i] = g_strdup_printf("%s%d", __func__, i);
-last_path = paths[i] = g_strdup_printf("%s/%s", last_path, wnames[i]);
-g_assert(!mkdir(paths[i], 0700));
+wnames[i] = g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i);
 }
 
 fs_attach(v9p);
@@ -443,8 +435,6 @@ static void fs_walk(QVirtIO9P *v9p)
 g_assert_cmpint(nwqid, ==, P9_MAXWELEM);
 
 for (i = 0; i < P9_MAXWELEM; i++) {
-rmdir(paths[P9_MAXWELEM - i - 1]);
-g_free(paths[P9_MAXWELEM - i - 1]);
 g_free(wnames[i]);
 }
 
-- 
2.13.6




Re: [Qemu-devel] [PATCH v4 0/5] coroutine-lock: polymorphic CoQueue

2018-02-02 Thread Fam Zheng
On Fri, Feb 2, 2018 at 6:01 AM,   wrote:
> === OUTPUT BEGIN ===
> Checking PATCH 1/5: test-coroutine: add simple CoMutex test...
> ERROR: do not initialise statics to 0 or NULL
> #30: FILE: tests/test-coroutine.c:198:
> +static bool locked = false;
>
> total: 1 errors, 0 warnings, 74 lines checked

I think we should fix this one too. Otherwise,

Reviewed-by: Fam Zheng 


>
> Your patch has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
>
> Checking PATCH 2/5: lockable: add QemuLockable...
> WARNING: line over 80 characters
> #58: FILE: include/qemu/compiler.h:144:
> +#define QEMU_GENERIC2(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC1(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #59: FILE: include/qemu/compiler.h:145:
> +#define QEMU_GENERIC3(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC2(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #60: FILE: include/qemu/compiler.h:146:
> +#define QEMU_GENERIC4(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC3(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #61: FILE: include/qemu/compiler.h:147:
> +#define QEMU_GENERIC5(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC4(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #62: FILE: include/qemu/compiler.h:148:
> +#define QEMU_GENERIC6(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC5(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #63: FILE: include/qemu/compiler.h:149:
> +#define QEMU_GENERIC7(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC6(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #64: FILE: include/qemu/compiler.h:150:
> +#define QEMU_GENERIC8(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC7(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #65: FILE: include/qemu/compiler.h:151:
> +#define QEMU_GENERIC9(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC8(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #66: FILE: include/qemu/compiler.h:152:
> +#define QEMU_GENERIC10(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC9(x, 
> __VA_ARGS__))
>
> WARNING: line over 80 characters
> #124: FILE: include/qemu/lockable.h:28:
> + * to QEMU_MAKE_LOCKABLE.  For optimized builds, we can rely on dead-code 
> elimination
>
> WARNING: architecture specific defines should be avoided
> #127: FILE: include/qemu/lockable.h:31:
> +#ifdef __OPTIMIZE__
>
> total: 0 errors, 11 warnings, 242 lines checked
>
> Your patch has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> Checking PATCH 3/5: coroutine-lock: convert CoQueue to use QemuLockable...
> Checking PATCH 4/5: coroutine-lock: make qemu_co_enter_next thread-safe...
> Checking PATCH 5/5: curl: convert to CoQueue...
> === OUTPUT END ===
>
> Test command exited with code: 1
>
>
> ---
> Email generated automatically by Patchew [http://patchew.org/].
> Please send your feedback to patchew-de...@freelists.org



Re: [Qemu-devel] [PATCH v3 17/39] qcow2: Update l2_allocate() to support L2 slices

2018-02-02 Thread Alberto Garcia
On Thu 01 Feb 2018 07:22:16 PM CET, Max Reitz wrote:
> On 2018-02-01 16:43, Alberto Garcia wrote:
>> On Thu 01 Feb 2018 04:23:09 PM CET, Anton Nefedov wrote:
> However, I'm wondering whether this is the best approach.  The old
> L2 table is probably not going to be used after this function, so
> we're basically polluting the cache here.  That was bad enough so
> far, but now that actually means wasting multiple cache entries on
> it.
>
> Sure, the code is simpler this way.  But maybe it would still be
> better to manually copy the data over from the old offset...  (As
> long as it's not much more complicated.)

 You mean bypassing the cache altogether?

  qcow2_cache_flush(bs, s->l2_table_cache);
  new_table = g_malloc(s->cluster_size);
  if (old_l2_offset & L1E_OFFSET_MASK) {
  bdrv_pread(bs->file, old_l2_offset, new_table, s->cluster_size);
  } else {
  memset(new_table, 0, s->cluster_size);
  }
  bdrv_pwrite(bs->file, new_l2_offset, new_table, s->cluster_size);
  g_free(new_table);

 ??
>>>
>>> (I know it's a draft so you probably just skipped that but just in
>>> case) It seems ok to bypass the cache read - perhaps even a flush is
>>> not necessary: old_l2_offset must be read-only and flushed at this
>>> point; I believe new_l2_offset might be cached too, so it needs to be
>>> updated.
>> 
>> One problem I see with this is that while we wouldn't pollute the cache
>> we'd always be reading the table twice from disk in all cases:
>> 
>>  1) Read old table
>>  2) Write new table
>>  3) Read new table (after l2_allocate(), using the cache this time)
>> 
>> We can of course improve it by reading the old table from disk but
>> directly in the cache -so we'd spare step (3)-, but we'd still have to
>> read at least once from disk.
>> 
>> With the old code (especially if slice_size == cluster_size) we don't
>> need to read anything if the L2 table is already cached:
>> 
>>  1) Get empty table from the cache
>>  2) memcpy() the old data
>>  3) Get new table from the cache (after l2_allocate()).
>
> Well, then scratch the bdrv_pwrite() for the new table and keep using
> the cache for that (because that actually sounds useful).
>
> On second thought, though, it's rather probable the old L2 table is
> already in the cache...  Before the guest does a write to a location,
> it is reasonable to assume it has read from there before.
>
> So I guess we could think about adding a parameter to qcow2_cache_put()
> or something to reset the LRU counter because we probably won't need
> that entry anymore.  But not something for this series, of course.

That actually doesn't sound like a bad idea, there are maybe more cases
in which we know we're unlikely to need a cache entry soon, but as you
say let's take a look at it after this series.

Berto



[Qemu-devel] [PATCH RFC 04/21] qapi: Reduce use of global variables in generators some

2018-02-02 Thread Markus Armbruster
In preparation of the next commit, which will turn the generators into
modules.  These global variables will become local to main() then.

Signed-off-by: Markus Armbruster 
---
 scripts/qapi-commands.py   |  9 +
 scripts/qapi-event.py  | 15 +++
 scripts/qapi-introspect.py |  7 ---
 scripts/qapi-types.py  | 17 +
 scripts/qapi-visit.py  | 17 +
 5 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 4be7dbc482..d229537659 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -207,7 +207,7 @@ def gen_register_command(name, success_response):
 return ret
 
 
-def gen_registry(registry):
+def gen_registry(registry, prefix):
 ret = mcgen('''
 
 void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds)
@@ -224,7 +224,8 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds)
 
 
 class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
-def __init__(self):
+def __init__(self, prefix):
+self._prefix = prefix
 self.decl = None
 self.defn = None
 self._regy = None
@@ -237,7 +238,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
 self._visited_ret_types = set()
 
 def visit_end(self):
-self.defn += gen_registry(self._regy)
+self.defn += gen_registry(self._regy, self._prefix)
 self._regy = None
 self._visited_ret_types = None
 
@@ -289,7 +290,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
 prefix=prefix, c_prefix=c_name(prefix, protect=False)))
 
 schema = QAPISchema(input_file)
-vis = QAPISchemaGenCommandVisitor()
+vis = QAPISchemaGenCommandVisitor(prefix)
 schema.visit(vis)
 genc.body(vis.defn)
 genh.body(vis.decl)
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index da3de17c76..1af21b580a 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -58,7 +58,7 @@ def gen_param_var(typ):
 return ret
 
 
-def gen_event_send(name, arg_type, boxed):
+def gen_event_send(name, arg_type, boxed, event_enum_name):
 # FIXME: Our declaration of local variables (and of 'errp' in the
 # parameter list) can collide with exploded members of the event's
 # data type passed in as parameters.  If this collision ever hits in
@@ -149,7 +149,8 @@ out:
 
 
 class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
-def __init__(self):
+def __init__(self, prefix):
+self._enum_name = c_name(prefix + 'QAPIEvent', protect=False)
 self.decl = None
 self.defn = None
 self._event_names = None
@@ -160,13 +161,13 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
 self._event_names = []
 
 def visit_end(self):
-self.decl += gen_enum(event_enum_name, self._event_names)
-self.defn += gen_enum_lookup(event_enum_name, self._event_names)
+self.decl += gen_enum(self._enum_name, self._event_names)
+self.defn += gen_enum_lookup(self._enum_name, self._event_names)
 self._event_names = None
 
 def visit_event(self, name, info, arg_type, boxed):
 self.decl += gen_event_send_decl(name, arg_type, boxed)
-self.defn += gen_event_send(name, arg_type, boxed)
+self.defn += gen_event_send(name, arg_type, boxed, self._enum_name)
 self._event_names.append(name)
 
 
@@ -199,10 +200,8 @@ genh.body(mcgen('''
 ''',
 prefix=prefix))
 
-event_enum_name = c_name(prefix + 'QAPIEvent', protect=False)
-
 schema = QAPISchema(input_file)
-vis = QAPISchemaGenEventVisitor()
+vis = QAPISchemaGenEventVisitor(prefix)
 schema.visit(vis)
 genc.body(vis.defn)
 genh.body(vis.decl)
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index c654f8fa94..8d4e3c1c3a 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -41,7 +41,8 @@ def to_c_string(string):
 
 
 class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor):
-def __init__(self, unmask):
+def __init__(self, prefix, unmask):
+self._prefix = prefix
 self._unmask = unmask
 self.defn = None
 self.decl = None
@@ -65,7 +66,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor):
 # generate C
 # TODO can generate awfully long lines
 jsons.extend(self._jsons)
-name = c_name(prefix, protect=False) + 'qmp_schema_json'
+name = c_name(self._prefix, protect=False) + 'qmp_schema_json'
 self.decl = mcgen('''
 extern const char %(c_name)s[];
 ''',
@@ -192,7 +193,7 @@ genc.body(mcgen('''
 prefix=prefix))
 
 schema = QAPISchema(input_file)
-vis = QAPISchemaGenIntrospectVisitor(opt_unmask)
+vis = QAPISchemaGenIntrospectVisitor(prefix, opt_unmask)
 schema.visit(vis)
 genc.body(vis.defn)
 genh.body(vis.decl)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 97406b3368..2d711b137b 100644
--- a/scripts/qapi-types.py
+++ 

Re: [Qemu-devel] [PATCH] s390x/sclp: fix event mask handling

2018-02-02 Thread Claudio Imbrenda
On Fri,  2 Feb 2018 09:42:41 +
Christian Borntraeger  wrote:

> commit 67915de9f038 ("s390x/event-facility: variable-length event
> masks") switches the sclp receive/send mask. This broke the sclp
> lm console.

Reviewed-by: Claudio Imbrenda 
 
> Signed-off-by: Christian Borntraeger 
> Fixes: commit 67915de9f038 ("s390x/event-facility: variable-length
> event masks") Cc: Cornelia Huck 
> Cc: Jason J. Herne 
> Cc: qemu-sta...@nongnu.org
> ---
>  hw/s390x/event-facility.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index b0f71f4554..155a69467b 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -293,10 +293,10 @@ static void write_event_mask(SCLPEventFacility
> *ef, SCCB *sccb) ef->receive_mask = be32_to_cpu(tmp_mask);
> 
>  /* return the SCLP's capability masks to the guest */
> -tmp_mask = cpu_to_be32(get_host_send_mask(ef));
> +tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
>  copy_mask(WEM_RECEIVE_MASK(we_mask, mask_length), (uint8_t
> *)_mask, mask_length, sizeof(tmp_mask));
> -tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
> +tmp_mask = cpu_to_be32(get_host_send_mask(ef));
>  copy_mask(WEM_SEND_MASK(we_mask, mask_length), (uint8_t
> *)_mask, mask_length, sizeof(tmp_mask));
> 




[Qemu-devel] [PATCH RFC 19/21] qapi/types: Generate separate .h, .c for each module

2018-02-02 Thread Markus Armbruster
Our qapi-schema.json is composed of modules connected by include
directives, but the generated code is monolithic all the same: one
qapi-types.h with all the types, one qapi-visit.h with all the
visitors, and so forth.  These monolithic headers get included all
over the place.  In my "build everything" tree, adding a QAPI type
recompiles about 4500 out of 4800 objects.

Nobody would write such monolithic headers by hand.  It stands to
reason that one shouldn't generate them, either.

Split up generated qapi-types.h to mirror the schema's modular
structure: one header per module.  Name the main module's header
qapi-types.h, and sub-module D/B.json's header D/qapi-types-B.h.

Mirror the schema's includes in the headers, so that qapi-types.h gets
you everything exactly as before.  If you need less, you can include
one or more of the sub-module headers.  To be exploited shortly.

Split up qapi-types.c similarly.

Signed-off-by: Markus Armbruster 
---
 Makefile  | 30 ++
 Makefile.objs | 18 +-
 scripts/qapi/types.py | 18 --
 3 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index f9b7900330..f1b68dca9b 100644
--- a/Makefile
+++ b/Makefile
@@ -91,6 +91,21 @@ GENERATED_FILES = qemu-version.h config-host.h 
qemu-options.def
 GENERATED_FILES += qmp-commands.h qmp-marshal.c
 GENERATED_FILES += qapi-builtin-types.h qapi-builtin-types.c
 GENERATED_FILES += qapi-types.h qapi-types.c
+GENERATED_FILES += qapi/qapi-types-block-core.h qapi/qapi-types-block-core.c
+GENERATED_FILES += qapi/qapi-types-block.h qapi/qapi-types-block.c
+GENERATED_FILES += qapi/qapi-types-char.h qapi/qapi-types-char.c
+GENERATED_FILES += qapi/qapi-types-common.h qapi/qapi-types-common.c
+GENERATED_FILES += qapi/qapi-types-crypto.h qapi/qapi-types-crypto.c
+GENERATED_FILES += qapi/qapi-types-introspect.h qapi/qapi-types-introspect.c
+GENERATED_FILES += qapi/qapi-types-migration.h qapi/qapi-types-migration.c
+GENERATED_FILES += qapi/qapi-types-net.h qapi/qapi-types-net.c
+GENERATED_FILES += qapi/qapi-types-rocker.h qapi/qapi-types-rocker.c
+GENERATED_FILES += qapi/qapi-types-run-state.h qapi/qapi-types-run-state.c
+GENERATED_FILES += qapi/qapi-types-sockets.h qapi/qapi-types-sockets.c
+GENERATED_FILES += qapi/qapi-types-tpm.h qapi/qapi-types-tpm.c
+GENERATED_FILES += qapi/qapi-types-trace.h qapi/qapi-types-trace.c
+GENERATED_FILES += qapi/qapi-types-transaction.h qapi/qapi-types-transaction.c
+GENERATED_FILES += qapi/qapi-types-ui.h qapi/qapi-types-ui.c
 GENERATED_FILES += qapi-builtin-visit.h qapi-builtin-visit.c
 GENERATED_FILES += qapi-visit.h qapi-visit.c
 GENERATED_FILES += qapi-event.h qapi-event.c
@@ -519,6 +534,21 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json 
$(SRC_PATH)/qapi/common.json \
 
 qapi-builtin-types.c qapi-builtin-types.h \
 qapi-types.c qapi-types.h \
+qapi/qapi-types-block-core.c qapi/qapi-types-block-core.h \
+qapi/qapi-types-block.c qapi/qapi-types-block.h \
+qapi/qapi-types-char.c qapi/qapi-types-char.h \
+qapi/qapi-types-common.c qapi/qapi-types-common.h \
+qapi/qapi-types-crypto.c qapi/qapi-types-crypto.h \
+qapi/qapi-types-introspect.c qapi/qapi-types-introspect.h \
+qapi/qapi-types-migration.c qapi/qapi-types-migration.h \
+qapi/qapi-types-net.c qapi/qapi-types-net.h \
+qapi/qapi-types-rocker.c qapi/qapi-types-rocker.h \
+qapi/qapi-types-run-state.c qapi/qapi-types-run-state.h \
+qapi/qapi-types-sockets.c qapi/qapi-types-sockets.h \
+qapi/qapi-types-tpm.c qapi/qapi-types-tpm.h \
+qapi/qapi-types-trace.c qapi/qapi-types-trace.h \
+qapi/qapi-types-transaction.c qapi/qapi-types-transaction.h \
+qapi/qapi-types-ui.c qapi/qapi-types-ui.h \
 qapi-builtin-visit.c qapi-builtin-visit.h \
 qapi-visit.c qapi-visit.h \
 qmp-commands.h qmp-marshal.c \
diff --git a/Makefile.objs b/Makefile.objs
index f16cca06e7..e7411a2658 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -3,7 +3,23 @@
 stub-obj-y = stubs/ crypto/
 util-obj-y = util/ qobject/ qapi/
 util-obj-y += qapi-builtin-types.o qapi-builtin-visit.o
-util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
+util-obj-y += qapi-types.o
+util-obj-y += qapi/qapi-types-block-core.o
+util-obj-y += qapi/qapi-types-block.o
+util-obj-y += qapi/qapi-types-char.o
+util-obj-y += qapi/qapi-types-common.o
+util-obj-y += qapi/qapi-types-crypto.o
+util-obj-y += qapi/qapi-types-introspect.o
+util-obj-y += qapi/qapi-types-migration.o
+util-obj-y += qapi/qapi-types-net.o
+util-obj-y += qapi/qapi-types-rocker.o
+util-obj-y += qapi/qapi-types-run-state.o
+util-obj-y += qapi/qapi-types-sockets.o
+util-obj-y += qapi/qapi-types-tpm.o
+util-obj-y += qapi/qapi-types-trace.o
+util-obj-y += qapi/qapi-types-transaction.o
+util-obj-y += qapi/qapi-types-ui.o
+util-obj-y += qmp-introspect.o qapi-visit.o qapi-event.o
 
 chardev-obj-y = chardev/
 
diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py
index f84ed17960..7bd8e1a978 100644
--- 

Re: [Qemu-devel] [PATCH v3 05/12] sdl: use DisplayOptions

2018-02-02 Thread Eric Blake
On 02/02/2018 05:10 AM, Gerd Hoffmann wrote:
> Switch sdl ui to use qapi DisplayOptions for configuration.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  include/ui/console.h |  8 
>  ui/sdl.c | 19 +--
>  ui/sdl2.c| 33 +++--
>  vl.c | 13 +++--
>  qapi/ui.json |  5 +++--
>  5 files changed, 50 insertions(+), 28 deletions(-)
> 
Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v3 07/12] egl-headless: use DisplayOptions

2018-02-02 Thread Eric Blake
On 02/02/2018 05:10 AM, Gerd Hoffmann wrote:
> Switch egl-headless ui to use qapi DisplayOptions for configuration.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  include/ui/console.h | 2 +-
>  ui/egl-headless.c| 2 +-
>  vl.c | 3 ++-
>  qapi/ui.json | 5 +++--
>  4 files changed, 7 insertions(+), 5 deletions(-)
> 

Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] qemu-img: Fixed grammatical error in dump_human_image_check

2018-02-02 Thread Max Reitz
On 2018-02-02 14:37, Max Reitz wrote:
> On 2017-12-02 23:37, Shravan Rajinikanth wrote:
>> Signed-off-by: Shravan Rajinikanth 
>> ---
>>  qemu-img.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/qemu-img.c b/qemu-img.c
>> index 68b375f..bea9268 100644
>> --- a/qemu-img.c
>> +++ b/qemu-img.c
>> @@ -580,7 +580,7 @@ static void dump_human_image_check(ImageCheck *check, 
>> bool quiet)
>>  if (check->leaks) {
>>  qprintf(quiet,
>>  "\n%" PRId64 " leaked clusters were found on the 
>> image.\n"
>> -"This means waste of disk space, but no harm to 
>> data.\n",
>> +"This means disk space is wasted, but data is safe.\n",
>>  check->leaks);
>>  }
> 
> Sorry, somehow I never applied this.  (Maybe I thought it would go
> through trivial...)
> 
> Applied to my block tree:
> 
> https://github.com/XanClic/qemu/commits/block

I'll have to unstage it again because it breaks some iotests (026, 060,
and 112), sorry.

Max



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH RFC 17/21] qapi/types qapi/visit: Generate built-in stuff into separate files

2018-02-02 Thread Markus Armbruster
Linking code from multiple separate QAPI schemata into the same
program is possible, but involves some weirdness around built-in
types:

* We generate code for built-in types into .c only with option
  --builtins.  The user is responsible to generate code for exactly
  one QAPI schema per program with --builtins.

* We generate code for them it into .h regardless of --builtins,
  guarded by #ifndef QAPI_VISIT_BUILTIN.  Because the code for
  built-in types is exactly the same in all of them, including any
  combination of these headers works.

Replace this contraption by something more conventional: generate code
for built-in types into their very own files: qapi-builtin-types.c,
qapi-builtin-visit.c, qapi-builtin-types.h, qapi-builtin-visit.h, but
only with --builtins.  Obey --output-dir, but ignore --prefix for
them.

Make qapi-types.h include qapi-builtin-types.h.  With multiple
schemata you now have multiple qapi-types.[ch], but only one
qapi-builtin-types.[ch].  Same for qapi-visit.[ch] and
qapi-builtin-visit.[ch].

Bonus: if all you need is built-in stuff, you can include a much
smaller header.  To be exploited shortly.

Signed-off-by: Markus Armbruster 
---
 Makefile   | 13 +---
 Makefile.objs  |  1 +
 scripts/qapi/common.py | 18 +--
 scripts/qapi/types.py  | 82 ++--
 scripts/qapi/visit.py  | 84 --
 5 files changed, 111 insertions(+), 87 deletions(-)

diff --git a/Makefile b/Makefile
index e02f0c13ef..f9b7900330 100644
--- a/Makefile
+++ b/Makefile
@@ -88,10 +88,13 @@ endif
 include $(SRC_PATH)/rules.mak
 
 GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
-GENERATED_FILES += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
-GENERATED_FILES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
-GENERATED_FILES += qmp-introspect.h
-GENERATED_FILES += qmp-introspect.c
+GENERATED_FILES += qmp-commands.h qmp-marshal.c
+GENERATED_FILES += qapi-builtin-types.h qapi-builtin-types.c
+GENERATED_FILES += qapi-types.h qapi-types.c
+GENERATED_FILES += qapi-builtin-visit.h qapi-builtin-visit.c
+GENERATED_FILES += qapi-visit.h qapi-visit.c
+GENERATED_FILES += qapi-event.h qapi-event.c
+GENERATED_FILES += qmp-introspect.c qmp-introspect.h
 GENERATED_FILES += qapi.texi
 
 GENERATED_FILES += trace/generated-tcg-tracers.h
@@ -514,7 +517,9 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json 
$(SRC_PATH)/qapi/common.json \
$(SRC_PATH)/qapi/transaction.json \
$(SRC_PATH)/qapi/ui.json
 
+qapi-builtin-types.c qapi-builtin-types.h \
 qapi-types.c qapi-types.h \
+qapi-builtin-visit.c qapi-builtin-visit.h \
 qapi-visit.c qapi-visit.h \
 qmp-commands.h qmp-marshal.c \
 qapi-event.c qapi-event.h \
diff --git a/Makefile.objs b/Makefile.objs
index 323ef12384..f16cca06e7 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -2,6 +2,7 @@
 # Common libraries for tools and emulators
 stub-obj-y = stubs/ crypto/
 util-obj-y = util/ qobject/ qapi/
+util-obj-y += qapi-builtin-types.o qapi-builtin-visit.o
 util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
 
 chardev-obj-y = chardev/
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index f4e9ebbb53..7c78d9 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -1527,11 +1527,10 @@ class QAPISchema(object):
 
 def _def_builtin_type(self, name, json_type, c_type):
 self._def_entity(QAPISchemaBuiltinType(name, json_type, c_type))
-# TODO As long as we have QAPI_TYPES_BUILTIN to share multiple
-# qapi-types.h from a single .c, all arrays of builtins must be
-# declared in the first file whether or not they are used.  Nicer
-# would be to use lazy instantiation, while figuring out how to
-# avoid compilation issues with multiple qapi-types.h.
+# Instantiating only the arrays that are actually used would
+# be nice, but we can't as long as their generated code
+# (qapi-builtin-types.[ch]) may be shared by some other
+# schema.
 self._make_array_type(name, None)
 
 def _def_predefineds(self):
@@ -1985,14 +1984,15 @@ class QAPIGen(object):
 return ''
 
 def write(self, output_dir, fname):
-if output_dir:
+pathname = os.path.join(output_dir, fname)
+dir = os.path.dirname(pathname)
+if dir:
 try:
-os.makedirs(output_dir)
+os.makedirs(dir)
 except os.error as e:
 if e.errno != errno.EEXIST:
 raise
-fd = os.open(os.path.join(output_dir, fname),
- os.O_RDWR | os.O_CREAT, 0666)
+fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0666)
 f = os.fdopen(fd, 'r+')
 text = (self.top(fname) + self._preamble + self._body
 + self.bottom(fname))
diff --git a/scripts/qapi/types.py 

[Qemu-devel] [PULL 0/1] Vga 20180202 patches

2018-02-02 Thread Gerd Hoffmann
The following changes since commit b05631954d6dfe93340d516660397e2c1a2a5dd6:

  Merge remote-tracking branch 'remotes/rth/tags/pull-hppa-20180131' into 
staging (2018-01-31 15:50:29 +)

are available in the git repository at:

  git://git.kraxel.org/qemu tags/vga-20180202-pull-request

for you to fetch changes up to 34e304e97576a9e17680c868c00ff524a981007b:

  virtio-gpu: disallow vIOMMU (2018-02-02 08:53:22 +0100)


virtio-gpu: disallow vIOMMU



Peter Xu (1):
  virtio-gpu: disallow vIOMMU

 hw/display/virtio-gpu-pci.c | 8 +++-
 hw/display/virtio-gpu.c | 5 +
 2 files changed, 12 insertions(+), 1 deletion(-)

-- 
2.9.3




Re: [Qemu-devel] Qemu Trace

2018-02-02 Thread Nesrine Zouari
Hello Mr. Stefan,

Thank you for your response. To answer your question : the trace solution
should be architecture independent.This is the best for us. We aim to test
it at least for ARM/ARM64 , x86 and x64 architectures. But even if  there
will be some differences , we can accept it.

Regards,

On Fri, Feb 2, 2018 at 11:08 AM, Stefan Hajnoczi 
wrote:

> On Thu, Feb 01, 2018 at 04:30:10PM +0100, Nesrine Zouari wrote:
> > I am a computer engineering student and I am actually working on my
> > graduation project at Lauterbach company. The project is about Qemu Trace
> > and as a future I would like to contribute this work to the main line.
> >
> > My project is divided into two parts:
> >
> > 1/ Collecting the Guest trace data : The trace solution should be able to
> > provide:
> >
> > a/ Instruction flow Trace
> >
> > b/ Memory read/write access
> >
> > c/ Time Stamps.
> >
> > d/ For tracing rich operating systems that are using MMU, we
> > additionally need to trace the task switches.
>
> Lluìs has done the most instrumentation work in qemu.git and can explain
> the current status.
>
> The focus in QEMU is more on functional simulation than on low-level
> instrumentation.  Therefore the instrumentation facilities aren't very
> rich.  Code changes will be required to get the information you need.
> In order to be suitable for upstream they should not be too invasive or
> impact performance significantly.
>
> Which CPU architecture are you targeting?
>
> > 2/ Sending the collected data to a third party tool for analysis.
> >
> > My question is about the first part. I would like to know, which trace
> > backend that better fit my use case.
>
> LTTng UST has the highest performance tracing interface.  It uses shared
> memory to efficiently export trace data to a collector or analysis
> process.
>
> It is probably not necessary to invent your own tracer or interface for
> capturing trace data.  I suggest looking into LTTng UST and trying it
> out.
>
> The basic idea would be:
>
> 1. Add missing trace events to QEMU
> 2. Build with ./configure --enable-trace-backend=ust && make
> 3. Use LTTng tools or write your own collector using the LTTng libraries
> 4. Enable the trace events that you need for instruction flow, memory
>access, and task switching.
>
> The QEMU code changes involved would be changes to trace-events and
> placing those trace events into TCG and/or memory API code to record the
> necessary information.
>
> Stefan
>



-- 
-

Nesrine ZOUARI
Computer Engineering Student
Department of Computer Engineering and Applied Mathematics
National Engineering School of Sfax (ENIS)
University of Sfax-Tunisia
Tel: +216 52 620 475


[Qemu-devel] [PULL v2 06/10] tests: virtio-9p: add LOPEN operation test

2018-02-02 Thread Greg Kurz
Trivial test of a successful open.

Signed-off-by: Greg Kurz 
Reviewed-by: Stefan Hajnoczi 
---
 hw/9pfs/9p-synth.c |  5 +
 hw/9pfs/9p-synth.h |  1 +
 tests/virtio-9p-test.c | 47 +++
 3 files changed, 53 insertions(+)

diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index dcbd320da17a..f17b74f44461 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -541,6 +541,11 @@ static int synth_init(FsContext *ctx, Error **errp)
 assert(!ret);
 g_free(name);
 }
+
+/* File for LOPEN test */
+ret = qemu_v9fs_synth_add_file(NULL, 0, QTEST_V9FS_SYNTH_LOPEN_FILE,
+   NULL, NULL, ctx);
+assert(!ret);
 }
 
 return 0;
diff --git a/hw/9pfs/9p-synth.h b/hw/9pfs/9p-synth.h
index 876b4ef58288..2a8d6fd00d69 100644
--- a/hw/9pfs/9p-synth.h
+++ b/hw/9pfs/9p-synth.h
@@ -52,5 +52,6 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
 /* qtest stuff */
 
 #define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d"
+#define QTEST_V9FS_SYNTH_LOPEN_FILE "LOPEN"
 
 #endif
diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index 652198156731..6ba782e24f3a 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -238,6 +238,7 @@ static const char *rmessage_name(uint8_t id)
 id == P9_RVERSION ? "RVERSION" :
 id == P9_RATTACH ? "RATTACH" :
 id == P9_RWALK ? "RWALK" :
+id == P9_RLOPEN ? "RLOPEN" :
 "";
 }
 
@@ -389,6 +390,34 @@ static void v9fs_rwalk(P9Req *req, uint16_t *nwqid, 
v9fs_qid **wqid)
 v9fs_req_free(req);
 }
 
+/* size[4] Tlopen tag[2] fid[4] flags[4] */
+static P9Req *v9fs_tlopen(QVirtIO9P *v9p, uint32_t fid, uint32_t flags,
+  uint16_t tag)
+{
+P9Req *req;
+
+req = v9fs_req_init(v9p,  4 + 4, P9_TLOPEN, tag);
+v9fs_uint32_write(req, fid);
+v9fs_uint32_write(req, flags);
+v9fs_req_send(req);
+return req;
+}
+
+/* size[4] Rlopen tag[2] qid[13] iounit[4] */
+static void v9fs_rlopen(P9Req *req, v9fs_qid *qid, uint32_t *iounit)
+{
+v9fs_req_recv(req, P9_RLOPEN);
+if (qid) {
+v9fs_memread(req, qid, 13);
+} else {
+v9fs_memskip(req, 13);
+}
+if (iounit) {
+v9fs_uint32_read(req, iounit);
+}
+v9fs_req_free(req);
+}
+
 static void fs_version(QVirtIO9P *v9p)
 {
 const char *version = "9P2000.L";
@@ -478,6 +507,23 @@ static void fs_walk_dotdot(QVirtIO9P *v9p)
 g_free(wnames[0]);
 }
 
+static void fs_lopen(QVirtIO9P *v9p)
+{
+char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE) };
+P9Req *req;
+
+fs_attach(v9p);
+req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
+v9fs_req_wait_for_reply(req);
+v9fs_rwalk(req, NULL, NULL);
+
+req = v9fs_tlopen(v9p, 1, O_WRONLY, 0);
+v9fs_req_wait_for_reply(req);
+v9fs_rlopen(req, NULL, NULL);
+
+g_free(wnames[0]);
+}
+
 typedef void (*v9fs_test_fn)(QVirtIO9P *v9p);
 
 static void v9fs_run_pci_test(gconstpointer data)
@@ -507,6 +553,7 @@ int main(int argc, char **argv)
 v9fs_qtest_pci_add("/virtio/9p/pci/fs/walk/no_slash", fs_walk_no_slash);
 v9fs_qtest_pci_add("/virtio/9p/pci/fs/walk/dotdot_from_root",
fs_walk_dotdot);
+v9fs_qtest_pci_add("/virtio/9p/pci/fs/lopen/basic", fs_lopen);
 
 return g_test_run();
 }
-- 
2.13.6




Re: [Qemu-devel] [PATCH v3 08/12] curses: use DisplayOptions

2018-02-02 Thread Eric Blake
On 02/02/2018 05:10 AM, Gerd Hoffmann wrote:
> Switch curses ui to use qapi DisplayOptions for configuration.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  include/ui/console.h | 4 ++--
>  ui/curses.c  | 2 +-
>  vl.c | 4 +++-
>  qapi/ui.json | 5 +++--
>  4 files changed, 9 insertions(+), 6 deletions(-)
> 

Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v3 12/12] vl: drop display_type variable

2018-02-02 Thread Eric Blake
On 02/02/2018 05:10 AM, Gerd Hoffmann wrote:
> Switch over all leftover users to qapi DisplayType.
> Then delete the unused display_type variable.
> 
> Add 'default' DisplayType, which isn't an actual display type but
> a placeholder for "user didn't specify a display".  It will be replaced
> by the DisplayType actually used, which in turn depends on the
> DisplayTypes availabel in the particular build.

s/availabel/available/

> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  vl.c | 54 ++
>  qapi/ui.json |  5 +++--
>  2 files changed, 17 insertions(+), 42 deletions(-)
> 

> +++ b/qapi/ui.json
> @@ -1017,7 +1017,7 @@
>  #
>  ##
>  { 'enum': 'DisplayType',
> -  'data': [ 'none', 'gtk', 'sdl',
> +  'data': [ 'default', 'none', 'gtk', 'sdl',
>  'egl-headless', 'curses', 'cocoa' ] }

Worth documenting that the 'default' value is special and will be
converted to one of the other types, based on compile-time availability?

>  
>  ##
> @@ -1039,7 +1039,8 @@
>  '*window-close'  : 'bool',
>  '*gl': 'bool' },
>'discriminator' : 'type',
> -  'data': { 'none'   : 'DisplayNoOpts',
> +  'data': { 'default': 'DisplayNoOpts',
> +'none'   : 'DisplayNoOpts',
>  'gtk': 'DisplayGTK',
>  'sdl': 'DisplayNoOpts',
>  'egl-headless'   : 'DisplayNoOpts',
> 

Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PULL 17/51] readline: add a free function

2018-02-02 Thread Greg Kurz
On Thu, 1 Feb 2018 19:10:06 -0500
Paolo Bonzini  wrote:

> On 01/02/2018 19:00, Alex Williamson wrote:
> > On Tue, 16 Jan 2018 15:16:59 +0100
> > Paolo Bonzini  wrote:
> >   
> >> From: Marc-André Lureau 
> >>
> >> Fixes leaks such as:
> >>
> >> Direct leak of 2 byte(s) in 1 object(s) allocated from:
> >> #0 0x7eff58beb850 in malloc (/lib64/libasan.so.4+0xde850)
> >> #1 0x7eff57942f0c in g_malloc ../glib/gmem.c:94
> >> #2 0x7eff579431cf in g_malloc_n ../glib/gmem.c:331
> >> #3 0x7eff5795f6eb in g_strdup ../glib/gstrfuncs.c:363
> >> #4 0x55db720f1d46 in readline_hist_add 
> >> /home/elmarco/src/qq/util/readline.c:258
> >> #5 0x55db720f2d34 in readline_handle_byte 
> >> /home/elmarco/src/qq/util/readline.c:387
> >> #6 0x55db71539d00 in monitor_read /home/elmarco/src/qq/monitor.c:3896
> >> #7 0x55db71f9be35 in qemu_chr_be_write_impl 
> >> /home/elmarco/src/qq/chardev/char.c:167
> >> #8 0x55db71f9bed3 in qemu_chr_be_write 
> >> /home/elmarco/src/qq/chardev/char.c:179
> >> #9 0x55db71fa013c in fd_chr_read 
> >> /home/elmarco/src/qq/chardev/char-fd.c:66
> >> #10 0x55db71fe18a8 in qio_channel_fd_source_dispatch 
> >> /home/elmarco/src/qq/io/channel-watch.c:84
> >> #11 0x7eff5793a90b in g_main_dispatch ../glib/gmain.c:3182
> >> #12 0x7eff5793b7ac in g_main_context_dispatch ../glib/gmain.c:3847
> >> #13 0x55db720af3bd in glib_pollfds_poll 
> >> /home/elmarco/src/qq/util/main-loop.c:214
> >> #14 0x55db720af505 in os_host_main_loop_wait 
> >> /home/elmarco/src/qq/util/main-loop.c:261
> >> #15 0x55db720af6d6 in main_loop_wait 
> >> /home/elmarco/src/qq/util/main-loop.c:515
> >> #16 0x55db7184e0de in main_loop /home/elmarco/src/qq/vl.c:1995
> >> #17 0x55db7185e956 in main /home/elmarco/src/qq/vl.c:4914
> >> #18 0x7eff4ea17039 in __libc_start_main (/lib64/libc.so.6+0x21039)
> >>
> >> (while at it, use g_new0(ReadLineState), it's a bit easier to read)
> >>
> >> Signed-off-by: Marc-André Lureau 
> >> Reviewed-by: Dr. David Alan Gilbert 
> >> Reviewed-by: Philippe Mathieu-Daudé 
> >> Message-Id: <20180104160523.22995-11-marcandre.lur...@redhat.com>
> >> Signed-off-by: Paolo Bonzini 
> >> ---  
> > 
> > I'm having some trouble with this patch, using b05631954d6d:
> > 
> > # /usr/local/bin/qemu-system-x86_64 -m 1G -nodefaults -net none -monitor 
> > stdio -serial none -parallel none -nographic 
> > QEMU 2.11.50 monitor - type 'help' for more information
> > (qemu) sys
> > system_powerdown  system_reset  system_wakeup 
> > (qemu) system_p# resulting in system_powerdown
> > (qemu) quit
> > Segmentation fault (core dumped)
> > 
> > gdb shows:
> > 
> > Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
> > 0x7f7d64d82927 in malloc () from /lib64/libc.so.6
> > (gdb) bt
> > #0  0x7f7d64d82927 in malloc () at /lib64/libc.so.6
> > #1  0x7f7d6ef68359 in g_malloc () at /lib64/libglib-2.0.so.0
> > #2  0x7f7d6ef83004 in g_strsplit () at /lib64/libglib-2.0.so.0
> > #3  0x55e5ac0d549d in container_get (root=0x55e5ad570ee0, 
> > path=path@entry=0x55e5ac2fa0f8 "/chardevs") at qom/container.c:34
> > #4  0x55e5ac14d102 in get_chardevs_root () at chardev/char.c:43
> > #5  0x55e5ac14ec4d in qemu_chr_cleanup () at chardev/char.c:1107
> > #6  0x55e5abeff1c4 in main (argc=, argv=, 
> > envp=) at vl.c:4780
> > 
> > Reverting this patch, commit e5dc1a6c6c435, I don't see the issue.
> > Thanks,  
> 
> Yeah, I have a fix queued.  Unfortunately, I don't have the usual setup
> to do pre-pull-request sets here so it will have to wait for next Monday.
> 
> Paolo
> 

The queued fix is:

http://patchwork.ozlabs.org/patch/862816/



Re: [Qemu-devel] [PATCH 1/2] qcow2: add overlap check for bitmap directory

2018-02-02 Thread Max Reitz
On 2018-02-02 14:48, Vladimir Sementsov-Ogievskiy wrote:
> 02.02.2018 16:00, Max Reitz wrote:
>> On 2018-02-02 13:07, Vladimir Sementsov-Ogievskiy wrote:
>>> 29.01.2018 18:34, Max Reitz wrote:
 On 2017-11-30 17:47, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>    block/qcow2.h  |  7 +--
>    block/qcow2-refcount.c | 12 
>    block/qcow2.c  |  6 ++
>    3 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/block/qcow2.h b/block/qcow2.h
> index 6f0ff15dd0..8f226a3609 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -98,6 +98,7 @@
>    #define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE
> "overlap-check.snapshot-table"
>    #define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1"
>    #define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2"
> +#define QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY
> "overlap-check.bitmap-directory"
>    #define QCOW2_OPT_CACHE_SIZE "cache-size"
>    #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size"
>    #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size"
> @@ -406,8 +407,9 @@ typedef enum QCow2MetadataOverlap {
>    QCOW2_OL_SNAPSHOT_TABLE_BITNR = 5,
>    QCOW2_OL_INACTIVE_L1_BITNR    = 6,
>    QCOW2_OL_INACTIVE_L2_BITNR    = 7,
> +    QCOW2_OL_BITMAP_DIRECTORY_BITNR = 8,
>    -    QCOW2_OL_MAX_BITNR    = 8,
> +    QCOW2_OL_MAX_BITNR  = 9,
>      QCOW2_OL_NONE   = 0,
>    QCOW2_OL_MAIN_HEADER    = (1 << QCOW2_OL_MAIN_HEADER_BITNR),
> @@ -420,12 +422,13 @@ typedef enum QCow2MetadataOverlap {
>    /* NOTE: Checking overlaps with inactive L2 tables will result
> in bdrv
>     * reads. */
>    QCOW2_OL_INACTIVE_L2    = (1 << QCOW2_OL_INACTIVE_L2_BITNR),
> +    QCOW2_OL_BITMAP_DIRECTORY = (1 <<
> QCOW2_OL_BITMAP_DIRECTORY_BITNR),
>    } QCow2MetadataOverlap;
>      /* Perform all overlap checks which can be done in constant
> time */
>    #define QCOW2_OL_CONSTANT \
>    (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 |
> QCOW2_OL_REFCOUNT_TABLE | \
> - QCOW2_OL_SNAPSHOT_TABLE)
> + QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_BITMAP_DIRECTORY)
>      /* Perform all overlap checks which don't require disk access */
>    #define QCOW2_OL_CACHED \
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 3de1ab51ba..a7a2703f26 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -2585,6 +2585,18 @@ int
> qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t
> offset,
>    }
>    }
>    +    if ((chk & QCOW2_OL_BITMAP_DIRECTORY) &&
> +    (s->autoclear_features & QCOW2_AUTOCLEAR_BITMAPS))
> +    {
> +    /* update_ext_header_and_dir_in_place firstly drop autoclear
> flag,
> + * so it will not fail */
 That's really not an argument.  bitmap_list_store() has to pass
 QCOW2_OL_BITMAP_DIRECTORY to @ign anyway.  (Because there is no reason
 not to.)
>>> in_place is a reason. When we store directory in_place, it definitely
>>> overlaps with current directory.
>> Well, then you just pass QCOW2_OL_BITMAP_DIRECTORY to @ign, which is
>> what that argument is for? :-)
> 
> hmm. but actually, I should not, because of zeroed autoclear flag. So,
> do you think, it is better to pass it, anyway?

Yes.  That flag describes what kind of metadata structures you are
planning to overwrite, and you *are* planning to overwrite the bitmap
directory, so you should set it.

Max



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PULL v2 10/10] tests/virtio-9p: explicitly handle potential integer overflows

2018-02-02 Thread Greg Kurz
Signed-off-by: Greg Kurz 
Reviewed-by: Eric Blake 
Reviewed-by: Stefan Hajnoczi 
---
 tests/virtio-9p-test.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index 0d3334a6ce17..54edcb995542 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -168,7 +168,7 @@ static uint16_t v9fs_string_size(const char *string)
 {
 size_t len = strlen(string);
 
-g_assert_cmpint(len, <=, UINT16_MAX);
+g_assert_cmpint(len, <=, UINT16_MAX - 2);
 
 return 2 + len;
 }
@@ -209,17 +209,20 @@ static P9Req *v9fs_req_init(QVirtIO9P *v9p, uint32_t 
size, uint8_t id,
 uint16_t tag)
 {
 P9Req *req = g_new0(P9Req, 1);
-uint32_t t_size = 7 + size; /* 9P header has well-known size of 7 bytes */
+uint32_t total_size = 7; /* 9P header has well-known size of 7 bytes */
 P9Hdr hdr = {
-.size = cpu_to_le32(t_size),
 .id = id,
 .tag = cpu_to_le16(tag)
 };
 
-g_assert_cmpint(t_size, <=, P9_MAX_SIZE);
+g_assert_cmpint(total_size, <=, UINT32_MAX - size);
+total_size += size;
+hdr.size = cpu_to_le32(total_size);
+
+g_assert_cmpint(total_size, <=, P9_MAX_SIZE);
 
 req->v9p = v9p;
-req->t_size = t_size;
+req->t_size = total_size;
 req->t_msg = guest_alloc(v9p->qs->alloc, req->t_size);
 v9fs_memwrite(req, , 7);
 req->tag = tag;
@@ -305,8 +308,13 @@ static void v9fs_rlerror(P9Req *req, uint32_t *err)
 static P9Req *v9fs_tversion(QVirtIO9P *v9p, uint32_t msize, const char 
*version,
 uint16_t tag)
 {
-P9Req *req = v9fs_req_init(v9p, 4 + v9fs_string_size(version), P9_TVERSION,
-   tag);
+P9Req *req;
+uint32_t body_size = 4;
+uint16_t string_size = v9fs_string_size(version);
+
+g_assert_cmpint(body_size, <=, UINT32_MAX - string_size);
+body_size += string_size;
+req = v9fs_req_init(v9p, body_size, P9_TVERSION, tag);
 
 v9fs_uint32_write(req, msize);
 v9fs_string_write(req, version);
@@ -366,12 +374,15 @@ static P9Req *v9fs_twalk(QVirtIO9P *v9p, uint32_t fid, 
uint32_t newfid,
 {
 P9Req *req;
 int i;
-uint32_t size = 4 + 4 + 2;
+uint32_t body_size = 4 + 4 + 2;
 
 for (i = 0; i < nwname; i++) {
-size += v9fs_string_size(wnames[i]);
+uint16_t wname_size = v9fs_string_size(wnames[i]);
+
+g_assert_cmpint(body_size, <=, UINT32_MAX - wname_size);
+body_size += wname_size;
 }
-req = v9fs_req_init(v9p,  size, P9_TWALK, tag);
+req = v9fs_req_init(v9p,  body_size, P9_TWALK, tag);
 v9fs_uint32_write(req, fid);
 v9fs_uint32_write(req, newfid);
 v9fs_uint16_write(req, nwname);
-- 
2.13.6




[Qemu-devel] [PATCH v3 1/1] s390x/cpu: expose the guest crash information

2018-02-02 Thread Christian Borntraeger
This patch is the s390 implementation of guest crash information,
similar to commit d187e08dc4 ("i386/cpu: add crash-information QOM
property") and the related commits. We will detect several crash
reasons, with the "disabled wait" being the most important one, since
this is used by all s390 guests as a "panic like" notification.

Demonstrate these ways with examples as follows.

  1. crash-information QOM property;

  Run qemu with -qmp unix:qmp-sock,server, then use utility "qmp-shell"
  to execute "qom-get" command, and might get the result like,

  (QEMU) qom-get path=/machine/cpu[0]/ property=crash-information
  {"return": {"psw-addr": 1105350, "psw-mask": 562956395872256, "reason":
   "disabled wait", "type": "s390"}}

  2. GUEST_PANICKED event reporting;

  Run qemu with a socket option, and telnet or nc to that,
  -chardev socket,id=qmp,port=,host=localhost,server \
  -mon chardev=qmp,mode=control,pretty=on \
  Negotiating the mode by { "execute": "qmp_capabilities" }, and the crash
  information will be reported on a guest crash event like,

  {
  "timestamp": {
  "seconds": 1499931739,
  "microseconds": 961296
  },
  "event": "GUEST_PANICKED",
  "data": {
  "action": "pause",
  "info": {
  "psw-addr": 1105350,
  "reason": "disabled wait",
  "psw-mask": 562956395872256,
  "type": "s390"
  }
  }
  }

  3. log;

  Run qemu with the parameters: -D  -d guest_errors, to
  specify the logfile and log item. The results might be,

  Guest crashed
  S390 crash parameters: (0x1000 0x0006)
  S390 crash reason: operation exception loop

Co-authored-by: Jing Liu 
Signed-off-by: Christian Borntraeger 
---
 qapi/run-state.json   | 29 --
 target/s390x/cpu.c| 57 +++
 target/s390x/cpu.h| 10 +
 target/s390x/helper.c |  5 -
 target/s390x/kvm.c| 27 +++-
 vl.c  |  6 ++
 6 files changed, 126 insertions(+), 8 deletions(-)

diff --git a/qapi/run-state.json b/qapi/run-state.json
index bca46a8785..a93f6fea5c 100644
--- a/qapi/run-state.json
+++ b/qapi/run-state.json
@@ -320,22 +320,31 @@
 #
 # An enumeration of the guest panic information types
 #
+# @hyper-v: hyper-v guest panic information type
+#
+# @s390: s390 guest panic information type (Since: 2.12)
+#
 # Since: 2.9
 ##
 { 'enum': 'GuestPanicInformationType',
-  'data': [ 'hyper-v'] }
+  'data': [ 'hyper-v', 's390' ] }
 
 ##
 # @GuestPanicInformation:
 #
 # Information about a guest panic
 #
+# @hyper-v: hyper-v guest panic information
+#
+# @s390: s390 guest panic information (Since: 2.12)
+#
 # Since: 2.9
 ##
 {'union': 'GuestPanicInformation',
  'base': {'type': 'GuestPanicInformationType'},
  'discriminator': 'type',
- 'data': { 'hyper-v': 'GuestPanicInformationHyperV' } }
+ 'data': { 'hyper-v': 'GuestPanicInformationHyperV',
+   's390': 'GuestPanicInformationS390' } }
 
 ##
 # @GuestPanicInformationHyperV:
@@ -350,3 +359,19 @@
'arg3': 'uint64',
'arg4': 'uint64',
'arg5': 'uint64' } }
+
+##
+# @GuestPanicInformationS390:
+#
+# S390 specific guest panic information (PSW)
+#
+# @psw-mask: control fields of guest PSW
+# @psw-addr: guest instruction address
+# @reason: guest crash reason for human reading
+#
+# Since: 2.12
+##
+{'struct': 'GuestPanicInformationS390',
+ 'data': { 'psw-mask': 'uint64',
+   'psw-addr': 'uint64',
+   'reason': 'str' } }
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index d2e6b9f5c7..ac8e963307 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -35,6 +35,8 @@
 #include "qemu/error-report.h"
 #include "trace.h"
 #include "qapi/visitor.h"
+#include "qapi-visit.h"
+#include "sysemu/hw_accel.h"
 #include "exec/exec-all.h"
 #include "hw/qdev-properties.h"
 #ifndef CONFIG_USER_ONLY
@@ -237,6 +239,58 @@ out:
 error_propagate(errp, err);
 }
 
+static GuestPanicInformation *s390x_cpu_get_crash_info(CPUState *cs)
+{
+GuestPanicInformation *panic_info;
+S390CPU *cpu = S390_CPU(cs);
+
+cpu_synchronize_state(cs);
+panic_info = g_malloc0(sizeof(GuestPanicInformation));
+
+panic_info->type = GUEST_PANIC_INFORMATION_TYPE_S390;
+panic_info->u.s390.psw_mask = cpu->env.psw.mask;
+panic_info->u.s390.psw_addr = cpu->env.psw.addr;
+
+switch (cpu->env.crash_reason) {
+case CRASH_REASON_PGM:
+panic_info->u.s390.reason = g_strdup("program interrupt loop");
+break;
+case CRASH_REASON_EXT:
+panic_info->u.s390.reason = g_strdup("external interrupt loop");
+break;
+case CRASH_REASON_WAITPSW:
+panic_info->u.s390.reason = g_strdup("disabled wait");
+break;
+case CRASH_REASON_OPEREXC:
+panic_info->u.s390.reason = g_strdup("operation exception loop");
+break;
+

Re: [Qemu-devel] [PATCH v7 for-2.12 21/25] block: Purify .bdrv_refresh_filename()

2018-02-02 Thread Max Reitz
On 2017-12-04 19:25, Max Reitz wrote:
> On 2017-12-04 17:37, Alberto Garcia wrote:
>> On Mon 20 Nov 2017 09:10:00 PM CET, Max Reitz wrote:
>>> -static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
>>> +static void blkdebug_refresh_filename(BlockDriverState *bs)
>>>  {
>>>  BDRVBlkdebugState *s = bs->opaque;
>>> -QDict *opts;
>>>  const QDictEntry *e;
>>> -bool force_json = false;
>>> -
>>> -for (e = qdict_first(options); e; e = qdict_next(options, e)) {
>>> -if (strcmp(qdict_entry_key(e), "config") &&
>>> -strcmp(qdict_entry_key(e), "x-image"))
>>> -{
>>> -force_json = true;
>>> -break;
>>> -}
>>> -}
>>> +int ret;
>>>  
>>> -if (force_json && !bs->file->bs->full_open_options) {
>>> -/* The config file cannot be recreated, so creating a plain 
>>> filename
>>> - * is impossible */
>>> +if (!bs->file->bs->exact_filename[0]) {
>>>  return;
>>>  }
>>>  
>>> -if (!force_json && bs->file->bs->exact_filename[0]) {
>>> -int ret = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
>>> -   "blkdebug:%s:%s", s->config_file ?: "",
>>> -   bs->file->bs->exact_filename);
>>> -if (ret >= sizeof(bs->exact_filename)) {
>>> -/* An overflow makes the filename unusable, so do not report 
>>> any */
>>> -bs->exact_filename[0] = 0;
>>> +for (e = qdict_first(bs->full_open_options); e;
>>> + e = qdict_next(bs->full_open_options, e))
>>> +{
>>> +if (strcmp(qdict_entry_key(e), "config") &&
>>> +strcmp(qdict_entry_key(e), "image") &&
>>
>> Shouldn't this be "x-image" ?
> 
> Er, yes.  It should.

Actually, it should be both.  That's because the child is attached as
"image" and not "x-image", so when the child options are gathered, they
are put under "image".

And since the child is attached using bdrv_open_child(), you have to
specify all child options in an "image" sub qdict, too (as can be seen
in iotest 099), so this is indeed correct.  (Btw, note that the old code
already put these options under "image".)

(So with "x-image" instead of "image", iotest 162 fails.)

Of course, x-image can be specified, too (although I wouldn't really
mind breaking that for users...), so we have to ignore that, still.


Before this patch, we could ignore "image" because we iterated over the
options before they were newly generated.  Now they are generated
automatically before this function is called, so there may be an "image"
key now.

x-image



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 4/6] target/arm: Add "-cpu max" support

2018-02-02 Thread Peter Maydell
On 26 January 2018 at 15:44, Philippe Mathieu-Daudé  wrote:
> On 01/26/2018 11:33 AM, Peter Maydell wrote:
>> On 26 January 2018 at 14:29, Philippe Mathieu-Daudé  wrote:
>>> Why not use arm_any_initfn() here?
>>
>> That function (and the 'any' cpu) are deliberately only
>> included in the linux-user binaries, not the system-emulation binaries.
>
> why not use the V8 features?

What v8 features?

>> (Also arm_any_initfn() only initializes userspace-visible stuff, it
>> doesn't provide ID register values etc for kernel-visible things.)
>
> I'd still use an unique arm_max_initfn() such
>
>   // initializes userspace-visible stuff
> #ifndef CONFIG_USER_ONLY
>   // initializes kernel-visible things
> #endif

>>> Actually what seems cleaner is to move "any" features here, and kill the
>>> "any" cpu, using "max" for this purpose.
>>
>> We can't kill 'any', that would break back-compatibility
>> of command lines.
>
> and use an alias for 'any' -> 'max' or just
>
>   { .name = "any", .initfn = arm_max_initfn }, /* backward compat */

Yes, we could probably do something similar to this.

thanks
-- PMM



Re: [Qemu-devel] [PATCH] qemu-img: Fixed grammatical error in dump_human_image_check

2018-02-02 Thread Max Reitz
On 2017-12-02 23:37, Shravan Rajinikanth wrote:
> Signed-off-by: Shravan Rajinikanth 
> ---
>  qemu-img.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 68b375f..bea9268 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -580,7 +580,7 @@ static void dump_human_image_check(ImageCheck *check, 
> bool quiet)
>  if (check->leaks) {
>  qprintf(quiet,
>  "\n%" PRId64 " leaked clusters were found on the 
> image.\n"
> -"This means waste of disk space, but no harm to data.\n",
> +"This means disk space is wasted, but data is safe.\n",
>  check->leaks);
>  }

Sorry, somehow I never applied this.  (Maybe I thought it would go
through trivial...)

Applied to my block tree:

https://github.com/XanClic/qemu/commits/block

Max



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PULL 2/2] hw/audio/sb16.c: change dolog() to qemu_log_mask()

2018-02-02 Thread Gerd Hoffmann
From: John Arbuckle 

Changes all the occurrances of dolog() to qemu_log_mask().

Signed-off-by: John Arbuckle 
Message-id: 20180201172744.7504-1-programmingk...@gmail.com
Signed-off-by: Gerd Hoffmann 
---
 hw/audio/sb16.c | 79 +++--
 1 file changed, 43 insertions(+), 36 deletions(-)

diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 6ab2f6f89a..31de264ab7 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -29,6 +29,8 @@
 #include "hw/qdev.h"
 #include "qemu/timer.h"
 #include "qemu/host-utils.h"
+#include "qemu/log.h"
+#include "qapi/error.h"
 
 #define dolog(...) AUD_log ("sb16", __VA_ARGS__)
 
@@ -123,7 +125,7 @@ static int magic_of_irq (int irq)
 case 10:
 return 8;
 default:
-dolog ("bad irq %d\n", irq);
+qemu_log_mask(LOG_GUEST_ERROR, "bad irq %d\n", irq);
 return 2;
 }
 }
@@ -140,7 +142,7 @@ static int irq_of_magic (int magic)
 case 8:
 return 10;
 default:
-dolog ("bad irq magic %d\n", magic);
+qemu_log_mask(LOG_GUEST_ERROR, "bad irq magic %d\n", magic);
 return -1;
 }
 }
@@ -258,8 +260,8 @@ static void dma_cmd8 (SB16State *s, int mask, int dma_len)
 s->align = (1 << s->fmt_stereo) - 1;
 
 if (s->block_size & s->align) {
-dolog ("warning: misaligned block size %d, alignment %d\n",
-   s->block_size, s->align + 1);
+qemu_log_mask(LOG_GUEST_ERROR, "warning: misaligned block size %d,"
+  " alignment %d\n", s->block_size, s->align + 1);
 }
 
 ldebug ("freq %d, stereo %d, sign %d, bits %d, "
@@ -338,8 +340,8 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, 
int dma_len)
 s->highspeed = 0;
 s->align = (1 << (s->fmt_stereo + (s->fmt_bits == 16))) - 1;
 if (s->block_size & s->align) {
-dolog ("warning: misaligned block size %d, alignment %d\n",
-   s->block_size, s->align + 1);
+qemu_log_mask(LOG_GUEST_ERROR, "warning: misaligned block size %d,"
+  " alignment %d\n", s->block_size, s->align + 1);
 }
 
 if (s->freq) {
@@ -391,7 +393,8 @@ static void command (SB16State *s, uint8_t cmd)
 
 if (cmd > 0xaf && cmd < 0xd0) {
 if (cmd & 8) {
-dolog ("ADC not yet supported (command %#x)\n", cmd);
+qemu_log_mask(LOG_UNIMP, "ADC not yet supported (command %#x)\n",
+  cmd);
 }
 
 switch (cmd >> 4) {
@@ -399,7 +402,7 @@ static void command (SB16State *s, uint8_t cmd)
 case 12:
 break;
 default:
-dolog ("%#x wrong bits\n", cmd);
+qemu_log_mask(LOG_GUEST_ERROR, "%#x wrong bits\n", cmd);
 }
 s->needed_bytes = 3;
 }
@@ -453,7 +456,7 @@ static void command (SB16State *s, uint8_t cmd)
 goto warn;
 
 case 0x35:
-dolog ("0x35 - MIDI command not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x35 - MIDI command not implemented\n");
 break;
 
 case 0x40:
@@ -487,34 +490,38 @@ static void command (SB16State *s, uint8_t cmd)
 
 case 0x74:
 s->needed_bytes = 2; /* DMA DAC, 4-bit ADPCM */
-dolog ("0x75 - DMA DAC, 4-bit ADPCM not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x75 - DMA DAC, 4-bit ADPCM not"
+  " implemented\n");
 break;
 
 case 0x75:  /* DMA DAC, 4-bit ADPCM Reference */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 4-bit ADPCM Reference not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 4-bit ADPCM Reference 
not"
+  " implemented\n");
 break;
 
 case 0x76:  /* DMA DAC, 2.6-bit ADPCM */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 2.6-bit ADPCM not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 2.6-bit ADPCM not"
+  " implemented\n");
 break;
 
 case 0x77:  /* DMA DAC, 2.6-bit ADPCM Reference */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 2.6-bit ADPCM Reference not 
implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 2.6-bit ADPCM Reference"
+  " not implemented\n");
 break;
 
 case 0x7d:
-dolog ("0x7d - Autio-Initialize DMA DAC, 4-bit ADPCM Reference\n");
-dolog ("not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x7d - Autio-Initialize DMA DAC, 4-bit"
+  " ADPCM Reference\n");
+qemu_log_mask(LOG_UNIMP, "not implemented\n");
 break;
 
 case 0x7f:
-dolog (
-"0x7d - Autio-Initialize DMA DAC, 2.6-bit ADPCM Reference\n"
-);
-

Re: [Qemu-devel] [RFC 0/2] virtio-vhost-user: add virtio-vhost-user device

2018-02-02 Thread Wei Wang

On 02/02/2018 01:08 AM, Michael S. Tsirkin wrote:

On Tue, Jan 30, 2018 at 08:09:19PM +0800, Wei Wang wrote:

Issues:
Suppose we have both the vhost and virtio-net set up, and vhost pmd <->
virtio-net pmd communication works well. Now, vhost pmd exits (virtio-net
pmd is still there). Some time later, we re-run vhost pmd, the vhost pmd
doesn't know the virtqueue addresses of the virtio-net pmd, unless the
virtio-net pmd reloads to start the 2nd phase of the vhost-user protocol. So
the second run of the vhost pmd won't work.

Any thoughts?

Best,
Wei

So vhost in qemu must resend all configuration on reconnect.
Does this address the issues?



Yes, but the issues are
1) there is no reconnecting when a pmd exits (the socket connection 
seems still on at the device layer);
2) If we find a way to break the QEMU layer socket connection when pmd 
exits and get it reconnect, virtio-net device still won't send all the 
configure when reconnecting, because socket connecting only triggers 
phase 1 of vhost-user negotiation (i.e. vhost_user_init). Phase 2 is 
triggered after the driver loads (i.e. vhost_net_start). If the 
virtio-net pmd doesn't reload, there are no phase 2 messages (like 
virtqueue addresses which are allocated by the pmd). I think we need to 
think more about this before moving forward.


Best,
Wei



Re: [Qemu-devel] [PATCH] s390x/sclp: fix event mask handling

2018-02-02 Thread Cornelia Huck
On Fri, 2 Feb 2018 11:33:01 +0100
Cornelia Huck  wrote:

> On Fri, 2 Feb 2018 10:43:18 +0100
> Christian Borntraeger  wrote:
> 
> > On 02/02/2018 10:42 AM, Christian Borntraeger wrote:  
> > > commit 67915de9f038 ("s390x/event-facility: variable-length event
> > > masks") switches the sclp receive/send mask. This broke the sclp
> > > lm console.  
> 
> Hum. Probably should add sclp-lm to my test setup.
> 
> > > 
> > > Signed-off-by: Christian Borntraeger 
> > > Fixes: commit 67915de9f038 ("s390x/event-facility: variable-length event 
> > > masks")
> > > Cc: Cornelia Huck 
> > 
> > opps. Please fixup yourself Conny :-)  
> 
> Well, you did cc: the original author :)
> 
> >   
> > > Cc: Jason J. Herne 
> > > Cc: qemu-sta...@nongnu.org
> > > ---
> > >  hw/s390x/event-facility.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> > > index b0f71f4554..155a69467b 100644
> > > --- a/hw/s390x/event-facility.c
> > > +++ b/hw/s390x/event-facility.c
> > > @@ -293,10 +293,10 @@ static void write_event_mask(SCLPEventFacility *ef, 
> > > SCCB *sccb)
> > >  ef->receive_mask = be32_to_cpu(tmp_mask);
> > > 
> > >  /* return the SCLP's capability masks to the guest */
> > > -tmp_mask = cpu_to_be32(get_host_send_mask(ef));
> > > +tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
> > >  copy_mask(WEM_RECEIVE_MASK(we_mask, mask_length), (uint8_t 
> > > *)_mask,
> > >mask_length, sizeof(tmp_mask));
> > > -tmp_mask = cpu_to_be32(get_host_receive_mask(ef));
> > > +tmp_mask = cpu_to_be32(get_host_send_mask(ef));
> > >  copy_mask(WEM_SEND_MASK(we_mask, mask_length), (uint8_t *)_mask,
> > >mask_length, sizeof(tmp_mask));
> > > 
> >   
> 
> Thanks, applied.

Oh, and as always, I still take R-bs until I prepare a pull req.



[Qemu-devel] [PATCH RFC 14/21] qapi: Generate in source order

2018-02-02 Thread Markus Armbruster
The generators' conversion to visitors (merge commit 9e72681d16)
changed the processing order of entities from source order to
alphabetical order.  The next commit needs source order, so change it
back.

Signed-off-by: Markus Armbruster 
---
 scripts/qapi/common.py   |   4 +-
 tests/qapi-schema/comments.out   |   2 +-
 tests/qapi-schema/doc-bad-section.out|   4 +-
 tests/qapi-schema/doc-good.out   |  32 ++--
 tests/qapi-schema/empty.out  |   2 +-
 tests/qapi-schema/event-case.out |   2 +-
 tests/qapi-schema/ident-with-escape.out  |   6 +-
 tests/qapi-schema/include-relpath.out|   2 +-
 tests/qapi-schema/include-repetition.out |   2 +-
 tests/qapi-schema/include-simple.out |   2 +-
 tests/qapi-schema/indented-expr.out  |   2 +-
 tests/qapi-schema/qapi-schema-test.out   | 320 +++
 12 files changed, 191 insertions(+), 189 deletions(-)

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index d5b93e7381..3b97bf8702 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -1471,6 +1471,7 @@ class QAPISchema(object):
 parser = QAPISchemaParser(open(fname, 'r'))
 exprs = check_exprs(parser.exprs)
 self.docs = parser.docs
+self._entity_list = []
 self._entity_dict = {}
 self._predefining = True
 self._def_predefineds()
@@ -1482,6 +1483,7 @@ class QAPISchema(object):
 # Only the predefined types are allowed to not have info
 assert ent.info or self._predefining
 assert ent.name not in self._entity_dict
+self._entity_list.append(ent)
 self._entity_dict[ent.name] = ent
 
 def lookup_entity(self, name, typ=None):
@@ -1685,7 +1687,7 @@ class QAPISchema(object):
 
 def visit(self, visitor):
 visitor.visit_begin(self)
-for (name, entity) in sorted(self._entity_dict.items()):
+for entity in self._entity_list:
 if visitor.visit_needed(entity):
 entity.visit(visitor)
 visitor.visit_end()
diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
index 17e652535c..0261ddf202 100644
--- a/tests/qapi-schema/comments.out
+++ b/tests/qapi-schema/comments.out
@@ -1,4 +1,4 @@
+object q_empty
 enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
 prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
-object q_empty
diff --git a/tests/qapi-schema/doc-bad-section.out 
b/tests/qapi-schema/doc-bad-section.out
index 089bde1381..23bf8c71ab 100644
--- a/tests/qapi-schema/doc-bad-section.out
+++ b/tests/qapi-schema/doc-bad-section.out
@@ -1,7 +1,7 @@
-enum Enum ['one', 'two']
+object q_empty
 enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
 prefix QTYPE
-object q_empty
+enum Enum ['one', 'two']
 doc symbol=Enum
 body=
 == Produces *invalid* texinfo
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index 1d2c250527..0c07301f07 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -1,35 +1,35 @@
+object q_empty
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
+prefix QTYPE
+enum Enum ['one', 'two']
 object Base
 member base1: Enum optional=False
-enum Enum ['one', 'two']
+object Variant1
+member var1: str optional=False
+object Variant2
 object Object
 base Base
 tag base1
 case one: Variant1
 case two: Variant2
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-prefix QTYPE
+object q_obj_Variant1-wrapper
+member data: Variant1 optional=False
+object q_obj_Variant2-wrapper
+member data: Variant2 optional=False
+enum SugaredUnionKind ['one', 'two']
 object SugaredUnion
 member type: SugaredUnionKind optional=False
 tag type
 case one: q_obj_Variant1-wrapper
 case two: q_obj_Variant2-wrapper
-enum SugaredUnionKind ['one', 'two']
-object Variant1
-member var1: str optional=False
-object Variant2
-command cmd q_obj_cmd-arg -> Object
-   gen=True success_response=True boxed=False
-command cmd-boxed Object -> None
-   gen=True success_response=True boxed=True
-object q_empty
-object q_obj_Variant1-wrapper
-member data: Variant1 optional=False
-object q_obj_Variant2-wrapper
-member data: Variant2 optional=False
 object q_obj_cmd-arg
 member arg1: int optional=False
 member arg2: str optional=True
 member arg3: bool optional=False
+command cmd q_obj_cmd-arg -> Object
+   gen=True success_response=True boxed=False
+command cmd-boxed Object -> None
+   gen=True success_response=True boxed=True
 doc freeform
 body=
 = Section
diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out
index 40b886ddae..0ec234eec4 100644
--- a/tests/qapi-schema/empty.out
+++ b/tests/qapi-schema/empty.out
@@ -1,3 +1,3 @@
+object q_empty
 enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 

  1   2   3   >