Upstream: integrate minor cleanups

Change-Id: I8de8e1044794f0ef8427717fc0b3b5e9e121247b
diff --git a/Changelog b/Changelog
index 2a3e37d..152feaa 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,73 @@
+version 0.12.0:
+
+  - Update to SeaBIOS 0.5.0
+  - e1000: fix device link status in Linux (Anthony Liguori)
+  - monitor: fix QMP for balloon command (Luiz Capitulino)
+  - QMP: Return an empty dict by default (Luiz Capitulino)
+  - QMP: Only handle converted commands (Luiz Capitulino)
+  - pci: support PCI based option rom loading (Gerd Hoffman/Anthony Liguori)
+  - Fix backcompat for hotplug of SCSI controllers (Daniel P. Berrange)
+  - fdc: fix migration from 0.11 (Juan Quintela)
+  - vmware-vga: fix segv on cursor resize. (Dave Airlie)
+  - vmware-vga: various fixes (Dave Airlie/Anthony Liguori)
+  - qdev: improve property error reporting. (Gerd Hoffmann)
+  - fix vga names in default_list (Gerd Hoffmann)
+  - usb-host: check mon before using it. (Gerd Hoffmann)
+  - usb-net: use qdev for -usbdevice (Gerd Hoffmann)
+  - monitor: Catch printing to non-existent monitor (Luiz Capitulino)
+  - Avoid permanently disabled QEMU monitor when UNIX migration fails (Daniel P. Berrange)
+  - Fix loading of ELF multiboot kernels (Kevin Wolf)
+  - qemu-io: Fix memory leak (Kevin Wolf)
+  - Fix thinko in linuxboot.S (Paolo Bonzini)
+  - target-i386: Fix evaluation of DR7 register (Jan Kiszka)
+  - vnc: hextile: do not generate ForegroundSpecified and SubrectsColoured tiles (Anthony Liguori)
+  - S390: Bail out without KVM (Alexander Graf)
+  - S390: Don't tell guest we're updating config space (Alexander Graf)
+  - target-s390: Fail on unknown instructions (Alexander Graf)
+  - osdep: Fix runtime failure on older Linux kernels (Andre Przywara)
+  - Fix a make -j race (Juergen Lock)
+  - target-alpha: Fix generic ctz64. (Richard Henderson)
+  - s390: Fix buggy assignment (Stefan Weil)
+  - target-mips: fix user-mode emulation startup (Nathan Froyd)
+  - target-i386: Update CPUID feature set for TCG (Andre Przywara)
+  - s390: fix build on 32 bit host (Michael S. Tsirkin)
+	
+version 0.12.0-rc2:
+
+  - v2: properly save kvm system time msr registers (Glauber Costa)
+  - convert more monitor commands to qmp (Luiz Capitulino)
+  - vnc: fix capslock tracking logic. (Gerd Hoffmann)
+  - QemuOpts: allow larger option values. (Gerd Hoffmann)
+  - scsi: fix drive hotplug. (Gerd Hoffmann)
+  - pci: don't hw_error() when no slot is available. (Gerd Hoffmann)
+  - pci: don't abort() when trying to hotplug with acpi off. (Gerd Hoffmann)
+  - allow default devices to be implemented in config file (Gerd Hoffman)
+  - vc: colorize chardev title line with blue background. (Gerd Hoffmann)
+  - chardev: make chardevs specified in config file work. (Gerd Hoffmann)
+  - qdev: also match bus name for global properties (Gerd Hoffmann)
+  - qdev: add command line option to set global defaults for properties. (Gerd Hoffmann)
+  - kvm: x86: Save/restore exception_index (Jan Kiszka)
+  - qdev: Replace device names containing whitespace (Markus Armbruster)
+  - fix rtc-td-hack on host without high-res timers (Gleb Natapov)
+  - virtio: verify features on load (Michael S. Tsirkin)
+  - vmware_vga: add rom file so that it boots. (Dave Airlie)
+  - Do not abort on qemu_malloc(0) in production builds (Anthony Liguori)
+  - Fix ARM userspace strex implementation. (Paul Brook)
+  - qemu: delete rule target on error (Michael S. Tsirkin)
+  - QMP: add human-readable description to error response (Markus Armbruster)
+  - convert more monitor commands to QError (Markus Armbruster)
+  - monitor: Fix double-prompt after "change vnc passwd BLA" (Markus Armbruster)
+  - monitor: do_cont(): Don't ask for passwords (Luiz Capitulino)
+  - monitor: Introduce 'block_passwd' command (Luiz Capitulino)
+  - pci: interrupt disable bit support (Michael S. Tsirkin)
+  - pci: interrupt status bit implementation (Michael S. Tsirkin)
+  - pci: prepare irq code for interrupt state (Michael S. Tsirkin)
+  - msix: function mask support (Michael S. Tsirkin)
+  - msix: macro rename for function mask support (Michael S. Tsirkin)
+  - cpuid: Fix multicore setup on Intel (Andre Przywara)
+  - kvm: x86: Fix initial kvm_has_msr_star (Jan Kiszka)
+  - Update OpenBIOS images to r640 (Aurelien Jarno)	
+
 version 0.10.2:
 
   - fix savevm/loadvm (Anthony Liguori)
diff --git a/arm-dis.c b/arm-dis.c
index cc42576..2c67d8f 100644
--- a/arm-dis.c
+++ b/arm-dis.c
@@ -17,15 +17,12 @@
    more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
 /* Start of qemu specific additions.  Mostly this is stub definitions
    for things we don't care about.  */
 
 #include "dis-asm.h"
-#define FALSE 0
-#define TRUE (!FALSE)
 #define ATTRIBUTE_UNUSED __attribute__((unused))
 #define ISSPACE(x) ((x) == ' ' || (x) == '\t' || (x) == '\n')
 
@@ -1532,7 +1529,7 @@
 #define NUM_ARM_REGNAMES  NUM_ELEM (regnames)
 #define arm_regnames      regnames[regname_selected].reg_names
 
-static bfd_boolean force_thumb = FALSE;
+static bfd_boolean force_thumb = false;
 
 /* Current IT instruction state.  This contains the same state as the IT
    bits in the CPSR.  */
@@ -1629,7 +1626,7 @@
 }
 
 /* Print one coprocessor instruction on INFO->STREAM.
-   Return TRUE if the instuction matched, FALSE if this is not a
+   Return true if the instuction matched, false if this is not a
    recognised coprocessor instruction.  */
 
 static bfd_boolean
@@ -2122,10 +2119,10 @@
 	      else
 		func (stream, "%c", *c);
 	    }
-	  return TRUE;
+	  return true;
 	}
     }
-  return FALSE;
+  return false;
 }
 
 static void
@@ -2219,7 +2216,7 @@
 }
 
 /* Print one neon instruction on INFO->STREAM.
-   Return TRUE if the instuction matched, FALSE if this is not a
+   Return true if the instuction matched, false if this is not a
    recognised neon instruction.  */
 
 static bfd_boolean
@@ -2245,7 +2242,7 @@
       else if ((given & 0xff000000) == 0xf9000000)
 	given ^= 0xf9000000 ^ 0xf4000000;
       else
-	return FALSE;
+	return false;
     }
 
   for (insn = neon_opcodes; insn->assembler; insn++)
@@ -2335,34 +2332,34 @@
                             {
                               int amask = (1 << size) - 1;
                               if ((idx_align & (1 << size)) != 0)
-                                return FALSE;
+                                return false;
                               if (size > 0)
                                 {
                                   if ((idx_align & amask) == amask)
                                     align = 8 << size;
                                   else if ((idx_align & amask) != 0)
-                                    return FALSE;
+                                    return false;
                                 }
                               }
                             break;
 
                           case 2:
                             if (size == 2 && (idx_align & 2) != 0)
-                              return FALSE;
+                              return false;
                             align = (idx_align & 1) ? 16 << size : 0;
                             break;
 
                           case 3:
                             if ((size == 2 && (idx_align & 3) != 0)
                                 || (idx_align & 1) != 0)
-                              return FALSE;
+                              return false;
                             break;
 
                           case 4:
                             if (size == 2)
                               {
                                 if ((idx_align & 3) == 3)
-                                  return FALSE;
+                                  return false;
                                 align = (idx_align & 3) * 64;
                               }
                             else
@@ -2671,10 +2668,10 @@
 	      else
 		func (stream, "%c", *c);
 	    }
-	  return TRUE;
+	  return true;
 	}
     }
-  return FALSE;
+  return false;
 }
 
 /* Print one ARM instruction from PC on INFO->STREAM.  */
@@ -2686,10 +2683,10 @@
   void *stream = info->stream;
   fprintf_ftype func = info->fprintf_func;
 
-  if (print_insn_coprocessor (pc, info, given, FALSE))
+  if (print_insn_coprocessor (pc, info, given, false))
     return;
 
-  if (print_insn_neon (info, given, FALSE))
+  if (print_insn_neon (info, given, false))
     return;
 
   for (insn = arm_opcodes; insn->assembler; insn++)
@@ -3322,10 +3319,10 @@
   void *stream = info->stream;
   fprintf_ftype func = info->fprintf_func;
 
-  if (print_insn_coprocessor (pc, info, given, TRUE))
+  if (print_insn_coprocessor (pc, info, given, true))
     return;
 
-  if (print_insn_neon (info, given, TRUE))
+  if (print_insn_neon (info, given, true))
     return;
 
   for (insn = thumb32_opcodes; insn->assembler; insn++)
@@ -3460,7 +3457,7 @@
 		  unsigned int op  = (given & 0x00000f00) >> 8;
 		  unsigned int i12 = (given & 0x00000fff);
 		  unsigned int i8  = (given & 0x000000ff);
-		  bfd_boolean writeback = FALSE, postind = FALSE;
+		  bfd_boolean writeback = false, postind = false;
 		  int offset = 0;
 
 		  func (stream, "[%s", arm_regnames[Rn]);
@@ -3490,22 +3487,22 @@
 
 		    case 0xF:  /* 8-bit + preindex with wb */
 		      offset = i8;
-		      writeback = TRUE;
+		      writeback = true;
 		      break;
 
 		    case 0xD:  /* 8-bit - preindex with wb */
 		      offset = -i8;
-		      writeback = TRUE;
+		      writeback = true;
 		      break;
 
 		    case 0xB:  /* 8-bit + postindex */
 		      offset = i8;
-		      postind = TRUE;
+		      postind = true;
 		      break;
 
 		    case 0x9:  /* 8-bit - postindex */
 		      offset = -i8;
-		      postind = TRUE;
+		      postind = true;
 		      break;
 
 		    default:
@@ -3878,12 +3875,12 @@
   unsigned char b[4];
   long		given;
   int           status;
-  int           is_thumb = FALSE;
-  int           is_data = FALSE;
+  int           is_thumb = false;
+  int           is_data = false;
   unsigned int	size = 4;
   void	 	(*printer) (bfd_vma, struct disassemble_info *, long);
 #if 0
-  bfd_boolean   found = FALSE;
+  bfd_boolean   found = false;
 
   if (info->disassembler_options)
     {
@@ -3906,7 +3903,7 @@
       if (pc <= last_mapping_addr)
 	last_mapping_sym = -1;
       is_thumb = (last_type == MAP_THUMB);
-      found = FALSE;
+      found = false;
       /* Start scanning at the start of the function, or wherever
 	 we finished last time.  */
       n = info->symtab_pos + 1;
@@ -3924,7 +3921,7 @@
 	      && get_sym_code_type (info, n, &type))
 	    {
 	      last_sym = n;
-	      found = TRUE;
+	      found = true;
 	    }
 	}
 
@@ -3941,7 +3938,7 @@
 	      if (get_sym_code_type (info, n, &type))
 		{
 		  last_sym = n;
-		  found = TRUE;
+		  found = true;
 		  break;
 		}
 	    }
@@ -4013,7 +4010,7 @@
 #endif
 
   if (force_thumb)
-    is_thumb = TRUE;
+    is_thumb = true;
 
   info->bytes_per_line = 4;
 
diff --git a/arm-semi.c b/arm-semi.c
index a33b8e5..5239ffc 100644
--- a/arm-semi.c
+++ b/arm-semi.c
@@ -15,9 +15,7 @@
  *  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, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
- *  MA 02110-1301, USA.
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <sys/types.h>
diff --git a/block_int.h b/block_int.h
index 830b7e9..32b66b5 100644
--- a/block_int.h
+++ b/block_int.h
@@ -37,6 +37,7 @@
 #define BLOCK_OPT_BACKING_FILE  "backing_file"
 #define BLOCK_OPT_BACKING_FMT   "backing_fmt"
 #define BLOCK_OPT_CLUSTER_SIZE  "cluster_size"
+#define BLOCK_OPT_PREALLOC      "preallocation"
 
 typedef struct AIOPool {
     void (*cancel)(BlockDriverAIOCB *acb);
diff --git a/bt-host.c b/bt-host.c
index 9a06578..964ac11 100644
--- a/bt-host.c
+++ b/bt-host.c
@@ -14,8 +14,7 @@
  * 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, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "qemu-common.h"
diff --git a/bt-vhci.c b/bt-vhci.c
index ee90f10..679c5e0 100644
--- a/bt-vhci.c
+++ b/bt-vhci.c
@@ -14,8 +14,7 @@
  * 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, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "qemu-common.h"
diff --git a/buffered_file.c b/buffered_file.c
index 364b912..641ce21 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -39,10 +39,10 @@
 } QEMUFileBuffered;
 
 #ifdef DEBUG_BUFFERED_FILE
-#define dprintf(fmt, ...) \
+#define DPRINTF(fmt, ...) \
     do { printf("buffered-file: " fmt, ## __VA_ARGS__); } while (0)
 #else
-#define dprintf(fmt, ...) \
+#define DPRINTF(fmt, ...) \
     do { } while (0)
 #endif
 
@@ -52,7 +52,7 @@
     if (size > (s->buffer_capacity - s->buffer_size)) {
         void *tmp;
 
-        dprintf("increasing buffer capacity from %ld by %ld\n",
+        DPRINTF("increasing buffer capacity from %zu by %zu\n",
                 s->buffer_capacity, size + 1024);
 
         s->buffer_capacity += size + 1024;
@@ -75,11 +75,11 @@
     size_t offset = 0;
 
     if (s->has_error) {
-        dprintf("flush when error, bailing\n");
+        DPRINTF("flush when error, bailing\n");
         return;
     }
 
-    dprintf("flushing %ld byte(s) of data\n", s->buffer_size);
+    DPRINTF("flushing %zu byte(s) of data\n", s->buffer_size);
 
     while (offset < s->buffer_size) {
         ssize_t ret;
@@ -87,22 +87,22 @@
         ret = s->put_buffer(s->opaque, s->buffer + offset,
                             s->buffer_size - offset);
         if (ret == -EAGAIN) {
-            dprintf("backend not ready, freezing\n");
+            DPRINTF("backend not ready, freezing\n");
             s->freeze_output = 1;
             break;
         }
 
         if (ret <= 0) {
-            dprintf("error flushing data, %ld\n", ret);
+            DPRINTF("error flushing data, %zd\n", ret);
             s->has_error = 1;
             break;
         } else {
-            dprintf("flushed %ld byte(s)\n", ret);
+            DPRINTF("flushed %zd byte(s)\n", ret);
             offset += ret;
         }
     }
 
-    dprintf("flushed %ld of %ld byte(s)\n", offset, s->buffer_size);
+    DPRINTF("flushed %zu of %zu byte(s)\n", offset, s->buffer_size);
     memmove(s->buffer, s->buffer + offset, s->buffer_size - offset);
     s->buffer_size -= offset;
 }
@@ -113,45 +113,45 @@
     int offset = 0;
     ssize_t ret;
 
-    dprintf("putting %ld bytes at %Ld\n", size, pos);
+    DPRINTF("putting %d bytes at %" PRId64 "\n", size, pos);
 
     if (s->has_error) {
-        dprintf("flush when error, bailing\n");
+        DPRINTF("flush when error, bailing\n");
         return -EINVAL;
     }
 
-    dprintf("unfreezing output\n");
+    DPRINTF("unfreezing output\n");
     s->freeze_output = 0;
 
     buffered_flush(s);
 
     while (!s->freeze_output && offset < size) {
         if (s->bytes_xfer > s->xfer_limit) {
-            dprintf("transfer limit exceeded when putting\n");
+            DPRINTF("transfer limit exceeded when putting\n");
             break;
         }
 
         ret = s->put_buffer(s->opaque, buf + offset, size - offset);
         if (ret == -EAGAIN) {
-            dprintf("backend not ready, freezing\n");
+            DPRINTF("backend not ready, freezing\n");
             s->freeze_output = 1;
             break;
         }
 
         if (ret <= 0) {
-            dprintf("error putting\n");
+            DPRINTF("error putting\n");
             s->has_error = 1;
             offset = -EINVAL;
             break;
         }
 
-        dprintf("put %ld byte(s)\n", ret);
+        DPRINTF("put %zd byte(s)\n", ret);
         offset += ret;
         s->bytes_xfer += ret;
     }
 
     if (offset >= 0) {
-        dprintf("buffering %ld bytes\n", size - offset);
+        DPRINTF("buffering %d bytes\n", size - offset);
         buffered_append(s, buf + offset, size - offset);
         offset = size;
     }
@@ -164,7 +164,7 @@
     QEMUFileBuffered *s = opaque;
     int ret;
 
-    dprintf("closing\n");
+    DPRINTF("closing\n");
 
     while (!s->has_error && s->buffer_size) {
         buffered_flush(s);
@@ -211,6 +211,13 @@
     return s->xfer_limit;
 }
 
+static size_t buffered_get_rate_limit(void *opaque)
+{
+    QEMUFileBuffered *s = opaque;
+  
+    return s->xfer_limit;
+}
+
 static void buffered_rate_tick(void *opaque)
 {
     QEMUFileBuffered *s = opaque;
diff --git a/console.h b/console.h
index 9222115..c4baf10 100644
--- a/console.h
+++ b/console.h
@@ -83,6 +83,7 @@
 
 #define QEMU_BIG_ENDIAN_FLAG    0x01
 #define QEMU_ALLOCATED_FLAG     0x02
+#define QEMU_REALPIXELS_FLAG    0x04
 
 struct PixelFormat {
     uint8_t bits_per_pixel;
diff --git a/qemu-thread.c b/qemu-thread.c
index 719cfcd..3923db7 100644
--- a/qemu-thread.c
+++ b/qemu-thread.c
@@ -158,6 +158,6 @@
 
 int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2)
 {
-   return (thread1->thread == thread2->thread);
+   return pthread_equal(thread1->thread, thread2->thread);
 }
 
diff --git a/sysemu.h b/sysemu.h
index fe24415..1d9e28c 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -3,6 +3,11 @@
 /* Misc. things related to the system emulator.  */
 
 #include "qemu-common.h"
+#include "qemu-option.h"
+#include "qemu-queue.h"
+#include "qemu-timer.h"
+#include "qdict.h"
+#include "qerror.h"
 
 #ifdef _WIN32
 #include <windows.h>
@@ -70,6 +75,17 @@
 int qemu_savevm_state(QEMUFile *f);
 int qemu_loadvm_state(QEMUFile *f);
 
+void qemu_errors_to_file(FILE *fp);
+void qemu_errors_to_mon(Monitor *mon);
+void qemu_errors_to_previous(void);
+void qemu_error(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
+void qemu_error_internal(const char *file, int linenr, const char *func,
+                         const char *fmt, ...)
+                         __attribute__ ((format(printf, 4, 5)));
+
+#define qemu_error_new(fmt, ...) \
+    qemu_error_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
+
 #ifdef _WIN32
 /* Polling handling */