[Spice-commits] 48 commits - MAINTAINERS block.c block/backup.c block/curl.c block/mirror.c block/rbd.c blockdev.c disas/mips.c hw/arm hw/block hw/s390x hw/watchdog include/block include/hw include/migration linux-user/main.c migration/migration.c migration/ram.c migration/savevm.c numa.c qmp-commands.hx target-arm/helper.c target-i386/cpu.c target-mips/mips-defs.h target-mips/mips-semi.c target-mips/msa_helper.c target-mips/op_helper.c target-mips/translate.c target-mips/translate_init.c ui/vnc.c vl.c

Gerd Hoffmann kraxel at kemper.freedesktop.org
Thu Jul 16 08:31:55 PDT 2015


 MAINTAINERS                   |    2 
 block.c                       |  144 +++++++++++++++++++++++++++++-------------
 block/backup.c                |    2 
 block/curl.c                  |   15 ++++
 block/mirror.c                |   24 ++++++-
 block/rbd.c                   |   64 ++++++++++--------
 blockdev.c                    |    7 --
 disas/mips.c                  |   12 +--
 hw/arm/boot.c                 |   28 ++++++--
 hw/block/nvme.c               |   38 ++++++++---
 hw/block/nvme.h               |    1 
 hw/s390x/s390-virtio-ccw.c    |    6 +
 hw/s390x/virtio-ccw.c         |    2 
 hw/watchdog/wdt_diag288.c     |    8 ++
 include/block/block.h         |    7 ++
 include/block/block_int.h     |    5 -
 include/hw/i386/pc.h          |   68 +++++++++++++++++++
 include/migration/migration.h |    1 
 linux-user/main.c             |    4 -
 migration/migration.c         |   52 ++++++++-------
 migration/ram.c               |   10 +-
 migration/savevm.c            |    6 +
 numa.c                        |    3 
 qmp-commands.hx               |    1 
 target-arm/helper.c           |    1 
 target-i386/cpu.c             |   39 +++++------
 target-mips/mips-defs.h       |    2 
 target-mips/mips-semi.c       |   23 +++++-
 target-mips/msa_helper.c      |    6 +
 target-mips/op_helper.c       |    5 -
 target-mips/translate.c       |   15 ++++
 target-mips/translate_init.c  |   18 ++---
 ui/vnc.c                      |    2 
 vl.c                          |    2 
 34 files changed, 445 insertions(+), 178 deletions(-)

New commits:
commit 2d5ee9e7a7dd495d233cf9613a865f63f88e3375
Merge: 3749c11 908680c
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Thu Jul 16 10:40:22 2015 +0100

    Merge remote-tracking branch 'remotes/lalrae/tags/mips-20150716' into staging
    
    MIPS patches 2015-07-16
    
    Changes:
    * bug fixes
    
    # gpg: Signature made Thu Jul 16 09:04:56 2015 BST using RSA key ID 0B29DA6B
    # gpg: Good signature from "Leon Alrae <leon.alrae at imgtec.com>"
    # gpg: WARNING: This key is not certified with a trusted signature!
    # gpg:          There is no indication that the signature belongs to the owner.
    # Primary key fingerprint: 8DD3 2F98 5495 9D66 35D4  4FC0 5211 8E3C 0B29 DA6B
    
    * remotes/lalrae/tags/mips-20150716:
      target-mips: fix page fault address for LWL/LWR/LDL/LDR
      linux-user: Fix MIPS N64 trap and break instruction bug
      target-mips: fix resource leak reported by Coverity
      target-mips: fix logically dead code reported by Coverity
      target-mips: correct DERET instruction
      target-mips: fix ASID synchronisation for MIPS MT
      disas/mips: fix disassembling R6 instructions
      target-mips: fix to clear MSACSR.Cause
      target-mips: fix MIPS64R6-generic configuration
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit 3749c11a720689694101dcf2ebc43217a02f960f
Merge: be0df8c 3046bb5
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Wed Jul 15 22:05:13 2015 +0100

    Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging
    
    X86 queue, 2015-07-15
    
    Two bug fixes:
    * Memory leak due to extra g_strdup() when registering X86CPU alias properties
    * Fix CPUID levels so that W10 insider can run as guest OS
    
    # gpg: Signature made Wed Jul 15 21:26:59 2015 BST using RSA key ID 984DC5A6
    # gpg: Good signature from "Eduardo Habkost <ehabkost at redhat.com>"
    # gpg: WARNING: This key is not certified with sufficiently trusted signatures!
    # gpg:          It is not certain that the signature belongs to the owner.
    # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6
    
    * remotes/ehabkost/tags/x86-pull-request:
      target-i386: emulate CPUID level of real hardware
      target-i386: Don't strdup() alias property name
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit be0df8cd1eb8e182a9b61a2b4d1c57824cffadc4
Merge: 7692401 672558d
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Wed Jul 15 21:06:54 2015 +0100

    Merge remote-tracking branch 'remotes/ehabkost/tags/numa-pull-request' into staging
    
    NUMA queue, 2015-07-15
    
    # gpg: Signature made Wed Jul 15 21:01:37 2015 BST using RSA key ID 984DC5A6
    # gpg: Good signature from "Eduardo Habkost <ehabkost at redhat.com>"
    # gpg: WARNING: This key is not certified with sufficiently trusted signatures!
    # gpg:          It is not certain that the signature belongs to the owner.
    # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6
    
    * remotes/ehabkost/tags/numa-pull-request:
      numa: Fix memory leak in numa_set_mem_node_id()
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit 3046bb5debc8153a542acb1df93b2a1a85527a15
Author: Radim Krčmář <rkrcmar at redhat.com>
Date:   Thu Jul 9 21:07:39 2015 +0200

    target-i386: emulate CPUID level of real hardware
    
    W10 insider has a bug where it ignores CPUID level and interprets
    CPUID.(EAX=07H, ECX=0H) incorrectly, because CPUID in fact returned
    CPUID.(EAX=04H, ECX=0H);  this resulted in execution of unsupported
    instructions.
    
    While it's a Windows bug, there is no reason to emulate incorrect level.
    
    I used http://instlatx64.atw.hu/ as a source of CPUID and checked that
    it matches Penryn Xeon X5472, Westmere Xeon W3520, SandyBridge i5-2540M,
    and Haswell i5-4670T.
    
    kvm64 and qemu64 were bumped to 0xD to allow all available features for
    them (and to avoid the same Windows bug).
    
    Signed-off-by: Radim Krčmář <rkrcmar at redhat.com>
    Reviewed-by: Eduardo Habkost <ehabkost at redhat.com>
    Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 15e3352..c416574 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -298,6 +298,74 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
             .driver   = TYPE_X86_CPU,\
             .property = "arat",\
             .value    = "off",\
+        },{\
+            .driver   = "qemu64" "-" TYPE_X86_CPU,\
+            .property = "level",\
+            .value    = stringify(4),\
+        },{\
+            .driver   = "kvm64" "-" TYPE_X86_CPU,\
+            .property = "level",\
+            .value    = stringify(5),\
+        },{\
+            .driver   = "pentium3" "-" TYPE_X86_CPU,\
+            .property = "level",\
+            .value    = stringify(2),\
+        },{\
+            .driver   = "n270" "-" TYPE_X86_CPU,\
+            .property = "level",\
+            .value    = stringify(5),\
+        },{\
+            .driver   = "Conroe" "-" TYPE_X86_CPU,\
+            .property = "level",\
+            .value    = stringify(4),\
+        },{\
+            .driver   = "Penryn" "-" TYPE_X86_CPU,\
+            .property = "level",\
+            .value    = stringify(4),\
+        },{\
+            .driver   = "Nehalem" "-" TYPE_X86_CPU,\
+            .property = "level",\
+            .value    = stringify(4),\
+        },{\
+            .driver   = "n270" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "Penryn" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "Conroe" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "Nehalem" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "Westmere" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "SandyBridge" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "Haswell" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "Haswell-noTSX" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "Broadwell" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
+        },{\
+            .driver   = "Broadwell-noTSX" "-" TYPE_X86_CPU,\
+            .property = "xlevel",\
+            .value    = stringify(0x8000000a),\
         },
 
 #define PC_COMPAT_2_2 \
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 1e49a14..7a779b1 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -695,7 +695,7 @@ struct X86CPUDefinition {
 static X86CPUDefinition builtin_x86_defs[] = {
     {
         .name = "qemu64",
-        .level = 4,
+        .level = 0xd,
         .vendor = CPUID_VENDOR_AMD,
         .family = 6,
         .model = 6,
@@ -771,7 +771,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
     },
     {
         .name = "kvm64",
-        .level = 5,
+        .level = 0xd,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 15,
         .model = 6,
@@ -882,7 +882,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
     },
     {
         .name = "pentium3",
-        .level = 2,
+        .level = 3,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
         .model = 7,
@@ -907,8 +907,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
     },
     {
         .name = "n270",
-        /* original is on level 10 */
-        .level = 5,
+        .level = 10,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
         .model = 28,
@@ -928,12 +927,12 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_NX,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel(R) Atom(TM) CPU N270   @ 1.60GHz",
     },
     {
         .name = "Conroe",
-        .level = 4,
+        .level = 10,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
         .model = 15,
@@ -950,12 +949,12 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Celeron_4x0 (Conroe/Merom Class Core 2)",
     },
     {
         .name = "Penryn",
-        .level = 4,
+        .level = 10,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
         .model = 23,
@@ -973,12 +972,12 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Core 2 Duo P9xxx (Penryn Class Core 2)",
     },
     {
         .name = "Nehalem",
-        .level = 4,
+        .level = 11,
         .vendor = CPUID_VENDOR_INTEL,
         .family = 6,
         .model = 26,
@@ -996,7 +995,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Core i7 9xx (Nehalem Class Core i7)",
     },
     {
@@ -1022,7 +1021,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT3_LAHF_LM,
         .features[FEAT_6_EAX] =
             CPUID_6_EAX_ARAT,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Westmere E56xx/L56xx/X56xx (Nehalem-C)",
     },
     {
@@ -1053,7 +1052,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_XSAVE_XSAVEOPT,
         .features[FEAT_6_EAX] =
             CPUID_6_EAX_ARAT,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Xeon E312xx (Sandy Bridge)",
     },
     {
@@ -1087,7 +1086,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_XSAVE_XSAVEOPT,
         .features[FEAT_6_EAX] =
             CPUID_6_EAX_ARAT,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge)",
     },
     {
@@ -1123,7 +1122,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_XSAVE_XSAVEOPT,
         .features[FEAT_6_EAX] =
             CPUID_6_EAX_ARAT,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Core Processor (Haswell, no TSX)",
     },    {
         .name = "Haswell",
@@ -1159,7 +1158,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_XSAVE_XSAVEOPT,
         .features[FEAT_6_EAX] =
             CPUID_6_EAX_ARAT,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Core Processor (Haswell)",
     },
     {
@@ -1197,7 +1196,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_XSAVE_XSAVEOPT,
         .features[FEAT_6_EAX] =
             CPUID_6_EAX_ARAT,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Core Processor (Broadwell, no TSX)",
     },
     {
@@ -1235,7 +1234,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_XSAVE_XSAVEOPT,
         .features[FEAT_6_EAX] =
             CPUID_6_EAX_ARAT,
-        .xlevel = 0x8000000A,
+        .xlevel = 0x80000008,
         .model_id = "Intel Core Processor (Broadwell)",
     },
     {
commit d461a44ca4b164549fe19b14d2cdf0524f778ce1
Author: Eduardo Habkost <ehabkost at redhat.com>
Date:   Thu Jul 9 12:24:43 2015 -0300

    target-i386: Don't strdup() alias property name
    
    Now object_property_add_alias() calls g_strdup() on the target property
    name, so we don't need to call g_strdup() ourselves.
    
    Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f9b1788..1e49a14 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -3021,7 +3021,7 @@ static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
 
     for (i = 1; names[i]; i++) {
         feat2prop(names[i]);
-        object_property_add_alias(obj, names[i], obj, g_strdup(names[0]),
+        object_property_add_alias(obj, names[i], obj, names[0],
                                   &error_abort);
     }
 
commit 672558d2ea8dd782d1d2adc6e16af3bc34029a36
Author: Bharata B Rao <bharata at linux.vnet.ibm.com>
Date:   Thu Jul 9 20:57:36 2015 +0530

    numa: Fix memory leak in numa_set_mem_node_id()
    
    Fix a memory leak in numa_set_mem_node_id().
    
    Signed-off-by: Bharata B Rao <bharata at linux.vnet.com>
    Reported-by: Paolo Bonzini <pbonzini at redhat.com>
    Reviewed-by: Eduardo Habkost <ehabkost at redhat.com>
    Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>

diff --git a/numa.c b/numa.c
index 3c80059..402804b 100644
--- a/numa.c
+++ b/numa.c
@@ -54,7 +54,7 @@ NodeInfo numa_info[MAX_NODES];
 
 void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node)
 {
-    struct numa_addr_range *range = g_malloc0(sizeof(*range));
+    struct numa_addr_range *range;
 
     /*
      * Memory-less nodes can come here with 0 size in which case,
@@ -64,6 +64,7 @@ void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node)
         return;
     }
 
+    range = g_malloc0(sizeof(*range));
     range->mem_start = addr;
     range->mem_end = addr + size - 1;
     QLIST_INSERT_HEAD(&numa_info[node].addr, range, entry);
commit 7692401a0826803522cfde533bdcc149932ddc6a
Merge: 711dc6f 76e2aef
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Wed Jul 15 17:28:59 2015 +0100

    Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20150715' into staging
    
    target arm queue:
     * handle broken AArch64 kernels which assume DTB won't cross a 2MB boundary
     * correct broken SCTLR_EL3 reset value
    
    # gpg: Signature made Wed Jul 15 17:24:24 2015 BST using RSA key ID 14360CDE
    # gpg: Good signature from "Peter Maydell <peter.maydell at linaro.org>"
    
    * remotes/pmaydell/tags/pull-target-arm-20150715:
      hw/arm/boot: Increase fdt alignment
      target-arm: Fix broken SCTLR_EL3 reset
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit 76e2aef392629f2b2a468f5158d5c397cc5beed2
Author: Alexander Graf <agraf at suse.de>
Date:   Wed Jul 15 17:16:26 2015 +0100

    hw/arm/boot: Increase fdt alignment
    
    The Linux kernel on aarch64 creates a page table entry at early bootup
    that spans the 2MB range on memory spanning the fdt start address:
    
      [ ALIGN_DOWN(fdt, 2MB) ... ALIGN_DOWN(fdt, 2MB) + 2MB ]
    
    This means that when our current 4k alignment happens to fall at the end
    of the aligned region, Linux tries to access memory that is not mapped.
    
    The easy fix is to instead increase the alignment to 2MB, making Linux's
    logic always succeed.
    
    We leave the existing 4k alignment for 32bit kernels to not cause any
    regressions due to space constraints.
    
    Reported-by: Andreas Schwab <schwab at suse.de>
    Signed-off-by: Alexander Graf <agraf at suse.de>
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index f48ed2d..5b969cd 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -735,12 +735,28 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
          * we point to the kernel args.
          */
         if (have_dtb(info)) {
-            /* Place the DTB after the initrd in memory. Note that some
-             * kernels will trash anything in the 4K page the initrd
-             * ends in, so make sure the DTB isn't caught up in that.
-             */
-            hwaddr dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size,
-                                             4096);
+            hwaddr align;
+            hwaddr dtb_start;
+
+            if (elf_machine == EM_AARCH64) {
+                /*
+                 * Some AArch64 kernels on early bootup map the fdt region as
+                 *
+                 *   [ ALIGN_DOWN(fdt, 2MB) ... ALIGN_DOWN(fdt, 2MB) + 2MB ]
+                 *
+                 * Let's play safe and prealign it to 2MB to give us some space.
+                 */
+                align = 2 * 1024 * 1024;
+            } else {
+                /*
+                 * Some 32bit kernels will trash anything in the 4K page the
+                 * initrd ends in, so make sure the DTB isn't caught up in that.
+                 */
+                align = 4096;
+            }
+
+            /* Place the DTB after the initrd in memory with alignment. */
+            dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, align);
             if (load_dtb(dtb_start, info, 0) < 0) {
                 exit(1);
             }
commit e46e1a74ef482f1ef773e750df9654ef4442ca29
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Wed Jul 15 17:16:26 2015 +0100

    target-arm: Fix broken SCTLR_EL3 reset
    
    The SCTLR_EL3 cpreg definition was implicitly resetting the
    register state to 0, which is both wrong and clashes with
    the reset done via the SCTLR definition (since sctlr[3]
    is unioned with sctlr_s). This went unnoticed until recently,
    when an unrelated change (commit a903c449b41f105aa) happened to
    perturb the order of enumeration through the cpregs hashtable for
    reset such that the erroneous reset happened after the correct one
    rather than before it. Fix this by marking SCTLR_EL3 as an alias,
    so its reset is left up to the AArch32 view.
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>
    Reviewed-by: Edgar E. Iglesias <edgar.iglesias at xilinx.com>

diff --git a/target-arm/helper.c b/target-arm/helper.c
index b87afe7..01f0d0d 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -2752,6 +2752,7 @@ static const ARMCPRegInfo el3_cp_reginfo[] = {
       .access = PL3_RW, .writefn = vbar_write, .resetvalue = 0,
       .fieldoffset = offsetof(CPUARMState, cp15.mvbar) },
     { .name = "SCTLR_EL3", .state = ARM_CP_STATE_AA64,
+      .type = ARM_CP_ALIAS, /* reset handled by AArch32 view */
       .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 0, .opc2 = 0,
       .access = PL3_RW, .raw_writefn = raw_write, .writefn = sctlr_write,
       .fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]) },
commit 711dc6f36b74fe65a6e5a1847f1152717d887f8a
Merge: f5dec79 796a060
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Wed Jul 15 14:23:58 2015 +0100

    Merge remote-tracking branch 'remotes/cody/tags/jtc-for-upstream-pull-request' into staging
    
    # gpg: Signature made Wed Jul 15 03:25:16 2015 BST using RSA key ID C0DE3057
    # gpg: Good signature from "Jeffrey Cody <jcody at redhat.com>"
    # gpg:                 aka "Jeffrey Cody <jeff at codyprime.org>"
    # gpg:                 aka "Jeffrey Cody <codyprime at gmail.com>"
    # gpg: WARNING: This key is not certified with sufficiently trusted signatures!
    # gpg:          It is not certain that the signature belongs to the owner.
    # Primary key fingerprint: 9957 4B4D 3474 90E7 9D98  D624 BDBE 7B27 C0DE 3057
    
    * remotes/cody/tags/jtc-for-upstream-pull-request:
      block/curl: Don't lose original error when a connection fails.
      mirror: correct buf_size
      block: keep bitmap if incremental backup job is cancelled
      blockdev: no need to drain in qmp_block_commit
      block/mirror: Sleep periodically during bitmap scanning
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit 908680c6441ac468f4871d513f42be396ea0d264
Author: Aurelien Jarno <aurelien at aurel32.net>
Date:   Tue Jul 14 17:45:16 2015 +0200

    target-mips: fix page fault address for LWL/LWR/LDL/LDR
    
    When a LWL, LWR, LDL or LDR instruction triggers a page fault, QEMU
    currently reports the aligned address in CP0 BadVAddr, while the Windows
    NT kernel expects the unaligned address.
    
    This patch adds a byte access with the unaligned address at the
    beginning of the LWL/LWR/LDL/LDR instructions to possibly trigger a page
    fault and fill the QEMU TLB.
    
    Cc: Leon Alrae <leon.alrae at imgtec.com>
    Reported-by: Hervé Poussineau <hpoussin at reactos.org>
    Tested-by: Hervé Poussineau <hpoussin at reactos.org>
    Signed-off-by: Aurelien Jarno <aurelien at aurel32.net>
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>

diff --git a/target-mips/translate.c b/target-mips/translate.c
index 4a1ffdb..d1de35a 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -2142,6 +2142,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
         break;
     case OPC_LDL:
         t1 = tcg_temp_new();
+        /* Do a byte access to possibly trigger a page
+           fault with the unaligned address.  */
+        tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UB);
         tcg_gen_andi_tl(t1, t0, 7);
 #ifndef TARGET_WORDS_BIGENDIAN
         tcg_gen_xori_tl(t1, t1, 7);
@@ -2163,6 +2166,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
         break;
     case OPC_LDR:
         t1 = tcg_temp_new();
+        /* Do a byte access to possibly trigger a page
+           fault with the unaligned address.  */
+        tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UB);
         tcg_gen_andi_tl(t1, t0, 7);
 #ifdef TARGET_WORDS_BIGENDIAN
         tcg_gen_xori_tl(t1, t1, 7);
@@ -2229,6 +2235,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
         break;
     case OPC_LWL:
         t1 = tcg_temp_new();
+        /* Do a byte access to possibly trigger a page
+           fault with the unaligned address.  */
+        tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UB);
         tcg_gen_andi_tl(t1, t0, 3);
 #ifndef TARGET_WORDS_BIGENDIAN
         tcg_gen_xori_tl(t1, t1, 3);
@@ -2251,6 +2260,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
         break;
     case OPC_LWR:
         t1 = tcg_temp_new();
+        /* Do a byte access to possibly trigger a page
+           fault with the unaligned address.  */
+        tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UB);
         tcg_gen_andi_tl(t1, t0, 3);
 #ifdef TARGET_WORDS_BIGENDIAN
         tcg_gen_xori_tl(t1, t1, 3);
commit f01a361bfcce4bd0c439b0e051ef2a1e56727a44
Author: Andrew Bennett <andrew.bennett at imgtec.com>
Date:   Mon Jun 29 10:20:07 2015 +0000

    linux-user: Fix MIPS N64 trap and break instruction bug
    
    For the MIPS N64 ABI when QEMU reads the break/trap instruction so that
    it can inspect the break/trap code it reads 8 rather than 4 bytes
    which means it finds the code field from the instruction after the
    break/trap instruction.  This then causes the break/trap handling
    code to fail because it does not understand the code number.
    
    The fix forces QEMU to always read 4 bytes of instruction data rather
    than deciding how much to read based on the ABI.
    
    Signed-off-by: Andrew Bennett <andrew.bennett at imgtec.com>
    Reviewed-by: Leon Alrae <leon.alrae at imgtec.com>
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>

diff --git a/linux-user/main.c b/linux-user/main.c
index 05914b1..fdee981 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2577,7 +2577,7 @@ done_syscall:
                         code = (trap_instr >> 6) & 0x3f;
                     }
                 } else {
-                    ret = get_user_ual(trap_instr, env->active_tc.PC);
+                    ret = get_user_u32(trap_instr, env->active_tc.PC);
                     if (ret != 0) {
                         goto error;
                     }
@@ -2611,7 +2611,7 @@ done_syscall:
 
                     trap_instr = (instr[0] << 16) | instr[1];
                 } else {
-                    ret = get_user_ual(trap_instr, env->active_tc.PC);
+                    ret = get_user_u32(trap_instr, env->active_tc.PC);
                 }
 
                 if (ret != 0) {
commit 26e7e982b267e71d40cd20e9e234fedef6770a90
Author: Leon Alrae <leon.alrae at imgtec.com>
Date:   Tue Jul 14 11:08:15 2015 +0100

    target-mips: fix resource leak reported by Coverity
    
    UHI assert and link operations call lock_user_string() twice to obtain two
    strings pointed by gpr[4] and gpr[5]. If the second lock_user_string()
    fails, then the first one won't get freed. Fix this by introducing another
    macro responsible for obtaining two strings and handling allocation
    failure.
    
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>
    Reviewed-by: Aurelien Jarno <aurelien at aurel32.net>

diff --git a/target-mips/mips-semi.c b/target-mips/mips-semi.c
index 1162c76..5050940 100644
--- a/target-mips/mips-semi.c
+++ b/target-mips/mips-semi.c
@@ -220,6 +220,23 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num,
         }                                       \
     } while (0)
 
+#define GET_TARGET_STRINGS_2(p, addr, p2, addr2)        \
+    do {                                                \
+        p = lock_user_string(addr);                     \
+        if (!p) {                                       \
+            gpr[2] = -1;                                \
+            gpr[3] = EFAULT;                            \
+            goto uhi_done;                              \
+        }                                               \
+        p2 = lock_user_string(addr2);                   \
+        if (!p2) {                                      \
+            unlock_user(p, addr, 0);                    \
+            gpr[2] = -1;                                \
+            gpr[3] = EFAULT;                            \
+            goto uhi_done;                              \
+        }                                               \
+    } while (0)
+
 #define FREE_TARGET_STRING(p, gpr)              \
     do {                                        \
         unlock_user(p, gpr, 0);                 \
@@ -322,8 +339,7 @@ void helper_do_semihosting(CPUMIPSState *env)
         FREE_TARGET_STRING(p, gpr[4]);
         break;
     case UHI_assert:
-        GET_TARGET_STRING(p, gpr[4]);
-        GET_TARGET_STRING(p2, gpr[5]);
+        GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]);
         printf("assertion '");
         printf("\"%s\"", p);
         printf("': file \"%s\", line %d\n", p2, (int)gpr[6]);
@@ -341,8 +357,7 @@ void helper_do_semihosting(CPUMIPSState *env)
         break;
 #ifndef _WIN32
     case UHI_link:
-        GET_TARGET_STRING(p, gpr[4]);
-        GET_TARGET_STRING(p2, gpr[5]);
+        GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]);
         gpr[2] = link(p, p2);
         gpr[3] = errno_mips(errno);
         FREE_TARGET_STRING(p2, gpr[5]);
commit 47ada0ad3431b39863918dc80386634693d317b5
Author: Leon Alrae <leon.alrae at imgtec.com>
Date:   Tue Jul 14 11:08:14 2015 +0100

    target-mips: fix logically dead code reported by Coverity
    
    Make use of CMPOP in floating-point compare instructions.
    
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>
    Reviewed-by: Aurelien Jarno <aurelien at aurel32.net>

diff --git a/target-mips/translate.c b/target-mips/translate.c
index 7302857..4a1ffdb 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -9552,6 +9552,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
             gen_cmp_s(ctx, func-48, ft, fs, cc);
             opn = condnames[func-48];
         }
+        optype = CMPOP;
         break;
     case OPC_ADD_D:
         check_cp1_registers(ctx, fs | ft | fd);
@@ -10036,6 +10037,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
             gen_cmp_d(ctx, func-48, ft, fs, cc);
             opn = condnames[func-48];
         }
+        optype = CMPOP;
         break;
     case OPC_CVT_S_D:
         check_cp1_registers(ctx, fs);
@@ -10461,6 +10463,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
             gen_cmp_ps(ctx, func-48, ft, fs, cc);
             opn = condnames[func-48];
         }
+        optype = CMPOP;
         break;
     default:
         MIPS_INVAL(opn);
commit fe87c2b36ae9c1c9a5279f3891f3bce1b573baa0
Author: Leon Alrae <leon.alrae at imgtec.com>
Date:   Tue Jul 14 11:08:13 2015 +0100

    target-mips: correct DERET instruction
    
    Fix Debug Mode flag clearing, and when DERET is placed between LL and SC
    do not make SC fail.
    
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>
    Reviewed-by: Aurelien Jarno <aurelien at aurel32.net>

diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index d457a29..9c28631 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -2154,10 +2154,9 @@ void helper_deret(CPUMIPSState *env)
     debug_pre_eret(env);
     set_pc(env, env->CP0_DEPC);
 
-    env->hflags &= MIPS_HFLAG_DM;
+    env->hflags &= ~MIPS_HFLAG_DM;
     compute_hflags(env);
     debug_post_eret(env);
-    env->lladdr = 1;
 }
 #endif /* !CONFIG_USER_ONLY */
 
commit 6a973e6b6584221bed89a01e755b88e58b496652
Author: Aurelien Jarno <aurelien at aurel32.net>
Date:   Wed Jul 1 15:59:13 2015 +0200

    target-mips: fix ASID synchronisation for MIPS MT
    
    When syncing the task ASID with EntryHi, correctly or the value instead
    of assigning it.
    
    Reported-by: "Dr. David Alan Gilbert" <dgilbert at redhat.com>
    Signed-off-by: Aurelien Jarno <aurelien at aurel32.net>
    Cc: Leon Alrae <leon.alrae at imgtec.com>
    Reviewed-by: Leon Alrae <leon.alrae at imgtec.com>
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>

diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 2a9ddff..d457a29 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -661,7 +661,7 @@ static void sync_c0_tcstatus(CPUMIPSState *cpu, int tc,
 
     /* Sync the TASID with EntryHi.  */
     cpu->CP0_EntryHi &= ~0xff;
-    cpu->CP0_EntryHi = tasid;
+    cpu->CP0_EntryHi |= tasid;
 
     compute_hflags(cpu);
 }
commit 6b9c26fb5eed2345398daca4eef601da2f3d7867
Author: Yongbok Kim <yongbok.kim at imgtec.com>
Date:   Tue Jun 30 16:33:15 2015 +0100

    disas/mips: fix disassembling R6 instructions
    
    In the Release 6 of the MIPS Architecture, LL, SC, LLD, SCD, PREF
    and CACHE instructions have 9 bits offsets.
    
    Signed-off-by: Yongbok Kim <yongbok.kim at imgtec.com>
    Reviewed-by: Aurelien Jarno <aurelien at aurel32.net>
    Reviewed-by: Leon Alrae <leon.alrae at imgtec.com>
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>

diff --git a/disas/mips.c b/disas/mips.c
index 32940fe..01336a8 100644
--- a/disas/mips.c
+++ b/disas/mips.c
@@ -1296,12 +1296,12 @@ const struct mips_opcode mips_builtin_opcodes[] =
 {"dmod",    "d,s,t",    0x000000de, 0xfc0007ff, WR_d|RD_s|RD_t,       0, I64R6},
 {"ddivu",   "d,s,t",    0x0000009f, 0xfc0007ff, WR_d|RD_s|RD_t,       0, I64R6},
 {"dmodu",   "d,s,t",    0x000000df, 0xfc0007ff, WR_d|RD_s|RD_t,       0, I64R6},
-{"ll",      "t,o(b)",   0x7c000036, 0xfc00007f, LDD|RD_b|WR_t,        0, I32R6},
-{"sc",      "t,o(b)",   0x7c000026, 0xfc00007f, LDD|RD_b|WR_t,        0, I32R6},
-{"lld",     "t,o(b)",   0x7c000037, 0xfc00007f, LDD|RD_b|WR_t,        0, I64R6},
-{"scd",     "t,o(b)",   0x7c000027, 0xfc00007f, LDD|RD_b|WR_t,        0, I64R6},
-{"pref",    "h,o(b)",   0x7c000035, 0xfc00007f, RD_b,                 0, I32R6},
-{"cache",   "k,o(b)",   0x7c000025, 0xfc00007f, RD_b,                 0, I32R6},
+{"ll",      "t,+o(b)",  0x7c000036, 0xfc00007f, LDD|RD_b|WR_t,        0, I32R6},
+{"sc",      "t,+o(b)",  0x7c000026, 0xfc00007f, LDD|RD_b|WR_t,        0, I32R6},
+{"lld",     "t,+o(b)",  0x7c000037, 0xfc00007f, LDD|RD_b|WR_t,        0, I64R6},
+{"scd",     "t,+o(b)",  0x7c000027, 0xfc00007f, LDD|RD_b|WR_t,        0, I64R6},
+{"pref",    "h,+o(b)",  0x7c000035, 0xfc00007f, RD_b,                 0, I32R6},
+{"cache",   "k,+o(b)",  0x7c000025, 0xfc00007f, RD_b,                 0, I32R6},
 {"seleqz",  "d,v,t",    0x00000035, 0xfc0007ff, WR_d|RD_s|RD_t,       0, I32R6},
 {"selnez",  "d,v,t",    0x00000037, 0xfc0007ff, WR_d|RD_s|RD_t,       0, I32R6},
 {"maddf.s", "D,S,T",    0x46000018, 0xffe0003f, WR_D|RD_S|RD_T|FP_S,  0, I32R6},
commit d4f4f0d5d9e74c19614479592c8bc865d92773d0
Author: Yongbok Kim <yongbok.kim at imgtec.com>
Date:   Tue Jun 30 15:44:28 2015 +0100

    target-mips: fix to clear MSACSR.Cause
    
    MSACSR.Cause bits are needed to be cleared before a vector floating-point
    instructions.
    FEXDO.df, FEXUPL.df and FEXUPR.df were missed out.
    
    Signed-off-by: Yongbok Kim <yongbok.kim at imgtec.com>
    Reviewed-by: Aurelien Jarno <aurelien at aurel32.net>
    Reviewed-by: Leon Alrae <leon.alrae at imgtec.com>
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>

diff --git a/target-mips/msa_helper.c b/target-mips/msa_helper.c
index 26ffdc7..a1cb48f 100644
--- a/target-mips/msa_helper.c
+++ b/target-mips/msa_helper.c
@@ -2642,6 +2642,8 @@ void helper_msa_fexdo_df(CPUMIPSState *env, uint32_t df, uint32_t wd,
     wr_t *pwt = &(env->active_fpu.fpr[wt].wr);
     uint32_t i;
 
+    clear_msacsr_cause(env);
+
     switch (df) {
     case DF_WORD:
         for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) {
@@ -3192,6 +3194,8 @@ void helper_msa_fexupl_df(CPUMIPSState *env, uint32_t df, uint32_t wd,
     wr_t *pws = &(env->active_fpu.fpr[ws].wr);
     uint32_t i;
 
+    clear_msacsr_cause(env);
+
     switch (df) {
     case DF_WORD:
         for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) {
@@ -3224,6 +3228,8 @@ void helper_msa_fexupr_df(CPUMIPSState *env, uint32_t df, uint32_t wd,
     wr_t *pws = &(env->active_fpu.fpr[ws].wr);
     uint32_t i;
 
+    clear_msacsr_cause(env);
+
     switch (df) {
     case DF_WORD:
         for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) {
commit 4dc89b782095d7a0b919fafd7b1322b3cb1279f1
Author: Yongbok Kim <yongbok.kim at imgtec.com>
Date:   Mon Jun 29 10:11:23 2015 +0100

    target-mips: fix MIPS64R6-generic configuration
    
    Fix core configuration for MIPS64R6-generic to make it as close as
    I6400.
    I6400 core has 48-bit of Virtual Address available (SEGBITS).
    MIPS SIMD Architecture is available.
    Rearrange order of bits to match the specification.
    
    Signed-off-by: Yongbok Kim <yongbok.kim at imgtec.com>
    Reviewed-by: Aurelien Jarno <aurelien at aurel32.net>
    Reviewed-by: Leon Alrae <leon.alrae at imgtec.com>
    Signed-off-by: Leon Alrae <leon.alrae at imgtec.com>

diff --git a/target-mips/mips-defs.h b/target-mips/mips-defs.h
index 20aa87c..53b185e 100644
--- a/target-mips/mips-defs.h
+++ b/target-mips/mips-defs.h
@@ -11,7 +11,7 @@
 #if defined(TARGET_MIPS64)
 #define TARGET_LONG_BITS 64
 #define TARGET_PHYS_ADDR_SPACE_BITS 48
-#define TARGET_VIRT_ADDR_SPACE_BITS 42
+#define TARGET_VIRT_ADDR_SPACE_BITS 48
 #else
 #define TARGET_LONG_BITS 32
 #define TARGET_PHYS_ADDR_SPACE_BITS 40
diff --git a/target-mips/translate_init.c b/target-mips/translate_init.c
index ddfaff8..9304e74 100644
--- a/target-mips/translate_init.c
+++ b/target-mips/translate_init.c
@@ -655,14 +655,14 @@ static const mips_def_t mips_defs[] =
                        (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
                        (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
         .CP0_Config2 = MIPS_CONFIG2,
-        .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_RXI) | (1 << CP0C3_BP) |
-                       (1 << CP0C3_BI) | (1 << CP0C3_ULRI) | (1 << CP0C3_LPA) |
-                       (1U << CP0C3_M),
-        .CP0_Config4 = MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) |
-                       (3 << CP0C4_IE) | (1 << CP0C4_M),
+        .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_MSAP) |
+                       (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) |
+                       (1 << CP0C3_RXI) | (1 << CP0C3_LPA),
+        .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) |
+                       (0xfc << CP0C4_KScrExist),
         .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_LLB),
-        .CP0_Config5_rw_bitmask = (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) |
-                                  (1 << CP0C5_UFE),
+        .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) |
+                                  (1 << CP0C5_FRE) | (1 << CP0C5_UFE),
         .CP0_LLAddr_rw_bitmask = 0,
         .CP0_LLAddr_shift = 0,
         .SYNCI_Step = 32,
@@ -674,9 +674,9 @@ static const mips_def_t mips_defs[] =
         .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_F64) | (1 << FCR0_L) |
                     (1 << FCR0_W) | (1 << FCR0_D) | (1 << FCR0_S) |
                     (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
-        .SEGBITS = 42,
+        .SEGBITS = 48,
         .PABITS = 48,
-        .insn_flags = CPU_MIPS64R6,
+        .insn_flags = CPU_MIPS64R6 | ASE_MSA,
         .mmu_type = MMU_TYPE_R4000,
     },
     {
commit f5dec79ee88034b2da52463145a2056500db9ff2
Merge: 661725d 560d027
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Wed Jul 15 12:22:31 2015 +0100

    Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20150715-1' into staging
    
    migration/next for 20150715
    
    # gpg: Signature made Wed Jul 15 11:23:33 2015 BST using RSA key ID 5872D723
    # gpg: Good signature from "Juan Quintela <quintela at redhat.com>"
    # gpg:                 aka "Juan Quintela <quintela at trasno.org>"
    
    * remotes/juanquintela/tags/migration/20150715-1:
      migration: We also want to store the global state for savevm
      migration: reduce the count of strlen call
      migration: Register global state section before loadvm
      migration: Write documetation for events capabilites
      migration: Trace event and migration event are different things
      migration: Only change state after migration has finished
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit 560d027b54067ffa4e79c6f7c0a499abb0d749a3
Author: Juan Quintela <quintela at redhat.com>
Date:   Wed Jul 15 09:53:46 2015 +0200

    migration: We also want to store the global state for savevm
    
    Commit df4b1024526cae3479da3492d6371fd4a7324a03 introduced global_state
    section.  But it only filled the state while doing migration.  While
    doing a savevm, we stored an empty string as state.  So when we did a
    loadvm, it complained that state was invalid.
    
    Fedora 21, 4.1.1, qemu 2.4.0-rc0
    > ../../configure --target-list="x86_64-softmmu"
    
    068 2s ... - output mismatch (see 068.out.bad)
    --- /home/bos/jhuston/src/qemu/tests/qemu-iotests/068.out	2015-07-08
    17:56:18.588164979 -0400
    +++ 068.out.bad	2015-07-09 17:39:58.636651317 -0400
    @@ -6,6 +6,8 @@
     QEMU X.Y.Z monitor - type 'help' for more information
     (qemu) savevm 0
     (qemu) quit
    +qemu-system-x86_64: Unknown savevm section or instance 'globalstate' 0
    +qemu-system-x86_64: Error -22 while loading VM state
     QEMU X.Y.Z monitor - type 'help' for more information
     (qemu) quit
     *** done
    Failures: 068
    Failed 1 of 1 tests
    
    Actually, there were two problems here:
    - we registered global_state too late for load_vm (fixed on another
      patch on the list)
    - we didn't store a valid state for savevm (fixed by this patch).
    
    Reported-by: John Snow <jsnow at redhat.com>
    Signed-off-by: Juan Quintela <quintela at redhat.com>
    Reviewed-by: Dr. David Alan Gilbert <dgilbert at redhat.com>
    Reviewed-by: Amit Shah <amit.shah at redhat.com>
    Tested-by:  Christian Borntraeger <borntraeger at de.ibm.com>

diff --git a/include/migration/migration.h b/include/migration/migration.h
index b2711ef..a2f8ed0 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -202,4 +202,5 @@ void savevm_skip_section_footers(void);
 void register_global_state(void);
 void global_state_set_optional(void);
 void savevm_skip_configuration(void);
+int global_state_store(void);
 #endif
diff --git a/migration/migration.c b/migration/migration.c
index ba82ff6..86ca099 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -110,7 +110,7 @@ typedef struct {
 
 static GlobalState global_state;
 
-static int global_state_store(void)
+int global_state_store(void)
 {
     if (!runstate_store((char *)global_state.runstate,
                         sizeof(global_state.runstate))) {
diff --git a/migration/savevm.c b/migration/savevm.c
index 86735fc..81dbe58 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1315,6 +1315,12 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     }
 
     saved_vm_running = runstate_is_running();
+
+    ret = global_state_store();
+    if (ret) {
+        monitor_printf(mon, "Error saving global state\n");
+        return;
+    }
     vm_stop(RUN_STATE_SAVE_VM);
 
     memset(sn, 0, sizeof(*sn));
commit 9f5f380b54d6ad80cf35d93c8cd71c8d7a1b52b7
Author: Liang Li <liang.z.li at intel.com>
Date:   Mon Jul 13 17:34:10 2015 +0800

    migration: reduce the count of strlen call
    
    'strlen' is called three times in 'save_page_header', it's
    inefficient.
    
    Signed-off-by: Liang Li <liang.z.li at intel.com>
    Reviewed-by: Juan Quintela <quintela at redhat.com>
    Reviewed-by: Amit Shah <amit.shah at redhat.com>
    Signed-off-by: Juan Quintela <quintela at redhat.com>

diff --git a/migration/ram.c b/migration/ram.c
index 1e58cd3..7f007e6 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -382,16 +382,16 @@ void migrate_compress_threads_create(void)
  */
 static size_t save_page_header(QEMUFile *f, RAMBlock *block, ram_addr_t offset)
 {
-    size_t size;
+    size_t size, len;
 
     qemu_put_be64(f, offset);
     size = 8;
 
     if (!(offset & RAM_SAVE_FLAG_CONTINUE)) {
-        qemu_put_byte(f, strlen(block->idstr));
-        qemu_put_buffer(f, (uint8_t *)block->idstr,
-                        strlen(block->idstr));
-        size += 1 + strlen(block->idstr);
+        len = strlen(block->idstr);
+        qemu_put_byte(f, len);
+        qemu_put_buffer(f, (uint8_t *)block->idstr, len);
+        size += 1 + len;
     }
     return size;
 }
commit 48212d87d6655b029231d830a77983c21552fe49
Author: Juan Quintela <quintela at redhat.com>
Date:   Fri Jul 10 14:51:58 2015 +0200

    migration: Register global state section before loadvm
    
    Otherwise, it is not found
    
    Signed-off-by: Juan Quintela <quintela at redhat.com>

diff --git a/vl.c b/vl.c
index 3f269dc..5856396 100644
--- a/vl.c
+++ b/vl.c
@@ -4615,6 +4615,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     qemu_system_reset(VMRESET_SILENT);
+    register_global_state();
     if (loadvm) {
         if (load_vmstate(loadvm) < 0) {
             autostart = 0;
@@ -4628,7 +4629,6 @@ int main(int argc, char **argv, char **envp)
         return 0;
     }
 
-    register_global_state();
     if (incoming) {
         Error *local_err = NULL;
         qemu_start_incoming_migration(incoming, &local_err);
commit 72e72e1a71e5e67a11204606a5c09f6cc3089a53
Author: Juan Quintela <quintela at redhat.com>
Date:   Wed Jul 8 14:13:10 2015 +0200

    migration: Write documetation for events capabilites
    
    Reported-by: Jiri Denemark <jdenemar at redhat.com>
    Signed-off-by: Juan Quintela <quintela at redhat.com>

diff --git a/qmp-commands.hx b/qmp-commands.hx
index e1bcc60..ba630b1 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3406,6 +3406,7 @@ Enable/Disable migration capabilities
 - "rdma-pin-all": pin all pages when using RDMA during migration
 - "auto-converge": throttle down guest to help convergence of migration
 - "zero-blocks": compress zero blocks during block migration
+- "events": generate events for each migration state change
 
 Arguments:
 
commit 4ba4bc5e9bfab457a96ac56dc470730a330aded8
Author: Juan Quintela <quintela at redhat.com>
Date:   Wed Jul 8 13:58:27 2015 +0200

    migration: Trace event and migration event are different things
    
    We can want the trace event even without migration events enabled.
    
    Reported-by:  Wen Congyang <ghostwcy at gmail.com>
    Signed-off-by: Juan Quintela <quintela at redhat.com>
    Reviewed-by: Dr. David Alan Gilbert <dgilbert at redhat.com>

diff --git a/migration/migration.c b/migration/migration.c
index ede432e..ba82ff6 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -216,7 +216,6 @@ static void migrate_generate_event(int new_state)
 {
     if (migrate_use_events()) {
         qapi_event_send_migration(new_state, &error_abort);
-        trace_migrate_set_state(new_state);
     }
 }
 
@@ -528,6 +527,7 @@ void qmp_migrate_set_parameters(bool has_compress_level,
 static void migrate_set_state(MigrationState *s, int old_state, int new_state)
 {
     if (atomic_cmpxchg(&s->state, old_state, new_state) == old_state) {
+        trace_migrate_set_state(new_state);
         migrate_generate_event(new_state);
     }
 }
commit 172c4356f38fbf91675256447a3bedd08220214f
Author: Juan Quintela <quintela at redhat.com>
Date:   Wed Jul 8 13:56:26 2015 +0200

    migration: Only change state after migration has finished
    
    On previous change, we changed state at post load time if it was not
    running, special casing the "running" change.  Now, we change any states
    at the end of the migration.
    
    Signed-off-by: Juan Quintela <quintela at redhat.com>
    Tested-by: Christian Borntraeger <borntraeger at de.ibm.com>

diff --git a/migration/migration.c b/migration/migration.c
index 45719a0..ede432e 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -104,6 +104,8 @@ typedef struct {
     bool optional;
     uint32_t size;
     uint8_t runstate[100];
+    RunState state;
+    bool received;
 } GlobalState;
 
 static GlobalState global_state;
@@ -119,9 +121,14 @@ static int global_state_store(void)
     return 0;
 }
 
-static char *global_state_get_runstate(void)
+static bool global_state_received(void)
 {
-    return (char *)global_state.runstate;
+    return global_state.received;
+}
+
+static RunState global_state_get_runstate(void)
+{
+    return global_state.state;
 }
 
 void global_state_set_optional(void)
@@ -154,26 +161,25 @@ static bool global_state_needed(void *opaque)
 static int global_state_post_load(void *opaque, int version_id)
 {
     GlobalState *s = opaque;
-    int ret = 0;
+    Error *local_err = NULL;
+    int r;
     char *runstate = (char *)s->runstate;
 
+    s->received = true;
     trace_migrate_global_state_post_load(runstate);
 
-    if (strcmp(runstate, "running") != 0) {
-        Error *local_err = NULL;
-        int r = qapi_enum_parse(RunState_lookup, runstate, RUN_STATE_MAX,
+    r = qapi_enum_parse(RunState_lookup, runstate, RUN_STATE_MAX,
                                 -1, &local_err);
 
-        if (r == -1) {
-            if (local_err) {
-                error_report_err(local_err);
-            }
-            return -EINVAL;
+    if (r == -1) {
+        if (local_err) {
+            error_report_err(local_err);
         }
-        ret = vm_stop_force_state(r);
+        return -EINVAL;
     }
+    s->state = r;
 
-   return ret;
+    return 0;
 }
 
 static void global_state_pre_save(void *opaque)
@@ -202,6 +208,7 @@ void register_global_state(void)
 {
     /* We would use it independently that we receive it */
     strcpy((char *)&global_state.runstate, "");
+    global_state.received = false;
     vmstate_register(NULL, 0, &vmstate_globalstate, &global_state);
 }
 
@@ -283,20 +290,19 @@ static void process_incoming_migration_co(void *opaque)
         exit(EXIT_FAILURE);
     }
 
-    /* runstate == "" means that we haven't received it through the
-     * wire, so we obey autostart.  runstate == runing means that we
-     * need to run it, we need to make sure that we do it after
-     * everything else has finished.  Every other state change is done
-     * at the post_load function */
+    /* If global state section was not received or we are in running
+       state, we need to obey autostart. Any other state is set with
+       runstate_set. */
 
-    if (strcmp(global_state_get_runstate(), "running") == 0) {
-        vm_start();
-    } else if (strcmp(global_state_get_runstate(), "") == 0) {
+    if (!global_state_received() ||
+        global_state_get_runstate() == RUN_STATE_RUNNING) {
         if (autostart) {
             vm_start();
         } else {
             runstate_set(RUN_STATE_PAUSED);
         }
+    } else {
+        runstate_set(global_state_get_runstate());
     }
     migrate_decompress_threads_join();
 }
commit 796a060bc0fab40953997976a2e30d9d6235bc7b
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Wed Jul 8 14:37:48 2015 +0100

    block/curl: Don't lose original error when a connection fails.
    
    Currently if qemu is connected to a curl source (eg. web server), and
    the web server fails / times out / dies, you always see a bogus EIO
    "Input/output error".
    
    For example, choose a large file located on any local webserver which
    you control:
    
      $ qemu-img convert -p http://example.com/large.iso /tmp/test
    
    Once it starts copying the file, stop the webserver and you will see
    qemu-img fail with:
    
      qemu-img: error while reading sector 61440: Input/output error
    
    This patch does two things: Firstly print the actual error from curl
    so it doesn't get lost.  Secondly, change EIO to EPROTO.  EPROTO is a
    POSIX.1 compatible errno which more accurately reflects that there was
    a protocol error, rather than some kind of hardware failure.
    
    After this patch is applied, the error changes to:
    
      $ qemu-img convert -p http://example.com/large.iso /tmp/test
      qemu-img: curl: transfer closed with 469989 bytes remaining to read
      qemu-img: error while reading sector 16384: Protocol error
    
    Signed-off-by: Richard W.M. Jones <rjones at redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha at redhat.com>
    Signed-off-by: Jeff Cody <jcody at redhat.com>

diff --git a/block/curl.c b/block/curl.c
index 3a2b63e..032cc8a 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu-common.h"
+#include "qemu/error-report.h"
 #include "block/block_int.h"
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qstring.h"
@@ -298,6 +299,18 @@ static void curl_multi_check_completion(BDRVCURLState *s)
             /* ACBs for successful messages get completed in curl_read_cb */
             if (msg->data.result != CURLE_OK) {
                 int i;
+                static int errcount = 100;
+
+                /* Don't lose the original error message from curl, since
+                 * it contains extra data.
+                 */
+                if (errcount > 0) {
+                    error_report("curl: %s", state->errmsg);
+                    if (--errcount == 0) {
+                        error_report("curl: further errors suppressed");
+                    }
+                }
+
                 for (i = 0; i < CURL_NUM_ACB; i++) {
                     CURLAIOCB *acb = state->acb[i];
 
@@ -305,7 +318,7 @@ static void curl_multi_check_completion(BDRVCURLState *s)
                         continue;
                     }
 
-                    acb->common.cb(acb->common.opaque, -EIO);
+                    acb->common.cb(acb->common.opaque, -EPROTO);
                     qemu_aio_unref(acb);
                     state->acb[i] = NULL;
                 }
commit 48ac0a4df84662f23da25262443e1810b70c2228
Author: Wen Congyang <wency at cn.fujitsu.com>
Date:   Fri May 15 15:51:36 2015 +0800

    mirror: correct buf_size
    
    If bus_size is less than 0, the command fails.
    If buf_size is 0, use DEFAULT_MIRROR_BUF_SIZE.
    If buf_size % granularity is not 0, mirror_free_init() will
    do dangerous things.
    
    Signed-off-by: Wen Congyang <wency at cn.fujitsu.com>
    Reviewed-by: Fam Zheng <famz at redhat.com>
    Message-id: 5555A588.3080907 at cn.fujitsu.com
    Signed-off-by: Jeff Cody <jcody at redhat.com>

diff --git a/block/mirror.c b/block/mirror.c
index a2700ca..323f747 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -20,6 +20,7 @@
 
 #define SLICE_TIME    100000000ULL /* ns */
 #define MAX_IN_FLIGHT 16
+#define DEFAULT_MIRROR_BUF_SIZE   (10 << 20)
 
 /* The mirroring buffer is a list of granularity-sized chunks.
  * Free chunks are organized in a list.
@@ -701,6 +702,14 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
         return;
     }
 
+    if (buf_size < 0) {
+        error_setg(errp, "Invalid parameter 'buf-size'");
+        return;
+    }
+
+    if (buf_size == 0) {
+        buf_size = DEFAULT_MIRROR_BUF_SIZE;
+    }
 
     s = block_job_create(driver, bs, speed, cb, opaque, errp);
     if (!s) {
@@ -714,7 +723,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
     s->is_none_mode = is_none_mode;
     s->base = base;
     s->granularity = granularity;
-    s->buf_size = MAX(buf_size, granularity);
+    s->buf_size = ROUND_UP(buf_size, granularity);
     s->unmap = unmap;
 
     s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
diff --git a/blockdev.c b/blockdev.c
index 50421c8..62a4586 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2639,8 +2639,6 @@ out:
     aio_context_release(aio_context);
 }
 
-#define DEFAULT_MIRROR_BUF_SIZE   (10 << 20)
-
 void qmp_drive_mirror(const char *device, const char *target,
                       bool has_format, const char *format,
                       bool has_node_name, const char *node_name,
@@ -2682,7 +2680,7 @@ void qmp_drive_mirror(const char *device, const char *target,
         granularity = 0;
     }
     if (!has_buf_size) {
-        buf_size = DEFAULT_MIRROR_BUF_SIZE;
+        buf_size = 0;
     }
     if (!has_unmap) {
         unmap = true;
commit 17d9716d7b5381c4b6566bb1a06267d2bfcd1821
Author: Stefan Hajnoczi <stefanha at redhat.com>
Date:   Mon Jun 15 16:02:14 2015 +0100

    block: keep bitmap if incremental backup job is cancelled
    
    Reclaim the dirty bitmap if an incremental backup block job is
    cancelled.  The ret variable may be 0 when the job is cancelled so it's
    not enough to check ret < 0.
    
    Reviewed-by: John Snow <jsnow at redhat.com>
    Signed-off-by: Stefan Hajnoczi <stefanha at redhat.com>
    Message-id: 1434380534-7680-1-git-send-email-stefanha at redhat.com
    Signed-off-by: Jeff Cody <jcody at redhat.com>

diff --git a/block/backup.c b/block/backup.c
index d3c7d9f..965654d 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -431,7 +431,7 @@ static void coroutine_fn backup_run(void *opaque)
 
     if (job->sync_bitmap) {
         BdrvDirtyBitmap *bm;
-        if (ret < 0) {
+        if (ret < 0 || block_job_is_cancelled(&job->common)) {
             /* Merge the successor back into the parent, delete nothing. */
             bm = bdrv_reclaim_dirty_bitmap(bs, job->sync_bitmap, NULL);
             assert(bm);
commit 299bf097375f9d148cda579ad85477304e38856b
Author: Paolo Bonzini <pbonzini at redhat.com>
Date:   Thu May 28 16:21:43 2015 +0200

    blockdev: no need to drain in qmp_block_commit
    
    Draining is not necessary, I/O can happen as soon as the
    commit coroutine yields.  Draining can be necessary before
    reopening the file for read/write, or while modifying the
    backing file chain, but that is done separately in
    bdrv_reopen_multiple or bdrv_close; this particular
    bdrv_drain_all does nothing for that.
    
    Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
    Reviewed-by: Fam Zheng <famz at redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha at redhat.com>
    Message-id: 1432822903-25821-1-git-send-email-pbonzini at redhat.com
    Signed-off-by: Jeff Cody <jcody at redhat.com>

diff --git a/blockdev.c b/blockdev.c
index 7fee519..50421c8 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2380,9 +2380,6 @@ void qmp_block_commit(const char *device,
     aio_context = bdrv_get_aio_context(bs);
     aio_context_acquire(aio_context);
 
-    /* drain all i/o before commits */
-    bdrv_drain_all();
-
     if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, errp)) {
         goto out;
     }
commit 4c0cbd6fec7db182a6deb52d5a8a8e7b0c5cbe64
Author: Fam Zheng <famz at redhat.com>
Date:   Wed May 13 11:11:13 2015 +0800

    block/mirror: Sleep periodically during bitmap scanning
    
    Before, we only yield after initializing dirty bitmap, where the QMP
    command would return. That may take very long, and guest IO will be
    blocked.
    
    Add sleep points like the later mirror iterations.
    
    Signed-off-by: Fam Zheng <famz at redhat.com>
    Reviewed-by: Wen Congyang <wency at cn.fujitsu.com>
    Reviewed-by: Paolo Bonzini <pbonzini at redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha at redhat.com>
    Message-id: 1431486673-19280-1-git-send-email-famz at redhat.com
    Signed-off-by: Jeff Cody <jcody at redhat.com>

diff --git a/block/mirror.c b/block/mirror.c
index d409337..a2700ca 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -444,11 +444,23 @@ static void coroutine_fn mirror_run(void *opaque)
     sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
     mirror_free_init(s);
 
+    last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
     if (!s->is_none_mode) {
         /* First part, loop on the sectors and initialize the dirty bitmap.  */
         BlockDriverState *base = s->base;
         for (sector_num = 0; sector_num < end; ) {
             int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1;
+            int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+
+            if (now - last_pause_ns > SLICE_TIME) {
+                last_pause_ns = now;
+                block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, 0);
+            }
+
+            if (block_job_is_cancelled(&s->common)) {
+                goto immediate_exit;
+            }
+
             ret = bdrv_is_allocated_above(bs, base,
                                           sector_num, next - sector_num, &n);
 
@@ -467,7 +479,6 @@ static void coroutine_fn mirror_run(void *opaque)
     }
 
     bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi);
-    last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
     for (;;) {
         uint64_t delay_ns = 0;
         int64_t cnt;
commit 661725da09f47eb92d356fac10a4cf3b7ad1f61d
Merge: f394798 2af9170
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Tue Jul 14 18:50:16 2015 +0100

    Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150714' into staging
    
    s390x fixes for 2.4:
    - virtio migration regression
    - missing diag288 watchdog resets
    
    # gpg: Signature made Tue Jul 14 18:17:54 2015 BST using RSA key ID C6F02FAF
    # gpg: Good signature from "Cornelia Huck <huckc at linux.vnet.ibm.com>"
    # gpg:                 aka "Cornelia Huck <cornelia.huck at de.ibm.com>"
    
    * remotes/cohuck/tags/s390x-20150714:
      s390/virtio-ccw: Fix migration
      watchdog/diag288: correctly register for system reset requests
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit 2af9170c8c269c4fba73e5271453ca15a57f5844
Author: Christian Borntraeger <borntraeger at de.ibm.com>
Date:   Tue Jul 7 13:47:23 2015 +0200

    s390/virtio-ccw: Fix migration
    
    commit 213941d73b ("virtio-ccw: migrate ->revision") broke
    migration:
    2015-07-07T11:22:55.570968Z qemu-system-s390x: VQ 39 address 0x0 inconsistent with Host index 0x100
    2015-07-07T11:22:55.571008Z qemu-system-s390x: error while loading state for instance 0x0 of
    
    If thinint support is active, the config_load function returns early.
    Make sure to load the revision all the time.
    
    Signed-off-by: Christian Borntraeger <borntraeger at de.ibm.com>
    Fixes: 213941d73b ("virtio-ccw: migrate ->revision")
    Message-Id: <1436269643-66303-1-git-send-email-borntraeger at de.ibm.com>
    Signed-off-by: Cornelia Huck <cornelia.huck at de.ibm.com>

diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index e345a6e..d36373e 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1508,12 +1508,12 @@ static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f)
     qemu_get_be16s(f, &vdev->config_vector);
     dev->routes.adapter.ind_offset = qemu_get_be64(f);
     dev->thinint_isc = qemu_get_byte(f);
+    dev->revision = qemu_get_be32(f);
     if (s->thinint_active) {
         return css_register_io_adapter(CSS_IO_ADAPTER_VIRTIO,
                                        dev->thinint_isc, true, false,
                                        &dev->routes.adapter.adapter_id);
     }
-    dev->revision = qemu_get_be32(f);
 
     return 0;
 }
commit 0c7322cfd3fd382c0096c2a9f00775818a878e13
Author: Xu Wang <gesaint at linux.vnet.ibm.com>
Date:   Mon Jun 29 08:21:10 2015 +0200

    watchdog/diag288: correctly register for system reset requests
    
    The diag288 watchdog is no sysbus device, therefore it doesn't get
    triggered on resets automatically using dc->reset.
    
    Let's register the reset handler manually, so we get correctly notified
    again when a system reset was requested. Also reset the watchdog on
    subsystem resets that don't trigger a full system reset.
    
    Signed-off-by: Xu Wang <gesaint at linux.vnet.ibm.com>
    Reviewed-by: David Hildenbrand <dahi at linux.vnet.ibm.com>
    Signed-off-by: Cornelia Huck <cornelia.huck at de.ibm.com>
    Tested-by: Christian Borntraeger <borntraeger at de.ibm.com>
    Reviewed-by: Andreas Färber <afaerber at suse.de>

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 3d20d6a..4c51d1a 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -36,7 +36,7 @@ typedef struct S390CcwMachineState {
 
 void io_subsystem_reset(void)
 {
-    DeviceState *css, *sclp, *flic;
+    DeviceState *css, *sclp, *flic, *diag288;
 
     css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
     if (css) {
@@ -51,6 +51,10 @@ void io_subsystem_reset(void)
     if (flic) {
         qdev_reset_all(flic);
     }
+    diag288 = DEVICE(object_resolve_path_type("", "diag288", NULL));
+    if (diag288) {
+        qdev_reset_all(diag288);
+    }
 }
 
 static int virtio_ccw_hcall_notify(const uint64_t *args)
diff --git a/hw/watchdog/wdt_diag288.c b/hw/watchdog/wdt_diag288.c
index 1185e06..2a885a4 100644
--- a/hw/watchdog/wdt_diag288.c
+++ b/hw/watchdog/wdt_diag288.c
@@ -40,6 +40,13 @@ static void wdt_diag288_reset(DeviceState *dev)
     timer_del(diag288->timer);
 }
 
+static void diag288_reset(void *opaque)
+{
+    DeviceState *diag288 = opaque;
+
+    wdt_diag288_reset(diag288);
+}
+
 static void diag288_timer_expired(void *dev)
 {
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
+    qemu_register_reset(diag288_reset, diag288);
     diag288->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, diag288_timer_expired,
                                   dev);
 }
commit f3947986d9bbbae1087c4c33880d3f8dbf1f1384
Merge: 0030ff4 e34d8f2
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Tue Jul 14 16:51:44 2015 +0100

    Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
    
    Block layer patches for 2.4.0-rc1
    
    # gpg: Signature made Tue Jul 14 16:15:35 2015 BST using RSA key ID C88F2FD6
    # gpg: Good signature from "Kevin Wolf <kwolf at redhat.com>"
    
    * remotes/kevin/tags/for-upstream:
      rbd: fix ceph settings precedence
      rbd: make qemu's cache setting override any ceph setting
      MAINTAINERS: update email address
      rbd: remove unused constants and fields
      block: Fix backing file child when modifying graph
      block: Reorder cleanups in bdrv_close()
      block: Introduce bdrv_unref_child()
      block: Introduce bdrv_open_child()
      block: Move bdrv_attach_child() calls up the call chain
      nvme: properly report volatile write caches
      nvme: implement the Flush command
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit e34d8f297d51b7ffa5dce72df1e45fa94cff989c
Author: Josh Durgin <jdurgin at redhat.com>
Date:   Wed Jun 10 20:28:46 2015 -0700

    rbd: fix ceph settings precedence
    
    Apply the ceph settings from a config file before any ceph settings
    from the command line. Since the ceph config file location may be
    specified on the command line, parse it once to read the config file,
    and do a second pass to apply the rest of the command line ceph
    options.
    
    Signed-off-by: Josh Durgin <jdurgin at redhat.com>
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>

diff --git a/block/rbd.c b/block/rbd.c
index 00d027d..a60a19d 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -228,7 +228,9 @@ static char *qemu_rbd_parse_clientname(const char *conf, char *clientname)
     return NULL;
 }
 
-static int qemu_rbd_set_conf(rados_t cluster, const char *conf, Error **errp)
+static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
+                             bool only_read_conf_file,
+                             Error **errp)
 {
     char *p, *buf;
     char name[RBD_MAX_CONF_NAME_SIZE];
@@ -260,14 +262,18 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf, Error **errp)
         qemu_rbd_unescape(value);
 
         if (strcmp(name, "conf") == 0) {
-            ret = rados_conf_read_file(cluster, value);
-            if (ret < 0) {
-                error_setg(errp, "error reading conf file %s", value);
-                break;
+            /* read the conf file alone, so it doesn't override more
+               specific settings for a particular device */
+            if (only_read_conf_file) {
+                ret = rados_conf_read_file(cluster, value);
+                if (ret < 0) {
+                    error_setg(errp, "error reading conf file %s", value);
+                    break;
+                }
             }
         } else if (strcmp(name, "id") == 0) {
             /* ignore, this is parsed by qemu_rbd_parse_clientname() */
-        } else {
+        } else if (!only_read_conf_file) {
             ret = rados_conf_set(cluster, name, value);
             if (ret < 0) {
                 error_setg(errp, "invalid conf option %s", name);
@@ -330,10 +336,15 @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
     if (strstr(conf, "conf=") == NULL) {
         /* try default location, but ignore failure */
         rados_conf_read_file(cluster, NULL);
+    } else if (conf[0] != '\0' &&
+               qemu_rbd_set_conf(cluster, conf, true, &local_err) < 0) {
+        rados_shutdown(cluster);
+        error_propagate(errp, local_err);
+        return -EIO;
     }
 
     if (conf[0] != '\0' &&
-        qemu_rbd_set_conf(cluster, conf, &local_err) < 0) {
+        qemu_rbd_set_conf(cluster, conf, false, &local_err) < 0) {
         rados_shutdown(cluster);
         error_propagate(errp, local_err);
         return -EIO;
@@ -463,10 +474,15 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
     if (strstr(conf, "conf=") == NULL) {
         /* try default location, but ignore failure */
         rados_conf_read_file(s->cluster, NULL);
+    } else if (conf[0] != '\0') {
+        r = qemu_rbd_set_conf(s->cluster, conf, true, errp);
+        if (r < 0) {
+            goto failed_shutdown;
+        }
     }
 
     if (conf[0] != '\0') {
-        r = qemu_rbd_set_conf(s->cluster, conf, errp);
+        r = qemu_rbd_set_conf(s->cluster, conf, false, errp);
         if (r < 0) {
             goto failed_shutdown;
         }
commit 99a3c89d5d538dc6c360e35dffb797cfe06e9cda
Author: Josh Durgin <jdurgin at redhat.com>
Date:   Wed Jun 10 20:28:45 2015 -0700

    rbd: make qemu's cache setting override any ceph setting
    
    To be safe, when cache=none is used ceph settings should not be able
    to override it to turn on caching. This was previously possible with
    rbd_cache=true in the rbd device configuration or a ceph configuration
    file. Similarly, rbd settings could have turned off caching when qemu
    requested it, although this would just be a performance problem.
    
    Fix this by changing rbd's cache setting to match qemu after all other
    ceph settings have been applied.
    
    Signed-off-by: Josh Durgin <jdurgin at redhat.com>
    Reviewed-by: Jeff Cody <jcody at redhat.com>
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>

diff --git a/block/rbd.c b/block/rbd.c
index 50b5f6b..00d027d 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -460,6 +460,18 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         s->snap = g_strdup(snap_buf);
     }
 
+    if (strstr(conf, "conf=") == NULL) {
+        /* try default location, but ignore failure */
+        rados_conf_read_file(s->cluster, NULL);
+    }
+
+    if (conf[0] != '\0') {
+        r = qemu_rbd_set_conf(s->cluster, conf, errp);
+        if (r < 0) {
+            goto failed_shutdown;
+        }
+    }
+
     /*
      * Fallback to more conservative semantics if setting cache
      * options fails. Ignore errors from setting rbd_cache because the
@@ -473,18 +485,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         rados_conf_set(s->cluster, "rbd_cache", "true");
     }
 
-    if (strstr(conf, "conf=") == NULL) {
-        /* try default location, but ignore failure */
-        rados_conf_read_file(s->cluster, NULL);
-    }
-
-    if (conf[0] != '\0') {
-        r = qemu_rbd_set_conf(s->cluster, conf, errp);
-        if (r < 0) {
-            goto failed_shutdown;
-        }
-    }
-
     r = rados_connect(s->cluster);
     if (r < 0) {
         error_setg(errp, "error connecting");
commit 5a8ac6d9d70e1a078d04ad75a5c055b00a041d70
Author: Josh Durgin <jdurgin at redhat.com>
Date:   Wed Jun 10 20:28:44 2015 -0700

    MAINTAINERS: update email address
    
    The old one still works for now, but will not work indefinitely.
    
    Signed-off-by: Josh Durgin <jdurgin at redhat.com>
    Reviewed-by: Jeff Cody <jcody at redhat.com>
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>

diff --git a/MAINTAINERS b/MAINTAINERS
index 411da3c..978b717 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1169,7 +1169,7 @@ S: Supported
 F: block/vmdk.c
 
 RBD
-M: Josh Durgin <josh.durgin at inktank.com>
+M: Josh Durgin <jdurgin at redhat.com>
 M: Jeff Cody <jcody at redhat.com>
 L: qemu-block at nongnu.org
 S: Supported
commit 3dbf00e058e450173c6f892bb572df871eb4ea58
Author: Josh Durgin <jdurgin at redhat.com>
Date:   Wed Jun 10 20:28:43 2015 -0700

    rbd: remove unused constants and fields
    
    RBDAIOCB.status was only used for cancel, which was removed in
    7691e24dbebb46658e89b3f950fda6ec78bbb823.
    
    RBDAIOCB.sector_num was never used.
    
    RADOSCB.done and rcbid were never used.
    
    RBD_FD* are obsolete since the pipe was removed in
    e04fb07fd1676e9facd7f3f878c1bbe03bccd26b.
    
    Signed-off-by: Josh Durgin <jdurgin at redhat.com>
    Reviewed-by: Jeff Cody <jcody at redhat.com>
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>

diff --git a/block/rbd.c b/block/rbd.c
index fbe87e0..50b5f6b 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -74,25 +74,18 @@ typedef struct RBDAIOCB {
     QEMUIOVector *qiov;
     char *bounce;
     RBDAIOCmd cmd;
-    int64_t sector_num;
     int error;
     struct BDRVRBDState *s;
-    int status;
 } RBDAIOCB;
 
 typedef struct RADOSCB {
-    int rcbid;
     RBDAIOCB *acb;
     struct BDRVRBDState *s;
-    int done;
     int64_t size;
     char *buf;
     int64_t ret;
 } RADOSCB;
 
-#define RBD_FD_READ 0
-#define RBD_FD_WRITE 1
-
 typedef struct BDRVRBDState {
     rados_t cluster;
     rados_ioctx_t io_ctx;
@@ -405,7 +398,6 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
     }
     qemu_vfree(acb->bounce);
     acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret));
-    acb->status = 0;
 
     qemu_aio_unref(acb);
 }
@@ -621,7 +613,6 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     acb->error = 0;
     acb->s = s;
     acb->bh = NULL;
-    acb->status = -EINPROGRESS;
 
     if (cmd == RBD_AIO_WRITE) {
         qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
@@ -633,7 +624,6 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     size = nb_sectors * BDRV_SECTOR_SIZE;
 
     rcb = g_new(RADOSCB, 1);
-    rcb->done = 0;
     rcb->acb = acb;
     rcb->buf = buf;
     rcb->s = acb->s;
commit 80a1e130917e0745625129553c943743eb663727
Author: Kevin Wolf <kwolf at redhat.com>
Date:   Wed Jun 17 15:52:09 2015 +0200

    block: Fix backing file child when modifying graph
    
    This patch moves bdrv_attach_child() from the individual places that add
    a backing file to a BDS to bdrv_set_backing_hd(), which is called by all
    of them. It also adds bdrv_detach_child() there.
    
    For normal operation (starting with one backing file chain and not
    changing it until the topmost image is closed) and live snapshots, this
    constitutes no change in behaviour.
    
    For all other cases, this is a fix for the bug that the old backing file
    was still referenced as a child, and the new one wasn't referenced.
    
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>
    Reviewed-by: Max Reitz <mreitz at redhat.com>

diff --git a/block.c b/block.c
index d5c9f03..d088ee0 100644
--- a/block.c
+++ b/block.c
@@ -1141,6 +1141,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
     if (bs->backing_hd) {
         assert(bs->backing_blocker);
         bdrv_op_unblock_all(bs->backing_hd, bs->backing_blocker);
+        bdrv_detach_child(bs->backing_child);
     } else if (backing_hd) {
         error_setg(&bs->backing_blocker,
                    "node is used as backing hd of '%s'",
@@ -1151,8 +1152,10 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
     if (!backing_hd) {
         error_free(bs->backing_blocker);
         bs->backing_blocker = NULL;
+        bs->backing_child = NULL;
         goto out;
     }
+    bs->backing_child = bdrv_attach_child(bs, backing_hd, &child_backing);
     bs->open_flags &= ~BDRV_O_NO_BACKING;
     pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename);
     pstrcpy(bs->backing_format, sizeof(bs->backing_format),
@@ -1236,7 +1239,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
         goto free_exit;
     }
 
-    bdrv_attach_child(bs, backing_hd, &child_backing);
     bdrv_set_backing_hd(bs, backing_hd);
 
 free_exit:
@@ -2171,7 +2173,6 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
     /* The contents of 'tmp' will become bs_top, as we are
      * swapping bs_new and bs_top contents. */
     bdrv_set_backing_hd(bs_top, bs_new);
-    bdrv_attach_child(bs_top, bs_new, &child_backing);
 }
 
 static void bdrv_delete(BlockDriverState *bs)
diff --git a/include/block/block_int.h b/include/block/block_int.h
index ec244b5..14ad4c3 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -379,6 +379,7 @@ struct BlockDriverState {
     char exact_filename[PATH_MAX];
 
     BlockDriverState *backing_hd;
+    BdrvChild *backing_child;
     BlockDriverState *file;
 
     NotifierList close_notifiers;
commit 9a7dedbc43c7c400663d2876a8ccb6d942a1429a
Author: Kevin Wolf <kwolf at redhat.com>
Date:   Tue Jun 16 10:58:20 2015 +0200

    block: Reorder cleanups in bdrv_close()
    
    Block drivers may still want to access their child nodes in their
    .bdrv_close handler. If they unref and/or detach a child by themselves,
    this should not result in a double free.
    
    There is additional code for backing files, which are just a special
    case of child nodes. The same applies for them.
    
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>
    Reviewed-by: Max Reitz <mreitz at redhat.com>

diff --git a/block.c b/block.c
index b723cf2..d5c9f03 100644
--- a/block.c
+++ b/block.c
@@ -1901,6 +1901,14 @@ void bdrv_close(BlockDriverState *bs)
     if (bs->drv) {
         BdrvChild *child, *next;
 
+        bs->drv->bdrv_close(bs);
+
+        if (bs->backing_hd) {
+            BlockDriverState *backing_hd = bs->backing_hd;
+            bdrv_set_backing_hd(bs, NULL);
+            bdrv_unref(backing_hd);
+        }
+
         QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
             /* TODO Remove bdrv_unref() from drivers' close function and use
              * bdrv_unref_child() here */
@@ -1910,12 +1918,6 @@ void bdrv_close(BlockDriverState *bs)
             bdrv_detach_child(child);
         }
 
-        if (bs->backing_hd) {
-            BlockDriverState *backing_hd = bs->backing_hd;
-            bdrv_set_backing_hd(bs, NULL);
-            bdrv_unref(backing_hd);
-        }
-        bs->drv->bdrv_close(bs);
         g_free(bs->opaque);
         bs->opaque = NULL;
         bs->drv = NULL;
commit 33a604075c51e5528eed970eeaeefe609ea2337d
Author: Kevin Wolf <kwolf at redhat.com>
Date:   Mon Jun 15 13:51:04 2015 +0200

    block: Introduce bdrv_unref_child()
    
    This is the counterpart for bdrv_open_child(). It decreases the
    reference count of the child BDS and removes it from the list of
    children of the given parent BDS.
    
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>
    Reviewed-by: Max Reitz <mreitz at redhat.com>

diff --git a/block.c b/block.c
index 029feeb..b723cf2 100644
--- a/block.c
+++ b/block.c
@@ -1117,6 +1117,24 @@ static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
     return child;
 }
 
+static void bdrv_detach_child(BdrvChild *child)
+{
+    QLIST_REMOVE(child, next);
+    g_free(child);
+}
+
+void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
+{
+    BlockDriverState *child_bs = child->bs;
+
+    if (child->bs->inherits_from == parent) {
+        child->bs->inherits_from = NULL;
+    }
+
+    bdrv_detach_child(child);
+    bdrv_unref(child_bs);
+}
+
 void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
 {
 
@@ -1884,11 +1902,12 @@ void bdrv_close(BlockDriverState *bs)
         BdrvChild *child, *next;
 
         QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
+            /* TODO Remove bdrv_unref() from drivers' close function and use
+             * bdrv_unref_child() here */
             if (child->bs->inherits_from == bs) {
                 child->bs->inherits_from = NULL;
             }
-            QLIST_REMOVE(child, next);
-            g_free(child);
+            bdrv_detach_child(child);
         }
 
         if (bs->backing_hd) {
diff --git a/include/block/block.h b/include/block/block.h
index 5048772..37916f7 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -513,6 +513,7 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs);
 
 void bdrv_ref(BlockDriverState *bs);
 void bdrv_unref(BlockDriverState *bs);
+void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child);
 
 bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp);
 void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason);
commit b4b059f628173dd1d722ee8a9c592a80aec1fc2f
Author: Kevin Wolf <kwolf at redhat.com>
Date:   Mon Jun 15 13:24:19 2015 +0200

    block: Introduce bdrv_open_child()
    
    It is the same as bdrv_open_image(), except that it doesn't only return
    success or failure, but the newly created BdrvChild object for the new
    child node.
    
    As the BdrvChild object already contains a BlockDriverState pointer (and
    this is supposed to become the only pointer so that bdrv_append() and
    friends can just change a single pointer in BdrvChild), the pbs
    parameter is removed for bdrv_open_child().
    
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>
    Reviewed-by: Max Reitz <mreitz at redhat.com>

diff --git a/block.c b/block.c
index 0398bff..029feeb 100644
--- a/block.c
+++ b/block.c
@@ -1102,9 +1102,9 @@ static int bdrv_fill_options(QDict **options, const char **pfilename,
     return 0;
 }
 
-static void bdrv_attach_child(BlockDriverState *parent_bs,
-                              BlockDriverState *child_bs,
-                              const BdrvChildRole *child_role)
+static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
+                                    BlockDriverState *child_bs,
+                                    const BdrvChildRole *child_role)
 {
     BdrvChild *child = g_new(BdrvChild, 1);
     *child = (BdrvChild) {
@@ -1113,6 +1113,8 @@ static void bdrv_attach_child(BlockDriverState *parent_bs,
     };
 
     QLIST_INSERT_HEAD(&parent_bs->children, child, next);
+
+    return child;
 }
 
 void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
@@ -1229,7 +1231,7 @@ free_exit:
  * device's options.
  *
  * If allow_none is true, no image will be opened if filename is false and no
- * BlockdevRef is given. *pbs will remain unchanged and 0 will be returned.
+ * BlockdevRef is given. NULL will be returned, but errp remains unset.
  *
  * bdrev_key specifies the key for the image's BlockdevRef in the options QDict.
  * That QDict has to be flattened; therefore, if the BlockdevRef is a QDict
@@ -1237,21 +1239,20 @@ free_exit:
  * BlockdevRef.
  *
  * The BlockdevRef will be removed from the options QDict.
- *
- * To conform with the behavior of bdrv_open(), *pbs has to be NULL.
  */
-int bdrv_open_image(BlockDriverState **pbs, const char *filename,
-                    QDict *options, const char *bdref_key,
-                    BlockDriverState* parent, const BdrvChildRole *child_role,
-                    bool allow_none, Error **errp)
+BdrvChild *bdrv_open_child(const char *filename,
+                           QDict *options, const char *bdref_key,
+                           BlockDriverState* parent,
+                           const BdrvChildRole *child_role,
+                           bool allow_none, Error **errp)
 {
+    BdrvChild *c = NULL;
+    BlockDriverState *bs;
     QDict *image_options;
     int ret;
     char *bdref_key_dot;
     const char *reference;
 
-    assert(pbs);
-    assert(*pbs == NULL);
     assert(child_role != NULL);
 
     bdref_key_dot = g_strdup_printf("%s.", bdref_key);
@@ -1260,28 +1261,60 @@ int bdrv_open_image(BlockDriverState **pbs, const char *filename,
 
     reference = qdict_get_try_str(options, bdref_key);
     if (!filename && !reference && !qdict_size(image_options)) {
-        if (allow_none) {
-            ret = 0;
-        } else {
+        if (!allow_none) {
             error_setg(errp, "A block device must be specified for \"%s\"",
                        bdref_key);
-            ret = -EINVAL;
         }
         QDECREF(image_options);
         goto done;
     }
 
-    ret = bdrv_open_inherit(pbs, filename, reference, image_options, 0,
+    bs = NULL;
+    ret = bdrv_open_inherit(&bs, filename, reference, image_options, 0,
                             parent, child_role, NULL, errp);
     if (ret < 0) {
         goto done;
     }
 
-    bdrv_attach_child(parent, *pbs, child_role);
+    c = bdrv_attach_child(parent, bs, child_role);
 
 done:
     qdict_del(options, bdref_key);
-    return ret;
+    return c;
+}
+
+/*
+ * This is a version of bdrv_open_child() that returns 0/-EINVAL instead of
+ * a BdrvChild object.
+ *
+ * If allow_none is true, no image will be opened if filename is false and no
+ * BlockdevRef is given. *pbs will remain unchanged and 0 will be returned.
+ *
+ * To conform with the behavior of bdrv_open(), *pbs has to be NULL.
+ */
+int bdrv_open_image(BlockDriverState **pbs, const char *filename,
+                    QDict *options, const char *bdref_key,
+                    BlockDriverState* parent, const BdrvChildRole *child_role,
+                    bool allow_none, Error **errp)
+{
+    Error *local_err = NULL;
+    BdrvChild *c;
+
+    assert(pbs);
+    assert(*pbs == NULL);
+
+    c = bdrv_open_child(filename, options, bdref_key, parent, child_role,
+                        allow_none, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return -EINVAL;
+    }
+
+    if (c != NULL) {
+        *pbs = c->bs;
+    }
+
+    return 0;
 }
 
 int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
diff --git a/include/block/block.h b/include/block/block.h
index 06e4137..5048772 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -12,6 +12,7 @@
 /* block.c */
 typedef struct BlockDriver BlockDriver;
 typedef struct BlockJob BlockJob;
+typedef struct BdrvChild BdrvChild;
 typedef struct BdrvChildRole BdrvChildRole;
 
 typedef struct BlockDriverInfo {
@@ -208,6 +209,11 @@ int bdrv_open_image(BlockDriverState **pbs, const char *filename,
                     QDict *options, const char *bdref_key,
                     BlockDriverState* parent, const BdrvChildRole *child_role,
                     bool allow_none, Error **errp);
+BdrvChild *bdrv_open_child(const char *filename,
+                           QDict *options, const char *bdref_key,
+                           BlockDriverState* parent,
+                           const BdrvChildRole *child_role,
+                           bool allow_none, Error **errp);
 void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd);
 int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp);
 int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 8996baf..ec244b5 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -335,11 +335,11 @@ struct BdrvChildRole {
 extern const BdrvChildRole child_file;
 extern const BdrvChildRole child_format;
 
-typedef struct BdrvChild {
+struct BdrvChild {
     BlockDriverState *bs;
     const BdrvChildRole *role;
     QLIST_ENTRY(BdrvChild) next;
-} BdrvChild;
+};
 
 /*
  * Note: the function bdrv_append() copies and swaps contents of
commit df5817926790f6e84d1936eab523556f96fa577a
Author: Kevin Wolf <kwolf at redhat.com>
Date:   Mon Jun 15 11:53:47 2015 +0200

    block: Move bdrv_attach_child() calls up the call chain
    
    Let the callers of bdrv_open_inherit() call bdrv_attach_child(). It
    needs to be called in all cases where bdrv_open_inherit() succeeds (i.e.
    returns 0) and a child_role is given.
    
    bdrv_attach_child() is moved upwards to avoid a forward declaration.
    
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>
    Reviewed-by: Max Reitz <mreitz at redhat.com>

diff --git a/block.c b/block.c
index 5e80336..0398bff 100644
--- a/block.c
+++ b/block.c
@@ -1102,6 +1102,19 @@ static int bdrv_fill_options(QDict **options, const char **pfilename,
     return 0;
 }
 
+static void bdrv_attach_child(BlockDriverState *parent_bs,
+                              BlockDriverState *child_bs,
+                              const BdrvChildRole *child_role)
+{
+    BdrvChild *child = g_new(BdrvChild, 1);
+    *child = (BdrvChild) {
+        .bs     = child_bs,
+        .role   = child_role,
+    };
+
+    QLIST_INSERT_HEAD(&parent_bs->children, child, next);
+}
+
 void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
 {
 
@@ -1202,6 +1215,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
         error_free(local_err);
         goto free_exit;
     }
+
+    bdrv_attach_child(bs, backing_hd, &child_backing);
     bdrv_set_backing_hd(bs, backing_hd);
 
 free_exit:
@@ -1237,6 +1252,7 @@ int bdrv_open_image(BlockDriverState **pbs, const char *filename,
 
     assert(pbs);
     assert(*pbs == NULL);
+    assert(child_role != NULL);
 
     bdref_key_dot = g_strdup_printf("%s.", bdref_key);
     qdict_extract_subqdict(options, &image_options, bdref_key_dot);
@@ -1257,6 +1273,11 @@ int bdrv_open_image(BlockDriverState **pbs, const char *filename,
 
     ret = bdrv_open_inherit(pbs, filename, reference, image_options, 0,
                             parent, child_role, NULL, errp);
+    if (ret < 0) {
+        goto done;
+    }
+
+    bdrv_attach_child(parent, *pbs, child_role);
 
 done:
     qdict_del(options, bdref_key);
@@ -1328,19 +1349,6 @@ out:
     return ret;
 }
 
-static void bdrv_attach_child(BlockDriverState *parent_bs,
-                              BlockDriverState *child_bs,
-                              const BdrvChildRole *child_role)
-{
-    BdrvChild *child = g_new(BdrvChild, 1);
-    *child = (BdrvChild) {
-        .bs     = child_bs,
-        .role   = child_role,
-    };
-
-    QLIST_INSERT_HEAD(&parent_bs->children, child, next);
-}
-
 /*
  * Opens a disk image (raw, qcow2, vmdk, ...)
  *
@@ -1393,9 +1401,6 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename,
             return -ENODEV;
         }
         bdrv_ref(bs);
-        if (child_role) {
-            bdrv_attach_child(parent, bs, child_role);
-        }
         *pbs = bs;
         return 0;
     }
@@ -1540,10 +1545,6 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename,
         goto close_and_fail;
     }
 
-    if (child_role) {
-        bdrv_attach_child(parent, bs, child_role);
-    }
-
     QDECREF(options);
     *pbs = bs;
     return 0;
commit 30349fd038ffb26528fad21abe1e264031364449
Author: Christoph Hellwig <hch at lst.de>
Date:   Thu Jun 11 12:01:39 2015 +0200

    nvme: properly report volatile write caches
    
    Implement support in Identify and Get/Set Features to properly report
    and allow to change the Volatile Write Cache status reported by the
    virtual NVMe device.
    
    Signed-off-by: Christoph Hellwig <hch at lst.de>
    Acked-by: Keith Busch <keith.busch at intel.com>
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index dc9caf0..40d4880 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -487,26 +487,32 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd)
 static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
 {
     uint32_t dw10 = le32_to_cpu(cmd->cdw10);
+    uint32_t result;
 
     switch (dw10) {
-    case NVME_NUMBER_OF_QUEUES:
-        req->cqe.result =
-            cpu_to_le32((n->num_queues - 1) | ((n->num_queues - 1) << 16));
-        break;
     case NVME_VOLATILE_WRITE_CACHE:
-        req->cqe.result = cpu_to_le32(1);
+        result = blk_enable_write_cache(n->conf.blk);
+        break;
+    case NVME_NUMBER_OF_QUEUES:
+        result = cpu_to_le32((n->num_queues - 1) | ((n->num_queues - 1) << 16));
         break;
     default:
         return NVME_INVALID_FIELD | NVME_DNR;
     }
+
+    req->cqe.result = result;
     return NVME_SUCCESS;
 }
 
 static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
 {
     uint32_t dw10 = le32_to_cpu(cmd->cdw10);
+    uint32_t dw11 = le32_to_cpu(cmd->cdw11);
 
     switch (dw10) {
+    case NVME_VOLATILE_WRITE_CACHE:
+        blk_set_enable_write_cache(n->conf.blk, dw11 & 1);
+        break;
     case NVME_NUMBER_OF_QUEUES:
         req->cqe.result =
             cpu_to_le32((n->num_queues - 1) | ((n->num_queues - 1) << 16));
@@ -831,6 +837,9 @@ static int nvme_init(PCIDevice *pci_dev)
     id->psd[0].mp = cpu_to_le16(0x9c4);
     id->psd[0].enlat = cpu_to_le32(0x10);
     id->psd[0].exlat = cpu_to_le32(0x4);
+    if (blk_enable_write_cache(n->conf.blk)) {
+        id->vwc = 1;
+    }
 
     n->bar.cap = 0;
     NVME_CAP_SET_MQES(n->bar.cap, 0x7ff);
commit 8b9d74e0eebb2106b767d66355d38086be72ad2b
Author: Christoph Hellwig <hch at lst.de>
Date:   Thu Jun 11 12:01:38 2015 +0200

    nvme: implement the Flush command
    
    Implement a real flush instead of faking it.  This is especially important
    as Qemu assume Write back cashing by default and thus requires a working
    cache flush operation for data integrity.
    
    Signed-off-by: Christoph Hellwig <hch at lst.de>
    Acked-by: Keith Busch <keith.busch at intel.com>
    Signed-off-by: Kevin Wolf <kwolf at redhat.com>

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index c6a6a0e..dc9caf0 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -207,11 +207,23 @@ static void nvme_rw_cb(void *opaque, int ret)
     } else {
         req->status = NVME_INTERNAL_DEV_ERROR;
     }
-
-    qemu_sglist_destroy(&req->qsg);
+    if (req->has_sg) {
+        qemu_sglist_destroy(&req->qsg);
+    }
     nvme_enqueue_req_completion(cq, req);
 }
 
+static uint16_t nvme_flush(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
+    NvmeRequest *req)
+{
+    req->has_sg = false;
+    block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0,
+         BLOCK_ACCT_FLUSH);
+    req->aiocb = blk_aio_flush(n->conf.blk, nvme_rw_cb, req);
+
+    return NVME_NO_COMPLETE;
+}
+
 static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
     NvmeRequest *req)
 {
@@ -235,6 +247,7 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
     }
     assert((nlb << data_shift) == req->qsg.size);
 
+    req->has_sg = true;
     dma_acct_start(n->conf.blk, &req->acct, &req->qsg,
                    is_write ? BLOCK_ACCT_WRITE : BLOCK_ACCT_READ);
     req->aiocb = is_write ?
@@ -256,7 +269,7 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
     ns = &n->namespaces[nsid - 1];
     switch (cmd->opcode) {
     case NVME_CMD_FLUSH:
-        return NVME_SUCCESS;
+        return nvme_flush(n, ns, cmd, req);
     case NVME_CMD_WRITE:
     case NVME_CMD_READ:
         return nvme_rw(n, ns, cmd, req);
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index b6ccb65..bf3a3cc 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -638,6 +638,7 @@ typedef struct NvmeRequest {
     struct NvmeSQueue       *sq;
     BlockAIOCB              *aiocb;
     uint16_t                status;
+    bool                    has_sg;
     NvmeCqe                 cqe;
     BlockAcctCookie         acct;
     QEMUSGList              qsg;
commit 0030ff40472b9ebf0e0595afbc8d7e428218c5d7
Merge: f3a1b50 a169513
Author: Peter Maydell <peter.maydell at linaro.org>
Date:   Tue Jul 14 14:52:45 2015 +0100

    Merge remote-tracking branch 'remotes/kraxel/tags/pull-vnc-20150714-1' into staging
    
    vnc: fix vnc client authentication
    
    # gpg: Signature made Tue Jul 14 14:38:48 2015 BST using RSA key ID D3E87138
    # gpg: Good signature from "Gerd Hoffmann (work) <kraxel at redhat.com>"
    # gpg:                 aka "Gerd Hoffmann <gerd at kraxel.org>"
    # gpg:                 aka "Gerd Hoffmann (private) <kraxel at gmail.com>"
    
    * remotes/kraxel/tags/pull-vnc-20150714-1:
      vnc: fix vnc client authentication
    
    Signed-off-by: Peter Maydell <peter.maydell at linaro.org>

commit a16951375f7669b7faf27f72ca753e25325c5179
Author: Wolfgang Bumiller <w.bumiller at proxmox.com>
Date:   Tue Jul 14 14:51:40 2015 +0200

    vnc: fix vnc client authentication
    
    Commit 800567a61 updated the code to the generic crypto API
    and mixed up encrypt and decrypt functions in
    procotol_client_auth_vnc.
    (Used to be: deskey(key, EN0) which encrypts, and was
    changed to qcrypto_cipher_decrypt in 800567a61.)
    Changed it to qcrypto_cipher_encrypt now.
    
    Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
    Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>

diff --git a/ui/vnc.c b/ui/vnc.c
index 94e4f19..1483958 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2551,7 +2551,7 @@ static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len)
         goto reject;
     }
 
-    if (qcrypto_cipher_decrypt(cipher,
+    if (qcrypto_cipher_encrypt(cipher,
                                vs->challenge,
                                response,
                                VNC_AUTH_CHALLENGE_SIZE,


More information about the Spice-commits mailing list