Re: [Qemu-devel] [PATCH for-2.10?] file-posix: Clear out first sector in hdev_create

2017-08-10 Thread Eric Blake
On 08/10/2017 03:01 AM, Fam Zheng wrote:
> People get surprised when, after "qemu-imc create -f raw /dev/sdX", they
> still see qcow2 with "qemu-img info", if previously the bdev had a qcow2
> header. While this is natural because raw doesn't need to write any
> magic bytes during creation, hdev_create is free to clear out the first
> sector to make sure the stale qcow2 header doesn't cause such a
> confusion.
> 
> Signed-off-by: Fam Zheng 
> ---
>  block/file-posix.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index f4de022ae0..1d8ef6f873 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -2703,6 +2703,17 @@ static int hdev_create(const char *filename, QemuOpts 
> *opts,
>  ret = -ENOSPC;
>  }
>  
> +if (total_size) {
> +int64_t zero_size = MIN(BDRV_SECTOR_SIZE, total_size);
> +uint8_t *buf;

Since BDRV_SECTOR_SIZE is small enough to stack-allocate, you could skip
the malloc by doing:

uint8_t buf[BDRV_SECTOR_SIZE] = "";

> +if (lseek(fd, 0, SEEK_SET) == -1) {
> +ret = -errno;
> +} else {
> +buf = g_malloc0(zero_size);
> +ret = qemu_write_full(fd, buf, zero_size);

Instead of doing lseek + qemu_write_full, can we just use
qemu_pwritev(fd, , 1, 0) with an iov set up to point to the
appropriate amount of buf?

At any rate, my ideas are micro-optimizations, so I can also live with
how you wrote it.

Reviewed-by: Eric Blake 

Are you arguing that this is a bug-fix worthy of inclusion in 2.10,
because it helps avoid user confusion? Or are you delaying it to 2.11,
because we've had the existing behavior for longer than one release, so
one release more won't hurt?

-- 
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 2/2] vl: Partial support for non-scalar properties with -object

2017-08-10 Thread Paolo Bonzini
On 10/08/2017 14:25, Markus Armbruster wrote:
> We've wanted -object to support non-scalar properties for a while.
> Dan Berrange tried in "[PATCH v4 00/10]Provide a QOM-based
> authorization API".  Review led to the conclusion that we need to
> replace rather than add to QemuOpts.  Initial work towards that goal
> has been merged to provide -blockdev (commit 8746709), but there's
> substantial work left, mostly due to an bewildering array of
> compatibility problems.
> 
> Even if a full solution is still out of reach, we can have a partial
> solution now: accept -object argument in JSON syntax.  This should
> unblock development work that needs non-scalar properties with -object
> 
> The implementation is similar to -blockdev, except we use the new
> infrastructure only for the new JSON case, and stick to QemuOpts for
> the existing KEY=VALUE,... case, to sidestep compatibility problems.
> 
> If we did this for more options, we'd have to factor out common code.
> But for one option, this will do.
> 
> Signed-off-by: Markus Armbruster 
> ---
>  qapi-schema.json | 14 +++---
>  vl.c | 55 +++
>  2 files changed, 66 insertions(+), 3 deletions(-)
> 
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 802ea53..7ed1db1 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -3618,15 +3618,23 @@
>  { 'command': 'netdev_del', 'data': {'id': 'str'} }
>  
>  ##
> -# @object-add:
> +# @ObjectOptions:
>  #
> -# Create a QOM object.
> +# Options for creating an object.
>  #
>  # @qom-type: the class name for the object to be created
>  #
>  # @id: the name of the new object
>  #
>  # @props: a dictionary of properties to be passed to the backend
> +##
> +{ 'struct': 'ObjectOptions',
> +  'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'} }
> +
> +##
> +# @object-add:
> +#
> +# Create a QOM object.
>  #
>  # Returns: Nothing on success
>  #  Error if @qom-type is not a valid class name
> @@ -3642,7 +3650,7 @@
>  #
>  ##
>  { 'command': 'object-add',
> -  'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'} }
> +  'data': 'ObjectOptions' }
>  
>  ##
>  # @object-del:
> diff --git a/vl.c b/vl.c
> index fd98ed1..db4680b 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2854,8 +2854,32 @@ static bool object_create_delayed(const char *type)
>  return !object_create_initial(type);
>  }
>  
> +typedef struct ObjectOptionsQueueEntry {
> +ObjectOptions *oo;
> +Location loc;
> +QSIMPLEQ_ENTRY(ObjectOptionsQueueEntry) entry;
> +} ObjectOptionsQueueEntry;
> +
> +typedef QSIMPLEQ_HEAD(ObjectOptionsQueue, ObjectOptionsQueueEntry)
> +ObjectOptionsQueue;
> +
> +ObjectOptionsQueue oo_queue = QSIMPLEQ_HEAD_INITIALIZER(oo_queue);
> +
> +
>  static void object_create(bool (*type_predicate)(const char *))
>  {
> +ObjectOptionsQueueEntry *e;
> +
> +QSIMPLEQ_FOREACH(e, _queue, entry) {
> +if (!type_predicate(e->oo->qom_type)) {
> +continue;
> +}
> +loc_push_restore(>loc);
> +qmp_object_add(e->oo->qom_type, e->oo->id,
> +   e->oo->has_props, e->oo->props, _fatal);
> +loc_pop(>loc);
> +}
> +
>  if (qemu_opts_foreach(qemu_find_opts("object"),
>user_creatable_add_opts_foreach,
>type_predicate, NULL)) {
> @@ -4078,6 +4102,29 @@ int main(int argc, char **argv, char **envp)
>  #endif
>  break;
>  case QEMU_OPTION_object:
> +/*
> + * TODO Use qobject_input_visitor_new_str() instead of
> + * QemuOpts, not in addition to.  Not done now because
> + * keyval_parse() isn't wart-compatible with QemuOpts.
> + */
> +if (optarg[0] == '{') {
> +Visitor *v;
> +ObjectOptionsQueueEntry *e;
> +
> +v = qobject_input_visitor_new_str(optarg, "qom-type",
> +  );
> +if (!v) {
> +error_report_err(err);
> +exit(1);
> +}
> +
> +e = g_new(ObjectOptionsQueueEntry, 1);
> +visit_type_ObjectOptions(v, NULL, >oo, _fatal);
> +visit_free(v);
> +loc_save(>loc);
> +QSIMPLEQ_INSERT_TAIL(_queue, e, entry);
> +break;
> +}
>  opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
> optarg, true);
>  if (!opts) {
> @@ -4525,6 +4572,14 @@ int main(int argc, char **argv, char **envp)
>  
>  object_create(object_create_delayed);
>  
> +while (!QSIMPLEQ_EMPTY(_queue)) {
> +ObjectOptionsQueueEntry *e = QSIMPLEQ_FIRST(_queue);
> +
> +QSIMPLEQ_REMOVE_HEAD(_queue, 

[Qemu-devel] [PATCH 07/15] input: convert ps2 device to keycodemapdb

2017-08-10 Thread Daniel P. Berrange
Replace the qcode_to_keycode_set1, qcode_to_keycode_set2,
and qcode_to_keycode_set3 tables with automatically
generated tables.

Missing entries in qcode_to_keycode_set1 now fixed:

 - Q_KEY_CODE_SYSRQ -> 0x54
 - Q_KEY_CODE_PRINT -> 0x54 (NB ignored due to special case)
 - Q_KEY_CODE_AGAIN -> 0xe005
 - Q_KEY_CODE_PROPS -> 0xe006
 - Q_KEY_CODE_UNDO -> 0xe007
 - Q_KEY_CODE_FRONT -> 0xe00c
 - Q_KEY_CODE_COPY -> 0xe078
 - Q_KEY_CODE_OPEN -> 0x64
 - Q_KEY_CODE_PASTE -> 0x65
 - Q_KEY_CODE_CUT -> 0xe03c
 - Q_KEY_CODE_LF -> 0x5b
 - Q_KEY_CODE_HELP -> 0xe075
 - Q_KEY_CODE_COMPOSE -> 0xe05d
 - Q_KEY_CODE_PAUSE -> 0xe046
 - Q_KEY_CODE_KP_EQUALS -> 0x59

And some mistakes corrected:

 - Q_KEY_CODE_HIRAGANA was mapped to 0x70 (Katakanahiragana)
   instead of of 0x77 (Hirigana)
 - Q_KEY_CODE_MENU was incorrectly mapped to the compose
   scancode (0xe05d) and is now mapped to 0xe01e
 - Q_KEY_CODE_FIND was mapped to 0xe065 (Search) instead
   of to 0xe041 (Find)
 - Q_KEY_CODE_POWER, SLEEP & WAKE had 0x0e instead of 0xe0
   as the prefix

Missing entries in qcode_to_keycode_set2 now fixed:

 - Q_KEY_CODE_PRINT -> 0x7f (NB ignored due to special case)
 - Q_KEY_CODE_COMPOSE -> 0xe02f
 - Q_KEY_CODE_PAUSE -> 0xe077
 - Q_KEY_CODE_KP_EQUALS -> 0x0f

And some mistakes corrected:

 - Q_KEY_CODE_HIRAGANA was mapped to 0x13 (Katakanahiragana)
   instead of of 0x62 (Hirigana)
 - Q_KEY_CODE_MENU was incorrectly mapped to the compose
   scancode (0xe02f) and is now not mapped
 - Q_KEY_CODE_FIND was mapped to 0xe010 (Search) and is now
   not mapped.
 - Q_KEY_CODE_POWER, SLEEP & WAKE had 0x0e instead of 0xe0
   as the prefix

Missing entries in qcode_to_keycode_set3 now fixed:

 - Q_KEY_CODE_ASTERISK -> 0x7e
 - Q_KEY_CODE_SYSRQ -> 0x57
 - Q_KEY_CODE_LESS -> 0x13
 - Q_KEY_CODE_STOP -> 0x0a
 - Q_KEY_CODE_AGAIN -> 0x0b
 - Q_KEY_CODE_PROPS -> 0x0c
 - Q_KEY_CODE_UNDO -> 0x10
 - Q_KEY_CODE_COPY -> 0x18
 - Q_KEY_CODE_OPEN -> 0x20
 - Q_KEY_CODE_PASTE -> 0x28
 - Q_KEY_CODE_FIND -> 0x30
 - Q_KEY_CODE_CUT -> 0x38
 - Q_KEY_CODE_HELP -> 0x09
 - Q_KEY_CODE_COMPOSE -> 0x8d
 - Q_KEY_CODE_AUDIONEXT -> 0x93
 - Q_KEY_CODE_AUDIOPREV -> 0x94
 - Q_KEY_CODE_AUDIOSTOP -> 0x98
 - Q_KEY_CODE_AUDIOMUTE -> 0x9c
 - Q_KEY_CODE_VOLUMEUP -> 0x95
 - Q_KEY_CODE_VOLUMEDOWN -> 0x9d
 - Q_KEY_CODE_CALCULATOR -> 0xa3
 - Q_KEY_CODE_AC_HOME -> 0x97

And some mistakes corrected:

 - Q_KEY_CODE_MENU was incorrectly mapped to the compose
   scancode (0x8d) and is now 0x91

Signed-off-by: Daniel P. Berrange 
---
 hw/input/ps2.c | 406 +
 include/ui/input.h |   9 ++
 ui/Makefile.objs   |   3 +
 ui/input-keymap.c  |   3 +
 4 files changed, 22 insertions(+), 399 deletions(-)

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 14b1d85f6c..86529a058a 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -115,401 +115,6 @@ typedef struct {
 uint8_t mouse_buttons;
 } PS2MouseState;
 
-/* Table to convert from QEMU codes to scancodes.  */
-static const uint16_t qcode_to_keycode_set1[Q_KEY_CODE__MAX] = {
-[0 ... Q_KEY_CODE__MAX - 1] = 0,
-
-[Q_KEY_CODE_A] = 0x1e,
-[Q_KEY_CODE_B] = 0x30,
-[Q_KEY_CODE_C] = 0x2e,
-[Q_KEY_CODE_D] = 0x20,
-[Q_KEY_CODE_E] = 0x12,
-[Q_KEY_CODE_F] = 0x21,
-[Q_KEY_CODE_G] = 0x22,
-[Q_KEY_CODE_H] = 0x23,
-[Q_KEY_CODE_I] = 0x17,
-[Q_KEY_CODE_J] = 0x24,
-[Q_KEY_CODE_K] = 0x25,
-[Q_KEY_CODE_L] = 0x26,
-[Q_KEY_CODE_M] = 0x32,
-[Q_KEY_CODE_N] = 0x31,
-[Q_KEY_CODE_O] = 0x18,
-[Q_KEY_CODE_P] = 0x19,
-[Q_KEY_CODE_Q] = 0x10,
-[Q_KEY_CODE_R] = 0x13,
-[Q_KEY_CODE_S] = 0x1f,
-[Q_KEY_CODE_T] = 0x14,
-[Q_KEY_CODE_U] = 0x16,
-[Q_KEY_CODE_V] = 0x2f,
-[Q_KEY_CODE_W] = 0x11,
-[Q_KEY_CODE_X] = 0x2d,
-[Q_KEY_CODE_Y] = 0x15,
-[Q_KEY_CODE_Z] = 0x2c,
-[Q_KEY_CODE_0] = 0x0b,
-[Q_KEY_CODE_1] = 0x02,
-[Q_KEY_CODE_2] = 0x03,
-[Q_KEY_CODE_3] = 0x04,
-[Q_KEY_CODE_4] = 0x05,
-[Q_KEY_CODE_5] = 0x06,
-[Q_KEY_CODE_6] = 0x07,
-[Q_KEY_CODE_7] = 0x08,
-[Q_KEY_CODE_8] = 0x09,
-[Q_KEY_CODE_9] = 0x0a,
-[Q_KEY_CODE_GRAVE_ACCENT] = 0x29,
-[Q_KEY_CODE_MINUS] = 0x0c,
-[Q_KEY_CODE_EQUAL] = 0x0d,
-[Q_KEY_CODE_BACKSLASH] = 0x2b,
-[Q_KEY_CODE_BACKSPACE] = 0x0e,
-[Q_KEY_CODE_SPC] = 0x39,
-[Q_KEY_CODE_TAB] = 0x0f,
-[Q_KEY_CODE_CAPS_LOCK] = 0x3a,
-[Q_KEY_CODE_SHIFT] = 0x2a,
-[Q_KEY_CODE_CTRL] = 0x1d,
-[Q_KEY_CODE_META_L] = 0xe05b,
-[Q_KEY_CODE_ALT] = 0x38,
-[Q_KEY_CODE_SHIFT_R] = 0x36,
-[Q_KEY_CODE_CTRL_R] = 0xe01d,
-[Q_KEY_CODE_META_R] = 0xe05c,
-[Q_KEY_CODE_ALT_R] = 0xe038,
-[Q_KEY_CODE_MENU] = 0xe05d,
-[Q_KEY_CODE_RET] = 0x1c,
-[Q_KEY_CODE_ESC] = 0x01,
-[Q_KEY_CODE_F1] = 0x3b,
-[Q_KEY_CODE_F2] = 0x3c,
-[Q_KEY_CODE_F3] = 0x3d,
-[Q_KEY_CODE_F4] = 0x3e,
-[Q_KEY_CODE_F5] = 0x3f,
-[Q_KEY_CODE_F6] = 0x40,
-[Q_KEY_CODE_F7] = 0x41,
-[Q_KEY_CODE_F8] = 0x42,
-[Q_KEY_CODE_F9] = 0x43,
-

[Qemu-devel] [PATCH 13/15] ui: remove qemu_input_qcode_to_number method

2017-08-10 Thread Daniel P. Berrange
The qemu_input_qcode_to_number method is only used in one place and
no new code should require it, so inline it at the only caller.

Signed-off-by: Daniel P. Berrange 
---
 include/ui/input.h |  1 -
 ui/input-keymap.c  | 16 +++-
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/include/ui/input.h b/include/ui/input.h
index 7ac1d62747..b3827b6082 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -42,7 +42,6 @@ void qemu_input_event_send_key_number(QemuConsole *src, int 
num, bool down);
 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
 void qemu_input_event_send_key_delay(uint32_t delay_ms);
 int qemu_input_key_number_to_qcode(unsigned int nr);
-int qemu_input_qcode_to_number(QKeyCode qcode);
 int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down, int *codes);
 int qemu_input_linux_to_qcode(unsigned int lnx);
 
diff --git a/ui/input-keymap.c b/ui/input-keymap.c
index 566b8f2000..71c6a79e66 100644
--- a/ui/input-keymap.c
+++ b/ui/input-keymap.c
@@ -32,14 +32,6 @@ int qemu_input_linux_to_qcode(unsigned int lnx)
 return qemu_input_map_linux2qcode[lnx];
 }
 
-int qemu_input_qcode_to_number(QKeyCode qcode)
-{
-if (qcode >= qemu_input_map_qcode2qnum_len) {
-return 0;
-}
-return qemu_input_map_qcode2qnum[qcode];
-}
-
 int qemu_input_key_number_to_qcode(unsigned int nr)
 {
 if (nr >= qemu_input_map_qnum2qcode_len) {
@@ -51,9 +43,15 @@ int qemu_input_key_number_to_qcode(unsigned int nr)
 int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down,
  int *codes)
 {
-int keycode = qemu_input_qcode_to_number(qcode);
+int keycode;
 int count = 0;
 
+if (qcode >= qemu_input_map_qcode2qnum_len) {
+keycode = 0;
+} else {
+keycode = qemu_input_map_qcode2qnum[qcode];
+}
+
 if (qcode == Q_KEY_CODE_PAUSE) {
 /* specific case */
 int v = down ? 0 : 0x80;
-- 
2.13.3




[Qemu-devel] [PATCH 09/15] char: convert the escc device to keycodemapdb

2017-08-10 Thread Daniel P. Berrange
Replace the qcode_to_keycode table with automatically
generated tables.

Missing entries in qcode_to_keycode now fixed:

 - Q_KEY_CODE_KP_COMMA -> 0x2d

Signed-off-by: Daniel P. Berrange 
---
 hw/char/escc.c | 126 +++--
 include/ui/input.h |   3 ++
 ui/Makefile.objs   |   1 +
 ui/input-keymap.c  |   1 +
 4 files changed, 10 insertions(+), 121 deletions(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 5af7f0cddf..3cacdb5102 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -717,126 +717,6 @@ MemoryRegion *escc_init(hwaddr base, qemu_irq irqA, 
qemu_irq irqB,
 return >mmio;
 }
 
-static const uint8_t qcode_to_keycode[Q_KEY_CODE__MAX] = {
-[Q_KEY_CODE_SHIFT] = 99,
-[Q_KEY_CODE_SHIFT_R]   = 110,
-[Q_KEY_CODE_ALT]   = 19,
-[Q_KEY_CODE_ALT_R] = 13,
-[Q_KEY_CODE_CTRL]  = 76,
-[Q_KEY_CODE_CTRL_R]= 76,
-[Q_KEY_CODE_ESC]   = 29,
-[Q_KEY_CODE_1] = 30,
-[Q_KEY_CODE_2] = 31,
-[Q_KEY_CODE_3] = 32,
-[Q_KEY_CODE_4] = 33,
-[Q_KEY_CODE_5] = 34,
-[Q_KEY_CODE_6] = 35,
-[Q_KEY_CODE_7] = 36,
-[Q_KEY_CODE_8] = 37,
-[Q_KEY_CODE_9] = 38,
-[Q_KEY_CODE_0] = 39,
-[Q_KEY_CODE_MINUS] = 40,
-[Q_KEY_CODE_EQUAL] = 41,
-[Q_KEY_CODE_BACKSPACE] = 43,
-[Q_KEY_CODE_TAB]   = 53,
-[Q_KEY_CODE_Q] = 54,
-[Q_KEY_CODE_W] = 55,
-[Q_KEY_CODE_E] = 56,
-[Q_KEY_CODE_R] = 57,
-[Q_KEY_CODE_T] = 58,
-[Q_KEY_CODE_Y] = 59,
-[Q_KEY_CODE_U] = 60,
-[Q_KEY_CODE_I] = 61,
-[Q_KEY_CODE_O] = 62,
-[Q_KEY_CODE_P] = 63,
-[Q_KEY_CODE_BRACKET_LEFT]  = 64,
-[Q_KEY_CODE_BRACKET_RIGHT] = 65,
-[Q_KEY_CODE_RET]   = 89,
-[Q_KEY_CODE_A] = 77,
-[Q_KEY_CODE_S] = 78,
-[Q_KEY_CODE_D] = 79,
-[Q_KEY_CODE_F] = 80,
-[Q_KEY_CODE_G] = 81,
-[Q_KEY_CODE_H] = 82,
-[Q_KEY_CODE_J] = 83,
-[Q_KEY_CODE_K] = 84,
-[Q_KEY_CODE_L] = 85,
-[Q_KEY_CODE_SEMICOLON] = 86,
-[Q_KEY_CODE_APOSTROPHE]= 87,
-[Q_KEY_CODE_GRAVE_ACCENT]  = 42,
-[Q_KEY_CODE_BACKSLASH] = 88,
-[Q_KEY_CODE_Z] = 100,
-[Q_KEY_CODE_X] = 101,
-[Q_KEY_CODE_C] = 102,
-[Q_KEY_CODE_V] = 103,
-[Q_KEY_CODE_B] = 104,
-[Q_KEY_CODE_N] = 105,
-[Q_KEY_CODE_M] = 106,
-[Q_KEY_CODE_COMMA] = 107,
-[Q_KEY_CODE_DOT]   = 108,
-[Q_KEY_CODE_SLASH] = 109,
-[Q_KEY_CODE_ASTERISK]  = 47,
-[Q_KEY_CODE_SPC]   = 121,
-[Q_KEY_CODE_CAPS_LOCK] = 119,
-[Q_KEY_CODE_F1]= 5,
-[Q_KEY_CODE_F2]= 6,
-[Q_KEY_CODE_F3]= 8,
-[Q_KEY_CODE_F4]= 10,
-[Q_KEY_CODE_F5]= 12,
-[Q_KEY_CODE_F6]= 14,
-[Q_KEY_CODE_F7]= 16,
-[Q_KEY_CODE_F8]= 17,
-[Q_KEY_CODE_F9]= 18,
-[Q_KEY_CODE_F10]   = 7,
-[Q_KEY_CODE_NUM_LOCK]  = 98,
-[Q_KEY_CODE_SCROLL_LOCK]   = 23,
-[Q_KEY_CODE_KP_DIVIDE] = 46,
-[Q_KEY_CODE_KP_MULTIPLY]   = 47,
-[Q_KEY_CODE_KP_SUBTRACT]   = 71,
-[Q_KEY_CODE_KP_ADD]= 125,
-[Q_KEY_CODE_KP_ENTER]  = 90,
-[Q_KEY_CODE_KP_DECIMAL]= 50,
-[Q_KEY_CODE_KP_0]  = 94,
-[Q_KEY_CODE_KP_1]  = 112,
-[Q_KEY_CODE_KP_2]  = 113,
-[Q_KEY_CODE_KP_3]  = 114,
-[Q_KEY_CODE_KP_4]  = 91,
-[Q_KEY_CODE_KP_5]  = 92,
-[Q_KEY_CODE_KP_6]  = 93,
-[Q_KEY_CODE_KP_7]  = 68,
-[Q_KEY_CODE_KP_8]  = 69,
-[Q_KEY_CODE_KP_9]  = 70,
-[Q_KEY_CODE_LESS]  = 124,
-[Q_KEY_CODE_F11]   = 9,
-[Q_KEY_CODE_F12]   = 11,
-[Q_KEY_CODE_HOME]  = 52,
-[Q_KEY_CODE_PGUP]  = 96,
-[Q_KEY_CODE_PGDN]  = 123,
-[Q_KEY_CODE_END]   = 74,
-[Q_KEY_CODE_LEFT]  = 24,
-[Q_KEY_CODE_UP]= 20,
-[Q_KEY_CODE_DOWN]  = 27,
-[Q_KEY_CODE_RIGHT] = 28,
-[Q_KEY_CODE_INSERT]= 44,
-[Q_KEY_CODE_DELETE]= 66,
-[Q_KEY_CODE_STOP]  = 1,
-[Q_KEY_CODE_AGAIN] = 3,
-[Q_KEY_CODE_PROPS] = 25,
-[Q_KEY_CODE_UNDO]  = 26,
-[Q_KEY_CODE_FRONT] = 49,
-[Q_KEY_CODE_COPY]  = 51,
-[Q_KEY_CODE_OPEN]  = 72,
-[Q_KEY_CODE_PASTE] = 73,
-[Q_KEY_CODE_FIND]  = 95,
-[Q_KEY_CODE_CUT]   = 97,
-[Q_KEY_CODE_LF]= 111,

[Qemu-devel] [PULL] 9pfs: local: fix fchmodat_nofollow() limitations

2017-08-10 Thread Greg Kurz
This function has to ensure it doesn't follow a symlink that could be used
to escape the virtfs directory. This could be easily achieved if fchmodat()
on linux honored the AT_SYMLINK_NOFOLLOW flag as described in POSIX, but
it doesn't. There was a tentative to implement a new fchmodat2() syscall
with the correct semantics:

https://patchwork.kernel.org/patch/9596301/

but it didn't gain much momentum. Also it was suggested to look at an O_PATH
based solution in the first place.

The current implementation covers most use-cases, but it notably fails if:
- the target path has access rights equal to  (openat() returns EPERM),
  => once you've done chmod() on a file, you can never chmod() again
- the target path is UNIX domain socket (openat() returns ENXIO)
  => bind() of UNIX domain sockets fails if the file is on 9pfs

The solution is to use O_PATH: openat() now succeeds in both cases, and we
can ensure the path isn't a symlink with fstat(). The associated entry in
"/proc/self/fd" can hence be safely passed to the regular chmod() syscall.

The previous behavior is kept for older systems that don't have O_PATH.

Signed-off-by: Greg Kurz 
Reviewed-by: Eric Blake 
Tested-by: Zhi Yong Wu 
Acked-by: Philippe Mathieu-Daudé 
---
 hw/9pfs/9p-local.c | 42 +++---
 hw/9pfs/9p-util.h  | 24 +++-
 2 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 6e478f4765ef..efb0b79a74bf 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -333,17 +333,27 @@ update_map_file:
 
 static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
 {
+struct stat stbuf;
 int fd, ret;
 
 /* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW).
- * Unfortunately, the linux kernel doesn't implement it yet. As an
- * alternative, let's open the file and use fchmod() instead. This
- * may fail depending on the permissions of the file, but it is the
- * best we can do to avoid TOCTTOU. We first try to open read-only
- * in case name points to a directory. If that fails, we try write-only
- * in case name doesn't point to a directory.
+ * Unfortunately, the linux kernel doesn't implement it yet.
  */
-fd = openat_file(dirfd, name, O_RDONLY, 0);
+
+ /* First, we clear non-racing symlinks out of the way. */
+if (fstatat(dirfd, name, , AT_SYMLINK_NOFOLLOW)) {
+return -1;
+}
+if (S_ISLNK(stbuf.st_mode)) {
+errno = ELOOP;
+return -1;
+}
+
+/* Access modes are ignored when O_PATH is supported. We try O_RDONLY and
+ * O_WRONLY for old-systems that don't support O_PATH.
+ */
+fd = openat_file(dirfd, name, O_RDONLY | O_PATH_9P_UTIL, 0);
+#if O_PATH_9P_UTIL == 0
 if (fd == -1) {
 /* In case the file is writable-only and isn't a directory. */
 if (errno == EACCES) {
@@ -357,6 +367,24 @@ static int fchmodat_nofollow(int dirfd, const char *name, 
mode_t mode)
 return -1;
 }
 ret = fchmod(fd, mode);
+#else
+if (fd == -1) {
+return -1;
+}
+
+/* Now we handle racing symlinks. */
+ret = fstat(fd, );
+if (!ret) {
+if (S_ISLNK(stbuf.st_mode)) {
+errno = ELOOP;
+ret = -1;
+} else {
+char *proc_path = g_strdup_printf("/proc/self/fd/%d", fd);
+ret = chmod(proc_path, mode);
+g_free(proc_path);
+}
+}
+#endif
 close_preserve_errno(fd);
 return ret;
 }
diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
index 91299a24b8af..dc0d2e29aa3b 100644
--- a/hw/9pfs/9p-util.h
+++ b/hw/9pfs/9p-util.h
@@ -13,6 +13,12 @@
 #ifndef QEMU_9P_UTIL_H
 #define QEMU_9P_UTIL_H
 
+#ifdef O_PATH
+#define O_PATH_9P_UTIL O_PATH
+#else
+#define O_PATH_9P_UTIL 0
+#endif
+
 static inline void close_preserve_errno(int fd)
 {
 int serrno = errno;
@@ -22,13 +28,8 @@ static inline void close_preserve_errno(int fd)
 
 static inline int openat_dir(int dirfd, const char *name)
 {
-#ifdef O_PATH
-#define OPENAT_DIR_O_PATH O_PATH
-#else
-#define OPENAT_DIR_O_PATH 0
-#endif
 return openat(dirfd, name,
-  O_DIRECTORY | O_RDONLY | O_NOFOLLOW | OPENAT_DIR_O_PATH);
+  O_DIRECTORY | O_RDONLY | O_NOFOLLOW | O_PATH_9P_UTIL);
 }
 
 static inline int openat_file(int dirfd, const char *name, int flags,
@@ -43,9 +44,14 @@ static inline int openat_file(int dirfd, const char *name, 
int flags,
 }
 
 serrno = errno;
-/* O_NONBLOCK was only needed to open the file. Let's drop it. */
-ret = fcntl(fd, F_SETFL, flags);
-assert(!ret);
+/* O_NONBLOCK was only needed to open the file. Let's drop it. We don't
+ * do that with O_PATH since fcntl(F_SETFL) isn't supported, and openat()
+ * ignored it anyway.
+ */
+if (!(flags & O_PATH_9P_UTIL)) {
+ret = fcntl(fd, 

[Qemu-devel] [PATCH 1/8] tests: add functional test validating ipv4/ipv6 address flag handling

2017-08-10 Thread Daniel P. Berrange
The semantics around handling ipv4=on|off & ipv6=on|off are quite
subtle to understand in combination with the various hostname addresses
and backend types. Introduce a massive test matrix that launches QEMU
and validates the ability to connect a client on each protocol as
appropriate.

The test requires that the host has ability to bind to both :: and
0.0.0.0, on port 9000. If either protocol is not available, or if
something is already listening on that port the test will skip.

Although it isn't using the QTest APIs, it expects the
QTEST_QEMU_BINARY env variable to be set.

Reviewed-by: Eric Blake 
Tested-by: Eric Blake 
Signed-off-by: Daniel P. Berrange 
---
 tests/.gitignore   |   1 +
 tests/Makefile.include |   3 +
 tests/test-sockets-proto.c | 924 +
 3 files changed, 928 insertions(+)
 create mode 100644 tests/test-sockets-proto.c

diff --git a/tests/.gitignore b/tests/.gitignore
index fed0189a5a..044183f4a0 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -78,6 +78,7 @@ test-qobject-output-visitor
 test-rcu-list
 test-replication
 test-shift128
+test-sockets-proto
 test-string-input-visitor
 test-string-output-visitor
 test-thread-pool
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 59e536bf0b..8caa5a7ae8 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -340,6 +340,7 @@ check-qtest-s390x-y = tests/boot-serial-test$(EXESUF)
 
 check-qtest-generic-y += tests/qom-test$(EXESUF)
 check-qtest-generic-y += tests/test-hmp$(EXESUF)
+check-qtest-generic-y += tests/test-sockets-proto$(EXESUF)
 
 qapi-schema += alternate-any.json
 qapi-schema += alternate-array.json
@@ -750,6 +751,8 @@ tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o 
$(libqos-usb-obj-y)
 tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
 tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o
 tests/postcopy-test$(EXESUF): tests/postcopy-test.o
+tests/test-sockets-proto$(EXESUF): tests/test-sockets-proto.o \
+   $(test-io-obj-y)
 tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o $(test-util-obj-y) \
$(qtest-obj-y) $(test-io-obj-y) $(libqos-virtio-obj-y) 
$(libqos-pc-obj-y) \
$(chardev-obj-y)
diff --git a/tests/test-sockets-proto.c b/tests/test-sockets-proto.c
new file mode 100644
index 00..1d6beda59f
--- /dev/null
+++ b/tests/test-sockets-proto.c
@@ -0,0 +1,924 @@
+/*
+ * QTest for IPv4/IPv6 protocol setup
+ *
+ * Copyright (c) 2017 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+
+#include "io/channel-socket.h"
+#include "qapi/error.h"
+#include "qemu/cutils.h"
+
+typedef struct {
+const char *name;
+const char *args;
+int ipv4; /* 0 -> disabled, 1 -> enabled */
+int ipv6; /* 0 -> disabled, 1 -> enabled, -1 -> check getaddrinfo() order 
*/
+bool error;
+} QSocketsData;
+
+/*
+ * This is the giant matrix of combinations we need to consider.
+ * There are 3 axes we deal with
+ *
+ * Axis 1: Protocol flags:
+ *
+ *  ipv4=unset, ipv6=unset  -> v4 & v6 clients ([1]
+ *  ipv4=unset, ipv6=off-> v4 clients only
+ *  ipv4=unset, ipv6=on -> v6 clients only
+ *  ipv4=off, ipv6=unset-> v6 clients only
+ *  ipv4=off, ipv6=off  -> error - can't disable both [2]
+ *  ipv4=off, ipv6=on   -> v6 clients only
+ *  ipv4=on, ipv6=unset -> v4 clients only
+ *  ipv4=on, ipv6=off   -> v4 clients only
+ *  ipv4=on, ipv6=on-> v4 & v6 clients [3]
+ *
+ * Depending on the listening address, some of those combinations
+ * may result in errors. eg ipv4=off,ipv6=on combined with 0.0.0.0
+ * is nonsensical.
+ *
+ * [1] Some backends only support a single socket listener, so
+ * will actually only allow v4 clients
+ * [2] QEMU should fail to startup in this case
+ * [3] If hostname is "" or "::", then we get a single listener
+ * on IPv6 and thus can also accept v4 clients. For all other
+ * hostnames, have same problem as [1].
+ *
+ * Axis 2: Listening address:
+ *
+ *  ""- resolves to 0.0.0.0 and ::, in that order
+ *  "0.0.0.0" - v4 clients only
+ *  "::"  - Mostly v6 clients only. Some scenarios should
+ *  permit v4 clients too.
+ *
+ * Axis 3: Backend type:
+ *
+ *  Migration - restricted to a single listener. Also relies
+ *  on buggy inet_parse() which can't accept
+ *  =off/=on parameters to ipv4/ipv6 flags
+ *  Chardevs  - restricted to a single listener.
+ *  VNC   - supports multiple listeners. Also supports
+ *  socket ranges, so has extra set of tests
+ *  in the matrix
+ *
+ */
+static QSocketsData test_data[] = {
+/* Migrate with "" address */
+/* XXX all settings with =off are disabled due to inet_parse() bug */
+/* XXX multilistener bug - 

[Qemu-devel] [PATCH 6/8] chardev: convert the socket server to QIONetListener

2017-08-10 Thread Daniel P. Berrange
Instead of creating a QIOChannelSocket directly for the chardev
server socket, use a QIONetListener. This provides the ability
to listen on multiple sockets at the same time, so enables
full support for IPv4/IPv6 dual stack.

Signed-off-by: Daniel P. Berrange 
---
 chardev/char-socket.c  | 70 ++
 tests/test-sockets-proto.c |  8 ++
 2 files changed, 29 insertions(+), 49 deletions(-)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 1ae730a4cb..96ff2a3ff4 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -25,6 +25,7 @@
 #include "chardev/char.h"
 #include "io/channel-socket.h"
 #include "io/channel-tls.h"
+#include "io/net-listener.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qapi/clone-visitor.h"
@@ -40,8 +41,7 @@ typedef struct {
 Chardev parent;
 QIOChannel *ioc; /* Client I/O channel */
 QIOChannelSocket *sioc; /* Client master channel */
-QIOChannelSocket *listen_ioc;
-guint listen_tag;
+QIONetListener *listener;
 QCryptoTLSCreds *tls_creds;
 int connected;
 int max_size;
@@ -93,9 +93,9 @@ static void check_report_connect_error(Chardev *chr,
 qemu_chr_socket_restart_timer(chr);
 }
 
-static gboolean tcp_chr_accept(QIOChannel *chan,
-   GIOCondition cond,
-   void *opaque);
+static void tcp_chr_accept(QIONetListener *listener,
+   QIOChannelSocket *cioc,
+   void *opaque);
 
 static int tcp_chr_read_poll(void *opaque);
 static void tcp_chr_disconnect(Chardev *chr);
@@ -404,9 +404,8 @@ static void tcp_chr_disconnect(Chardev *chr)
 
 tcp_chr_free_connection(chr);
 
-if (s->listen_ioc) {
-s->listen_tag = qio_channel_add_watch(
-QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
+if (s->listener) {
+qio_net_listener_set_client_func(s->listener, tcp_chr_accept, chr, 
NULL);
 }
 update_disconnected_filename(s);
 qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
@@ -704,9 +703,8 @@ static int tcp_chr_new_client(Chardev *chr, 
QIOChannelSocket *sioc)
 if (s->do_nodelay) {
 qio_channel_set_delay(s->ioc, false);
 }
-if (s->listen_tag) {
-g_source_remove(s->listen_tag);
-s->listen_tag = 0;
+if (s->listener) {
+qio_net_listener_set_client_func(s->listener, NULL, NULL, NULL);
 }
 
 if (s->tls_creds) {
@@ -738,24 +736,14 @@ static int tcp_chr_add_client(Chardev *chr, int fd)
 return ret;
 }
 
-static gboolean tcp_chr_accept(QIOChannel *channel,
-   GIOCondition cond,
-   void *opaque)
+static void tcp_chr_accept(QIONetListener *listener,
+   QIOChannelSocket *cioc,
+   void *opaque)
 {
 Chardev *chr = CHARDEV(opaque);
-QIOChannelSocket *sioc;
-
-sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(channel),
- NULL);
-if (!sioc) {
-return TRUE;
-}
-
-tcp_chr_new_client(chr, sioc);
 
-object_unref(OBJECT(sioc));
-
-return TRUE;
+tcp_chr_set_client_ioc_name(chr, cioc);
+tcp_chr_new_client(chr, cioc);
 }
 
 static int tcp_chr_wait_connected(Chardev *chr, Error **errp)
@@ -769,9 +757,10 @@ static int tcp_chr_wait_connected(Chardev *chr, Error 
**errp)
 if (s->is_listen) {
 info_report("QEMU waiting for connection on: %s",
 chr->filename);
-qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), true, NULL);
-tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr);
-qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
+sioc = qio_net_listener_wait_client(s->listener);
+tcp_chr_set_client_ioc_name(chr, sioc);
+tcp_chr_new_client(chr, sioc);
+object_unref(OBJECT(sioc));
 } else {
 sioc = qio_channel_socket_new();
 tcp_chr_set_client_ioc_name(chr, sioc);
@@ -799,12 +788,9 @@ static void char_socket_finalize(Object *obj)
 s->reconnect_timer = 0;
 }
 qapi_free_SocketAddress(s->addr);
-if (s->listen_tag) {
-g_source_remove(s->listen_tag);
-s->listen_tag = 0;
-}
-if (s->listen_ioc) {
-object_unref(OBJECT(s->listen_ioc));
+if (s->listener) {
+qio_net_listener_set_client_func(s->listener, NULL, NULL, NULL);
+object_unref(OBJECT(s->listener));
 }
 if (s->tls_creds) {
 object_unref(OBJECT(s->tls_creds));
@@ -937,29 +923,27 @@ static void qmp_chardev_open_socket(Chardev *chr,
 } else {
 if (s->is_listen) {
 char *name;
-sioc = qio_channel_socket_new();
+s->listener = qio_net_listener_new();
 
 name = g_strdup_printf("chardev-tcp-listener-%s", 

Re: [Qemu-devel] [PATCH] virtio-blk: handle blk_getlength() errors

2017-08-10 Thread Stefan Hajnoczi
On Tue, Aug 08, 2017 at 01:22:51PM +0100, Stefan Hajnoczi wrote:
> If blk_getlength() fails in virtio_blk_update_config() consider the disk
> image length to be 0 bytes.
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  hw/block/virtio-blk.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v7 2/6] qmp: Create IOThrottle structure

2017-08-10 Thread Pradeep Jagadeesh

On 8/8/2017 5:18 PM, Markus Armbruster wrote:

Alberto Garcia  writes:


On Tue 08 Aug 2017 02:30:43 PM CEST, Pradeep Jagadeesh wrote:

On 8/8/2017 1:30 PM, Alberto Garcia wrote:

On Mon 07 Aug 2017 04:48:38 PM CEST, Markus Armbruster wrote:

Awkward question for a v7, but here goes anyway: why is IOThrottle
worth its very own .json file?

I feel this is a common throttle structure that is used by block
devices as well as fsdev, so moved to a separate file.

I'm not sure that's a good idea.  Kevin, Berto, what do you think?


Mmm... I don't have a very strong opinion, but if there's no actual need
to move it to a separate file I'd prefer to leave it where it is.

The segregation is the solid reason. Because throttling is a feature
that is used by fsdev, block may many more in future. I do not see
moving it back to block does it make any sense?


It's not "moving it back", it's keeping it where it is. But I see no big
problem with moving it to a common file either.


I'd rather not put every struct shared across subsystem boundaries in
its own file.

We can keep it right where it is for now.  Bonus: more readable diff.
If we start sharing more throttle-related material than just a struct,
we can reconsider.

We could also move it to the existing file for common stuff:
qapi/common.json.  Not a great fit, though.

So, the final conclusion is to move to common.json?

Regards,
Pradeep







Re: [Qemu-devel] [PATCH v7 2/6] qmp: Create IOThrottle structure

2017-08-10 Thread Eric Blake
On 08/10/2017 09:06 AM, Pradeep Jagadeesh wrote:

>>> It's not "moving it back", it's keeping it where it is. But I see no big
>>> problem with moving it to a common file either.
>>
>> I'd rather not put every struct shared across subsystem boundaries in
>> its own file.
>>
>> We can keep it right where it is for now.  Bonus: more readable diff.
>> If we start sharing more throttle-related material than just a struct,
>> we can reconsider.
>>
>> We could also move it to the existing file for common stuff:
>> qapi/common.json.  Not a great fit, though.
> So, the final conclusion is to move to common.json?

No.

If more than one .json file would benefit by including the definition,
then put it in a separate file that both .json include from.

But if only one .json file would be including a new file, then just
inline the struct directly into that one original file (in this case,
block-core.json) instead of creating a separate file (so no to needing
iothrottle.json), or putting the code in yet a different file than the
one that is using the struct (so no to putting it in common.json).

-- 
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 05/15] ui: use QKeyCode exclusively in InputKeyEvent

2017-08-10 Thread Daniel P. Berrange
Now that keycode numbers are converted to QKeyCodes immediately
when creating input events, the InputKeyEvent struct can be
changed to only accept a QKeyCode, instead of a KeyValue.

Signed-off-by: Daniel P. Berrange 
---
 hw/char/escc.c  |  2 +-
 hw/input/adb.c  |  2 +-
 hw/input/hid.c  |  6 +++---
 hw/input/ps2.c  |  2 +-
 hw/input/virtio-input-hid.c |  2 +-
 include/ui/input.h  |  7 ++-
 qapi-schema.json|  2 +-
 replay/replay-input.c   | 36 --
 ui/input-keymap.c   | 32 --
 ui/input-legacy.c   | 31 +-
 ui/input.c  | 47 +
 ui/trace-events |  1 -
 12 files changed, 53 insertions(+), 117 deletions(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 1aca564e33..5af7f0cddf 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -847,7 +847,7 @@ static void sunkbd_handle_event(DeviceState *dev, 
QemuConsole *src,
 
 assert(evt->type == INPUT_EVENT_KIND_KEY);
 key = evt->u.key.data;
-qcode = qemu_input_key_value_to_qcode(key->key);
+qcode = key->key;
 trace_escc_sunkbd_event_in(qcode, QKeyCode_lookup[qcode],
key->down);
 
diff --git a/hw/input/adb.c b/hw/input/adb.c
index fcca3a8eb9..992f5bd1c4 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -438,7 +438,7 @@ static void adb_keyboard_event(DeviceState *dev, 
QemuConsole *src,
 KBDState *s = (KBDState *)dev;
 int qcode, keycode;
 
-qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key);
+qcode = evt->u.key.data->key;
 if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) {
 return;
 }
diff --git a/hw/input/hid.c b/hw/input/hid.c
index 0d049ff61c..fdb77b8b2a 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -231,9 +231,9 @@ static void hid_keyboard_event(DeviceState *dev, 
QemuConsole *src,
 int slot;
 InputKeyEvent *key = evt->u.key.data;
 
-count = qemu_input_key_value_to_scancode(key->key,
- key->down,
- scancodes);
+count = qemu_input_qcode_to_scancode(key->key,
+ key->down,
+ scancodes);
 if (hs->n + count > QUEUE_LENGTH) {
 trace_hid_kbd_queue_full();
 return;
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 77906d5f46..14b1d85f6c 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -599,7 +599,7 @@ static void ps2_keyboard_event(DeviceState *dev, 
QemuConsole *src,
 
 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
 assert(evt->type == INPUT_EVENT_KIND_KEY);
-qcode = qemu_input_key_value_to_qcode(key->key);
+qcode = key->key;
 
 if (s->scancode_set == 1) {
 if (qcode == Q_KEY_CODE_PAUSE) {
diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
index 46c038110c..7a04e21b33 100644
--- a/hw/input/virtio-input-hid.c
+++ b/hw/input/virtio-input-hid.c
@@ -200,7 +200,7 @@ static void virtio_input_handle_event(DeviceState *dev, 
QemuConsole *src,
 switch (evt->type) {
 case INPUT_EVENT_KIND_KEY:
 key = evt->u.key.data;
-qcode = qemu_input_key_value_to_qcode(key->key);
+qcode = key->key;
 if (qcode && keymap_qcode[qcode]) {
 event.type  = cpu_to_le16(EV_KEY);
 event.code  = cpu_to_le16(keymap_qcode[qcode]);
diff --git a/include/ui/input.h b/include/ui/input.h
index 576006c370..5577cbcb04 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -38,15 +38,12 @@ void qemu_input_event_send_impl(QemuConsole *src, 
InputEvent *evt);
 void qemu_input_event_sync(void);
 void qemu_input_event_sync_impl(void);
 
-void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
 void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
 void qemu_input_event_send_key_delay(uint32_t delay_ms);
 int qemu_input_key_number_to_qcode(unsigned int nr);
-int qemu_input_key_value_to_number(const KeyValue *value);
-int qemu_input_key_value_to_qcode(const KeyValue *value);
-int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
- int *codes);
+int qemu_input_qcode_to_number(QKeyCode qcode);
+int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down, int *codes);
 int qemu_input_linux_to_qcode(unsigned int lnx);
 
 InputEvent *qemu_input_event_new_btn(InputButton btn, bool down);
diff --git a/qapi-schema.json b/qapi-schema.json
index 802ea53d00..fa6e99ee9c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -5747,7 +5747,7 @@
 # Since: 2.0
 ##
 { 'struct'  : 'InputKeyEvent',
-  'data'  : { 'key' : 'KeyValue',
+  'data'  : { 'key' : 'QKeyCode',
   

[Qemu-devel] [PATCH 04/15] ui: don't export qemu_input_event_new_key

2017-08-10 Thread Daniel P. Berrange
All public code should use qemu_input_event_send_key* functions
instead of creating an event directly.

Signed-off-by: Daniel P. Berrange 
---
 include/ui/input.h | 1 -
 ui/input.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/ui/input.h b/include/ui/input.h
index 1e1cfa0fdf..576006c370 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -38,7 +38,6 @@ void qemu_input_event_send_impl(QemuConsole *src, InputEvent 
*evt);
 void qemu_input_event_sync(void);
 void qemu_input_event_sync_impl(void);
 
-InputEvent *qemu_input_event_new_key(KeyValue *key, bool down);
 void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
 void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
diff --git a/ui/input.c b/ui/input.c
index 64e9103a61..ba85bf01a9 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -374,7 +374,7 @@ void qemu_input_event_sync(void)
 replay_input_sync_event();
 }
 
-InputEvent *qemu_input_event_new_key(KeyValue *key, bool down)
+static InputEvent *qemu_input_event_new_key(KeyValue *key, bool down)
 {
 InputEvent *evt = g_new0(InputEvent, 1);
 evt->u.key.data = g_new0(InputKeyEvent, 1);
-- 
2.13.3




[Qemu-devel] [PATCH 15/15] display: convert XenInput keyboard to keycodemapdb

2017-08-10 Thread Daniel P. Berrange
Replace the scancode2linux table with an automatically
generated table. In doing so, the XenFB keyboard
handler is also converted to the modern InputEvent
framework.

Signed-off-by: Daniel P. Berrange 
---
 hw/display/xenfb.c | 131 -
 1 file changed, 28 insertions(+), 103 deletions(-)

diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index df8b78f6f4..fc3f1198e0 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -28,6 +28,7 @@
 
 #include "hw/hw.h"
 #include "ui/console.h"
+#include "ui/input.h"
 #include "hw/xen/xen_backend.h"
 
 #include 
@@ -52,7 +53,7 @@ struct XenInput {
 struct common c;
 int abs_pointer_wanted; /* Whether guest supports absolute pointer */
 int button_state;   /* Last seen pointer button state */
-int extended;
+QemuInputHandlerState *qkbd;
 QEMUPutMouseEntry *qmouse;
 };
 
@@ -120,78 +121,6 @@ static void common_unbind(struct common *c)
 
 /*  */
 
-#if 0
-/*
- * These two tables are not needed any more, but left in here
- * intentionally as documentation, to show how scancode2linux[]
- * was generated.
- *
- * Tables to map from scancode to Linux input layer keycode.
- * Scancodes are hardware-specific.  These maps assumes a
- * standard AT or PS/2 keyboard which is what QEMU feeds us.
- */
-const unsigned char atkbd_set2_keycode[512] = {
-
- 0, 67, 65, 63, 61, 59, 60, 88,  0, 68, 66, 64, 62, 15, 41,117,
- 0, 56, 42, 93, 29, 16,  2,  0,  0,  0, 44, 31, 30, 17,  3,  0,
- 0, 46, 45, 32, 18,  5,  4, 95,  0, 57, 47, 33, 20, 19,  6,183,
- 0, 49, 48, 35, 34, 21,  7,184,  0,  0, 50, 36, 22,  8,  9,185,
- 0, 51, 37, 23, 24, 11, 10,  0,  0, 52, 53, 38, 39, 25, 12,  0,
- 0, 89, 40,  0, 26, 13,  0,  0, 58, 54, 28, 27,  0, 43,  0, 85,
- 0, 86, 91, 90, 92,  0, 14, 94,  0, 79,124, 75, 71,121,  0,  0,
-82, 83, 80, 76, 77, 72,  1, 69, 87, 78, 81, 74, 55, 73, 70, 99,
-
-  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-217,100,255,  0, 97,165,  0,  0,156,  0,  0,  0,  0,  0,  0,125,
-173,114,  0,113,  0,  0,  0,126,128,  0,  0,140,  0,  0,  0,127,
-159,  0,115,  0,164,  0,  0,116,158,  0,150,166,  0,  0,  0,142,
-157,  0,  0,  0,  0,  0,  0,  0,155,  0, 98,  0,  0,163,  0,  0,
-226,  0,  0,  0,  0,  0,  0,  0,  0,255, 96,  0,  0,  0,143,  0,
-  0,  0,  0,  0,  0,  0,  0,  0,  0,107,  0,105,102,  0,  0,112,
-110,111,108,112,106,103,  0,119,  0,118,109,  0, 99,104,119,  0,
-
-};
-
-const unsigned char atkbd_unxlate_table[128] = {
-
-  0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13,
- 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27,
- 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42,
- 50, 49, 58, 65, 73, 74, 89,124, 17, 41, 88,  5,  6,  4, 12,  3,
- 11,  2, 10,  1,  9,119,126,108,117,125,123,107,115,116,121,105,
-114,122,112,113,127, 96, 97,120,  7, 15, 23, 31, 39, 47, 55, 63,
- 71, 79, 86, 94,  8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87,111,
- 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110
-
-};
-#endif
-
-/*
- * for (i = 0; i < 128; i++) {
- * scancode2linux[i] = atkbd_set2_keycode[atkbd_unxlate_table[i]];
- * scancode2linux[i | 0x80] = atkbd_set2_keycode[atkbd_unxlate_table[i] | 
0x80];
- * }
- */
-static const unsigned char scancode2linux[512] = {
-  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 99,  0, 86, 87, 88,117,  0,  0, 95,183,184,185,
-  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
- 93,  0,  0, 89,  0,  0, 85, 91, 90, 92,  0, 94,  0,124,121,  0,
-
-  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-165,  0,  0,  0,  0,  0,  0,  0,  0,163,  0,  0, 96, 97,  0,  0,
-113,140,164,  0,166,  0,  0,  0,  0,  0,255,  0,  0,  0,114,  0,
-115,  0,150,  0,  0, 98,255, 99,100,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  0,119,119,102,103,104,  0,105,112,106,118,107,
-108,109,110,111,  0,  0,  0,  0,  0,  0,  0,125,126,127,116,142,
-  0,  0,  0,143,  0,217,156,173,128,159,158,157,155,226,  0,112,
-  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-};
-
 /* Send an event to the keyboard frontend driver */
 static int xenfb_kbd_event(struct XenInput *xenfb,
   union xenkbd_in_event *event)
@@ -260,37 +189,19 @@ static int xenfb_send_position(struct XenInput *xenfb,
 return xenfb_kbd_event(xenfb, );
 }
 
-/*
- * Send a key event from the client to the guest OS
- * QEMU gives us a raw scancode from an AT / PS/2 

[Qemu-devel] [PATCH 14/15] ui: remove qemu_input_linux_to_qcode method

2017-08-10 Thread Daniel P. Berrange
The qemu_input_linux_to_qcode method is only used in one place and
no new code should require it, so inline it at the only caller.

Signed-off-by: Daniel P. Berrange 
---
 include/ui/input.h | 1 -
 ui/input-keymap.c  | 8 
 ui/input-linux.c   | 4 ++--
 3 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/include/ui/input.h b/include/ui/input.h
index b3827b6082..92e54c25e2 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -43,7 +43,6 @@ void qemu_input_event_send_key_qcode(QemuConsole *src, 
QKeyCode q, bool down);
 void qemu_input_event_send_key_delay(uint32_t delay_ms);
 int qemu_input_key_number_to_qcode(unsigned int nr);
 int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down, int *codes);
-int qemu_input_linux_to_qcode(unsigned int lnx);
 
 InputEvent *qemu_input_event_new_btn(InputButton btn, bool down);
 void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
diff --git a/ui/input-keymap.c b/ui/input-keymap.c
index 71c6a79e66..bbd818ef97 100644
--- a/ui/input-keymap.c
+++ b/ui/input-keymap.c
@@ -24,14 +24,6 @@
 #include "ui/input-keymap-xorgxquartz2qcode.c"
 #include "ui/input-keymap-xorgxwin2qcode.c"
 
-int qemu_input_linux_to_qcode(unsigned int lnx)
-{
-if (lnx >= qemu_input_map_linux2qcode_len) {
-return 0;
-}
-return qemu_input_map_linux2qcode[lnx];
-}
-
 int qemu_input_key_number_to_qcode(unsigned int nr)
 {
 if (nr >= qemu_input_map_qnum2qcode_len) {
diff --git a/ui/input-linux.c b/ui/input-linux.c
index 9720333b2c..f5eb589b1d 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -128,8 +128,8 @@ static void input_linux_handle_keyboard(InputLinux *il,
 }
 
 /* send event to guest when grab is active */
-if (il->grab_active) {
-int qcode = qemu_input_linux_to_qcode(event->code);
+if (il->grab_active && event->code < qemu_input_map_linux2qcode_len) {
+int qcode = qemu_input_map_linux2qcode[event->code];
 qemu_input_event_send_key_qcode(NULL, qcode, event->value);
 }
 
-- 
2.13.3




Re: [Qemu-devel] [PATCH v4 4/7] block: convert ThrottleGroup to object with QOM

2017-08-10 Thread Alberto Garcia
On Wed 09 Aug 2017 12:07:31 PM CEST, Manos Pitsidianakis wrote:
> +/* unfix buckets to check validity */
> +throttle_get_config(>ts, cfg);
> +if (!throttle_is_valid(cfg, errp)) {
> +return;
> +}
> +/* fix buckets again */
> +throttle_config(>ts, tg->clock_type, cfg);

Ugh, this whole fix/unfix buckets should be transparent to outside users
of throttle.c.

You can leave this here for now but I'll think of a way to eliminate the
need to do this.

Berto



Re: [Qemu-devel] [PATCH v6 02/19] migration: Teach it about G_SOURCE_REMOVE

2017-08-10 Thread Daniel P. Berrange
On Tue, Aug 08, 2017 at 06:26:12PM +0200, Juan Quintela wrote:
> As this is defined on glib 2.32, add compatibility macros for older glibs.
> 
> Signed-off-by: Juan Quintela 
> ---
>  include/glib-compat.h | 2 ++
>  migration/exec.c  | 2 +-
>  migration/fd.c| 2 +-
>  migration/socket.c| 2 +-
>  4 files changed, 5 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrange 


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 v6 05/19] qio: Create new qio_channel_{readv, writev}_all

2017-08-10 Thread Daniel P. Berrange
On Tue, Aug 08, 2017 at 06:26:15PM +0200, Juan Quintela wrote:
> The functions waits until it is able to write the full iov.
> 
> Signed-off-by: Juan Quintela 
> 
> --
> 
> Add tests.
> 
> fix reader to check for len == 0.
> ---
>  include/io/channel.h   | 46 +
>  io/channel.c   | 77 
> ++
>  migration/qemu-file-channel.c  | 29 +---
>  tests/io-channel-helpers.c | 55 ++
>  tests/io-channel-helpers.h |  4 +++
>  tests/test-io-channel-buffer.c | 55 --
>  6 files changed, 235 insertions(+), 31 deletions(-)
> 
> diff --git a/include/io/channel.h b/include/io/channel.h
> index db9bb02..bfc97e2 100644
> --- a/include/io/channel.h
> +++ b/include/io/channel.h
> @@ -269,6 +269,52 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
>  Error **errp);
>  
>  /**
> + * qio_channel_readv_all:
> + * @ioc: the channel object
> + * @iov: the array of memory regions to read data into
> + * @niov: the length of the @iov array
> + * @errp: pointer to a NULL-initialized error object
> + *
> + * Read data from the IO channel, storing it in the
> + * memory regions referenced by @iov. Each element
> + * in the @iov will be fully populated with data
> + * before the next one is used. The @niov parameter
> + * specifies the total number of elements in @iov.
> + *
> + * Returns: the number of bytes read, or -1 on error,
> + * or QIO_CHANNEL_ERR_BLOCK if no data is available
> + * and the channel is non-blocking

This is incorrect - it'll never return QIO_CHANNEL_ERR_BLOCK.
If it seems that, it'll go into a wait until data arrives.

> + */
> +ssize_t qio_channel_readv_all(QIOChannel *ioc,
> +  const struct iovec *iov,
> +  size_t niov,
> +  Error **errp);
> +
> +
> +/**
> + * qio_channel_writev_all:
> + * @ioc: the channel object
> + * @iov: the array of memory regions to write data from
> + * @niov: the length of the @iov array
> + * @errp: pointer to a NULL-initialized error object
> + *
> + * Write data to the IO channel, reading it from the
> + * memory regions referenced by @iov. Each element
> + * in the @iov will be fully sent, before the next
> + * one is used. The @niov parameter specifies the
> + * total number of elements in @iov.
> + *
> + * It is required for all @iov data to be fully
> + * sent.
> + *
> + * Returns: the number of bytes sent, or -1 on error,
> + */
> +ssize_t qio_channel_writev_all(QIOChannel *ioc,
> +   const struct iovec *iov,
> +   size_t niov,
> +   Error **erp);
> +
> +/**
>   * qio_channel_readv:
>   * @ioc: the channel object
>   * @iov: the array of memory regions to read data into
> diff --git a/io/channel.c b/io/channel.c
> index 1cfb8b3..0b521f9 100644
> --- a/io/channel.c
> +++ b/io/channel.c
> @@ -22,6 +22,7 @@
>  #include "io/channel.h"
>  #include "qapi/error.h"
>  #include "qemu/main-loop.h"
> +#include "qemu/iov.h"
>  
>  bool qio_channel_has_feature(QIOChannel *ioc,
>   QIOChannelFeature feature)
> @@ -85,6 +86,82 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
>  }
>  
>  
> +
> +ssize_t qio_channel_readv_all(QIOChannel *ioc,
> +  const struct iovec *iov,
> +  size_t niov,
> +  Error **errp)
> +{
> +ssize_t done = 0;
> +struct iovec *local_iov = g_new(struct iovec, niov);
> +struct iovec *local_iov_head = local_iov;
> +unsigned int nlocal_iov = niov;

Should be  size_t

> +
> +nlocal_iov = iov_copy(local_iov, nlocal_iov,
> +  iov, niov,
> +  0, iov_size(iov, niov));
> +
> +while (nlocal_iov > 0) {
> +ssize_t len;
> +len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp);
> +if (len == QIO_CHANNEL_ERR_BLOCK) {
> +qio_channel_wait(ioc, G_IO_OUT);


This should be waiting for G_IO_IN


> +continue;
> +} else if (len < 0) {
> +error_setg_errno(errp, EIO,
> + "Channel was not able to read full iov");
> +done = -1;
> +goto cleanup;
> +} else if (len == 0) {
> +goto cleanup;
> +}
> +
> +iov_discard_front(_iov, _iov, len);
> +done += len;
> +}
> +
> + cleanup:
> +g_free(local_iov_head);
> +return done;
> +}
> +
> +ssize_t qio_channel_writev_all(QIOChannel *ioc,
> +   const struct iovec *iov,
> +   size_t niov,
> +   Error **errp)
> +{
> +ssize_t done = 0;
> +struct iovec *local_iov = g_new(struct iovec, niov);
> +struct iovec *local_iov_head = local_iov;
> +  

[Qemu-devel] [PATCH 11/15] ui: convert the SDL2 frontend to keycodemapdb

2017-08-10 Thread Daniel P. Berrange
The SDL2 scancodes are conveniently identical to the USB
scancodes. Replace the sdl2_scancode_to_qcode table with
an automatically generated table.

Missing entries in sdl2_scancode_to_qcode now fixed:

  - 0x32 -> Q_KEY_CODE_BACKSLASH
  - 0x66 -> Q_KEY_CODE_POWER
  - 0x67 -> Q_KEY_CODE_KP_EQUALS
  - 0x74 -> Q_KEY_CODE_OPEN
  - 0x77 -> Q_KEY_CODE_FRONT
  - 0x7f -> Q_KEY_CODE_AUDIOMUTE
  - 0x80 -> Q_KEY_CODE_VOLUMEUP
  - 0x81 -> Q_KEY_CODE_VOLUMEDOWN
  - 0x85 -> Q_KEY_CODE_KP_COMMA
  - 0x87 -> Q_KEY_CODE_RO
  - 0x89 -> Q_KEY_CODE_YEN
  - 0x8a -> Q_KEY_CODE_HENKAN
  - 0x93 -> Q_KEY_CODE_HIRAGANA
  - 0xe8 -> Q_KEY_CODE_AUDIOPLAY
  - 0xe9 -> Q_KEY_CODE_AUDIOSTOP
  - 0xea -> Q_KEY_CODE_AUDIOPREV
  - 0xeb -> Q_KEY_CODE_AUDIONEXT
  - 0xed -> Q_KEY_CODE_VOLUMEUP
  - 0xee -> Q_KEY_CODE_VOLUMEDOWN
  - 0xef -> Q_KEY_CODE_AUDIOMUTE
  - 0xf1 -> Q_KEY_CODE_AC_BACK
  - 0xf2 -> Q_KEY_CODE_AC_FORWARD
  - 0xf3 -> Q_KEY_CODE_STOP
  - 0xf4 -> Q_KEY_CODE_FIND
  - 0xf8 -> Q_KEY_CODE_SLEEP
  - 0xfa -> Q_KEY_CODE_AC_REFRESH
  - 0xfb -> Q_KEY_CODE_CALCULATOR

And some mistakes corrected:

  - 0x65 -> Q_KEY_CODE_COMPOSE, not duplicating Q_KEY_CODE_MENU

Signed-off-by: Daniel P. Berrange 
---
 include/ui/input.h |   3 +
 ui/Makefile.objs   |   1 +
 ui/input-keymap.c  |   1 +
 ui/sdl2-input.c|  14 ++-
 ui/sdl2-keymap.h   | 267 -
 5 files changed, 14 insertions(+), 272 deletions(-)
 delete mode 100644 ui/sdl2-keymap.h

diff --git a/include/ui/input.h b/include/ui/input.h
index 595e596ef3..11bf94aacf 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -95,4 +95,7 @@ extern const guint16 qemu_input_map_qcode2sun[];
 extern const guint qemu_input_map_qnum2qcode_len;
 extern const guint16 qemu_input_map_qnum2qcode[];
 
+extern const guint qemu_input_map_usb2qcode_len;
+extern const guint16 qemu_input_map_usb2qcode[];
+
 #endif /* INPUT_H */
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index ce9c4380ae..cd2bf1e790 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -64,6 +64,7 @@ KEYCODEMAP_FILES = \
 ui/input-keymap-qcode2qnum.c \
 ui/input-keymap-qcode2sun.c \
 ui/input-keymap-qnum2qcode.c \
+ui/input-keymap-usb2qcode.c \
 $(NULL)
 
 GENERATED_FILES += $(KEYCODEMAP_FILES)
diff --git a/ui/input-keymap.c b/ui/input-keymap.c
index e575348cb2..c7a9c08bdb 100644
--- a/ui/input-keymap.c
+++ b/ui/input-keymap.c
@@ -15,6 +15,7 @@
 #include "ui/input-keymap-qcode2qnum.c"
 #include "ui/input-keymap-qcode2sun.c"
 #include "ui/input-keymap-qnum2qcode.c"
+#include "ui/input-keymap-usb2qcode.c"
 
 int qemu_input_linux_to_qcode(unsigned int lnx)
 {
diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
index 6e315ae800..f0a99ffd73 100644
--- a/ui/sdl2-input.c
+++ b/ui/sdl2-input.c
@@ -30,8 +30,6 @@
 #include "ui/sdl2.h"
 #include "sysemu/sysemu.h"
 
-#include "sdl2-keymap.h"
-
 static uint8_t modifiers_state[SDL_NUM_SCANCODES];
 
 void sdl2_reset_keys(struct sdl2_console *scon)
@@ -39,9 +37,9 @@ void sdl2_reset_keys(struct sdl2_console *scon)
 QemuConsole *con = scon ? scon->dcl.con : NULL;
 int i;
 
-for (i = 0; i < SDL_NUM_SCANCODES; i++) {
+for (i = 0; i < SDL_NUM_SCANCODES && i < qemu_input_map_usb2qcode_len ; 
i++) {
 if (modifiers_state[i]) {
-int qcode = sdl2_scancode_to_qcode[i];
+int qcode = qemu_input_map_usb2qcode[i];
 qemu_input_event_send_key_qcode(con, qcode, false);
 modifiers_state[i] = 0;
 }
@@ -51,9 +49,15 @@ void sdl2_reset_keys(struct sdl2_console *scon)
 void sdl2_process_key(struct sdl2_console *scon,
   SDL_KeyboardEvent *ev)
 {
-int qcode = sdl2_scancode_to_qcode[ev->keysym.scancode];
+int qcode;
 QemuConsole *con = scon ? scon->dcl.con : NULL;
 
+if (ev->keysym.scancode >= qemu_input_map_usb2qcode_len) {
+return;
+}
+
+qcode = qemu_input_map_usb2qcode[ev->keysym.scancode];
+
 if (!qemu_console_is_graphic(con)) {
 if (ev->type == SDL_KEYDOWN) {
 switch (ev->keysym.scancode) {
diff --git a/ui/sdl2-keymap.h b/ui/sdl2-keymap.h
deleted file mode 100644
index cbedaa477d..00
--- a/ui/sdl2-keymap.h
+++ /dev/null
@@ -1,267 +0,0 @@
-
-/* map SDL2 scancodes to QKeyCode */
-
-static const int sdl2_scancode_to_qcode[SDL_NUM_SCANCODES] = {
-[SDL_SCANCODE_A] = Q_KEY_CODE_A,
-[SDL_SCANCODE_B] = Q_KEY_CODE_B,
-[SDL_SCANCODE_C] = Q_KEY_CODE_C,
-[SDL_SCANCODE_D] = Q_KEY_CODE_D,
-[SDL_SCANCODE_E] = Q_KEY_CODE_E,
-[SDL_SCANCODE_F] = Q_KEY_CODE_F,
-[SDL_SCANCODE_G] = Q_KEY_CODE_G,
-[SDL_SCANCODE_H] = Q_KEY_CODE_H,
-[SDL_SCANCODE_I] = Q_KEY_CODE_I,
-[SDL_SCANCODE_J] = Q_KEY_CODE_J,
-[SDL_SCANCODE_K] = 

[Qemu-devel] [PATCH 01/15] ui: add keycodemapdb repository as a GIT submodule

2017-08-10 Thread Daniel P. Berrange
The https://gitlab.com/keycodemap/keycodemapdb/ repo contains a
data file mapping between all the different scancode/keycode/keysym
sets that are known, and a tool to auto-generate lookup tables for
different combinations.

It is used by GTK-VNC, SPICE-GTK and libvirt for mapping keys.
Using it in QEMU will let us replace many hand written lookup
tables with auto-generated tables from a master data source,
reducing bugs. Adding new QKeyCodes will now only require the
master table to be updated, all ~20 other tables will be
automatically updated to follow.

Signed-off-by: Daniel P. Berrange 
---
 .gitignore   |  2 ++
 .gitmodules  |  3 +++
 ui/Makefile.objs | 18 ++
 ui/keycodemapdb  |  1 +
 4 files changed, 24 insertions(+)
 create mode 16 ui/keycodemapdb

diff --git a/.gitignore b/.gitignore
index cf65316863..6e5a1202c8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,8 @@
 /trace/generated-tcg-tracers.h
 /ui/shader/texture-blit-frag.h
 /ui/shader/texture-blit-vert.h
+/ui/keycodemap_*.c
+/ui/input-keymap-*.c
 *-timestamp
 /*-softmmu
 /*-darwin-user
diff --git a/.gitmodules b/.gitmodules
index 5b0c212622..369989f19e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -37,3 +37,6 @@
 [submodule "roms/QemuMacDrivers"]
path = roms/QemuMacDrivers
url = git://git.qemu.org/QemuMacDrivers.git
+[submodule "ui/keycodemapdb"]
+   path = ui/keycodemapdb
+   url = https://gitlab.com/keycodemap/keycodemapdb.git
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index 3369451285..d94d1ca183 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -49,3 +49,21 @@ gtk-egl.o-libs += $(OPENGL_LIBS)
 shader.o-libs += $(OPENGL_LIBS)
 console-gl.o-libs += $(OPENGL_LIBS)
 egl-helpers.o-libs += $(OPENGL_LIBS)
+
+KEYCODEMAP_GEN = ui/keycodemapdb/tools/keymap-gen
+KEYCODEMAP_CSV = ui/keycodemapdb/data/keymaps.csv
+
+KEYCODEMAP_FILES = \
+$(NULL)
+
+GENERATED_FILES += $(KEYCODEMAP_FILES)
+
+ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) ui/Makefile.objs
+   $(call quiet-command,\
+   $(PYTHON) $(KEYCODEMAP_GEN) \
+ --lang glib2 \
+ --varname qemu_input_map_$$(echo $@ | sed -e 
"s,^ui/input-keymap-,," -e "s,\.c$$,,") \
+ code-map $(KEYCODEMAP_CSV) \
+ $$(echo $@ | sed -E -e 
"s,^ui/input-keymap-([a-zA-Z0-9]+)2([a-zA-Z0-9]+)\.c$$,\1,") \
+ $$(echo $@ | sed -E -e 
"s,^ui/input-keymap-([a-zA-Z0-9]+)2([a-zA-Z0-9]+)\.c$$,\2,") \
+   > $@ || rm $@, "GEN", "$@")
diff --git a/ui/keycodemapdb b/ui/keycodemapdb
new file mode 16
index 00..aed87bb2aa
--- /dev/null
+++ b/ui/keycodemapdb
@@ -0,0 +1 @@
+Subproject commit aed87bb2aa6ed83b49574eb982e3bdd4c36acf17
-- 
2.13.3




[Qemu-devel] [PATCH 06/15] input: convert virtio-input-hid device to keycodemapdb

2017-08-10 Thread Daniel P. Berrange
Replace the keymap_qcode table with automatically generated
tables.

Missing entries in keymap_qcode now fixed:

  Q_KEY_CODE_ASTERISK -> KEY_KPASTERISK
  Q_KEY_CODE_KP_MULTIPLY -> KEY_KPASTERISK
  Q_KEY_CODE_STOP -> KEY_STOP
  Q_KEY_CODE_AGAIN -> KEY_AGAIN
  Q_KEY_CODE_PROPS -> KEY_PROPS
  Q_KEY_CODE_UNDO -> KEY_UNDO
  Q_KEY_CODE_FRONT -> KEY_FRONT
  Q_KEY_CODE_COPY -> KEY_COPY
  Q_KEY_CODE_OPEN -> KEY_OPEN
  Q_KEY_CODE_PASTE -> KEY_PASTE
  Q_KEY_CODE_FIND -> KEY_FIND
  Q_KEY_CODE_CUT -> KEY_CUT
  Q_KEY_CODE_LF -> KEY_LINEFEED
  Q_KEY_CODE_HELP -> KEY_HELP
  Q_KEY_CODE_COMPOSE -> KEY_COMPOSE
  Q_KEY_CODE_RO -> KEY_RO
  Q_KEY_CODE_HIRAGANA -> KEY_HIRAGANA
  Q_KEY_CODE_HENKAN -> KEY_HENKAN
  Q_KEY_CODE_YEN -> KEY_YEN
  Q_KEY_CODE_KP_COMMA -> KEY_KPCOMMA
  Q_KEY_CODE_KP_EQUALS -> KEY_KPEQUAL
  Q_KEY_CODE_POWER -> KEY_POWER
  Q_KEY_CODE_SLEEP -> KEY_SLEEP
  Q_KEY_CODE_WAKE -> KEY_WAKEUP
  Q_KEY_CODE_AUDIONEXT -> KEY_NEXTSONG
  Q_KEY_CODE_AUDIOPREV -> KEY_PREVIOUSSONG
  Q_KEY_CODE_AUDIOSTOP -> KEY_STOPCD
  Q_KEY_CODE_AUDIOPLAY -> KEY_PLAYPAUSE
  Q_KEY_CODE_AUDIOMUTE -> KEY_MUTE
  Q_KEY_CODE_VOLUMEUP -> KEY_VOLUMEUP
  Q_KEY_CODE_VOLUMEDOWN -> KEY_VOLUMEDOWN
  Q_KEY_CODE_MEDIASELECT -> KEY_MEDIA
  Q_KEY_CODE_MAIL -> KEY_MAIL
  Q_KEY_CODE_CALCULATOR -> KEY_CALC
  Q_KEY_CODE_COMPUTER -> KEY_COMPUTER
  Q_KEY_CODE_AC_HOME -> KEY_HOMEPAGE
  Q_KEY_CODE_AC_BACK -> KEY_BACK
  Q_KEY_CODE_AC_FORWARD -> KEY_FORWARD
  Q_KEY_CODE_AC_REFRESH -> KEY_REFRESH
  Q_KEY_CODE_AC_BOOKMARKS -> KEY_BOOKMARKS

Signed-off-by: Daniel P. Berrange 
---
 hw/input/virtio-input-hid.c | 136 +++-
 include/ui/input.h  |   3 +
 ui/Makefile.objs|   1 +
 ui/input-keymap.c   |   1 +
 4 files changed, 14 insertions(+), 127 deletions(-)

diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
index 7a04e21b33..47efc6f35b 100644
--- a/hw/input/virtio-input-hid.c
+++ b/hw/input/virtio-input-hid.c
@@ -22,126 +22,7 @@
 
 /* - */
 
-static const unsigned int keymap_qcode[Q_KEY_CODE__MAX] = {
-[Q_KEY_CODE_ESC] = KEY_ESC,
-[Q_KEY_CODE_1]   = KEY_1,
-[Q_KEY_CODE_2]   = KEY_2,
-[Q_KEY_CODE_3]   = KEY_3,
-[Q_KEY_CODE_4]   = KEY_4,
-[Q_KEY_CODE_5]   = KEY_5,
-[Q_KEY_CODE_6]   = KEY_6,
-[Q_KEY_CODE_7]   = KEY_7,
-[Q_KEY_CODE_8]   = KEY_8,
-[Q_KEY_CODE_9]   = KEY_9,
-[Q_KEY_CODE_0]   = KEY_0,
-[Q_KEY_CODE_MINUS]   = KEY_MINUS,
-[Q_KEY_CODE_EQUAL]   = KEY_EQUAL,
-[Q_KEY_CODE_BACKSPACE]   = KEY_BACKSPACE,
-
-[Q_KEY_CODE_TAB] = KEY_TAB,
-[Q_KEY_CODE_Q]   = KEY_Q,
-[Q_KEY_CODE_W]   = KEY_W,
-[Q_KEY_CODE_E]   = KEY_E,
-[Q_KEY_CODE_R]   = KEY_R,
-[Q_KEY_CODE_T]   = KEY_T,
-[Q_KEY_CODE_Y]   = KEY_Y,
-[Q_KEY_CODE_U]   = KEY_U,
-[Q_KEY_CODE_I]   = KEY_I,
-[Q_KEY_CODE_O]   = KEY_O,
-[Q_KEY_CODE_P]   = KEY_P,
-[Q_KEY_CODE_BRACKET_LEFT]= KEY_LEFTBRACE,
-[Q_KEY_CODE_BRACKET_RIGHT]   = KEY_RIGHTBRACE,
-[Q_KEY_CODE_RET] = KEY_ENTER,
-
-[Q_KEY_CODE_CTRL]= KEY_LEFTCTRL,
-[Q_KEY_CODE_A]   = KEY_A,
-[Q_KEY_CODE_S]   = KEY_S,
-[Q_KEY_CODE_D]   = KEY_D,
-[Q_KEY_CODE_F]   = KEY_F,
-[Q_KEY_CODE_G]   = KEY_G,
-[Q_KEY_CODE_H]   = KEY_H,
-[Q_KEY_CODE_J]   = KEY_J,
-[Q_KEY_CODE_K]   = KEY_K,
-[Q_KEY_CODE_L]   = KEY_L,
-[Q_KEY_CODE_SEMICOLON]   = KEY_SEMICOLON,
-[Q_KEY_CODE_APOSTROPHE]  = KEY_APOSTROPHE,
-[Q_KEY_CODE_GRAVE_ACCENT]= KEY_GRAVE,
-
-[Q_KEY_CODE_SHIFT]   = KEY_LEFTSHIFT,
-[Q_KEY_CODE_BACKSLASH]   = KEY_BACKSLASH,
-[Q_KEY_CODE_LESS]= KEY_102ND,
-[Q_KEY_CODE_Z]   = KEY_Z,
-[Q_KEY_CODE_X]   = KEY_X,
-[Q_KEY_CODE_C]   = KEY_C,
-[Q_KEY_CODE_V]   = KEY_V,
-[Q_KEY_CODE_B]   = KEY_B,
-[Q_KEY_CODE_N]   = KEY_N,
-[Q_KEY_CODE_M]   = KEY_M,
-[Q_KEY_CODE_COMMA]   = KEY_COMMA,
-[Q_KEY_CODE_DOT] = KEY_DOT,
-[Q_KEY_CODE_SLASH]   = KEY_SLASH,
-[Q_KEY_CODE_SHIFT_R] = KEY_RIGHTSHIFT,
-
-[Q_KEY_CODE_ALT] = KEY_LEFTALT,
-[Q_KEY_CODE_SPC] = KEY_SPACE,
-[Q_KEY_CODE_CAPS_LOCK]   = 

[Qemu-devel] [PATCH 3/8] blockdev: convert internal NBD server to QIONetListener

2017-08-10 Thread Daniel P. Berrange
Instead of creating a QIOChannelSocket directly for the NBD
server socket, use a QIONetListener. This provides the ability
to listen on multiple sockets at the same time, so enables
full support for IPv4/IPv6 dual stack.

Signed-off-by: Daniel P. Berrange 
---
 blockdev-nbd.c | 50 --
 1 file changed, 16 insertions(+), 34 deletions(-)

diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 28f551a7b0..9e3c22109c 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -18,10 +18,10 @@
 #include "qmp-commands.h"
 #include "block/nbd.h"
 #include "io/channel-socket.h"
+#include "io/net-listener.h"
 
 typedef struct NBDServerData {
-QIOChannelSocket *listen_ioc;
-int watch;
+QIONetListener *listener;
 QCryptoTLSCreds *tlscreds;
 } NBDServerData;
 
@@ -32,27 +32,13 @@ static void nbd_blockdev_client_closed(NBDClient *client, 
bool ignored)
 nbd_client_put(client);
 }
 
-static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition,
-   gpointer opaque)
+static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
+   gpointer opaque)
 {
-QIOChannelSocket *cioc;
-
-if (!nbd_server) {
-return FALSE;
-}
-
-cioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
- NULL);
-if (!cioc) {
-return TRUE;
-}
-
 qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
 nbd_client_new(NULL, cioc,
nbd_server->tlscreds, NULL,
nbd_blockdev_client_closed);
-object_unref(OBJECT(cioc));
-return TRUE;
 }
 
 
@@ -62,10 +48,8 @@ static void nbd_server_free(NBDServerData *server)
 return;
 }
 
-if (server->watch != -1) {
-g_source_remove(server->watch);
-}
-object_unref(OBJECT(server->listen_ioc));
+qio_net_listener_disconnect(server->listener);
+object_unref(OBJECT(server->listener));
 if (server->tlscreds) {
 object_unref(OBJECT(server->tlscreds));
 }
@@ -112,12 +96,12 @@ void nbd_server_start(SocketAddress *addr, const char 
*tls_creds,
 }
 
 nbd_server = g_new0(NBDServerData, 1);
-nbd_server->watch = -1;
-nbd_server->listen_ioc = qio_channel_socket_new();
-qio_channel_set_name(QIO_CHANNEL(nbd_server->listen_ioc),
- "nbd-listener");
-if (qio_channel_socket_listen_sync(
-nbd_server->listen_ioc, addr, errp) < 0) {
+nbd_server->listener = qio_net_listener_new();
+
+qio_net_listener_set_name(nbd_server->listener,
+  "nbd-listener");
+
+if (qio_net_listener_open_sync(nbd_server->listener, addr, errp) < 0) {
 goto error;
 }
 
@@ -134,12 +118,10 @@ void nbd_server_start(SocketAddress *addr, const char 
*tls_creds,
 }
 }
 
-nbd_server->watch = qio_channel_add_watch(
-QIO_CHANNEL(nbd_server->listen_ioc),
-G_IO_IN,
-nbd_accept,
-NULL,
-NULL);
+qio_net_listener_set_client_func(nbd_server->listener,
+ nbd_accept,
+ NULL,
+ NULL);
 
 return;
 
-- 
2.13.3




Re: [Qemu-devel] [PATCH v4 5/7] block: add throttle block filter driver

2017-08-10 Thread Alberto Garcia
On Wed 09 Aug 2017 12:07:32 PM CEST, Manos Pitsidianakis wrote:
> +/* Extract ThrottleConfig options. Assumes cfg is initialized and will be
> + * checked for validity.
> + *
> + * Returns -1 and sets errp if a burst_length value is over UINT_MAX.
> + */
> +static int throttle_extract_options(QemuOpts *opts, ThrottleConfig *cfg,
> +Error **errp)
> +{
> +#define IF_OPT_SET(rvalue, opt_name) \
> +if (qemu_opt_get(opts, THROTTLE_OPT_PREFIX opt_name)) { \
> +rvalue = qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX opt_name, 0); 
> }
> +
> +IF_OPT_SET(cfg->buckets[THROTTLE_BPS_TOTAL].avg, QEMU_OPT_BPS_TOTAL);
> +IF_OPT_SET(cfg->buckets[THROTTLE_BPS_READ].avg, QEMU_OPT_BPS_READ);
> +IF_OPT_SET(cfg->buckets[THROTTLE_BPS_WRITE].avg, QEMU_OPT_BPS_WRITE);
> +IF_OPT_SET(cfg->buckets[THROTTLE_OPS_TOTAL].avg, QEMU_OPT_IOPS_TOTAL);
> +IF_OPT_SET(cfg->buckets[THROTTLE_OPS_READ].avg, QEMU_OPT_IOPS_READ);
> +IF_OPT_SET(cfg->buckets[THROTTLE_OPS_WRITE].avg, QEMU_OPT_IOPS_WRITE);
> +IF_OPT_SET(cfg->buckets[THROTTLE_BPS_TOTAL].max, QEMU_OPT_BPS_TOTAL_MAX);
  [...]

This is all the code that I was saying that we'd save if we don't allow
setting limits here.

> +static int throttle_configure_tgm(BlockDriverState *bs,
> +  ThrottleGroupMember *tgm,
> +  QDict *options, Error **errp)
> +{
> +int ret;
> +ThrottleConfig cfg;
> +const char *group_name = NULL;

No need to set it to NULL here.

> +Error *local_err = NULL;
> +QemuOpts *opts = qemu_opts_create(_opts, NULL, 0, _abort);
> +
> +qemu_opts_absorb_qdict(opts, options, _err);
> +if (local_err) {
> +error_propagate(errp, local_err);
> +goto err;
> +}
> +
> +/* If group_name is NULL, an anonymous group will be created */
> +group_name = qemu_opt_get(opts, QEMU_OPT_THROTTLE_GROUP_NAME);
> +
> +/* Register membership to group with name group_name */
> +throttle_group_register_tgm(tgm, group_name, bdrv_get_aio_context(bs));
> +
> +/* Copy previous configuration */
> +throttle_group_get_config(tgm, );
> +
> +/* Change limits if user has specified them */
> +if (throttle_extract_options(opts, , errp) ||
> +!throttle_is_valid(, errp)) {
> +throttle_group_unregister_tgm(tgm);
> +goto err;
> +}
> +/* Update group configuration */
> +throttle_group_config(tgm, );

We'd also spare this, and this function would remain much simpler.

> +
> +ret = 0;
> +goto fin;
> +
> +err:
> +ret = -EINVAL;
> +fin:
> +qemu_opts_del(opts);
> +return ret;
> +}

If you set ret = -EINVAL before calling goto err you can simplify this
part as well, but feel free to ignore this suggestion.

> +static int throttle_reopen_prepare(BDRVReopenState *reopen_state,
> +   BlockReopenQueue *queue, Error **errp)
> +{
> +ThrottleGroupMember *tgm = NULL;
> +
> +assert(reopen_state != NULL);
> +assert(reopen_state->bs != NULL);
> +
> +reopen_state->opaque = g_new0(ThrottleGroupMember, 1);
> +tgm = reopen_state->opaque;
> +
> +return throttle_configure_tgm(reopen_state->bs, tgm, 
> reopen_state->options,
> +errp);
> +}

I would rename 'reopen_state' as 'state' for consistency with the other
two functions.

> +static void throttle_reopen_commit(BDRVReopenState *state)
> +{
> +ThrottleGroupMember *tgm = state->bs->opaque;
> +
> +throttle_group_unregister_tgm(tgm);
> +g_free(state->bs->opaque);
> +state->bs->opaque = state->opaque;
> +state->opaque = NULL;
> +}

I also find the mixing of state->bs->opaque and tgm a bit confusing.
Here's a suggestion, but feel free to ignore it:

ThrottleGroupMember *old_tgm = state->bs->opaque;
ThrottleGroupMember *new_tgm = state->opaque;

throttle_group_unregister_tgm(old_tgm);
g_free(old_tgm);

state->bs->opaque = new_tgm;
state->opaque = NULL;

> +static void throttle_reopen_abort(BDRVReopenState *state)
> +{
> +ThrottleGroupMember *tgm = state->opaque;
> +
> +throttle_group_unregister_tgm(tgm);
> +g_free(state->opaque);
> +state->opaque = NULL;
> +}

Similar problem here (this one is simpler though).

Apart from the general question of whether we're parsing the limits in
this driver, the rest are just comments about the style. Otherwise the
code looks good, thanks!

Berto



Re: [Qemu-devel] [PATCH] error: Improve documentation of error_append_hint()

2017-08-10 Thread Eric Blake
On 08/10/2017 05:06 AM, Markus Armbruster wrote:
> Suggested-by: Halil Pasic 
> Signed-off-by: Markus Armbruster 
> ---
>  include/qapi/error.h | 8 
>  1 file changed, 8 insertions(+)

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 v6 03/19] migration: Add comments to channel functions

2017-08-10 Thread Daniel P. Berrange
On Tue, Aug 08, 2017 at 06:26:13PM +0200, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  migration/channel.c | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/migration/channel.c b/migration/channel.c
> index edceebd..79b0f8b 100644
> --- a/migration/channel.c
> +++ b/migration/channel.c
> @@ -19,6 +19,14 @@
>  #include "qapi/error.h"
>  #include "io/channel-tls.h"
>  
> +/**
> + * @migration_channel_process_incoming - Create new incoming migration 
> channel
> + *
> + * Notice that TLS is special.  For it we listen in a listener socket,
> + * and then create a new client socket from the TLS library.
> + *
> + * @ioc: Channel to wich we are connecting
> + */

s/wich/which/

>  void migration_channel_process_incoming(QIOChannel *ioc)
>  {
>  MigrationState *s = migrate_get_current();
> @@ -41,6 +49,13 @@ void migration_channel_process_incoming(QIOChannel *ioc)
>  }
>  
>  
> +/**
> + * @migration_channel_connect - Create new outgoing migration channel
> + *
> + * @s: Current migration state
> + * @ioc: Channel to wich we are connecting

s/wich/which/

> + * @hostname: Where we want to connect
> + */
>  void migration_channel_connect(MigrationState *s,
> QIOChannel *ioc,
> const char *hostname)
> -- 
> 2.9.4

With those typos fixed, you can add

Reviewed-by: Daniel P. Berrange 

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



[Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support

2017-08-10 Thread Daniel P. Berrange
Currently all the network listeners in QEMU, except the VNC server,
are restricted to listening on a single socket. This makes it
impossible to fully support IPv4/IPv6 dual stack. We're restricted
to using IPV6_V6ONLY=0 to listen on both protocols from a single
socket, but this doesn't work at all on OpenBSD, and even where
supported it is quite crude (only really works for localhost and
wildcard addresses).

This patch series introduces a new object QIONetListener, which
encapsulates multiple QIOChannelSocket listeners. This makes it
trivial to support multiple listening sockets in any part of
QEMU.

Daniel P. Berrange (8):
  tests: add functional test validating ipv4/ipv6 address flag handling
  io: introduce a network socket listener API
  blockdev: convert internal NBD server to QIONetListener
  blockdev: convert qemu-nbd server to QIONetListener
  migration: convert socket server to QIONetListener
  chardev: convert the socket server to QIONetListener
  ui: convert VNC server to QIONetListener
  sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr

 blockdev-nbd.c |  50 +--
 chardev/char-socket.c  |  70 ++--
 include/io/net-listener.h  | 174 +
 io/Makefile.objs   |   1 +
 io/net-listener.c  | 315 
 migration/socket.c |  44 +--
 qemu-nbd.c |  50 +--
 tests/.gitignore   |   1 +
 tests/Makefile.include |   3 +
 tests/test-sockets-proto.c | 906 +
 ui/vnc.c   | 194 +++---
 ui/vnc.h   |   9 +-
 util/qemu-sockets.c|  36 +-
 13 files changed, 1563 insertions(+), 290 deletions(-)
 create mode 100644 include/io/net-listener.h
 create mode 100644 io/net-listener.c
 create mode 100644 tests/test-sockets-proto.c

-- 
2.13.3




Re: [Qemu-devel] [PULL v2 6/7] exec: allow to get a pointer for some mmio memory region

2017-08-10 Thread KONRAD Frederic



On 08/10/2017 02:59 PM, Paolo Bonzini wrote:

On 10/08/2017 14:56, Peter Maydell wrote:

+qemu_mutex_lock_iothread();
+
+/* Reset dirty so this doesn't happen later. */
+cpu_physical_memory_test_and_clear_dirty(offset, size, 1);
+
+if (section.mr != mr) {
+/* memory_region_find add a ref on section.mr */
+memory_region_unref(section.mr);
+if (MMIO_INTERFACE(section.mr->owner)) {


Could somebody explain why it's OK to unref section.mr here before
we go on to do things with it, rather than only unrefing it after
we've finished using it?


The memory region won't disappear until you release the BQL and/or
RCU-read-lock, but yes it's cleaner to move it later, and yes there is a
leak.


I missed the case here where section.mr != mr but this shouldn't
happen. Either we make it acceptable and fix the leak.. or just
trigger an error as it is a bogus device. I'd rather go for the
first.
This is the same for memory_region_unref(section.mr).
memory_region_find must hit a MMIO_INTERFACE. In this case the
reference of MMIO_INTERFACE can't be zero here.

Thanks,
Fred



Paolo


Also, by my reading memory_region_find() will always ref
ret.mr (if it's not NULL), whereas this code only unrefs it
if section.mr == mr. Does this leak a reference in the case
where section.mr != mr, or am I missing something ?







[Qemu-devel] Odd character rendering/refresh behaviour?

2017-08-10 Thread Dr. David Alan Gilbert
I'm seeing something odd with character rendering and I can't quite put
my finger on it.

Generally I'm booting a Fedora26 guest and I'm seeing as I type
the characters appear in sections, and you see the rest of the
character appear shortly after (i.e. parts of each character,
not obviously top/bottom etc, but much more random)

I've not been able to get a consistent feel for when this happens;
but it feels like it's only started happening recently.

So far I can't with confidence say if it's in any way related to guest
type, video emulation or what.

Anyone else seeing this?

Dave

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



[Qemu-devel] [Bug 1709784] Re: KVM on 16.04.3 throws an error

2017-08-10 Thread Andrew Cloke
** Also affects: qemu
   Importance: Undecided
   Status: New

** Also affects: qemu (Ubuntu)
   Importance: Undecided
   Status: New

** No longer affects: qemu

** Changed in: ubuntu-power-systems
 Assignee: (unassigned) => Canonical Server Team (canonical-server)

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

Title:
  KVM on 16.04.3 throws an error

Status in The Ubuntu-power-systems project:
  New
Status in linux package in Ubuntu:
  New
Status in qemu package in Ubuntu:
  New

Bug description:
  Problem Description
  
  KVM on Ubuntu 16.04.3 throws an error when used
   
  ---uname output---
  Linux bastion-1 4.4.0-89-generic #112-Ubuntu SMP Mon Jul 31 19:37:08 UTC 2017 
ppc64le ppc64le ppc64le GNU/Linux
   
  Machine Type =  8348-21C Habanero 
   
  ---Steps to Reproduce---
   Install 16.04.3

  install KVM like:

  apt-get install libvirt-bin qemu qemu-slof qemu-system qemu-utils

  then exit and log back in so virsh will work without sudo

  then run my spawn script

  $ cat spawn.sh
  #!/bin/bash

  img=$1
  qemu-system-ppc64 \
  -machine pseries,accel=kvm,usb=off -cpu host -m 512 \
  -display none -nographic \
  -net nic -net user \
  -drive "file=$img"

  with a freshly downloaded ubuntu cloud image

  sudo ./spawn.sh xenial-server-cloudimg-ppc64el-disk1.img

  And I get nothing on the output.

  and errors in dmesg

  
  ubuntu@bastion-1:~$ [  340.180295] Facility 'TM' unavailable, exception at 
0xd000148b7f10, MSR=90009033
  [  340.180399] Oops: Unexpected facility unavailable exception, sig: 6 [#1]
  [  340.180513] SMP NR_CPUS=2048 NUMA PowerNV
  [  340.180547] Modules linked in: xt_CHECKSUM iptable_mangle ipt_MASQUERADE 
nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 
nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp 
bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables 
iptable_filter ip_tables x_tables kvm_hv kvm binfmt_misc joydev input_leds 
mac_hid opal_prd ofpart cmdlinepart powernv_flash ipmi_powernv ipmi_msghandler 
mtd at24 uio_pdrv_genirq uio ibmpowernv powernv_rng vmx_crypto ib_iser rdma_cm 
iw_cm ib_cm ib_sa ib_mad ib_core ib_addr iscsi_tcp libiscsi_tcp libiscsi 
scsi_transport_iscsi autofs4 btrfs raid10 raid456 async_raid6_recov 
async_memcpy async_pq async_xor async_tx xor raid6_pq raid1 raid0 multipath 
linear mlx4_en hid_generic usbhid hid uas usb_storage ast i2c_algo_bit bnx2x 
ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops mlx4_core drm 
ahci vxlan libahci ip6_udp_tunnel udp_tunnel mdio libcrc32c
  [  340.181331] CPU: 46 PID: 5252 Comm: qemu-system-ppc Not tainted 
4.4.0-89-generic #112-Ubuntu
  [  340.181382] task: c01e34c30b50 ti: c01e34ce4000 task.ti: 
c01e34ce4000
  [  340.181432] NIP: d000148b7f10 LR: d00014822a14 CTR: 
d000148b7e40
  [  340.181475] REGS: c01e34ce77b0 TRAP: 0f60   Not tainted  
(4.4.0-89-generic)
  [  340.181519] MSR: 90009033   CR: 22024848  
XER: 
  [  340.181629] CFAR: d000148b7ea4 SOFTE: 1 
  GPR00: d00014822a14 c01e34ce7a30 d000148cc018 c01e37bc 
  GPR04: c01db9ac c01e34ce7bc0   
  GPR08: 0001 c01e34c30b50 0001 d000148278f8 
  GPR12: d000148b7e40 cfb5b500  001f 
  GPR16: 3fff91c3 0080 3fffa8e34390 3fff9242f200 
  GPR20: 3fff92430010 01001de5c030 3fff9242eb60 100c1ff0 
  GPR24: 3fffc91fe990 3fff91c10028  c01e37bc 
  GPR28:  c01db9ac c01e37bc c01db9ac 
  [  340.182315] NIP [d000148b7f10] kvmppc_vcpu_run_hv+0xd0/0xff0 [kvm_hv]
  [  340.182357] LR [d00014822a14] kvmppc_vcpu_run+0x44/0x60 [kvm]
  [  340.182394] Call Trace:
  [  340.182413] [c01e34ce7a30] [c01e34ce7ab0] 0xc01e34ce7ab0 
(unreliable)
  [  340.182468] [c01e34ce7b70] [d00014822a14] 
kvmppc_vcpu_run+0x44/0x60 [kvm]
  [  340.182522] [c01e34ce7ba0] [d0001481f674] 
kvm_arch_vcpu_ioctl_run+0x64/0x170 [kvm]
  [  340.182581] [c01e34ce7be0] [d00014813918] 
kvm_vcpu_ioctl+0x528/0x7b0 [kvm]
  [  340.182634] [c01e34ce7d40] [c02fffa0] do_vfs_ioctl+0x480/0x7d0
  [  340.182678] [c01e34ce7de0] [c03003c4] SyS_ioctl+0xd4/0xf0
  [  340.182723] [c01e34ce7e30] [c0009204] system_call+0x38/0xb4
  [  340.182766] Instruction dump:
  [  340.182788] e92d02a0 e9290a50 e9290108 792a07e3 41820058 e92d02a0 e9290a50 
e9290108 
  [  340.182863] 7927e8a4 78e71f87 40820ed8 e92d02a0 <7d4022a6> f9490ee8 
e92d02a0 7d4122a6 
  [  340.182938] ---[ end trace bc5080cb7d18f102 ]---
  [  340.276202] 

  
  This was with the latest ubuntu cloud image. I get the same thing when trying 
to use 

Re: [Qemu-devel] [PATCH v6 04/19] migration: Create migration_has_all_channels

2017-08-10 Thread Daniel P. Berrange
On Tue, Aug 08, 2017 at 06:26:14PM +0200, Juan Quintela wrote:
> This functions allows us to decide when to close the listener socket.
> For now, we only need one connection.
> 
> Signed-off-by: Juan Quintela 
> ---
>  migration/migration.c | 11 +++
>  migration/migration.h |  2 ++
>  migration/socket.c| 10 +++---
>  3 files changed, 20 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrange 


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



[Qemu-devel] [PATCH 03/15] ui: convert key events to QKeyCodes immediately

2017-08-10 Thread Daniel P. Berrange
Always use QKeyCode in the InputKeyEvent struct, by converting key
numbers to QKeyCode at the time the event is created.

Signed-off-by: Daniel P. Berrange 
---
 ui/input.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/ui/input.c b/ui/input.c
index af05f06368..64e9103a61 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -400,10 +400,8 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue 
*key, bool down)
 
 void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down)
 {
-KeyValue *key = g_new0(KeyValue, 1);
-key->type = KEY_VALUE_KIND_NUMBER;
-key->u.number.data = num;
-qemu_input_event_send_key(src, key, down);
+QKeyCode code = qemu_input_key_number_to_qcode(num);
+qemu_input_event_send_key_qcode(src, code, down);
 }
 
 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down)
-- 
2.13.3




[Qemu-devel] [PULL] 9pfs fixes for 2.10 20170810

2017-08-10 Thread Greg Kurz
The following changes since commit b38df311c174c98ef8cce7dec9f46603b083018e:

  Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.10-20170809' 
into staging (2017-08-10 11:12:36 +0100)

are available in the git repository at:

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

for you to fetch changes up to 4751fd5328dfcd4fe2f9055728a72a0e3ae56512:

  9pfs: local: fix fchmodat_nofollow() limitations (2017-08-10 14:36:11 +0200)


Just a single fix for an annoying regression introduced in 2.9 when fixing
CVE-2016-9602.


Greg Kurz (1):
  9pfs: local: fix fchmodat_nofollow() limitations

 hw/9pfs/9p-local.c | 42 +++---
 hw/9pfs/9p-util.h  | 24 +++-
 2 files changed, 50 insertions(+), 16 deletions(-)
-- 
2.7.5




[Qemu-devel] [PATCH 5/8] migration: convert socket server to QIONetListener

2017-08-10 Thread Daniel P. Berrange
Instead of creating a QIOChannelSocket directly for the migration
server socket, use a QIONetListener. This provides the ability
to listen on multiple sockets at the same time, so enables
full support for IPv4/IPv6 dual stack.

Signed-off-by: Daniel P. Berrange 
---
 migration/socket.c | 44 ++--
 tests/test-sockets-proto.c |  3 +--
 2 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/migration/socket.c b/migration/socket.c
index 757d3821a1..34811addc5 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -24,6 +24,7 @@
 #include "migration.h"
 #include "qemu-file.h"
 #include "io/channel-socket.h"
+#include "io/net-listener.h"
 #include "trace.h"
 
 
@@ -130,53 +131,36 @@ void unix_start_outgoing_migration(MigrationState *s,
 }
 
 
-static gboolean socket_accept_incoming_migration(QIOChannel *ioc,
- GIOCondition condition,
- gpointer opaque)
+static void socket_accept_incoming_migration(QIONetListener *listener,
+ QIOChannelSocket *cioc,
+ gpointer opaque)
 {
-QIOChannelSocket *sioc;
-Error *err = NULL;
-
-sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
- );
-if (!sioc) {
-error_report("could not accept migration connection (%s)",
- error_get_pretty(err));
-goto out;
-}
-
 trace_migration_socket_incoming_accepted();
 
-qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-incoming");
-migration_channel_process_incoming(QIO_CHANNEL(sioc));
-object_unref(OBJECT(sioc));
+qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming");
+migration_channel_process_incoming(QIO_CHANNEL(cioc));
 
-out:
 /* Close listening socket as its no longer needed */
-qio_channel_close(ioc, NULL);
-return FALSE; /* unregister */
+qio_net_listener_disconnect(listener);
+
+object_unref(OBJECT(listener));
 }
 
 
 static void socket_start_incoming_migration(SocketAddress *saddr,
 Error **errp)
 {
-QIOChannelSocket *listen_ioc = qio_channel_socket_new();
+QIONetListener *listener = qio_net_listener_new();
 
-qio_channel_set_name(QIO_CHANNEL(listen_ioc),
- "migration-socket-listener");
+qio_net_listener_set_name(listener, "migration-socket-listener");
 
-if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) {
-object_unref(OBJECT(listen_ioc));
+if (qio_net_listener_open_sync(listener, saddr, errp) < 0) {
+object_unref(OBJECT(listener));
 qapi_free_SocketAddress(saddr);
 return;
 }
 
-qio_channel_add_watch(QIO_CHANNEL(listen_ioc),
-  G_IO_IN,
-  socket_accept_incoming_migration,
-  listen_ioc,
-  (GDestroyNotify)object_unref);
+qio_net_listener_set_client_func(listener, 
socket_accept_incoming_migration, NULL, NULL);
 qapi_free_SocketAddress(saddr);
 }
 
diff --git a/tests/test-sockets-proto.c b/tests/test-sockets-proto.c
index 1d6beda59f..1495369696 100644
--- a/tests/test-sockets-proto.c
+++ b/tests/test-sockets-proto.c
@@ -70,8 +70,7 @@ typedef struct {
 static QSocketsData test_data[] = {
 /* Migrate with "" address */
 /* XXX all settings with =off are disabled due to inet_parse() bug */
-/* XXX multilistener bug - should be .ipv6 = 1 */
-{ .ipv4 = 1, .ipv6 = -1, .error = false,
+{ .ipv4 = 1, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/wildcard/all",
   .args = "-incoming tcp::9000" },
 { .ipv4 = 1, .ipv6 = 0, .error = false,
-- 
2.13.3




[Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API

2017-08-10 Thread Daniel P. Berrange
The existing QIOChannelSocket class provides the ability to
listen on a single socket at a time. This patch introduces
a QIONetListener class that provides a higher level API
concept around listening for network services, allowing
for listening on multiple sockets.

Signed-off-by: Daniel P. Berrange 
---
 include/io/net-listener.h | 174 +
 io/Makefile.objs  |   1 +
 io/net-listener.c | 315 ++
 3 files changed, 490 insertions(+)
 create mode 100644 include/io/net-listener.h
 create mode 100644 io/net-listener.c

diff --git a/include/io/net-listener.h b/include/io/net-listener.h
new file mode 100644
index 00..0ac5c9cc72
--- /dev/null
+++ b/include/io/net-listener.h
@@ -0,0 +1,174 @@
+/*
+ * QEMU I/O network listener
+ *
+ * Copyright (c) 2016 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see .
+ *
+ */
+
+#ifndef QIO_NET_LISTENER_H
+#define QIO_NET_LISTENER_H
+
+#include "io/channel-socket.h"
+
+#define TYPE_QIO_NET_LISTENER "qio-net-listener"
+#define QIO_NET_LISTENER(obj)\
+OBJECT_CHECK(QIONetListener, (obj), TYPE_QIO_NET_LISTENER)
+#define QIO_NET_LISTENER_CLASS(klass)\
+OBJECT_CLASS_CHECK(QIONetListenerClass, klass, TYPE_QIO_NET_LISTENER)
+#define QIO_NET_LISTENER_GET_CLASS(obj)  \
+OBJECT_GET_CLASS(QIONetListenerClass, obj, TYPE_QIO_NET_LISTENER)
+
+typedef struct QIONetListener QIONetListener;
+typedef struct QIONetListenerClass QIONetListenerClass;
+
+typedef void (*QIONetListenerClientFunc)(QIONetListener *listener,
+ QIOChannelSocket *sioc,
+ gpointer data);
+
+/**
+ * QIONetListener:
+ *
+ * The QIONetListener object encapsulates the management of a
+ * listening socket. It is able to listen on multiple sockets
+ * concurrently, to deal with the scenario where IPv4 / IPv6
+ * needs separate sockets, or there is a need to listen on a
+ * subset of interface IP addresses, instead of the wildcard
+ * address.
+ */
+struct QIONetListener {
+Object parent;
+
+char *name;
+QIOChannelSocket **sioc;
+gulong *io_tag;
+size_t nsioc;
+
+gboolean disconnected;
+
+QIONetListenerClientFunc io_func;
+gpointer io_data;
+GDestroyNotify io_notify;
+};
+
+struct QIONetListenerClass {
+ObjectClass parent;
+};
+
+
+/**
+ * qio_net_listener_new:
+ *
+ * Create a new network listener service, which is not
+ * listening on any sockets initially.
+ *
+ * Returns: the new listener
+ */
+QIONetListener *qio_net_listener_new(void);
+
+
+/**
+ * qio_net_listener_set_name:
+ * @listener: the network listener object
+ * @name: the listener name
+ *
+ * Set the name of the listener. This is used as a debugging
+ * aid, to set names on any GSource instances associated
+ * with the listener
+ */
+void qio_net_listener_set_name(QIONetListener *listener,
+   const char *name);
+
+/**
+ * qio_net_listener_open_sync:
+ * @listener: the network listener object
+ * @addr: the address to listen on
+ * @errp: pointer to a NULL initialized error object
+ *
+ * Synchronously open a listening connection on all
+ * addresses associated with @addr. This method may
+ * also be invoked multiple times, in order to have a
+ * single listener on multiple distinct addresses.
+ */
+int qio_net_listener_open_sync(QIONetListener *listener,
+   SocketAddress *addr,
+   Error **errp);
+
+/**
+ * qio_net_listener_add:
+ * @listener: the network listener object
+ * @sioc: the socket I/O channel
+ *
+ * Associate a listening socket I/O channel with the
+ * listener. The listener will acquire an new reference
+ * on @sioc, so the caller should release its own reference
+ * if it no longer requires the object.
+ */
+void qio_net_listener_add(QIONetListener *listener,
+  QIOChannelSocket *sioc);
+
+/**
+ * qio_net_listener_set_client_func:
+ * @listener: the network listener object
+ * @func: the callback function
+ * @data: opaque data to pass to @func
+ * @notify: callback to free @data
+ *
+ * Register @func to be invoked whenever a new client
+ * connects to the listener. 

[Qemu-devel] [PATCH v2 for-2.11 2/2] tests/pxe: Check virtio-net-ccw on s390x

2017-08-10 Thread Thomas Huth
Now that we've got a firmware that can do TFTP booting on s390x (i.e.
the pc-bios/s390-netboot.img), we can enable the PXE tester for this
architecture, too.

Signed-off-by: Thomas Huth 
---
 tests/Makefile.include |  1 +
 tests/boot-sector.c| 20 
 tests/pxe-test.c   |  7 +++
 3 files changed, 28 insertions(+)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index eb4895f..2a238db 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -337,6 +337,7 @@ check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
 check-qtest-xtensaeb-y = $(check-qtest-xtensa-y)
 
 check-qtest-s390x-y = tests/boot-serial-test$(EXESUF)
+check-qtest-s390x-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
 
 check-qtest-generic-y += tests/qom-test$(EXESUF)
 check-qtest-generic-y += tests/test-hmp$(EXESUF)
diff --git a/tests/boot-sector.c b/tests/boot-sector.c
index 8729562..9ee8537 100644
--- a/tests/boot-sector.c
+++ b/tests/boot-sector.c
@@ -67,6 +67,21 @@ static uint8_t x86_boot_sector[512] = {
 [0x1FF] = 0xAA,
 };
 
+/* For s390x, use a mini "kernel" with the appropriate signature */
+static const uint8_t s390x_psw[] = {
+0x00, 0x08, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00
+};
+static const uint8_t s390x_code[] = {
+0xa7, 0xf4, 0x00, 0x0a,/* j 0x10010 */
+0x00, 0x00, 0x00, 0x00,
+'S', '3', '9', '0',
+'E', 'P', 0x00, 0x01,
+0xa7, 0x38, HIGH(SIGNATURE_ADDR), LOW(SIGNATURE_ADDR), /* lhi r3,0x7c10 */
+0xa7, 0x48, LOW(SIGNATURE), HIGH(SIGNATURE),   /* lhi r4,0xadde */
+0x40, 0x40, 0x30, 0x00,/* sth r4,0(r3) */
+0xa7, 0xf4, 0xff, 0xfa /* j 0x10010 */
+};
+
 /* Create boot disk file.  */
 int boot_sector_init(char *fname)
 {
@@ -92,6 +107,11 @@ int boot_sector_init(char *fname)
 LOW(SIGNATURE), SIGNATURE_ADDR,
 HIGH(SIGNATURE), SIGNATURE_ADDR + 1);
 len = strlen(boot_code);
+} else if (g_str_equal(arch, "s390x")) {
+len = 0x1 + sizeof(s390x_code);
+boot_code = g_malloc0(len);
+memcpy(boot_code, s390x_psw, sizeof(s390x_psw));
+memcpy(_code[0x1], s390x_code, sizeof(s390x_code));
 } else {
 g_assert_not_reached();
 }
diff --git a/tests/pxe-test.c b/tests/pxe-test.c
index cf6e225..0d70afc 100644
--- a/tests/pxe-test.c
+++ b/tests/pxe-test.c
@@ -51,6 +51,11 @@ static void test_pxe_spapr_vlan(void)
 test_pxe_one("-device spapr-vlan,netdev=" NETNAME, true);
 }
 
+static void test_pxe_virtio_ccw(void)
+{
+test_pxe_one("-device virtio-net-ccw,bootindex=1,netdev=" NETNAME, false);
+}
+
 int main(int argc, char *argv[])
 {
 int ret;
@@ -68,6 +73,8 @@ int main(int argc, char *argv[])
 } else if (strcmp(arch, "ppc64") == 0) {
 qtest_add_func("pxe/virtio", test_pxe_virtio_pci);
 qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan);
+} else if (g_str_equal(arch, "s390x")) {
+qtest_add_func("pxe/virtio-ccw", test_pxe_virtio_ccw);
 }
 ret = g_test_run();
 boot_sector_cleanup(disk);
-- 
1.8.3.1




[Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester

2017-08-10 Thread Thomas Huth
The first patch improves the buffer handling in the pxe tester a
little bit by allocating a separate buffer on the heap for each
architecture. This also gets rid of the huge pre-initialized
array in the tester, shrinking the size of the executable by
half of a megabyte!
The second patch adds s390x support to the pxe tester. Starting
with QEMU 2.10, the guest firmware on s390x can now net-boot via
TFTP, too, so we can automatically test this code in the pxe tester.

v2: Adressed Cornelia's review feedback from the first version, e.g.:
 - Use g_malloc0() instead of g_malloc()
 - Use sizeof with parentheses

Thomas Huth (2):
  tests/boot-sector: Do not overwrite the x86 buffer on other
architectures
  tests/pxe: Check virtio-net-ccw on s390x

 tests/Makefile.include |  1 +
 tests/boot-sector.c| 61 +-
 tests/pxe-test.c   |  7 ++
 3 files changed, 54 insertions(+), 15 deletions(-)

-- 
1.8.3.1




[Qemu-devel] [PATCH v2 for-2.11 1/2] tests/boot-sector: Do not overwrite the x86 buffer on other architectures

2017-08-10 Thread Thomas Huth
Re-using the boot_sector code buffer from x86 for other architectures
is not very nice, especially if we add more architectures later. It's
also ugly that the test uses a huge pre-initialized array at all - the
size of the executable is very huge due to this array. So let's use a
separate buffer for each architecture instead, allocated from the heap,
so that we really just use the memory that we need.

Suggested-by: Michael Tsirkin 
Signed-off-by: Thomas Huth 
---
 tests/boot-sector.c | 41 ++---
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/tests/boot-sector.c b/tests/boot-sector.c
index e3880f4..8729562 100644
--- a/tests/boot-sector.c
+++ b/tests/boot-sector.c
@@ -21,13 +21,12 @@
 #define SIGNATURE 0xdead
 #define SIGNATURE_OFFSET 0x10
 #define BOOT_SECTOR_ADDRESS 0x7c00
+#define SIGNATURE_ADDR (BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET)
 
-/* Boot sector code: write SIGNATURE into memory,
+/* x86 boot sector code: write SIGNATURE into memory,
  * then halt.
- * Q35 machine requires a minimum 0x7e000 bytes disk.
- * (bug or feature?)
  */
-static uint8_t boot_sector[0x7e000] = {
+static uint8_t x86_boot_sector[512] = {
 /* The first sector will be placed at RAM address 7C00, and
  * the BIOS transfers control to 7C00
  */
@@ -50,8 +49,8 @@ static uint8_t boot_sector[0x7e000] = {
 [0x07] = HIGH(SIGNATURE),
 /* 7c08:  mov %ax,0x7c10 */
 [0x08] = 0xa3,
-[0x09] = LOW(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET),
-[0x0a] = HIGH(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET),
+[0x09] = LOW(SIGNATURE_ADDR),
+[0x0a] = HIGH(SIGNATURE_ADDR),
 
 /* 7c0b cli */
 [0x0b] = 0xfa,
@@ -72,7 +71,9 @@ static uint8_t boot_sector[0x7e000] = {
 int boot_sector_init(char *fname)
 {
 int fd, ret;
-size_t len = sizeof boot_sector;
+size_t len;
+char *boot_code;
+const char *arch = qtest_get_arch();
 
 fd = mkstemp(fname);
 if (fd < 0) {
@@ -80,16 +81,26 @@ int boot_sector_init(char *fname)
 return 1;
 }
 
-/* For Open Firmware based system, we can use a Forth script instead */
-if (strcmp(qtest_get_arch(), "ppc64") == 0) {
-len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x 
c!\n",
-LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,
-HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
+if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) {
+/* Q35 requires a minimum 0x7e000 bytes disk (bug or feature?) */
+len = MAX(0x7e000, sizeof(x86_boot_sector));
+boot_code = g_malloc0(len);
+memcpy(boot_code, x86_boot_sector, sizeof(x86_boot_sector));
+} else if (g_str_equal(arch, "ppc64")) {
+/* For Open Firmware based system, use a Forth script */
+boot_code = g_strdup_printf("\\ Bootscript\n%x %x c! %x %x c!\n",
+LOW(SIGNATURE), SIGNATURE_ADDR,
+HIGH(SIGNATURE), SIGNATURE_ADDR + 1);
+len = strlen(boot_code);
+} else {
+g_assert_not_reached();
 }
 
-ret = write(fd, boot_sector, len);
+ret = write(fd, boot_code, len);
 close(fd);
 
+g_free(boot_code);
+
 if (ret != len) {
 fprintf(stderr, "Could not write \"%s\"", fname);
 return 1;
@@ -115,8 +126,8 @@ void boot_sector_test(void)
  * instruction.
  */
 for (i = 0; i < TEST_CYCLES; ++i) {
-signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
-signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
+signature_low = readb(SIGNATURE_ADDR);
+signature_high = readb(SIGNATURE_ADDR + 1);
 signature = (signature_high << 8) | signature_low;
 if (signature == SIGNATURE) {
 break;
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v5 17/17] migration: Flush receive queue

2017-08-10 Thread Peter Xu
On Tue, Aug 08, 2017 at 01:40:58PM +0200, Juan Quintela wrote:
> Peter Xu  wrote:
> > On Mon, Jul 17, 2017 at 03:42:38PM +0200, Juan Quintela wrote:
> >> Each time that we sync the bitmap, it is a possiblity that we receive
> >> a page that is being processed by a different thread.  We fix this
> >> problem just making sure that we wait for all receiving threads to
> >> finish its work before we procedeed with the next stage.
> >> 
> >> We are low on page flags, so we use a combination that is not valid to
> >> emit that message:  MULTIFD_PAGE and COMPRESSED.
> >> 
> >> I tried to make a migration command for it, but it don't work because
> >> we sync the bitmap sometimes when we have already sent the beggining
> >> of the section, so I just added a new page flag.
> >> 
> >> Signed-off-by: Juan Quintela 
> 
> >> @@ -675,6 +686,10 @@ static void *multifd_recv_thread(void *opaque)
> >>  return NULL;
> >>  }
> >>  p->done = true;
> >> +if (p->sync) {
> >> +qemu_cond_signal(>cond_sync);
> >> +p->sync = false;
> >> +}
> >
> > Could we use the same p->ready for this purpose? They looks similar:
> > all we want to do is to let the main thread know "worker thread has
> > finished receiving the last piece and becomes idle again", right?
> 
> We *could*, but "ready" is used for each page that we sent, sync is only
> used once every round.  Notice that "ready" is a semaphore, and its
> semantic is weird.  See next comment.
> 
> 
> >> +static int multifd_flush(void)
> >> +{
> >> +int i, thread_count;
> >> +
> >> +if (!migrate_use_multifd()) {
> >> +return 0;
> >> +}
> >> +thread_count = migrate_multifd_threads();
> >> +for (i = 0; i < thread_count; i++) {
> >> +MultiFDRecvParams *p = multifd_recv_state->params[i];
> >> +
> >> +qemu_mutex_lock(>mutex);
> >> +while (!p->done) {
> >> +p->sync = true;
> >> +qemu_cond_wait(>cond_sync, >mutex);
> >
> > (similar comment like above)
> 
> We need to look at the two pieces of code at the same time.  What are we
> trying to do:
> 
> - making sure that all threads have finished the current round.
>   in this particular case, that this thread has finished its current
>   round OR  that it is waiting for work.
> 
> So, the main thread is the one that does the sem_wait(ready) and the channel
> thread is the one that does the sem_post(ready).
> 
> multifd_recv_thread()
> 
> if (p->sync) {
> sem_post(ready);
> p->sync = false;
> }
> 
> multifd_flush()
>if (!p->done) {
>p->sync = true;
>sem_wait(ready);
>}
> 
> Ah, but done and sync can be changed from other threads, so current code
> will become:
> 
> multifd_recv_thread()
> 
> if (p->sync) {
> sem_post(ready);
> p->sync = false;
> }
> 
> multifd_flush()
>...
>mutex_lock(lock);
>if (!p->done) {
>p->sync = true;
>mutex_unlock(lock)
>sem_wait(ready);
>mutex_lock(lock)
>}
>mutex_unlock(lock)
> 
> That I would claim that it is more complicated to understand.  Mixing
> locks and semaphores is . interesting to say the least.  With
> variable conditions it becomes easy.
> 
> Yes, we can change sync/done to atomic access, but not sure that makes
> things so much simpler.

I was thinking that p->ready can be used a notification channel from
recv thread to main thread for any reason. But I'm also fine that if
you want to do this separately to have different sync channels for
page-level completions and global flushes especially in first version.

(but I'd say I feel the whole thing slightly complicated, while I feel
 it can be simpler somewhere...)

> 
> >> +}
> >> +qemu_mutex_unlock(>mutex);
> >> +}
> >> +return 0;
> >> +}
> >> +
> >>  /**
> >>   * save_page_header: write page header to wire
> >>   *
> >> @@ -809,6 +847,12 @@ static size_t save_page_header(RAMState *rs, QEMUFile 
> >> *f,  RAMBlock *block,
> >>  {
> >>  size_t size, len;
> >>  
> >> +if (rs->multifd_needs_flush &&
> >> +(offset & RAM_SAVE_FLAG_MULTIFD_PAGE)) {
> >
> > If multifd_needs_flush is only for multifd, then we may skip this
> > check, but it looks more like an assertion:
> >
> > if (rs->multifd_needs_flush) {
> > assert(offset & RAM_SAVE_FLAG_MULTIFD_PAGE);
> > offset |= RAM_SAVE_FLAG_ZERO;
> > }
> 
> No, it could be that this page is a _non_ multifd page, and then ZERO
> means something different.  So, we can only send this for MULTIFD pages.

But if multifd_needs_flush==true, it must be a multifd page, no? :)

I think this is trivial, so both work for me.

> 
> > (Dave mentioned about unaligned flag used in commit message and here:
> >  ZERO is used, but COMPRESS is mentioned)
> 
> OK, I can change the message.
> 
> >> @@ -2496,6 +2540,9 @@ static int 

Re: [Qemu-devel] [PATCH v3] 9pfs: fix dependencies

2017-08-10 Thread Cornelia Huck
On Wed, 9 Aug 2017 18:53:11 +0200
Greg Kurz  wrote:

> On Wed,  9 Aug 2017 18:30:19 +0200
> Cornelia Huck  wrote:
> 
> > Nothing in fsdev/ or hw/9pfs/ depends on pci; it should rather depend
> > on CONFIG_VIRTFS and CONFIG_VIRTIO/CONFIG_XEN only.
> > 
> > Signed-off-by: Cornelia Huck 
> > ---
> >   
> 
> I think we're ok now. Thanks for fixing that!
> 
> IIUC, this patch will be needed when your zpci cleanup patches get merged.

Yes, it does not really matter before that.

> I suggest you add it to your series with my:
> 
> Acked-by: Greg Kurz 

Thanks!



Re: [Qemu-devel] [PATCH v4 14/22] libqtest: Separate qmp_discard_response() from command

2017-08-10 Thread Markus Armbruster
Eric Blake  writes:

> On 08/09/2017 10:15 AM, Markus Armbruster wrote:
>> Eric Blake  writes:
>> 
>>> Upcoming patches will be adding new convenience methods for
>>> constructing QMP commands.  But making every variation of sending
>>> support every variation of response handling becomes unwieldy;
>>> it's easier to specify that discarding a JSON response is
>>> unassociated with sending the command, where qmp_async() already
>>> fits the bill for sending a command without tying up a reference
>>> to the response.
>>>
>>> Doing this renders qtest_qmp[v]_discard_response() unused.
>>>
>>> Bonus: gets rid of a non-literal format string, which is a step
>>> towards compile-time format string checking without triggering
>>> -Wformat-nonliteral.
>> 
>> Where?  (I'm feeling lazy today)
>> 
>
> Sure:
>
>> 
>> +++ b/tests/ide-test.c
>> @@ -624,7 +624,6 @@ static void test_retry_flush(const char *machine)
>>  QPCIDevice *dev;
>>  QPCIBar bmdma_bar, ide_bar;
>>  uint8_t data;
>> -const char *s;
>> 
>>  prepare_blkdebug_script(debug_path, "flush_to_disk");
>> 
>> @@ -652,8 +651,8 @@ static void test_retry_flush(const char *machine)
>>  qmp_eventwait("STOP");
>> 
>>  /* Complete the command */
>> -s = "{'execute':'cont' }";
>> -qmp_discard_response(s);
>> +qmp_async("{'execute':'cont' }");
>> +qmp_discard_response();
>
> Yes, I can update the commit message to focus in on it more precisely.

Not enabled by this patch, just cleanup while there.  Recommend to make
that clearer in the commit message.

Aside: I wonder what goes through a developer's head when he writes such
code.  "Too terse, let me splice in a variable" seems unlikely.

[...]



[Qemu-devel] [PATCH] block/qcow2-snapshot: Fix a null pointer dereference in qcow2_free_snapshots

2017-08-10 Thread Hu Chaojian
From: chaojianhu 

In function qcow2_do_open, if "go fail;" before calling qcow2_read_snapshots, 
then snapshots 
will always be NULL. When dealing with "fail:", qcow2_free_snapshots will be 
called, and 
s->snapshots will be dereferenced without checked.

Reported-by: chaojianhu 
Signed-off-by: chaojianhu 

---
 block/qcow2-snapshot.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 44243e0..4a8128c 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -35,6 +35,10 @@ void qcow2_free_snapshots(BlockDriverState *bs)
 BDRVQcow2State *s = bs->opaque;
 int i;
 
+if (NULL == s->snapshots) {
+return;
+}
+
 for(i = 0; i < s->nb_snapshots; i++) {
 g_free(s->snapshots[i].name);
 g_free(s->snapshots[i].id_str);
-- 
1.9.1




Re: [Qemu-devel] [PATCH v8 0/8] Optimize VMDK I/O by allocating multiple clusters

2017-08-10 Thread Stefan Hajnoczi
On Thu, Jul 27, 2017 at 3:33 PM, Ashijeet Acharya
 wrote:
> Previously posted series patches:
> v1 - http://lists.nongnu.org/archive/html/qemu-devel/2017-03/msg02044.html
> v2 - http://lists.nongnu.org/archive/html/qemu-devel/2017-03/msg05080.html
> v3 - http://lists.nongnu.org/archive/html/qemu-devel/2017-04/msg00074.html
> v4 - http://lists.nongnu.org/archive/html/qemu-devel/2017-04/msg03851.html
> v5 - http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg00929.html
> v6 - http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg00947.html
> v7 - http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg06600.html
>
> This series helps to optimize the I/O performance of VMDK driver.
>
> Patch 1 helps us to move vmdk_find_offset_in_cluster.
>
> Patch 2 & 3 perform a simple function re-naming tasks.
>
> Patch 4 is used to factor out metadata loading code and implement it in 
> separate
> functions. This will help us to avoid code duplication in future patches of 
> this
> series.
>
> Patch 5 helps to set the upper limit of the bytes handled in one cycle.
>
> Patch 6 adds new functions to help us allocate multiple clusters according to
> the size requested, perform COW if required and return the offset of the first
> newly allocated cluster.
>
> Patch 7 changes the metadata update code to update the L2 tables for multiple
> clusters at once.
>
> Patch 8 helps us to finally change vmdk_get_cluster_offset() to find cluster
> offset only as cluster allocation task is now handled by vmdk_alloc_clusters()
>
> Optimization test results:
>
> This patch series improves 128 KB sequential write performance to an
> empty VMDK file by 54%
>
> Benchmark command: ./qemu-img bench -w -c 1024 -s 128K -d 1 -t none -f
> vmdk test.vmdk
>
> Changes in v8:
> - fix minor variable naming issue in patch 6

Fam: Ping?

Ashijeet: Feel free to send a ping reply if no one reviews your
patches within a few days.



[Qemu-devel] [PATCH] qemu-iothread: IOThread supports the GMainContext event loop

2017-08-10 Thread Wang yong
From: Wang Yong

IOThread uses AioContext event loop and does not run a GMainContext.
Therefore,chardev cannot work in IOThread,such as the chardev is
used for colo-compare packets reception.

This patch makes the IOThread run the GMainContext event loop,
chardev and IOThread can work together.

Signed-off-by: Wang Yong
Signed-off-by: Wang Guang
---
 include/sysemu/iothread.h |  1 +
 iothread.c| 13 +
 2 files changed, 14 insertions(+)

diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
index e6da1a4..ffe4e8a 100644
--- a/include/sysemu/iothread.h
+++ b/include/sysemu/iothread.h
@@ -24,6 +24,7 @@ typedef struct {
 
 QemuThread thread;
 AioContext *ctx;
+GMainLoop *loop;
 QemuMutex init_done_lock;
 QemuCond init_done_cond;/* is thread initialization done? */
 bool stopping;
diff --git a/iothread.c b/iothread.c
index beeb870..b6f3c3c 100644
--- a/iothread.c
+++ b/iothread.c
@@ -46,6 +46,7 @@ AioContext *qemu_get_current_aio_context(void)
 static void *iothread_run(void *opaque)
 {
 IOThread *iothread = opaque;
+GMainContext *context;
 
 rcu_register_thread();
 
@@ -57,6 +58,15 @@ static void *iothread_run(void *opaque)
 
 while (!atomic_read(>stopping)) {
 aio_poll(iothread->ctx, true);
+
+context = iothread->ctx->source.context;
+if (context) {
+iothread->loop = g_main_loop_new(context, TRUE);
+g_main_loop_run(iothread->loop);
+
+g_main_loop_unref(iothread->loop);
+g_main_context_unref(context);
+}
 }
 
 rcu_unregister_thread();
@@ -72,6 +82,9 @@ static int iothread_stop(Object *object, void *opaque)
 return 0;
 }
 iothread->stopping = true;
+if (iothread->loop) {
+g_main_loop_quit(iothread->loop);
+}
 aio_notify(iothread->ctx);
 qemu_thread_join(>thread);
 return 0;
-- 
1.8.3.1





Re: [Qemu-devel] [PATCH v4 19/22] libqtest: Add qmp_args_dict() helper

2017-08-10 Thread Markus Armbruster
Eric Blake  writes:

> On 08/09/2017 10:59 AM, Markus Armbruster wrote:
>> Eric Blake  writes:
>> 
>>> Leaving interpolation into JSON to qobject_from_jsonf() is more
>>> robust than building QMP input manually; however, we have a few
>>> places where code is already creating a QDict to interpolate
>>> individual arguments, which cannot be reproduced with the
>>> qobject_from_jsonf() parser.  Expose a public wrapper
>>> qmp_args_dict() for the internal helper qmp_args_dict_async()
>>> that we needed earlier for qmp_args(), and fix a test to use
>>> the new helper.
>>>
>>> Signed-off-by: Eric Blake 
>>> ---
>
>>> +++ b/tests/device-introspect-test.c
>>> @@ -36,8 +36,7 @@ static QList *qom_list_types(const char *implements, bool 
>>> abstract)
>>>  if (implements) {
>>>  qdict_put_str(args, "implements", implements);
>>>  }
>>> -resp = qmp("{'execute': 'qom-list-types',"
>>> -   " 'arguments': %p }", args);
>>> +resp = qmp_args_dict("qom-list-types", args);
>>>  g_assert(qdict_haskey(resp, "return"));
>>>  ret = qdict_get_qlist(resp, "return");
>>>  QINCREF(ret);
>> 
>> If we had five of these, the helper would be worth its keep.
>
> This patch only  has one client, but 20/22 adds another.  Is having 2
> clients sufficient to keep it (not quite the 5 that makes it obvious,
> but still a good reuse of code)?

Your idea to use macros might make this a moot question.  Let's revisit
it in v2.



Re: [Qemu-devel] [PATCH v8 0/8] Optimize VMDK I/O by allocating multiple clusters

2017-08-10 Thread Ashijeet Acharya
On Thu, Aug 10, 2017 at 1:41 PM, Stefan Hajnoczi  wrote:

> On Thu, Jul 27, 2017 at 3:33 PM, Ashijeet Acharya
>  wrote:
> > Previously posted series patches:
> > v1 - http://lists.nongnu.org/archive/html/qemu-devel/2017-
> 03/msg02044.html
> > v2 - http://lists.nongnu.org/archive/html/qemu-devel/2017-
> 03/msg05080.html
> > v3 - http://lists.nongnu.org/archive/html/qemu-devel/2017-
> 04/msg00074.html
> > v4 - http://lists.nongnu.org/archive/html/qemu-devel/2017-
> 04/msg03851.html
> > v5 - http://lists.nongnu.org/archive/html/qemu-devel/2017-
> 06/msg00929.html
> > v6 - http://lists.nongnu.org/archive/html/qemu-devel/2017-
> 06/msg00947.html
> > v7 - http://lists.nongnu.org/archive/html/qemu-devel/2017-
> 06/msg06600.html
> >
> > This series helps to optimize the I/O performance of VMDK driver.
> >
> > Patch 1 helps us to move vmdk_find_offset_in_cluster.
> >
> > Patch 2 & 3 perform a simple function re-naming tasks.
> >
> > Patch 4 is used to factor out metadata loading code and implement it in
> separate
> > functions. This will help us to avoid code duplication in future patches
> of this
> > series.
> >
> > Patch 5 helps to set the upper limit of the bytes handled in one cycle.
> >
> > Patch 6 adds new functions to help us allocate multiple clusters
> according to
> > the size requested, perform COW if required and return the offset of the
> first
> > newly allocated cluster.
> >
> > Patch 7 changes the metadata update code to update the L2 tables for
> multiple
> > clusters at once.
> >
> > Patch 8 helps us to finally change vmdk_get_cluster_offset() to find
> cluster
> > offset only as cluster allocation task is now handled by
> vmdk_alloc_clusters()
> >
> > Optimization test results:
> >
> > This patch series improves 128 KB sequential write performance to an
> > empty VMDK file by 54%
> >
> > Benchmark command: ./qemu-img bench -w -c 1024 -s 128K -d 1 -t none -f
> > vmdk test.vmdk
> >
> > Changes in v8:
> > - fix minor variable naming issue in patch 6
>
> Fam: Ping?
>
> Ashijeet: Feel free to send a ping reply if no one reviews your
> patches within a few days.
>

Hi Stefan,

I had a chat with Fam on #qemu-block before submitting this series and he
said he will be merging it soon when the freeze is over (I am not sure if
it is yet) since all the patches are already reviewed :-)

Ashijeet


Re: [Qemu-devel] [PATCH for-2.10 2/2] xilinx-spips: add a migration blocker when using mmio_execution

2017-08-10 Thread Peter Maydell
On 1 August 2017 at 10:41, Peter Maydell  wrote:
> On 1 August 2017 at 10:35, KONRAD Frederic  
> wrote:
>>
>>
>> On 08/01/2017 11:30 AM, Edgar E. Iglesias wrote:
>>> At this stage, perhaps we should just register the blocker when this dev
>>> realizes.
>>>
>>> If a request_ptr comes in during migration, the VM will fail either way...
>
>> Yes but this will breaks migration for the spips device everytime
>> and not only when mmio-execution is used?
>
> This line of thought is why I ended up suggesting just disabling
> the exec-in-place feature -- that way we just don't introduce
> what would be a new-in-2.10 feature, rather than breaking something
> that used to work in 2.9.

OK, so what's the plan here? We have several options:
 * just disable exec-from-spips for 2.10 (I sent a patch for that)
 * disable exec-from-spips for 2.10 but with a device x-property
   to allow the user to turn it on again if they really want it
 * this patch or variants on it which try to only disable
   migration if exec-from-spips is actually used by the guest
   (I don't like these because of the awkward corner cases if
   migration and the guest using exec-from-spips happen at the
   same time)

So my current view remains "we should just disable this feature
for 2.10 and we can implement it properly with handling of
migration for 2.11", unless somebody cares enough to implement
the x-property thing within the next day or so.

thanks
-- PMM



Re: [Qemu-devel] [PATCH 09/12] qemu-iotests: do not search for binaries in the current directory

2017-08-10 Thread Markus Armbruster
Paolo Bonzini  writes:

> Looking in the build root is enough.
>
> Signed-off-by: Paolo Bonzini 

It's actually *better*.  I hate it when tests pick up random garbage I
have lying around.



[Qemu-devel] 答复: Re: [PATCH] qemu-iothread: IOThread supports the GMainContext eventloop

2017-08-10 Thread wang.yong155
>Nice.  Just a note, I think an iothread should have its own (optional)

>GMainContext accessed with iothread_get_g_main_context(iothread).  When

>you call it for the first time, the iothread:

>

>1) creates a GMainContext

>

>2) adds the AioContext as a GSource in the GMainContext

>

>3) asks iothread_run to switch from the AioContext loop to the

>GMainContext loop

>

>

>To simplify thread-safety:

>

>1) the GMainContext can be wrapped with a GOnce

>

>2) the GOnce callback can leave steps 2 and 3 to a bottom half.

>

Thanks, I will submit a patch v2.




WangYong






原始邮件



发件人: 
收件人:王勇10170530
抄送人:   王广10165992 
  
 
日 期 :2017年08月10日 16:51
主 题 :Re: [PATCH] qemu-iothread: IOThread supports the GMainContext eventloop







- Original Message -
> From: "Wang yong" 
> To: pbonz...@redhat.com, stefa...@redhat.com, f...@redhat.com, 
> jasow...@redhat.com
> Cc: "wang yong155" , "wang guang55" 
> , "zhangchen fnst"
> , "zhang zhanghailiang" 
> , lizhij...@cn.fujitsu.com,
> qemu-devel@nongnu.org
> Sent: Friday, August 11, 2017 2:29:15 AM
> Subject: [PATCH] qemu-iothread: IOThread supports the GMainContext event loop
> 
> From: Wang Yong
> 
> IOThread uses AioContext event loop and does not run a GMainContext.
> Therefore,chardev cannot work in IOThread,such as the chardev is
> used for colo-compare packets reception.
> 
> This patch makes the IOThread run the GMainContext event loop,
> chardev and IOThread can work together.
> 
> Signed-off-by: Wang Yong
> Signed-off-by: Wang Guang

Nice.  Just a note, I think an iothread should have its own (optional)
GMainContext accessed with iothread_get_g_main_context(iothread).  When
you call it for the first time, the iothread:

1) creates a GMainContext

2) adds the AioContext as a GSource in the GMainContext

3) asks iothread_run to switch from the AioContext loop to the
GMainContext loop


To simplify thread-safety:

1) the GMainContext can be wrapped with a GOnce

2) the GOnce callback can leave steps 2 and 3 to a bottom half.

Paolo

> ---
>  include/sysemu/iothread.h |  1 +
>  iothread.c| 13 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
> index e6da1a4..ffe4e8a 100644
> --- a/include/sysemu/iothread.h
> +++ b/include/sysemu/iothread.h
> @@ -24,6 +24,7 @@ typedef struct {
>  
>  QemuThread thread
>  AioContext *ctx
> +GMainLoop *loop
>  QemuMutex init_done_lock
>  QemuCond init_done_cond/* is thread initialization done? */
>  bool stopping
> diff --git a/iothread.c b/iothread.c
> index beeb870..b6f3c3c 100644
> --- a/iothread.c
> +++ b/iothread.c
> @@ -46,6 +46,7 @@ AioContext *qemu_get_current_aio_context(void)
>  static void *iothread_run(void *opaque)
>  {
>  IOThread *iothread = opaque
> +GMainContext *context
>  
>  rcu_register_thread()
>  
> @@ -57,6 +58,15 @@ static void *iothread_run(void *opaque)
>  
>  while (!atomic_read(>stopping)) {
>  aio_poll(iothread->ctx, true)
> +
> +context = iothread->ctx->source.context
> +if (context) {
> +iothread->loop = g_main_loop_new(context, TRUE)
> +g_main_loop_run(iothread->loop)
> +
> +g_main_loop_unref(iothread->loop)
> +g_main_context_unref(context)
> +}
>  }
>  
>  rcu_unregister_thread()
> @@ -72,6 +82,9 @@ static int iothread_stop(Object *object, void *opaque)
>  return 0
>  }
>  iothread->stopping = true
> +if (iothread->loop) {
> +g_main_loop_quit(iothread->loop)
> +}
>  aio_notify(iothread->ctx)
>  qemu_thread_join(>thread)
>  return 0
> --
> 1.8.3.1
> 
> 
>

Re: [Qemu-devel] [qemu-web PATCH v2] Add a blog post about deprecation of old interfaces and features

2017-08-10 Thread Paolo Bonzini
On 10/08/2017 11:23, Daniel P. Berrange wrote:
> On Thu, Aug 10, 2017 at 10:46:30AM +0200, Thomas Huth wrote:
>> Now that we've got a list of deprecated interfaces/features in the QEMU
>> documentation, it is time to draw some more public attention to our plans
>> of removing certain interfaces/features in future releases.
>>
>> Signed-off-by: Thomas Huth 
>> ---
>>  v2: Use a link to the qemu-doc instead of pointing to the Wiki
>>
>>  _posts/2017-08-10-deprecation.md | 26 ++
>>  1 file changed, 26 insertions(+)
>>  create mode 100644 _posts/2017-08-10-deprecation.md
>>
>> diff --git a/_posts/2017-08-10-deprecation.md 
>> b/_posts/2017-08-10-deprecation.md
>> new file mode 100644
>> index 000..784fb79
>> --- /dev/null
>> +++ b/_posts/2017-08-10-deprecation.md
>> @@ -0,0 +1,26 @@
>> +---
>> +layout: post
>> +title:  "Deprecation of old parameters and features"
>> +date:   2017-08-10 10:45:00 +0200
>> +author: Thomas Huth
>> +categories: [features, 'web site']
>> +---
>> +QEMU has a lot of interfaces (like command line options or HMP commands) and
>> +old features (like certain devices) which are considered as deprecated
>> +since other more generic or better interfaces/features have been established
>> +instead. While the QEMU developers are generally trying to keep each QEMU
>> +release compatible with the previous ones, the old legacy sometimes gets 
>> into
>> +the way when developing new code and/or causes quite some burden of 
>> maintaining
>> +it.
>> +
>> +Thus we are currently considering to get rid of some of the old interfaces
>> +and features in a future release and have started to collect a list of such
>> +old items in our
>> +[QEMU 
>> documentation](https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features).
> 
> Unrelated to your post - it would be nice to have the qemu docs hosted
> on qemu.org, and even nicer if someone figures out how to theme them
> to fit in with the website style instead of being bare black & white
> pages with no navigation :-)

My hope is still to host them on readthedocs sooner or later (though
then they'd have the readthedocs theme).

Paolo



Re: [Qemu-devel] [PATCH v2 2/4] vhost-user-blk: introduce a new vhost-user-blk host device

2017-08-10 Thread Paolo Bonzini
On 09/08/2017 19:10, Michael S. Tsirkin wrote:
> So user specifies properties and
> they get sent to backend at init time. Only handle geometry changes
> specially.

So QEMU would get the configuration, set these properties, and send the
result to the backend via SET_CONFIG?

vhost-user-blk-pci.cyls=uint32
vhost-user-blk-pci.secs=uint32
vhost-user-blk-pci.heads=uint32
vhost-user-blk-pci.serial=str
vhost-user-blk-pci.min_io_size=uint16
vhost-user-blk-pci.opt_io_size=uint32
vhost-user-blk-pci.logical_block_size=uint16
vhost-user-blk-pci.physical_block_size=uint16

If the properties are incompatible (e.g. too small logical block size)
SET_CONFIG fails and QEMU would fail to realize the device.  This makes
sense, I think.

Thanks,

Paolo



Re: [Qemu-devel] [PATCH 18/47] MAINTAINERS: add missing TCG entry

2017-08-10 Thread Peter Maydell
On 9 August 2017 at 22:30, Philippe Mathieu-Daudé  wrote:
> I wonder if I'm understanding correctly what the MAINTAINERS file is for and
> how to use it.
>
> From an submitter view I feel a bit confused. I thought ./get_maintainer.pl
> would give me the list of person to email the changes I did on some file
> from the repository. This script seems correctly named, I'm looking for some
> ./get_reviewers.pl instead, to know who I'v to keep updated, apart from the
> ./get_maintainer.pl.
>
> currently we have:
> "M: Mail patches to: FullName "
> Does this imply FullName is a maintainer?

Does it matter? As a contributor, what you want to know is
"who cares enough about this file to be worth cc'ing, if anybody",
and get_maintainer.pl does that for you.
Hopefully at least one of those people is also in a position
to shepherd the patch through into git master, but that doesn't
affect what you need to do as a patch submitter.
If anybody cares enough about a particular area of the codebase
to want to be cc'd on all patches so they can review them, then
to my mind that makes them effectively a co-maintainer on those
files, and they can be listed in MAINTAINERS.

> If so is it ok I do this change:
>
> -M: Mail patches to: FullName 
> +M: Maintainer: FullName 
> +   These maintainers must be mailed on patches.
>  R: Designated reviewer: FullName 
> These reviewers should be CCed on patches.
>
>
> actual default for un-matched: "recent contributors" + qemu-devel@
>
>   $ ./scripts/get_maintainer.pl -f disas.c
>   get_maintainer.pl: No maintainers found, printing recent contributors.
>   get_maintainer.pl: Do not blindly cc: them on patches!  Use common sense.
>   Peter Maydell  (commit_signer:2/3=67%)
>   Richard Henderson  (commit_signer:1/3=33%)
>   Thomas Huth  (commit_signer:1/3=33%)
>   Michael Tokarev  (commit_signer:1/3=33%)
>   Julian Brown  (commit_signer:1/3=33%)
>   qemu-devel@nongnu.org (open list:All patches CC here)
>
> I find the un-matched "recent contributors" list often confuse, due to files
> being moved, header updated, checkpatch indented.

Yes, the recent-contributors list is often unhelpful, which
is partly why the script warns about them. We might perhaps
switch the default to --no-git-fallback".

> Anyway I now understand these recent contributors are not maintainers but
> no-designated reviewers, unwilling to be maintainers (else they'd have added
> a section/entry by themselves).

They're just people who touched a file more often, that's all;
the script does a little of the git log mining for you in
case it's useful (often it isn't).

The underlying problem, as Cornelia points out, is that some
parts of QEMU have no maintainer at all, or have a theoretical
maintainer who in practice doesn't these days have enough time
to do code reviews very promptly, or have a email listed that
actually bounces because they changed employer 3 years ago and
stopped working on QEMU, etc. Changing wording in the
MAINTAINERS file is not going to help with this :-(

thanks
-- PMM



Re: [Qemu-devel] 答复: Re: [PATCH] qemu-iothread: IOThread supports the GMainContext eventloop

2017-08-10 Thread Paolo Bonzini
On 10/08/2017 11:17, wang.yong...@zte.com.cn wrote:
>> Nice.  Just a note, I think an iothread should have its own (optional)
> 
>> GMainContext accessed with iothread_get_g_main_context(iothread).  When
> 
>> you call it for the first time, the iothread:
> 
>>
> 
>> 1) creates a GMainContext
> 
>>
> 
>> 2) adds the AioContext as a GSource in the GMainContext
> 
>>
> 
>> 3) asks iothread_run to switch from the AioContext loop to the
> 
>> GMainContext loop
> 
>>
> 
>>
> 
>> To simplify thread-safety:
> 
>>
> 
>> 1) the GMainContext can be wrapped with a GOnce
> 
>>
> 
>> 2) the GOnce callback can leave steps 2 and 3 to a bottom half.
> 
>>
> 
> Thanks, I will submit a patch v2.
> 
> 
> 
> 
> WangYong
> 
> 
> 
> 
> 
> 
> 原始邮件
> 
> 
> 
> 发件人: 
> 收件人:王勇10170530
> 抄送人:   王广10165992 
>   
>  
> 日 期 :2017年08月10日 16:51
> 主 题 :Re: [PATCH] qemu-iothread: IOThread supports the GMainContext eventloop
> 
> 
> 
> 
> 
> 
> 
> - Original Message -
>> From: "Wang yong" 
>> To: pbonz...@redhat.com, stefa...@redhat.com, f...@redhat.com, 
>> jasow...@redhat.com
>> Cc: "wang yong155" , "wang guang55" 
>> , "zhangchen fnst"
>> , "zhang zhanghailiang" 
>> , lizhij...@cn.fujitsu.com,
>> qemu-devel@nongnu.org
>> Sent: Friday, August 11, 2017 2:29:15 AM
>> Subject: [PATCH] qemu-iothread: IOThread supports the GMainContext event loop
>>
>> From: Wang Yong
>>
>> IOThread uses AioContext event loop and does not run a GMainContext.
>> Therefore,chardev cannot work in IOThread,such as the chardev is
>> used for colo-compare packets reception.
>>
>> This patch makes the IOThread run the GMainContext event loop,
>> chardev and IOThread can work together.
>>
>> Signed-off-by: Wang Yong
>> Signed-off-by: Wang Guang
> 
> Nice.  Just a note, I think an iothread should have its own (optional)
> GMainContext accessed with iothread_get_g_main_context(iothread).  When
> you call it for the first time, the iothread:
> 
> 1) creates a GMainContext
> 
> 2) adds the AioContext as a GSource in the GMainContext
> 
> 3) asks iothread_run to switch from the AioContext loop to the
> GMainContext loop
> 
> 
> To simplify thread-safety:
> 
> 1) the GMainContext can be wrapped with a GOnce
> 
> 2) the GOnce callback can leave steps 2 and 3 to a bottom half.

Thanks.  Another thing, please add a call to
g_main_context_push_thread_default() and
g_main_context_pop_thread_default().

Thanks,

Paolo

>> ---
>>  include/sysemu/iothread.h |  1 +
>>  iothread.c| 13 +
>>  2 files changed, 14 insertions(+)
>>
>> diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
>> index e6da1a4..ffe4e8a 100644
>> --- a/include/sysemu/iothread.h
>> +++ b/include/sysemu/iothread.h
>> @@ -24,6 +24,7 @@ typedef struct {
>>  
>>  QemuThread thread
>>  AioContext *ctx
>> +GMainLoop *loop
>>  QemuMutex init_done_lock
>>  QemuCond init_done_cond/* is thread initialization done? */
>>  bool stopping
>> diff --git a/iothread.c b/iothread.c
>> index beeb870..b6f3c3c 100644
>> --- a/iothread.c
>> +++ b/iothread.c
>> @@ -46,6 +46,7 @@ AioContext *qemu_get_current_aio_context(void)
>>  static void *iothread_run(void *opaque)
>>  {
>>  IOThread *iothread = opaque
>> +GMainContext *context
>>  
>>  rcu_register_thread()
>>  
>> @@ -57,6 +58,15 @@ static void *iothread_run(void *opaque)
>>  
>>  while (!atomic_read(>stopping)) {
>>  aio_poll(iothread->ctx, true)
>> +
>> +context = iothread->ctx->source.context
>> +if (context) {
>> +iothread->loop = g_main_loop_new(context, TRUE)
>> +g_main_loop_run(iothread->loop)
>> +
>> +g_main_loop_unref(iothread->loop)
>> +g_main_context_unref(context)
>> +}
>>  }
>>  
>>  rcu_unregister_thread()
>> @@ -72,6 +82,9 @@ static int iothread_stop(Object *object, void *opaque)
>>  return 0
>>  }
>>  iothread->stopping = true
>> +if (iothread->loop) {
>> +g_main_loop_quit(iothread->loop)
>> +}
>>  aio_notify(iothread->ctx)
>>  qemu_thread_join(>thread)
>>  return 0
>> --
>> 1.8.3.1
>>
>>
>>
> 




Re: [Qemu-devel] [PATCH v4 15/22] libqtest: Delete qtest_qmp() wrappers

2017-08-10 Thread Markus Armbruster
Eric Blake  writes:

> On 08/09/2017 10:34 AM, Markus Armbruster wrote:
>> Eric Blake  writes:
>> 
>>> None of our tests were directly using qtest_qmp() and friends;
>>> even tests like postcopy-test.c that manage multiple connections
>>> get along just fine changing global_qtest as needed (other than
>>> one callsite where it forgot to use the inlined form).  It's
>>> also annoying that we have qmp_async() but qtest_async_qmp(),
>>> with inconsistent naming for tracing through the wrappers.
>>>
>
>> What about all the other functions taking a QTestState?  Aren't they
>> just as silly?
>
> What's left after this patch:
>
> - qtest_init()
>   qtest_init_without_qmp_handshake()
>   qtest_quit()
> necessary for setting up parallel state.

"Necessary" is too strong, as you could use qtest_start(); save
global_qtest; qtest_start(); ... qtest_end(); restore global_qtest;
qtest_end().  But I could buy convenient.

> and then a lot of functions that have static inline wrappers (for
> example, qmp_receive(), inb(), ...).
>
> So yes, I could additionally get rid of more wrappers and have even more
> functions implicitly depend on global_qtest.
>
>> Having two of every function is tiresome, but consistent.
>> 
>> Having just one is easier to maintain, so if it serves our needs,
>> possibly with the occasional state switch, I like it.
>> 
>> What I don't like is a mix of the two.
>
> Okay, I'll prune even harder in the next revision.  Deleting cruft is fun!

Yes, please!

>>> +++ b/tests/libqtest.c
>>> @@ -233,9 +233,10 @@ QTestState *qtest_init(const char *extra_args)
>>>  QDict *greeting;
>>>
>>>  /* Read the QMP greeting and then do the handshake */
>>> -greeting = qtest_qmp_receive(s);
>>> +greeting = qmp_fd_receive(s->qmp_fd);
>> 
>> Why doesn't this become qmp_receive()?
>
> Because in THIS version of the patch, qmp_receive() is still a static
> inline wrapper that calls qtest_qmp_receive(global_qtest) - but
> global_qtest is not set here.  (If I delete qtest_qmp_receive() and have
> qmp_receive() not be static inline, then we STILL want to operate
> directly on the just-created s->qmp_fd rather than assuming that
> global_qtest == s, when in the body of qtest_init).
>
>>> @@ -446,7 +447,7 @@ QDict *qtest_qmp_receive(QTestState *s)
>>>   * Internal code that converts from interpolated JSON into a message
>>>   * to send over the wire, without waiting for a reply.
>>>   */
>>> -static void qmp_fd_sendv(int fd, const char *fmt, va_list ap)
>>> +static void qtest_qmp_sendv(QTestState *s, const char *fmt, va_list ap)
>> 
>> Why this move in the other direction?
>
> Because it fixes the disparity you pointed out in 12/22 about
> qmp_fd_sendv() no longer being a sane pairing to qmp_fd_send(), AND
> because I needed the .../va_list pairing to work in order for...
>
>>> -char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)
>>> +static char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)
>>>  {
>>>  char *cmd;
>>>  QDict *resp;
>>>  char *ret;
>>>
>>>  cmd = g_strdup_vprintf(fmt, ap);
>>> -resp = qtest_qmp(s, "{'execute': 'human-monitor-command',"
>>> - " 'arguments': {'command-line': %s}}",
>>> - cmd);
>>> +qtest_qmp_send(s, "{'execute': 'human-monitor-command',"
>>> +   " 'arguments': {'command-line': %s}}", cmd);
>>> +resp = qtest_qmp_receive(s);
>
> ...this to work.  So now my sane pairing is
> qtest_qmp_send()/qtest_qmp_sendv() - although your argument that
> qtest_qmp_sendf() might have been a nicer name for the ... form may
> still have merit - at least any time the sendv() form is in a public
> header.  Then again, by the end of the series, I managed to get rid of
> all va_list in libqtest.h, needing it only in libqtest.c.

This is all quite confusing to me right now.  I trust I'll do better
with v2.

>>> @@ -889,7 +854,7 @@ void qmp_async(const char *fmt, ...)
>>>  va_list ap;
>>>
>>>  va_start(ap, fmt);
>>> -qtest_async_qmpv(global_qtest, fmt, ap);
>>> +qtest_qmp_sendv(global_qtest, fmt, ap);
>>>  va_end(ap);
>>>  }
>> 
>> Hmm.  Before this patch, qmp_async() is the ... buddy of va_list
>> qmp_fd_sendv().  If we keep qmp_fd_sendv(), they should be named
>> accordingly.
>
> What name to use, though?  By the end of the series, we have
> qmp_async(...) but no public va_list form.

Discussed later in the thread.



[Qemu-devel] [PATCH for-2.10] qemu-doc: Mention host_net_add/-remove in the deprecation chapter

2017-08-10 Thread Thomas Huth
The two HMP commands host_net_add and -remove have recently been
marked as deprecated, too, so we should now mention them in the
chapter of deprecated features.

Signed-off-by: Thomas Huth 
---
 qemu-doc.texi | 8 
 1 file changed, 8 insertions(+)

diff --git a/qemu-doc.texi b/qemu-doc.texi
index aeb7bc5..7b62fdf 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -3283,6 +3283,14 @@ by the ``convert -l snapshot_param'' argument instead.
 
 @section System emulator human monitor commands
 
+@subsection host_net_add (since 2.10.0)
+
+The ``host_net_add'' command is replaced by the ``netdev_add'' command.
+
+@subsection host_net_remove (since 2.10.0)
+
+The ``host_net_remove'' command is replaced by the ``host_net_remove'' command.
+
 @subsection usb_add (since 2.10.0)
 
 The ``usb_add'' command is replaced by the ``device_add'' command.
-- 
1.8.3.1




[Qemu-devel] [PATCH v2 for-2.10] qemu-doc: Mention host_net_add/-remove in the deprecation chapter

2017-08-10 Thread Thomas Huth
The two HMP commands host_net_add and -remove have recently been
marked as deprecated, too, so we should now mention them in the
chapter of deprecated features.

Signed-off-by: Thomas Huth 
---
 qemu-doc.texi | 8 
 1 file changed, 8 insertions(+)

diff --git a/qemu-doc.texi b/qemu-doc.texi
index aeb7bc5..7b62fdf 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -3283,6 +3283,14 @@ by the ``convert -l snapshot_param'' argument instead.
 
 @section System emulator human monitor commands
 
+@subsection host_net_add (since 2.10.0)
+
+The ``host_net_add'' command is replaced by the ``netdev_add'' command.
+
+@subsection host_net_remove (since 2.10.0)
+
+The ``host_net_remove'' command is replaced by the ``netdev_del'' command.
+
 @subsection usb_add (since 2.10.0)
 
 The ``usb_add'' command is replaced by the ``device_add'' command.
-- 
1.8.3.1




[Qemu-devel] [PATCH] file-posix: Clear out first sector in hdev_create

2017-08-10 Thread Fam Zheng
People get surprised when, after "qemu-imc create -f raw /dev/sdX", they
still see qcow2 with "qemu-img info", if previously the bdev had a qcow2
header. While this is natural because raw doesn't need to write any
magic bytes during creation, hdev_create is free to clear out the first
sector to make sure the stale qcow2 header doesn't cause such a
confusion.

Signed-off-by: Fam Zheng 
---
 block/file-posix.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/block/file-posix.c b/block/file-posix.c
index f4de022ae0..1d8ef6f873 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2703,6 +2703,17 @@ static int hdev_create(const char *filename, QemuOpts 
*opts,
 ret = -ENOSPC;
 }
 
+if (total_size) {
+int64_t zero_size = MIN(BDRV_SECTOR_SIZE, total_size);
+uint8_t *buf;
+if (lseek(fd, 0, SEEK_SET) == -1) {
+ret = -errno;
+} else {
+buf = g_malloc0(zero_size);
+ret = qemu_write_full(fd, buf, zero_size);
+g_free(buf);
+}
+}
 qemu_close(fd);
 return ret;
 }
-- 
2.13.3




Re: [Qemu-devel] [RFC PATCH 01/56] qobject: Touch up comments to say @param instead of 'param'

2017-08-10 Thread Markus Armbruster
Eric Blake  writes:

> On 08/07/2017 09:45 AM, Markus Armbruster wrote:
>> Signed-off-by: Markus Armbruster 
>> ---
>>  qobject/qdict.c | 68 
>> -
>>  qobject/qlist.c |  2 +-
>>  2 files changed, 35 insertions(+), 35 deletions(-)
>> 
>> diff --git a/qobject/qdict.c b/qobject/qdict.c
>> index 576018e..d795079 100644
>> --- a/qobject/qdict.c
>> +++ b/qobject/qdict.c
>> @@ -116,13 +116,13 @@ static QDictEntry *qdict_find(const QDict *qdict,
>>  /**
>>   * qdict_put_obj(): Put a new QObject into the dictionary
>>   *
>> - * Insert the pair 'key:value' into 'qdict', if 'key' already exists
>> - * its 'value' will be replaced.
>> + * Insert the pair @key:@value into @qdict, if @key already exists
>> + * its value will be replaced.
>
> Maybe s/,/;/ while at it.

Or even *gasp* a period.

> Reviewed-by: Eric Blake 

Thanks!



Re: [Qemu-devel] [PATCH v2 0/3] Qemu: Add Xen vIOMMU interrupt remapping function support

2017-08-10 Thread Paolo Bonzini
On 09/08/2017 22:51, Lan Tianyu wrote:
> This patchset is to deal with MSI interrupt remapping request when guest
> updates MSI registers.
> 
> Chao Gao (3):
>   i386/msi: Correct mask of destination ID in MSI address
>   xen-pt: bind/unbind interrupt remapping format MSI
>   msi: Handle remappable format interrupt request
> 
>  configure |  4 +++-
>  hw/i386/xen/xen-hvm.c |  8 ++-
>  hw/pci/msi.c  |  5 +++--
>  hw/pci/msix.c |  4 +++-
>  hw/xen/xen_pt_msi.c   | 52 
> +++
>  include/hw/i386/apic-msidef.h |  3 ++-
>  include/hw/xen/xen.h  |  2 +-
>  include/hw/xen/xen_common.h   | 25 +
>  stubs/xen-hvm.c   |  2 +-
>  9 files changed, 83 insertions(+), 22 deletions(-)
> 

Non-Xen parts look good (though I cannot ack them).

Paolo



Re: [Qemu-devel] [qemu-web PATCH v2] Add a blog post about deprecation of old interfaces and features

2017-08-10 Thread Paolo Bonzini
On 10/08/2017 10:46, Thomas Huth wrote:
> Now that we've got a list of deprecated interfaces/features in the QEMU
> documentation, it is time to draw some more public attention to our plans
> of removing certain interfaces/features in future releases.
> 
> Signed-off-by: Thomas Huth 
> ---
>  v2: Use a link to the qemu-doc instead of pointing to the Wiki
> 
>  _posts/2017-08-10-deprecation.md | 26 ++
>  1 file changed, 26 insertions(+)
>  create mode 100644 _posts/2017-08-10-deprecation.md
> 
> diff --git a/_posts/2017-08-10-deprecation.md 
> b/_posts/2017-08-10-deprecation.md
> new file mode 100644
> index 000..784fb79
> --- /dev/null
> +++ b/_posts/2017-08-10-deprecation.md
> @@ -0,0 +1,26 @@
> +---
> +layout: post
> +title:  "Deprecation of old parameters and features"
> +date:   2017-08-10 10:45:00 +0200
> +author: Thomas Huth
> +categories: [features, 'web site']
> +---
> +QEMU has a lot of interfaces (like command line options or HMP commands) and
> +old features (like certain devices) which are considered as deprecated
> +since other more generic or better interfaces/features have been established
> +instead. While the QEMU developers are generally trying to keep each QEMU
> +release compatible with the previous ones, the old legacy sometimes gets into
> +the way when developing new code and/or causes quite some burden of 
> maintaining
> +it.
> +
> +Thus we are currently considering to get rid of some of the old interfaces
> +and features in a future release and have started to collect a list of such
> +old items in our
> +[QEMU 
> documentation](https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features).
> +If you are running QEMU directly, please have a look at this deprecation
> +chapter of the QEMU documentation to see whether you are still using one of
> +these old interfaces or features, so you can adapt your setup to use the new
> +interfaces/features instead. Or if you rather think that one of the items
> +should *not* be removed from QEMU at all, please speak up on the
> +[qemu-devel mailing list](http://wiki.qemu.org/Contribute/MailingLists)
> +to explain why the interface or feature is still required.
> 

Pushed, thanks.

Paolo



Re: [Qemu-devel] [PATCH 18/47] MAINTAINERS: add missing TCG entry

2017-08-10 Thread Paolo Bonzini
On 10/08/2017 11:35, Peter Maydell wrote:
>> actual default for un-matched: "recent contributors" + qemu-devel@
>>
>>   $ ./scripts/get_maintainer.pl -f disas.c
>>   get_maintainer.pl: No maintainers found, printing recent contributors.
>>   get_maintainer.pl: Do not blindly cc: them on patches!  Use common sense.
>>   Peter Maydell  (commit_signer:2/3=67%)
>>   Richard Henderson  (commit_signer:1/3=33%)
>>   Thomas Huth  (commit_signer:1/3=33%)
>>   Michael Tokarev  (commit_signer:1/3=33%)
>>   Julian Brown  (commit_signer:1/3=33%)
>>   qemu-devel@nongnu.org (open list:All patches CC here)
>>
>> I find the un-matched "recent contributors" list often confuse, due to files
>> being moved, header updated, checkpatch indented.
> 
> Yes, the recent-contributors list is often unhelpful, which
> is partly why the script warns about them. We might perhaps
> switch the default to --no-git-fallback".

Note that if a patch touches both maintained and unmaintained files, the
recent contributors list is omitted:

$ scripts/get_maintainer.pl -f util/cutils.c hw/ide/core.c
John Snow  (supporter:IDE)
qemu-devel@nongnu.org (open list:All patches CC here)
qemu-bl...@nongnu.org (open list:IDE)

"--no-git-fallback" is probably the right thing to do when sending a
patch series.  The maintainer that shepherds the series will take care
of unmaintained files too.

However, when sending a single patch to an unmaintained file the
contributors list usually does get the patch to the inbox of a
maintainer.  This increases the odds of getting someone's attention.
Because inexperienced contributors usually don't send large series, my
feeling is that overall "--git-fallback"'s advantage are more than the
disadvantages, especially with the above logic that was introduced in
commit c6561586f0 ("get_maintainer.pl: restrict cases where it falls
back to --git", 2014-10-23).

Paolo



Re: [Qemu-devel] [PATCH v2 0/3] Qemu: Add Xen vIOMMU interrupt remapping function support

2017-08-10 Thread Lan Tianyu
On 2017年08月10日 17:04, Paolo Bonzini wrote:
> On 09/08/2017 22:51, Lan Tianyu wrote:
>> This patchset is to deal with MSI interrupt remapping request when guest
>> updates MSI registers.
>>
>> Chao Gao (3):
>>   i386/msi: Correct mask of destination ID in MSI address
>>   xen-pt: bind/unbind interrupt remapping format MSI
>>   msi: Handle remappable format interrupt request
>>
>>  configure |  4 +++-
>>  hw/i386/xen/xen-hvm.c |  8 ++-
>>  hw/pci/msi.c  |  5 +++--
>>  hw/pci/msix.c |  4 +++-
>>  hw/xen/xen_pt_msi.c   | 52 
>> +++
>>  include/hw/i386/apic-msidef.h |  3 ++-
>>  include/hw/xen/xen.h  |  2 +-
>>  include/hw/xen/xen_common.h   | 25 +
>>  stubs/xen-hvm.c   |  2 +-
>>  9 files changed, 83 insertions(+), 22 deletions(-)
>>
> 
> Non-Xen parts look good (though I cannot ack them).
> 
> Paolo
> 

Never minder. Thanks for your review.

-- 
Best regards
Tianyu Lan



Re: [Qemu-devel] [Qemu-block] [PATCH 01/12] qemu-iotests: remove dead code

2017-08-10 Thread Paolo Bonzini
On 10/08/2017 00:18, Eric Blake wrote:
> On 08/09/2017 04:54 PM, Paolo Bonzini wrote:
>> This includes shell function, shell variables, command line options
>> (randomize.awk does not exist) and conditions that can never be true
>> (./qemu does not exist anymore).
> 
> Can we point to a commit id where we stopped making ./qemu?  Is it still
> worth supporting a local symlink?
> 
>>
>> Signed-off-by: Paolo Bonzini 
>> ---
>>  tests/qemu-iotests/check | 36 +
>>  tests/qemu-iotests/common| 23 --
>>  tests/qemu-iotests/common.config | 26 ---
>>  tests/qemu-iotests/common.rc | 68 
>> 
>>  4 files changed, 1 insertion(+), 152 deletions(-)
>>
>> -#
>> -# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
> 
> Good riddance to the wrong word ('which' was intended)
> 
> Other than possibly still wanting ./qemu convenience, this looks like a
> reasonable cleanup.

In my reply yesterday, I forgot to note that the other current-directory
searches go away in patch 9 anyway. :)

Paolo



Re: [Qemu-devel] No video for Windows 2000 guest

2017-08-10 Thread Michael Tokarev
10.08.2017 06:51, Thomas Huth wrote:
[]

> I guess you'll end up with QEMU 2.1 as good version and 2.2 as the first
> "bad" version. According the qemu-doc:
> 
> -vga type
> 
> Select type of VGA card to emulate. Valid values for type are
> 
> cirrus
> 
> Cirrus Logic GD5446 Video card. All Windows versions starting
> from Windows 95 should recognize and use this graphic card. For
> optimal performances, use 16 bit color depth in the guest and
> the host OS. (This card was the default before QEMU 2.2)
> 
> std
> 
> Standard VGA card with Bochs VBE extensions. If your guest OS
> supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if
> you want to use high resolution modes (>= 1280x1024x16) then you
> should use this option. (This card is the default since QEMU
> 2.2)

Both cirrus and stdvga worked in Win2k not-so-recently. Cirrus, IIRC,
required a driver install, stdvga used "standard vga controller" which,
in win2k, was always marked with yellow exclamation mark, just because
the driver itself always sets that mark, "thinking" it is always wrong
driver.

So no, it's not the switch from cirrus to std, it's something else.

/mjt



Re: [Qemu-devel] [PATCH v4 17/22] libqtest: Add qmp_args() helper

2017-08-10 Thread Markus Armbruster
Eric Blake  writes:

> On 08/09/2017 10:57 AM, Markus Armbruster wrote:
>
>> I don't like the qmp_args name.  It's not about arguments, it's about
>> sending a command with arguments.
>> 
>> I'm afraid I'm getting pretty thorougly confused by the evolving
>> interface.  So I stop and think how it should look like when done.
>
> At a bare minimum, I like your idea that we want:
>
> FOO_send() # sends a message, does not wait for a reply
> FOO_receive()  # reads one JSON object, returns QObject counterpart
> FOO() # combo of FOO_send() and FOO_receive()
>
> Then FOO_discard() is a convenient shorthand for QDECREF(FOO_receive()).

Yes.

Obvious names for the variations of FOO_send():

FOO_send()send a string exactly as is
FOO_sendf()   build a string from a template, interpolating from ...
FOO_vsendf()  ditto, interpolating from va_list

Since "send string exactly as is" is uncommon, using a longer name for
it would be okay.  Say FOO_send_string() or FOO_send_raw().

> Which FOO do we need? Right now, we have 'qmp' for anything using the
> global_qtest, 'qtest_qmp' for anything using an explicit QTestState (but
> we're arguing that is overkill), and 'qmp_fd' for anything using a raw
> fd (test-qga.c - and where I added 'qga' in 11/22, although that
> addition was local rather than in libqtest.h).

'qmp', 'qtest_qmp' and 'qmp_fd' sounds good.  I hope we can get rid of
'qtest_qmp'.

> I also just had an insight: it is possible to write a macro
> qmp_send(...) that will expand to qmp_send_cmd(name) if there is only
> one argument, but to qmp_send_cmdf(name, fmt, ...) if there is more than
> one argument (and later expose a public qmp_send_cmdv(name, fmt,
> va_list) as pair if it is needed, although right now it is not).
> Perhaps we can even make the one-arg form expand to qmp_send_cmdf(name,
> " "), if that's enough to silence gcc's -Wformat-zero-length, and if our
> underlying routines are smart enough to recognize a single-space
> argument as not being worthy of calling qobject_from_jsonf() (since
> qobject_from_jsonf() aborts rather than returning NULL when presented
> just whitespace).
>
> In fact, having a macro qmp_send(cmd, ...) expand to
> qmp_send_internal(cmd, " " __VA_ARGS__) might even do the trick without
> preprocessor magic of checking whether __VA_ARGS__ contains a comma
> (although it has the subtle limitation that if present, a format
> argument MUST be a string literal because we now rely on string
> concatenation with " " - although given gcc's -Wformat-nonliteral, we
> are probably okay with that limitation).
>
> So, with a nice macro, the bulk of the testsuite would just write in
> this style:
>
> qmp_send("foo");
> qmp_send("foo", "{literal_args...}");
> qmp_send("foo", "{'name':%s}", value);
>
> for send without waiting, or:
>
> obj = qmp("foo");
> obj = qmp(foo", "{literal_args...}");
> obj = qmp("foo", "{'name':%s}", value);
>
> where the result matters.  And the names we choose for internal
> implementation are no longer quite as important (although still helpful
> to get right).

Play with it, and we'll see how it turns out.

>> We need send and receive.  Convenience functions to do both, and to
>> receive and throw away are nice to have.
>
> Do we want both a convenience function to throw away a single read, AND
> a function to send a command + throw away a read? Prior to this series,
> we have qmp_discard_response() which is send + discard, but nothing that
> does plain discard; although plain discard is a better building block
> (precisely because then we don't have to duplicate all the different
> send forms) - the convenience of send+receive in one call should be
> limited to the most common case.

The interface should provide the basic building blocks.

Convenience functions are welcome when they help the interface' users
write clearer code.  Less code is often clearer code.

> Also, the qmp_eventwait() is a nice convenience function for wait in a
> loop until the received object matches a given name; whether we also
> need the convenience of qmp_eventwait_ref() is a bit more debatable
> (perhaps we could just as easily have qmp_event_wait() always return an
> object, and require the caller to QDECREF() it, for one less function to
> maintain).

See previous paragraph :)

>> We need qmp_raw().  We haven't found a need for a raw receive function.
>
> Yes, qmp_raw() (or maybe it should be named qmp_send_raw(), depending on
> whether the receive is coupled with it?) is our backdoor for sending
> JSON that does not match the normal {'execute':'name','arguments':{}}
> paradigm (and pretty much qmp-test.c, or maybe also test-qga.c, would be
> the only clients).

A "send raw and receive cooked" function feels slightly weird.  Since
it's used only rarely, we might want to avoid the weirdness and use a
pair of calls there.

Apropos raw vs. cooked: the "send cooked" functions convert single
quotes in the template to double quotes.  The "send raw" functions

Re: [Qemu-devel] [PATCH 2/2] file-posix: Do runtime check for ofd lock API

2017-08-10 Thread Christian Ehrhardt
On Fri, Jul 21, 2017 at 2:36 PM, Eric Blake  wrote:

> On 07/21/2017 05:20 AM, Fam Zheng wrote:
> > It is reported that on Windows Subsystem for Linux, ofd operations fail
> > with -EINVAL. In other words, QEMU binary built with system headers that
> > exports F_OFD_SETLK doesn't necessarily run in an environment that
> > actually supports it:
> >
> > $ qemu-system-aarch64 ... -drive file=test.vhdx,if=none,id=hd0 \
> > -device virtio-blk-pci,drive=hd0
> > qemu-system-aarch64: -drive file=test.vhdx,if=none,id=hd0: Failed to
> unlock byte 100
> > qemu-system-aarch64: -drive file=test.vhdx,if=none,id=hd0: Failed to
> unlock byte 100
> > qemu-system-aarch64: -drive file=test.vhdx,if=none,id=hd0: Failed to
> lock byte 100
> >
> > Let's do a runtime check to cope with that.
>
> You may want to mention that the same is possible on a system with old
> kernel but new glibc (ie. this issue is not necessarily specific to WSL).
>

I first thought that this combination hitting me as I run KVM in containers
which can diverge glibc (in container) a lot from kernel (in host).

My issue turned out to be an apparmor block instead.
But since I clearly see how my case could lead to the mentioned
old kernel but new glibc I wanted to ping here to refresh/reconsider
this change as well.

Also the reply might be worth as documentation if people search for the
error
message and get here that the following apparmor block leads to the same.

apparmor="DENIED" operation="file_lock"
namespace="root//lxd-testkvm-artful-from_"
profile="libvirt-f687a9b3-5bca-41bc-b206-6e616720cc5e"
name="/var/lib/uvtool/libvirt/images/kvmguest-artful-normal.qcow" pid=7001
comm="qemu-system-x86" requested_mask="k" denied_mask="k" fsuid=0 ouid=0

I'll work on libvirt's virt-aa-helper to generate a rule appropriate for
the new behavior.


Re: [Qemu-devel] make check-help not working

2017-08-10 Thread Fam Zheng
On Fri, 07/28 20:56, Philippe Mathieu-Daudé wrote:
> I'm a bit lost with this error:
> 
> (master)$ make check-help V=1
> cc -nostdlib  -o check-help.mo
> cc: fatal error: no input files
> compilation terminated.
> rules.mak:115: recipe for target 'check-help.mo' failed
> make: *** [check-help.mo] Error 1

I think this is because in Makefile:

ifneq ($(wildcard config-host.mak),)
include $(SRC_PATH)/tests/Makefile.include
endif

which basically means only include that file, which contains the "check-help"
rule, after configure.

We can move that ifned/endif pair down to tests/Makefile.include and move
check-help out of it.

I'll send a patch for it.

Fam



Re: [Qemu-devel] [PATCH 18/47] MAINTAINERS: add missing TCG entry

2017-08-10 Thread Cornelia Huck
On Wed, 9 Aug 2017 18:30:25 -0300
Philippe Mathieu-Daudé  wrote:

> [I added mails of other person who reply to this series, this mail is 
> not directly addressed to Alex]

Hey, a maintainership discussion! I don't think we had one before 8)

> 
> On 08/09/2017 11:38 AM, Alex Bennée wrote:
> > Philippe Mathieu-Daudé  writes:  
> [...]
> >> Do you think there should be another entry in "Block QAPI, monitor,
> >> command line"?
> >> or this file (and related include) rather deserves an own section
> >> (possibly tagged Odd Fixes) to unburden Richard?  
> > 
> > Well the default for un-matched files is qemu-devel right? It would be
> > nice for it to be properly maintained but that requires someone to
> > step-up to the plate.  
> 
> I wonder if I'm understanding correctly what the MAINTAINERS file is for 
> and how to use it.

The blurb at the start of MAINTAINERS should describe this; I'm
wondering how much it reflects current reality, though (the 'ownership'
part).

> 
>  From an submitter view I feel a bit confused. I thought 
> ./get_maintainer.pl would give me the list of person to email the 
> changes I did on some file from the repository. This script seems 
> correctly named, I'm looking for some ./get_reviewers.pl instead, to 
> know who I'v to keep updated, apart from the ./get_maintainer.pl.
> 
> currently we have:
> "M: Mail patches to: FullName "
> Does this imply FullName is a maintainer?
> If so is it ok I do this change:
> 
> -M: Mail patches to: FullName 
> +M: Maintainer: FullName 
> +   These maintainers must be mailed on patches.

This line seems to have originally come from the Linux kernel's
MAINTAINERS file. But I like your version better.

>   R: Designated reviewer: FullName 
>  These reviewers should be CCed on patches.

I'm wondering whether we need some more detailed descriptions about the
roles of maintainers and reviewers, i.e.
- maintainers are responsible for an area; they review and pick up
  patches; a non-trivial patch merged through someone else needs at
  least an ack from them
- reviewers are interested in an area, the entries are mostly there so
  that they are sure to get cc:ed on patches; while their feedback
  (like everyone's) is valued, it is not essential to getting a change
  merged

> 
> 
> actual default for un-matched: "recent contributors" + qemu-devel@
> 
>$ ./scripts/get_maintainer.pl -f disas.c
>get_maintainer.pl: No maintainers found, printing recent contributors.
>get_maintainer.pl: Do not blindly cc: them on patches!  Use common sense.
>Peter Maydell  (commit_signer:2/3=67%)
>Richard Henderson  (commit_signer:1/3=33%)
>Thomas Huth  (commit_signer:1/3=33%)
>Michael Tokarev  (commit_signer:1/3=33%)
>Julian Brown  (commit_signer:1/3=33%)
>qemu-devel@nongnu.org (open list:All patches CC here)
> 
> I find the un-matched "recent contributors" list often confuse, due to 
> files being moved, header updated, checkpatch indented.
> Most of the time you get the list of queue maintainers since they accept 
> patches and sign-of the pull request.
> 
> Having to use 'git log --follow' and 'git blame' to figure out is not 
> bad, to be aware of who modified this file before you, but there are 
> some files I already hit 3 times in different series, and wondered about 
> how avoid those manual steps.
> 
> Anyway I now understand these recent contributors are not maintainers 
> but no-designated reviewers, unwilling to be maintainers (else they'd 
> have added a section/entry by themselves).

The root problem is "some files have no maintainers". The reasons range
from "forgot to include the file in the pattern" (easily fixed), over
"file is updated via a script" (the linux-headers case), to "nobody
feels up to the task" (which is the worst case).

In most cases, I don't think the recent contributors list is very
helpful. Somebody who simply did a tree-wide rename is unlikely to be
able to make a good judgment about a complicated logic change. Just
printing qemu-devel as the address to send this to is probably better;
unfortunately, it may cause patches to languish on the list if nobody
takes pity on them.

Do we need someone collecting non-trivial patches like that, who either
pesters others or picks up the patches themselves?

> 
> I also understand why Fam said it sounds weird to add an new section as 
> "Orphan".
> 
> For the linux-headers case, if people want to be notified of changes the 
> easiest seems to modify the update-linux-headers.sh script.

The approach I like the most for this is to add a pattern that covers
both the script and the directories updated by it. If someone
explicitly wants notifications for header changes that are used by
their code, they can add it to their files as well, but I 

[Qemu-devel] [qemu-web PATCH v2] Add a blog post about deprecation of old interfaces and features

2017-08-10 Thread Thomas Huth
Now that we've got a list of deprecated interfaces/features in the QEMU
documentation, it is time to draw some more public attention to our plans
of removing certain interfaces/features in future releases.

Signed-off-by: Thomas Huth 
---
 v2: Use a link to the qemu-doc instead of pointing to the Wiki

 _posts/2017-08-10-deprecation.md | 26 ++
 1 file changed, 26 insertions(+)
 create mode 100644 _posts/2017-08-10-deprecation.md

diff --git a/_posts/2017-08-10-deprecation.md b/_posts/2017-08-10-deprecation.md
new file mode 100644
index 000..784fb79
--- /dev/null
+++ b/_posts/2017-08-10-deprecation.md
@@ -0,0 +1,26 @@
+---
+layout: post
+title:  "Deprecation of old parameters and features"
+date:   2017-08-10 10:45:00 +0200
+author: Thomas Huth
+categories: [features, 'web site']
+---
+QEMU has a lot of interfaces (like command line options or HMP commands) and
+old features (like certain devices) which are considered as deprecated
+since other more generic or better interfaces/features have been established
+instead. While the QEMU developers are generally trying to keep each QEMU
+release compatible with the previous ones, the old legacy sometimes gets into
+the way when developing new code and/or causes quite some burden of maintaining
+it.
+
+Thus we are currently considering to get rid of some of the old interfaces
+and features in a future release and have started to collect a list of such
+old items in our
+[QEMU 
documentation](https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features).
+If you are running QEMU directly, please have a look at this deprecation
+chapter of the QEMU documentation to see whether you are still using one of
+these old interfaces or features, so you can adapt your setup to use the new
+interfaces/features instead. Or if you rather think that one of the items
+should *not* be removed from QEMU at all, please speak up on the
+[qemu-devel mailing list](http://wiki.qemu.org/Contribute/MailingLists)
+to explain why the interface or feature is still required.
-- 
1.8.3.1




[Qemu-devel] [PATCH] Makefile: Let "make check-help" work without running ./configure

2017-08-10 Thread Fam Zheng
Currently if you do "make check-help" in a fresh checkout, only an error
is printed which is not nice:

$ make check-help V=1
cc -nostdlib  -o check-help.mo
cc: fatal error: no input files
compilation terminated.
rules.mak:115: recipe for target 'check-help.mo' failed
make: *** [check-help.mo] Error 1

Move the config-host.mak condition into the body of
tests/Makefile.include and always include the rule for check-help.

Reported-by: Philippe Mathieu-Daudé 
Signed-off-by: Fam Zheng 
---
 Makefile   |  2 --
 tests/Makefile.include | 46 +-
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/Makefile b/Makefile
index 97a58a0f4e..81447b1f08 100644
--- a/Makefile
+++ b/Makefile
@@ -281,9 +281,7 @@ dummy := $(call unnest-vars,, \
 common-obj-m \
 trace-obj-y)
 
-ifneq ($(wildcard config-host.mak),)
 include $(SRC_PATH)/tests/Makefile.include
-endif
 
 all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
 
diff --git a/tests/Makefile.include b/tests/Makefile.include
index eb4895f94a..37c1bed683 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1,3 +1,26 @@
+
+.PHONY: check-help
+check-help:
+   @echo "Regression testing targets:"
+   @echo
+   @echo " make checkRun all tests"
+   @echo " make check-qtest-TARGET   Run qtest tests for given target"
+   @echo " make check-qtest  Run qtest tests"
+   @echo " make check-unit   Run qobject tests"
+   @echo " make check-speed  Run qobject speed tests"
+   @echo " make check-qapi-schemaRun QAPI schema tests"
+   @echo " make check-block  Run block tests"
+   @echo " make check-report.htmlGenerates an HTML test report"
+   @echo " make check-clean  Clean the tests"
+   @echo
+   @echo "Please note that HTML reports do not regenerate if the unit 
tests"
+   @echo "has not changed."
+   @echo
+   @echo "The variable SPEED can be set to control the gtester speed 
setting."
+   @echo "Default options are -k and (for make V=1) --verbose; they can be"
+   @echo "changed with variable GTESTER_OPTIONS."
+
+ifneq ($(wildcard config-host.mak),)
 export SRC_PATH
 
 qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
@@ -802,27 +825,6 @@ $(check-qtest-y): $(qtest-obj-y)
 
 tests/test-qga: tests/test-qga.o $(qtest-obj-y)
 
-.PHONY: check-help
-check-help:
-   @echo "Regression testing targets:"
-   @echo
-   @echo " make checkRun all tests"
-   @echo " make check-qtest-TARGET   Run qtest tests for given target"
-   @echo " make check-qtest  Run qtest tests"
-   @echo " make check-unit   Run qobject tests"
-   @echo " make check-speed  Run qobject speed tests"
-   @echo " make check-qapi-schemaRun QAPI schema tests"
-   @echo " make check-block  Run block tests"
-   @echo " make check-report.htmlGenerates an HTML test report"
-   @echo " make check-clean  Clean the tests"
-   @echo
-   @echo "Please note that HTML reports do not regenerate if the unit 
tests"
-   @echo "has not changed."
-   @echo
-   @echo "The variable SPEED can be set to control the gtester speed 
setting."
-   @echo "Default options are -k and (for make V=1) --verbose; they can be"
-   @echo "changed with variable GTESTER_OPTIONS."
-
 SPEED = quick
 GTESTER_OPTIONS = -k $(if $(V),--verbose,-q)
 GCOV_OPTIONS = -n $(if $(V),-f,)
@@ -917,3 +919,5 @@ all: $(QEMU_IOTESTS_HELPERS-y)
 
 -include $(wildcard tests/*.d)
 -include $(wildcard tests/libqos/*.d)
+
+endif
-- 
2.13.4




Re: [Qemu-devel] [PATCH v2 for-2.10] qemu-doc: Mention host_net_add/-remove in the deprecation chapter

2017-08-10 Thread Paolo Bonzini
On 10/08/2017 10:00, Thomas Huth wrote:
> The two HMP commands host_net_add and -remove have recently been
> marked as deprecated, too, so we should now mention them in the
> chapter of deprecated features.
> 
> Signed-off-by: Thomas Huth 
> ---
>  qemu-doc.texi | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/qemu-doc.texi b/qemu-doc.texi
> index aeb7bc5..7b62fdf 100644
> --- a/qemu-doc.texi
> +++ b/qemu-doc.texi
> @@ -3283,6 +3283,14 @@ by the ``convert -l snapshot_param'' argument instead.
>  
>  @section System emulator human monitor commands
>  
> +@subsection host_net_add (since 2.10.0)
> +
> +The ``host_net_add'' command is replaced by the ``netdev_add'' command.
> +
> +@subsection host_net_remove (since 2.10.0)
> +
> +The ``host_net_remove'' command is replaced by the ``netdev_del'' command.
> +
>  @subsection usb_add (since 2.10.0)
>  
>  The ``usb_add'' command is replaced by the ``device_add'' command.
> 

Queued, thanks.

Paolo



Re: [Qemu-devel] [PATCH] qemu-iothread: IOThread supports the GMainContext event loop

2017-08-10 Thread Fam Zheng
On Fri, 08/11 08:29, Wang yong wrote:
> From: Wang Yong
> 
> IOThread uses AioContext event loop and does not run a GMainContext.
> Therefore,chardev cannot work in IOThread,such as the chardev is
> used for colo-compare packets reception.
> 
> This patch makes the IOThread run the GMainContext event loop,
> chardev and IOThread can work together.
> 
> Signed-off-by: Wang Yong
> Signed-off-by: Wang Guang
> ---
>  include/sysemu/iothread.h |  1 +
>  iothread.c| 13 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
> index e6da1a4..ffe4e8a 100644
> --- a/include/sysemu/iothread.h
> +++ b/include/sysemu/iothread.h
> @@ -24,6 +24,7 @@ typedef struct {
>  
>  QemuThread thread;
>  AioContext *ctx;
> +GMainLoop *loop;
>  QemuMutex init_done_lock;
>  QemuCond init_done_cond;/* is thread initialization done? */
>  bool stopping;
> diff --git a/iothread.c b/iothread.c
> index beeb870..b6f3c3c 100644
> --- a/iothread.c
> +++ b/iothread.c
> @@ -46,6 +46,7 @@ AioContext *qemu_get_current_aio_context(void)
>  static void *iothread_run(void *opaque)
>  {
>  IOThread *iothread = opaque;
> +GMainContext *context;
>  
>  rcu_register_thread();
>  
> @@ -57,6 +58,15 @@ static void *iothread_run(void *opaque)
>  
>  while (!atomic_read(>stopping)) {
>  aio_poll(iothread->ctx, true);
> +
> +context = iothread->ctx->source.context;
> +if (context) {
> +iothread->loop = g_main_loop_new(context, TRUE);
> +g_main_loop_run(iothread->loop);
> +
> +g_main_loop_unref(iothread->loop);

Is it better to set iothread->loop to NULL after unref? If in the future a
second place adds g_main_loop_quit(), it can coordinate with iothread_stop by
checking iothread->loop == NULL.

> +g_main_context_unref(context);

Where is the matching g_main_context_ref? I think the one reference in
iothread->loop goes away with g_main_loop_unref. Is this line unnecessary?

> +}
>  }
>  
>  rcu_unregister_thread();
> @@ -72,6 +82,9 @@ static int iothread_stop(Object *object, void *opaque)
>  return 0;
>  }
>  iothread->stopping = true;
> +if (iothread->loop) {
> +g_main_loop_quit(iothread->loop);
> +}
>  aio_notify(iothread->ctx);
>  qemu_thread_join(>thread);
>  return 0;
> -- 
> 1.8.3.1
> 
> 
> 

Though I haven't seen the chardev changes yet, the general idea looks good to
me.

Fam



Re: [Qemu-devel] [PATCH 08/12] qemu-iotests: fix uninitialized variable

2017-08-10 Thread Markus Armbruster
Drive-by comment:

Paolo Bonzini  writes:

> The function is used in "common" but defined only after the file

"This variable"

> is sourced.
>
> Signed-off-by: Paolo Bonzini 



Re: [Qemu-devel] [PATCH for-2.10 2/2] xilinx-spips: add a migration blocker when using mmio_execution

2017-08-10 Thread Edgar E. Iglesias
On Thu, Aug 10, 2017 at 10:11:13AM +0100, Peter Maydell wrote:
> On 1 August 2017 at 10:41, Peter Maydell  wrote:
> > On 1 August 2017 at 10:35, KONRAD Frederic  
> > wrote:
> >>
> >>
> >> On 08/01/2017 11:30 AM, Edgar E. Iglesias wrote:
> >>> At this stage, perhaps we should just register the blocker when this dev
> >>> realizes.
> >>>
> >>> If a request_ptr comes in during migration, the VM will fail either way...
> >
> >> Yes but this will breaks migration for the spips device everytime
> >> and not only when mmio-execution is used?
> >
> > This line of thought is why I ended up suggesting just disabling
> > the exec-in-place feature -- that way we just don't introduce
> > what would be a new-in-2.10 feature, rather than breaking something
> > that used to work in 2.9.
> 
> OK, so what's the plan here? We have several options:
>  * just disable exec-from-spips for 2.10 (I sent a patch for that)
>  * disable exec-from-spips for 2.10 but with a device x-property
>to allow the user to turn it on again if they really want it
>  * this patch or variants on it which try to only disable
>migration if exec-from-spips is actually used by the guest
>(I don't like these because of the awkward corner cases if
>migration and the guest using exec-from-spips happen at the
>same time)
> 
> So my current view remains "we should just disable this feature
> for 2.10 and we can implement it properly with handling of
> migration for 2.11", unless somebody cares enough to implement
> the x-property thing within the next day or so.

Hi Peter,

I think the x-property sounds good.
Fred, would you like to send a patch for that?
Otherwise, I can do it later today.

Cheers,
Edgar



Re: [Qemu-devel] [PATCH for-2.10 2/2] xilinx-spips: add a migration blocker when using mmio_execution

2017-08-10 Thread KONRAD Frederic



On 08/10/2017 11:22 AM, Edgar E. Iglesias wrote:

On Thu, Aug 10, 2017 at 10:11:13AM +0100, Peter Maydell wrote:

On 1 August 2017 at 10:41, Peter Maydell  wrote:

On 1 August 2017 at 10:35, KONRAD Frederic  wrote:



On 08/01/2017 11:30 AM, Edgar E. Iglesias wrote:

At this stage, perhaps we should just register the blocker when this dev
realizes.

If a request_ptr comes in during migration, the VM will fail either way...



Yes but this will breaks migration for the spips device everytime
and not only when mmio-execution is used?


This line of thought is why I ended up suggesting just disabling
the exec-in-place feature -- that way we just don't introduce
what would be a new-in-2.10 feature, rather than breaking something
that used to work in 2.9.


OK, so what's the plan here? We have several options:
  * just disable exec-from-spips for 2.10 (I sent a patch for that)
  * disable exec-from-spips for 2.10 but with a device x-property
to allow the user to turn it on again if they really want it
  * this patch or variants on it which try to only disable
migration if exec-from-spips is actually used by the guest
(I don't like these because of the awkward corner cases if
migration and the guest using exec-from-spips happen at the
same time)

So my current view remains "we should just disable this feature
for 2.10 and we can implement it properly with handling of
migration for 2.11", unless somebody cares enough to implement
the x-property thing within the next day or so.


Hi Peter,

I think the x-property sounds good.
Fred, would you like to send a patch for that?
Otherwise, I can do it later today.

Cheers,
Edgar



Hi,

Ok I will do.

Thanks,
Fred



Re: [Qemu-devel] [PATCH v4 13/22] libqtest: Add qmp_raw()

2017-08-10 Thread Markus Armbruster
Eric Blake  writes:

> On 08/09/2017 09:54 AM, Markus Armbruster wrote:
>> Eric Blake  writes:
>> 
>>> The majority of calls into libqtest's qmp() and friends are passing
>>> a JSON object that includes a command name; we can prove this by
>>> adding an assertion.  The only outlier is qmp-test, which is testing
>>> appropriate error responses to protocol violations and id support,
>>> by sending raw strings, where those raw strings don't need
>>> interpolation anyways.
>>>
>>> Adding a new entry-point makes a clean separation of which input
>>> needs interpolation, so that upcoming patches can refactor qmp()
>>> to be more like the recent additions to test-qga in taking the
>>> command name separately from the arguments for an overall
>>> reduction in testsuite boilerplate.
>>>
>>> This change also lets us move the workaround for the QMP parser
>>> limitation of not ending a parse until } or newline: all calls
>>> through qmp() are passing an object ending in }, so only the
>>> few callers of qmp_raw() have to worry about a trailing newline.
>>> +++ b/tests/libqtest.c
>>> @@ -451,7 +451,7 @@ static void qmp_fd_sendv(int fd, const char *fmt, 
>>> va_list ap)
>>>  QString *qstr;
>>>  const char *str;
>>>
>>> -assert(*fmt);
>>> +assert(strstr(fmt, "execute"));
>> 
>> I doubt this assertion is worthwhile.
>
> Indeed, and it disappears later in the series.  But it was useful in the
> interim, to prove that ALL callers through this function are passing a
> command name (and therefore my later patches to rewrite qmp() to take a
> command name aren't overlooking any callers).
>
>> 
>> One , qmp_fd_sendv() works just fine whether you include an 'execute' or
>> not.  Two, there are zillions of other ways to send nonsense with
>> qmp_fd_sendv().  If you do, your test doesn't work, so you fix it.
>> 
>> Rejecting nonsensical QMP input is QEMU's job, not libqtest's.
>
> I'm fine omitting the assertions in the next spin, even if they proved
> useful in this revision for making sure I converted everything.

Omitting them is fine.

Keeping them temporarily with a comment why would also be fine, but more
work.

>>>
>>>  /* Test command failure with 'id' */
>>> -resp = qmp("{ 'execute': 'human-monitor-command', 'id': 2 }");
>>> +resp = qmp_raw("{ 'execute': 'human-monitor-command', 'id': 2 }");
>>>  g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
>>>  g_assert_cmpint(qdict_get_int(resp, "id"), ==, 2);
>>>  QDECREF(resp);
>> 
>> I'm afraid I don't like this patch.  All the extra function buys us is
>> an assertion that isn't even tight, and the lifting of a newline out of
>> a place where it shouldn't be.
>
> Maybe you'll change your mind by the end of the series, once you see the
> changes to make qmp() shorter (and where those changes necessitate a
> qmp_raw() as the backdoor for anything that is not a normal
> command+arguments).

It's a big series.  I may not see the forest for the trees right now.  A
v2 taking care of the uncontroversial improvements should improve my
view some.



Re: [Qemu-devel] [PATCH for-2.10] qemu-doc: Mention host_net_add/-remove in the deprecation chapter

2017-08-10 Thread Thomas Huth
On 10.08.2017 09:48, Thomas Huth wrote:
> The two HMP commands host_net_add and -remove have recently been
> marked as deprecated, too, so we should now mention them in the
> chapter of deprecated features.
> 
> Signed-off-by: Thomas Huth 
> ---
>  qemu-doc.texi | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/qemu-doc.texi b/qemu-doc.texi
> index aeb7bc5..7b62fdf 100644
> --- a/qemu-doc.texi
> +++ b/qemu-doc.texi
> @@ -3283,6 +3283,14 @@ by the ``convert -l snapshot_param'' argument instead.
>  
>  @section System emulator human monitor commands
>  
> +@subsection host_net_add (since 2.10.0)
> +
> +The ``host_net_add'' command is replaced by the ``netdev_add'' command.
> +
> +@subsection host_net_remove (since 2.10.0)
> +
> +The ``host_net_remove'' command is replaced by the ``host_net_remove'' 
> command.

D'oh, stupid copy-n-paste bug ... that should be replaced by
"netdev_del" of course instead. I'll send a v2...

 Thomas



Re: [Qemu-devel] [PATCH] qemu-iothread: IOThread supports the GMainContext event loop

2017-08-10 Thread Paolo Bonzini


- Original Message -
> From: "Wang yong" 
> To: pbonz...@redhat.com, stefa...@redhat.com, f...@redhat.com, 
> jasow...@redhat.com
> Cc: "wang yong155" , "wang guang55" 
> , "zhangchen fnst"
> , "zhang zhanghailiang" 
> , lizhij...@cn.fujitsu.com,
> qemu-devel@nongnu.org
> Sent: Friday, August 11, 2017 2:29:15 AM
> Subject: [PATCH] qemu-iothread: IOThread supports the GMainContext event loop
> 
> From: Wang Yong
> 
> IOThread uses AioContext event loop and does not run a GMainContext.
> Therefore,chardev cannot work in IOThread,such as the chardev is
> used for colo-compare packets reception.
> 
> This patch makes the IOThread run the GMainContext event loop,
> chardev and IOThread can work together.
> 
> Signed-off-by: Wang Yong
> Signed-off-by: Wang Guang

Nice.  Just a note, I think an iothread should have its own (optional)
GMainContext accessed with iothread_get_g_main_context(iothread).  When
you call it for the first time, the iothread:

1) creates a GMainContext

2) adds the AioContext as a GSource in the GMainContext

3) asks iothread_run to switch from the AioContext loop to the
GMainContext loop


To simplify thread-safety:

1) the GMainContext can be wrapped with a GOnce

2) the GOnce callback can leave steps 2 and 3 to a bottom half.

Paolo

> ---
>  include/sysemu/iothread.h |  1 +
>  iothread.c| 13 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
> index e6da1a4..ffe4e8a 100644
> --- a/include/sysemu/iothread.h
> +++ b/include/sysemu/iothread.h
> @@ -24,6 +24,7 @@ typedef struct {
>  
>  QemuThread thread;
>  AioContext *ctx;
> +GMainLoop *loop;
>  QemuMutex init_done_lock;
>  QemuCond init_done_cond;/* is thread initialization done? */
>  bool stopping;
> diff --git a/iothread.c b/iothread.c
> index beeb870..b6f3c3c 100644
> --- a/iothread.c
> +++ b/iothread.c
> @@ -46,6 +46,7 @@ AioContext *qemu_get_current_aio_context(void)
>  static void *iothread_run(void *opaque)
>  {
>  IOThread *iothread = opaque;
> +GMainContext *context;
>  
>  rcu_register_thread();
>  
> @@ -57,6 +58,15 @@ static void *iothread_run(void *opaque)
>  
>  while (!atomic_read(>stopping)) {
>  aio_poll(iothread->ctx, true);
> +
> +context = iothread->ctx->source.context;
> +if (context) {
> +iothread->loop = g_main_loop_new(context, TRUE);
> +g_main_loop_run(iothread->loop);
> +
> +g_main_loop_unref(iothread->loop);
> +g_main_context_unref(context);
> +}
>  }
>  
>  rcu_unregister_thread();
> @@ -72,6 +82,9 @@ static int iothread_stop(Object *object, void *opaque)
>  return 0;
>  }
>  iothread->stopping = true;
> +if (iothread->loop) {
> +g_main_loop_quit(iothread->loop);
> +}
>  aio_notify(iothread->ctx);
>  qemu_thread_join(>thread);
>  return 0;
> --
> 1.8.3.1
> 
> 
> 



Re: [Qemu-devel] [RFC 23/29] vub+postcopy: madvises

2017-08-10 Thread Dr. David Alan Gilbert
* Alexey Perevalov (a.pereva...@samsung.com) wrote:
> On 08/08/2017 08:06 PM, Dr. David Alan Gilbert wrote:
> > * Alexey Perevalov (a.pereva...@samsung.com) wrote:
> > > On 06/28/2017 10:00 PM, Dr. David Alan Gilbert (git) wrote:
> > > > From: "Dr. David Alan Gilbert" 
> > > > 
> > > > Clear the area and turn off THP.
> > > > 
> > > > Signed-off-by: Dr. David Alan Gilbert 
> > > > ---
> > > >contrib/libvhost-user/libvhost-user.c | 32 
> > > > ++--
> > > >1 file changed, 30 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/contrib/libvhost-user/libvhost-user.c 
> > > > b/contrib/libvhost-user/libvhost-user.c
> > > > index 0658b6e847..ceddeac74f 100644
> > > > --- a/contrib/libvhost-user/libvhost-user.c
> > > > +++ b/contrib/libvhost-user/libvhost-user.c
> > > > @@ -451,11 +451,39 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg 
> > > > *vmsg)
> > > >}
> > > >if (dev->postcopy_listening) {
> > > > +int ret;
> > > >/* We should already have an open ufd need to mark each 
> > > > memory
> > > > * range as ufd.
> > > > - * Note: Do we need any madvises? Well it's not been 
> > > > accessed
> > > > - * yet, still probably need no THP to be safe, discard to 
> > > > be safe?
> > > > */
> > > > +
> > > > +/* Discard any mapping we have here; note I can't use 
> > > > MADV_REMOVE
> > > > + * or fallocate to make the hole since I don't want to lose
> > > > + * data that's already arrived in the shared process.
> > > > + * TODO: How to do hugepage
> > > > + */
> > > Hi, David, frankly saying, I stuck with my solution, and I have also 
> > > another
> > > issues,
> > > but here I could suggest solution for hugepages. I think we could 
> > > transmit a
> > > received pages
> > > bitmap in VHOST_USER_SET_MEM_TABLE (VhostUserMemoryRegion), but it will
> > > raise a compatibility issue,
> > > or introduce special message type for that and send it before
> > > VHOST_USER_SET_MEM_TABLE.
> > > So it will be  possible to do fallocate on received bitmap basis, just 
> > > skip
> > > already copied pages.
> > > If you wish, I could send patches, rebased on yours, for doing it.
> > What we found works is that actually we don't need to do a discard -
> > since we've only just done the mmap of the arena, nothing will be
> > occupying it on the shared client, so we don't need to discard.
> Looks like yes, I checked on kernel from Andrea's git,
> there is any more EEXIST error in case when client doesn't
> fallocate.
> 
> > 
> > We've had a postcopy migrate work now, with a few hacks we're still
> > cleaning up, both on vhost-user-bridge and dpdk; so I'll get this
> > updated and reposted.
> In you patch series vring is disabling in case of VHOST_USER_GET_VRING_BASE.
> It's being called when vhost-user server want's to stop vring.
> QEMU is enabling vring as soon as virtual machine is started, so I didn't
> see
> explicit vring disabling for migrating VRING.
> So migrating VRING is protected just by uffd_register, isn't it? And PMD
> thread (any
> vhost-user thread which accessing migrating VRING) will wait page copying in
> this case,
> right?

Yes I believe that's the case; although I don't know the structure of
dpdk to know the effect of that.

Dave

> 
> > 
> > Dave
> > 
> > > > +ret = madvise((void *)dev_region->mmap_addr,
> > > > +  dev_region->size + dev_region->mmap_offset,
> > > > +  MADV_DONTNEED);
> > > > +if (ret) {
> > > > +fprintf(stderr,
> > > > +"%s: Failed to madvise(DONTNEED) region %d: 
> > > > %s\n",
> > > > +__func__, i, strerror(errno));
> > > > +}
> > > > +/* Turn off transparent hugepages so we dont get lose 
> > > > wakeups
> > > > + * in neighbouring pages.
> > > > + * TODO: Turn this backon later.
> > > > + */
> > > > +ret = madvise((void *)dev_region->mmap_addr,
> > > > +  dev_region->size + dev_region->mmap_offset,
> > > > +  MADV_NOHUGEPAGE);
> > > > +if (ret) {
> > > > +/* Note: This can happen legally on kernels that are 
> > > > configured
> > > > + * without madvise'able hugepages
> > > > + */
> > > > +fprintf(stderr,
> > > > +"%s: Failed to madvise(NOHUGEPAGE) region %d: 
> > > > %s\n",
> > > > +__func__, i, strerror(errno));
> > > > +}
> > > >struct uffdio_register reg_struct;
> > > >/* Note: We might need to go back to using mmap_addr and
> > > > * len + mmap_offset for * huge pages, but then we do 
> > > > 

Re: [Qemu-devel] [PATCH 18/47] MAINTAINERS: add missing TCG entry

2017-08-10 Thread Peter Maydell
On 10 August 2017 at 09:46, Cornelia Huck  wrote:
> The root problem is "some files have no maintainers". The reasons range
> from "forgot to include the file in the pattern" (easily fixed), over
> "file is updated via a script" (the linux-headers case), to "nobody
> feels up to the task" (which is the worst case).
>
> In most cases, I don't think the recent contributors list is very
> helpful. Somebody who simply did a tree-wide rename is unlikely to be
> able to make a good judgment about a complicated logic change. Just
> printing qemu-devel as the address to send this to is probably better;
> unfortunately, it may cause patches to languish on the list if nobody
> takes pity on them.
>
> Do we need someone collecting non-trivial patches like that, who either
> pesters others or picks up the patches themselves?

The problem is that if nobody's feeling up to the task of taking
on a particular single file which has no maintainer, then it's
definitely true that nobody's going to feel up to taking on
the entire collection of unmaintained files...

I think the UI (giving no consideration to how we might implement
this!) would ideally be something like:
 * if anybody mails a patch which touches an "unmaintained" file,
   a robot should send a reply along the lines of "thanks for the
   patch; unfortunately file X is not maintained so it may be
   tricky to get patch review for this. You'll need to be
   persistent and do more of the legwork than if you were patching
   a file that did have an active maintainer" so contributors
   know when they've wandered into the swamp
 * some mechanism for easily finding patches to unmaintained
   files which haven't got review yet, so that anybody with some
   spare time and interest can move some of them along (the idea
   being to spread the load rather than trying to designate a
   particular "owner" for this headache)
 * ditto for finding patches to unmaintained files which have got
   review but which haven't been committed

thanks
-- PMM



Re: [Qemu-devel] [qemu-web PATCH v2] Add a blog post about deprecation of old interfaces and features

2017-08-10 Thread Daniel P. Berrange
On Thu, Aug 10, 2017 at 10:46:30AM +0200, Thomas Huth wrote:
> Now that we've got a list of deprecated interfaces/features in the QEMU
> documentation, it is time to draw some more public attention to our plans
> of removing certain interfaces/features in future releases.
> 
> Signed-off-by: Thomas Huth 
> ---
>  v2: Use a link to the qemu-doc instead of pointing to the Wiki
> 
>  _posts/2017-08-10-deprecation.md | 26 ++
>  1 file changed, 26 insertions(+)
>  create mode 100644 _posts/2017-08-10-deprecation.md
> 
> diff --git a/_posts/2017-08-10-deprecation.md 
> b/_posts/2017-08-10-deprecation.md
> new file mode 100644
> index 000..784fb79
> --- /dev/null
> +++ b/_posts/2017-08-10-deprecation.md
> @@ -0,0 +1,26 @@
> +---
> +layout: post
> +title:  "Deprecation of old parameters and features"
> +date:   2017-08-10 10:45:00 +0200
> +author: Thomas Huth
> +categories: [features, 'web site']
> +---
> +QEMU has a lot of interfaces (like command line options or HMP commands) and
> +old features (like certain devices) which are considered as deprecated
> +since other more generic or better interfaces/features have been established
> +instead. While the QEMU developers are generally trying to keep each QEMU
> +release compatible with the previous ones, the old legacy sometimes gets into
> +the way when developing new code and/or causes quite some burden of 
> maintaining
> +it.
> +
> +Thus we are currently considering to get rid of some of the old interfaces
> +and features in a future release and have started to collect a list of such
> +old items in our
> +[QEMU 
> documentation](https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features).

Unrelated to your post - it would be nice to have the qemu docs hosted
on qemu.org, and even nicer if someone figures out how to theme them
to fit in with the website style instead of being bare black & white
pages with no navigation :-)



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] target/i386: fix packusdw in-place operation

2017-08-10 Thread Paolo Bonzini
On 10/08/2017 02:24, Joseph Myers wrote:
> The SSE4.1 packusdw instruction combines source and destination
> vectors of signed 32-bit integers into a single vector of unsigned
> 16-bit integers, with unsigned saturation.  When the source and
> destination are the same register, this means each 32-bit element of
> that register is used twice as an input, to produce two of the 16-bit
> output elements, and so if the operation is carried out
> element-by-element in-place, no matter what the order in which it is
> applied to the elements, the first element's operation will overwrite
> some future input.  The helper for packssdw avoids this issue by
> computing the result in a local temporary and copying it to the
> destination at the end; this patch fixes the packusdw helper to do
> likewise.  This fixes three gcc test failures in my GCC 6-based
> testing.
> 
> Signed-off-by: Joseph Myers 
> 
> ---
> 
> diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h
> index 16509d0..05b1701 100644
> --- a/target/i386/ops_sse.h
> +++ b/target/i386/ops_sse.h
> @@ -1655,14 +1655,17 @@ SSE_HELPER_Q(helper_pcmpeqq, FCMPEQQ)
>  
>  void glue(helper_packusdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
>  {
> -d->W(0) = satuw((int32_t) d->L(0));
> -d->W(1) = satuw((int32_t) d->L(1));
> -d->W(2) = satuw((int32_t) d->L(2));
> -d->W(3) = satuw((int32_t) d->L(3));
> -d->W(4) = satuw((int32_t) s->L(0));
> -d->W(5) = satuw((int32_t) s->L(1));
> -d->W(6) = satuw((int32_t) s->L(2));
> -d->W(7) = satuw((int32_t) s->L(3));
> +Reg r;
> +
> +r.W(0) = satuw((int32_t) d->L(0));
> +r.W(1) = satuw((int32_t) d->L(1));
> +r.W(2) = satuw((int32_t) d->L(2));
> +r.W(3) = satuw((int32_t) d->L(3));
> +r.W(4) = satuw((int32_t) s->L(0));
> +r.W(5) = satuw((int32_t) s->L(1));
> +r.W(6) = satuw((int32_t) s->L(2));
> +r.W(7) = satuw((int32_t) s->L(3));
> +*d = r;
>  }
>  
>  #define FMINSB(d, s) MIN((int8_t)d, (int8_t)s)
> 

Queued, thanks.

Paolo



Re: [Qemu-devel] [PATCH 0/2] IDE: Do not flush empty drives

2017-08-10 Thread Stefan Hajnoczi
On Wed, Aug 09, 2017 at 05:02:10PM +0100, Stefan Hajnoczi wrote:
> John Snow is offline until Monday, QEMU 2.10-rc3 is due to be tagged on
> Tuesday, and so I've taken two patches John sent for 2.10 and addressed review
> comments.
> 
> Kevin Wolf (1):
>   IDE: test flush on empty CDROM
> 
> Stefan Hajnoczi (1):
>   IDE: Do not flush empty CDROM drives
> 
>  hw/ide/core.c| 10 +-
>  tests/ide-test.c | 19 +++
>  2 files changed, 28 insertions(+), 1 deletion(-)

John: I am sending a pull request to get this fix into -rc3 (Aug 15th).
Feel free to send a follow-up/revert if you want to make changes when
you get back online.

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH] x86: Increase max vcpu number to 352

2017-08-10 Thread Daniel P. Berrange
On Thu, Aug 10, 2017 at 02:13:30PM +0200, Paolo Bonzini wrote:
> On 10/08/2017 12:08, Lan Tianyu wrote:
> > Intel Xeon phi chip will support 352 logical threads. For HPC
> > usage case, it will create a huge VM with vcpus number as same as host
> > cpus. This patch is to increase max vcpu number to 352.
> 
> Even without Xeon Phi, a 24-core, 8-socket system (E7-8890 v4 for
> example) will have 384 physical CPUs.  288 was the biggest we could test
> at the time, but now that the 256 vCPU barrier has been broken I agree
> with going straight to 512.

FWIW, linux allows  8192 CPUs on x86_64 already, due to alledged
existance of SGI machines with 6096 CPUs

  commit b53b5eda8194214928c8243d711a75dbf51809fc
  Author: Josh Boyer 
  Date:   Tue Nov 5 09:38:16 2013 -0500

x86/cpu: Increase max CPU count to 8192

The MAXSMP option is intended to enable silly large numbers of
CPUs for testing purposes.  The current value of 4096 isn't very
silly any longer as there are actual SGI machines that approach
6096 CPUs when taking HT into account.

Increase the value to a nice round 8192 to account for this and
allow for short term future increases.



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] qemu-doc: Fix "-net van" typo

2017-08-10 Thread Eric Blake
On 08/10/2017 06:44 AM, Thomas Huth wrote:
> While Andrew S. Tanenbaum has a point by saying "Never underestimate the
> bandwidth of a station wagon full of tapes hurtling down the highway",
> we don't support that way of transportation in QEMU yet, so replace the
> typo with the correct word "vlan".
> 
> Signed-off-by: Thomas Huth 
> ---
>  qemu-doc.texi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake 

(Kudos for a commit message that is 4 times as long, and definitely
funnier, than the patch itself :)

> 
> diff --git a/qemu-doc.texi b/qemu-doc.texi
> index 92d50f1..9811476 100644
> --- a/qemu-doc.texi
> +++ b/qemu-doc.texi
> @@ -3243,7 +3243,7 @@ the ``-netdev user,guestfwd=ARGS'' argument instead.
>  
>  @subsection -net vlan (since 2.9.0)
>  
> -The ``-net van=NN'' argument is partially replaced with the
> +The ``-net vlan=NN'' argument is partially replaced with the
>  new ``-netdev'' argument. The remaining use cases will no
>  longer be directly supported in QEMU.
>  
> 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v6 04/19] migration: Create migration_has_all_channels

2017-08-10 Thread Eric Blake
On 08/08/2017 11:26 AM, Juan Quintela wrote:
> This functions allows us to decide when to close the listener socket.

s/functions/function/

> For now, we only need one connection.
> 
> Signed-off-by: Juan Quintela 
> ---
-- 
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] [for-2.10 PATCH v4] 9pfs: local: fix fchmodat_nofollow() limitations

2017-08-10 Thread Zhi Yong Wu
Tested-by: Zhi Yong Wu 



Regards,


Zhi Yong Wu
At 2017-08-10 00:40:57, "Greg Kurz"  wrote:
>This function has to ensure it doesn't follow a symlink that could be used
>to escape the virtfs directory. This could be easily achieved if fchmodat()
>on linux honored the AT_SYMLINK_NOFOLLOW flag as described in POSIX, but
>it doesn't. There was a tentative to implement a new fchmodat2() syscall
>with the correct semantics:
>
>https://patchwork.kernel.org/patch/9596301/
>
>but it didn't gain much momentum. Also it was suggested to look at an O_PATH
>based solution in the first place.
>
>The current implementation covers most use-cases, but it notably fails if:
>- the target path has access rights equal to  (openat() returns EPERM),
>  => once you've done chmod() on a file, you can never chmod() again
>- the target path is UNIX domain socket (openat() returns ENXIO)
>  => bind() of UNIX domain sockets fails if the file is on 9pfs
>
>The solution is to use O_PATH: openat() now succeeds in both cases, and we
>can ensure the path isn't a symlink with fstat(). The associated entry in
>"/proc/self/fd" can hence be safely passed to the regular chmod() syscall.
>
>The previous behavior is kept for older systems that don't have O_PATH.
>
>Signed-off-by: Greg Kurz 
>Reviewed-by: Eric Blake 
>---
>v4: - fixed #if condition
>- moved out: label above #endif
>- fixed typo in changelog
>- added Eric's r-b
>
>v3: - O_PATH in a separate block of code
>- added a reference to the fchmodat2() tentative in the changelog
>
>v2: - renamed OPENAT_DIR_O_PATH to O_PATH_9P_UTIL and use it as a replacement
>  for O_PATH to avoid build breaks on O_PATH-less systems
>- keep current behavior for O_PATH-less systems
>- added comments
>- TODO in 2.11: add _nofollow suffix to openat_dir() and openat_file()
>---
> hw/9pfs/9p-local.c |   43 ---
> hw/9pfs/9p-util.h  |   24 +++-
> 2 files changed, 51 insertions(+), 16 deletions(-)
>
>diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
>index 6e478f4765ef..d9ef57d343c9 100644
>--- a/hw/9pfs/9p-local.c
>+++ b/hw/9pfs/9p-local.c
>@@ -333,17 +333,27 @@ update_map_file:
> 
> static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
> {
>+struct stat stbuf;
> int fd, ret;
> 
> /* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW).
>- * Unfortunately, the linux kernel doesn't implement it yet. As an
>- * alternative, let's open the file and use fchmod() instead. This
>- * may fail depending on the permissions of the file, but it is the
>- * best we can do to avoid TOCTTOU. We first try to open read-only
>- * in case name points to a directory. If that fails, we try write-only
>- * in case name doesn't point to a directory.
>+ * Unfortunately, the linux kernel doesn't implement it yet.
>  */
>-fd = openat_file(dirfd, name, O_RDONLY, 0);
>+
>+ /* First, we clear non-racing symlinks out of the way. */
>+if (fstatat(dirfd, name, , AT_SYMLINK_NOFOLLOW)) {
>+return -1;
>+}
>+if (S_ISLNK(stbuf.st_mode)) {
>+errno = ELOOP;
>+return -1;
>+}
>+
>+/* Access modes are ignored when O_PATH is supported. We try O_RDONLY and
>+ * O_WRONLY for old-systems that don't support O_PATH.
>+ */
>+fd = openat_file(dirfd, name, O_RDONLY | O_PATH_9P_UTIL, 0);
>+#if O_PATH_9P_UTIL == 0
> if (fd == -1) {
> /* In case the file is writable-only and isn't a directory. */
> if (errno == EACCES) {
>@@ -357,6 +367,25 @@ static int fchmodat_nofollow(int dirfd, const char *name, 
>mode_t mode)
> return -1;
> }
> ret = fchmod(fd, mode);
>+#else
>+/* Now we handle racing symlinks. */
>+ret = fstat(fd, );
>+if (ret) {
>+goto out;
>+}
>+if (S_ISLNK(stbuf.st_mode)) {
>+errno = ELOOP;
>+ret = -1;
>+goto out;
>+}
>+
>+{
>+char *proc_path = g_strdup_printf("/proc/self/fd/%d", fd);
>+ret = chmod(proc_path, mode);
>+g_free(proc_path);
>+}
>+out:
>+#endif
> close_preserve_errno(fd);
> return ret;
> }
>diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
>index 91299a24b8af..dc0d2e29aa3b 100644
>--- a/hw/9pfs/9p-util.h
>+++ b/hw/9pfs/9p-util.h
>@@ -13,6 +13,12 @@
> #ifndef QEMU_9P_UTIL_H
> #define QEMU_9P_UTIL_H
> 
>+#ifdef O_PATH
>+#define O_PATH_9P_UTIL O_PATH
>+#else
>+#define O_PATH_9P_UTIL 0
>+#endif
>+
> static inline void close_preserve_errno(int fd)
> {
> int serrno = errno;
>@@ -22,13 +28,8 @@ static inline void close_preserve_errno(int fd)
> 
> static inline int openat_dir(int dirfd, const char *name)
> {
>-#ifdef O_PATH
>-#define OPENAT_DIR_O_PATH O_PATH
>-#else
>-#define OPENAT_DIR_O_PATH 0
>-#endif
> return openat(dirfd, name,
>-  O_DIRECTORY | O_RDONLY | O_NOFOLLOW | 

[Qemu-devel] [PATCH 12/15] ui: convert GTK and SDL1 frontends to keycodemapdb

2017-08-10 Thread Daniel P. Berrange
The x_keycode_to_pc_keycode and evdev_keycode_to_pc_keycode
tables are replaced with automatically generated tables.
In addition the X11 heuristics are improved to detect running
on XQuartz and XWin X11 servers, to activate the correct OS-X
and Win32 keycode maps.

Signed-off-by: Daniel P. Berrange 
---
 include/ui/input.h |  21 +
 ui/Makefile.objs   |  12 ++-
 ui/gtk.c   | 205 ++--
 ui/input-keymap.c  |   7 ++
 ui/sdl.c   | 103 +++---
 ui/trace-events|   9 +-
 ui/x_keymap.c  | 247 -
 ui/x_keymap.h  |   8 +-
 8 files changed, 294 insertions(+), 318 deletions(-)

diff --git a/include/ui/input.h b/include/ui/input.h
index 11bf94aacf..7ac1d62747 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -65,6 +65,9 @@ void qemu_input_check_mode_change(void);
 void qemu_add_mouse_mode_change_notifier(Notifier *notify);
 void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
 
+extern const guint qemu_input_map_atset12qcode_len;
+extern const guint16 qemu_input_map_atset12qcode[];
+
 extern const guint qemu_input_map_linux2qcode_len;
 extern const guint16 qemu_input_map_linux2qcode[];
 
@@ -98,4 +101,22 @@ extern const guint16 qemu_input_map_qnum2qcode[];
 extern const guint qemu_input_map_usb2qcode_len;
 extern const guint16 qemu_input_map_usb2qcode[];
 
+extern const guint qemu_input_map_win322qcode_len;
+extern const guint16 qemu_input_map_win322qcode[];
+
+extern const guint qemu_input_map_x112qcode_len;
+extern const guint16 qemu_input_map_x112qcode[];
+
+extern const guint qemu_input_map_xorgevdev2qcode_len;
+extern const guint16 qemu_input_map_xorgevdev2qcode[];
+
+extern const guint qemu_input_map_xorgkbd2qcode_len;
+extern const guint16 qemu_input_map_xorgkbd2qcode[];
+
+extern const guint qemu_input_map_xorgxquartz2qcode_len;
+extern const guint16 qemu_input_map_xorgxquartz2qcode[];
+
+extern const guint qemu_input_map_xorgxwin2qcode_len;
+extern const guint16 qemu_input_map_xorgxwin2qcode[];
+
 #endif /* INPUT_H */
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index cd2bf1e790..f240c4aa87 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -11,11 +11,12 @@ common-obj-y += keymaps.o console.o cursor.o qemu-pixman.o
 common-obj-y += input.o input-keymap.o input-legacy.o
 common-obj-$(CONFIG_LINUX) += input-linux.o
 common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
-common-obj-$(CONFIG_SDL) += sdl.mo x_keymap.o
+common-obj-$(CONFIG_SDL) += sdl.mo
 common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_CURSES) += curses.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
-common-obj-$(CONFIG_GTK) += gtk.o x_keymap.o
+common-obj-$(CONFIG_GTK) += gtk.o
+common-obj-$(if $(CONFIG_WIN32),n,$(if $(CONFIG_SDL),y,$(CONFIG_GTK))) += 
x_keymap.o
 
 ifeq ($(CONFIG_SDLABI),1.2)
 sdl.mo-objs := sdl.o sdl_zoom.o
@@ -54,6 +55,7 @@ KEYCODEMAP_GEN = ui/keycodemapdb/tools/keymap-gen
 KEYCODEMAP_CSV = ui/keycodemapdb/data/keymaps.csv
 
 KEYCODEMAP_FILES = \
+ui/input-keymap-atset12qcode.c \
 ui/input-keymap-linux2qcode.c \
 ui/input-keymap-osx2qcode.c \
 ui/input-keymap-qcode2adb.c \
@@ -65,6 +67,12 @@ KEYCODEMAP_FILES = \
 ui/input-keymap-qcode2sun.c \
 ui/input-keymap-qnum2qcode.c \
 ui/input-keymap-usb2qcode.c \
+ui/input-keymap-win322qcode.c \
+ui/input-keymap-x112qcode.c \
+ui/input-keymap-xorgevdev2qcode.c \
+ui/input-keymap-xorgkbd2qcode.c \
+ui/input-keymap-xorgxquartz2qcode.c \
+ui/input-keymap-xorgxwin2qcode.c \
 $(NULL)
 
 GENERATED_FILES += $(KEYCODEMAP_FILES)
diff --git a/ui/gtk.c b/ui/gtk.c
index 5bd87c265a..52519e9aeb 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -52,7 +52,6 @@
 #include "ui/input.h"
 #include "sysemu/sysemu.h"
 #include "qmp-commands.h"
-#include "x_keymap.h"
 #include "keymaps.h"
 #include "chardev/char.h"
 #include "qom/object.h"
@@ -65,6 +64,48 @@
 #define VC_SCALE_MIN0.25
 #define VC_SCALE_STEP   0.25
 
+#ifdef GDK_WINDOWING_X11
+#include "ui/x_keymap.h"
+
+/* Gtk2 compat */
+#ifndef GDK_IS_X11_DISPLAY
+#define GDK_IS_X11_DISPLAY(dpy) (dpy != NULL)
+#endif
+#endif
+
+
+#ifdef GDK_WINDOWING_WAYLAND
+/* Gtk2 compat */
+#ifndef GDK_IS_WAYLAND_DISPLAY
+#define GDK_IS_WAYLAND_DISPLAY(dpy) (dpy != NULL)
+#endif
+#endif
+
+
+#ifdef GDK_WINDOWING_WIN32
+/* Gtk2 compat */
+#ifndef GDK_IS_WIN32_DISPLAY
+#define GDK_IS_WIN32_DISPLAY(dpy) (dpy != NULL)
+#endif
+#endif
+
+
+#ifdef GDK_WINDOWING_BROADWAY
+/* Gtk2 compat */
+#ifndef GDK_IS_BROADWAY_DISPLAY
+#define GDK_IS_BROADWAY_DISPLAY(dpy) (dpy != NULL)
+#endif
+#endif
+
+
+#ifdef GDK_WINDOWING_QUARTZ
+/* Gtk2 compat */
+#ifndef GDK_IS_QUARTZ_DISPLAY
+#define GDK_IS_QUARTZ_DISPLAY(dpy) (dpy != NULL)
+#endif
+#endif
+
+
 #if 

[Qemu-devel] [PATCH 08/15] input: convert the adb device to keycodemapdb

2017-08-10 Thread Daniel P. Berrange
Replace the qcode_to_adb_keycode table with automatically
generated tables.

Missing entries in qcode_to_adb_keycode now fixed:

 - Q_KEY_CODE_KP_COMMA -> 0x47

Signed-off-by: Daniel P. Berrange 
---
 hw/input/adb.c  | 124 +-
 include/hw/input/adb-keys.h | 141 
 include/ui/input.h  |   3 +
 ui/Makefile.objs|   1 +
 ui/input-keymap.c   |   1 +
 5 files changed, 7 insertions(+), 263 deletions(-)
 delete mode 100644 include/hw/input/adb-keys.h

diff --git a/hw/input/adb.c b/hw/input/adb.c
index 992f5bd1c4..1a3216c31b 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -25,7 +25,6 @@
 #include "hw/hw.h"
 #include "hw/input/adb.h"
 #include "ui/console.h"
-#include "include/hw/input/adb-keys.h"
 #include "ui/input.h"
 #include "sysemu/sysemu.h"
 
@@ -193,125 +192,6 @@ typedef struct ADBKeyboardClass {
 DeviceRealize parent_realize;
 } ADBKeyboardClass;
 
-int qcode_to_adb_keycode[] = {
- /* Make sure future additions are automatically set to NO_KEY */
-[0 ... 0xff]   = NO_KEY,
-
-[Q_KEY_CODE_SHIFT] = ADB_KEY_LEFT_SHIFT,
-[Q_KEY_CODE_SHIFT_R]   = ADB_KEY_RIGHT_SHIFT,
-[Q_KEY_CODE_ALT]   = ADB_KEY_LEFT_OPTION,
-[Q_KEY_CODE_ALT_R] = ADB_KEY_RIGHT_OPTION,
-[Q_KEY_CODE_CTRL]  = ADB_KEY_LEFT_CONTROL,
-[Q_KEY_CODE_CTRL_R]= ADB_KEY_RIGHT_CONTROL,
-[Q_KEY_CODE_META_L]= ADB_KEY_COMMAND,
-[Q_KEY_CODE_META_R]= ADB_KEY_COMMAND,
-[Q_KEY_CODE_SPC]   = ADB_KEY_SPACEBAR,
-
-[Q_KEY_CODE_ESC]   = ADB_KEY_ESC,
-[Q_KEY_CODE_1] = ADB_KEY_1,
-[Q_KEY_CODE_2] = ADB_KEY_2,
-[Q_KEY_CODE_3] = ADB_KEY_3,
-[Q_KEY_CODE_4] = ADB_KEY_4,
-[Q_KEY_CODE_5] = ADB_KEY_5,
-[Q_KEY_CODE_6] = ADB_KEY_6,
-[Q_KEY_CODE_7] = ADB_KEY_7,
-[Q_KEY_CODE_8] = ADB_KEY_8,
-[Q_KEY_CODE_9] = ADB_KEY_9,
-[Q_KEY_CODE_0] = ADB_KEY_0,
-[Q_KEY_CODE_MINUS] = ADB_KEY_MINUS,
-[Q_KEY_CODE_EQUAL] = ADB_KEY_EQUAL,
-[Q_KEY_CODE_BACKSPACE] = ADB_KEY_DELETE,
-[Q_KEY_CODE_TAB]   = ADB_KEY_TAB,
-[Q_KEY_CODE_Q] = ADB_KEY_Q,
-[Q_KEY_CODE_W] = ADB_KEY_W,
-[Q_KEY_CODE_E] = ADB_KEY_E,
-[Q_KEY_CODE_R] = ADB_KEY_R,
-[Q_KEY_CODE_T] = ADB_KEY_T,
-[Q_KEY_CODE_Y] = ADB_KEY_Y,
-[Q_KEY_CODE_U] = ADB_KEY_U,
-[Q_KEY_CODE_I] = ADB_KEY_I,
-[Q_KEY_CODE_O] = ADB_KEY_O,
-[Q_KEY_CODE_P] = ADB_KEY_P,
-[Q_KEY_CODE_BRACKET_LEFT]  = ADB_KEY_LEFT_BRACKET,
-[Q_KEY_CODE_BRACKET_RIGHT] = ADB_KEY_RIGHT_BRACKET,
-[Q_KEY_CODE_RET]   = ADB_KEY_RETURN,
-[Q_KEY_CODE_A] = ADB_KEY_A,
-[Q_KEY_CODE_S] = ADB_KEY_S,
-[Q_KEY_CODE_D] = ADB_KEY_D,
-[Q_KEY_CODE_F] = ADB_KEY_F,
-[Q_KEY_CODE_G] = ADB_KEY_G,
-[Q_KEY_CODE_H] = ADB_KEY_H,
-[Q_KEY_CODE_J] = ADB_KEY_J,
-[Q_KEY_CODE_K] = ADB_KEY_K,
-[Q_KEY_CODE_L] = ADB_KEY_L,
-[Q_KEY_CODE_SEMICOLON] = ADB_KEY_SEMICOLON,
-[Q_KEY_CODE_APOSTROPHE]= ADB_KEY_APOSTROPHE,
-[Q_KEY_CODE_GRAVE_ACCENT]  = ADB_KEY_GRAVE_ACCENT,
-[Q_KEY_CODE_BACKSLASH] = ADB_KEY_BACKSLASH,
-[Q_KEY_CODE_Z] = ADB_KEY_Z,
-[Q_KEY_CODE_X] = ADB_KEY_X,
-[Q_KEY_CODE_C] = ADB_KEY_C,
-[Q_KEY_CODE_V] = ADB_KEY_V,
-[Q_KEY_CODE_B] = ADB_KEY_B,
-[Q_KEY_CODE_N] = ADB_KEY_N,
-[Q_KEY_CODE_M] = ADB_KEY_M,
-[Q_KEY_CODE_COMMA] = ADB_KEY_COMMA,
-[Q_KEY_CODE_DOT]   = ADB_KEY_PERIOD,
-[Q_KEY_CODE_SLASH] = ADB_KEY_FORWARD_SLASH,
-[Q_KEY_CODE_ASTERISK]  = ADB_KEY_KP_MULTIPLY,
-[Q_KEY_CODE_CAPS_LOCK] = ADB_KEY_CAPS_LOCK,
-
-[Q_KEY_CODE_F1]= ADB_KEY_F1,
-[Q_KEY_CODE_F2]= ADB_KEY_F2,
-[Q_KEY_CODE_F3]= ADB_KEY_F3,
-[Q_KEY_CODE_F4]= ADB_KEY_F4,
-[Q_KEY_CODE_F5]= ADB_KEY_F5,
-[Q_KEY_CODE_F6]= ADB_KEY_F6,
-[Q_KEY_CODE_F7]= ADB_KEY_F7,
-[Q_KEY_CODE_F8]= ADB_KEY_F8,
-[Q_KEY_CODE_F9]= ADB_KEY_F9,
-[Q_KEY_CODE_F10]   = ADB_KEY_F10,
-[Q_KEY_CODE_F11]   = ADB_KEY_F11,
-[Q_KEY_CODE_F12]   = ADB_KEY_F12,
-[Q_KEY_CODE_PRINT] = ADB_KEY_F13,
-[Q_KEY_CODE_SYSRQ] = ADB_KEY_F13,
-[Q_KEY_CODE_SCROLL_LOCK]   = ADB_KEY_F14,
-[Q_KEY_CODE_PAUSE] = ADB_KEY_F15,
-
-[Q_KEY_CODE_NUM_LOCK]  = ADB_KEY_KP_CLEAR,
-[Q_KEY_CODE_KP_EQUALS] = ADB_KEY_KP_EQUAL,

Re: [Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support

2017-08-10 Thread no-reply
Hi,

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

Message-id: 20170810160451.32723-1-berra...@redhat.com
Subject: [Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support
Type: series

=== 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
time make docker-test-build@min-glib
time make docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]   patchew/20170810160451.32723-1-berra...@redhat.com 
-> patchew/20170810160451.32723-1-berra...@redhat.com
Switched to a new branch 'test'
c80d4b3d99 sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
85193a29c1 ui: convert VNC server to QIONetListener
59dd1813c8 chardev: convert the socket server to QIONetListener
2304ec200f migration: convert socket server to QIONetListener
4f4c339d2c blockdev: convert qemu-nbd server to QIONetListener
9837cc0ccd blockdev: convert internal NBD server to QIONetListener
f3aa1d82c5 io: introduce a network socket listener API
81584cdc6f tests: add functional test validating ipv4/ipv6 address flag handling

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-7o1dgdzo/src/dtc'...
Submodule path 'dtc': checked out '558cd81bdd432769b59bff01240c44f82cfb1a9d'
  BUILD   centos6
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-7o1dgdzo/src'
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  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
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
flex-2.5.35-9.el6.x86_64
gcc-4.4.7-18.el6.x86_64
git-1.7.1-8.el6.x86_64
glib2-devel-2.28.8-9.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=libfdt-devel ccache tar git make gcc g++ flex bison zlib-devel 
glib2-devel SDL-devel pixman-devel epel-release
HOSTNAME=638a1a17597e
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu 
--prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code
Install prefix/var/tmp/qemu-build/install
BIOS directory/var/tmp/qemu-build/install/share/qemu
binary directory  /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib
module directory  /var/tmp/qemu-build/install/lib/qemu
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory  /var/tmp/qemu-build/install/etc
local state directory   /var/tmp/qemu-build/install/var
Manual directory  /var/tmp/qemu-build/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path   /tmp/qemu-test/src
C compilercc
Host C compiler   cc
C++ compiler  
Objective-C compiler cc

[Qemu-devel] [PATCH 2/2] backup: QEMU Backup Tool

2017-08-10 Thread Ishani Chugh
qemu-backup will be a command-line tool for performing full and
incremental disk backups on running VMs. It is intended as a
reference implementation for management stack and backup developers
to see QEMU's backup features in action. The tool writes details of
guest in a configuration file and the data is retrieved from the file
while creating a backup. The location of config file can be set as an
environment variable QEMU_BACKUP_CONFIG. The usage is as follows:

Add a guest
python qemu-backup.py guest add --guest  --qmp 

Add a drive for backup in a specified guest
python qemu-backup.py drive add --guest  --id  [--target 
]

Create backup of the added drives:
python qemu-backup.py backup --guest 

List all guest configs in configuration file:
python qemu-backup.py guest list

Restore operation
python qemu-backup.py restore --guest 

Remove a guest
python qemu-backup.py guest remove --guest 

Signed-off-by: Ishani Chugh 
---
 contrib/backup/qemu-backup.py | 309 ++
 1 file changed, 309 insertions(+)
 create mode 100644 contrib/backup/qemu-backup.py

diff --git a/contrib/backup/qemu-backup.py b/contrib/backup/qemu-backup.py
new file mode 100644
index 000..9bbbdb7
--- /dev/null
+++ b/contrib/backup/qemu-backup.py
@@ -0,0 +1,309 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+#
+
+"""
+This file is an implementation of backup tool
+"""
+from __future__ import print_function
+from argparse import ArgumentParser
+import os
+import errno
+from socket import error as socket_error
+try:
+import configparser
+except ImportError:
+import ConfigParser as configparser
+import sys
+sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',
+ 'scripts', 'qmp'))
+from qmp import QEMUMonitorProtocol
+
+
+class BackupTool(object):
+"""BackupTool Class"""
+def __init__(self,
+ config_file=os.path.expanduser('~')+'/.qemu/backup/config'):
+if "QEMU_BACKUP_CONFIG" in os.environ:
+self.config_file = os.environ["QEMU_BACKUP_CONFIG"]
+else:
+self.config_file = config_file
+try:
+if not os.path.isdir(os.path.expanduser('~')+'/.qemu/backup'):
+os.makedirs(os.path.expanduser('~')+'/.qemu/backup')
+except:
+print("Cannot find the config file", file=sys.stderr)
+exit(1)
+self.config = configparser.ConfigParser()
+self.config.read(self.config_file)
+
+def write_config(self):
+"""
+Writes configuration to ini file.
+"""
+config_file = open(self.config_file+".tmp", 'w')
+self.config.write(config_file)
+config_file.flush()
+os.fsync(config_file.fileno())
+config_file.close()
+os.rename(self.config_file+".tmp", self.config_file)
+
+def get_socket_address(self, socket_address):
+"""
+Return Socket address in form of string or tuple
+"""
+if socket_address.startswith('tcp'):
+return (socket_address.split(':')[1],
+int(socket_address.split(':')[2]))
+return socket_address.split(':',2)[1]
+
+def _full_backup(self, guest_name):
+"""
+Performs full backup of guest
+"""
+if guest_name not in self.config.sections():
+print ("Cannot find specified guest", file=sys.stderr)
+exit(1)
+
+self.verify_guest_running(guest_name)
+connection = QEMUMonitorProtocol(
+ self.get_socket_address(
+ self.config[guest_name]['qmp']))
+connection.connect()
+cmd = {"execute": "transaction", "arguments": {"actions": []}}
+for key in self.config[guest_name]:
+if key.startswith("drive_"):
+drive = key[len('drive_'):]
+target = self.config[guest_name][key]
+sub_cmd = {"type": "drive-backup", "data": {"device": drive,
+"target": target,
+"sync": "full"}}
+

Re: [Qemu-devel] [PULL] 9pfs fixes for 2.10 20170810

2017-08-10 Thread Peter Maydell
On 10 August 2017 at 17:02, Greg Kurz  wrote:
> The following changes since commit b38df311c174c98ef8cce7dec9f46603b083018e:
>
>   Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.10-20170809' 
> into staging (2017-08-10 11:12:36 +0100)
>
> are available in the git repository at:
>
>   https://github.com/gkurz/qemu.git tags/for-upstream
>
> for you to fetch changes up to 4751fd5328dfcd4fe2f9055728a72a0e3ae56512:
>
>   9pfs: local: fix fchmodat_nofollow() limitations (2017-08-10 14:36:11 +0200)
>
> 
> Just a single fix for an annoying regression introduced in 2.9 when fixing
> CVE-2016-9602.
>
> 
> Greg Kurz (1):
>   9pfs: local: fix fchmodat_nofollow() limitations
>
>  hw/9pfs/9p-local.c | 42 +++---
>  hw/9pfs/9p-util.h  | 24 +++-
>  2 files changed, 50 insertions(+), 16 deletions(-)
> --

Applied, thanks.

-- PMM



[Qemu-devel] [PULL for-2.10 1/3] IDE: Do not flush empty CDROM drives

2017-08-10 Thread Stefan Hajnoczi
The block backend changed in a way that flushing empty CDROM drives now
crashes.  Amend IDE to avoid doing so until the root problem can be
addressed for 2.11.

Original patch by John Snow .

Reported-by: Kieron Shorrock 
Signed-off-by: Stefan Hajnoczi 
Reviewed-by: Eric Blake 
Message-id: 20170809160212.29976-2-stefa...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 hw/ide/core.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 0b48b64d3a..bea39536b0 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -1063,7 +1063,15 @@ static void ide_flush_cache(IDEState *s)
 s->status |= BUSY_STAT;
 ide_set_retry(s);
 block_acct_start(blk_get_stats(s->blk), >acct, 0, BLOCK_ACCT_FLUSH);
-s->pio_aiocb = blk_aio_flush(s->blk, ide_flush_cb, s);
+
+if (blk_bs(s->blk)) {
+s->pio_aiocb = blk_aio_flush(s->blk, ide_flush_cb, s);
+} else {
+/* XXX blk_aio_flush() crashes when blk_bs(blk) is NULL, remove this
+ * temporary workaround when blk_aio_*() functions handle NULL blk_bs.
+ */
+ide_flush_cb(s, 0);
+}
 }
 
 static void ide_cfata_metadata_inquiry(IDEState *s)
-- 
2.13.4




Re: [Qemu-devel] [PATCH 00/15] Convert over to use keycodemapdb

2017-08-10 Thread no-reply
Hi,

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

Subject: [Qemu-devel] [PATCH 00/15] Convert over to use keycodemapdb
Type: series
Message-id: 20170810155522.31099-1-berra...@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 ==="
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
 - [tag update]  
patchew/150229685736.21846.2809147507731700887.st...@bahia.lan -> 
patchew/150229685736.21846.2809147507731700887.st...@bahia.lan
 - [tag update]  
patchew/1502359588-29451-1-git-send-email-arm...@redhat.com -> 
patchew/1502359588-29451-1-git-send-email-arm...@redhat.com
 - [tag update]  patchew/1502365466-19432-1-git-send-email-th...@redhat.com 
-> patchew/1502365466-19432-1-git-send-email-th...@redhat.com
 - [tag update]  
patchew/1502367921-17730-1-git-send-email-arm...@redhat.com -> 
patchew/1502367921-17730-1-git-send-email-arm...@redhat.com
 - [tag update]  patchew/20170808162629.32493-1-quint...@redhat.com -> 
patchew/20170808162629.32493-1-quint...@redhat.com
 - [tag update]  patchew/20170809203808.31725-1-ebl...@redhat.com -> 
patchew/20170809203808.31725-1-ebl...@redhat.com
 - [tag update]  patchew/20170810080108.31047-1-f...@redhat.com -> 
patchew/20170810080108.31047-1-f...@redhat.com
 - [tag update]  patchew/20170810123741.30449-1-coh...@redhat.com -> 
patchew/20170810123741.30449-1-coh...@redhat.com
 * [new tag] patchew/20170810155522.31099-1-berra...@redhat.com -> 
patchew/20170810155522.31099-1-berra...@redhat.com
Switched to a new branch 'test'
7c26de2 display: convert XenInput keyboard to keycodemapdb
b9d4f63 ui: remove qemu_input_linux_to_qcode method
b82952e ui: remove qemu_input_qcode_to_number method
e61e51c ui: convert GTK and SDL1 frontends to keycodemapdb
8da0073 ui: convert the SDL2 frontend to keycodemapdb
f4347fa ui: convert cocoa frontend to keycodemapdb
0bb5e3c char: convert the escc device to keycodemapdb
1524c65 input: convert the adb device to keycodemapdb
931965d input: convert ps2 device to keycodemapdb
0e01238 input: convert virtio-input-hid device to keycodemapdb
f6ca40d ui: use QKeyCode exclusively in InputKeyEvent
5252b59 ui: don't export qemu_input_event_new_key
047c3a0 ui: convert key events to QKeyCodes immediately
9ee7d58 ui: convert common input code to keycodemapdb
ae5a212 ui: add keycodemapdb repository as a GIT submodule

=== OUTPUT BEGIN ===
=== ENV ===
XDG_SESSION_ID=20695
SHELL=/bin/sh
USER=fam
PATCHEW=/home/fam/patchew/patchew-cli -s http://patchew.org --nodebug
PATH=/usr/bin:/bin
PWD=/var/tmp/patchew-tester-tmp-pe1ekf8x/src
LANG=en_US.UTF-8
HOME=/home/fam
SHLVL=2
LOGNAME=fam
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1012/bus
XDG_RUNTIME_DIR=/run/user/1012
_=/usr/bin/env
=== PACKAGES ===
gpg-pubkey-873529b8-54e386ff
xz-libs-5.2.2-2.fc24.s390x
libxshmfence-1.2-3.fc24.s390x
giflib-4.1.6-15.fc24.s390x
trousers-lib-0.3.13-6.fc24.s390x
ncurses-base-6.0-6.20160709.fc25.noarch
gmp-6.1.1-1.fc25.s390x
libidn-1.33-1.fc25.s390x
slang-2.3.0-7.fc25.s390x
pkgconfig-0.29.1-1.fc25.s390x
alsa-lib-1.1.1-2.fc25.s390x
yum-metadata-parser-1.1.4-17.fc25.s390x
python3-slip-dbus-0.6.4-4.fc25.noarch
python2-cssselect-0.9.2-1.fc25.noarch
createrepo_c-libs-0.10.0-6.fc25.s390x
initscripts-9.69-1.fc25.s390x
parted-3.2-21.fc25.s390x
flex-2.6.0-3.fc25.s390x
colord-libs-1.3.4-1.fc25.s390x
python-osbs-client-0.33-3.fc25.noarch
perl-Pod-Simple-3.35-1.fc25.noarch
python2-simplejson-3.10.0-1.fc25.s390x
brltty-5.4-2.fc25.s390x
librados2-10.2.4-2.fc25.s390x
tcp_wrappers-7.6-83.fc25.s390x
libcephfs_jni1-10.2.4-2.fc25.s390x
nettle-devel-3.3-1.fc25.s390x
bzip2-devel-1.0.6-21.fc25.s390x
libuuid-2.28.2-2.fc25.s390x
python3-dnf-1.1.10-6.fc25.noarch
texlive-kpathsea-doc-svn41139-33.fc25.1.noarch
openssh-7.4p1-4.fc25.s390x
texlive-kpathsea-bin-svn40473-33.20160520.fc25.1.s390x
texlive-graphics-svn41015-33.fc25.1.noarch
texlive-dvipdfmx-def-svn40328-33.fc25.1.noarch
texlive-mfware-svn40768-33.fc25.1.noarch
texlive-texlive-scripts-svn41433-33.fc25.1.noarch
texlive-euro-svn22191.1.1-33.fc25.1.noarch
texlive-etex-svn37057.0-33.fc25.1.noarch
texlive-iftex-svn29654.0.2-33.fc25.1.noarch
texlive-palatino-svn31835.0-33.fc25.1.noarch
texlive-texlive-docindex-svn41430-33.fc25.1.noarch
texlive-xunicode-svn30466.0.981-33.fc25.1.noarch
texlive-koma-script-svn41508-33.fc25.1.noarch
texlive-pst-grad-svn15878.1.06-33.fc25.1.noarch
texlive-pst-blur-svn15878.2.0-33.fc25.1.noarch

[Qemu-devel] [PATCH 4/8] blockdev: convert qemu-nbd server to QIONetListener

2017-08-10 Thread Daniel P. Berrange
Instead of creating a QIOChannelSocket directly for the NBD
server socket, use a QIONetListener. This provides the ability
to listen on multiple sockets at the same time, so enables
full support for IPv4/IPv6 dual stack.

Signed-off-by: Daniel P. Berrange 
---
 qemu-nbd.c | 50 +-
 1 file changed, 17 insertions(+), 33 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index b8666bb575..dcde7ac75c 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -38,6 +38,7 @@
 #include "qapi/qmp/qstring.h"
 #include "qom/object_interfaces.h"
 #include "io/channel-socket.h"
+#include "io/net-listener.h"
 #include "crypto/init.h"
 #include "trace/control.h"
 #include "qemu-version.h"
@@ -63,8 +64,7 @@ static int persistent = 0;
 static enum { RUNNING, TERMINATE, TERMINATING, TERMINATED } state;
 static int shared = 1;
 static int nb_fds;
-static QIOChannelSocket *server_ioc;
-static int server_watch = -1;
+static QIONetListener *server;
 static QCryptoTLSCreds *tlscreds;
 
 static void usage(const char *name)
@@ -345,44 +345,24 @@ static void nbd_client_closed(NBDClient *client, bool 
negotiated)
 nbd_client_put(client);
 }
 
-static gboolean nbd_accept(QIOChannel *ioc, GIOCondition cond, gpointer opaque)
+static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc, 
gpointer opaque)
 {
-QIOChannelSocket *cioc;
-
-cioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
- NULL);
-if (!cioc) {
-return TRUE;
-}
-
 if (state >= TERMINATE) {
-object_unref(OBJECT(cioc));
-return TRUE;
+return;
 }
 
 nb_fds++;
 nbd_update_server_watch();
 nbd_client_new(newproto ? NULL : exp, cioc,
tlscreds, NULL, nbd_client_closed);
-object_unref(OBJECT(cioc));
-
-return TRUE;
 }
 
 static void nbd_update_server_watch(void)
 {
 if (nbd_can_accept()) {
-if (server_watch == -1) {
-server_watch = qio_channel_add_watch(QIO_CHANNEL(server_ioc),
- G_IO_IN,
- nbd_accept,
- NULL, NULL);
-}
+qio_net_listener_set_client_func(server, nbd_accept, NULL, NULL);
 } else {
-if (server_watch != -1) {
-g_source_remove(server_watch);
-server_watch = -1;
-}
+qio_net_listener_set_client_func(server, NULL, NULL, NULL);
 }
 }
 
@@ -917,24 +897,28 @@ int main(int argc, char **argv)
 snprintf(sockpath, 128, SOCKET_PATH, basename(device));
 }
 
+server = qio_net_listener_new();
 if (socket_activation == 0) {
-server_ioc = qio_channel_socket_new();
 saddr = nbd_build_socket_address(sockpath, bindto, port);
-if (qio_channel_socket_listen_sync(server_ioc, saddr, _err) < 0) 
{
-object_unref(OBJECT(server_ioc));
+if (qio_net_listener_open_sync(server, saddr, _err) < 0) {
+object_unref(OBJECT(server));
 error_report_err(local_err);
-return 1;
+exit(EXIT_FAILURE);
 }
 } else {
+QIOChannelSocket *sioc;
 /* See comment in check_socket_activation above. */
 assert(socket_activation == 1);
-server_ioc = qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_FD,
-   _err);
-if (server_ioc == NULL) {
+sioc = qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_FD,
+ _err);
+if (sioc == NULL) {
+object_unref(OBJECT(server));
 error_report("Failed to use socket activation: %s",
  error_get_pretty(local_err));
 exit(EXIT_FAILURE);
 }
+qio_net_listener_add(server, sioc);
+object_unref(OBJECT(sioc));
 }
 
 if (qemu_init_main_loop(_err)) {
-- 
2.13.3




Re: [Qemu-devel] [PATCH 1/2] vl: Factor object_create() out of main()

2017-08-10 Thread Markus Armbruster
Eric Blake  writes:

> On 08/10/2017 07:25 AM, Markus Armbruster wrote:
>> Signed-off-by: Markus Armbruster 
>> ---
>>  vl.c | 21 ++---
>>  1 file changed, 10 insertions(+), 11 deletions(-)
>> 
>
>> +++ b/vl.c
>> @@ -2845,7 +2845,6 @@ static bool object_create_initial(const char *type)
>>  return true;
>>  }
>>  
>> -
>>  /*
>
> Spurious whitespace change? I can live with it because it adds
> consistency, but it's not on a function directly touched by this patch.

Not intentional (alternatively: I've since forgotten).  I'll drop it.

> Reviewed-by: Eric Blake 

Thanks!



Re: [Qemu-devel] [PATCH 2/2] vl: Partial support for non-scalar properties with -object

2017-08-10 Thread Markus Armbruster
Paolo Bonzini  writes:

> On 10/08/2017 14:25, Markus Armbruster wrote:
>> We've wanted -object to support non-scalar properties for a while.
>> Dan Berrange tried in "[PATCH v4 00/10]Provide a QOM-based
>> authorization API".  Review led to the conclusion that we need to
>> replace rather than add to QemuOpts.  Initial work towards that goal
>> has been merged to provide -blockdev (commit 8746709), but there's
>> substantial work left, mostly due to an bewildering array of
>> compatibility problems.
>> 
>> Even if a full solution is still out of reach, we can have a partial
>> solution now: accept -object argument in JSON syntax.  This should
>> unblock development work that needs non-scalar properties with -object
>> 
>> The implementation is similar to -blockdev, except we use the new
>> infrastructure only for the new JSON case, and stick to QemuOpts for
>> the existing KEY=VALUE,... case, to sidestep compatibility problems.
>> 
>> If we did this for more options, we'd have to factor out common code.
>> But for one option, this will do.
>> 
>> Signed-off-by: Markus Armbruster 
>> ---
>>  qapi-schema.json | 14 +++---
>>  vl.c | 55 
>> +++
>>  2 files changed, 66 insertions(+), 3 deletions(-)
>> 
>> diff --git a/qapi-schema.json b/qapi-schema.json
>> index 802ea53..7ed1db1 100644
>> --- a/qapi-schema.json
>> +++ b/qapi-schema.json
>> @@ -3618,15 +3618,23 @@
>>  { 'command': 'netdev_del', 'data': {'id': 'str'} }
>>  
>>  ##
>> -# @object-add:
>> +# @ObjectOptions:
>>  #
>> -# Create a QOM object.
>> +# Options for creating an object.
>>  #
>>  # @qom-type: the class name for the object to be created
>>  #
>>  # @id: the name of the new object
>>  #
>>  # @props: a dictionary of properties to be passed to the backend
>> +##
>> +{ 'struct': 'ObjectOptions',
>> +  'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'} }
>> +
>> +##
>> +# @object-add:
>> +#
>> +# Create a QOM object.
>>  #
>>  # Returns: Nothing on success
>>  #  Error if @qom-type is not a valid class name
>> @@ -3642,7 +3650,7 @@
>>  #
>>  ##
>>  { 'command': 'object-add',
>> -  'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'} }
>> +  'data': 'ObjectOptions' }
>>  
>>  ##
>>  # @object-del:
>> diff --git a/vl.c b/vl.c
>> index fd98ed1..db4680b 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2854,8 +2854,32 @@ static bool object_create_delayed(const char *type)
>>  return !object_create_initial(type);
>>  }
>>  
>> +typedef struct ObjectOptionsQueueEntry {
>> +ObjectOptions *oo;
>> +Location loc;
>> +QSIMPLEQ_ENTRY(ObjectOptionsQueueEntry) entry;
>> +} ObjectOptionsQueueEntry;
>> +
>> +typedef QSIMPLEQ_HEAD(ObjectOptionsQueue, ObjectOptionsQueueEntry)
>> +ObjectOptionsQueue;
>> +
>> +ObjectOptionsQueue oo_queue = QSIMPLEQ_HEAD_INITIALIZER(oo_queue);
>> +
>> +
>>  static void object_create(bool (*type_predicate)(const char *))
>>  {
>> +ObjectOptionsQueueEntry *e;
>> +
>> +QSIMPLEQ_FOREACH(e, _queue, entry) {
>> +if (!type_predicate(e->oo->qom_type)) {
>> +continue;
>> +}
>> +loc_push_restore(>loc);
>> +qmp_object_add(e->oo->qom_type, e->oo->id,
>> +   e->oo->has_props, e->oo->props, _fatal);
>> +loc_pop(>loc);
>> +}
>> +
>>  if (qemu_opts_foreach(qemu_find_opts("object"),
>>user_creatable_add_opts_foreach,
>>type_predicate, NULL)) {
>> @@ -4078,6 +4102,29 @@ int main(int argc, char **argv, char **envp)
>>  #endif
>>  break;
>>  case QEMU_OPTION_object:
>> +/*
>> + * TODO Use qobject_input_visitor_new_str() instead of
>> + * QemuOpts, not in addition to.  Not done now because
>> + * keyval_parse() isn't wart-compatible with QemuOpts.
>> + */
>> +if (optarg[0] == '{') {
>> +Visitor *v;
>> +ObjectOptionsQueueEntry *e;
>> +
>> +v = qobject_input_visitor_new_str(optarg, "qom-type",
>> +  );
>> +if (!v) {
>> +error_report_err(err);
>> +exit(1);
>> +}
>> +
>> +e = g_new(ObjectOptionsQueueEntry, 1);
>> +visit_type_ObjectOptions(v, NULL, >oo, _fatal);
>> +visit_free(v);
>> +loc_save(>loc);
>> +QSIMPLEQ_INSERT_TAIL(_queue, e, entry);
>> +break;
>> +}
>>  opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
>> optarg, true);
>>  if (!opts) {
>> @@ -4525,6 +4572,14 @@ int main(int argc, char **argv, char **envp)
>>  
>>  

Re: [Qemu-devel] [PATCH v8 0/8] Optimize VMDK I/O by allocating multiple clusters

2017-08-10 Thread Stefan Hajnoczi
On Thu, Aug 10, 2017 at 9:18 AM, Ashijeet Acharya
 wrote:
> On Thu, Aug 10, 2017 at 1:41 PM, Stefan Hajnoczi  wrote:
>>
>> On Thu, Jul 27, 2017 at 3:33 PM, Ashijeet Acharya
>>  wrote:
>> > Previously posted series patches:
>> > v1 -
>> > http://lists.nongnu.org/archive/html/qemu-devel/2017-03/msg02044.html
>> > v2 -
>> > http://lists.nongnu.org/archive/html/qemu-devel/2017-03/msg05080.html
>> > v3 -
>> > http://lists.nongnu.org/archive/html/qemu-devel/2017-04/msg00074.html
>> > v4 -
>> > http://lists.nongnu.org/archive/html/qemu-devel/2017-04/msg03851.html
>> > v5 -
>> > http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg00929.html
>> > v6 -
>> > http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg00947.html
>> > v7 -
>> > http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg06600.html
>> >
>> > This series helps to optimize the I/O performance of VMDK driver.
>> >
>> > Patch 1 helps us to move vmdk_find_offset_in_cluster.
>> >
>> > Patch 2 & 3 perform a simple function re-naming tasks.
>> >
>> > Patch 4 is used to factor out metadata loading code and implement it in
>> > separate
>> > functions. This will help us to avoid code duplication in future patches
>> > of this
>> > series.
>> >
>> > Patch 5 helps to set the upper limit of the bytes handled in one cycle.
>> >
>> > Patch 6 adds new functions to help us allocate multiple clusters
>> > according to
>> > the size requested, perform COW if required and return the offset of the
>> > first
>> > newly allocated cluster.
>> >
>> > Patch 7 changes the metadata update code to update the L2 tables for
>> > multiple
>> > clusters at once.
>> >
>> > Patch 8 helps us to finally change vmdk_get_cluster_offset() to find
>> > cluster
>> > offset only as cluster allocation task is now handled by
>> > vmdk_alloc_clusters()
>> >
>> > Optimization test results:
>> >
>> > This patch series improves 128 KB sequential write performance to an
>> > empty VMDK file by 54%
>> >
>> > Benchmark command: ./qemu-img bench -w -c 1024 -s 128K -d 1 -t none -f
>> > vmdk test.vmdk
>> >
>> > Changes in v8:
>> > - fix minor variable naming issue in patch 6
>>
>> Fam: Ping?
>>
>> Ashijeet: Feel free to send a ping reply if no one reviews your
>> patches within a few days.
>
>
> Hi Stefan,
>
> I had a chat with Fam on #qemu-block before submitting this series and he
> said he will be merging it soon when the freeze is over (I am not sure if it
> is yet) since all the patches are already reviewed :-)

Good to hear :).

QEMU 2.10 is scheduled to be released on 22nd or 29th of August.

Stefan



[Qemu-devel] [PULL for-2.10 2/3] IDE: test flush on empty CDROM

2017-08-10 Thread Stefan Hajnoczi
From: Kevin Wolf 

Signed-off-by: Kevin Wolf 
Signed-off-by: John Snow 
Reviewed-by: Eric Blake 
Signed-off-by: Stefan Hajnoczi 
Message-id: 20170809160212.29976-3-stefa...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 tests/ide-test.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/tests/ide-test.c b/tests/ide-test.c
index bfd79ddbdc..aa9de065fc 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -689,6 +689,24 @@ static void test_flush_nodev(void)
 ide_test_quit();
 }
 
+static void test_flush_empty_drive(void)
+{
+QPCIDevice *dev;
+QPCIBar bmdma_bar, ide_bar;
+
+ide_test_start("-device ide-cd,bus=ide.0");
+dev = get_pci_device(_bar, _bar);
+
+/* FLUSH CACHE command on device 0 */
+qpci_io_writeb(dev, ide_bar, reg_device, 0);
+qpci_io_writeb(dev, ide_bar, reg_command, CMD_FLUSH_CACHE);
+
+/* Just testing that qemu doesn't crash... */
+
+free_pci_device(dev);
+ide_test_quit();
+}
+
 static void test_pci_retry_flush(void)
 {
 test_retry_flush("pc");
@@ -954,6 +972,7 @@ int main(int argc, char **argv)
 
 qtest_add_func("/ide/flush", test_flush);
 qtest_add_func("/ide/flush/nodev", test_flush_nodev);
+qtest_add_func("/ide/flush/empty_drive", test_flush_empty_drive);
 qtest_add_func("/ide/flush/retry_pci", test_pci_retry_flush);
 qtest_add_func("/ide/flush/retry_isa", test_isa_retry_flush);
 
-- 
2.13.4




[Qemu-devel] [PATCH 8/8] sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr

2017-08-10 Thread Daniel P. Berrange
The inet_parse() function looks for 'ipv4' and 'ipv6'
flags, but only treats them as bare bool flags. The normal
QemuOpts parsing would allow on/off values to be set too.

This updated inet_parse() so that its handling of the
'ipv4' and 'ipv6' flags matches that done by QemuOpts.

Signed-off-by: Daniel P. Berrange 
---
 tests/test-sockets-proto.c | 13 -
 util/qemu-sockets.c| 36 
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/tests/test-sockets-proto.c b/tests/test-sockets-proto.c
index a92389bef6..5805d2be5f 100644
--- a/tests/test-sockets-proto.c
+++ b/tests/test-sockets-proto.c
@@ -69,7 +69,6 @@ typedef struct {
  */
 static QSocketsData test_data[] = {
 /* Migrate with "" address */
-/* XXX all settings with =off are disabled due to inet_parse() bug */
 { .ipv4 = 1, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/wildcard/all",
   .args = "-incoming tcp::9000" },
@@ -85,7 +84,6 @@ static QSocketsData test_data[] = {
 { .ipv4 = 0, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/wildcard/ipv6on",
   .args = "-incoming tcp::9000,ipv6=on" },
-/*
 { .ipv4 = 0, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/wildcard/ipv4off",
   .args = "-incoming tcp::9000,ipv4=off" },
@@ -98,15 +96,12 @@ static QSocketsData test_data[] = {
 { .ipv4 = 0, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/wildcard/ipv4offipv6on",
   .args = "-incoming tcp::9000,ipv4=off,ipv6=on" },
-*/
 { .ipv4 = 1, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/wildcard/ipv4onipv6on",
   .args = "-incoming tcp::9000,ipv4=on,ipv6=on" },
-/*
 { .ipv4 = 0, .ipv6 = 0, .error = true,
   .name = "/sockets/migrate/wildcard/ipv4offipv6off",
   .args = "-incoming tcp::9000,ipv4=off,ipv6=off" },
-*/
 
 /* Migrate with 0.0.0.0 address */
 { .ipv4 = 1, .ipv6 = 0, .error = false,
@@ -124,7 +119,6 @@ static QSocketsData test_data[] = {
 { .ipv4 = 0, .ipv6 = 0, .error = true,
   .name = "/sockets/migrate/0.0.0.0/ipv6on",
   .args = "-incoming tcp:0.0.0.0:9000,ipv6=on" },
-/*
 { .ipv4 = 0, .ipv6 = 0, .error = true,
   .name = "/sockets/migrate/0.0.0.0/ipv4off",
   .args = "-incoming tcp:0.0.0.0:9000,ipv4=off" },
@@ -137,15 +131,12 @@ static QSocketsData test_data[] = {
 { .ipv4 = 0, .ipv6 = 0, .error = true,
   .name = "/sockets/migrate/0.0.0.0/ipv4offipv6on",
   .args = "-incoming tcp:0.0.0.0:9000,ipv4=off,ipv6=on" },
-*/
 { .ipv4 = 1, .ipv6 = 0, .error = false,
   .name = "/sockets/migrate/0.0.0.0/ipv4onipv6on",
   .args = "-incoming tcp:0.0.0.0:9000,ipv4=on,ipv6=on" },
-/*
 { .ipv4 = 0, .ipv6 = 0, .error = true,
   .name = "/sockets/migrate/0.0.0.0/ipv4offipv6off",
   .args = "-incoming tcp:0.0.0.0:9000,ipv4=off,ipv6=off" },
-*/
 
 /* Migrate with :: address */
 { .ipv4 = 1, .ipv6 = 1, .error = false,
@@ -163,7 +154,6 @@ static QSocketsData test_data[] = {
 { .ipv4 = 0, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/::/ipv6on",
   .args = "-incoming tcp:[::]:9000,ipv6=on" },
-/*
 { .ipv4 = 0, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/::/ipv4off",
   .args = "-incoming tcp:[::]:9000,ipv4=off" },
@@ -176,15 +166,12 @@ static QSocketsData test_data[] = {
 { .ipv4 = 0, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/::/ipv4offipv6on",
   .args = "-incoming tcp:[::]:9000,ipv4=off,ipv6=on" },
-*/
 { .ipv4 = 1, .ipv6 = 1, .error = false,
   .name = "/sockets/migrate/::/ipv4onipv6on",
   .args = "-incoming tcp:[::]:9000,ipv4=on,ipv6=on" },
-/*
 { .ipv4 = 0, .ipv6 = 0, .error = true,
   .name = "/sockets/migrate/::/ipv4offipv6off",
   .args = "-incoming tcp:[::]:9000,ipv4=off,ipv6=off" },
-*/
 
 
 
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 1358c81bcc..76202949f5 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -616,6 +616,25 @@ err:
 }
 
 /* compatibility wrapper */
+static int inet_parse_flag(const char *flagname, const char *optstr, bool *val,
+   Error **errp)
+{
+char *end;
+size_t len;
+
+end = strstr(optstr, ",");
+len = end ? end - optstr : strlen(optstr);
+if (len == 0 || (len == 3 && strncmp(optstr, "=on", len) == 0)) {
+*val = true;
+} else if ((len == 4) && strncmp(optstr, "=off", len) == 0) {
+*val = false;
+} else {
+error_setg(errp, "error parsing '%s' flag '%s'", flagname, optstr);
+return -1;
+}
+return 0;
+}
+
 int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)
 {
 const char *optstr, *h;
@@ -623,6 +642,7 @@ int inet_parse(InetSocketAddress *addr, const char *str, 
Error **errp)
 char port[33];
 int to;
 int pos;
+char *begin;
 
 memset(addr, 0, 

Re: [Qemu-devel] [PATCH 00/15] Convert over to use keycodemapdb

2017-08-10 Thread no-reply
Hi,

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

Message-id: 20170810155522.31099-1-berra...@redhat.com
Subject: [Qemu-devel] [PATCH 00/15] Convert over to use keycodemapdb
Type: series

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

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

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]   
patchew/1502380961-16398-2-git-send-email-gr...@kaod.org -> 
patchew/1502380961-16398-2-git-send-email-gr...@kaod.org
Switched to a new branch 'test'
7c26de29e6 display: convert XenInput keyboard to keycodemapdb
b9d4f633bb ui: remove qemu_input_linux_to_qcode method
b82952e02a ui: remove qemu_input_qcode_to_number method
e61e51c4c6 ui: convert GTK and SDL1 frontends to keycodemapdb
8da0073fa4 ui: convert the SDL2 frontend to keycodemapdb
f4347fae8a ui: convert cocoa frontend to keycodemapdb
0bb5e3ca3a char: convert the escc device to keycodemapdb
1524c6518c input: convert the adb device to keycodemapdb
931965df01 input: convert ps2 device to keycodemapdb
0e01238d65 input: convert virtio-input-hid device to keycodemapdb
f6ca40df3d ui: use QKeyCode exclusively in InputKeyEvent
5252b5946a ui: don't export qemu_input_event_new_key
047c3a0c37 ui: convert key events to QKeyCodes immediately
9ee7d5824f ui: convert common input code to keycodemapdb
ae5a212c48 ui: add keycodemapdb repository as a GIT submodule

=== OUTPUT BEGIN ===
Checking PATCH 1/15: ui: add keycodemapdb repository as a GIT submodule...
Checking PATCH 2/15: ui: convert common input code to keycodemapdb...
Checking PATCH 3/15: ui: convert key events to QKeyCodes immediately...
Checking PATCH 4/15: ui: don't export qemu_input_event_new_key...
Checking PATCH 5/15: ui: use QKeyCode exclusively in InputKeyEvent...
WARNING: line over 80 characters
#361: FILE: ui/input.c:380:
+void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode qcode, bool 
down)

total: 0 errors, 1 warnings, 321 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 6/15: input: convert virtio-input-hid device to keycodemapdb...
Checking PATCH 7/15: input: convert ps2 device to keycodemapdb...
Checking PATCH 8/15: input: convert the adb device to keycodemapdb...
Checking PATCH 9/15: char: convert the escc device to keycodemapdb...
Checking PATCH 10/15: ui: convert cocoa frontend to keycodemapdb...
Checking PATCH 11/15: ui: convert the SDL2 frontend to keycodemapdb...
WARNING: line over 80 characters
#101: FILE: ui/sdl2-input.c:40:
+for (i = 0; i < SDL_NUM_SCANCODES && i < qemu_input_map_usb2qcode_len ; 
i++) {

total: 0 errors, 1 warnings, 56 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 12/15: ui: convert GTK and SDL1 frontends to keycodemapdb...
ERROR: unnecessary whitespace before a quoted newline
#279: FILE: ui/gtk.c:1149:
+g_warning("experimental: using broadway, x11 virtual keysym \n"

ERROR: unnecessary whitespace before a quoted newline
#280: FILE: ui/gtk.c:1150:
+  "mapping - with very limited support. See also \n"

ERROR: braces {} are necessary for all arms of this statement
#301: FILE: ui/gtk.c:1170:
+if (!keycode_map)
[...]

ERROR: braces {} are necessary for all arms of this statement
#303: FILE: ui/gtk.c:1172:
+if (scancode > keycode_maplen)
[...]

ERROR: braces {} are necessary for all arms of this statement
#550: FILE: ui/sdl.c:245:
+if (!keycode_map)
[...]

ERROR: braces {} are necessary for all arms of this statement
#552: FILE: ui/sdl.c:247:
+if (ev->keysym.scancode > keycode_maplen)
[...]

ERROR: braces {} are necessary for all arms of this statement
#797: FILE: ui/x_keymap.c:27:
+if (strstr(vendor, "Cygwin/X"))
[...]

ERROR: braces {} are necessary for all arms of this statement
#813: FILE: ui/x_keymap.c:41:
+if (strcmp(extensions[i], "Apple-WM") == 0 ||
[...]

ERROR: braces {} are necessary for all arms of this statement
#817: FILE: ui/x_keymap.c:45:
+if (extensions)
[...]

total: 9 errors, 0 warnings, 833 lines checked

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

Checking PATCH 13/15: ui: remove qemu_input_qcode_to_number method...
Checking PATCH 14/15: ui: remove 

  1   2   >