Re: [Qemu-devel] [PATCH v7 12/15] hw/timer: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
Philippe Mathieu-Daudé  writes:

> On 02/02/2018 03:37 PM, Markus Armbruster wrote:
>> From: Alistair Francis 
>> 
>> Replace a large number of the fprintf(stderr, "*\n" calls with
>> error_report(). The functions were renamed with these commands and then
>> compiler issues where manually fixed.
>> 
>> find ./* -type f -exec sed -i \
>> 'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N;N;N;N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N;N;N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N;N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N;N; {s|fprintf(stderr, 
>> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> find ./* -type f -exec sed -i \
>> 'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
>> {} +
>> 
>> Some lines where then manually tweaked to pass checkpatch.
>> 
>> Signed-off-by: Alistair Francis 
>> 
>> Conversions that aren't followed by exit() dropped, because they might
>> be inappropriate.
>> 
>> Signed-off-by: Markus Armbruster 
>> ---
>>  hw/timer/xilinx_timer.c | 10 +-
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>> 
>> diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c
>> index 59439c05be..2d658b5791 100644
>> --- a/hw/timer/xilinx_timer.c
>> +++ b/hw/timer/xilinx_timer.c
>> @@ -127,7 +127,7 @@ timer_read(void *opaque, hwaddr addr, unsigned int size)
>>  break;
>>  
>>  }
>> -D(fprintf(stderr, "%s timer=%d %x=%x\n", __func__, timer, addr * 4, r));
>> +D(error_report("%s timer=%d %x=%x", __func__, timer, addr * 4, r));
>
> Not sure what we gain here, since those aren't error messages but trace
> event.
> Can you drop this patch from your series? I'll convert to tracepoints
> and send a patch for this file.

Done.  Thanks!



Re: [Qemu-devel] [PATCH v7 15/15] target: Use qemu_log() instead of fprintf(stderr, ...)

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

> On 02/02/2018 12:37 PM, Markus Armbruster wrote:
>> From: Alistair Francis 
>> 
>> Convert fprintf(stderr, ...) to use qemu_log(). Double prints in
>> target/ppc/translate.c were manually remove. A fprintf() in
>> target/sh4/translate.c was kept as it's inside a #if 0. The #if 0 and
>> fflush() was removed around the unimplemented log in
>> target/sh4/translate.c as well.
>> 
>> Signed-off-by: Alistair Francis 
>> [Trivial conflict with 6f1c2af641d resolved]
>> Signed-off-by: Markus Armbruster 
>> ---
>>  dtc  |  2 +-
>>  target/cris/translate.c  |  2 +-
>>  target/ppc/translate.c   | 36 ++--
>>  target/sh4/translate.c   |  7 ++-
>>  target/unicore32/translate.c |  2 +-
>>  5 files changed, 15 insertions(+), 34 deletions(-)
>> 
>> diff --git a/dtc b/dtc
>> index e54388015a..558cd81bdd 16
>> --- a/dtc
>> +++ b/dtc
>> @@ -1 +1 @@
>> -Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42
>> +Subproject commit 558cd81bdd432769b59bff01240c44f82cfb1a9d
>
> Intentional?

Rebase accident, good catch!



[Qemu-devel] [PATCH v2 1/3] block/iscsi: drop unused IscsiAIOCB->buf field

2018-02-02 Thread Stefan Hajnoczi
The IscsiAIOCB->buf field has not been used since commit
e49ab19fcaa617ad6cdfe1ac401327326b6a2552 ("block/iscsi: bump libiscsi
requirement to 1.9.0").  It used to be a linear buffer for old libiscsi
versions that didn't support scatter-gather.  The minimum libiscsi
version supports scatter-gather so we don't linearize buffers anymore.

Signed-off-by: Stefan Hajnoczi 
---
 block/iscsi.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 6a1c53711a..cd0738942c 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -112,7 +112,6 @@ typedef struct IscsiAIOCB {
 QEMUBH *bh;
 IscsiLun *iscsilun;
 struct scsi_task *task;
-uint8_t *buf;
 int status;
 int64_t sector_num;
 int nb_sectors;
@@ -145,9 +144,6 @@ iscsi_bh_cb(void *p)
 
 qemu_bh_delete(acb->bh);
 
-g_free(acb->buf);
-acb->buf = NULL;
-
 acb->common.cb(acb->common.opaque, acb->status);
 
 if (acb->task != NULL) {
@@ -925,9 +921,6 @@ iscsi_aio_ioctl_cb(struct iscsi_context *iscsi, int status,
 {
 IscsiAIOCB *acb = opaque;
 
-g_free(acb->buf);
-acb->buf = NULL;
-
 acb->status = 0;
 if (status < 0) {
 error_report("Failed to ioctl(SG_IO) to iSCSI lun. %s",
@@ -1002,7 +995,6 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
 acb->iscsilun = iscsilun;
 acb->bh  = NULL;
 acb->status  = -EINPROGRESS;
-acb->buf = NULL;
 acb->ioh = buf;
 
 if (req != SG_IO) {
-- 
2.14.3




[Qemu-devel] [PATCH v2 0/3] block/iscsi: fix ioctl cancel use-after-free

2018-02-02 Thread Stefan Hajnoczi
v2:
 * It was unnecessary to avoid duplicate iscsi_schedule_bh() calls since this
   function already protects against duplicate calls internally [Stefan]

Patches 1 & 2 are cleanups.

Patch 3 fixes cancellation of ioctls.  Felipe showed me a trace where an acb is
cancelled and then completes twice.  The second time around crashes QEMU.

Compile-tested only.

Felipe: Please let us know if this fixes the issue you are seeing.  Thanks!

Stefan Hajnoczi (3):
  block/iscsi: drop unused IscsiAIOCB->buf field
  block/iscsi: take iscsilun->mutex in iscsi_timed_check_events()
  block/iscsi: fix ioctl cancel use-after-free

 block/iscsi.c | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

-- 
2.14.3




[Qemu-devel] [PATCH v2 2/3] block/iscsi: take iscsilun->mutex in iscsi_timed_check_events()

2018-02-02 Thread Stefan Hajnoczi
Commit d045c466d9e62b4321fadf586d024d54ddfd8bd4 ("iscsi: do not use
aio_context_acquire/release") introduced iscsilun->mutex but appears to
have overlooked iscsi_timed_check_events() when introducing the mutex.

iscsi_service() and iscsi_set_events() must be called with
iscsilun->mutex held.

iscsi_timed_check_events() is invoked from the AioContext and does not
take the mutex.

Signed-off-by: Stefan Hajnoczi 
---
 block/iscsi.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/block/iscsi.c b/block/iscsi.c
index cd0738942c..1cfe1c647c 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -339,6 +339,8 @@ static void iscsi_timed_check_events(void *opaque)
 {
 IscsiLun *iscsilun = opaque;
 
+qemu_mutex_lock(&iscsilun->mutex);
+
 /* check for timed out requests */
 iscsi_service(iscsilun->iscsi, 0);
 
@@ -351,6 +353,8 @@ static void iscsi_timed_check_events(void *opaque)
  * to return to service once this situation changes. */
 iscsi_set_events(iscsilun);
 
+qemu_mutex_unlock(&iscsilun->mutex);
+
 timer_mod(iscsilun->event_timer,
   qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL);
 }
-- 
2.14.3




[Qemu-devel] [PATCH v2 3/3] block/iscsi: fix ioctl cancel use-after-free

2018-02-02 Thread Stefan Hajnoczi
iscsi_aio_cancel() does not increment the request's reference count,
causing a use-after-free when ABORT TASK finishes after the request has
already completed.

There are some additional issues with iscsi_aio_cancel():
1. Several ABORT TASKs may be sent for the same task if
   iscsi_aio_cancel() is invoked multiple times.  It's better to avoid
   this just in case the command identifier is reused.
2. The iscsilun->mutex protection is missing in iscsi_aio_cancel().

Reported-by: Felipe Franciosi 
Signed-off-by: Stefan Hajnoczi 
---
 block/iscsi.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 1cfe1c647c..8140baac15 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -119,6 +119,7 @@ typedef struct IscsiAIOCB {
 #ifdef __linux__
 sg_io_hdr_t *ioh;
 #endif
+bool cancelled;
 } IscsiAIOCB;
 
 /* libiscsi uses time_t so its enough to process events every second */
@@ -282,6 +283,7 @@ static void iscsi_co_init_iscsitask(IscsiLun *iscsilun, 
struct IscsiTask *iTask)
 };
 }
 
+/* Called (via iscsi_service) with QemuMutex held. */
 static void
 iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void 
*command_data,
 void *private_data)
@@ -290,6 +292,7 @@ iscsi_abort_task_cb(struct iscsi_context *iscsi, int 
status, void *command_data,
 
 acb->status = -ECANCELED;
 iscsi_schedule_bh(acb);
+qemu_aio_unref(acb); /* acquired in iscsi_aio_cancel() */
 }
 
 static void
@@ -298,14 +301,25 @@ iscsi_aio_cancel(BlockAIOCB *blockacb)
 IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
 IscsiLun *iscsilun = acb->iscsilun;
 
-if (acb->status != -EINPROGRESS) {
+qemu_mutex_lock(&iscsilun->mutex);
+
+/* If it was cancelled or completed already, our work is done here */
+if (acb->cancelled || acb->status != -EINPROGRESS) {
+qemu_mutex_unlock(&iscsilun->mutex);
 return;
 }
 
+acb->cancelled = true;
+
+qemu_aio_ref(acb); /* released in iscsi_abort_task_cb() */
+
 /* send a task mgmt call to the target to cancel the task on the target */
-iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
- iscsi_abort_task_cb, acb);
+if (iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+ iscsi_abort_task_cb, acb) < 0) {
+qemu_aio_unref(acb); /* since iscsi_abort_task_cb() won't be called */
+}
 
+qemu_mutex_unlock(&iscsilun->mutex);
 }
 
 static const AIOCBInfo iscsi_aiocb_info = {
@@ -1000,6 +1014,7 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
 acb->bh  = NULL;
 acb->status  = -EINPROGRESS;
 acb->ioh = buf;
+acb->cancelled   = false;
 
 if (req != SG_IO) {
 iscsi_ioctl_handle_emulated(acb, req, buf);
-- 
2.14.3




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

2018-02-02 Thread no-reply
Hi,

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

Type: series
Message-id: 20180202130336.24719-1-arm...@redhat.com
Subject: [Qemu-devel] [PATCH RFC 00/21] Modularize generated QAPI code

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
20edfbb769 qapi: Empty out qapi-schema.json
908a02511e Include less of qapi-types.h
cc0f486390 qapi/types: Generate separate .h, .c for each module
da8bb99aca qapi/common: Fix guardname() for funny filenames
c8a5aa0179 qapi/types qapi/visit: Generate built-in stuff into separate files
799da1022d qapi/types qapi/visit: Make visitors use QAPIGen more
1755f6ed36 qapi: Record 'include' directives in intermediate representation
4e1183baa6 qapi: Generate in source order
b9771d2e65 qapi: Record 'include' directives in parse tree
656629e139 qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()
1bc777d460 qapi: Lift error reporting from QAPISchema.__init__() to callers
c531a76a97 qapi/common: Eliminate QAPISchema.exprs
7f7062dc58 qapi: Don't absolutize include file name in error messages
bd75734a2c qapi: Touch generated files only when they change
a4e94e3e75 qapi: Move parse_command_line() next to its only use
b9b12fa6c6 qapi-gen: New common driver for code and doc generators
3a56fc45c2 qapi: Turn generators into modules
c09593eb74 qapi: Reduce use of global variables in generators some
4e457ceed8 qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc
d969856a53 qapi: Generate up-to-date copyright notice
a295c600fc qapi: Streamline boilerplate comment generation

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-t2c_u19x/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
  BUILD   min-glib
  GEN 
/var/tmp/patchew-tester-tmp-t2c_u19x/src/docker-src.2018-02-02-17.13.16.3631/qemu.tar
Cloning into 
'/var/tmp/patchew-tester-tmp-t2c_u19x/src/docker-src.2018-02-02-17.13.16.3631/qemu.tar.vroot'...
done.
Checking out files:  44% (2583/5779)   
Checking out files:  45% (2601/5779)   
Checking out files:  46% (2659/5779)   
Checking out files:  47% (2717/5779)   
Checking out files:  48% (2774/5779)   
Checking out files:  49% (2832/5779)   
Checking out files:  50% (2890/5779)   
Checking out files:  51% (2948/5779)   
Checking out files:  52% (3006/5779)   
Checking out files:  53% (3063/5779)   
Checking out files:  54% (3121/5779)   
Checking out files:  55% (3179/5779)   
Checking out files:  56% (3237/5779)   
Checking out files:  57% (3295/5779)   
Checking out files:  58% (3352/5779)   
Checking out files:  59% (3410/5779)   
Checking out files:  60% (3468/5779)   
Checking out files:  61% (3526/5779)   
Checking out files:  62% (3583/5779)   
Checking out files:  63% (3641/5779)   
Checking out files:  64% (3699/5779)   
Checking out files:  65% (3757/5779)   
Checking out files:  66% (3815/5779)   
Checking out files:  67% (3872/5779)   
Checking out files:  68% (3930/5779)   
Checking out files:  69% (3988/5779)   
Checking out files:  70% (4046/5779)   
Checking out files:  71% (4104/5779)   
Checking out files:  72% (4161/5779)   
Checking out files:  73% (4219/5779)   
Checking out files:  74% (4277/5779)   
Checking out files:  75% (4335/5779)   
Checking out files:  76% (4393/5779)   
Checking out files:  77% (4450/5779)   
Checking out files:  78% (4508/5779)   
Checking out files:  79% (4566/5779)   
Checking out files:  80% (4624/5779)   
Checking out files:  81% (4681/5779)   
Checking out files:  82% (4739/5779)   
Checking out files:  83% (4797/5779)   
Checking out files:  84% (4855/5779)   
Checking out files:  85% (4913/5779)   
Checking out files:  86% (4970/5779)   
Checking out files:  87% (5028/5779)   
Checking out files:  88% (5086/5779)   
Checking out files:  89% (5144/5779)   
Checking out files:  90% (5202/5779)   
Checking out files:  91% (5259/5779)   
Checking out files:  92% (5317/5779)   
Checking out files:  93% (5375/5779)   
Checking out files:  94% (5433/5779)   
Checking out files:  95% (5491/5779)   
Checking out files:  96% (5548/5779)   
Checking out files:  97% (5606/5779)   
Checking out files:  98% (5664/5779)   
Checking out files:  99% (5722/5779)   
Checking out files: 100% (5779/5779)   
Checking out files: 100% (5779/5779), done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 
'/var/tmp/patchew-tester-tmp-t2c_u19x/src/docker-src.2018-02-02-17.13.16.3631/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba107

Re: [Qemu-devel] [Bug 1703795] Re: Unable to release mouse in SDL2 mode

2018-02-02 Thread BALATON Zoltan
The patch works for me too. Thanks.

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

Title:
  Unable to release mouse in SDL2 mode

Status in QEMU:
  New

Bug description:
  Starting with commit 8f4ea9cd0b770dbe496d9d24f0ef8813fdbfe0d0 "sdl:
  prefer sdl2 over sdl1", I can no longer release mouse pointer grab
  unless I use --with-sdlabi=1.2 configure option.

  This easily reproduces in e.g. guest Kubuntu, when I let it start Xorg
  and then click into the QEMU window. After this the mouse is trapped
  and no matter how I combine Ctrl+Alt and motion of the cursor, the
  pointer never goes out from the window. When at the border, QEMU
  window switches from "Press Ctrl+Alt to exit grab" to "QEMU", i.e. it
  thinks that it has released the grab. But it hasn't really, so I have
  to go to VT1 and do "pkill qemu" from there to get my pointer back.

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



Re: [Qemu-devel] [PATCH v1 1/1] hw: register: Run post_write hook on reset

2018-02-02 Thread Alistair Francis
On Fri, Feb 2, 2018 at 12:24 PM, Philippe Mathieu-Daudé  wrote:
> Hi Alistair,
>
> On 02/02/2018 04:38 PM, Alistair Francis wrote:
>> Ensure that the post write hook is called during reset. This allows us
>> to rely on the post write functions instead of having to call them from
>> the reset() function.
>
> This makes sens. Can you add a comment about this new behavior in
> include/hw/register.h?

Yep, fixed in V2 which I'll send out next week.

Alistair

>
>>
>> Signed-off-by: Alistair Francis 
>
> with comment:
> Reviewed-by: Philippe Mathieu-Daudé 
>
>> ---
>>
>>  hw/core/register.c | 8 
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/hw/core/register.c b/hw/core/register.c
>> index 900294b9c4..0741a1af32 100644
>> --- a/hw/core/register.c
>> +++ b/hw/core/register.c
>> @@ -159,13 +159,21 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, 
>> const char* prefix,
>>
>>  void register_reset(RegisterInfo *reg)
>>  {
>> +const RegisterAccessInfo *ac;
>> +
>>  g_assert(reg);
>>
>>  if (!reg->data || !reg->access) {
>>  return;
>>  }
>>
>> +ac = reg->access;
>> +
>>  register_write_val(reg, reg->access->reset);
>> +
>> +if (ac->post_write) {
>> +ac->post_write(reg, reg->access->reset);
>> +}
>>  }
>>
>>  void register_init(RegisterInfo *reg)
>>



Re: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

2018-02-02 Thread no-reply
Hi,

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

Type: series
Message-id: 20180202143746.204851-1-borntrae...@de.ibm.com
Subject: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
ac346828ac s390x/cpu: expose the guest crash information

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-pf4jkx1i/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
  BUILD   min-glib
  GEN 
/var/tmp/patchew-tester-tmp-pf4jkx1i/src/docker-src.2018-02-02-17.51.52.29620/qemu.tar
Cloning into 
'/var/tmp/patchew-tester-tmp-pf4jkx1i/src/docker-src.2018-02-02-17.51.52.29620/qemu.tar.vroot'...
done.
Checking out files:  49% (2881/5777)   
Checking out files:  50% (2889/5777)   
Checking out files:  51% (2947/5777)   
Checking out files:  52% (3005/5777)   
Checking out files:  53% (3062/5777)   
Checking out files:  54% (3120/5777)   
Checking out files:  55% (3178/5777)   
Checking out files:  56% (3236/5777)   
Checking out files:  57% (3293/5777)   
Checking out files:  58% (3351/5777)   
Checking out files:  59% (3409/5777)   
Checking out files:  60% (3467/5777)   
Checking out files:  61% (3524/5777)   
Checking out files:  62% (3582/5777)   
Checking out files:  63% (3640/5777)   
Checking out files:  64% (3698/5777)   
Checking out files:  65% (3756/5777)   
Checking out files:  66% (3813/5777)   
Checking out files:  67% (3871/5777)   
Checking out files:  68% (3929/5777)   
Checking out files:  69% (3987/5777)   
Checking out files:  70% (4044/5777)   
Checking out files:  71% (4102/5777)   
Checking out files:  72% (4160/5777)   
Checking out files:  73% (4218/5777)   
Checking out files:  74% (4275/5777)   
Checking out files:  75% (4333/5777)   
Checking out files:  76% (4391/5777)   
Checking out files:  77% (4449/5777)   
Checking out files:  78% (4507/5777)   
Checking out files:  79% (4564/5777)   
Checking out files:  80% (4622/5777)   
Checking out files:  81% (4680/5777)   
Checking out files:  82% (4738/5777)   
Checking out files:  83% (4795/5777)   
Checking out files:  84% (4853/5777)   
Checking out files:  85% (4911/5777)   
Checking out files:  86% (4969/5777)   
Checking out files:  87% (5026/5777)   
Checking out files:  88% (5084/5777)   
Checking out files:  89% (5142/5777)   
Checking out files:  90% (5200/5777)   
Checking out files:  91% (5258/5777)   
Checking out files:  92% (5315/5777)   
Checking out files:  93% (5373/5777)   
Checking out files:  94% (5431/5777)   
Checking out files:  95% (5489/5777)   
Checking out files:  96% (5546/5777)   
Checking out files:  97% (5604/5777)   
Checking out files:  98% (5662/5777)   
Checking out files:  99% (5720/5777)   
Checking out files: 100% (5777/5777)   
Checking out files: 100% (5777/5777), done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 
'/var/tmp/patchew-tester-tmp-pf4jkx1i/src/docker-src.2018-02-02-17.51.52.29620/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 
'/var/tmp/patchew-tester-tmp-pf4jkx1i/src/docker-src.2018-02-02-17.51.52.29620/qemu.tar.vroot/ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'10739aa26051a5d49d88132604539d3ed085e72e'
  COPYRUNNER
RUN test-build in qemu:min-glib 
Environment variables:
HOSTNAME=fd003b1deba3
MAKEFLAGS= -j8
J=8
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
TARGET_LIST=
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
FEATURES= dtc
DEBUG=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu 
--prefix=/tmp/qemu-test/install
No C++ compiler available; disabling C++ specific optional code
Install prefix/tmp/qemu-test/install
BIOS directory/tmp/qemu-test/install/share/qemu
firmware path /tmp/qemu-test/install/share/qemu-firmware
binary directory  /tmp/qemu-test/install/bin
library directory /tmp/qemu-test/install/lib
module directory  /tmp/qemu-test/install/lib/qemu
libexec directory /tmp/qemu-test/install/libexec
include directory /tmp/qemu-test/install/include
config directory  /tmp/qemu-test/install/etc
local state directory   /tmp/qemu-test/install/var
Manual directory  /tmp/qemu-test/ins

Re: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

2018-02-02 Thread no-reply
Hi,

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

Type: series
Message-id: 20180202143746.204851-1-borntrae...@de.ibm.com
Subject: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
ac346828ac s390x/cpu: expose the guest crash information

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-dqebvbdh/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
  BUILD   centos6
  GEN 
/var/tmp/patchew-tester-tmp-dqebvbdh/src/docker-src.2018-02-02-17.21.02.18131/qemu.tar
Cloning into 
'/var/tmp/patchew-tester-tmp-dqebvbdh/src/docker-src.2018-02-02-17.21.02.18131/qemu.tar.vroot'...
done.
Checking out files:  44% (2563/5777)   
Checking out files:  45% (2600/5777)   
Checking out files:  46% (2658/5777)   
Checking out files:  47% (2716/5777)   
Checking out files:  48% (2773/5777)   
Checking out files:  49% (2831/5777)   
Checking out files:  50% (2889/5777)   
Checking out files:  51% (2947/5777)   
Checking out files:  52% (3005/5777)   
Checking out files:  53% (3062/5777)   
Checking out files:  54% (3120/5777)   
Checking out files:  55% (3178/5777)   
Checking out files:  56% (3236/5777)   
Checking out files:  57% (3293/5777)   
Checking out files:  58% (3351/5777)   
Checking out files:  59% (3409/5777)   
Checking out files:  60% (3467/5777)   
Checking out files:  61% (3524/5777)   
Checking out files:  62% (3582/5777)   
Checking out files:  63% (3640/5777)   
Checking out files:  64% (3698/5777)   
Checking out files:  65% (3756/5777)   
Checking out files:  66% (3813/5777)   
Checking out files:  67% (3871/5777)   
Checking out files:  68% (3929/5777)   
Checking out files:  69% (3987/5777)   
Checking out files:  70% (4044/5777)   
Checking out files:  71% (4102/5777)   
Checking out files:  72% (4160/5777)   
Checking out files:  73% (4218/5777)   
Checking out files:  74% (4275/5777)   
Checking out files:  75% (4333/5777)   
Checking out files:  76% (4391/5777)   
Checking out files:  77% (4449/5777)   
Checking out files:  78% (4507/5777)   
Checking out files:  79% (4564/5777)   
Checking out files:  80% (4622/5777)   
Checking out files:  81% (4680/5777)   
Checking out files:  82% (4738/5777)   
Checking out files:  83% (4795/5777)   
Checking out files:  84% (4853/5777)   
Checking out files:  85% (4911/5777)   
Checking out files:  86% (4969/5777)   
Checking out files:  87% (5026/5777)   
Checking out files:  88% (5084/5777)   
Checking out files:  89% (5142/5777)   
Checking out files:  90% (5200/5777)   
Checking out files:  91% (5258/5777)   
Checking out files:  92% (5315/5777)   
Checking out files:  93% (5373/5777)   
Checking out files:  94% (5431/5777)   
Checking out files:  95% (5489/5777)   
Checking out files:  96% (5546/5777)   
Checking out files:  97% (5604/5777)   
Checking out files:  98% (5662/5777)   
Checking out files:  99% (5720/5777)   
Checking out files: 100% (5777/5777)   
Checking out files: 100% (5777/5777), done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 
'/var/tmp/patchew-tester-tmp-dqebvbdh/src/docker-src.2018-02-02-17.21.02.18131/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 
'/var/tmp/patchew-tester-tmp-dqebvbdh/src/docker-src.2018-02-02-17.21.02.18131/qemu.tar.vroot/ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'10739aa26051a5d49d88132604539d3ed085e72e'
  COPYRUNNER
RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
bison-2.4.1-5.el6.x86_64
bzip2-devel-1.0.5-7.el6_0.x86_64
ccache-3.1.6-2.el6.x86_64
csnappy-devel-0-6.20150729gitd7bc683.el6.x86_64
flex-2.5.35-9.el6.x86_64
gcc-4.4.7-18.el6.x86_64
gettext-0.17-18.el6.x86_64
git-1.7.1-9.el6_9.x86_64
glib2-devel-2.28.8-9.el6.x86_64
libepoxy-devel-1.2-3.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
librdmacm-devel-1.0.21-0.el6.x86_64
lzo-devel-2.03-3.1.el6_5.1.x86_64
make-3.81-23.el6.x86_64
mesa-libEGL-devel-11.0.7-4.el6.x86_64
mesa-libgbm-devel-11.0.7-4.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
spice-glib-devel-0.26-8.el6.x86_64
spice-server-devel-0.12.4-16.el6.x86_64
tar-1.23-15.el6_8.x86_64
vte-devel-0.25.1-9.el6.x86_64
xen-devel-4.6.6-2.el6.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PA

Re: [Qemu-devel] [PATCH RFC 10/21] qapi/common: Eliminate QAPISchema.exprs

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster 
> ---
>  scripts/qapi/common.py | 8 
>  1 file changed, 4 insertions(+), 4 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] MTTCG External Halt

2018-02-02 Thread Alistair Francis
On Fri, Feb 2, 2018 at 1:49 PM, Alistair Francis
 wrote:
> On Fri, Feb 2, 2018 at 12:37 PM, Alex Bennée  wrote:
>>
>> Alistair Francis  writes:
>>
>>> On Thu, Feb 1, 2018 at 9:13 AM, Alistair Francis
>>>  wrote:
 On Thu, Feb 1, 2018 at 4:01 AM, Alex Bennée  wrote:
>
> Alistair Francis  writes:
>
>> On Wed, Jan 31, 2018 at 12:32 PM, Alex Bennée  
>> wrote:
>>>
>>> Alistair Francis  writes:
>>>
 On Tue, Jan 30, 2018 at 8:26 PM, Paolo Bonzini  
 wrote:
> On 30/01/2018 18:56, Alistair Francis wrote:
>>
>> I don't have a good solution though, as setting CPU_INTERRUPT_RESET
>> doesn't help (that isn't handled while we are halted) and
>> async_run_on_cpu()/run_on_cpu() doesn't reliably reset the CPU when 
>> we
>> want.
>>
>> I've ever tried pausing all CPUs before reseting the CPU and them
>> resuming them all but that doesn't seem to to work either.
>
> async_safe_run_on_cpu would be like async_run_on_cpu, except that it
> takes care of stopping all other CPUs while the function runs.
>
>> Is there
>> anything I'm missing? Is there no reliable way to reset a CPU?
>
> What do you mean by reliable?  Executing no instruction after the one
> you were at?

 The reset is called by a GPIO line, so I need the reset to be called
 basically as quickly as the GPIO line changes. The async_ and
 async_safe_ functions seem to not run quickly enough, even if I run a
 process_work_queue() function afterwards.

 Is there a way to kick the CPU to act on the async_*?
>>>
>>> Define quickly enough? The async_(safe) functions kick the vCPUs so they
>>> will all exit the run loop as they enter the next TB (even if they loop
>>> to themselves).
>>
>> We have a special power controller CPU that wakes all the CPUs up and
>> at boot the async_* functions don't wake the CPUs up. If I just use
>> the cpu_rest() function directly everything starts fine (but then I
>> hit issues later).
>>
>> If I forcefully run process_queued_cpu_work() then I can get the CPUs
>> up, but I don't think that is the right solution.
>>
>>>
>>> From an external vCPUs point of view those extra instructions have
>>> already executed. If the resetting vCPU needs them to have reset by the
>>> time it executes it's next instruction it should either cpu_loop_exit at
>>> that point or ensure it is the last instruction in it's TB (which is
>>> what we do for the MMU flush cases in ARM, they all end the TB at that
>>> point).
>>
>> cpu_loop_exit() sounds like it would help, but as I'm not in the CPU
>> context it just seg faults.
>
> What context are you in? gdb-stub does have to something like this.

 gdb-stub just seems to use vm_stop() and vm_start().

 That fixes all hangs/asserts, but now Linux only brings up 1 CPU (instead 
 of 4).
>>>
>>> Hmmm... Interesting if I do this on reset events:
>>>
>>> pause_all_vcpus();
>>> cpu_reset(cpu);
>>> resume_all_vcpus();
>>>
>>> it hangs, while if I do this
>>>
>>> if (runstate_is_running()) {
>>> vm_stop(RUN_STATE_PAUSED);
>>> }
>>> cpu_reset(cpu);
>>> if (!runstate_needs_reset()) {
>>> vm_start();
>>> }
>>>
>>> it doesn't hang but CPU bringup doesn't work.
>>
>> Hmm I'm still confused what context you are in. Is this an externally
>> triggered reset via the (qemu) prompt or something?
>
> This gets called from a variety of places. But most likely it's called
> from a second QEMU process that is triggering an interrupt through a
> device.

Something like this:

#0  0x55807350 in cpu_reset_gpio (opaque=0x57272100,
irq=0, level=0) at /scratch/alistai/master-qemu/exec.c:3853
#1  0x55a20336 in dep_register_refresh_gpios
(reg=reg@entry=0x56fa5ad0, old_value=old_value@entry=2147496974)
at hw/core/register-dep.c:246
#2  0x55a2067b in dep_register_write (reg=0x56fa5ad0,
val=, we=)
at hw/core/register-dep.c:142
#3  0x55841ae8 in memory_region_write_accessor
(mr=0x56fa5b80, addr=0, value=, size=4,
shift=, mask=, attrs=...) at
/scratch/alistai/master-qemu/memory.c:617
#4  0x5583e57d in access_with_adjusted_size
(addr=addr@entry=0, value=value@entry=0x7fffd218,
size=size@entry=4, access_size_min=,
access_size_max=, access_fn=
0x55841a70 , mr=0x56fa5b80,
attrs=...) at /scratch/alistai/master-qemu/memory.c:684
#5  0x55843cda in memory_region_dispatch_write
(mr=0x56fa5b80, addr=0, data=, size=4, attrs=...)
at /scratch/alistai/master-qemu/memory.c:1789
#6  0x557fbcb1 in flatview_write_continue (mr=0x56fa5b80,
l=, addr1=, len=4, buf=0x7fff900047c0
"\f4", attrs=..., addr=4246339

Re: [Qemu-devel] [Qemu-block] [PATCH 3/3] block/iscsi: fix ioctl cancel use-after-free

2018-02-02 Thread Stefan Hajnoczi
On Fri, Feb 2, 2018 at 10:16 PM, Stefan Hajnoczi  wrote:
> The ioctl request cancellation code assumes that requests do not
> complete once TASK ABORT has been sent to the iSCSI target.  The request
> completion callback is unconditionally invoked when TASK ABORT finishes.
> Therefore the request completion callback is invoked twice if the
> request does happen to complete before TASK ABORT.
>
> Futhermore, iscsi_aio_cancel() does not increment the request's
> reference count, causing a use-after-free when TASK ABORT finishes after
> the request has already completed.
>
> The iscsilun->mutex protection is also missing in iscsi_aio_cancel().
>
> This patch rewrites iscsi_aio_cancel() and iscsi_abort_task_cb() to
> avoid double completion, use-after-free, and to take iscsilun->mutex
> when needed.
>
> Reported-by: Felipe Franciosi 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  block/iscsi.c | 25 +
>  1 file changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 1cfe1c647c..4566902d43 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -282,14 +282,19 @@ static void iscsi_co_init_iscsitask(IscsiLun *iscsilun, 
> struct IscsiTask *iTask)
>  };
>  }
>
> +/* Called (via iscsi_service) with QemuMutex held. */
>  static void
>  iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void 
> *command_data,
>  void *private_data)
>  {
>  IscsiAIOCB *acb = private_data;
>
> -acb->status = -ECANCELED;
> -iscsi_schedule_bh(acb);
> +/* Skip if the request already completed */
> +if (acb->status == -ECANCELED) {

There is a bug here.  acb->status can be -ECANCELED if the request
completed with COMMAND ABORTED.

I'll send a v2 of this patch tomorrow to solve this.

Stefan



Re: [Qemu-devel] rate limiting issues

2018-02-02 Thread John Snow
CCing qemu-block and Berto

On 02/02/2018 06:10 AM, Wolfgang Bumiller wrote:
> Summary:
> Rate limit is effectively halved when the size of written chunks adds up to
> exceeding the quota of a slice only slightly. This is surprisingly reliable.
> 
> Explanation:
> The ratelimiting code in include/qemu/ratelimit.h currently uses slices with
> quotas. Finishing up the quota for one slice means it'll wait for the end of
> this _and_ the next slice before resetting the accounting and start over.
> If that first slice was exceeded by only a tiny bit, we effectively spend 
> every
> second slice waiting around. before starting over.
> 
> Here if I use a limit of 3KiB/s I get 3KiB/s.
> Increasing the limit to 30700KiB/s gives me 30700KiB/s.
> Increasing it to 30720KiB/s reliably gives me 15000KiB/s.
> 
> Making it wait to the end of only the current slice means the excess data is 
> not
> counted at all and we may go above the limit (though by at most one 
> write-chunk,
> so I'm not sure if that's fine for most of the users, for backup jobs it seems
> to be 64k always).
> 
> I'd like to fix this and am unsure about which way to go. On the one hand I
> think the old code (before f14a39ccb922) may be fixable in a better way by not
> resetting the accounting completely but subtracting the amount of data the
> wait-period would have added.
> 
> At the same time, though, this could be simplified to not using slices but
> always comparing the amount of actually written data to the amount of data
> which should at most have been written.
> 
> Here are two approaches which seem to fix my issues:
> 
> --- Old code revised:
> 
> typedef struct {
> int64_t next_slice_time;
> uint64_t slice_quota;
> uint64_t slice_ns;
> int64_t dispatched;
> } RateLimit;
> 
> static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
> {
> int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> 
> assert(limit->slice_quota && limit->slice_ns);
> 
> if (limit->next_slice_time == 0) { /* first call */
> limit->dispatched = 0;
> limit->next_slice_time = now + limit->slice_ns;
> return 0;
> }
> 
> if (limit->next_slice_time < now) {
> uint64_t passed_slices = DIV_ROUND_UP(now - limit->next_slice_time,
> limit->slice_ns);
> limit->next_slice_time = now + limit->slice_ns;
> limit->dispatched -= passed_slices * limit->slice_quota;
> }
> limit->dispatched += n;
> if (limit->dispatched+n <= limit->slice_quota) {
> return 0;
> }
> return limit->next_slice_time - now;
> }
> 
> static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
>uint64_t slice_ns)
> {
> limit->slice_ns = slice_ns;
> limit->slice_quota = MAX(((double)speed * slice_ns) / 10ULL, 1);
> }
> 
> ---
> 
> And this is a short slice-less version. I wonder if there's any particular
> reason for sticking to slices?
> 
> --- Version without slices:
> 
> typedef struct {
> int64_t last_time;
> uint64_t speed;
> int64_t allowed;
> } RateLimit;
> 
> static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
> {
> int64_t delta, now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> 
> if (limit->last_time == 0) { /* first call */
> limit->allowed = -n;
> limit->last_time = now;
> return (n * 10ULL) / limit->speed;
> }
> 
> delta = (now - limit->last_time);
> limit->allowed += (delta * limit->speed)/10ULL - n;
> limit->last_time = now;
> if (limit->allowed < 0) {
> return ((uint64_t)-limit->allowed * 10ULL) / limit->speed;
> }
> return 0;
> }
> 
> static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
>uint64_t slice_ns)
> {
> (void)slice_ns; // TODO: remove
> limit->speed = speed;
> }
> 
> ---
> 
> Numerical note: a small delta means 'allowed' is incremented by 0, which
> should be fine since when we hit the quota, we'll have a longer wait after
> which the delta is for sure big enough to produce positive values.
> (I tried larger and smaller values (1KiB/s to some MiB/s)).
> Alternatively we could set last_time and do the quota increment
> conditionally only when the delta is big enough, but I have not found
> this to be necessary in my tests.
> 
> 




Re: [Qemu-devel] MTTCG External Halt

2018-02-02 Thread Alistair Francis
On Fri, Feb 2, 2018 at 12:37 PM, Alex Bennée  wrote:
>
> Alistair Francis  writes:
>
>> On Thu, Feb 1, 2018 at 9:13 AM, Alistair Francis
>>  wrote:
>>> On Thu, Feb 1, 2018 at 4:01 AM, Alex Bennée  wrote:

 Alistair Francis  writes:

> On Wed, Jan 31, 2018 at 12:32 PM, Alex Bennée  
> wrote:
>>
>> Alistair Francis  writes:
>>
>>> On Tue, Jan 30, 2018 at 8:26 PM, Paolo Bonzini  
>>> wrote:
 On 30/01/2018 18:56, Alistair Francis wrote:
>
> I don't have a good solution though, as setting CPU_INTERRUPT_RESET
> doesn't help (that isn't handled while we are halted) and
> async_run_on_cpu()/run_on_cpu() doesn't reliably reset the CPU when we
> want.
>
> I've ever tried pausing all CPUs before reseting the CPU and them
> resuming them all but that doesn't seem to to work either.

 async_safe_run_on_cpu would be like async_run_on_cpu, except that it
 takes care of stopping all other CPUs while the function runs.

> Is there
> anything I'm missing? Is there no reliable way to reset a CPU?

 What do you mean by reliable?  Executing no instruction after the one
 you were at?
>>>
>>> The reset is called by a GPIO line, so I need the reset to be called
>>> basically as quickly as the GPIO line changes. The async_ and
>>> async_safe_ functions seem to not run quickly enough, even if I run a
>>> process_work_queue() function afterwards.
>>>
>>> Is there a way to kick the CPU to act on the async_*?
>>
>> Define quickly enough? The async_(safe) functions kick the vCPUs so they
>> will all exit the run loop as they enter the next TB (even if they loop
>> to themselves).
>
> We have a special power controller CPU that wakes all the CPUs up and
> at boot the async_* functions don't wake the CPUs up. If I just use
> the cpu_rest() function directly everything starts fine (but then I
> hit issues later).
>
> If I forcefully run process_queued_cpu_work() then I can get the CPUs
> up, but I don't think that is the right solution.
>
>>
>> From an external vCPUs point of view those extra instructions have
>> already executed. If the resetting vCPU needs them to have reset by the
>> time it executes it's next instruction it should either cpu_loop_exit at
>> that point or ensure it is the last instruction in it's TB (which is
>> what we do for the MMU flush cases in ARM, they all end the TB at that
>> point).
>
> cpu_loop_exit() sounds like it would help, but as I'm not in the CPU
> context it just seg faults.

 What context are you in? gdb-stub does have to something like this.
>>>
>>> gdb-stub just seems to use vm_stop() and vm_start().
>>>
>>> That fixes all hangs/asserts, but now Linux only brings up 1 CPU (instead 
>>> of 4).
>>
>> Hmmm... Interesting if I do this on reset events:
>>
>> pause_all_vcpus();
>> cpu_reset(cpu);
>> resume_all_vcpus();
>>
>> it hangs, while if I do this
>>
>> if (runstate_is_running()) {
>> vm_stop(RUN_STATE_PAUSED);
>> }
>> cpu_reset(cpu);
>> if (!runstate_needs_reset()) {
>> vm_start();
>> }
>>
>> it doesn't hang but CPU bringup doesn't work.
>
> Hmm I'm still confused what context you are in. Is this an externally
> triggered reset via the (qemu) prompt or something?

This gets called from a variety of places. But most likely it's called
from a second QEMU process that is triggering an interrupt through a
device.

Alistair

>
>>
>> Alistair
>>
>>>
>>> Alistair
>
>
> --
> Alex Bennée
>



Re: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

2018-02-02 Thread no-reply
Hi,

This series failed build test on ppc host. Please find the details below.

Message-id: 20180202143746.204851-1-borntrae...@de.ibm.com
Subject: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
set -e
echo "=== ENV ==="
env
echo "=== PACKAGES ==="
rpm -qa
echo "=== TEST BEGIN ==="
INSTALL=$PWD/install
BUILD=$PWD/build
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --prefix=$INSTALL
make -j100
# XXX: we need reliable clean up
# make check -j100 V=1
make install
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Submodule 'capstone' (git://git.qemu.org/capstone.git) registered for path 
'capstone'
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Submodule 'roms/QemuMacDrivers' (git://git.qemu.org/QemuMacDrivers.git) 
registered for path 'roms/QemuMacDrivers'
Submodule 'roms/SLOF' (git://git.qemu-project.org/SLOF.git) registered for path 
'roms/SLOF'
Submodule 'roms/ipxe' (git://git.qemu-project.org/ipxe.git) registered for path 
'roms/ipxe'
Submodule 'roms/openbios' (git://git.qemu-project.org/openbios.git) registered 
for path 'roms/openbios'
Submodule 'roms/openhackware' (git://git.qemu-project.org/openhackware.git) 
registered for path 'roms/openhackware'
Submodule 'roms/qemu-palcode' (git://github.com/rth7680/qemu-palcode.git) 
registered for path 'roms/qemu-palcode'
Submodule 'roms/seabios' (git://git.qemu-project.org/seabios.git/) registered 
for path 'roms/seabios'
Submodule 'roms/seabios-hppa' (git://github.com/hdeller/seabios-hppa.git) 
registered for path 'roms/seabios-hppa'
Submodule 'roms/sgabios' (git://git.qemu-project.org/sgabios.git) registered 
for path 'roms/sgabios'
Submodule 'roms/skiboot' (git://git.qemu.org/skiboot.git) registered for path 
'roms/skiboot'
Submodule 'roms/u-boot' (git://git.qemu-project.org/u-boot.git) registered for 
path 'roms/u-boot'
Submodule 'roms/vgabios' (git://git.qemu-project.org/vgabios.git/) registered 
for path 'roms/vgabios'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 'capstone'...
Submodule path 'capstone': checked out 
'22ead3e0bfdb87516656453336160e0a37b066bf'
Cloning into 'dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Cloning into 'roms/QemuMacDrivers'...
Submodule path 'roms/QemuMacDrivers': checked out 
'd4e7d7ac663fcb55f1b93575445fcbca372f17a7'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out 
'fa981320a1e0968d6fc1b8de319723ff8212b337'
Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 
'0600d3ae94f93efd10fc6b3c7420a9557a3a1670'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out 
'b5c93acd14b7b3886c2c81d84cd18e666984a4c8'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 
'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out 
'f3c7e44c70254975df2a00af39701eafbac4d471'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 
'63451fca13c75870e1703eb3e20584d91179aebc'
Cloning into 'roms/seabios-hppa'...
Submodule path 'roms/seabios-hppa': checked out 
'8fa4ca9935669414a824ecda24f6e70c36e8dc94'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 
'cbaee52287e5f32373181cff50a00b6c4ac9015a'
Cloning into 'roms/skiboot'...
Submodule path 'roms/skiboot': checked out 
'e0ee24c27a172bcf482f6f2bc905e6211c134bcc'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 
'd85ca029f257b53a96da6c2fb421e78a003a9943'
Cloning into 'roms/vgabios'...
Submodule path 'roms/vgabios': checked out 
'19ea12c230ded95928ecaef0db47a82231c2e485'
Cloning into 'ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'10739aa26051a5d49d88132604539d3ed085e72e'
Switched to a new branch 'test'
ac34682 s390x/cpu: expose the guest crash information

=== OUTPUT BEGIN ===
=== ENV ===
XDG_SESSION_ID=170004
SHELL=/bin/sh
USER=patchew
PATCHEW=/home/patchew/patchew/patchew-cli -s http://patchew.org --nodebug
PATH=/usr/bin:/bin
PWD=/var/tmp/patchew-tester-tmp-pu8mazen/src
LANG=en_US.UTF-8
HOME=/home/patchew
SHLVL=2
LOGNAME=patchew
XDG_RUNTIME_DIR=/run/user/1000
_=/usr/bin/env
=== PACKAGES ===
plymouth-core-libs-0.8.9-0.28.20140113.el7.centos.ppc64le
vim-common-7.4.160-2.el7.ppc64le
perl-Test-Simple-0.98-243.el7.noarch
hplip-common-3.15.9-3.el7.ppc64le
valgrind-3.12.0-8.el7.ppc64le
gamin-0.1.10-16.el7.ppc64le
libpeas-loader-python-1.20.0-1.el7.ppc64le
telepathy-filesystem-0.0.2-6.el7.noarch
colord-libs-1.3.4-1.el7.ppc64le
kbd-legacy-1.15.5-13.el7.noarch
perl-CPAN-Meta-YAML-0.008-14.el7.noarch
libvirt-daemon-driver-nwfilter-3.2.0-14.el7.ppc64le
ntsysv-1.7.4-1.el7.ppc64le
kernel-bootwra

[Qemu-devel] [PATCH 2/3] block/iscsi: take iscsilun->mutex in iscsi_timed_check_events()

2018-02-02 Thread Stefan Hajnoczi
Commit d045c466d9e62b4321fadf586d024d54ddfd8bd4 ("iscsi: do not use
aio_context_acquire/release") introduced iscsilun->mutex but appears to
have overlooked iscsi_timed_check_events() when introducing the mutex.

iscsi_service() and iscsi_set_events() must be called with
iscsilun->mutex held.

iscsi_timed_check_events() is invoked from the AioContext and does not
take the mutex.

Signed-off-by: Stefan Hajnoczi 
---
 block/iscsi.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/block/iscsi.c b/block/iscsi.c
index cd0738942c..1cfe1c647c 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -339,6 +339,8 @@ static void iscsi_timed_check_events(void *opaque)
 {
 IscsiLun *iscsilun = opaque;
 
+qemu_mutex_lock(&iscsilun->mutex);
+
 /* check for timed out requests */
 iscsi_service(iscsilun->iscsi, 0);
 
@@ -351,6 +353,8 @@ static void iscsi_timed_check_events(void *opaque)
  * to return to service once this situation changes. */
 iscsi_set_events(iscsilun);
 
+qemu_mutex_unlock(&iscsilun->mutex);
+
 timer_mod(iscsilun->event_timer,
   qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL);
 }
-- 
2.14.3




[Qemu-devel] [PATCH 3/3] block/iscsi: fix ioctl cancel use-after-free

2018-02-02 Thread Stefan Hajnoczi
The ioctl request cancellation code assumes that requests do not
complete once TASK ABORT has been sent to the iSCSI target.  The request
completion callback is unconditionally invoked when TASK ABORT finishes.
Therefore the request completion callback is invoked twice if the
request does happen to complete before TASK ABORT.

Futhermore, iscsi_aio_cancel() does not increment the request's
reference count, causing a use-after-free when TASK ABORT finishes after
the request has already completed.

The iscsilun->mutex protection is also missing in iscsi_aio_cancel().

This patch rewrites iscsi_aio_cancel() and iscsi_abort_task_cb() to
avoid double completion, use-after-free, and to take iscsilun->mutex
when needed.

Reported-by: Felipe Franciosi 
Signed-off-by: Stefan Hajnoczi 
---
 block/iscsi.c | 25 +
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 1cfe1c647c..4566902d43 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -282,14 +282,19 @@ static void iscsi_co_init_iscsitask(IscsiLun *iscsilun, 
struct IscsiTask *iTask)
 };
 }
 
+/* Called (via iscsi_service) with QemuMutex held. */
 static void
 iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void 
*command_data,
 void *private_data)
 {
 IscsiAIOCB *acb = private_data;
 
-acb->status = -ECANCELED;
-iscsi_schedule_bh(acb);
+/* Skip if the request already completed */
+if (acb->status == -ECANCELED) {
+iscsi_schedule_bh(acb);
+}
+
+qemu_aio_unref(acb); /* acquired in iscsi_aio_cancel() */
 }
 
 static void
@@ -298,14 +303,26 @@ iscsi_aio_cancel(BlockAIOCB *blockacb)
 IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
 IscsiLun *iscsilun = acb->iscsilun;
 
+qemu_mutex_lock(&iscsilun->mutex);
+
+/* If it was cancelled or completed already, our work is done here */
 if (acb->status != -EINPROGRESS) {
+qemu_mutex_unlock(&iscsilun->mutex);
 return;
 }
 
+/* This can still be overwritten if the request completes */
+acb->status = -ECANCELED;
+
+qemu_aio_ref(acb); /* released in iscsi_abort_task_cb() */
+
 /* send a task mgmt call to the target to cancel the task on the target */
-iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
- iscsi_abort_task_cb, acb);
+if (iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+ iscsi_abort_task_cb, acb) < 0) {
+qemu_aio_unref(acb); /* since iscsi_abort_task_cb() won't be called */
+}
 
+qemu_mutex_unlock(&iscsilun->mutex);
 }
 
 static const AIOCBInfo iscsi_aiocb_info = {
-- 
2.14.3




[Qemu-devel] [PATCH 0/3] block/iscsi: fix ioctl cancel use-after-free

2018-02-02 Thread Stefan Hajnoczi
Patches 1 & 2 are cleanups.

Patch 3 fixes cancellation of ioctls.  Felipe showed me a trace where an acb is
cancelled and then completes twice.  The second time around crashes QEMU.

Compile-tested only.

Felipe: Please let us know if this fixes the issue you are seeing.  Thanks!

Stefan Hajnoczi (3):
  block/iscsi: drop unused IscsiAIOCB->buf field
  block/iscsi: take iscsilun->mutex in iscsi_timed_check_events()
  block/iscsi: fix ioctl cancel use-after-free

 block/iscsi.c | 37 +
 1 file changed, 25 insertions(+), 12 deletions(-)

-- 
2.14.3




[Qemu-devel] [PATCH 1/3] block/iscsi: drop unused IscsiAIOCB->buf field

2018-02-02 Thread Stefan Hajnoczi
The IscsiAIOCB->buf field has not been used since commit
e49ab19fcaa617ad6cdfe1ac401327326b6a2552 ("block/iscsi: bump libiscsi
requirement to 1.9.0").  It used to be a linear buffer for old libiscsi
versions that didn't support scatter-gather.  The minimum libiscsi
version supports scatter-gather so we don't linearize buffers anymore.

Signed-off-by: Stefan Hajnoczi 
---
 block/iscsi.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 6a1c53711a..cd0738942c 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -112,7 +112,6 @@ typedef struct IscsiAIOCB {
 QEMUBH *bh;
 IscsiLun *iscsilun;
 struct scsi_task *task;
-uint8_t *buf;
 int status;
 int64_t sector_num;
 int nb_sectors;
@@ -145,9 +144,6 @@ iscsi_bh_cb(void *p)
 
 qemu_bh_delete(acb->bh);
 
-g_free(acb->buf);
-acb->buf = NULL;
-
 acb->common.cb(acb->common.opaque, acb->status);
 
 if (acb->task != NULL) {
@@ -925,9 +921,6 @@ iscsi_aio_ioctl_cb(struct iscsi_context *iscsi, int status,
 {
 IscsiAIOCB *acb = opaque;
 
-g_free(acb->buf);
-acb->buf = NULL;
-
 acb->status = 0;
 if (status < 0) {
 error_report("Failed to ioctl(SG_IO) to iSCSI lun. %s",
@@ -1002,7 +995,6 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
 acb->iscsilun = iscsilun;
 acb->bh  = NULL;
 acb->status  = -EINPROGRESS;
-acb->buf = NULL;
 acb->ioh = buf;
 
 if (req != SG_IO) {
-- 
2.14.3




Re: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

2018-02-02 Thread no-reply
Hi,

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

Type: series
Message-id: 20180202143746.204851-1-borntrae...@de.ibm.com
Subject: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
ac346828ac s390x/cpu: expose the guest crash information

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-4i5hcqso/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
  BUILD   fedora
  GEN 
/var/tmp/patchew-tester-tmp-4i5hcqso/src/docker-src.2018-02-02-15.28.45.11412/qemu.tar
Cloning into 
'/var/tmp/patchew-tester-tmp-4i5hcqso/src/docker-src.2018-02-02-15.28.45.11412/qemu.tar.vroot'...
done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 
'/var/tmp/patchew-tester-tmp-4i5hcqso/src/docker-src.2018-02-02-15.28.45.11412/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 
'/var/tmp/patchew-tester-tmp-4i5hcqso/src/docker-src.2018-02-02-15.28.45.11412/qemu.tar.vroot/ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'10739aa26051a5d49d88132604539d3ed085e72e'
  COPYRUNNER
RUN test-mingw in qemu:fedora 
Packages installed:
PyYAML-3.11-13.fc25.x86_64
SDL-devel-1.2.15-21.fc24.x86_64
bc-1.06.95-16.fc24.x86_64
bison-3.0.4-4.fc24.x86_64
bzip2-1.0.6-21.fc25.x86_64
ccache-3.3.4-1.fc25.x86_64
clang-3.9.1-2.fc25.x86_64
findutils-4.6.0-8.fc25.x86_64
flex-2.6.0-3.fc25.x86_64
gcc-6.4.1-1.fc25.x86_64
gcc-c++-6.4.1-1.fc25.x86_64
gettext-0.19.8.1-3.fc25.x86_64
git-2.9.5-3.fc25.x86_64
glib2-devel-2.50.3-1.fc25.x86_64
hostname-3.15-8.fc25.x86_64
libaio-devel-0.3.110-6.fc24.x86_64
libasan-6.4.1-1.fc25.x86_64
libfdt-devel-1.4.2-1.fc25.x86_64
libubsan-6.4.1-1.fc25.x86_64
make-4.1-6.fc25.x86_64
mingw32-SDL-1.2.15-7.fc24.noarch
mingw32-bzip2-1.0.6-7.fc24.noarch
mingw32-curl-7.47.0-1.fc24.noarch
mingw32-glib2-2.50.3-1.fc25.noarch
mingw32-gmp-6.1.1-1.fc25.noarch
mingw32-gnutls-3.5.5-2.fc25.noarch
mingw32-gtk2-2.24.31-2.fc25.noarch
mingw32-gtk3-3.22.17-1.fc25.noarch
mingw32-libjpeg-turbo-1.5.1-1.fc25.noarch
mingw32-libpng-1.6.27-1.fc25.noarch
mingw32-libssh2-1.4.3-5.fc24.noarch
mingw32-libtasn1-4.9-1.fc25.noarch
mingw32-nettle-3.3-1.fc25.noarch
mingw32-pixman-0.34.0-1.fc25.noarch
mingw32-pkg-config-0.28-6.fc24.x86_64
mingw64-SDL-1.2.15-7.fc24.noarch
mingw64-bzip2-1.0.6-7.fc24.noarch
mingw64-curl-7.47.0-1.fc24.noarch
mingw64-glib2-2.50.3-1.fc25.noarch
mingw64-gmp-6.1.1-1.fc25.noarch
mingw64-gnutls-3.5.5-2.fc25.noarch
mingw64-gtk2-2.24.31-2.fc25.noarch
mingw64-gtk3-3.22.17-1.fc25.noarch
mingw64-libjpeg-turbo-1.5.1-1.fc25.noarch
mingw64-libpng-1.6.27-1.fc25.noarch
mingw64-libssh2-1.4.3-5.fc24.noarch
mingw64-libtasn1-4.9-1.fc25.noarch
mingw64-nettle-3.3-1.fc25.noarch
mingw64-pixman-0.34.0-1.fc25.noarch
mingw64-pkg-config-0.28-6.fc24.x86_64
nettle-devel-3.3-1.fc25.x86_64
package python2 is not installed
perl-5.24.3-389.fc25.x86_64
pixman-devel-0.34.0-2.fc24.x86_64
sparse-0.5.0-10.fc25.x86_64
tar-1.29-3.fc25.x86_64
which-2.21-1.fc25.x86_64
zlib-devel-1.2.8-10.fc24.x86_64

Environment variables:
PACKAGES=ccache gettext git tar PyYAML sparse flex bison python2 bzip2 hostname 
glib2-devel pixman-devel zlib-devel SDL-devel libfdt-devel gcc gcc-c++ 
clang make perl which bc findutils libaio-devel nettle-devel libasan 
libubsan mingw32-pixman mingw32-glib2 mingw32-gmp mingw32-SDL 
mingw32-pkg-config mingw32-gtk2 mingw32-gtk3 mingw32-gnutls mingw32-nettle 
mingw32-libtasn1 mingw32-libjpeg-turbo mingw32-libpng mingw32-curl 
mingw32-libssh2 mingw32-bzip2 mingw64-pixman mingw64-glib2 mingw64-gmp 
mingw64-SDL mingw64-pkg-config mingw64-gtk2 mingw64-gtk3 mingw64-gnutls 
mingw64-nettle mingw64-libtasn1 mingw64-libjpeg-turbo mingw64-libpng 
mingw64-curl mingw64-libssh2 mingw64-bzip2
HOSTNAME=5c2c388a6296
MAKEFLAGS= -j8
J=8
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
TARGET_LIST=
FGC=f25
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
DISTTAG=f25container
FEATURES=mingw clang pyyaml asan dtc
DEBUG=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu 
--prefix=/tmp/qemu-test/install --cross-prefix=x86_64-w64-mingw32- 
--enable-trace-backends=s

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

2018-02-02 Thread no-reply
Hi,

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

Type: series
Message-id: 20180202130336.24719-1-arm...@redhat.com
Subject: [Qemu-devel] [PATCH RFC 00/21] Modularize generated QAPI code

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
20edfbb769 qapi: Empty out qapi-schema.json
908a02511e Include less of qapi-types.h
cc0f486390 qapi/types: Generate separate .h, .c for each module
da8bb99aca qapi/common: Fix guardname() for funny filenames
c8a5aa0179 qapi/types qapi/visit: Generate built-in stuff into separate files
799da1022d qapi/types qapi/visit: Make visitors use QAPIGen more
1755f6ed36 qapi: Record 'include' directives in intermediate representation
4e1183baa6 qapi: Generate in source order
b9771d2e65 qapi: Record 'include' directives in parse tree
656629e139 qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()
1bc777d460 qapi: Lift error reporting from QAPISchema.__init__() to callers
c531a76a97 qapi/common: Eliminate QAPISchema.exprs
7f7062dc58 qapi: Don't absolutize include file name in error messages
bd75734a2c qapi: Touch generated files only when they change
a4e94e3e75 qapi: Move parse_command_line() next to its only use
b9b12fa6c6 qapi-gen: New common driver for code and doc generators
3a56fc45c2 qapi: Turn generators into modules
c09593eb74 qapi: Reduce use of global variables in generators some
4e457ceed8 qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc
d969856a53 qapi: Generate up-to-date copyright notice
a295c600fc qapi: Streamline boilerplate comment generation

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-ongo5ce8/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
  BUILD   centos6
  GEN 
/var/tmp/patchew-tester-tmp-ongo5ce8/src/docker-src.2018-02-02-16.12.30.11185/qemu.tar
Cloning into 
'/var/tmp/patchew-tester-tmp-ongo5ce8/src/docker-src.2018-02-02-16.12.30.11185/qemu.tar.vroot'...
done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 
'/var/tmp/patchew-tester-tmp-ongo5ce8/src/docker-src.2018-02-02-16.12.30.11185/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 
'/var/tmp/patchew-tester-tmp-ongo5ce8/src/docker-src.2018-02-02-16.12.30.11185/qemu.tar.vroot/ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'10739aa26051a5d49d88132604539d3ed085e72e'
  COPYRUNNER
RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
bison-2.4.1-5.el6.x86_64
bzip2-devel-1.0.5-7.el6_0.x86_64
ccache-3.1.6-2.el6.x86_64
csnappy-devel-0-6.20150729gitd7bc683.el6.x86_64
flex-2.5.35-9.el6.x86_64
gcc-4.4.7-18.el6.x86_64
gettext-0.17-18.el6.x86_64
git-1.7.1-9.el6_9.x86_64
glib2-devel-2.28.8-9.el6.x86_64
libepoxy-devel-1.2-3.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
librdmacm-devel-1.0.21-0.el6.x86_64
lzo-devel-2.03-3.1.el6_5.1.x86_64
make-3.81-23.el6.x86_64
mesa-libEGL-devel-11.0.7-4.el6.x86_64
mesa-libgbm-devel-11.0.7-4.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
spice-glib-devel-0.26-8.el6.x86_64
spice-server-devel-0.12.4-16.el6.x86_64
tar-1.23-15.el6_8.x86_64
vte-devel-0.25.1-9.el6.x86_64
xen-devel-4.6.6-2.el6.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=bison bzip2-devel ccache csnappy-devel flex g++
 gcc gettext git glib2-devel libepoxy-devel libfdt-devel
 librdmacm-devel lzo-devel make mesa-libEGL-devel 
mesa-libgbm-devel pixman-devel SDL-devel spice-glib-devel 
spice-server-devel tar vte-devel xen-devel zlib-devel
HOSTNAME=1c5da51c1a21
MAKEFLAGS= -j8
J=8
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
TARGET_LIST=
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
FEATURES= dtc
DEBUG=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu 
--prefix=/tmp/qemu-test/install
No C++ compiler available; disabling C++ specific optional code
Install prefix/tmp/qemu-test/install
BIOS directory/tmp/qemu-test/install/share/qemu
firmware path /tmp/qemu-test/install/share/qemu-firmware
binary directory  /tmp/qemu-test/install/bin
library directory /tmp/qemu-test/install/lib
module direc

Re: [Qemu-devel] MTTCG External Halt

2018-02-02 Thread Alex Bennée

Alistair Francis  writes:

> On Thu, Feb 1, 2018 at 9:13 AM, Alistair Francis
>  wrote:
>> On Thu, Feb 1, 2018 at 4:01 AM, Alex Bennée  wrote:
>>>
>>> Alistair Francis  writes:
>>>
 On Wed, Jan 31, 2018 at 12:32 PM, Alex Bennée  
 wrote:
>
> Alistair Francis  writes:
>
>> On Tue, Jan 30, 2018 at 8:26 PM, Paolo Bonzini  
>> wrote:
>>> On 30/01/2018 18:56, Alistair Francis wrote:

 I don't have a good solution though, as setting CPU_INTERRUPT_RESET
 doesn't help (that isn't handled while we are halted) and
 async_run_on_cpu()/run_on_cpu() doesn't reliably reset the CPU when we
 want.

 I've ever tried pausing all CPUs before reseting the CPU and them
 resuming them all but that doesn't seem to to work either.
>>>
>>> async_safe_run_on_cpu would be like async_run_on_cpu, except that it
>>> takes care of stopping all other CPUs while the function runs.
>>>
 Is there
 anything I'm missing? Is there no reliable way to reset a CPU?
>>>
>>> What do you mean by reliable?  Executing no instruction after the one
>>> you were at?
>>
>> The reset is called by a GPIO line, so I need the reset to be called
>> basically as quickly as the GPIO line changes. The async_ and
>> async_safe_ functions seem to not run quickly enough, even if I run a
>> process_work_queue() function afterwards.
>>
>> Is there a way to kick the CPU to act on the async_*?
>
> Define quickly enough? The async_(safe) functions kick the vCPUs so they
> will all exit the run loop as they enter the next TB (even if they loop
> to themselves).

 We have a special power controller CPU that wakes all the CPUs up and
 at boot the async_* functions don't wake the CPUs up. If I just use
 the cpu_rest() function directly everything starts fine (but then I
 hit issues later).

 If I forcefully run process_queued_cpu_work() then I can get the CPUs
 up, but I don't think that is the right solution.

>
> From an external vCPUs point of view those extra instructions have
> already executed. If the resetting vCPU needs them to have reset by the
> time it executes it's next instruction it should either cpu_loop_exit at
> that point or ensure it is the last instruction in it's TB (which is
> what we do for the MMU flush cases in ARM, they all end the TB at that
> point).

 cpu_loop_exit() sounds like it would help, but as I'm not in the CPU
 context it just seg faults.
>>>
>>> What context are you in? gdb-stub does have to something like this.
>>
>> gdb-stub just seems to use vm_stop() and vm_start().
>>
>> That fixes all hangs/asserts, but now Linux only brings up 1 CPU (instead of 
>> 4).
>
> Hmmm... Interesting if I do this on reset events:
>
> pause_all_vcpus();
> cpu_reset(cpu);
> resume_all_vcpus();
>
> it hangs, while if I do this
>
> if (runstate_is_running()) {
> vm_stop(RUN_STATE_PAUSED);
> }
> cpu_reset(cpu);
> if (!runstate_needs_reset()) {
> vm_start();
> }
>
> it doesn't hang but CPU bringup doesn't work.

Hmm I'm still confused what context you are in. Is this an externally
triggered reset via the (qemu) prompt or something?

>
> Alistair
>
>>
>> Alistair


--
Alex Bennée



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

2018-02-02 Thread Philippe Mathieu-Daudé
Hi Thomas,

On 02/02/2018 05:15 AM, Thomas Huth wrote:
> 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)

While not use tracepoints directly?

>  
>  /*
>   * 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;
>  }
> 



Re: [Qemu-devel] [PATCH v1 1/1] hw: register: Run post_write hook on reset

2018-02-02 Thread Philippe Mathieu-Daudé
Hi Alistair,

On 02/02/2018 04:38 PM, Alistair Francis wrote:
> Ensure that the post write hook is called during reset. This allows us
> to rely on the post write functions instead of having to call them from
> the reset() function.

This makes sens. Can you add a comment about this new behavior in
include/hw/register.h?

> 
> Signed-off-by: Alistair Francis 

with comment:
Reviewed-by: Philippe Mathieu-Daudé 

> ---
> 
>  hw/core/register.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/core/register.c b/hw/core/register.c
> index 900294b9c4..0741a1af32 100644
> --- a/hw/core/register.c
> +++ b/hw/core/register.c
> @@ -159,13 +159,21 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, 
> const char* prefix,
>  
>  void register_reset(RegisterInfo *reg)
>  {
> +const RegisterAccessInfo *ac;
> +
>  g_assert(reg);
>  
>  if (!reg->data || !reg->access) {
>  return;
>  }
>  
> +ac = reg->access;
> +
>  register_write_val(reg, reg->access->reset);
> +
> +if (ac->post_write) {
> +ac->post_write(reg, reg->access->reset);
> +}
>  }
>  
>  void register_init(RegisterInfo *reg)
> 



Re: [Qemu-devel] [PATCH v7 12/15] hw/timer: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Philippe Mathieu-Daudé


On 02/02/2018 03:37 PM, Markus Armbruster wrote:
> From: Alistair Francis 
> 
> Replace a large number of the fprintf(stderr, "*\n" calls with
> error_report(). The functions were renamed with these commands and then
> compiler issues where manually fixed.
> 
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N; {s|fprintf(stderr, 
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N; {s|fprintf(stderr, 
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N; {s|fprintf(stderr, 
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N; {s|fprintf(stderr, 
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
> \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> 
> Some lines where then manually tweaked to pass checkpatch.
> 
> Signed-off-by: Alistair Francis 
> 
> Conversions that aren't followed by exit() dropped, because they might
> be inappropriate.
> 
> Signed-off-by: Markus Armbruster 
> ---
>  hw/timer/xilinx_timer.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c
> index 59439c05be..2d658b5791 100644
> --- a/hw/timer/xilinx_timer.c
> +++ b/hw/timer/xilinx_timer.c
> @@ -127,7 +127,7 @@ timer_read(void *opaque, hwaddr addr, unsigned int size)
>  break;
>  
>  }
> -D(fprintf(stderr, "%s timer=%d %x=%x\n", __func__, timer, addr * 4, r));
> +D(error_report("%s timer=%d %x=%x", __func__, timer, addr * 4, r));

Not sure what we gain here, since those aren't error messages but trace
event.
Can you drop this patch from your series? I'll convert to tracepoints
and send a patch for this file.

>  return r;
>  }
>  
> @@ -135,8 +135,8 @@ static void timer_enable(struct xlx_timer *xt)
>  {
>  uint64_t count;
>  
> -D(fprintf(stderr, "%s timer=%d down=%d\n", __func__,
> -  xt->nr, xt->regs[R_TCSR] & TCSR_UDT));
> +D(error_report("%s timer=%d down=%d", __func__,
> +   xt->nr, xt->regs[R_TCSR] & TCSR_UDT));
>  
>  ptimer_stop(xt->ptimer);
>  
> @@ -160,7 +160,7 @@ timer_write(void *opaque, hwaddr addr,
>  addr >>= 2;
>  timer = timer_from_addr(addr);
>  xt = &t->timers[timer];
> -D(fprintf(stderr, "%s addr=%x val=%x (timer=%d off=%d)\n",
> +D(error_report("%s addr=%x val=%x (timer=%d off=%d)",
>   __func__, addr * 4, value, timer, addr & 3));
>  /* Further decoding to address a specific timers reg.  */
>  addr &= 3;
> @@ -197,7 +197,7 @@ static void timer_hit(void *opaque)
>  {
>  struct xlx_timer *xt = opaque;
>  struct timerblock *t = xt->parent;
> -D(fprintf(stderr, "%s %d\n", __func__, xt->nr));
> +D(error_report("%s %d", __func__, xt->nr));
>  xt->regs[R_TCSR] |= TCSR_TINT;
>  
>  if (xt->regs[R_TCSR] & TCSR_ARHT)
> 



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

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> Error messages print absolute filenames of included files even gave a

s/even gave/even when given/

> 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

Nice, and makes developing new qapi tests a little less painful since
it's less modification to qapi-schema/*.err additions.

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

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 v7 00/15] Remove some of the fprintf(stderr, "*

2018-02-02 Thread Philippe Mathieu-Daudé
On 02/02/2018 03:37 PM, Markus Armbruster wrote:
> This is my attempt to salvage a good part of Alistair's error
> reporting cleanup series
> 
> [PATCH v6 00/29]  Remove some of the fprintf(stderr, "*
> 
> Continue on improving QEMUs logging/error messages by removing more
> fprintf()'s.
> 
> Unfortunatley my Coccinelle skills aren't that great so it's all done in
> some nasty regex and a little bit of manual work.
> 
> It foundered on the problem that some of its fprintf() to
> error_report() conversions are inappropriate, see
> 
> Message-ID: <87lghulqno@dusky.pond.sub.org>
> https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg04961.html
> 
> Alistair didn't feel like checking about one hundred conversions by
> hand, which is understandable.  But letting the work go to waste would
> be a shame, so I wrote an AWK script (see below) to extract a common
> kind of obviously good conversions: the ones where the fprintf() is
> followed by exit().  Judging from the diffstat, this salvages more
> than half of his conversion work.

Thanks for this :)

except patch 12 and the dtc submodule change reported by Eric in patch
15, series:
Reviewed-by: Philippe Mathieu-Daudé 

> 
> v7:
> * Old PATCH 02,03,21 are already in master, drop
> * Conversions not obviously followed by exit() dropped
>   Nothing left in old PATCH 06-12,16,17,22, drop
>   R-bys dropped
> * Rebased, trivial conflict in the last patch resolved
> 
> 
> #!/usr/bin/awk -f
> 
> hunk && /^\+[ \t]*error_report/ {
> n++
> er_indent = match(substr($0, 2), /[^ \t]/)
> er_nr = NR
> plus = 0
> fatal = 0
> }
> 
> hunk && er_indent && /^\+/ {
> plus++
> }
> 
> hunk && er_indent && /^[ \t]*exit/ {
> d = NR - er_nr - plus
> if (maxd < d)
>   maxd = d
> fatal = 1
> }
> 
> hunk && er_indent && match(substr($0, 2), /[^ \t]/) < er_indent {
> if (fatal)
>   nf++
> er_indent = 0
> }
> 
> hunk && /^[-+ ]/ {
> hunk = hunk "\n" $0
> next
> }
> 
> hunk {
> if (n && nf && n != nf)
>   print loc, "mixed hunk", n, nf >"/dev/stderr"
> else if (n && !nf)
>   print loc, "non-fatal hunk", n, nf >"/dev/stderr"
> else if (!n || nf)
>   print hunk
> hunk = ""
> }
> 
> /^@@ / {
> hunk = $0
> loc = FILENAME ":" FNR ":"
> n = nf = 0
> next
> }
> 
> {
> print
> }
> 
> END {
> print "max distance", maxd+0 >"/dev/stderr"
> }
> 
> Alistair Francis (15):
>   audio: Replace AUDIO_FUNC with __func__
>   hw/arm: Replace fprintf(stderr, "*\n" with error_report()
>   hw/dma: Replace fprintf(stderr, "*\n" with error_report()
>   hw/lm32: Replace fprintf(stderr, "*\n" with error_report()
>   hw/mips: Replace fprintf(stderr, "*\n" with error_report()
>   hw/moxie: Replace fprintf(stderr, "*\n" with error_report()
>   hw/openrisc: Replace fprintf(stderr, "*\n" with error_report()
>   hw/pci*: Replace fprintf(stderr, "*\n" with error_report()
>   hw/ppc: Replace fprintf(stderr, "*\n" with error_report()
>   hw/sd: Replace fprintf(stderr, "*\n" with error_report()
>   hw/sparc*: Replace fprintf(stderr, "*\n" with error_report()
>   hw/timer: Replace fprintf(stderr, "*\n" with error_report()
>   hw/xen*: Replace fprintf(stderr, "*\n" with error_report()
>   tcg: Replace fprintf(stderr, "*\n" with error_report()
>   target: Use qemu_log() instead of fprintf(stderr, ...)
> 
>  audio/alsaaudio.c|  4 ++--
>  audio/audio.c| 40 +++
>  audio/audio_int.h|  6 -
>  audio/audio_pt_int.c | 28 +++---
>  audio/audio_template.h   | 26 ++--
>  audio/dsoundaudio.c  |  2 +-
>  audio/mixeng.c   |  2 +-
>  audio/ossaudio.c | 10 
>  audio/paaudio.c  | 56 
> ++--
>  audio/sdlaudio.c |  2 +-
>  audio/wavaudio.c |  2 +-
>  cpus.c   | 10 
>  dtc  |  2 +-
>  exec.c   |  6 ++---
>  hw/arm/armv7m.c  |  2 +-
>  hw/arm/boot.c| 16 ++---
>  hw/arm/gumstix.c | 13 +-
>  hw/arm/mainstone.c   |  7 +++---
>  hw/arm/musicpal.c|  2 +-
>  hw/arm/omap1.c   |  5 ++--
>  hw/arm/omap2.c   |  3 ++-
>  hw/arm/omap_sx1.c|  2 +-
>  hw/arm/pxa2xx.c  |  7 +++---
>  hw/arm/vexpress.c|  8 +++
>  hw/arm/z2.c  |  6 ++---
>  hw/dma/soc_dma.c | 36 ++--
>  hw/lm32/lm32_boards.c|  7 +++---
>  hw/lm32/milkymist.c  |  7 +++---
>  hw/mips/mips_fulong2e.c  | 13 +-
>  hw/mips/mips_jazz.c  |  4 ++--
>  hw/mips/mips_malta.c | 16 ++---
>  hw/mips/mips_mipssim.c   | 11 -
>  hw/mips/mips_r4k.c   | 16 ++---
>  hw/moxie/moxiesim.c  | 13 +-
>  h

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

2018-02-02 Thread no-reply
Hi,

This series failed build test on s390x host. Please find the details below.

Type: series
Message-id: 20180202130336.24719-1-arm...@redhat.com
Subject: [Qemu-devel] [PATCH RFC 00/21] Modularize generated QAPI code

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
set -e
echo "=== ENV ==="
env
echo "=== PACKAGES ==="
rpm -qa
echo "=== TEST BEGIN ==="
CC=$HOME/bin/cc
INSTALL=$PWD/install
BUILD=$PWD/build
echo -n "Using CC: "
realpath $CC
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --cc=$CC --prefix=$INSTALL
make -j4
# XXX: we need reliable clean up
# make check -j4 V=1
make install
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
20edfbb769 qapi: Empty out qapi-schema.json
908a02511e Include less of qapi-types.h
cc0f486390 qapi/types: Generate separate .h, .c for each module
da8bb99aca qapi/common: Fix guardname() for funny filenames
c8a5aa0179 qapi/types qapi/visit: Generate built-in stuff into separate files
799da1022d qapi/types qapi/visit: Make visitors use QAPIGen more
1755f6ed36 qapi: Record 'include' directives in intermediate representation
4e1183baa6 qapi: Generate in source order
b9771d2e65 qapi: Record 'include' directives in parse tree
656629e139 qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()
1bc777d460 qapi: Lift error reporting from QAPISchema.__init__() to callers
c531a76a97 qapi/common: Eliminate QAPISchema.exprs
7f7062dc58 qapi: Don't absolutize include file name in error messages
bd75734a2c qapi: Touch generated files only when they change
a4e94e3e75 qapi: Move parse_command_line() next to its only use
b9b12fa6c6 qapi-gen: New common driver for code and doc generators
3a56fc45c2 qapi: Turn generators into modules
c09593eb74 qapi: Reduce use of global variables in generators some
4e457ceed8 qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc
d969856a53 qapi: Generate up-to-date copyright notice
a295c600fc qapi: Streamline boilerplate comment generation

=== OUTPUT BEGIN ===
=== ENV ===
LANG=en_US.UTF-8
XDG_SESSION_ID=38971
USER=fam
PWD=/var/tmp/patchew-tester-tmp-0t3s9f7b/src
HOME=/home/fam
SHELL=/bin/sh
SHLVL=2
PATCHEW=/home/fam/patchew/patchew-cli -s http://patchew.org --nodebug
LOGNAME=fam
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1012/bus
XDG_RUNTIME_DIR=/run/user/1012
PATH=/usr/bin:/bin
_=/usr/bin/env
=== PACKAGES ===
gpg-pubkey-873529b8-54e386ff
glibc-debuginfo-common-2.24-10.fc25.s390x
fedora-release-26-1.noarch
dejavu-sans-mono-fonts-2.35-4.fc26.noarch
xemacs-filesystem-21.5.34-22.20170124hgf412e9f093d4.fc26.noarch
bash-4.4.12-7.fc26.s390x
freetype-2.7.1-9.fc26.s390x
libSM-1.2.2-5.fc26.s390x
libmpc-1.0.2-6.fc26.s390x
libaio-0.3.110-7.fc26.s390x
libverto-0.2.6-7.fc26.s390x
perl-Scalar-List-Utils-1.48-1.fc26.s390x
iptables-libs-1.6.1-2.fc26.s390x
perl-threads-shared-1.57-1.fc26.s390x
p11-kit-trust-0.23.9-2.fc26.s390x
tcl-8.6.6-2.fc26.s390x
libxshmfence-1.2-4.fc26.s390x
expect-5.45-23.fc26.s390x
perl-Thread-Queue-3.12-1.fc26.noarch
perl-encoding-2.19-6.fc26.s390x
keyutils-1.5.10-1.fc26.s390x
gmp-devel-6.1.2-4.fc26.s390x
enchant-1.6.0-16.fc26.s390x
net-snmp-libs-5.7.3-17.fc26.s390x
python-gobject-base-3.24.1-1.fc26.s390x
python3-distro-1.0.3-1.fc26.noarch
python3-enchant-1.6.10-1.fc26.noarch
python-lockfile-0.11.0-6.fc26.noarch
python2-pyparsing-2.1.10-3.fc26.noarch
python2-lxml-4.1.1-1.fc26.s390x
librados2-10.2.7-2.fc26.s390x
trousers-lib-0.3.13-7.fc26.s390x
libpaper-1.1.24-14.fc26.s390x
libdatrie-0.2.9-4.fc26.s390x
libsoup-2.58.2-1.fc26.s390x
passwd-0.79-9.fc26.s390x
bind99-libs-9.9.10-3.P3.fc26.s390x
python3-rpm-4.13.0.2-1.fc26.s390x
mock-core-configs-27.4-1.fc26.noarch
systemd-233-7.fc26.s390x
virglrenderer-0.6.0-1.20170210git76b3da97b.fc26.s390x
s390utils-ziomon-1.36.1-3.fc26.s390x
s390utils-osasnmpd-1.36.1-3.fc26.s390x
libXrandr-1.5.1-2.fc26.s390x
libglvnd-glx-1.0.0-1.fc26.s390x
texlive-ifxetex-svn19685.0.5-33.fc26.2.noarch
texlive-psnfss-svn33946.9.2a-33.fc26.2.noarch
texlive-dvipdfmx-def-svn40328-33.fc26.2.noarch
texlive-natbib-svn20668.8.31b-33.fc26.2.noarch
texlive-xdvi-bin-svn40750-33.20160520.fc26.2.s390x
texlive-cm-svn32865.0-33.fc26.2.noarch
texlive-beton-svn15878.0-33.fc26.2.noarch
texlive-fpl-svn15878.1.002-33.fc26.2.noarch
texlive-mflogo-svn38628-33.fc26.2.noarch
texlive-texlive-docindex-svn41430-33.fc26.2.noarch
texlive-luaotfload-bin-svn34647.0-33.20160520.fc26.2.noarch
texlive-koma-script-svn41508-33.fc26.2.noarch
texlive-pst-tree-svn24142.1.12-33.fc26.2.noarch
texlive-breqn-svn38099.0.98d-33.fc26.2.noarch
texlive-xetex-svn41438-33.fc26.2.noarch
gstreamer1-plugins-bad-free-1.12.3-1.fc26.s390x
xorg-x11-font-utils-7.5-33.fc26.s390x
ghostscript-fonts-5.50-36.fc26.noarch
libXext-devel-1.3.3-5.fc26.s390x
libusbx-devel-1.0.21-2.fc26.s390x
libglvnd-devel-1.0.0-1.fc26.s390x
emacs-25.3-3.fc26.s390x
alsa-lib-devel-1.1.4.1-1.fc26.s390x
kbd-2.0.4-2.fc26.s3

Re: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

2018-02-02 Thread no-reply
Hi,

This series failed build test on s390x host. Please find the details below.

Type: series
Message-id: 20180202143746.204851-1-borntrae...@de.ibm.com
Subject: [Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
set -e
echo "=== ENV ==="
env
echo "=== PACKAGES ==="
rpm -qa
echo "=== TEST BEGIN ==="
CC=$HOME/bin/cc
INSTALL=$PWD/install
BUILD=$PWD/build
echo -n "Using CC: "
realpath $CC
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --cc=$CC --prefix=$INSTALL
make -j4
# XXX: we need reliable clean up
# make check -j4 V=1
make install
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]   patchew/20180202183731.29990-1-arm...@redhat.com -> 
patchew/20180202183731.29990-1-arm...@redhat.com
Switched to a new branch 'test'
ac346828ac s390x/cpu: expose the guest crash information

=== OUTPUT BEGIN ===
=== ENV ===
LANG=en_US.UTF-8
XDG_SESSION_ID=38971
USER=fam
PWD=/var/tmp/patchew-tester-tmp-wkfticyp/src
HOME=/home/fam
SHELL=/bin/sh
SHLVL=2
PATCHEW=/home/fam/patchew/patchew-cli -s http://patchew.org --nodebug
LOGNAME=fam
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1012/bus
XDG_RUNTIME_DIR=/run/user/1012
PATH=/usr/bin:/bin
_=/usr/bin/env
=== PACKAGES ===
gpg-pubkey-873529b8-54e386ff
glibc-debuginfo-common-2.24-10.fc25.s390x
fedora-release-26-1.noarch
dejavu-sans-mono-fonts-2.35-4.fc26.noarch
xemacs-filesystem-21.5.34-22.20170124hgf412e9f093d4.fc26.noarch
bash-4.4.12-7.fc26.s390x
freetype-2.7.1-9.fc26.s390x
libSM-1.2.2-5.fc26.s390x
libmpc-1.0.2-6.fc26.s390x
libaio-0.3.110-7.fc26.s390x
libverto-0.2.6-7.fc26.s390x
perl-Scalar-List-Utils-1.48-1.fc26.s390x
iptables-libs-1.6.1-2.fc26.s390x
perl-threads-shared-1.57-1.fc26.s390x
p11-kit-trust-0.23.9-2.fc26.s390x
tcl-8.6.6-2.fc26.s390x
libxshmfence-1.2-4.fc26.s390x
expect-5.45-23.fc26.s390x
perl-Thread-Queue-3.12-1.fc26.noarch
perl-encoding-2.19-6.fc26.s390x
keyutils-1.5.10-1.fc26.s390x
gmp-devel-6.1.2-4.fc26.s390x
enchant-1.6.0-16.fc26.s390x
net-snmp-libs-5.7.3-17.fc26.s390x
python-gobject-base-3.24.1-1.fc26.s390x
python3-distro-1.0.3-1.fc26.noarch
python3-enchant-1.6.10-1.fc26.noarch
python-lockfile-0.11.0-6.fc26.noarch
python2-pyparsing-2.1.10-3.fc26.noarch
python2-lxml-4.1.1-1.fc26.s390x
librados2-10.2.7-2.fc26.s390x
trousers-lib-0.3.13-7.fc26.s390x
libpaper-1.1.24-14.fc26.s390x
libdatrie-0.2.9-4.fc26.s390x
libsoup-2.58.2-1.fc26.s390x
passwd-0.79-9.fc26.s390x
bind99-libs-9.9.10-3.P3.fc26.s390x
python3-rpm-4.13.0.2-1.fc26.s390x
mock-core-configs-27.4-1.fc26.noarch
systemd-233-7.fc26.s390x
virglrenderer-0.6.0-1.20170210git76b3da97b.fc26.s390x
s390utils-ziomon-1.36.1-3.fc26.s390x
s390utils-osasnmpd-1.36.1-3.fc26.s390x
libXrandr-1.5.1-2.fc26.s390x
libglvnd-glx-1.0.0-1.fc26.s390x
texlive-ifxetex-svn19685.0.5-33.fc26.2.noarch
texlive-psnfss-svn33946.9.2a-33.fc26.2.noarch
texlive-dvipdfmx-def-svn40328-33.fc26.2.noarch
texlive-natbib-svn20668.8.31b-33.fc26.2.noarch
texlive-xdvi-bin-svn40750-33.20160520.fc26.2.s390x
texlive-cm-svn32865.0-33.fc26.2.noarch
texlive-beton-svn15878.0-33.fc26.2.noarch
texlive-fpl-svn15878.1.002-33.fc26.2.noarch
texlive-mflogo-svn38628-33.fc26.2.noarch
texlive-texlive-docindex-svn41430-33.fc26.2.noarch
texlive-luaotfload-bin-svn34647.0-33.20160520.fc26.2.noarch
texlive-koma-script-svn41508-33.fc26.2.noarch
texlive-pst-tree-svn24142.1.12-33.fc26.2.noarch
texlive-breqn-svn38099.0.98d-33.fc26.2.noarch
texlive-xetex-svn41438-33.fc26.2.noarch
gstreamer1-plugins-bad-free-1.12.3-1.fc26.s390x
xorg-x11-font-utils-7.5-33.fc26.s390x
ghostscript-fonts-5.50-36.fc26.noarch
libXext-devel-1.3.3-5.fc26.s390x
libusbx-devel-1.0.21-2.fc26.s390x
libglvnd-devel-1.0.0-1.fc26.s390x
emacs-25.3-3.fc26.s390x
alsa-lib-devel-1.1.4.1-1.fc26.s390x
kbd-2.0.4-2.fc26.s390x
dconf-0.26.0-2.fc26.s390x
ccache-3.3.4-1.fc26.s390x
glibc-static-2.25-12.fc26.s390x
mc-4.8.19-5.fc26.s390x
doxygen-1.8.13-9.fc26.s390x
dpkg-1.18.24-1.fc26.s390x
libtdb-1.3.13-1.fc26.s390x
python2-pynacl-1.1.1-1.fc26.s390x
nss-sysinit-3.34.0-1.0.fc26.s390x
kernel-4.13.16-202.fc26.s390x
perl-Filter-1.58-1.fc26.s390x
python2-pip-9.0.1-11.fc26.noarch
dnf-2.7.5-2.fc26.noarch
pcre2-utf16-10.23-11.fc26.s390x
glusterfs-devel-3.10.8-1.fc26.s390x
sssd-common-1.16.0-4.fc26.s390x
python2-sssdconfig-1.16.0-4.fc26.noarch
acpica-tools-20171110-1.fc26.s390x
glibc-debuginfo-2.24-10.fc25.s390x
fedora-repos-26-1.noarch
dejavu-fonts-common-2.35-4.fc26.noarch
bind99-license-9.9.10-3.P3.fc26.noarch
ncurses-libs-6.0-8.20170212.fc26.s390x
libpng-1.6.28-2.fc26.s390x
libICE-1.0.9-9.fc26.s390x
kmod-24-1.fc26.s390x
libseccomp-2.3.2-1.fc26.s390x
perl-Text-ParseWords-3.30-366.fc26.noarch
libtool-ltdl-2.4.6-17.fc26.s390x
perl-threads-2.16-1.fc26.s390x
libselinux-utils-2.6-7.fc26.s390x
userspace-rcu-0.9.3-2.fc26.s390x
libXfont-1.5.2-5.fc26.s390x
perl-Cla

Re: [Qemu-devel] [PATCH v7 15/15] target: Use qemu_log() instead of fprintf(stderr, ...)

2018-02-02 Thread Eric Blake
On 02/02/2018 12:37 PM, Markus Armbruster wrote:
> From: Alistair Francis 
> 
> Convert fprintf(stderr, ...) to use qemu_log(). Double prints in
> target/ppc/translate.c were manually remove. A fprintf() in
> target/sh4/translate.c was kept as it's inside a #if 0. The #if 0 and
> fflush() was removed around the unimplemented log in
> target/sh4/translate.c as well.
> 
> Signed-off-by: Alistair Francis 
> [Trivial conflict with 6f1c2af641d resolved]
> Signed-off-by: Markus Armbruster 
> ---
>  dtc  |  2 +-
>  target/cris/translate.c  |  2 +-
>  target/ppc/translate.c   | 36 ++--
>  target/sh4/translate.c   |  7 ++-
>  target/unicore32/translate.c |  2 +-
>  5 files changed, 15 insertions(+), 34 deletions(-)
> 
> diff --git a/dtc b/dtc
> index e54388015a..558cd81bdd 16
> --- a/dtc
> +++ b/dtc
> @@ -1 +1 @@
> -Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42
> +Subproject commit 558cd81bdd432769b59bff01240c44f82cfb1a9d

Intentional?

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



signature.asc
Description: OpenPGP digital signature


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

2018-02-02 Thread no-reply
Hi,

This series failed build test on ppc host. Please find the details below.

Subject: [Qemu-devel] [PATCH RFC 00/21] Modularize generated QAPI code
Type: series
Message-id: 20180202130336.24719-1-arm...@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
set -e
echo "=== ENV ==="
env
echo "=== PACKAGES ==="
rpm -qa
echo "=== TEST BEGIN ==="
INSTALL=$PWD/install
BUILD=$PWD/build
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --prefix=$INSTALL
make -j100
# XXX: we need reliable clean up
# make check -j100 V=1
make install
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag] patchew/20180202183731.29990-1-arm...@redhat.com -> 
patchew/20180202183731.29990-1-arm...@redhat.com
Submodule 'capstone' (git://git.qemu.org/capstone.git) registered for path 
'capstone'
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Submodule 'roms/QemuMacDrivers' (git://git.qemu.org/QemuMacDrivers.git) 
registered for path 'roms/QemuMacDrivers'
Submodule 'roms/SLOF' (git://git.qemu-project.org/SLOF.git) registered for path 
'roms/SLOF'
Submodule 'roms/ipxe' (git://git.qemu-project.org/ipxe.git) registered for path 
'roms/ipxe'
Submodule 'roms/openbios' (git://git.qemu-project.org/openbios.git) registered 
for path 'roms/openbios'
Submodule 'roms/openhackware' (git://git.qemu-project.org/openhackware.git) 
registered for path 'roms/openhackware'
Submodule 'roms/qemu-palcode' (git://github.com/rth7680/qemu-palcode.git) 
registered for path 'roms/qemu-palcode'
Submodule 'roms/seabios' (git://git.qemu-project.org/seabios.git/) registered 
for path 'roms/seabios'
Submodule 'roms/seabios-hppa' (git://github.com/hdeller/seabios-hppa.git) 
registered for path 'roms/seabios-hppa'
Submodule 'roms/sgabios' (git://git.qemu-project.org/sgabios.git) registered 
for path 'roms/sgabios'
Submodule 'roms/skiboot' (git://git.qemu.org/skiboot.git) registered for path 
'roms/skiboot'
Submodule 'roms/u-boot' (git://git.qemu-project.org/u-boot.git) registered for 
path 'roms/u-boot'
Submodule 'roms/vgabios' (git://git.qemu-project.org/vgabios.git/) registered 
for path 'roms/vgabios'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 'capstone'...
Submodule path 'capstone': checked out 
'22ead3e0bfdb87516656453336160e0a37b066bf'
Cloning into 'dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Cloning into 'roms/QemuMacDrivers'...
Submodule path 'roms/QemuMacDrivers': checked out 
'd4e7d7ac663fcb55f1b93575445fcbca372f17a7'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out 
'fa981320a1e0968d6fc1b8de319723ff8212b337'
Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 
'0600d3ae94f93efd10fc6b3c7420a9557a3a1670'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out 
'b5c93acd14b7b3886c2c81d84cd18e666984a4c8'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 
'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out 
'f3c7e44c70254975df2a00af39701eafbac4d471'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 
'63451fca13c75870e1703eb3e20584d91179aebc'
Cloning into 'roms/seabios-hppa'...
Submodule path 'roms/seabios-hppa': checked out 
'8fa4ca9935669414a824ecda24f6e70c36e8dc94'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 
'cbaee52287e5f32373181cff50a00b6c4ac9015a'
Cloning into 'roms/skiboot'...
Submodule path 'roms/skiboot': checked out 
'e0ee24c27a172bcf482f6f2bc905e6211c134bcc'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 
'd85ca029f257b53a96da6c2fb421e78a003a9943'
Cloning into 'roms/vgabios'...
Submodule path 'roms/vgabios': checked out 
'19ea12c230ded95928ecaef0db47a82231c2e485'
Cloning into 'ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'10739aa26051a5d49d88132604539d3ed085e72e'
Switched to a new branch 'test'
c046d2f qapi: Empty out qapi-schema.json
cdc6347 Include less of qapi-types.h
6c08b68 qapi/types: Generate separate .h, .c for each module
3d0eed2 qapi/common: Fix guardname() for funny filenames
0711fd2 qapi/types qapi/visit: Generate built-in stuff into separate files
7ede026 qapi/types qapi/visit: Make visitors use QAPIGen more
5692214 qapi: Record 'include' directives in intermediate representation
429e27e qapi: Generate in source order
0c655e9 qapi: Record 'include' directives in parse tree
4253516 qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()
ab1ec20 qapi: Lift error reporting from QAPISchema.__init__() to callers
471fb6f qapi/common: Eliminate QAPISchema.exprs
60e5203 qapi: Don't absolutize include fi

Re: [Qemu-devel] [PATCH v7 00/15] Remove some of the fprintf(stderr, "*

2018-02-02 Thread Alistair Francis
On Fri, Feb 2, 2018 at 10:37 AM, Markus Armbruster  wrote:
> This is my attempt to salvage a good part of Alistair's error
> reporting cleanup series
>
> [PATCH v6 00/29]  Remove some of the fprintf(stderr, "*
>
> Continue on improving QEMUs logging/error messages by removing more
> fprintf()'s.
>
> Unfortunatley my Coccinelle skills aren't that great so it's all done in
> some nasty regex and a little bit of manual work.
>
> It foundered on the problem that some of its fprintf() to
> error_report() conversions are inappropriate, see
>
> Message-ID: <87lghulqno@dusky.pond.sub.org>
> https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg04961.html
>
> Alistair didn't feel like checking about one hundred conversions by
> hand, which is understandable.  But letting the work go to waste would
> be a shame, so I wrote an AWK script (see below) to extract a common
> kind of obviously good conversions: the ones where the fprintf() is
> followed by exit().  Judging from the diffstat, this salvages more
> than half of his conversion work.
>
> v7:
> * Old PATCH 02,03,21 are already in master, drop
> * Conversions not obviously followed by exit() dropped
>   Nothing left in old PATCH 06-12,16,17,22, drop
>   R-bys dropped
> * Rebased, trivial conflict in the last patch resolved
>
>
> #!/usr/bin/awk -f
>
> hunk && /^\+[ \t]*error_report/ {
> n++
> er_indent = match(substr($0, 2), /[^ \t]/)
> er_nr = NR
> plus = 0
> fatal = 0
> }
>
> hunk && er_indent && /^\+/ {
> plus++
> }
>
> hunk && er_indent && /^[ \t]*exit/ {
> d = NR - er_nr - plus
> if (maxd < d)
> maxd = d
> fatal = 1
> }
>
> hunk && er_indent && match(substr($0, 2), /[^ \t]/) < er_indent {
> if (fatal)
> nf++
> er_indent = 0
> }
>
> hunk && /^[-+ ]/ {
> hunk = hunk "\n" $0
> next
> }
>
> hunk {
> if (n && nf && n != nf)
> print loc, "mixed hunk", n, nf >"/dev/stderr"
> else if (n && !nf)
> print loc, "non-fatal hunk", n, nf >"/dev/stderr"
> else if (!n || nf)
> print hunk
> hunk = ""
> }
>
> /^@@ / {
> hunk = $0
> loc = FILENAME ":" FNR ":"
> n = nf = 0
> next
> }
>
> {
> print
> }
>
> END {
> print "max distance", maxd+0 >"/dev/stderr"
> }

Awesome!

I'm glad this isn't being wasted.

Alistair

>
> Alistair Francis (15):
>   audio: Replace AUDIO_FUNC with __func__
>   hw/arm: Replace fprintf(stderr, "*\n" with error_report()
>   hw/dma: Replace fprintf(stderr, "*\n" with error_report()
>   hw/lm32: Replace fprintf(stderr, "*\n" with error_report()
>   hw/mips: Replace fprintf(stderr, "*\n" with error_report()
>   hw/moxie: Replace fprintf(stderr, "*\n" with error_report()
>   hw/openrisc: Replace fprintf(stderr, "*\n" with error_report()
>   hw/pci*: Replace fprintf(stderr, "*\n" with error_report()
>   hw/ppc: Replace fprintf(stderr, "*\n" with error_report()
>   hw/sd: Replace fprintf(stderr, "*\n" with error_report()
>   hw/sparc*: Replace fprintf(stderr, "*\n" with error_report()
>   hw/timer: Replace fprintf(stderr, "*\n" with error_report()
>   hw/xen*: Replace fprintf(stderr, "*\n" with error_report()
>   tcg: Replace fprintf(stderr, "*\n" with error_report()
>   target: Use qemu_log() instead of fprintf(stderr, ...)
>
>  audio/alsaaudio.c|  4 ++--
>  audio/audio.c| 40 +++
>  audio/audio_int.h|  6 -
>  audio/audio_pt_int.c | 28 +++---
>  audio/audio_template.h   | 26 ++--
>  audio/dsoundaudio.c  |  2 +-
>  audio/mixeng.c   |  2 +-
>  audio/ossaudio.c | 10 
>  audio/paaudio.c  | 56 
> ++--
>  audio/sdlaudio.c |  2 +-
>  audio/wavaudio.c |  2 +-
>  cpus.c   | 10 
>  dtc  |  2 +-
>  exec.c   |  6 ++---
>  hw/arm/armv7m.c  |  2 +-
>  hw/arm/boot.c| 16 ++---
>  hw/arm/gumstix.c | 13 +-
>  hw/arm/mainstone.c   |  7 +++---
>  hw/arm/musicpal.c|  2 +-
>  hw/arm/omap1.c   |  5 ++--
>  hw/arm/omap2.c   |  3 ++-
>  hw/arm/omap_sx1.c|  2 +-
>  hw/arm/pxa2xx.c  |  7 +++---
>  hw/arm/vexpress.c|  8 +++
>  hw/arm/z2.c  |  6 ++---
>  hw/dma/soc_dma.c | 36 ++--
>  hw/lm32/lm32_boards.c|  7 +++---
>  hw/lm32/milkymist.c  |  7 +++---
>  hw/mips/mips_fulong2e.c  | 13 +-
>  hw/mips/mips_jazz.c  |  4 ++--
>  hw/mips/mips_malta.c | 16 ++---
>  hw/mips/mips_mipssim.c   | 11 -
>  hw/mips/mips_r4k.c   | 16 ++---
>  hw/moxie/moxiesim.c  | 13 +-
>  hw/openrisc/openrisc_sim.c   |  4 ++--
>  hw/pci-host/bonito.c |  6 ++---
>  hw

[Qemu-devel] [PATCH v1 1/1] hw: register: Run post_write hook on reset

2018-02-02 Thread Alistair Francis
Ensure that the post write hook is called during reset. This allows us
to rely on the post write functions instead of having to call them from
the reset() function.

Signed-off-by: Alistair Francis 
---

 hw/core/register.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/hw/core/register.c b/hw/core/register.c
index 900294b9c4..0741a1af32 100644
--- a/hw/core/register.c
+++ b/hw/core/register.c
@@ -159,13 +159,21 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, 
const char* prefix,
 
 void register_reset(RegisterInfo *reg)
 {
+const RegisterAccessInfo *ac;
+
 g_assert(reg);
 
 if (!reg->data || !reg->access) {
 return;
 }
 
+ac = reg->access;
+
 register_write_val(reg, reg->access->reset);
+
+if (ac->post_write) {
+ac->post_write(reg, reg->access->reset);
+}
 }
 
 void register_init(RegisterInfo *reg)
-- 
2.14.1




Re: [Qemu-devel] [PATCH RFC 08/21] qapi: Touch generated files only when they change

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> A massive number of objects depends on QAPI-generated headers.  In my
> "build everything" tree, it's roughly 4500 out of 4800.  This is
> particularly annoying when only some of the generated files change,
> say for a doc fix.
> 
> Improve qapi-gen.py to touch its output files only if they actually
> change.  Rebuild time for a QAPI doc fix drops from many minutes to a
> few seconds.  Rebuilds get faster for certain code changes, too.  For
> instance, adding a simple QMP event now recompiles less than 200
> instead of 4500 objects.  But adding a QAPI type is as bad as ever; we
> clearly got more work to do.

The last phrase sounds quite colloquial.  It may have been intentional;
but if not, s/we/we've/

> 
> Signed-off-by: Markus Armbruster 
> ---
>  scripts/qapi/common.py | 11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index cfa2671ca3..be0fcc548a 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -1944,9 +1944,16 @@ class QAPIGen(object):
>  except os.error as e:
>  if e.errno != errno.EEXIST:
>  raise
> -f = open(os.path.join(output_dir, fname), 'w')
> -f.write(self.top(fname) + self._preamble + self._body
> +fd = os.open(os.path.join(output_dir, fname),
> + os.O_RDWR | os.O_CREAT, 0666)
> +f = os.fdopen(fd, 'r+')
> +text = (self.top(fname) + self._preamble + self._body
>  + self.bottom(fname))
> +oldtext = f.read(len(text) + 1)
> +if text != oldtext:
> +f.seek(0)
> +f.truncate(0)
> +f.write(text)

In-memory rewrite rather than playing games with a secondary file
combined with the rename(2) syscall.  It means you're not atomic (an
external reader has a window of time where they can see an incomplete
version of the file).  But I think make dependency rules mean we don't
care - even in a parallel rule, as long as all clients depend on the
timestamp file, and the timestamp file isn't updated until all our
rewrites (if any) have settled, then we don't create any of those
external readers that can find the window of incomplete contents.

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] [RFC 0/2] virtio-vhost-user: add virtio-vhost-user device

2018-02-02 Thread Stefan Hajnoczi
On Tue, Jan 30, 2018 at 08:09:19PM +0800, Wei Wang wrote:
> On 01/26/2018 10:44 PM, Stefan Hajnoczi wrote:
> > On Thu, Jan 25, 2018 at 06:19:13PM +0800, Wei Wang wrote:
> > > On 01/24/2018 07:40 PM, Stefan Hajnoczi wrote:
> > > > On Tue, Jan 23, 2018 at 09:06:49PM +0800, Wei Wang wrote:
> > > > > On 01/23/2018 07:12 PM, Stefan Hajnoczi wrote:
> > > > > > On Mon, Jan 22, 2018 at 07:09:06PM +0800, Wei Wang wrote:
> > > > > > > On 01/19/2018 09:06 PM, Stefan Hajnoczi wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > - Suppose in the future there is also a kernel 
> > > > > > > virtio-vhost-user driver as
> > > > > > > other PCI devices, can we unbind the kernel driver first, and 
> > > > > > > then bind the
> > > > > > > device to the dpdk driver? A normal PCI device should be able to 
> > > > > > > smoothly
> > > > > > > switch between the kernel driver and dpdk driver.
> > > > > > It depends what you mean by "smoothly switch".
> > > > > > 
> > > > > > If you mean whether it's possible to go from a kernel driver to
> > > > > > vfio-pci, then the answer is yes.
> > > > > > 
> > > > > > But if the kernel driver has an established vhost-user connection 
> > > > > > then
> > > > > > it will be closed.  This is the same as reconnecting with AF_UNIX
> > > > > > vhost-user.
> > > > > > 
> > > > > Actually not only the case of switching to testpmd after kernel 
> > > > > establishes
> > > > > the connection, but also for several runs of testpmd. That is, if we 
> > > > > run
> > > > > testpmd, then exit testpmd. I think the second run of testpmd won't 
> > > > > work.
> > > > The vhost-user master must reconnect and initialize again (SET_FEATURES,
> > > > SET_MEM_TABLE, etc).  Is your master reconnecting after the AF_UNIX
> > > > connection is closed?
> > > Is this an explicit qmp operation to make the master re-connect?
> > I haven't tested it myself but I'm aware of two modes of operation:
> > 
> > 1. -chardev socket,id=chardev0,...,server
> > -netdev vhost-user,chardev=chardev0
> > 
> > When the vhost-user socket is disconnected the peer needs to
> > reconnect.  In this case no special commands are necessary.
> > 
> > Here we're relying on DPDK librte_vhost's reconnection behavior.
> > 
> > Or
> > 
> > 2. -chardev socket,id=chardev0,...,reconnect=3
> > -netdev vhost-user,chardev=chardev0
> > 
> > When the vhost-user socket is disconnected a new connection attempt
> > will be made after 3 seconds.
> > 
> > In both cases vhost-user negotiation will resume when the new connection
> > is established.
> > 
> > Stefan
> 
> I've been thinking about the issues, and it looks vhost-pci outperforms in
> this aspect.
> Vhost-pci is like using a mail box. messages are just dropped into the box,
> and whenever vhost-pci pmd gets booted, it can always get the messages from
> the box, the negotiation between vhost-pci pmd and virtio-net is
> asynchronous.
> Virtio-vhost-user is like a phone call, which is a synchronous
> communication. If one side is absent, then the other side will hang on
> without knowing when it could get connected or hang up with messages not
> passed (lost).
> 
> I also think the above solutions won't help. Please see below:
> 
> Background:
> The vhost-user negotiation is split into 2 phases currently. The 1st phase
> happens when the connection is established, and we can find what's done in
> the 1st phase in vhost_user_init(). The 2nd phase happens when the master
> driver is loaded (e.g. run of virtio-net pmd) and set status to the device,
> and we can find what's done in the 2nd phase in vhost_dev_start(), which
> includes sending the memory info and virtqueue info. The socket is
> connected, till one of the QEMU devices exits, so pmd exiting won't end the
> QEMU side socket connection.
>
> 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.

This isn't a problem for virtio-vhost-user since the vhost-pmd resets
the virtio-vhost-user device when it restarts.  The vhost-user AF_UNIX
socket reconnects and negotiation restarts.

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH] kvm: check dev parameter when updating msi route

2018-02-02 Thread Radim Krčmář
This should primarily go to the qemu devel list.  I've Cc'd it, but
reposting would be safer, thanks.


2018-02-02 10:21+0530, P J P:
> From: Prasad J Pandit 
> 
> When updating message signalled interrupt(MSI) route in routine
> kvm_irqchip_update_msi_route, device parameter could be null.
> Add check to avoid null dereference.
> 
> Reported-by: Guoxiang Niu 
> Signed-off-by: Prasad J Pandit 
> ---
>  accel/kvm/kvm-all.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index f290f487a5..cb7613d282 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -1167,7 +1167,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, 
> PCIDevice *dev)
>  kroute.u.msi.address_lo = (uint32_t)msg.address;
>  kroute.u.msi.address_hi = msg.address >> 32;
>  kroute.u.msi.data = le32_to_cpu(msg.data);
> -if (pci_available && kvm_msi_devid_required()) {
> +if (pci_available && dev && kvm_msi_devid_required()) {
>  kroute.flags = KVM_MSI_VALID_DEVID;
>  kroute.u.msi.devid = pci_requester_id(dev);
>  }
> @@ -1205,7 +1205,7 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, 
> MSIMessage msg,
>  kroute.u.msi.address_lo = (uint32_t)msg.address;
>  kroute.u.msi.address_hi = msg.address >> 32;
>  kroute.u.msi.data = le32_to_cpu(msg.data);
> -if (pci_available && kvm_msi_devid_required()) {
> +if (pci_available && dev && kvm_msi_devid_required()) {
>  kroute.flags = KVM_MSI_VALID_DEVID;
>  kroute.u.msi.devid = pci_requester_id(dev);
>  }
> -- 
> 2.14.3
> 



Re: [Qemu-devel] [PATCH v7 02/15] hw/arm: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Eric Blake
On 02/02/2018 12:37 PM, Markus Armbruster wrote:
> From: Alistair Francis 
> 
> Replace a large number of the fprintf(stderr, "*\n" calls with
> error_report(). The functions were renamed with these commands and then
> compiler issues where manually fixed.
> 

> 
> Some lines where then manually tweaked to pass checkpatch.
> 
> The 'qemu: ' prefix was manually removed from the hw/arm/boot.c file.
> 
> Signed-off-by: Alistair Francis 
> Cc: qemu-...@nongnu.org
> 
> Conversions that aren't followed by exit() dropped, because they might
> be inappropriate.
> 
> Signed-off-by: Markus Armbruster 
> ---

> +++ b/hw/arm/gumstix.c
> @@ -35,6 +35,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/error-report.h"
>  #include "hw/hw.h"
>  #include "hw/arm/pxa.h"
>  #include "net/net.h"
> @@ -62,8 +63,8 @@ static void connex_init(MachineState *machine)
>  
>  dinfo = drive_get(IF_PFLASH, 0, 0);
>  if (!dinfo && !qtest_enabled()) {
> -fprintf(stderr, "A flash image must be given with the "
> -"'pflash' parameter\n");
> +error_report("A flash image must be given with the "
> + "'pflash' parameter");
>  exit(1);
>  }
>  
> @@ -76,7 +77,7 @@ static void connex_init(MachineState *machine)
> dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
> sector_len, connex_rom / sector_len,
> 2, 0, 0, 0, 0, be)) {
> -fprintf(stderr, "qemu: Error registering flash memory.\n");
> +error_report("Error registering flash memory.");

Do we care about consistency on trailing dots in these conversions?

At any rate, all of these are sane rewrites of existing patterns;
Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [Bug 1703795] Re: Unable to release mouse in SDL2 mode

2018-02-02 Thread Ruslan
I can confirm that the patch from comment #9 appears to fix the original
problem.

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

Title:
  Unable to release mouse in SDL2 mode

Status in QEMU:
  New

Bug description:
  Starting with commit 8f4ea9cd0b770dbe496d9d24f0ef8813fdbfe0d0 "sdl:
  prefer sdl2 over sdl1", I can no longer release mouse pointer grab
  unless I use --with-sdlabi=1.2 configure option.

  This easily reproduces in e.g. guest Kubuntu, when I let it start Xorg
  and then click into the QEMU window. After this the mouse is trapped
  and no matter how I combine Ctrl+Alt and motion of the cursor, the
  pointer never goes out from the window. When at the border, QEMU
  window switches from "Press Ctrl+Alt to exit grab" to "QEMU", i.e. it
  thinks that it has released the grab. But it hasn't really, so I have
  to go to VT1 and do "pkill qemu" from there to get my pointer back.

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



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

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster 
> ---
>  scripts/qapi-gen.py| 52 +++-
>  scripts/qapi/common.py | 54 
> --
>  2 files changed, 51 insertions(+), 55 deletions(-)
> 

Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


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

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> 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.

Yay, about time!

One program, but still invoked multiple times:

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

Maybe the commit message should mention:

This requires moving some files around for proper use in python.

>  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

Unintinentional?  We're inconsistent on which of our *.py files are
executable in git.  Does it matter whether a file that is designed for
use as a module is marked executable (if so, perhaps 5/21 should be
adding the x attribute on other files, rather than this patch removing
it on the doc generator).

> +++ b/Makefile

> +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=%)")
> + @>$@

once for qga,


> +qapi-types.c qapi-types.h \
> +qapi-visit.c qapi-visit.h \
> +qmp-commands.h qmp-marshal.c \
> +qapi-event.c qapi-event.h \
> +qmp-introspect.h qmp-introspect.c \
> +qapi.texi: \
> +qapi-gen-timestamp ;
> +qapi-gen-timestamp: $(qapi-modules) $(qapi-py)
> + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
> + -o "." -b $<, \
> + "GEN","$(@:%-timestamp=%)")
> + @>$@

and again for the main level.  Still, a definite improvement!

> +++ b/scripts/qapi-gen.py

> +def main(argv):
> +(input_file, output_dir, do_c, do_h, prefix, opts) = \
> +parse_command_line('bu', ['builtins', 'unmask-non-abi-names'])
> +
> +opt_builtins = False
> +opt_unmask = False
> +
> +for o, a in opts:
> +if o in ('-b', '--builtins'):
> +opt_builtins = True
> +if o in ('-u', '--unmask-non-abi-names'):
> +opt_unmask = True
> +
> +schema = QAPISchema(input_file)
> +
> +gen_types(schema, output_dir, prefix, opt_builtins)
> +gen_visit(schema, output_dir, prefix, opt_builtins)
> +gen_commands(schema, output_dir, prefix)
> +gen_events(schema, output_dir, prefix)
> +gen_introspect(schema, output_dir, prefix, opt_unmask)
> +gen_doc(schema, output_dir, prefix)

Rather simple, but definitely nicer all in one python file than as a
series of make rules.

> @@ -255,13 +255,8 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
>  self._regy += gen_register_command(name, success_response)
>  
>  
> -def main(argv):
> -(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
> -
> -blurb = '''
> - * Schema-defined QAPI/QMP commands
> -'''
> -
> +def gen_commands(schema, output_dir, prefix):
> +blurb = ' * Schema-defined QAPI/QMP commands'

Some churn on the definition of blurb; worth tidying this in the
introduction earlier in the series?

> rename to scripts/qapi/introspect.py
> index 09e7d1f140..2153060f2c 100644
> --- a/scripts/qapi-introspect.py
> +++ b/scripts/qapi/introspect.py
> @@ -10,7 +10,7 @@ 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 *
> +from qapi.common import *
>  
>  
>  # Caveman's json.dumps() replacement (we're stuck at Python 2.4)
> @@ -168,22 +168,8 @@ const char %(c_name)s[] = %(c_string)s;
>  self._gen_json(name, 'event', {'arg-ty

[Qemu-devel] [PATCH v7 02/15] hw/arm: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

The 'qemu: ' prefix was manually removed from the hw/arm/boot.c file.

Signed-off-by: Alistair Francis 
Cc: qemu-...@nongnu.org

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 hw/arm/armv7m.c|  2 +-
 hw/arm/boot.c  | 16 
 hw/arm/gumstix.c   | 13 +++--
 hw/arm/mainstone.c |  7 ---
 hw/arm/musicpal.c  |  2 +-
 hw/arm/omap1.c |  5 +++--
 hw/arm/omap2.c |  3 ++-
 hw/arm/omap_sx1.c  |  2 +-
 hw/arm/pxa2xx.c|  7 ---
 hw/arm/vexpress.c  |  8 
 hw/arm/z2.c|  6 +++---
 11 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index bb2dfc942b..56770a7048 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -278,7 +278,7 @@ void armv7m_load_kernel(ARMCPU *cpu, const char 
*kernel_filename, int mem_size)
 #endif
 
 if (!kernel_filename && !qtest_enabled()) {
-fprintf(stderr, "Guest image must be specified (using -kernel)\n");
+error_report("Guest image must be specified (using -kernel)");
 exit(1);
 }
 
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index c2720c8046..bb244ec359 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -8,6 +8,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "qapi/error.h"
 #include 
 #include "hw/hw.h"
@@ -690,7 +691,7 @@ static void load_image_to_fw_cfg(FWCfgState *fw_cfg, 
uint16_t size_key,
 gsize length;
 
 if (!g_file_get_contents(image_name, &contents, &length, NULL)) {
-fprintf(stderr, "failed to load \"%s\"\n", image_name);
+error_report("failed to load \"%s\"", image_name);
 exit(1);
 }
 size = length;
@@ -956,8 +957,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void 
*data)
 is_linux = 1;
 }
 if (kernel_size < 0) {
-fprintf(stderr, "qemu: could not load kernel '%s'\n",
-info->kernel_filename);
+error_report("could not load kernel '%s'", info->kernel_filename);
 exit(1);
 }
 info->entry = entry;
@@ -976,8 +976,8 @@ static void arm_load_kernel_notify(Notifier *notifier, void 
*data)
   info->initrd_start);
 }
 if (initrd_size < 0) {
-fprintf(stderr, "qemu: could not load initrd '%s'\n",
-info->initrd_filename);
+error_report("could not load initrd '%s'",
+ info->initrd_filename);
 exit(1);
 }
 } else {
@@ -1021,9 +1021,9 @@ static void arm_load_kernel_notify(Notifier *notifier, 
void *data)
 } else {
 fixupcontext[FIXUP_ARGPTR] = info->loader_start + KERNEL_ARGS_ADDR;
 if (info->ram_size >= (1ULL << 32)) {
-fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
-" Linux kernel using ATAGS (try passing a device tree"
-" using -dtb)\n");
+error_report("RAM size must be less than 4GB to boot"
+ " Linux kernel using ATAGS (try passing a device 
tree"
+ " using -dtb)");
 exit(1);
  

[Qemu-devel] [PATCH v7 03/15] hw/dma: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

Signed-off-by: Alistair Francis 

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 hw/dma/soc_dma.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/hw/dma/soc_dma.c b/hw/dma/soc_dma.c
index 9bb499bf9c..45516241c6 100644
--- a/hw/dma/soc_dma.c
+++ b/hw/dma/soc_dma.c
@@ -18,6 +18,7 @@
  * with this program; if not, see .
  */
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "qemu-common.h"
 #include "qemu/timer.h"
 #include "hw/arm/soc_dma.h"
@@ -270,11 +271,11 @@ void soc_dma_port_add_fifo(struct soc_dma_s *soc, hwaddr 
virt_base,
 if (entry->type == soc_dma_port_mem) {
 if (entry->addr <= virt_base &&
 entry->addr + entry->u.mem.size > virt_base) {
-fprintf(stderr, "%s: FIFO at %"PRIx64
-" collides with RAM region at %"PRIx64
-"-%"PRIx64 "\n", __func__,
-virt_base, entry->addr,
-(entry->addr + entry->u.mem.size));
+error_report("%s: FIFO at %"PRIx64
+ " collides with RAM region at %"PRIx64
+ "-%"PRIx64, __func__,
+ virt_base, entry->addr,
+ (entry->addr + entry->u.mem.size));
 exit(-1);
 }
 
@@ -284,9 +285,9 @@ void soc_dma_port_add_fifo(struct soc_dma_s *soc, hwaddr 
virt_base,
 while (entry < dma->memmap + dma->memmap_size &&
 entry->addr <= virt_base) {
 if (entry->addr == virt_base && entry->u.fifo.out == out) {
-fprintf(stderr, "%s: FIFO at %"PRIx64
-" collides FIFO at %"PRIx64 "\n",
-__func__, virt_base, entry->addr);
+error_report("%s: FIFO at %"PRIx64
+ " collides FIFO at %"PRIx64,
+ __func__, virt_base, entry->addr);
 exit(-1);
 }
 
@@ -321,11 +322,11 @@ void soc_dma_port_add_mem(struct soc_dma_s *soc, uint8_t 
*phys_base,
 if ((entry->addr >= virt_base && entry->addr < virt_base + size) ||
 (entry->addr <= virt_base &&
  entry->addr + entry->u.mem.size > virt_base)) {
-fprintf(stderr, "%s: RAM at %"PRIx64 "-%"PRIx64
-" collides with RAM region at %"PRIx64
-"-%"PRIx64 "\n", __func__,
-virt_base, virt_base + size,
-entry->addr, entry->addr + entry->u.mem.size);
+error_report("%s: RAM at %"PRIx64 "-%"PRIx64
+ " collides with RAM region at %"PRIx64
+ "-%"PRIx64, __func__,
+ virt_base, virt_base + size,
+ entry->addr, entry->addr + entry->u.mem.size);
 exit(-1);
 }
 
@@ -334,11 +335,10 @@ void soc_dma_port_add_mem(st

[Qemu-devel] [PATCH v7 13/15] hw/xen*: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

xen_pt_log() was left with an fprintf(stderr,

Signed-off-by: Alistair Francis 
Cc: Stefano Stabellini 
Cc: Anthony Perard 

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 hw/xen/xen-common.c   | 5 +++--
 hw/xenpv/xen_machine_pv.c | 9 +
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
index 632a938dcc..afa1e3f404 100644
--- a/hw/xen/xen-common.c
+++ b/hw/xen/xen-common.c
@@ -9,6 +9,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "hw/xen/xen_backend.h"
 #include "qmp-commands.h"
 #include "chardev/char.h"
@@ -96,13 +97,13 @@ static void xenstore_record_dm_state(struct xs_handle *xs, 
const char *state)
 char path[50];
 
 if (xs == NULL) {
-fprintf(stderr, "xenstore connection not initialized\n");
+error_report("xenstore connection not initialized");
 exit(1);
 }
 
 snprintf(path, sizeof (path), "device-model/%u/state", xen_domid);
 if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
-fprintf(stderr, "error recording dm state\n");
+error_report("error recording dm state");
 exit(1);
 }
 }
diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c
index 69a52a9f93..44d67b87c4 100644
--- a/hw/xenpv/xen_machine_pv.c
+++ b/hw/xenpv/xen_machine_pv.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "hw/xen/xen_backend.h"
@@ -36,7 +37,7 @@ static void xen_init_pv(MachineState *machine)
 
 /* Initialize backend core & drivers */
 if (xen_be_init() != 0) {
-fprintf(stderr, "%s: xen backend core setup failed\n", __func__);
+error_report("%s: xen backend core setup failed", __func__);
 exit(1);
 }
 
@@ -51,18 +52,18 @@ static void xen_init_pv(MachineState *machine)
 const char *initrd_filename = machine->initrd_filename;
 if (xen_domain_build_pv(kernel_filename, initrd_filename,
 kernel_cmdline) < 0) {
-fprintf(stderr, "xen pv domain creation failed\n");
+error_report("xen pv domain creation failed");
 exit(1);
 }
 break;
 }
 #endif
 case XEN_EMULATE:
-fprintf(stderr, "xen emulation not implemented (yet)\n");
+error_report("xen emulation not implemented (yet)");
 exit(1);
 break;
 default:
-fprintf(stderr, "unhandled xen_mode %d\n", xen_mode);
+error_report("unhandled xen_mode %d", xen_mode);
 exit(1);
 break;
 }
-- 
2.13.6




[Qemu-devel] [PATCH v7 10/15] hw/sd: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

Some of the prints in hw/sd/sd.c were manually converted to using
DPRINTF() instead.

Signed-off-by: Alistair Francis 

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 hw/sd/sd.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 35347a5bbc..73e405a04f 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1564,9 +1564,10 @@ send_response:
 if (rsplen) {
 int i;
 DPRINTF("Response:");
-for (i = 0; i < rsplen; i++)
-fprintf(stderr, " %02x", response[i]);
-fprintf(stderr, " state %d\n", sd->state);
+for (i = 0; i < rsplen; i++) {
+DPRINTF(" %02x", response[i]);
+}
+DPRINTF(" state %d\n", sd->state);
 } else {
 DPRINTF("No response %d\n", sd->state);
 }
-- 
2.13.6




[Qemu-devel] [PATCH v7 11/15] hw/sparc*: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

Signed-off-by: Alistair Francis 
Cc: Fabien Chouteau 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Reviewed-by: Philippe Mathieu-Daudé 
Acked-by: Mark Cave-Ayland 
Signed-off-by: Markus Armbruster 
---
 hw/sparc/leon3.c | 16 +++-
 hw/sparc/sun4m.c | 16 +++-
 hw/sparc64/niagara.c |  4 ++--
 hw/sparc64/sun4u.c   | 10 +-
 4 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 8c66d5af24..bba3aa3dee 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -139,9 +140,8 @@ static void leon3_generic_hw_init(MachineState *machine)
 
 /* Allocate RAM */
 if ((uint64_t)ram_size > (1UL << 30)) {
-fprintf(stderr,
-"qemu: Too much memory for this machine: %d, maximum 1G\n",
-(unsigned int)(ram_size / (1024 * 1024)));
+error_report("Too much memory for this machine: %d, maximum 1G",
+ (unsigned int)(ram_size / (1024 * 1024)));
 exit(1);
 }
 
@@ -167,19 +167,18 @@ static void leon3_generic_hw_init(MachineState *machine)
 }
 
 if (bios_size > prom_size) {
-fprintf(stderr, "qemu: could not load prom '%s': file too big\n",
-filename);
+error_report("could not load prom '%s': file too big", filename);
 exit(1);
 }
 
 if (bios_size > 0) {
 ret = load_image_targphys(filename, 0x, bios_size);
 if (ret < 0 || ret > prom_size) {
-fprintf(stderr, "qemu: could not load prom '%s'\n", filename);
+error_report("could not load prom '%s'", filename);
 exit(1);
 }
 } else if (kernel_filename == NULL && !qtest_enabled()) {
-fprintf(stderr, "Can't read bios image %s\n", filename);
+error_report("Can't read bios image %s", filename);
 exit(1);
 }
 g_free(filename);
@@ -192,8 +191,7 @@ static void leon3_generic_hw_init(MachineState *machine)
 kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1 /* big endian */, EM_SPARC, 0, 0);
 if (kernel_size < 0) {
-fprintf(stderr, "qemu: could not load kernel '%s'\n",
-kernel_filename);
+error_report("could not load kernel '%s'", kernel_filename);
 exit(1);
 }
 if (bios_size <= 0) {
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index dd0038095b..f9892e38c3 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -259,8 +259,7 @@ static unsigned long sun4m_load_kernel(const char 
*kernel_filename,
   KERNEL_LOAD_ADDR,
   RAM_size - KERNEL_LOAD_ADDR);
 if (kernel_size < 0) {
-fprintf(stderr, "qemu: could not load kernel '%s'\n",
-kernel_filename);
+error_report("could not load kernel '%s'", kernel_filename);
 exit(1);
 }
 
@@ -271,8 +270,8 @@ static unsigned long sun4m_load_kernel(const char 
*kernel_filename,
   INITRD_LOAD_ADDR,
 

[Qemu-devel] [PATCH v7 09/15] hw/ppc: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines were then manually tweaked to pass checkpatch and some curly
braces were added to match QEMU style.

Signed-off-by: Alistair Francis 
Cc: qemu-...@nongnu.org

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 hw/ppc/e500.c  | 16 
 hw/ppc/mac_newworld.c  |  2 +-
 hw/ppc/mac_oldworld.c  |  2 +-
 hw/ppc/ppc405_boards.c | 15 ++-
 hw/ppc/ppc440_bamboo.c | 16 
 hw/ppc/prep.c  |  4 ++--
 hw/ppc/virtex_ml507.c  |  4 ++--
 7 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index c4fe06ea2a..3fb40b262f 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -811,8 +811,8 @@ void ppce500_init(MachineState *machine, PPCE500Params 
*params)
 cs = CPU(cpu);
 
 if (env->mmu_model != POWERPC_MMU_BOOKE206) {
-fprintf(stderr, "MMU model %i not supported by this machine.\n",
-env->mmu_model);
+error_report("MMU model %i not supported by this machine.",
+ env->mmu_model);
 exit(1);
 }
 
@@ -959,8 +959,8 @@ void ppce500_init(MachineState *machine, PPCE500Params 
*params)
   cur_base,
   ram_size - cur_base);
 if (kernel_size < 0) {
-fprintf(stderr, "qemu: could not load kernel '%s'\n",
-machine->kernel_filename);
+error_report("could not load kernel '%s'",
+ machine->kernel_filename);
 exit(1);
 }
 
@@ -974,8 +974,8 @@ void ppce500_init(MachineState *machine, PPCE500Params 
*params)
   ram_size - initrd_base);
 
 if (initrd_size < 0) {
-fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
-machine->initrd_filename);
+error_report("could not load initial ram disk '%s'",
+ machine->initrd_filename);
 exit(1);
 }
 
@@ -1016,7 +1016,7 @@ void ppce500_init(MachineState *machine, PPCE500Params 
*params)
 kernel_size = load_uimage(filename, &bios_entry, &loadaddr, NULL,
   NULL, NULL);
 if (kernel_size < 0) {
-fprintf(stderr, "qemu: could not load firmware '%s'\n", filename);
+error_report("could not load firmware '%s'", filename);
 exit(1);
 }
 }
@@ -1029,7 +1029,7 @@ void ppce500_init(MachineState *machine, PPCE500Params 
*params)
initrd_base, initrd_size,
kernel_base, kernel_size);
 if (dt_size < 0) {
-fprintf(stderr, "couldn't load device tree\n");
+error_report("couldn't load device tree");
 exit(1);
 }
 assert(dt_size < DTB_MAX_SIZE);
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 3fa7c429d5..b832417a56 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -270,7 +270,7 @@ static void ppc_core99_init(MachineState *machine)
 }
 }
 if (ppc_boot_device == '\0') {
-fprintf(stderr, "No valid boot device for Mac99 machine\n");
+error_report("No valid boot device for Ma

[Qemu-devel] [PATCH] mailmap: set preferred spelling for Daniel Berrangé

2018-02-02 Thread Daniel P . Berrangé
Signed-off-by: Daniel P. Berrangé 
---
 .mailmap | 4 
 1 file changed, 4 insertions(+)

diff --git a/.mailmap b/.mailmap
index ee81ac801e..cf689b9ec9 100644
--- a/.mailmap
+++ b/.mailmap
@@ -18,3 +18,7 @@ malc  malc 

 # There is also a:
 #(no author) <(no author)@c046a42c-6fe2-441c-8c8c-71466251a162>
 # for the cvs2svn initialization commit e63c3dc74bf.
+#
+# Also list preferred name forms where people have changed their
+# git author config
+Daniel P. Berrangé 
-- 
2.14.3




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

2018-02-02 Thread Peter Maydell
On 2 February 2018 at 08:32, Gerd Hoffmann  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:
>
>   git://git.kraxel.org/qemu tags/vga-20180202-pull-request
>
> for you to fetch changes up to 34e304e97576a9e17680c868c00ff524a981007b:
>
>   virtio-gpu: disallow vIOMMU (2018-02-02 08:53:22 +0100)
>
> 
> virtio-gpu: disallow vIOMMU
>
> 
>
> Peter Xu (1):
>   virtio-gpu: disallow vIOMMU
>
>  hw/display/virtio-gpu-pci.c | 8 +++-
>  hw/display/virtio-gpu.c | 5 +
>  2 files changed, 12 insertions(+), 1 deletion(-)

Applied, thanks.

-- PMM



[Qemu-devel] [PATCH v7 15/15] target: Use qemu_log() instead of fprintf(stderr, ...)

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Convert fprintf(stderr, ...) to use qemu_log(). Double prints in
target/ppc/translate.c were manually remove. A fprintf() in
target/sh4/translate.c was kept as it's inside a #if 0. The #if 0 and
fflush() was removed around the unimplemented log in
target/sh4/translate.c as well.

Signed-off-by: Alistair Francis 
[Trivial conflict with 6f1c2af641d resolved]
Signed-off-by: Markus Armbruster 
---
 dtc  |  2 +-
 target/cris/translate.c  |  2 +-
 target/ppc/translate.c   | 36 ++--
 target/sh4/translate.c   |  7 ++-
 target/unicore32/translate.c |  2 +-
 5 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/dtc b/dtc
index e54388015a..558cd81bdd 16
--- a/dtc
+++ b/dtc
@@ -1 +1 @@
-Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42
+Subproject commit 558cd81bdd432769b59bff01240c44f82cfb1a9d
diff --git a/target/cris/translate.c b/target/cris/translate.c
index f51a731db9..ff31311ed0 100644
--- a/target/cris/translate.c
+++ b/target/cris/translate.c
@@ -137,7 +137,7 @@ typedef struct DisasContext {
 
 static void gen_BUG(DisasContext *dc, const char *file, int line)
 {
-fprintf(stderr, "BUG: pc=%x %s %d\n", dc->pc, file, line);
+qemu_log("BUG: pc=%x %s %d\n", dc->pc, file, line);
 if (qemu_log_separate()) {
 qemu_log("BUG: pc=%x %s %d\n", dc->pc, file, line);
 }
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 4132f67bb1..172c9f2001 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -3933,12 +3933,8 @@ static inline void gen_op_mfspr(DisasContext *ctx)
  * allowing userland application to read the PVR
  */
 if (sprn != SPR_PVR) {
-fprintf(stderr, "Trying to read privileged spr %d (0x%03x) at "
-TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
-if (qemu_log_separate()) {
-qemu_log("Trying to read privileged spr %d (0x%03x) at "
- TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
-}
+qemu_log("Trying to read privileged spr %d (0x%03x) at "
+ TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
 }
 gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG);
 }
@@ -3950,12 +3946,8 @@ static inline void gen_op_mfspr(DisasContext *ctx)
 return;
 }
 /* Not defined */
-fprintf(stderr, "Trying to read invalid spr %d (0x%03x) at "
-TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
-if (qemu_log_separate()) {
-qemu_log("Trying to read invalid spr %d (0x%03x) at "
- TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
-}
+qemu_log("Trying to read invalid spr %d (0x%03x) at "
+ TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
 
 /* The behaviour depends on MSR:PR and SPR# bit 0x10,
  * it can generate a priv, a hv emu or a no-op
@@ -4096,12 +4088,8 @@ static void gen_mtspr(DisasContext *ctx)
 (*write_cb)(ctx, sprn, rS(ctx->opcode));
 } else {
 /* Privilege exception */
-fprintf(stderr, "Trying to write privileged spr %d (0x%03x) at "
-TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
-if (qemu_log_separate()) {
-qemu_log("Trying to write privileged spr %d (0x%03x) at "
- TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
-}
+qemu_log("Trying to write privileged spr %d (0x%03x) at "
+ TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
 gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG);
 }
 } else {
@@ -4113,12 +4101,8 @@ static void gen_mtspr(DisasContext *ctx)
 }
 
 /* Not defined */
-if (qemu_log_separate()) {
-qemu_log("Trying to write invalid spr %d (0x%03x) at "
- TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
-}
-fprintf(stderr, "Trying to write invalid spr %d (0x%03x) at "
-TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
+qemu_log("Trying to write invalid spr %d (0x%03x) at "
+ TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
 
 
 /* The behaviour depends on MSR:PR and SPR# bit 0x10,
@@ -7381,8 +7365,8 @@ void gen_intermediate_code(CPUState *cs, struct 
TranslationBlock *tb)
 break;
 }
 if (tcg_check_temp_count()) {
-fprintf(stderr, "Opcode %02x %02x %02x %02x (%08x) leaked "
-"temporaries\n", opc1(ctx.opcode), opc2(ctx.opcode),
+qemu_log("Opcode %02x %02x %02x %02x (%08x) leaked "
+ "temporaries\n", opc1(ctx.opcode), opc2(ctx.opcode),
 opc3(ctx.opcode), opc4(ctx.opcode), ctx.opcode);
 exit(1);
 }
diff --git 

[Qemu-devel] [PATCH v7 08/15] hw/pci*: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

A trailing '.' was removed in hw/pci/pci.c

Signed-off-by: Alistair Francis 
Cc: "Michael S. Tsirkin" 
Cc: Marcel Apfelbaum 

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 hw/pci-host/bonito.c | 6 +++---
 hw/pci/pci.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 0d8cacb884..2d25e9bf7c 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -38,7 +38,7 @@
  */
 
 #include "qemu/osdep.h"
-
+#include "qemu/error-report.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
 #include "hw/i386/pc.h"
@@ -449,8 +449,8 @@ static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr 
addr)
 regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
 
 if (idsel == 0) {
-fprintf(stderr, "error in bonito pci config address " TARGET_FMT_plx
-",pcimap_cfg=%x\n", addr, s->regs[BONITO_PCIMAP_CFG]);
+error_report("error in bonito pci config address " TARGET_FMT_plx
+ ",pcimap_cfg=%x", addr, s->regs[BONITO_PCIMAP_CFG]);
 exit(1);
 }
 pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index e8f9fc1c27..fc25cdecba 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1115,8 +1115,8 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
 assert(region_num >= 0);
 assert(region_num < PCI_NUM_REGIONS);
 if (size & (size-1)) {
-fprintf(stderr, "ERROR: PCI region size must be pow2 "
-"type=0x%x, size=0x%"FMT_PCIBUS"\n", type, size);
+error_report("ERROR: PCI region size must be pow2 "
+"type=0x%x, size=0x%"FMT_PCIBUS"", type, size);
 exit(1);
 }
 
-- 
2.13.6




Re: [Qemu-devel] [PULL 0/3] Ui 20180202 patches

2018-02-02 Thread Eric Blake
On 02/02/2018 01:17 AM, Gerd Hoffmann wrote:
> The following changes since commit 11ed801d3df3c6e46b2f1f97dcfbf4ca3a2a2f4f:
> 
>   Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' 
> into staging (2018-01-30 09:47:51 +)
> 
> are available in the git repository at:
> 
>   git://git.kraxel.org/qemu tags/ui-20180202-pull-request
> 
> for you to fetch changes up to 627ebec208a8809818589e17f4fce55a59420ad2:
> 
>   ui: correctly advance output buffer when writing SASL data (2018-02-02 
> 07:48:18 +0100)
> 
> 
> ui: use QIONetListener in vnc, bugfixes for sdl1 and vnc.
> 
> 
> 
> Daniel P. Berrange (1):
>   ui: convert VNC server to QIONetListener
> 
> Daniel P. Berrangé (2):

Odd effects based on choice of UTF-8 spellings.  Dan, do you want to add
a .mailmap entry to consolidate on a single preferred form of your name?

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH v7 07/15] hw/openrisc: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

Signed-off-by: Alistair Francis 
Cc: Jia Liu 
Cc: Stafford Horne 
Acked-by: Stafford Horne 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Markus Armbruster 
---
 hw/openrisc/openrisc_sim.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
index e9558f1ca4..c755f11efd 100644
--- a/hw/openrisc/openrisc_sim.c
+++ b/hw/openrisc/openrisc_sim.c
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -114,8 +115,7 @@ static void openrisc_load_kernel(ram_addr_t ram_size,
 }
 
 if (kernel_size < 0) {
-fprintf(stderr, "QEMU: couldn't load the kernel '%s'\n",
-kernel_filename);
+error_report("couldn't load the kernel '%s'", kernel_filename);
 exit(1);
 }
 boot_info.bootstrap_pc = entry;
-- 
2.13.6




[Qemu-devel] [PATCH v7 05/15] hw/mips: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

Signed-off-by: Alistair Francis 
Cc: Paul Burton 
Cc: Aurelien Jarno 
Cc: Yongbok Kim 
Cc: "Hervé Poussineau" 

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 hw/mips/mips_fulong2e.c | 13 ++---
 hw/mips/mips_jazz.c |  4 ++--
 hw/mips/mips_malta.c| 16 +++-
 hw/mips/mips_mipssim.c  | 11 +--
 hw/mips/mips_r4k.c  | 16 +++-
 5 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 725e25a134..f68c625666 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -120,7 +120,7 @@ static int64_t load_kernel (CPUMIPSState *env)
(uint64_t *)&kernel_low, (uint64_t *)&kernel_high,
0, EM_MIPS, 1, 0);
 if (kernel_size < 0) {
-error_report("qemu: could not load kernel '%s': %s",
+error_report("could not load kernel '%s': %s",
  loaderparams.kernel_filename,
  load_elf_strerror(kernel_size));
 exit(1);
@@ -134,17 +134,16 @@ static int64_t load_kernel (CPUMIPSState *env)
 if (initrd_size > 0) {
 initrd_offset = (kernel_high + ~INITRD_PAGE_MASK) & 
INITRD_PAGE_MASK;
 if (initrd_offset + initrd_size > ram_size) {
-fprintf(stderr,
-"qemu: memory too small for initial ram disk '%s'\n",
-loaderparams.initrd_filename);
+error_report("memory too small for initial ram disk '%s'",
+ loaderparams.initrd_filename);
 exit(1);
 }
 initrd_size = load_image_targphys(loaderparams.initrd_filename,
  initrd_offset, ram_size - initrd_offset);
 }
 if (initrd_size == (target_ulong) -1) {
-fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
-loaderparams.initrd_filename);
+error_report("could not load initial ram disk '%s'",
+ loaderparams.initrd_filename);
 exit(1);
 }
 }
@@ -338,7 +337,7 @@ static void mips_fulong2e_init(MachineState *machine)
 
 isa_bus = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0));
 if (!isa_bus) {
-fprintf(stderr, "vt82c686b_init error\n");
+error_report("vt82c686b_init error");
 exit(1);
 }
 
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index 0d2c0683ba..596f3c210e 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -268,10 +268,10 @@ static void mips_jazz_init(MachineState *machine,
 sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(rc4030, 4));
 break;
 } else if (is_help_option(nd->model)) {
-fprintf(stderr, "qemu: Supported NICs: dp83932\n");
+error_report("Supported NICs: dp83932");
 exit(1);
 } else {
-fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
+error_report("Unsupported NIC: %s", nd->model);
 exit(1);
 }
 }
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 37f19428d6..7ca8ba2086 100644
--- a/hw/mips/mips_mal

[Qemu-devel] [PATCH v7 01/15] audio: Replace AUDIO_FUNC with __func__

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Apparently we don't use __MSC_VER as a compiler anymore and we always
require a C99 compiler (which means we always have __func__) so we don't
need a special AUDIO_FUNC macro. We can just replace AUDIO_FUNC with
__func__ instead.

Checkpatch failures were manually fixed.

Signed-off-by: Alistair Francis 
Cc: Gerd Hoffmann 
Reviewed-by: Thomas Huth 
Reviewed-by: Eric Blake 
Reviewed-by: Gerd Hoffmann 
Signed-off-by: Markus Armbruster 
---
 audio/alsaaudio.c  |  4 ++--
 audio/audio.c  | 40 ++--
 audio/audio_int.h  |  6 --
 audio/audio_pt_int.c   | 28 -
 audio/audio_template.h | 26 +++
 audio/dsoundaudio.c|  2 +-
 audio/mixeng.c |  2 +-
 audio/ossaudio.c   | 10 -
 audio/paaudio.c| 56 +-
 audio/sdlaudio.c   |  2 +-
 audio/wavaudio.c   |  2 +-
 11 files changed, 85 insertions(+), 93 deletions(-)

diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 3652a7b5fa..92a96f8b2b 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -823,7 +823,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsettings 
*as,
 audio_pcm_init_info (&hw->info, &obt_as);
 hw->samples = obt.samples;
 
-alsa->pcm_buf = audio_calloc (AUDIO_FUNC, obt.samples, 1 << 
hw->info.shift);
+alsa->pcm_buf = audio_calloc(__func__, obt.samples, 1 << hw->info.shift);
 if (!alsa->pcm_buf) {
 dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\n",
hw->samples, 1 << hw->info.shift);
@@ -934,7 +934,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettings 
*as, void *drv_opaque)
 audio_pcm_init_info (&hw->info, &obt_as);
 hw->samples = obt.samples;
 
-alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << 
hw->info.shift);
+alsa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
 if (!alsa->pcm_buf) {
 dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
hw->samples, 1 << hw->info.shift);
diff --git a/audio/audio.c b/audio/audio.c
index beafed209b..7658d2af66 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -424,12 +424,12 @@ static void audio_process_options (const char *prefix,
 const char qemu_prefix[] = "QEMU_";
 size_t preflen, optlen;
 
-if (audio_bug (AUDIO_FUNC, !prefix)) {
+if (audio_bug(__func__, !prefix)) {
 dolog ("prefix = NULL\n");
 return;
 }
 
-if (audio_bug (AUDIO_FUNC, !opt)) {
+if (audio_bug(__func__, !opt)) {
 dolog ("opt = NULL\n");
 return;
 }
@@ -792,7 +792,7 @@ static int audio_attach_capture (HWVoiceOut *hw)
 SWVoiceOut *sw;
 HWVoiceOut *hw_cap = &cap->hw;
 
-sc = audio_calloc (AUDIO_FUNC, 1, sizeof (*sc));
+sc = audio_calloc(__func__, 1, sizeof(*sc));
 if (!sc) {
 dolog ("Could not allocate soft capture voice (%zu bytes)\n",
sizeof (*sc));
@@ -848,7 +848,7 @@ static int audio_pcm_hw_find_min_in (HWVoiceIn *hw)
 int audio_pcm_hw_get_live_in (HWVoiceIn *hw)
 {
 int live = hw->total_samples_captured - audio_pcm_hw_find_min_in (hw);
-if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
+if (audio_bug(__func__, live < 0 || live > hw->samples)) {
 dolog ("live=%d hw->samples=%d\n", live, hw->samples);
 return 0;
 }
@@ -886,7 +886,7 @@ static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw)
 int live = hw->total_samples_captured - sw->total_hw_samples_acquired;
 int rpos;
 
-if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
+if (audio_bug(__func__, live < 0 || live > hw->samples)) {
 dolog ("live=%d hw->samples=%d\n", live, hw->samples);
 return 0;
 }
@@ -909,7 +909,7 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
 rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
 
 live = hw->total_samples_captured - sw->total_hw_samples_acquired;
-if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
+if (audio_bug(__func__, live < 0 || live > hw->samples)) {
 dolog ("live_in=%d hw->samples=%d\n", live, hw->samples);
 return 0;
 }
@@ -935,7 +935,7 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
 }
 osamp = swlim;
 
-if (audio_bug (AUDIO_FUNC, osamp < 0)) {
+if (audio_bug(__func__, osamp < 0)) {
 dolog ("osamp=%d\n", osamp);
 return 0;
 }
@@ -990,7 +990,7 @@ static int audio_pcm_hw_get_live_out (HWVoiceOut *hw, int 
*nb_live)
 if (nb_live1) {
 int live = smin;
 
-if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
+if (audio_bug(__func__, live < 0 || live > hw->samples)) {
 dolog ("live=%d hw->samples=%d\n", live, hw->samples);
 return 0;
 }
@@ -1014,7 +1014,7 @@ int aud

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

2018-02-02 Thread Eduardo Habkost
On Fri, Feb 02, 2018 at 05:23:59PM +, Dr. David Alan Gilbert wrote:
> * Eduardo Habkost (ehabk...@redhat.com) 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.
> 
> Would that data be available without the bql?  I ask because if it is
> then a small advantage to having a separate command is that the command
> could be marked OOB with Peter's new series and never take the lock.

We would need a mechanism to safely walk the CPU list without the
BQL, so I wouldn't bother trying to make a OOB-capable version of
query-cpus unless really necessary.

-- 
Eduardo



[Qemu-devel] [PATCH v7 12/15] hw/timer: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

Signed-off-by: Alistair Francis 

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 hw/timer/xilinx_timer.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c
index 59439c05be..2d658b5791 100644
--- a/hw/timer/xilinx_timer.c
+++ b/hw/timer/xilinx_timer.c
@@ -127,7 +127,7 @@ timer_read(void *opaque, hwaddr addr, unsigned int size)
 break;
 
 }
-D(fprintf(stderr, "%s timer=%d %x=%x\n", __func__, timer, addr * 4, r));
+D(error_report("%s timer=%d %x=%x", __func__, timer, addr * 4, r));
 return r;
 }
 
@@ -135,8 +135,8 @@ static void timer_enable(struct xlx_timer *xt)
 {
 uint64_t count;
 
-D(fprintf(stderr, "%s timer=%d down=%d\n", __func__,
-  xt->nr, xt->regs[R_TCSR] & TCSR_UDT));
+D(error_report("%s timer=%d down=%d", __func__,
+   xt->nr, xt->regs[R_TCSR] & TCSR_UDT));
 
 ptimer_stop(xt->ptimer);
 
@@ -160,7 +160,7 @@ timer_write(void *opaque, hwaddr addr,
 addr >>= 2;
 timer = timer_from_addr(addr);
 xt = &t->timers[timer];
-D(fprintf(stderr, "%s addr=%x val=%x (timer=%d off=%d)\n",
+D(error_report("%s addr=%x val=%x (timer=%d off=%d)",
  __func__, addr * 4, value, timer, addr & 3));
 /* Further decoding to address a specific timers reg.  */
 addr &= 3;
@@ -197,7 +197,7 @@ static void timer_hit(void *opaque)
 {
 struct xlx_timer *xt = opaque;
 struct timerblock *t = xt->parent;
-D(fprintf(stderr, "%s %d\n", __func__, xt->nr));
+D(error_report("%s %d", __func__, xt->nr));
 xt->regs[R_TCSR] |= TCSR_TINT;
 
 if (xt->regs[R_TCSR] & TCSR_ARHT)
-- 
2.13.6




[Qemu-devel] [PATCH v7 14/15] tcg: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Signed-off-by: Alistair Francis 
Cc: Paolo Bonzini 
Cc: Peter Crosthwaite 
Cc: Richard Henderson 
Cc: Stefan Weil 

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Signed-off-by: Markus Armbruster 
---
 cpus.c | 10 +-
 exec.c |  6 +++---
 vl.c   |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/cpus.c b/cpus.c
index 2cb0af9b22..5d3a165960 100644
--- a/cpus.c
+++ b/cpus.c
@@ -259,7 +259,7 @@ int64_t cpu_get_icount_raw(void)
 
 if (cpu && cpu->running) {
 if (!cpu->can_do_io) {
-fprintf(stderr, "Bad icount read\n");
+error_report("Bad icount read");
 exit(1);
 }
 /* Take into account what has run */
@@ -1181,7 +1181,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
 
 r = kvm_init_vcpu(cpu);
 if (r < 0) {
-fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
+error_report("kvm_init_vcpu failed: %s", strerror(-r));
 exit(1);
 }
 
@@ -1211,7 +1211,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
 static void *qemu_dummy_cpu_thread_fn(void *arg)
 {
 #ifdef _WIN32
-fprintf(stderr, "qtest is not supported under Windows\n");
+error_report("qtest is not supported under Windows");
 exit(1);
 #else
 CPUState *cpu = arg;
@@ -1631,8 +1631,8 @@ static void qemu_cpu_kick_thread(CPUState *cpu)
 #else /* _WIN32 */
 if (!qemu_cpu_is_self(cpu)) {
 if (!QueueUserAPC(dummy_apc_func, cpu->hThread, 0)) {
-fprintf(stderr, "%s: QueueUserAPC failed with error %lu\n",
-__func__, GetLastError());
+error_report("%s: QueueUserAPC failed with error %lu", __func__,
+ GetLastError());
 exit(1);
 }
 }
diff --git a/exec.c b/exec.c
index 629a508385..e8d7b335b6 100644
--- a/exec.c
+++ b/exec.c
@@ -2216,9 +2216,9 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
 flags, -1, 0);
 }
 if (area != vaddr) {
-fprintf(stderr, "Could not remap addr: "
-RAM_ADDR_FMT "@" RAM_ADDR_FMT "\n",
-length, addr);
+error_report("Could not remap addr: "
+ RAM_ADDR_FMT "@" RAM_ADDR_FMT "",
+ length, addr);
 exit(1);
 }
 memory_try_enable_merging(vaddr, length);
diff --git a/vl.c b/vl.c
index e517a8d995..32db91da1e 100644
--- a/vl.c
+++ b/vl.c
@@ -2172,7 +2172,7 @@ static DisplayType select_display(const char *p)
 display_opengl = 1;
 display = DT_EGL;
 #else
-fprintf(stderr, "egl support is disabled\n");
+error_report("egl support is disabled");
 exit(1);
 #endif
 } else if (strstart(p, "curses", &opts)) {
-- 
2.13.6




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

2018-02-02 Thread no-reply
Hi,

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

Type: series
Message-id: 20180202130336.24719-1-arm...@redhat.com
Subject: [Qemu-devel] [PATCH RFC 00/21] Modularize generated QAPI code

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
c046d2f10e qapi: Empty out qapi-schema.json
cdc634732e Include less of qapi-types.h
6c08b6809b qapi/types: Generate separate .h, .c for each module
3d0eed2242 qapi/common: Fix guardname() for funny filenames
0711fd2195 qapi/types qapi/visit: Generate built-in stuff into separate files
7ede02642f qapi/types qapi/visit: Make visitors use QAPIGen more
5692214a78 qapi: Record 'include' directives in intermediate representation
429e27e46c qapi: Generate in source order
0c655e94f7 qapi: Record 'include' directives in parse tree
42535161b1 qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()
ab1ec2065d qapi: Lift error reporting from QAPISchema.__init__() to callers
471fb6f047 qapi/common: Eliminate QAPISchema.exprs
60e5203347 qapi: Don't absolutize include file name in error messages
8dc13338ce qapi: Touch generated files only when they change
31b120d6cf qapi: Move parse_command_line() next to its only use
d3c74048cf qapi-gen: New common driver for code and doc generators
f2a5a13014 qapi: Turn generators into modules
e6afdbb47e qapi: Reduce use of global variables in generators some
8afb71a043 qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc
63aed1bbee qapi: Generate up-to-date copyright notice
f3af02ec25 qapi: Streamline boilerplate comment generation

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-cdbcg9v3/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
  BUILD   fedora
  GEN 
/var/tmp/patchew-tester-tmp-cdbcg9v3/src/docker-src.2018-02-02-13.34.09.24306/qemu.tar
Cloning into 
'/var/tmp/patchew-tester-tmp-cdbcg9v3/src/docker-src.2018-02-02-13.34.09.24306/qemu.tar.vroot'...
done.
Checking out files:  48% (2826/5779)   
Checking out files:  49% (2832/5779)   
Checking out files:  50% (2890/5779)   
Checking out files:  51% (2948/5779)   
Checking out files:  52% (3006/5779)   
Checking out files:  53% (3063/5779)   
Checking out files:  54% (3121/5779)   
Checking out files:  55% (3179/5779)   
Checking out files:  56% (3237/5779)   
Checking out files:  57% (3295/5779)   
Checking out files:  58% (3352/5779)   
Checking out files:  59% (3410/5779)   
Checking out files:  60% (3468/5779)   
Checking out files:  61% (3526/5779)   
Checking out files:  62% (3583/5779)   
Checking out files:  63% (3641/5779)   
Checking out files:  64% (3699/5779)   
Checking out files:  65% (3757/5779)   
Checking out files:  66% (3815/5779)   
Checking out files:  67% (3872/5779)   
Checking out files:  68% (3930/5779)   
Checking out files:  69% (3988/5779)   
Checking out files:  70% (4046/5779)   
Checking out files:  71% (4104/5779)   
Checking out files:  72% (4161/5779)   
Checking out files:  73% (4219/5779)   
Checking out files:  74% (4277/5779)   
Checking out files:  75% (4335/5779)   
Checking out files:  76% (4393/5779)   
Checking out files:  77% (4450/5779)   
Checking out files:  78% (4508/5779)   
Checking out files:  79% (4566/5779)   
Checking out files:  80% (4624/5779)   
Checking out files:  81% (4681/5779)   
Checking out files:  82% (4739/5779)   
Checking out files:  83% (4797/5779)   
Checking out files:  84% (4855/5779)   
Checking out files:  85% (4913/5779)   
Checking out files:  86% (4970/5779)   
Checking out files:  87% (5028/5779)   
Checking out files:  88% (5086/5779)   
Checking out files:  89% (5144/5779)   
Checking out files:  90% (5202/5779)   
Checking out files:  91% (5259/5779)   
Checking out files:  92% (5317/5779)   
Checking out files:  93% (5375/5779)   
Checking out files:  94% (5433/5779)   
Checking out files:  95% (5491/5779)   
Checking out files:  96% (5548/5779)   
Checking out files:  97% (5606/5779)   
Checking out files:  98% (5664/5779)   
Checking out files:  99% (5722/5779)   
Checking out files: 100% (5779/5779)   
Checking out files: 100% (5779/5779), done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 
'/var/tmp/patchew-tester-tmp-cdbcg9v3/src/docker-src.2018-02-02-13.34.09.24306/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 
'/var/tmp/patchew-tester-tmp-cdbcg9

[Qemu-devel] [PATCH v7 04/15] hw/lm32: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

Signed-off-by: Alistair Francis 
Cc: Michael Walle 
Reviewed-by: Philippe Mathieu-Daudé 
Acked-by: Michael Walle 
Signed-off-by: Markus Armbruster 
---
 hw/lm32/lm32_boards.c | 7 +++
 hw/lm32/milkymist.c   | 7 +++
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/lm32/lm32_boards.c b/hw/lm32/lm32_boards.c
index 002d638edd..527bcc229c 100644
--- a/hw/lm32/lm32_boards.c
+++ b/hw/lm32/lm32_boards.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "qemu-common.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
@@ -148,8 +149,7 @@ static void lm32_evr_init(MachineState *machine)
 }
 
 if (kernel_size < 0) {
-fprintf(stderr, "qemu: could not load kernel '%s'\n",
-kernel_filename);
+error_report("could not load kernel '%s'", kernel_filename);
 exit(1);
 }
 }
@@ -242,8 +242,7 @@ static void lm32_uclinux_init(MachineState *machine)
 }
 
 if (kernel_size < 0) {
-fprintf(stderr, "qemu: could not load kernel '%s'\n",
-kernel_filename);
+error_report("could not load kernel '%s'", kernel_filename);
 exit(1);
 }
 }
diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index d4e765f2eb..85d64fe58d 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "qemu-common.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
@@ -145,8 +146,7 @@ milkymist_init(MachineState *machine)
 
 /* if no kernel is given no valid bios rom is a fatal error */
 if (!kernel_filename && !dinfo && !bios_filename && !qtest_enabled()) {
-fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
-bios_name);
+error_report("could not load Milkymist One bios '%s'", bios_name);
 exit(1);
 }
 g_free(bios_filename);
@@ -184,8 +184,7 @@ milkymist_init(MachineState *machine)
 }
 
 if (kernel_size < 0) {
-fprintf(stderr, "qemu: could not load kernel '%s'\n",
-kernel_filename);
+error_report("could not load kernel '%s'", kernel_filename);
 exit(1);
 }
 }
-- 
2.13.6




[Qemu-devel] [PATCH v7 00/15] Remove some of the fprintf(stderr, "*

2018-02-02 Thread Markus Armbruster
This is my attempt to salvage a good part of Alistair's error
reporting cleanup series

[PATCH v6 00/29]  Remove some of the fprintf(stderr, "*

Continue on improving QEMUs logging/error messages by removing more
fprintf()'s.

Unfortunatley my Coccinelle skills aren't that great so it's all done in
some nasty regex and a little bit of manual work.

It foundered on the problem that some of its fprintf() to
error_report() conversions are inappropriate, see

Message-ID: <87lghulqno@dusky.pond.sub.org>
https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg04961.html

Alistair didn't feel like checking about one hundred conversions by
hand, which is understandable.  But letting the work go to waste would
be a shame, so I wrote an AWK script (see below) to extract a common
kind of obviously good conversions: the ones where the fprintf() is
followed by exit().  Judging from the diffstat, this salvages more
than half of his conversion work.

v7:
* Old PATCH 02,03,21 are already in master, drop
* Conversions not obviously followed by exit() dropped
  Nothing left in old PATCH 06-12,16,17,22, drop
  R-bys dropped
* Rebased, trivial conflict in the last patch resolved


#!/usr/bin/awk -f

hunk && /^\+[ \t]*error_report/ {
n++
er_indent = match(substr($0, 2), /[^ \t]/)
er_nr = NR
plus = 0
fatal = 0
}

hunk && er_indent && /^\+/ {
plus++
}

hunk && er_indent && /^[ \t]*exit/ {
d = NR - er_nr - plus
if (maxd < d)
maxd = d
fatal = 1
}

hunk && er_indent && match(substr($0, 2), /[^ \t]/) < er_indent {
if (fatal)
nf++
er_indent = 0
}

hunk && /^[-+ ]/ {
hunk = hunk "\n" $0
next
}

hunk {
if (n && nf && n != nf)
print loc, "mixed hunk", n, nf >"/dev/stderr"
else if (n && !nf)
print loc, "non-fatal hunk", n, nf >"/dev/stderr"
else if (!n || nf)
print hunk
hunk = ""
}

/^@@ / {
hunk = $0
loc = FILENAME ":" FNR ":"
n = nf = 0
next
}

{
print
}

END {
print "max distance", maxd+0 >"/dev/stderr"
}

Alistair Francis (15):
  audio: Replace AUDIO_FUNC with __func__
  hw/arm: Replace fprintf(stderr, "*\n" with error_report()
  hw/dma: Replace fprintf(stderr, "*\n" with error_report()
  hw/lm32: Replace fprintf(stderr, "*\n" with error_report()
  hw/mips: Replace fprintf(stderr, "*\n" with error_report()
  hw/moxie: Replace fprintf(stderr, "*\n" with error_report()
  hw/openrisc: Replace fprintf(stderr, "*\n" with error_report()
  hw/pci*: Replace fprintf(stderr, "*\n" with error_report()
  hw/ppc: Replace fprintf(stderr, "*\n" with error_report()
  hw/sd: Replace fprintf(stderr, "*\n" with error_report()
  hw/sparc*: Replace fprintf(stderr, "*\n" with error_report()
  hw/timer: Replace fprintf(stderr, "*\n" with error_report()
  hw/xen*: Replace fprintf(stderr, "*\n" with error_report()
  tcg: Replace fprintf(stderr, "*\n" with error_report()
  target: Use qemu_log() instead of fprintf(stderr, ...)

 audio/alsaaudio.c|  4 ++--
 audio/audio.c| 40 +++
 audio/audio_int.h|  6 -
 audio/audio_pt_int.c | 28 +++---
 audio/audio_template.h   | 26 ++--
 audio/dsoundaudio.c  |  2 +-
 audio/mixeng.c   |  2 +-
 audio/ossaudio.c | 10 
 audio/paaudio.c  | 56 ++--
 audio/sdlaudio.c |  2 +-
 audio/wavaudio.c |  2 +-
 cpus.c   | 10 
 dtc  |  2 +-
 exec.c   |  6 ++---
 hw/arm/armv7m.c  |  2 +-
 hw/arm/boot.c| 16 ++---
 hw/arm/gumstix.c | 13 +-
 hw/arm/mainstone.c   |  7 +++---
 hw/arm/musicpal.c|  2 +-
 hw/arm/omap1.c   |  5 ++--
 hw/arm/omap2.c   |  3 ++-
 hw/arm/omap_sx1.c|  2 +-
 hw/arm/pxa2xx.c  |  7 +++---
 hw/arm/vexpress.c|  8 +++
 hw/arm/z2.c  |  6 ++---
 hw/dma/soc_dma.c | 36 ++--
 hw/lm32/lm32_boards.c|  7 +++---
 hw/lm32/milkymist.c  |  7 +++---
 hw/mips/mips_fulong2e.c  | 13 +-
 hw/mips/mips_jazz.c  |  4 ++--
 hw/mips/mips_malta.c | 16 ++---
 hw/mips/mips_mipssim.c   | 11 -
 hw/mips/mips_r4k.c   | 16 ++---
 hw/moxie/moxiesim.c  | 13 +-
 hw/openrisc/openrisc_sim.c   |  4 ++--
 hw/pci-host/bonito.c |  6 ++---
 hw/pci/pci.c |  4 ++--
 hw/ppc/e500.c| 16 ++---
 hw/ppc/mac_newworld.c|  2 +-
 hw/ppc/mac_oldworld.c|  2 +-
 hw/ppc/ppc405_boards.c   | 15 +---
 hw/ppc/ppc440_bamboo.c   | 16 ++---
 hw/ppc/prep.c|  4 ++--
 hw/ppc/virtex_ml507.c|  4 ++--
 hw/sd/sd.c   |  7 +++---
 hw

[Qemu-devel] [Bug 1747056] [NEW] FreeDOS / MS-Dos / Windows 3.11 cannot perform reboot with 'isapc' machine

2018-02-02 Thread Daniel Berrange
Public bug reported:

I was installing MS-Dos 6.22 + Windows 3.11 in preparation for running
Microsoft Bob, and noticed that when they try to perform a reboot, they
just get stuck. The console cursor stays flashing on/off, but the DOS
prompt no longer responds to input.

It is fairly easy to reproduce, even FreeDOS is impacted - download the
FreeDOS bootable CDROM image, then

$ qemu-img create demo.img 100MB

$ qemu-system-x86_64 -machine isapc -cdrom ~/Downloads/FD12CD.iso  -hda
demo.img  -monitor stdio

Wait for the installer to startup, and then in the monitor console run

  sendkey ctrl-alt-delete

It will fail to reboot

Testing shows this is a regression from QEMU 2.8.0 onwards, and git
bisect further narrowed it down to a SEABIOS update

commit 6e99f5741ff1b408ea76e6caf2bd4f76df4060e9 (HEAD, tag: 
pull-seabios-20161027-2, tag: pull-seabios-20161027-1, refs/bisect/bad)
Author: Gerd Hoffmann 
Date:   Thu Oct 27 16:42:28 2016 +0200

seabios: update to 1.10.0 release.

Note that this seems particular to the "isapc" machine type - with the
"pc" machine type, reboot still works

** Affects: qemu
 Importance: Undecided
 Status: New

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

Title:
  FreeDOS / MS-Dos / Windows 3.11 cannot perform reboot with 'isapc'
  machine

Status in QEMU:
  New

Bug description:
  I was installing MS-Dos 6.22 + Windows 3.11 in preparation for running
  Microsoft Bob, and noticed that when they try to perform a reboot,
  they just get stuck. The console cursor stays flashing on/off, but the
  DOS prompt no longer responds to input.

  It is fairly easy to reproduce, even FreeDOS is impacted - download
  the FreeDOS bootable CDROM image, then

  $ qemu-img create demo.img 100MB

  $ qemu-system-x86_64 -machine isapc -cdrom ~/Downloads/FD12CD.iso
  -hda demo.img  -monitor stdio

  Wait for the installer to startup, and then in the monitor console run

sendkey ctrl-alt-delete

  It will fail to reboot

  Testing shows this is a regression from QEMU 2.8.0 onwards, and git
  bisect further narrowed it down to a SEABIOS update

  commit 6e99f5741ff1b408ea76e6caf2bd4f76df4060e9 (HEAD, tag: 
pull-seabios-20161027-2, tag: pull-seabios-20161027-1, refs/bisect/bad)
  Author: Gerd Hoffmann 
  Date:   Thu Oct 27 16:42:28 2016 +0200

  seabios: update to 1.10.0 release.

  Note that this seems particular to the "isapc" machine type - with the
  "pc" machine type, reboot still works

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



[Qemu-devel] [PATCH v7 06/15] hw/moxie: Replace fprintf(stderr, "*\n" with error_report()

2018-02-02 Thread Markus Armbruster
From: Alistair Francis 

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, 
"\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' 
\
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

Signed-off-by: Alistair Francis 
Cc: Anthony Green 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
Signed-off-by: Markus Armbruster 
---
 hw/moxie/moxiesim.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/hw/moxie/moxiesim.c b/hw/moxie/moxiesim.c
index 6c200becab..0bbf770795 100644
--- a/hw/moxie/moxiesim.c
+++ b/hw/moxie/moxiesim.c
@@ -63,8 +63,8 @@ static void load_kernel(MoxieCPU *cpu, LoaderParams 
*loader_params)
0, 0);
 
 if (kernel_size <= 0) {
-fprintf(stderr, "qemu: could not load kernel '%s'\n",
-loader_params->kernel_filename);
+error_report("could not load kernel '%s'",
+ loader_params->kernel_filename);
 exit(1);
 }
 
@@ -77,9 +77,8 @@ static void load_kernel(MoxieCPU *cpu, LoaderParams 
*loader_params)
 initrd_offset = (kernel_high + ~TARGET_PAGE_MASK)
   & TARGET_PAGE_MASK;
 if (initrd_offset + initrd_size > loader_params->ram_size) {
-fprintf(stderr,
-"qemu: memory too small for initial ram disk '%s'\n",
-loader_params->initrd_filename);
+error_report("memory too small for initial ram disk '%s'",
+ loader_params->initrd_filename);
 exit(1);
 }
 initrd_size = load_image_targphys(loader_params->initrd_filename,
@@ -87,8 +86,8 @@ static void load_kernel(MoxieCPU *cpu, LoaderParams 
*loader_params)
   ram_size);
 }
 if (initrd_size == (target_ulong)-1) {
-fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
-loader_params->initrd_filename);
+error_report("could not load initial ram disk '%s'",
+ loader_params->initrd_filename);
 exit(1);
 }
 }
-- 
2.13.6




Re: [Qemu-devel] [PULL 0/3] Ui 20180202 patches

2018-02-02 Thread Daniel P . Berrangé
On Fri, Feb 02, 2018 at 11:49:55AM -0600, Eric Blake wrote:
> On 02/02/2018 01:17 AM, Gerd Hoffmann wrote:
> > The following changes since commit 11ed801d3df3c6e46b2f1f97dcfbf4ca3a2a2f4f:
> > 
> >   Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' 
> > into staging (2018-01-30 09:47:51 +)
> > 
> > are available in the git repository at:
> > 
> >   git://git.kraxel.org/qemu tags/ui-20180202-pull-request
> > 
> > for you to fetch changes up to 627ebec208a8809818589e17f4fce55a59420ad2:
> > 
> >   ui: correctly advance output buffer when writing SASL data (2018-02-02 
> > 07:48:18 +0100)
> > 
> > 
> > ui: use QIONetListener in vnc, bugfixes for sdl1 and vnc.
> > 
> > 
> > 
> > Daniel P. Berrange (1):
> >   ui: convert VNC server to QIONetListener
> > 
> > Daniel P. Berrangé (2):
> 
> Odd effects based on choice of UTF-8 spellings.  Dan, do you want to add
> a .mailmap entry to consolidate on a single preferred form of your name?

Oh yes, I've just sent such a patch.  I switched to the proper unicode
spelling of my name in git since I figure enough of the software world
handles unicode correctly by now :-)

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] [PULL v2 05/10] tests: virtio-9p: use the synth backend

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

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

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

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

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




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

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

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

Anyway, I have bad and good news:

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

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

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

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

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

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

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

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

-- 
Eduardo



[Qemu-devel] rate limiting issues

2018-02-02 Thread Wolfgang Bumiller
Summary:
Rate limit is effectively halved when the size of written chunks adds up to
exceeding the quota of a slice only slightly. This is surprisingly reliable.

Explanation:
The ratelimiting code in include/qemu/ratelimit.h currently uses slices with
quotas. Finishing up the quota for one slice means it'll wait for the end of
this _and_ the next slice before resetting the accounting and start over.
If that first slice was exceeded by only a tiny bit, we effectively spend every
second slice waiting around. before starting over.

Here if I use a limit of 3KiB/s I get 3KiB/s.
Increasing the limit to 30700KiB/s gives me 30700KiB/s.
Increasing it to 30720KiB/s reliably gives me 15000KiB/s.

Making it wait to the end of only the current slice means the excess data is not
counted at all and we may go above the limit (though by at most one write-chunk,
so I'm not sure if that's fine for most of the users, for backup jobs it seems
to be 64k always).

I'd like to fix this and am unsure about which way to go. On the one hand I
think the old code (before f14a39ccb922) may be fixable in a better way by not
resetting the accounting completely but subtracting the amount of data the
wait-period would have added.

At the same time, though, this could be simplified to not using slices but
always comparing the amount of actually written data to the amount of data
which should at most have been written.

Here are two approaches which seem to fix my issues:

--- Old code revised:

typedef struct {
int64_t next_slice_time;
uint64_t slice_quota;
uint64_t slice_ns;
int64_t dispatched;
} RateLimit;

static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
{
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);

assert(limit->slice_quota && limit->slice_ns);

if (limit->next_slice_time == 0) { /* first call */
limit->dispatched = 0;
limit->next_slice_time = now + limit->slice_ns;
return 0;
}

if (limit->next_slice_time < now) {
uint64_t passed_slices = DIV_ROUND_UP(now - limit->next_slice_time,
limit->slice_ns);
limit->next_slice_time = now + limit->slice_ns;
limit->dispatched -= passed_slices * limit->slice_quota;
}
limit->dispatched += n;
if (limit->dispatched+n <= limit->slice_quota) {
return 0;
}
return limit->next_slice_time - now;
}

static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
   uint64_t slice_ns)
{
limit->slice_ns = slice_ns;
limit->slice_quota = MAX(((double)speed * slice_ns) / 10ULL, 1);
}

---

And this is a short slice-less version. I wonder if there's any particular
reason for sticking to slices?

--- Version without slices:

typedef struct {
int64_t last_time;
uint64_t speed;
int64_t allowed;
} RateLimit;

static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
{
int64_t delta, now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);

if (limit->last_time == 0) { /* first call */
limit->allowed = -n;
limit->last_time = now;
return (n * 10ULL) / limit->speed;
}

delta = (now - limit->last_time);
limit->allowed += (delta * limit->speed)/10ULL - n;
limit->last_time = now;
if (limit->allowed < 0) {
return ((uint64_t)-limit->allowed * 10ULL) / limit->speed;
}
return 0;
}

static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
   uint64_t slice_ns)
{
(void)slice_ns; // TODO: remove
limit->speed = speed;
}

---

Numerical note: a small delta means 'allowed' is incremented by 0, which
should be fine since when we hit the quota, we'll have a longer wait after
which the delta is for sure big enough to produce positive values.
(I tried larger and smaller values (1KiB/s to some MiB/s)).
Alternatively we could set last_time and do the quota increment
conditionally only when the delta is big enough, but I have not found
this to be necessary in my tests.




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

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

What v8 features?

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

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

Yes, we could probably do something similar to this.

thanks
-- PMM



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

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

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

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

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




[Qemu-devel] [PATCH v3] tap: close fd conditionally when error occured

2018-02-02 Thread Jay Zhou
If netdev_add tap,id=net0,...,vhost=on failed in net_init_tap_one(),
the followed up device_add virtio-net-pci,netdev=net0 will fail
too, prints:

   TUNSETOFFLOAD ioctl() failed: Bad file descriptor TUNSETOFFLOAD
   ioctl() failed: Bad file descriptor

The reason is that the fd of tap is closed when error occured after
calling net_init_tap_one().

The fd should be closed when calling net_init_tap_one failed:
   - if tap_set_sndbuf() failed
   - if tap_set_sndbuf() succeeded but vhost failed to open or
 initialize with vhostforce flag on
The fd should not be closed just because vhost failed to open or
initialize but without vhostforce flag. So the followed up
device_add can fall back to userspace virtio successfully.

Suggested-by: Michael S. Tsirkin 
Suggested-by: Igor Mammedov 
Suggested-by: Jason Wang 
Signed-off-by: Jay Zhou 
---
 net/tap.c | 44 
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/net/tap.c b/net/tap.c
index 979e622..c46ab14 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -651,7 +651,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, 
NetClientState *peer,
 tap_set_sndbuf(s->fd, tap, &err);
 if (err) {
 error_propagate(errp, err);
-return;
+goto error;
 }
 
 if (tap->has_fd || tap->has_fds) {
@@ -686,15 +686,26 @@ static void net_init_tap_one(const NetdevTapOptions *tap, 
NetClientState *peer,
 if (vhostfdname) {
 vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err);
 if (vhostfd == -1) {
-error_propagate(errp, err);
-return;
+if (tap->has_vhostforce && tap->vhostforce) {
+error_propagate(errp, err);
+goto error;
+} else {
+warn_report_err(err);
+return;
+}
 }
 } else {
 vhostfd = open("/dev/vhost-net", O_RDWR);
 if (vhostfd < 0) {
-error_setg_errno(errp, errno,
- "tap: open vhost char device failed");
-return;
+if (tap->has_vhostforce && tap->vhostforce) {
+error_setg_errno(errp, errno,
+ "tap: open vhost char device failed");
+goto error;
+} else {
+warn_report("tap: open vhost char device failed: %s",
+strerror(errno));
+return;
+}
 }
 fcntl(vhostfd, F_SETFL, O_NONBLOCK);
 }
@@ -702,12 +713,23 @@ static void net_init_tap_one(const NetdevTapOptions *tap, 
NetClientState *peer,
 
 s->vhost_net = vhost_net_init(&options);
 if (!s->vhost_net) {
-error_setg(errp,
-   "vhost-net requested but could not be initialized");
-return;
+if (tap->has_vhostforce && tap->vhostforce) {
+error_setg(errp,
+   "vhost-net requested but could not be initialized");
+goto error;
+} else {
+warn_report("vhost-net requested but could not be 
initialized");
+return;
+}
 }
 } else if (vhostfdname) {
-error_setg(errp, "vhostfd(s)= is not valid without vhost");
+warn_report("vhostfd(s)= is not valid without vhost");
+return;
+}
+
+error:
+if (!tap->has_fd && !tap->has_fds) {
+close(fd);
 }
 }
 
@@ -877,7 +899,6 @@ free_fail:
  vnet_hdr, fd, &err);
 if (err) {
 error_propagate(errp, err);
-close(fd);
 return -1;
 }
 } else {
@@ -916,7 +937,6 @@ free_fail:
  vhostfdname, vnet_hdr, fd, &err);
 if (err) {
 error_propagate(errp, err);
-close(fd);
 return -1;
 }
 }
-- 
1.8.3.1





Re: [Qemu-devel] [PATCH] Add a git-publish configuration file

2018-02-02 Thread Fam Zheng
On Wed, Jan 31, 2018 at 6:06 PM, Marc-André Lureau
 wrote:
> Hi
>
> On Wed, Jan 31, 2018 at 6:33 AM, Fam Zheng  wrote:
>> 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
>
> It would be worth to update README "Submitting patches" with an example

Good idea. Thanks for reviewing!


>>
>> 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..2099c1520f
>> --- /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 "qemu"]
>> +base = master
>> +prefix = PATCH
>> +to = qemu-devel@nongnu.org
>> +cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit 
>> --nogit-fallback 2>/dev/null
>> +
>> +[gitpublishprofile "qemu-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 "qemu-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 "qemu-trivial"]
>> +base = master
>> +prefix = PATCH
>> +to = qemu-devel@nongnu.org
>
> cc qemu-triv...@nongnu.org ?

Good catch, I must have deleted it by mistake.

Fam



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

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

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

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

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

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


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

x-image



signature.asc
Description: OpenPGP digital signature


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

2018-02-02 Thread Eric Blake
On 02/02/2018 07:03 AM, Markus Armbruster wrote:
> The next commit will introduce a common driver program for all
> generators.  The generators need to be modules for that.  qapi2texi.py
> already is.  Make the other generators follow suit.
> 
> The changes are actually trivial.  Obvious in the diffs once you view
> them with whitespace changes ignored.
> 
> Signed-off-by: Markus Armbruster 
> ---
>  scripts/qapi-commands.py   | 43 ++--
>  scripts/qapi-event.py  | 43 ++--
>  scripts/qapi-introspect.py | 54 ++--
>  scripts/qapi-types.py  | 56 ++---
>  scripts/qapi-visit.py  | 62 
> +-
>  5 files changed, 143 insertions(+), 115 deletions(-)
> 

Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


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

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

Demonstrate these ways with examples as follows.

  1. crash-information QOM property;

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

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

  2. GUEST_PANICKED event reporting;

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

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

  3. log;

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

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

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

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

Re: [Qemu-devel] [PATCH] tests/migration: Add source to PC boot block

2018-02-02 Thread Wei Huang


On 01/31/2018 02:16 PM, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" 
> 
> The boot block used in the migration test is currently only
> shipped as a hex (with the source in the git commit message),
> change this to actually include the source.
> 
> A makefile rule is added, but the expectation is that
> the generated hex is shipped as well as the .s, so that
> there's no requirement to have just the right assembler etc.
> 
> Signed-off-by: Dr. David Alan Gilbert 
> ---
>  tests/Makefile.include  | 18 
>  tests/migration-test.c  | 46 +--
>  tests/migration/x86-a-b-bootblock.h | 52 +
>  tests/migration/x86-a-b-bootblock.s | 92 
> +
>  4 files changed, 163 insertions(+), 45 deletions(-)
>  create mode 100644 tests/migration/x86-a-b-bootblock.h
>  create mode 100644 tests/migration/x86-a-b-bootblock.s
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 851aafe9d1..2a0889479c 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -831,6 +831,24 @@ tests/migration/initrd-stress.img: 
> tests/migration/stress$(EXESUF)
>   rm $(INITRD_WORK_DIR)/init
>   rmdir $(INITRD_WORK_DIR)
>  
> +ASM_WORK_DIR=tests/asm-temp
> +$(SRC_PATH)/tests/migration/x86-a-b-bootblock.h: 
> $(SRC_PATH)/tests/migration/x86-a-b-bootblock.s
> + mkdir $(ASM_WORK_DIR)
> + as --32 -march=i486 $< -o $(ASM_WORK_DIR).o
> + objcopy -O binary $(ASM_WORK_DIR).o $(ASM_WORK_DIR).boot
> + dd if=$(ASM_WORK_DIR).boot of=$(ASM_WORK_DIR).bootsect bs=256 count=2 
> skip=124
> + xxd -i $(ASM_WORK_DIR).bootsect | \
> +sed -e 's/tests_asm_temp_bootsect/bootsect/' -e 's/.*int.*//' > 
> $(ASM_WORK_DIR).hex
> + echo -e "/* This file is automatically generated from\n" \
> + " * tests/migration/x86-a-b-bootblock.s, edit that and then\n" \
> + " * make tests/migration/x86-a-b-bootblock.h to update,\n" \
> + " * and then remember to send both in your patch submission.\n" 
> \
> + " */\n" | cat - $(ASM_WORK_DIR).hex > $@
> + rm $(ASM_WORK_DIR).hex $(ASM_WORK_DIR).bootsect $(ASM_WORK_DIR).boot
> + rm $(ASM_WORK_DIR).o
> + rmdir $(ASM_WORK_DIR)
> +
> +

Could we create a new Makefile.include under tests/migration/ and move
the code above there? The code above is very large and can distract
people working on tests/Makefile.include.

>  ifeq ($(CONFIG_POSIX),y)
>  LIBS += -lutil
>  endif
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 799e24ebc6..7550fd8d56 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -79,51 +79,7 @@ static const char *tmpfs;
>  /* A simple PC boot sector that modifies memory (1-100MB) quickly
>   * outputing a 'B' every so often if it's still running.
>   */
> -unsigned char bootsect[] = {
> -  0xfa, 0x0f, 0x01, 0x16, 0x74, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00,
> -  0x0f, 0x22, 0xc0, 0x66, 0xea, 0x20, 0x7c, 0x00, 0x00, 0x08, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x92, 0x0c, 0x02,
> -  0xe6, 0x92, 0xb8, 0x10, 0x00, 0x00, 0x00, 0x8e, 0xd8, 0x66, 0xb8, 0x41,
> -  0x00, 0x66, 0xba, 0xf8, 0x03, 0xee, 0xb3, 0x00, 0xb8, 0x00, 0x00, 0x10,
> -  0x00, 0xfe, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x40,
> -  0x06, 0x7c, 0xf2, 0xfe, 0xc3, 0x75, 0xe9, 0x66, 0xb8, 0x42, 0x00, 0x66,
> -  0xba, 0xf8, 0x03, 0xee, 0xeb, 0xde, 0x66, 0x90, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00,
> -  0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00, 0x27, 0x00, 0x5c, 0x7c,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  

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

2018-02-02 Thread Daniel P . Berrangé
On Fri, Feb 02, 2018 at 02:03:15PM +0100, Markus Armbruster wrote:
> 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.

Having gone through the same exercise for trace.h, I very much welcome
this effort for QAPI too !

If I consider the crypto stuff I maintain, the QAPI definitions are
in qapi/crypto.json.

>From my POV, I feel it would be natural to have them move to instead
be at  crypto/qapi.json, and have the generated headers/source files be
crypto/qapi-types.h, crypto/qapi-visit.h, etc.

This would mirror what we did with tracing, crypto/trace-events, and
generating crypto/trace*.{c,h}

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] [RFC] kvm: x86: export vCPU halted state to sysfs

2018-02-02 Thread Dr. David Alan Gilbert
* Eduardo Habkost (ehabk...@redhat.com) 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.

Would that data be available without the bql?  I ask because if it is
then a small advantage to having a separate command is that the command
could be marked OOB with Peter's new series and never take the lock.

Dave

> 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
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



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

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

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

are available in the git repository at:

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

for you to fetch changes up to 9ea776ee7d4061c043d0fbf89aa85f86ec0cf8a2:

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


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

Other patches are code cleanup and improvements.

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


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

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

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




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

2018-02-02 Thread Peter Maydell
On 2 February 2018 at 16:19, Greg Kurz  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/gkurz/qemu.git tags/for-upstream
>
> for you to fetch changes up to 9ea776ee7d4061c043d0fbf89aa85f86ec0cf8a2:
>
>   tests/virtio-9p: explicitly handle potential integer overflows (2018-02-02 
> 11:15:34 +0100)
>
> 
> This series is mostly about 9p request cancellation. It fixes a
> long standing bug (read "specification violation") where the server
> would send an invalid response when the client has cancelled an
> in-flight request. This was causing annoying spurious EINTR returns
> in linux. The fix comes with some related testing in QTEST.
>
> Other patches are code cleanup and improvements.
>
> v2: fix the alignment issue that was presumably causing make check to
> fail on sparc hosts
>

Applied, thanks.

-- PMM



Re: [Qemu-devel] [PATCH v5 11/14] input: add missing JIS keys to virtio input

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

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] [PATCH v3] block: maintain persistent disabled bitmaps

2018-02-02 Thread Max Reitz
On 2018-02-02 17:18, Eric Blake wrote:
> On 02/02/2018 10:07 AM, 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)
>>
>> Also, adjust iotests 165 and 176 appropriately.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy 
>> ---
> 
>> +++ b/qemu-doc.texi
>> @@ -2749,6 +2749,13 @@ used and it will be removed with no replacement.
>>  The ``convert -s snapshot_id_or_name'' argument is obsoleted
>>  by the ``convert -l snapshot_param'' argument instead.
>>  
>> +@section QEMU Machine Protocol (QMP) commands
>> +
>> +@subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0)
>> +
>> +"autoload" parameter is now ignored. All bitmaps are automatically loaded
>> +from qcow2 image.
> 
> Won't later patches be adding the ability to enable/disable bitmaps,
> which then affects whether they are autoloaded?  So we don't forget to
> revisit this text in that patch, a better wording might be:
> 
> The "autoload" parameter is ignored; all enabled persistent dirty
> bitmaps are automatically loaded from a qcow2 image, regardless of the
> initial setting requested in this parameter.
> 
> 
>> @@ -667,19 +662,6 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs)
>>  }
>>  
>>  /* Called with BQL taken. */
>> -void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload)
>> -{
>> -qemu_mutex_lock(bitmap->mutex);
>> -bitmap->autoload = autoload;
>> -qemu_mutex_unlock(bitmap->mutex);
>> -}
>> -
>> -bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap)
>> -{
>> -return bitmap->autoload;
>> -}
> 
> Will later patches be reintroducing these functions for learning which
> bitmaps are enabled/disabled?  But I'm okay with deleting them in this
> patch, even if that is more churn.

You mean bdrv_enable_dirty_bitmap(), bdrv_disable_dirty_bitmap(), and
bdrv_dirty_bitmap_enabled()? ;-)

Max



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH v3 0/1] respin of s390 crash information

2018-02-02 Thread Christian Borntraeger
This patch - originally from Jing Liu - was still on my disk and 
somehow dropped of my attention. Here is a fixed up version.
It probably still needs some review and polish.
One open aspect is migration. Right now QEMU switches from crashed
back into running state after migration (even without this patch).
Some fixup will be necessary. 

Christian Borntraeger (1):
  s390x/cpu: expose the guest crash information

 qapi/run-state.json   | 29 --
 target/s390x/cpu.c| 57 +++
 target/s390x/cpu.h| 10 +
 target/s390x/helper.c |  5 -
 target/s390x/kvm.c| 27 +++-
 vl.c  |  6 ++
 6 files changed, 126 insertions(+), 8 deletions(-)

-- 
2.14.3




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

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

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

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




[Qemu-devel] [PULL 1/1] virtio-gpu: disallow vIOMMU

2018-02-02 Thread Gerd Hoffmann
From: Peter Xu 

virtio-gpu has special code path that bypassed vIOMMU protection.  So
for now let's disable iommu_platform for the device until we fully
support that (if needed).

After the patch, both virtio-vga and virtio-gpu won't allow to boot with
iommu_platform parameter set.

CC: Gerd Hoffmann 
Signed-off-by: Peter Xu 
Message-id: 20180131040401.3550-1-pet...@redhat.com
Signed-off-by: Gerd Hoffmann 
---
 hw/display/virtio-gpu-pci.c | 8 +++-
 hw/display/virtio-gpu.c | 5 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c
index ef92c4ad6f..3519dc80b1 100644
--- a/hw/display/virtio-gpu-pci.c
+++ b/hw/display/virtio-gpu-pci.c
@@ -28,10 +28,16 @@ static void virtio_gpu_pci_realize(VirtIOPCIProxy 
*vpci_dev, Error **errp)
 VirtIOGPU *g = &vgpu->vdev;
 DeviceState *vdev = DEVICE(&vgpu->vdev);
 int i;
+Error *local_error = NULL;
 
 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
 virtio_pci_force_virtio_1(vpci_dev);
-object_property_set_bool(OBJECT(vdev), true, "realized", errp);
+object_property_set_bool(OBJECT(vdev), true, "realized", &local_error);
+
+if (local_error) {
+error_propagate(errp, local_error);
+return;
+}
 
 for (i = 0; i < g->conf.max_outputs; i++) {
 object_property_set_link(OBJECT(g->scanout[i].con),
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 274e365713..6658f6c6a6 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1173,6 +1173,11 @@ static void virtio_gpu_device_realize(DeviceState *qdev, 
Error **errp)
 Error *local_err = NULL;
 int i;
 
+if (virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) {
+error_setg(errp, "virtio-gpu does not support vIOMMU yet");
+return;
+}
+
 if (g->conf.max_outputs > VIRTIO_GPU_MAX_SCANOUTS) {
 error_setg(errp, "invalid max_outputs > %d", VIRTIO_GPU_MAX_SCANOUTS);
 return;
-- 
2.9.3




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

2018-02-02 Thread Eric Blake
On 02/02/2018 09:25 AM, Eduardo Habkost wrote:

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

If you add an optional bool/enum to opt-in to the command in order to
provide different levels of reporting on output, and the default remains
that when the new input field is absent, all information that was output
in earlier versions of qemu is still output, then you are backwards
compatible.  This is true even if you switched some fields from
mandatory output to optional output, because of the use of the new input
flag for opt-in semantics.  Newer callers that use the opt-in field get
what they want, older callers get what they always expected.

-- 
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] block: maintain persistent disabled bitmaps

2018-02-02 Thread Vladimir Sementsov-Ogievskiy

02.02.2018 19:18, Eric Blake wrote:

On 02/02/2018 10:07 AM, 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)

Also, adjust iotests 165 and 176 appropriately.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
+++ b/qemu-doc.texi
@@ -2749,6 +2749,13 @@ used and it will be removed with no replacement.
  The ``convert -s snapshot_id_or_name'' argument is obsoleted
  by the ``convert -l snapshot_param'' argument instead.
  
+@section QEMU Machine Protocol (QMP) commands

+
+@subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0)
+
+"autoload" parameter is now ignored. All bitmaps are automatically loaded
+from qcow2 image.

Won't later patches be adding the ability to enable/disable bitmaps,
which then affects whether they are autoloaded?  So we don't forget to
revisit this text in that patch, a better wording might be:

The "autoload" parameter is ignored; all enabled persistent dirty
bitmaps are automatically loaded from a qcow2 image, regardless of the
initial setting requested in this parameter.



hmm.. no. all bitmaps are loaded, even disabled ones. Before this patch 
there is

no way to have disabled bitmap in qemu (by loading or by creating).
After the patch, we have a theoretical way of creating such bitmap in 
qcow2 image, then

it will be loaded as disabled.

Also, we can store bitmap with persistent=true and autoload=false before 
this patch, and there is no way
to load this bitmap before this patch, but after this patch it will be 
loaded as disabled.







@@ -667,19 +662,6 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs)
  }
  
  /* Called with BQL taken. */

-void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload)
-{
-qemu_mutex_lock(bitmap->mutex);
-bitmap->autoload = autoload;
-qemu_mutex_unlock(bitmap->mutex);
-}
-
-bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap)
-{
-return bitmap->autoload;
-}

Will later patches be reintroducing these functions for learning which
bitmaps are enabled/disabled?  But I'm okay with deleting them in this
patch, even if that is more churn.



no, actually the aim of the patch is to drop buggy relation between 
autoload qmp parameter
and auto qcow2 flag (which is more like "enabled" then "autoload"). Look 
at "Reasoning" in head

letter for details.

--
Best regards,
Vladimir




Re: [Qemu-devel] [PATCH] Add a git-publish configuration file

2018-02-02 Thread Fam Zheng
On Thu, Feb 1, 2018 at 6:46 PM, Stefan Hajnoczi  wrote:
> On Wed, Jan 31, 2018 at 11:06:05AM +0100, Marc-André Lureau wrote:
>> Hi
>>
>> On Wed, Jan 31, 2018 at 6:33 AM, Fam Zheng  wrote:
>> > 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
>>
>> It would be worth to update README "Submitting patches" with an example
>
> Good idea!
>
> The workflow for a new patch series is:
>
>   $ git checkout -b my-feature
>   ...work on feature...
>   $ git publish
>
> Your patch series has been 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
>   ...work on feature...
>   $ git publish
>
> Your patch series has been tagged as my-feature-v2.

Will add a paragraph in README.

>
>> >
>> > 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..2099c1520f
>> > --- /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 "qemu"]
>
> Please rename the "qemu" profile to "default".  This way no --profile
> needs to be given:
>
>   $ git publish
>
> The default profile settings can be overridden by command-line options
> and branch-specific settings.

Yes, good idea.

Fam



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

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

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




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

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

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

Max



signature.asc
Description: OpenPGP digital signature


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

2018-02-02 Thread Peter Maydell
On 2 February 2018 at 07:50, Gerd Hoffmann  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:
>
>   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.
>
> 

Applied, thanks.

-- PMM



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

2018-02-02 Thread Eric Blake
On 02/02/2018 05:10 AM, Gerd Hoffmann wrote:
> Not used any more, delete it.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  vl.c | 2 --
>  1 file changed, 2 deletions(-)

Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


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

2018-02-02 Thread Eric Blake
On 02/02/2018 10:07 AM, 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)
> 
> Also, adjust iotests 165 and 176 appropriately.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---

> +++ b/qemu-doc.texi
> @@ -2749,6 +2749,13 @@ used and it will be removed with no replacement.
>  The ``convert -s snapshot_id_or_name'' argument is obsoleted
>  by the ``convert -l snapshot_param'' argument instead.
>  
> +@section QEMU Machine Protocol (QMP) commands
> +
> +@subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0)
> +
> +"autoload" parameter is now ignored. All bitmaps are automatically loaded
> +from qcow2 image.

Won't later patches be adding the ability to enable/disable bitmaps,
which then affects whether they are autoloaded?  So we don't forget to
revisit this text in that patch, a better wording might be:

The "autoload" parameter is ignored; all enabled persistent dirty
bitmaps are automatically loaded from a qcow2 image, regardless of the
initial setting requested in this parameter.


> @@ -667,19 +662,6 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs)
>  }
>  
>  /* Called with BQL taken. */
> -void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload)
> -{
> -qemu_mutex_lock(bitmap->mutex);
> -bitmap->autoload = autoload;
> -qemu_mutex_unlock(bitmap->mutex);
> -}
> -
> -bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap)
> -{
> -return bitmap->autoload;
> -}

Will later patches be reintroducing these functions for learning which
bitmaps are enabled/disabled?  But I'm okay with deleting them in this
patch, even if that is more churn.

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



signature.asc
Description: OpenPGP digital signature


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

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

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



signature.asc
Description: OpenPGP digital signature


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

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

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

The queued fix is:

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



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

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

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

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

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




[Qemu-devel] [PULL v2 08/10] libqos/virtio: return length written into used descriptor

2018-02-02 Thread Greg Kurz
When a 9p request is flushed (ie, cancelled) by the guest, the device
is expected to simply mark the request as used, without sending a 9p
reply (ie, without writing anything into the used buffer).

To be able to test this, we need access to the length written by the
device into the used descriptor. This patch adds a uint32_t * argument
to qvirtqueue_get_buf() and qvirtio_wait_used_elem() for this purpose.

All existing users are updated accordingly.

Signed-off-by: Greg Kurz 
Reviewed-by: Stefan Hajnoczi 
---
 tests/libqos/virtio.c| 25 +
 tests/libqos/virtio.h|  3 ++-
 tests/virtio-9p-test.c   |  2 +-
 tests/virtio-blk-test.c  | 24 +---
 tests/virtio-net-test.c  |  6 +++---
 tests/virtio-scsi-test.c |  3 ++-
 6 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 0879a621c8af..0dad5c19acde 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -119,6 +119,8 @@ uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d,
 /*
  * qvirtio_wait_used_elem:
  * @desc_idx: The next expected vq->desc[] index in the used ring
+ * @len: A pointer that is filled with the length written into the buffer, may
+ *   be NULL
  * @timeout_us: How many microseconds to wait before failing
  *
  * This function waits for the next completed request on the used ring.
@@ -126,6 +128,7 @@ uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d,
 void qvirtio_wait_used_elem(QVirtioDevice *d,
 QVirtQueue *vq,
 uint32_t desc_idx,
+uint32_t *len,
 gint64 timeout_us)
 {
 gint64 start_time = g_get_monotonic_time();
@@ -136,7 +139,7 @@ void qvirtio_wait_used_elem(QVirtioDevice *d,
 clock_step(100);
 
 if (d->bus->get_queue_isr_status(d, vq) &&
-qvirtqueue_get_buf(vq, &got_desc_idx)) {
+qvirtqueue_get_buf(vq, &got_desc_idx, len)) {
 g_assert_cmpint(got_desc_idx, ==, desc_idx);
 return;
 }
@@ -304,30 +307,36 @@ void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, 
uint32_t free_head)
 /*
  * qvirtqueue_get_buf:
  * @desc_idx: A pointer that is filled with the vq->desc[] index, may be NULL
+ * @len: A pointer that is filled with the length written into the buffer, may
+ *   be NULL
  *
  * This function gets the next used element if there is one ready.
  *
  * Returns: true if an element was ready, false otherwise
  */
-bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx)
+bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len)
 {
 uint16_t idx;
+uint64_t elem_addr;
 
 idx = readw(vq->used + offsetof(struct vring_used, idx));
 if (idx == vq->last_used_idx) {
 return false;
 }
 
-if (desc_idx) {
-uint64_t elem_addr;
+elem_addr = vq->used +
+offsetof(struct vring_used, ring) +
+(vq->last_used_idx % vq->size) *
+sizeof(struct vring_used_elem);
 
-elem_addr = vq->used +
-offsetof(struct vring_used, ring) +
-(vq->last_used_idx % vq->size) *
-sizeof(struct vring_used_elem);
+if (desc_idx) {
 *desc_idx = readl(elem_addr + offsetof(struct vring_used_elem, id));
 }
 
+if (len) {
+*len = readw(elem_addr + offsetof(struct vring_used_elem, len));
+}
+
 vq->last_used_idx++;
 return true;
 }
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index 0a04740adfe1..69b5b13840e7 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -124,6 +124,7 @@ uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d,
 void qvirtio_wait_used_elem(QVirtioDevice *d,
 QVirtQueue *vq,
 uint32_t desc_idx,
+uint32_t *len,
 gint64 timeout_us);
 void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us);
 QVirtQueue *qvirtqueue_setup(QVirtioDevice *d,
@@ -140,7 +141,7 @@ uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, 
uint32_t len, bool write,
 bool next);
 uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect);
 void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head);
-bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx);
+bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len);
 
 void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx);
 
diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index 12315aeb4e5b..0d0341491e79 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -254,7 +254,7 @@ static void v9fs_req_wait_for_reply(P9Req *req)
 {
 QVirtIO9P *v9p = req->v9p;
 
-qvirtio_wait_used_elem(v9p->dev, v9p->vq, req->free_head,
+qvirtio_wait_us

Re: [Qemu-devel] [PATCH v2 3/6] qapi: add block-dirty-bitmap-enable/disable

2018-02-02 Thread Vladimir Sementsov-Ogievskiy

22.01.2018 22:56, John Snow wrote:


On 01/22/2018 02:51 PM, Eric Blake wrote:

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


I have to admit exposing this interface still makes me nervous, but :)

Mechanically correct, and with suggesting phrasing changes:

Reviewed-by: John Snow 

Should we go with an x- prefix for now, and let things settle for a
release before promoting it to fully supported, just in case we find
something that justifies your nervousness in accepting the interface?


I proposed as much in a reply to the cover letter; I'm willing to take
patch one now for the sake of migration; the rest of this series I want
a test suite that helps document the anticipated use case, or otherwise
an x- prefix for the command names.


Give me a try with test, and if it will still be unclear, then let's add 
x- prefix for first steps.

(of course, my aim is to push the api without x- prefixes =)

--
Best regards,
Vladimir




[Qemu-devel] [Bug 1746943] [NEW] qemu-aarch64-static: qemu: uncaught target signal 11 for ps/top cmd

2018-02-02 Thread cee1
Public bug reported:

In a docker container created from an aarch64 image, injects 
qemu-aarch64-static (in /usr/bin)
  run ps/top cmd  inside this container

  reports "qemu: uncaught target signal 11 (Segmentation fault)"

Tried qemu-aarch64-static from fedora 27 / ubuntu artful / debian
unstable (i.e. qemu version 2.10 - 2.11)

The aarch64 dock image is fedora 27(and with qemu-aarch64-static Fedora
27), hence I opened a related bug here
https://bugzilla.redhat.com/show_bug.cgi?id=1541252

** Affects: qemu
 Importance: Undecided
 Status: New

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

Title:
  qemu-aarch64-static: qemu: uncaught target signal 11 for ps/top cmd

Status in QEMU:
  New

Bug description:
  In a docker container created from an aarch64 image, injects 
qemu-aarch64-static (in /usr/bin)
run ps/top cmd  inside this container

reports "qemu: uncaught target signal 11 (Segmentation fault)"

  Tried qemu-aarch64-static from fedora 27 / ubuntu artful / debian
  unstable (i.e. qemu version 2.10 - 2.11)

  The aarch64 dock image is fedora 27(and with qemu-aarch64-static
  Fedora 27), hence I opened a related bug here
  https://bugzilla.redhat.com/show_bug.cgi?id=1541252

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



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 02:24:15PM +0200, Marcel Apfelbaum wrote:
> Hi Peter,
> 
> On 01/02/2018 13:20, Peter Xu 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.
> > 
> > CC: Alex Williamson 
> > CC: Marcel Apfelbaum 
> > CC: Michael S. Tsirkin 
> > CC: Dr. David Alan Gilbert 
> > CC: Juan Quintela 
> > CC: Laurent Vivier 
> > Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1538953
> > Reported-by: Maxime Coquelin 
> > Signed-off-by: Peter Xu 
> > ---
> > Marcel & all,
> > 
> > I think it's possible that we need similar thing for other bridge-like
> > devices, but I'm not that familiar.  Would you help confirm?  Thanks,
> 
> Is a pity we don't have a way to mark the migration priority
> in a base class. Dave, maybe we do have a way?
> 
> In the meantime you would need to add it also to:
> - ioh3420 (Intel root port)
> - xio3130_downstream (Intel switch downstream port)
> - xio3130_upstream (The counterpart of the above, you want the whole
>   switch to be migrated before loading the IOMMU device state)
> - pcie_pci_bridge (for pci devices)
> - pci-pci bridge (if for some reason you have one attached to the 
> pcie_pci_brdge)
> - i82801b11 (dmi-pci bridge, we want to deprecate it bu is there for now)

I'll see whether there is any better way to do this instead of
duplicating, but I'm not really sure about it.

Anyway, this list is helpful.  Thanks Marcel.

-- 
Peter Xu



  1   2   3   >