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 *)&tmp_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 *)&tmp_mask,
   mask_length, sizeof(tmp_mask));
 
-- 
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 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;






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. 

> 
>> +env->spr[SPR_PTCR

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




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




[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




[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=", &nextopt)) {
+g_printerr("The frame= sdl option is deprecated, and will be\n"
+   "removed in a future release.\n");
 opts = nextopt;
 if (strstart(opts, "on", &nextopt)) {
 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 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(&s->mmio, OBJECT(s), &tpm_crb_memory_ops, s,
-"tpm-crb-mmio", sizeof(s->regs));
-memory_region_init_ram(&s->cmdmem, OBJECT(s),
-"tpm-crb-cmd", CRB_CTRL_CMD_SIZE, errp);
-
-memory_region_add_subregion(get_system_memory(),
-TPM_CRB_ADDR_BASE, &s->mmio);
-memory_region_add_subregion(get_system_memory(),
-TPM_CRB_ADDR_BASE + sizeof(s->regs), &s->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(&s->mmio, OBJECT(s), &tpm_crb_memory_ops, s,
+"tpm-crb-mmio", sizeof(s->regs));
+memory_region_init_ram(&s->cmdmem, OBJECT(s),
+"tpm-crb-cmd", CRB_CTRL_CMD_SIZE, errp);
+
+memory_region_add_subregion(get_system_memory(),
+TPM_CRB_ADDR_BASE, &s->mmio);
+memory_region_add_subregion(get_system_memory(),
+TPM_CRB_ADDR_BASE + sizeof(s->regs), &s->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] [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,
> 




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. 



[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", &opts)) {
 #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, &dpy);
 break;
 case DT_SDL:
 sdl_display_init(ds, &dpy);
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/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




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 = &cpu->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 a/target/ppc/transla

[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", &nextopt)) {
-no_quit = 0;
 dpy.window_close = true;
 } else if (strstart(opts, "off", &nextopt)) {
-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




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=", &nextopt)) {
+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", &nextopt)) {
 alt_grab = 1;
@@ -2124,6 +2126,8 @@ static DisplayType select_display(const char *p)
 goto invalid_sdl_args;
 }
 } else if (strstart(opts, ",ctrl_grab=", &nextopt)) {
+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", &nextopt)) {
 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




[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", &error_abort);
 #else
@@ -4716,7 +4717,7 @@ int main(int argc, char **argv, char **envp)
 sdl_display_init(ds, &dpy);
 break;
 case DT_COCOA:
-cocoa_display_init(ds, full_screen);
+cocoa_display_init(ds, &dpy);
 break;
 case DT_GTK:
 gtk_display_init(ds, &dpy);
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] [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] 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




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>

[...]



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 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", &nextopt)) {
-request_opengl = 1;
 dpy.gl = true;
 } else if (strstart(opts, "off", &nextopt)) {
-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", &opts)) {
 #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", &nextopt)) {
-request_opengl = 1;
 dpy.gl = true;
 } else if (strstart(opts, "off", &nextopt)) {
-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] [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 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", &opts)) {
 #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", &opts)) {
 #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", &opts)) {
 #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", &opts)) {
 #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", &opts)) {
-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", &error_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.

[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] 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 *)&tmp_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 *)&tmp_mask,
>mask_length, sizeof(tmp_mask));
> 




[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 = &ev1;
+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) {
 no_shutdow

[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", &opts)) {
 #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 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(&dpy);
 }
 #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




[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




[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(&keycode_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 (strstart(p, "gt

[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&cz@Bj4BBfd|yV!NB
zwqkL}nW3AI5x^jp=t%^F1pxqp)v#n#)j$zcm1xqv(!$2d*5%vF{5RPWnOV8-^tE<(
zU~%&}Y0uNu*9Wt=yS^8PkC&gPueZO%IG;aD{l#sG`m4Ho*fsHXdM_(-i7fPIW
zA+~n9iy_f)g8B2RILhd%F)dZ5f?7pFLw)@;Ncl3Bz9<|!xm0F{45K+gg8#n
z4FNAJ!AN0A08g#Z9x|HJ$H)ZJi0004xF0SE*D03g5s00IDLSQelF
ziVX^$pfWNUJrmRhn2k52pQ;Rs0EQC;(S%|!m`2~BZ@b++;etskRJUVl!Kt)wu7?VN
zl;%JdqX2?TgsNVJP?87M*MvL1qQnBkCES&?0@MeaN-bL4;bDzxmMm|da4fuh!=#fu
g@i9R@5z!av{9tA

[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




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


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 mailto:yuval.sh...@oracle.com>>
> 
> 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 mailto:mar...@redhat.com>>
> 
> 
> 




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

2018-02-02 Thread Eric Blake
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

-- 
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 v5 11/14] input: add missing JIS keys to virtio input

2018-02-02 Thread Eduardo Habkost
On Fri, Feb 02, 2018 at 01:13:14PM +, Daniel P. Berrangé wrote:
> On Thu, Feb 01, 2018 at 06:46:46PM -0200, Eduardo Habkost wrote:
> > On Tue, Jan 16, 2018 at 01:42:14PM +, Daniel P. Berrange wrote:
> > > From: Miika S 
> > > 
> > > keycodemapdb updated to add the QKeyCodes muhenkan and katakanahiragana
> > > 
> > > Signed-off-by: Miika S 
> > 
> > Oops, this conflicts with:
> > 
> > commit ae6b06ab655b21c19b234ce3422f694d11a013e0
> > Author: Daniel P. Berrange 
> > Date:   Wed Jan 17 16:41:18 2018 +
> > 
> > hw: convert virtio-input-hid device to keycodemapdb
> > 
> > [...]
> > 
> > Patch 11/14 and 12/14 need to be redone.  I'm removing patches
> > 11-14 from python-next until this is sorted out.
> 
> You can literally just drop the patch chunk which touches
> the hw/input/virtio-input-hid.c file entirely, as that table
> is now auto-generated.  I can resend the series with that if
> you prefer though ?

I will do that when applying the patch.  Thanks!

-- 
Eduardo



Re: [Qemu-devel] Windows balloon driver PFN issue

2018-02-02 Thread Peter Xu
On Thu, Feb 01, 2018 at 02:48:20PM +0200, Michael S. Tsirkin wrote:

[...]

> > > > > PFN is GPA>>12.  Do you have more than 1<<44 bytes of memory in this 
> > > > > VM then?
> > > > 
> > > > No.  But isn't it still not good to drop the page at offset zero (and
> > > > drop it NNN times)?
> > > 
> > > Absolutely - looks like a bug. I just don't know why does this happen.
> > 
> > IMHO if we are using a PFN array like this:
> > 
> >u64 pfn_array[];
> > 
> > In the windows guest driver, then we'll see this (as mentioned
> > above).  But for sure this is wild guess of mine.
> 
> I don't see code like this anywhere in the windows balloon
> driver. It's here:
> https://github.com/virtio-win/kvm-guest-drivers-windows.git

Thanks for the pointer.  I had a quick glance, the PFN array is
defined as:

PPFN_NUMBER pfns_table;

But I don't know what's sizeof(PPFN_NUMBER). :(

-- 
Peter Xu



Re: [Qemu-devel] [PULL 0/7] Small IPMI fixes

2018-02-02 Thread Peter Maydell
On 1 February 2018 at 18:52,   wrote:
> The following changes since commit 6521130b0a7f699fdb82446d57df5627bfa7ed3c:
>
>   Merge remote-tracking branch 
> 'remotes/stefanberger/tags/pull-tpm-2018-01-26-2' into staging (2018-01-30 
> 15:20:01 +)
>
> are available in the git repository at:
>
>   https://github.com/cminyard/qemu.git tags/for-release-20180201
>
> for you to fetch changes up to 20b233641d76cc1812064304798ffeb530dc112d:
>
>   ipmi: Allow BMC device properties to be set (2018-01-30 15:52:53 -0600)
>
> 
> Lots of litte miscellaneous fixes for the IPMI code, plus
> add me as the IPMI maintainer.
>
> 

Applied, thanks.

PS: it would be useful if you could arrange to get your gpg key
signed by more people, as and when you have the opportunity for that.

-- PMM



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

2018-02-02 Thread Luiz Capitulino
On Fri, 2 Feb 2018 12:50:14 -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.

Agree. The only thing I'm unsure about is that, is the performance
issue only present in x86? If yes, then do we deprecate it only
for x86 or for all archs? Maybe for all archs, otherwise this has
the potential to turn into a mess.

> 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 guess we can't remove fields, but maybe we could always return
"running" and skip interrupting the vCPU threads.



[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"
-);
-dolog ("not implemented\n");
+qemu_log_mask(LOG_UNIMP

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


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 RFC 00/21] Modularize generated QAPI code

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

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

And of course

  * Needs a doc update

[...]



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] [PATCH v6 18/23] sev: emit the SEV_MEASUREMENT event

2018-02-02 Thread Brijesh Singh



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.


-Brijesh



[Qemu-devel] How to make memory mapped controller receive data?

2018-02-02 Thread Fangda Cai
Hi, I have built a virtual arm board that includes onboard memory-mapped
SPI controller and CAN controller. I also built a bare metal program that
can run on the virtual arm board. Is it possible to make the SPI/CAN
receive data during the bare-metal program running on the board? I don't
know how to achieve it, any ideas?


Re: [Qemu-devel] [PATCH v1 06/21] RISC-V FPU Support

2018-02-02 Thread Michael Clark
On Mon, Jan 29, 2018 at 12:33 PM, Jim Wilson  wrote:

> On Wed, Jan 24, 2018 at 3:47 PM, Richard Henderson
>  wrote:
> > On 01/24/2018 10:58 AM, Jim Wilson wrote:
> >> Although, looking at this again, I see another statement in a
> >> different place that says:
> >>
> >> Except when otherwise stated, if the result of a floating-point
> operation is
> >> NaN, it is the canonical NaN. The canonical NaN has a positive sign and
> all
> >> significand bits clear except the MSB, a.k.a. the quiet bit. For
> >> single-precision floating-point, this corresponds to the pattern
> >> 0x7fc0.
> > Yes, I had read this before as well.  I had assumed that your patch
> constituted
> > an intended change to this text.
> >
> >> This could take a little time to sort out.
> > Ok.  I don't see this as a blocking issue for merging.
>
> So after looking at this a bit more, I've come to the conclusion that
> my patch to remove the default/canonical nan support from RISC-V qemu
> was wrong.  We will have to fix this on the gcc/glibc side.
>
> Michael, please revert my change
> https://github.com/riscv/riscv-qemu/commit/
> 4223d89b0c5c671332d66bcd649db5c6f46559f5


Done.


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

2018-02-02 Thread Eric Blake
On 02/02/2018 05:10 AM, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann 
> ---
>  vl.c  | 8 
>  qemu-doc.texi | 6 ++
>  2 files changed, 14 insertions(+)
> 

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

Should the error message printed to the user document the new interface
to be used instead? But that implies that we shouldn't deprecate this
until the new interface for configuring hotkeys has been finalized...

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


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 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] 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 *)&tmp_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 *)&tmp_mask,
> >mask_length, sizeof(tmp_mask));
> >   
> 

Thanks, applied.



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




[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
--- a/hw/audio/marvell_88w8618.c
+++ b/hw/audio/marvell_88w8618.c
@@ -13,6 +1

[Qemu-devel] [PATCH] hw/timer/mt48t59: Fix bit-rotten NVRAM_PRINTF format strings

2018-02-02 Thread Thomas Huth
When compiling with NVRAM_PRINTF enabled, gcc currently bails out with:

  CC  hw/timer/m48t59.o
  CC  hw/timer/m48t59-isa.o
hw/timer/m48t59.c: In function ‘NVRAM_writeb’:
hw/timer/m48t59.c:460:5: error: format ‘%x’ expects argument of type ‘unsigned 
int’, but argument 3 has type ‘hwaddr’ [-Werror=format=]
 NVRAM_PRINTF("%s: 0x%08x => 0x%08x\n", __func__, addr, val);
 ^
hw/timer/m48t59.c:460:5: error: format ‘%x’ expects argument of type ‘unsigned 
int’, but argument 4 has type ‘uint64_t’ [-Werror=format=]
hw/timer/m48t59.c: In function ‘NVRAM_readb’:
hw/timer/m48t59.c:492:5: error: format ‘%x’ expects argument of type ‘unsigned 
int’, but argument 3 has type ‘hwaddr’ [-Werror=format=]
 NVRAM_PRINTF("%s: 0x%08x <= 0x%08x\n", __func__, addr, retval);

Fix it by using the correct format strings and while we're at it,
also change the definition of NVRAM_PRINTF so that this can not
bit-rot so easily again.

Signed-off-by: Thomas Huth 
---
 hw/timer/m48t59-internal.h | 9 +++--
 hw/timer/m48t59.c  | 4 ++--
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/hw/timer/m48t59-internal.h b/hw/timer/m48t59-internal.h
index 32ae957..d0f0caf 100644
--- a/hw/timer/m48t59-internal.h
+++ b/hw/timer/m48t59-internal.h
@@ -25,13 +25,10 @@
 #ifndef HW_M48T59_INTERNAL_H
 #define HW_M48T59_INTERNAL_H 1
 
-//#define DEBUG_NVRAM
+#define M48T59_DEBUG 0
 
-#if defined(DEBUG_NVRAM)
-#define NVRAM_PRINTF(fmt, ...) do { printf(fmt , ## __VA_ARGS__); } while (0)
-#else
-#define NVRAM_PRINTF(fmt, ...) do { } while (0)
-#endif
+#define NVRAM_PRINTF(fmt, ...) do { \
+if (M48T59_DEBUG) { printf(fmt , ## __VA_ARGS__); } } while (0)
 
 /*
  * The M48T02, M48T08 and M48T59 chips are very similar. The newer '59 has
diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index 844aad5..4abb4ac 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -457,7 +457,7 @@ static void NVRAM_writeb(void *opaque, hwaddr addr, 
uint64_t val,
 {
 M48t59State *NVRAM = opaque;
 
-NVRAM_PRINTF("%s: 0x%08x => 0x%08x\n", __func__, addr, val);
+NVRAM_PRINTF("%s: 0x%"HWADDR_PRIx" => 0x%"PRIx64"\n", __func__, addr, val);
 switch (addr) {
 case 0:
 NVRAM->addr &= ~0x00FF;
@@ -489,7 +489,7 @@ static uint64_t NVRAM_readb(void *opaque, hwaddr addr, 
unsigned size)
 retval = -1;
 break;
 }
-NVRAM_PRINTF("%s: 0x%08x <= 0x%08x\n", __func__, addr, retval);
+NVRAM_PRINTF("%s: 0x%"HWADDR_PRIx" <= 0x%08x\n", __func__, addr, retval);
 
 return retval;
 }
-- 
1.8.3.1




Re: [Qemu-devel] Qemu Trace

2018-02-02 Thread Stefan Hajnoczi
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


signature.asc
Description: PGP signature


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

2018-02-02 Thread Eric Blake
On 02/02/2018 05:10 AM, Gerd Hoffmann wrote:
> 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(-)

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 0/1] Dump patches

2018-02-02 Thread Peter Maydell
On 1 February 2018 at 11:16, Marc-André Lureau
 wrote:
> 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/elmarco/qemu.git tags/dump-pull-request
>
> for you to fetch changes up to ce6b9e421a9ab45d7e6c97af092a07c04995:
>
>   dump-guest-memory.py: skip vmcoreinfo section if not available (2018-02-01 
> 12:13:52 +0100)
>
> 
>
> 
>
> Marc-André Lureau (1):
>   dump-guest-memory.py: skip vmcoreinfo section if not available
>
>  scripts/dump-guest-memory.py | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks.

-- PMM



Re: [Qemu-devel] [PATCH RFC 01/21] qapi: Streamline boilerplate comment generation

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> Every generator has separate boilerplate for .h and .c, and their
> differences are boring.  All of them repeat the license note.
> 
> Reduce the repetition as follows.  Move common text like the license
> note to common open_output(), next to the existintg common text there.

s/existintg/existing/

> For each generator, replace the two separate descriptions by a single
> one.
> 
> While there, emit an "automatically generated" note into generated
> documentation, too.
> 
> Signed-off-by: Markus Armbruster 
> ---

> +++ b/scripts/qapi2texi.py
> @@ -282,7 +282,8 @@ def main(argv):
>  print >>sys.stderr, ("%s: need pragma 'doc-required' "
>   "to generate documentation" % argv[0])
>  sys.exit(1)
> -print texi_schema(schema)
> +print '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n'
> +print texi_schema(schema),

Spurious addition of trailing comma. Otherwise,

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 17/39] qcow2: Update l2_allocate() to support L2 slices

2018-02-02 Thread Alberto Garcia
On Thu 01 Feb 2018 07:15:23 PM CET, Max Reitz  wrote:
 -static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t 
 **table)
 +static int l2_allocate(BlockDriverState *bs, int l1_index)
  {
  BDRVQcow2State *s = bs->opaque;
  uint64_t old_l2_offset;
 -uint64_t *l2_table = NULL;
 +uint64_t *l2_slice = NULL;
 +unsigned slice, slice_size2, n_slices;
>>>
>>> I'd personally prefer size_t, but oh well.
>> 
>> I don't see any reason not to use int / unsigned. The size of a slice
>> is always <= cluster_size (an int), and both slice and n_slices are
>> smaller than that.
>
> Well, what's the reason to use unsigned? :-)
> The type of the expression used to set slice_size2 simply is size_t.

I tend to choose the type of a variable based on what it's going to
hold, and use int (signed or not) whenever possible.

In this case a normal integer can certainly hold all possible values of
slice_size2. And unsigned because it's never going to be negative. It
could also be signed, it's not going to be any different in practice,
it's just more explicit.

Berto



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

2018-02-02 Thread Max Reitz
On 2018-02-02 16:18, Vladimir Sementsov-Ogievskiy wrote:
> 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.

I mean in the "Deprecated features" appendix.  I think whenever we
deprecate something, it should be noted there (as far as I've understood).

(Also on the Wiki, I think.)

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

There is docs/interop/qemu-qmp-qapi.texi in the build directory.

Max



signature.asc
Description: OpenPGP digital signature


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

2018-02-02 Thread Alberto Garcia
On Thu 01 Feb 2018 08:46:46 PM CET, Max Reitz  wrote:
>> @@ -3261,8 +3261,9 @@ static int qcow2_truncate(BlockDriverState *bs, 
>> int64_t offset,
>>  guest_offset = old_length;
>>  while (nb_new_data_clusters) {
>>  int64_t guest_cluster = guest_offset >> s->cluster_bits;
>> -int64_t nb_clusters = MIN(nb_new_data_clusters,
>> -  s->l2_size - guest_cluster % 
>> s->l2_size);
>> +int64_t nb_clusters = MIN(
>> +nb_new_data_clusters,
>> +s->l2_slice_size - guest_cluster % s->l2_slice_size);
>
> An alternative would be the
> "s->l2_slice_size - offset_to_l2_slice_index(s, guest_offset)" we
> basically have elsewhere, but that's longer and doesn't really matter:

It's a bit longer but it looks better and we can get rid of
guest_cluster, so I think I'll change it.

Berto



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

2018-02-02 Thread Dr. David Alan Gilbert
* Brijesh Singh (brijesh.si...@amd.com) wrote:
> 
> 
> 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).

Yes, that would be useful - I'm sure there's lots of information that
will be useful to display for understanding the state of SEV, e.g. the
policies etc.

Dave

> >
> > Regards,
> > Daniel
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



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

2018-02-02 Thread Daniel P . Berrangé
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.

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



[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) $(SRC_PATH)/scripts/qapi-visit.py \
-

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 
> > > *)&tmp_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 *)&tmp_mask,
> > >mask_length, sizeof(tmp_mask));
> > > 
> >   
> 
> Thanks, applied.

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



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 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 03/21] qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc

2018-02-02 Thread Markus Armbruster
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(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index a861ac52e7..4be7dbc482 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -260,12 +260,10 @@ blurb = '''
  * Schema-defined QAPI/QMP commands
 '''
 
-(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
-'qmp-marshal.c', 'qmp-commands.h',
-blurb, __doc__)
-
-fdef.write(mcgen('''
+genc = QAPIGenC(blurb, __doc__)
+genh = QAPIGenH(blurb, __doc__)
 
+genc.body(mcgen('''
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/module.h"
@@ -279,21 +277,24 @@ fdef.write(mcgen('''
 #include "%(prefix)sqmp-commands.h"
 
 ''',
- prefix=prefix))
+prefix=prefix))
 
-fdecl.write(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)))
+prefix=prefix, c_prefix=c_name(prefix, protect=False)))
 
 schema = QAPISchema(input_file)
-gen = QAPISchemaGenCommandVisitor()
-schema.visit(gen)
-fdef.write(gen.defn)
-fdecl.write(gen.decl)
+vis = QAPISchemaGenCommandVisitor()
+schema.visit(vis)
+genc.body(vis.defn)
+genh.body(vis.decl)
 
-close_output(fdef, fdecl)
+if do_c:
+genc.write(output_dir, prefix + 'qmp-marshal.c')
+if do_h:
+genh.write(output_dir, prefix + 'qmp-commands.h')
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index b1d611c5ea..da3de17c76 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -176,11 +176,10 @@ blurb = '''
  * Schema-defined QAPI/QMP events
 '''
 
-(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
-'qapi-event.c', 'qapi-event.h',
-blurb, __doc__)
+genc = QAPIGenC(blurb, __doc__)
+genh = QAPIGenH(blurb, __doc__)
 
-fdef.write(mcgen('''
+genc.body(mcgen('''
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "%(prefix)sqapi-event.h"
@@ -190,22 +189,25 @@ fdef.write(mcgen('''
 #include "qapi/qmp-event.h"
 
 ''',
- prefix=prefix))
+prefix=prefix))
 
-fdecl.write(mcgen('''
+genh.body(mcgen('''
 #include "qapi/util.h"
 #include "qapi/qmp/qdict.h"
 #include "%(prefix)sqapi-types.h"
 
 ''',
-  prefix=prefix))
+prefix=prefix))
 
 event_enum_name = c_name(prefix + 'QAPIEvent', protect=False)
 
 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)
 
-close_output(fdef, fdecl)
+if do_c:
+genc.write(output_dir, prefix + 'qapi-event.c')
+if do_h:
+genh.write(output_dir, prefix + 'qapi-event.h')
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index bd9253a172..c654f8fa94 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -181,21 +181,23 @@ blurb = '''
  * QAPI/QMP schema introspection
 '''
 
-(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
-'qmp-introspect.c', 'qmp-introspect.h',
-blurb, __doc__)
+genc = QAPIGenC(blurb, __doc__)
+genh = QAPIGenH(blurb, __doc__)
 
-fdef.write(mcgen('''
+genc.body(mcgen('''
 #include "qemu/osdep.h"
 #include "%(prefix)sqmp-introspect.h"
 
 ''',
- prefix=prefix))
+prefix=prefix))
 
 schema = QAPISchema(input_file)
-gen = QAPISchemaGenIntrospectVisitor(opt_unmask)
-schema.visit(gen)
-fdef.write(gen.defn)
-fdecl.write(gen.decl)
+vis = QAPISchemaGenIntrospectVisitor(opt_unmask)
+schema.visit(vis)
+genc.body(vis.defn)
+genh.body(vis.decl)
 
-close_output(fdef, fdecl)
+if do_c:
+genc.write(output_dir, prefix + 'qmp-introspect.c')
+if do_h:
+genh.write(output_dir, prefix + 'qmp-introspect.h')
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 1103dbda2d..974

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

2018-02-02 Thread Alberto Garcia
On Thu 01 Feb 2018 07:44:56 PM CET, Max Reitz  wrote:
> On 2018-01-26 15:59, Alberto Garcia wrote:
>> There's a loop in this function that iterates over the L2 entries in a
>> table, so now we need to assert that it remains within the limits of
>> an L2 slice.
>> 
>> Apart from that, this function doesn't need any additional changes, so
>> this patch simply updates the variable name from l2_table to l2_slice.
>> 
>> Signed-off-by: Alberto Garcia 
>> Reviewed-by: Eric Blake 
>> ---
>>  block/qcow2-cluster.c | 16 
>>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> Hm, well, strictly speaking this patch should not be at this point in
> this series -- e.g. handle_alloc() so far only limits its nb_clusters to
> the L2 size, not the L2 slice size.

Yeah, I didn't try to be too strict with this because you can only
change the slice size after everything else is ready.

Berto



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

2018-02-02 Thread Alberto Garcia
On Thu 01 Feb 2018 08:26:26 PM CET, Max Reitz  wrote:
>> @@ -1273,12 +1276,13 @@ int qcow2_update_snapshot_refcount(BlockDriverState 
>> *bs,
>>  case QCOW2_CLUSTER_NORMAL:
>>  case QCOW2_CLUSTER_ZERO_ALLOC:
>>  if (offset_into_cluster(s, offset)) {
>> +int l2_index = slice * s->l2_slice_size + j;
>>  qcow2_signal_corruption(
>>  bs, true, -1, -1, "Cluster "
>>  "allocation offset %#" PRIx64
>>  " unaligned (L2 offset: %#"
>>  PRIx64 ", L2 index: %#x)",
>> -offset, l2_offset, j);
>> +offset, l2_offset, l2_index);
>
> This makes it a bit weird that in other patches l2_index is now
> generally the L2 slice index...

You're right, I can call it l2_table_index, I think this is the only
case where it does not refer to the slice index.

Berto



[Qemu-devel] [PATCH RFC 13/21] qapi: Record 'include' directives in parse tree

2018-02-02 Thread Markus Armbruster
The parse tree is a list of expressions.  Except include expressions
currently get replaced by the included file's parse tree.

Instead of throwing away the include expression, keep it with the file
name expanded so you don't have to track the including file's
directory to make sense of it.

A future commit will put this include expression to use.

Signed-off-by: Markus Armbruster 
---
 scripts/qapi/common.py | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 7a327bfe9f..d5b93e7381 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -286,8 +286,11 @@ class QAPISchemaParser(object):
 if not isinstance(include, str):
 raise QAPISemError(info,
"Value of 'include' must be a string")
-exprs_include = self._include(include, info,
-  os.path.dirname(self.fname),
+incl_fname = os.path.join(os.path.dirname(self.fname),
+  include)
+self.exprs.append({'expr': {'include': incl_fname},
+   'info': info})
+exprs_include = self._include(include, info, incl_fname,
   previously_included)
 if exprs_include:
 self.exprs.extend(exprs_include.exprs)
@@ -322,8 +325,7 @@ class QAPISchemaParser(object):
 "Documentation for '%s' is not followed by the definition"
 % doc.symbol)
 
-def _include(self, include, info, base_dir, previously_included):
-incl_fname = os.path.join(base_dir, include)
+def _include(self, include, info, incl_fname, previously_included):
 incl_abs_fname = os.path.abspath(incl_fname)
 # catch inclusion cycle
 inf = info
@@ -889,6 +891,9 @@ def check_exprs(exprs):
 info = expr_elem['info']
 doc = expr_elem.get('doc')
 
+if 'include' in expr:
+continue
+
 if not doc and doc_required:
 raise QAPISemError(info,
"Expression missing documentation comment")
@@ -927,6 +932,9 @@ def check_exprs(exprs):
 
 # Try again for hidden UnionKind enum
 for expr_elem in exprs:
+if 'include' in expr:
+continue
+
 expr = expr_elem['expr']
 if 'union' in expr and not discriminator_find_enum_define(expr):
 name = '%sKind' % expr['union']
@@ -939,6 +947,9 @@ def check_exprs(exprs):
 
 # Validate that exprs make sense
 for expr_elem in exprs:
+if 'include' in expr:
+continue
+
 expr = expr_elem['expr']
 info = expr_elem['info']
 doc = expr_elem.get('doc')
@@ -1663,6 +1674,8 @@ class QAPISchema(object):
 self._def_command(expr, info, doc)
 elif 'event' in expr:
 self._def_event(expr, info, doc)
+elif 'include' in expr:
+pass
 else:
 assert False
 
-- 
2.13.6




[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', 'qlist', 'qbool']
 pref

[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 is licensed under the terms of the GNU GPL, version 2.
+"""
+QAPI types generator
+
+Copyright IBM, Corp. 2011
+Copyright (c) 2013-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 impo

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

2018-02-02 Thread Vladimir Sementsov-Ogievskiy

02.02.2018 18:23, Max Reitz wrote:

On 2018-02-02 16:18, Vladimir Sementsov-Ogievskiy wrote:

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.

I mean in the "Deprecated features" appendix.  I think whenever we
deprecate something, it should be noted there (as far as I've understood).


Ok, understand, will add. (hmm no section for QMP in this appendix, I'll 
be the first =(




(Also on the Wiki, I think.)


nothing about autoload and persistent parameters in the wiki ( 
https://wiki.qemu.org/Features/IncrementalBackup , nothing else ? ). 
Hovewer, it is good idea to update material in wiki, I'll think about it.





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

There is docs/interop/qemu-qmp-qapi.texi in the build directory.

Max




--
Best regards,
Vladimir




[Qemu-devel] [PATCH RFC 09/21] qapi: Don't absolutize include file name in error messages

2018-02-02 Thread Markus Armbruster
Error messages print absolute filenames of included files even gave a
relative one on the command line:

 PYTHONPATH=scripts python -B tests/qapi-schema/test-qapi.py 
tests/qapi-schema/include-cycle.json
In file included from tests/qapi-schema/include-cycle.json:1:
In file included from 
/work/armbru/qemu/tests/qapi-schema/include-cycle-b.json:1:
/work/armbru/qemu/tests/qapi-schema/include-cycle-c.json:1: Inclusion loop 
for include-cycle.json

Improve this to

In file included from tests/qapi-schema/include-cycle.json:1:
In file included from tests/qapi-schema/include-cycle-b.json:1:
tests/qapi-schema/include-cycle-c.json:1: Inclusion loop for 
include-cycle.json

Signed-off-by: Markus Armbruster 
---
 scripts/qapi/common.py| 12 ++--
 tests/qapi-schema/include-no-file.err |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index be0fcc548a..6c6962a364 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -255,9 +255,8 @@ class QAPIDoc(object):
 class QAPISchemaParser(object):
 
 def __init__(self, fp, previously_included=[], incl_info=None):
-abs_fname = os.path.abspath(fp.name)
 self.fname = fp.name
-previously_included.append(abs_fname)
+previously_included.append(os.path.abspath(fp.name))
 self.incl_info = incl_info
 self.src = fp.read()
 if self.src == '' or self.src[-1] != '\n':
@@ -288,7 +287,7 @@ class QAPISchemaParser(object):
 if not isinstance(include, str):
 raise QAPISemError(info,
"Value of 'include' must be a string")
-self._include(include, info, os.path.dirname(abs_fname),
+self._include(include, info, os.path.dirname(self.fname),
   previously_included)
 elif "pragma" in expr:
 self.reject_expr_doc(cur_doc)
@@ -321,7 +320,8 @@ class QAPISchemaParser(object):
 % doc.symbol)
 
 def _include(self, include, info, base_dir, previously_included):
-incl_abs_fname = os.path.join(base_dir, include)
+incl_fname = os.path.join(base_dir, include)
+incl_abs_fname = os.path.abspath(incl_fname)
 # catch inclusion cycle
 inf = info
 while inf:
@@ -333,9 +333,9 @@ class QAPISchemaParser(object):
 if incl_abs_fname in previously_included:
 return
 try:
-fobj = open(incl_abs_fname, 'r')
+fobj = open(incl_fname, 'r')
 except IOError as e:
-raise QAPISemError(info, '%s: %s' % (e.strerror, include))
+raise QAPISemError(info, '%s: %s' % (e.strerror, incl_fname))
 exprs_include = QAPISchemaParser(fobj, previously_included, info)
 self.exprs.extend(exprs_include.exprs)
 self.docs.extend(exprs_include.docs)
diff --git a/tests/qapi-schema/include-no-file.err 
b/tests/qapi-schema/include-no-file.err
index d5b9b22d85..e42bcf4bc1 100644
--- a/tests/qapi-schema/include-no-file.err
+++ b/tests/qapi-schema/include-no-file.err
@@ -1 +1 @@
-tests/qapi-schema/include-no-file.json:1: No such file or directory: 
include-no-file-sub.json
+tests/qapi-schema/include-no-file.json:1: No such file or directory: 
tests/qapi-schema/include-no-file-sub.json
-- 
2.13.6




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

2018-02-02 Thread Alberto Garcia
On Thu 01 Feb 2018 08:07:15 PM CET, Max Reitz  wrote:
> On 2018-01-26 15:59, Alberto Garcia wrote:
>> discard_single_l2() limits the number of clusters to be discarded to
>> the amount that fits inside an L2 table. Since we'll be loading L2
>> slices instead of full tables we need to update that limit.
>
> H, maybe rename the function to discard_l2_slice() or
> discard_in_l2_slice() or discard_all_in_l2_slice() or
> discard_single_l2_slice()?

Good idea, I think I that will change that (also the related comment in
qcow2_cluster_discard()).

Berto



[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




[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




[Qemu-devel] [PATCH RFC 12/21] qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()

2018-02-02 Thread Markus Armbruster
Signed-off-by: Markus Armbruster 
---
 scripts/qapi/common.py | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index d334e1db5a..7a327bfe9f 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -286,8 +286,12 @@ class QAPISchemaParser(object):
 if not isinstance(include, str):
 raise QAPISemError(info,
"Value of 'include' must be a string")
-self._include(include, info, os.path.dirname(self.fname),
-  previously_included)
+exprs_include = self._include(include, info,
+  os.path.dirname(self.fname),
+  previously_included)
+if exprs_include:
+self.exprs.extend(exprs_include.exprs)
+self.docs.extend(exprs_include.docs)
 elif "pragma" in expr:
 self.reject_expr_doc(cur_doc)
 if len(expr) != 1:
@@ -330,14 +334,13 @@ class QAPISchemaParser(object):
 
 # skip multiple include of the same file
 if incl_abs_fname in previously_included:
-return
+return None
+
 try:
 fobj = open(incl_fname, 'r')
 except IOError as e:
 raise QAPISemError(info, '%s: %s' % (e.strerror, incl_fname))
-exprs_include = QAPISchemaParser(fobj, previously_included, info)
-self.exprs.extend(exprs_include.exprs)
-self.docs.extend(exprs_include.docs)
+return QAPISchemaParser(fobj, previously_included, info)
 
 def _pragma(self, name, value, info):
 global doc_required, returns_whitelist, name_case_whitelist
-- 
2.13.6




[Qemu-devel] [PATCH RFC 01/21] qapi: Streamline boilerplate comment generation

2018-02-02 Thread Markus Armbruster
Every generator has separate boilerplate for .h and .c, and their
differences are boring.  All of them repeat the license note.

Reduce the repetition as follows.  Move common text like the license
note to common open_output(), next to the existintg common text there.
For each generator, replace the two separate descriptions by a single
one.

While there, emit an "automatically generated" note into generated
documentation, too.

Signed-off-by: Markus Armbruster 
---
 scripts/qapi-commands.py| 26 +++---
 scripts/qapi-event.py   | 26 +++---
 scripts/qapi-introspect.py  | 21 ++---
 scripts/qapi-types.py   | 26 +++---
 scripts/qapi-visit.py   | 26 +++---
 scripts/qapi.py | 31 ++-
 scripts/qapi2texi.py|  3 ++-
 tests/qapi-schema/doc-good.texi |  3 ++-
 8 files changed, 36 insertions(+), 126 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 26c56c5062..25ac52503a 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -255,38 +255,18 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
 
 (input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
 
-c_comment = '''
-/*
- * schema-defined QMP->QAPI command dispatch
+blurb = '''
+ * Schema-defined QAPI/QMP commands
  *
  * Copyright IBM, Corp. 2011
  *
  * Authors:
  *  Anthony Liguori   
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-'''
-h_comment = '''
-/*
- * schema-defined QAPI function prototypes
- *
- * Copyright IBM, Corp. 2011
- *
- * Authors:
- *  Anthony Liguori   
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
 '''
 
 (fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
 'qmp-marshal.c', 'qmp-commands.h',
-c_comment, h_comment)
+blurb)
 
 fdef.write(mcgen('''
 
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 9d7134658d..31faedc689 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -171,38 +171,18 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
 
 (input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
 
-c_comment = '''
-/*
- * schema-defined QAPI event functions
+blurb = '''
+ * Schema-defined QAPI/QMP events
  *
  * Copyright (c) 2014 Wenchao Xia
  *
  * Authors:
  *  Wenchao Xia   
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-'''
-h_comment = '''
-/*
- * schema-defined QAPI event functions
- *
- * Copyright (c) 2014 Wenchao Xia
- *
- * Authors:
- *  Wenchao Xia  
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
 '''
 
 (fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
 'qapi-event.c', 'qapi-event.h',
-c_comment, h_comment)
+blurb)
 
 fdef.write(mcgen('''
 #include "qemu/osdep.h"
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 032bcea491..83da2bdb94 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -176,32 +176,15 @@ for o, a in opts:
 if o in ('-u', '--unmask-non-abi-names'):
 opt_unmask = True
 
-c_comment = '''
-/*
+blurb = '''
  * QAPI/QMP schema introspection
  *
  * Copyright (C) 2015 Red Hat, Inc.
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-'''
-h_comment = '''
-/*
- * QAPI/QMP schema introspection
- *
- * Copyright (C) 2015 Red Hat, Inc.
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
 '''
 
 (fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
 'qmp-introspect.c', 'qmp-introspect.h',
-c_comment, h_comment)
+blurb)
 
 fdef.write(mcgen('''
 #include "qemu/osdep.h"
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 7e3051dbb9..86afc57f92 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -250,39 +250,19 @@ for o, a in opts:
 if o in ('-b', '--builtins'):
 do_builtins = True
 
-c_comment = '''
-/*
- * deallocation functions for schema-defined QAPI types
+blurb = '''
+ * Schema-defined QAPI types
  *
  * Copyright IBM, Corp. 2011
  *
  * Authors:
  *  Anthony Liguori   
  *  Michael Roth  
- *
- * This work is licensed under the terms of the

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 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
+++ b/scripts/qapi-types.py
@@

[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
--- a/scripts/qapi/types.py
+++ b/scripts/qapi

  1   2   3   >