pvpanic: fix bad merge

Context matching caused the 'has_pvpanic = true' to be applied to
the 1.6 machine type instead of the 1.5 machine type.

Reported-by: Markus Armbruster <armbru@redhat.com>
Reported-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-char: fix infinite recursion connecting to monitor pty

Since commit bd5c51e (qemu-char: don't issue CHR_EVENT_OPEN in a BH), an
infinite recursion occurs when putting the monitor on a pty (-monitor
pty) and connecting a terminal to the slave port.

This is because of the qemu_chr_be_event(s, CHR_EVENT_OPENED) added to
qemu_chr_be_generic_open(). This event is captured by monitor_event()
which prints a welcome message to the character device. The flush of
that welcome message retriggers another open event in pty_chr_state()
because it checks s->connected, but only sets it to 1 after calling
qemu_chr_be_generic_open().

I've fixed this by setting s->connected = 1 before the call to
qemu_chr_be_generic_open() instead of after, so that the recursive
pty_chr_state() doesn't call it again.

An example snippet of repeating backtrace:
 ...
 #107486 0x007aec58 in monitor_flush (mon=0xf418b0) at qemu/monitor.c:288
 #107487 0x007aee7c in monitor_puts (mon=0xf418b0, str=0x1176d07 "") at qemu/monitor.c:322
 #107488 0x007aef20 in monitor_vprintf (mon=0xf418b0, fmt=0x8d4820 "QEMU %s monitor - type 'help' for more information\n",
     ap=0x7f432be0) at qemu/monitor.c:339
 #107489 0x007aefac in monitor_printf (mon=0xf418b0, fmt=0x8d4820 "QEMU %s monitor - type 'help' for more information\n")
     at qemu/monitor.c:347
 #107490 0x007ba4bc in monitor_event (opaque=0xf418b0, event=2) at qemu/monitor.c:4699
 #107491 0x00684c28 in qemu_chr_be_event (s=0xf37788, event=2) at qemu/qemu-char.c:108
 #107492 0x00684c70 in qemu_chr_be_generic_open (s=0xf37788) at qemu/qemu-char.c:113
 #107493 0x006880a4 in pty_chr_state (chr=0xf37788, connected=1) at qemu/qemu-char.c:1145
 #107494 0x00687fa4 in pty_chr_update_read_handler (chr=0xf37788) at qemu/qemu-char.c:1121
 #107495 0x00687c9c in pty_chr_write (chr=0xf37788, buf=0x70b3c008 <Address 0x70b3c008 out of bounds>, len=538720)
     at qemu/qemu-char.c:1063
 #107496 0x00684cc4 in qemu_chr_fe_write (s=0xf37788, buf=0x70b3c008 <Address 0x70b3c008 out of bounds>, len=538720)
     at qemu/qemu-char.c:118
 ...

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Message-id: 1375960178-10882-1-git-send-email-james.hogan@imgtec.com
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: Dont ignore previously set bdrv_flags

bdrv_flags is set by bdrv_parse_discard_flags(), but later it is reset
to zero.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Message-id: 1376483201-13466-1-git-send-email-mohan@in.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
mips_malta: do not raise exceptions when accessing invalid memory

Since commit c658b94f6e8c206c59d02aa6fbac285b86b53d2c, MIPS raises
exceptions when accessing invalid memory. This is not the correct
behaviour for MIPS Malta Core LV, as the GT-64120A system controller
just ignore undecoded access. This feature is used by the Linux kernel
to probe for some devices.

Emulate the correct behaviour in QEMU by adding an empty slot covering
the entire memory space decoded by the GT-64120A.

Tested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Update version for 1.6.0

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Open up 1.7 development branch

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
pc: Remove PCLMULQDQ from Westmere on pc-*-1.4 and older

Commit 41cb383f42d0cb51d8e3e25e3ecebc954dd4196f made a guest-visible
change by adding the PCLMULQDQ bit to Westmere without adding
compatibility code to keep the ABI for older machine-types.
Fix it by adding the missing compat code.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>

Conflicts:
	hw/i386/pc_piix.c
	hw/i386/pc_q35.c

Conflicts:
	hw/i386/pc_q35.c
qemu-option: add def_value_str in QemuOptDesc struct and rewrite qemu_opts_print

qemu_opts_print has no user now, so can re-write the function safely.

qemu_opts_print is used while using "qemu-img create", it
produces the same output as previous code.

The behavior of this function has changed:

1. Print every possible option, whether a value has been set or not.
2. Option descriptors may provide a default value.
3. Print to stdout instead of stderr.

Previously the behavior was to print every option that has been set.
Options that have not been set would be skipped.

v13->v14:
1) fix memory leak.
2) make opt_set do not accpet null value argument.

v12->v13
1) re-write commit message.

v11->v12
1) make def_value_str become the real default value string in opt_set
function.

v10->v11:
1) print all values that have actually been assigned while accept-any
cases.

v7->v8:
1) print "elements => accept any params" while opts_accepts_any() ==
true.
2) since def_print_str is the default value if an option isn't set,
so rename it to def_value_str.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
qemu-option: avoid duplication of default value in QemuOpts

This patch moves the default value entirely to QemuOptDesc.

When getting the value of an option that hasn't been set, and
QemuOptDesc has a default value, return that.  Else, behave as
before.

Example: qemu_opt_get_number(opts, "foo", 42)

   If "foo" has been set in opts, return its value.

   Else, if opt's QemuOptDesc has a default value for "foo", return
   that.

   Else, return 42.

   Note that the last argument is useless when QemuOptDesc has a
   default value.  Ugly.  If it bothers us, we could assert.

Example: qemu_opt_get(opts, "bar")

   If "bar" has been set in opts, return its value.

   Else, if opt's QemuOptDesc has a default value for "bar", return
   that.

   Else, return NULL.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>

v13->v14:
1) change code style.
2) assert errors.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>

Conflicts:
	util/qemu-option.c
qemu-option: create four QemuOptsList related functions

This patch creates 4 functions, count_opts_list, qemu_opts_append,
qemu_opts_free and qemu_opts_print_help, they are used in following
commits.

v16->v17:
1) fix indentation.
2) fix typo.

v15->v16:
1) discard double-initialization.
2) use pointer directly, not g_strdup.

v12->v13:
1) simply assert that neither argument has merge_lists set.
2) drop superfluous paranthesesis around p == first.

v11->v12:
1) renmae functions.
2) fix loop styles and code styles.
3) qemu_opts_apend will not return NULL now.
4) merge_lists value is from arguments in qemu_opts_append.

v6->v7:
1) Fix typo.

v5->v6:
1) allocate enough space in append_opts_list function.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
qemu-option: create some QemuOpts functons

These functions will be used in next commit.

qemu_opt_get_(*)_del functions are used to make sure we
have the same behaviors as before: in block layer, after
parsing a parameter value, parameter list will delete it
to avoid parsing it twice.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>

v16->v17:
1) return "char *" instead of "const char*"

v13->v14:
1) rewrite commit message.
2) use def_value_str in qemu_opt_get_FOO_del() and qemu_opt_get_del().
3) delete redundant qemu_opt_del(opt).
qemu-option: opt->str store digit, without suffixes

To produce same output while using "qemu-img create", opt->str
should store pure digit, without suffixes.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
add interface to block

To make patches easy for reviewing, each block format is
a single patch. Add a new interface to block layer to make
sure origin code can compile and do not change any code
logic.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
block: add QemuOpts support for cow.c
block: add QemuOpts support for gluster.c
block: add QemuOpts support for iscsi.c

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
block: add QemuOpts support for qcow.c

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
block: add QemuOpts support for qcow2.c

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
block: add QemuOpts support for qed.c

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
block: add QemuOpts support for raw-posix.c

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>