Hi all,
I am trying to boot Windows 8 (x86) on arm host using qemu dynamic
translation.
It is not successfull but Windows xp boots fine.
Any suggest for this issue?

On Wednesday, December 9, 2015, <qemu-devel-requ...@nongnu.org> wrote:

> Send Qemu-devel mailing list submissions to
>         qemu-devel@nongnu.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.nongnu.org/mailman/listinfo/qemu-devel
> or, via email, send a message with subject or body 'help' to
>         qemu-devel-requ...@nongnu.org
>
> You can reach the person managing the list at
>         qemu-devel-ow...@nongnu.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Qemu-devel digest..."
>
>
> Today's Topics:
>
>    1. Re: [PATCH for-2.5] sparc: allow CASA with ASI 0xa        from user
>       space (Peter Maydell)
>    2. [Bug 1308341] Re: Multiple CPUs causes blue screen on Windows
>       guest (14.04 regression) (Cristian Aires)
>    3. Re: [PATCH] vfio: Align iova also to IOMMU page size
>       (Alex Williamson)
>    4. Re: tcg: improve MAX_CODE_GEN_BUFFER_SIZE for arm (TeLeMan)
>    5. [PATCH] xen_pt: fix failure of attaching & detaching a    PCI
>       device to VM repeatedly (Jianzhong,Chang)
>    6. Re: [PATCH] virtio-blk: Drop x-data-plane option (Stefan Hajnoczi)
>    7. [PATCH v6 00/11] Add basic "detach" support for
>       dump-guest-memory (Peter Xu)
>    8. [PATCH v6 01/11] dump-guest-memory: cleanup: removing
>       dump_{error|cleanup}(). (Peter Xu)
>    9. [PATCH v6 02/11] dump-guest-memory: add "detach" flag     for
>       QMP/HMP interfaces. (Peter Xu)
>   10. [PATCH v6 03/11] dump-guest-memory: using static  DumpState,
>       add DumpStatus (Peter Xu)
>   11. [PATCH v6 04/11] dump-guest-memory: add   dump_in_progress()
>       helper function (Peter Xu)
>   12. [PATCH v6 05/11] dump-guest-memory: introduce     dump_process()
>       helper function. (Peter Xu)
>   13. [PATCH v6 06/11] dump-guest-memory: disable dump when     in
>       INMIGRATE state (Peter Xu)
>   14. [PATCH v6 07/11] dump-guest-memory: add "detach"  support
>       (Peter Xu)
>   15. [PATCH v6 08/11] DumpState: adding total_size and
>       written_size fields (Peter Xu)
>   16. [PATCH v6 09/11] Dump: add qmp command "query-dump" (Peter Xu)
>   17. [PATCH v6 10/11] Dump: add hmp command "info dump" (Peter Xu)
>   18. [PATCH v6 11/11] dump-guest-memory: add qmp event
>       DUMP_COMPLETED (Peter Xu)
>   19. Re: [Qemu-ppc] [PATCHv2 07/10] pseries:   DEFINE_SPAPR_MACHINE
>       (Alexey Kardashevskiy)
>   20. Re: [PATCHv2 01/10] pseries: Remove redundant setting of
>       mc->name for pseries-2.5 machine (Alexey Kardashevskiy)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 8 Dec 2015 21:28:49 +0000
> From: Peter Maydell <peter.mayd...@linaro.org>
> To: Richard Henderson <r...@twiddle.net>
> Cc: Alex Zuepke <a...@sysgo.de>,     Mark Cave-Ayland
>         <mark.cave-ayl...@ilande.co.uk>,     QEMU Developers
>         <qemu-devel@nongnu.org>,     Fabien Chouteau <chout...@adacore.com
> >
> Subject: Re: [Qemu-devel] [PATCH for-2.5] sparc: allow CASA with ASI
>         0xa     from user space
> Message-ID:
>         <CAFEAcA8Y4SfWtq=LGVV6GUp7kDp=ytOC-v55yjCrcg8M=
> ez...@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On 8 December 2015 at 19:59, Richard Henderson <r...@twiddle.net> wrote:
> > On 12/04/2015 07:01 AM, Alex Zuepke wrote:
> >> LEON3 allows the CASA instruction to be used from user space
> >> if the ASI is set to 0xa (user data).
> >>
> >> Signed-off-by: Alex Zuepke <a...@sysgo.de>
> >> ---
> >>  target-sparc/translate.c | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/target-sparc/translate.c b/target-sparc/translate.c
> >> index 41a3319..63440dd 100644
> >> --- a/target-sparc/translate.c
> >> +++ b/target-sparc/translate.c
> >> @@ -5097,7 +5097,8 @@ static void disas_sparc_insn(DisasContext * dc,
> unsigned int insn)
> >>                      if (IS_IMM) {
> >>                          goto illegal_insn;
> >>                      }
> >> -                    if (!supervisor(dc)) {
> >> +                    /* LEON3 allows CASA from user space with ASI 0xa
> */
> >> +                    if ((GET_FIELD(insn, 19, 26) != 0xa) &&
> !supervisor(dc)) {
> >>                          goto priv_insn;
> >>                      }
> >>  #endif
> >>
> >
> > Reviewed-by: Richard Henderson <r...@twiddle.net>
> >
> > This should probably be merged for 2.5.
>
> Very late, but a very small patch which only affects TCG SPARC,
> so I'm OK with applying it to master. (Mark, did you want to ack/review?)
>
> thanks
> -- PMM
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 08 Dec 2015 16:51:45 -0000
> From: Cristian Aires <caires.dr...@gmail.com>
> To: qemu-devel@nongnu.org
> Subject: [Qemu-devel] [Bug 1308341] Re: Multiple CPUs causes blue
>         screen on Windows guest (14.04 regression)
> Message-ID: <20151208165145.25495.70757.mal...@gac.canonical.com>
> Content-Type: text/plain; charset="utf-8"
>
> *** This bug is a duplicate of bug 1346917 ***
>     https://bugs.launchpad.net/bugs/1346917
>
> Same problem
> I using kernel 3.16.0-55-generic, Ubuntu 14.04
>
> --
> You received this bug notification because you are a member of qemu-
> devel-ml, which is subscribed to QEMU.
> https://bugs.launchpad.net/bugs/1308341
>
> Title:
>   Multiple CPUs causes blue screen on Windows guest (14.04 regression)
>
> Status in QEMU:
>   New
> Status in linux package in Ubuntu:
>   Confirmed
> Status in qemu package in Ubuntu:
>   Confirmed
>
> Bug description:
>   Configuring a Windows 7 guest using more than one CPU cases the guest to
> fail. This happens after a few hours after guest boot. This is the error on
> the blue screen:
>   "A clock interrupt was not received on a secondary processor within the
> allocated time interval"
>
>   After resetting, the guest will never boot and a new bluescreen with
>   the error "STOP: 0x0000005c" appears. Shutting down the guest
>   completely and restarting it will allow it to boot and run for a few
>   hours again.
>
>   The guest was created using virt-manager. The error happens with or
>   without virtio devices and with both 32-bit and 64-bit Windows 7
>   guests.
>
>   I am using Ubuntu 14.04 release candidate.
>
>   qemu-kvm version 2.0.0~rc1+dfsg-0ubuntu3
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1308341/+subscriptions
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 08 Dec 2015 16:42:38 -0700
> From: Alex Williamson <alex.william...@redhat.com>
> To: Peter Maydell <peter.mayd...@linaro.org>
> Cc: Pavel Fedin <p.fe...@samsung.com>, QEMU Developers
>         <qemu-devel@nongnu.org>
> Subject: Re: [Qemu-devel] [PATCH] vfio: Align iova also to IOMMU page
>         size
> Message-ID: <1449618158.15753.439.ca...@redhat.com>
> Content-Type: text/plain; charset="UTF-8"
>
> On Mon, 2015-12-07 at 11:20 +0000, Peter Maydell wrote:
> > On 7 December 2015 at 10:53, Pavel Fedin <p.fe...@samsung.com> wrote:
> > >> TAGET_PAGE_ALIGN tells us that it *could* be a valid DMA target
> though.
> > >> The VM model is capable of using that as a page size, which means we
> > >> assume it is and want to generate a fault.
> > >
> > >  We seem to have looped back. So...
> > >  It is possible to fix this according to this assumption. In this
> > > case we would need to make TARGET_PAGE_BITS a variable. If we are
> > > emulating ancient armv5te, it will be set to 10. For modern targets,
> > > ARMv6 and newer, it will be 12.
> >
> > You can't just make TARGET_PAGE_BITS a variable, it is used as a compile
> > time constant in a bunch of TCG internal stuff. It would be nice
> > if we didn't require it to be compile time, but it would be a lot of
> > work to fix (especially if you want to avoid it being a performance
> > hit).
> >
> > In any case, that still doesn't fix the problem. On an AArch64
> > target CPU, TARGET_PAGE_BITS still has to be 12 (for a 4K
> > minimum page size), but the guest and host could still be using
> > 64K pages. So your VFIO code *must* be able to deal with the
> > situation where TARGET_PAGE_BITS is smaller than any alignment
> > that the guest, host or IOMMU need to care about.
> >
> > I still think the VFIO code needs to figure out what alignment
> > it actually cares about and find some way to determine what
> > that is, or alternatively if the relevant alignment is not
> > possible to determine, write the code so that it doesn't
> > need to care. Either way, TARGET_PAGE_ALIGN is not the answer.
>
> Ok, let's work our way down through the relevant page sizes, host,
> IOMMU, and target.
>
> The host page size is relevant because this is the granularity with
> which the kernel can pin pages.  Every IOMMU mapping must be backed by a
> pinned page in the current model since we don't really have hardware to
> support IOMMU page faults.
>
> The IOMMU page size defines the granularity with which we can map IOVA
> to physical memory.  The IOMMU may support multiple page sizes, but what
> we're really talking about here is the minimum page size.
>
> The target page size is relevant because this defines the minimum
> possible page size used within the VM.  We presume that anything less
> than TARGET_PAGE_ALIGN cannot be referenced as a page by the VM CPU and
> therefore is probably not allocated as a DMA buffer for a driver running
> within the guest.
>
> An implementation detail here is that the vfio type1 IOMMU model
> currently exposes the host page size as the minimum IOMMU page size.
> The reason for this is to simplify page accounting, if we don't allow
> sub-host page mappings we don't need per page reference counting.  This
> can be fixed within the current API, but kernel changes are required or
> else locked page requirements due to over-counting become a problem.
> The benefit though is that this abstracts the host page size from QEMU.
>
> So let's take the easy scenario first, if target page size is greater
> than or equal to the minimum IOMMU page size, we're golden.  We can map
> anything that could be a target DMA buffer.  This leads to the current
> situation that we simply ignore any ranges which disappear when we align
> to the target page size.  It can't be a DMA buffer, ignore it.  Note
> that the 64k host, 4k target problem goes away if type1 accounting is
> fixed to allow IOMMU granularity mapping, since I think in the cases we
> care about the IOMMU still supports 4k pages, otherwise...
>
> Then we come to the scenario here, where target page size is less than
> the minimum IOMMU page size.  The current code is intentionally trying
> to trigger the vfio type1 error that this cannot be mapped.  To resolve
> this, QEMU needs to decide if it's ok to provide the device with DMA
> access to everything on that IOMMU granularity page, ensure that aliases
> mapping the same IOMMU page are consistent and handle the reference
> counting for those sub-mappings to avoid duplicate mappings and
> premature unmaps.
>
> So I think in the end, the one page size we care about is the minimum
> IOMMU granularity.  We don't really care about the target page size at
> all and maybe we only care about the host page size for determining what
> might share a page with a sub-page mapping.  However, there's work to
> get there (QEMU, kernel, or both depending on the specific config) and
> the target page size trick has so far been a useful simplification.
> Thanks,
>
> Alex
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 9 Dec 2015 09:14:20 +0800
> From: TeLeMan <gele...@gmail.com>
> To: Laurent Desnogues <laurent.desnog...@gmail.com>,       TeLeMan
>         <gele...@gmail.com>,     qemu-devel <qemu-devel@nongnu.org>,
> Richard
>         Henderson <r...@twiddle.net>
> Subject: Re: [Qemu-devel] tcg: improve MAX_CODE_GEN_BUFFER_SIZE for
>         arm
> Message-ID:
>         <
> caetrqwmzsjyx+oonv1zq0vxs2u3pf71ibzv0vdr43y_+w08...@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On Tue, Dec 8, 2015 at 7:21 PM, Aurelien Jarno <aurel...@aurel32.net>
> wrote:
> > On 2015-12-08 11:51, Laurent Desnogues wrote:
> >> Hello,
> >>
> >> On Tue, Dec 8, 2015 at 11:39 AM, Aurelien Jarno <aurel...@aurel32.net>
> wrote:
> >> [...]
> >> > I already posted a patch a long time ago to remove the 16MB limit on
> ARM
> >> > hosts:
> >> >
> >> > http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg01684.html
> >> >
> >> > However as you can see in the thread, it has been rejected as it
> doesn't
> >> > not bring improvement in all cases.
> >>
> >> We could perhaps resurrect it and do some more benchmarking?  Who
> >> would be able to do testing on (recent) ARM hardware?
> >
> > I can provide an updated patch, but I would prefer if someone else does
> > the benchmarking on a really recent hardware. Not sure the hardware I
> > have (cortex A7) is really representative of a modern ARM CPU.
>
> ok,I wait your new patch, thanks. I have arm A7 too.
>
> > Aurelien
> >
> > --
> > Aurelien Jarno                          GPG: 4096R/1DDD8C9B
> > aurel...@aurel32.net                 http://www.aurel32.net
>
>
>
> ------------------------------
>
> Message: 5
> Date: Wed,  9 Dec 2015 09:40:40 +0800
> From: "Jianzhong,Chang" <jianzhongx.ch...@intel.com>
> To: qemu-devel@nongnu.org
> Cc: tianyu....@intel.com, konrad.w...@oracle.com,
>         liang.z...@intel.com,       xen-de...@lists.xen.org, "Jianzhong,
>  Chang"
>         <jianzhongx.ch...@intel.com>, pbonz...@redhat.com,
>         stefano.stabell...@eu.citrix.com
> Subject: [Qemu-devel] [PATCH] xen_pt: fix failure of attaching &
>         detaching a     PCI device to VM repeatedly
> Message-ID:
>         <1449625240-6927-1-git-send-email-jianzhongx.ch...@intel.com>
>
> Add pci = [ '$VF_BDF1', '$VF_BDF2', '$VF_BDF3'] in
> hvm guest configuration file. After the guest boot up,
> detach the VFs in sequence by "xl pci-detach $DOMID $VF_BDF",
> reattach the VFs by "xl pci-attach $VF_BDF" in sequence.
> An error message will be reported like this:
> "libxl: error: libxl_qmp.c:287:qmp_handle_error_response: received
> an error message from QMP server: Duplicate ID 'pci-pt-07_10.1' for device"
>
> When xen_pt_region_add/del() is called, MemoryRegion
> may not belong to the XenPCIPassthroughState.
> xen_pt_region_update() checks it but memory_region_ref/unref() does not.
> This case causes obj->ref issue and affects the release of related objects.
> So, memory_region_ref/unref() is moved from
> xen_pt_region_add/del inside xen_pt_region_update.
>
> Signed-off-by: Jianzhong,Chang <jianzhongx.ch...@intel.com>
> ---
>  hw/xen/xen_pt.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
> index aa96288..45d4d6c 100644
> --- a/hw/xen/xen_pt.c
> +++ b/hw/xen/xen_pt.c
> @@ -590,7 +590,11 @@ static void
> xen_pt_region_update(XenPCIPassthroughState *s,
>      if (bar == -1 && (!s->msix || &s->msix->mmio != mr)) {
>          return;
>      }
> -
> +    if (adding) {
> +        memory_region_ref(mr);
> +    } else {
> +        memory_region_unref(mr);
> +    }
>      if (s->msix && &s->msix->mmio == mr) {
>          if (adding) {
>              s->msix->mmio_base_addr = sec->offset_within_address_space;
> @@ -642,7 +646,6 @@ static void xen_pt_region_add(MemoryListener *l,
> MemoryRegionSection *sec)
>      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
>                                               memory_listener);
>
> -    memory_region_ref(sec->mr);
>      xen_pt_region_update(s, sec, true);
>  }
>
> @@ -652,7 +655,6 @@ static void xen_pt_region_del(MemoryListener *l,
> MemoryRegionSection *sec)
>                                               memory_listener);
>
>      xen_pt_region_update(s, sec, false);
> -    memory_region_unref(sec->mr);
>  }
>
>  static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection
> *sec)
> @@ -660,7 +662,6 @@ static void xen_pt_io_region_add(MemoryListener *l,
> MemoryRegionSection *sec)
>      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
>                                               io_listener);
>
> -    memory_region_ref(sec->mr);
>      xen_pt_region_update(s, sec, true);
>  }
>
> @@ -670,7 +671,6 @@ static void xen_pt_io_region_del(MemoryListener *l,
> MemoryRegionSection *sec)
>                                               io_listener);
>
>      xen_pt_region_update(s, sec, false);
> -    memory_region_unref(sec->mr);
>  }
>
>  static const MemoryListener xen_pt_memory_listener = {
> --
> 1.7.1
>
>
>
>
> ------------------------------
>
> Message: 6
> Date: Wed, 9 Dec 2015 10:37:16 +0800
> From: Stefan Hajnoczi <stefa...@redhat.com>
> To: Peter Maydell <peter.mayd...@linaro.org>
> Cc: Kevin Wolf <kw...@redhat.com>, Fam Zheng <f...@redhat.com>,
>         Qemu-block <qemu-bl...@nongnu.org>,  QEMU Developers
>         <qemu-devel@nongnu.org>,     Cornelia Huck <
> cornelia.h...@de.ibm.com>,
>         Paolo Bonzini <pbonz...@redhat.com>
> Subject: Re: [Qemu-devel] [PATCH] virtio-blk: Drop x-data-plane option
> Message-ID: <20151209023716.GA22280@stefanha-x1.localdomain>
> Content-Type: text/plain; charset="us-ascii"
>
> On Mon, Dec 07, 2015 at 05:10:26PM +0000, Peter Maydell wrote:
> > On 7 December 2015 at 15:19, Paolo Bonzini <pbonz...@redhat.com> wrote:
> > >
> > >
> > > On 07/12/2015 14:02, Fam Zheng wrote:
> > >> On Mon, 12/07 12:29, Cornelia Huck wrote:
> > >>> On Mon,  7 Dec 2015 18:59:27 +0800
> > >>> Fam Zheng <f...@redhat.com> wrote:
> > >>>
> > >>>> The official way of enabling dataplane is through the "iothread"
> > >>>> property that references an iothread object created by "-object
> > >>>> iothread".  Since the old "x-data-plane=on" way now even crashes,
> it's
> > >>>> probably easier to just drop it:
> > >>>>
> > >>>> $ qemu-system-x86_64 -drive file=null-co://,id=d0,if=none \
> > >>>>     -device virtio-blk-pci,drive=d0,x-data-plane=on
> > >>>>
> > >>>> ERROR:/home/fam/work/qemu/qom/object.c:1515:
> > >>>> object_get_canonical_path_component: assertion failed: (obj->parent
> != NULL)
> > >>>> Aborted
> > >>>
> > >>> Do we understand yet why this crashes, btw?
> > >>
> > >> I think it's because with x-data-plane=on, virtio-blk initialize an
> object that
> > >> doesn't have a parent, therefore it doesn't have a valid "canonical
> path
> > >> component" thing, which is different from objects created with
> "-object" CLI.
> > >> I'm not very familiar with the QOM semantics here.
> > >>
> > >>>
> > >>>>
> > >>>> Signed-off-by: Fam Zheng <f...@redhat.com>
> > >>>> ---
> > >>>>  hw/block/dataplane/virtio-blk.c | 15 ++-------------
> > >>>>  hw/block/virtio-blk.c           |  1 -
> > >>>>  include/hw/virtio/virtio-blk.h  |  1 -
> > >>>>  3 files changed, 2 insertions(+), 15 deletions(-)
> > >>>>
> > >>>
> > >>> No general objection to removing x-data-plane; but this probably
> wants
> > >>> a mention on the changelog as x-data-plane has been described in
> > >>> various howtos etc. over the years.
> > >>
> > >> Yes, that is a good point.  I don't know if it's too rushing in
> removing it for
> > >> 2.5 (this is just posted as one option) and we'll have to count on
> QOM experts
> > >> for the fix, if it is.
> > >
> > > The solution would be to add object_property_add_child to
> > > virtio_blk_data_plane_create, between object_initialize and
> > > user_creatable_complete.  But I think this patch is ok for 2.5.
> >
> > Paolo asked me to apply this to master, so I have done so.
>
> Okay.  I will do my best to communicate that x-data-plane is gone.
>
> Stefan
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 473 bytes
> Desc: not available
> URL: <
> http://lists.nongnu.org/archive/html/qemu-devel/attachments/20151209/f4b34564/attachment.pgp
> >
>
> ------------------------------
>
> Message: 7
> Date: Wed,  9 Dec 2015 10:42:12 +0800
> From: Peter Xu <pet...@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: drjo...@redhat.com, ler...@redhat.com, arm...@redhat.com,
>         pet...@redhat.com,       lcapitul...@redhat.com, f...@redhat.com,
>         pbonz...@redhat.com
> Subject: [Qemu-devel] [PATCH v6 00/11] Add basic "detach" support for
>         dump-guest-memory
> Message-ID: <1449628943-10197-1-git-send-email-pet...@redhat.com>
>
> v6 changes:
> - patch 10
>   - English error fix [Fam]
> - patch 11
>   - remove useless var: "not_used" [me]
> - all
>   - move patch 8 to the end to be patch 11 (v5 patches 9-11 become
>   v6 patches 8-10) [Eric]
>
> v5 changes:
> - patch 1
>   - comment English fix [Fam]
> - patch 2
>   - pass has_detach=true always in hmp_dump_guest_memory [Paolo]
> - patch 3
>   - always use local_err and error_propagate() when need to check
>     the result [Fam]
> - patch 8
>   - add "DumpQueryResult" in DUMP_COMPLETED event [Eric]
>     (since DumpQueryResult is introduced in patch 10, so doing it in
>     patch 10 for convenience. Please let me know if I should not do
>     this, e.g., if patch re-ordering is required)
>
> v4 changes:
> - patch 2:
>   - hmp: fix default value lost [Eric]
>   - English errors [Eric]
> - patch 3:
>   - use global DumpState, leverage C99 struct init [Paolo]
>   - English errors [Eric]
> - patch 5:
>   - more cleanup for dump_process [Paolo]
> - patch 8:
>   - make sure qmp-events.txt is sorted [Eric]
>   - enhance error_get_pretty() [Eric]
>   - emit DUMP_COMPLETED no matter detach or not
> - patch 10:
>   - use g_new0 to replace g_malloc0 [Eric]
>   - rename "written_bytes" to "completed", "total_bytes" to "total"
>     [Eric]
>   - use atomic ops and [rw]mb to protect status read/write [Paolo]
> - patch 12:
>   - English errors [Eric]
>   - merge contents into older patches [Eric]
>
> v3 changes (patch number corresponds to v2 patch set):
> - patch 1
>   - fix commit message. no memory leak, only code cleanup [Fam]
> - patch 2
>   - better documentation for "dump-guest-memory" (new patch 9) [Fam]
> - patch 3
>   - remove rcu lock/unlock in dump_init() [Fam, Paolo]
>   - embed mr pointer into GuestPhysBlock [Paolo]
>   - remove global dump state [Paolo]
> - patch 4
>   - fix memory leak for error [Fam]
>   - evt DUMP_COMPLETED data: change to an optional "*error" [Paolo]
> - patch 5
>   - fix documents [Fam]
>   - change "dump-query" to "query-dump", HMP to "info dump" [Paolo]
> - patch 6
>   - for query-dump command: define enum for DumpStatus, use "int"
>     for written/total [Paolo]
> - all
>   - reorder the commits as suggested, no fake values [Paolo]
>   - split big commit into smaller ones [me]
>
> v2 changes:
> - fixed English errors [Drew]
> - reordered the "detach" field, first make it optional, then make sure
>   it's order is consistent [Drew, Fam]
> - added doc for new detach flag [Eric]
> - collected error msg even detached [Drew]
> - added qmp event DUMP_COMPLETED to notify user [Eric, Fam]
> - added "dump-query" QMP & HMP commands to query dump status [Eric]
> - "stop" is not allowed when dump in background (also include
>   "cont" and "dump-guest-memory") [Fam]
> - added codes to calculate how many dump work finished, which could
>   be queried from "dump-query" [Laszlo]
> - added list to track all used MemoryRegion objects, also ref before
>   use [Paolo]
> - dump-guest-memory will be forbidden during incoming migrate [Paolo]
> - taking rcu lock when collecting memory info [Paolo]
>
> Test Done:
> - QMP & HMP
>   - test default dump (sync), work as usual
>   - test detached dump, command return immediately.
>   - When dump finished, will receive event DUMP_COMPLETED.
>   - test query-dump before/during/after dump
>   - test kdump with zlib compression, w/ and w/o detach
> - libvirt
>   - test "virsh dump --memory-only" with default format and
>     kdump-zlib format, work as usual
>
> Peter Xu (11):
>   dump-guest-memory: cleanup: removing dump_{error|cleanup}().
>   dump-guest-memory: add "detach" flag for QMP/HMP interfaces.
>   dump-guest-memory: using static DumpState, add DumpStatus
>   dump-guest-memory: add dump_in_progress() helper function
>   dump-guest-memory: introduce dump_process() helper function.
>   dump-guest-memory: disable dump when in INMIGRATE state
>   dump-guest-memory: add "detach" support
>   DumpState: adding total_size and written_size fields
>   Dump: add qmp command "query-dump"
>   Dump: add hmp command "info dump"
>   dump-guest-memory: add qmp event DUMP_COMPLETED
>
>  docs/qmp-events.txt             |  18 ++++
>  dump.c                          | 215
> ++++++++++++++++++++++++++++++----------
>  hmp-commands-info.hx            |  14 +++
>  hmp-commands.hx                 |   5 +-
>  hmp.c                           |  26 ++++-
>  hmp.h                           |   1 +
>  include/qemu-common.h           |   4 +
>  include/sysemu/dump.h           |  15 +++
>  include/sysemu/memory_mapping.h |   4 +
>  memory_mapping.c                |   3 +
>  qapi-schema.json                |  56 ++++++++++-
>  qapi/event.json                 |  16 +++
>  qmp-commands.hx                 |  31 +++++-
>  qmp.c                           |  14 +++
>  14 files changed, 359 insertions(+), 63 deletions(-)
>
> --
> 2.4.3
>
>
>
>
> ------------------------------
>
> Message: 8
> Date: Wed,  9 Dec 2015 10:42:13 +0800
> From: Peter Xu <pet...@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: drjo...@redhat.com, ler...@redhat.com, arm...@redhat.com,
>         pet...@redhat.com,       lcapitul...@redhat.com, f...@redhat.com,
>         pbonz...@redhat.com
> Subject: [Qemu-devel] [PATCH v6 01/11] dump-guest-memory: cleanup:
>         removing        dump_{error|cleanup}().
> Message-ID: <1449628943-10197-2-git-send-email-pet...@redhat.com>
>
> It might be a little bit confusing and error prone to do
> dump_cleanup() in these two functions. A better way is to do
> dump_cleanup() before dump finish, no matter whether dump has
> succeeded or not.
>
> Signed-off-by: Peter Xu <pet...@redhat.com>
> Reviewed-by: Fam Zheng <f...@redhat.com>
> ---
>  dump.c | 78
> +++++++++++++++++++++++++++---------------------------------------
>  1 file changed, 32 insertions(+), 46 deletions(-)
>
> diff --git a/dump.c b/dump.c
> index 78b7d84..445e739 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -82,12 +82,6 @@ static int dump_cleanup(DumpState *s)
>      return 0;
>  }
>
> -static void dump_error(DumpState *s, const char *reason, Error **errp)
> -{
> -    dump_cleanup(s);
> -    error_setg(errp, "%s", reason);
> -}
> -
>  static int fd_write_vmcore(const void *buf, size_t size, void *opaque)
>  {
>      DumpState *s = opaque;
> @@ -128,7 +122,7 @@ static void write_elf64_header(DumpState *s, Error
> **errp)
>
>      ret = fd_write_vmcore(&elf_header, sizeof(elf_header), s);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write elf header", errp);
> +        error_setg(errp, "dump: failed to write elf header");
>      }
>  }
>
> @@ -159,7 +153,7 @@ static void write_elf32_header(DumpState *s, Error
> **errp)
>
>      ret = fd_write_vmcore(&elf_header, sizeof(elf_header), s);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write elf header", errp);
> +        error_setg(errp, "dump: failed to write elf header");
>      }
>  }
>
> @@ -182,7 +176,7 @@ static void write_elf64_load(DumpState *s,
> MemoryMapping *memory_mapping,
>
>      ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write program header table", errp);
> +        error_setg(errp, "dump: failed to write program header table");
>      }
>  }
>
> @@ -205,7 +199,7 @@ static void write_elf32_load(DumpState *s,
> MemoryMapping *memory_mapping,
>
>      ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write program header table", errp);
> +        error_setg(errp, "dump: failed to write program header table");
>      }
>  }
>
> @@ -225,7 +219,7 @@ static void write_elf64_note(DumpState *s, Error
> **errp)
>
>      ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write program header table", errp);
> +        error_setg(errp, "dump: failed to write program header table");
>      }
>  }
>
> @@ -245,7 +239,7 @@ static void write_elf64_notes(WriteCoreDumpFunction f,
> DumpState *s,
>          id = cpu_index(cpu);
>          ret = cpu_write_elf64_note(f, cpu, id, s);
>          if (ret < 0) {
> -            dump_error(s, "dump: failed to write elf notes", errp);
> +            error_setg(errp, "dump: failed to write elf notes");
>              return;
>          }
>      }
> @@ -253,7 +247,7 @@ static void write_elf64_notes(WriteCoreDumpFunction f,
> DumpState *s,
>      CPU_FOREACH(cpu) {
>          ret = cpu_write_elf64_qemunote(f, cpu, s);
>          if (ret < 0) {
> -            dump_error(s, "dump: failed to write CPU status", errp);
> +            error_setg(errp, "dump: failed to write CPU status");
>              return;
>          }
>      }
> @@ -275,7 +269,7 @@ static void write_elf32_note(DumpState *s, Error
> **errp)
>
>      ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write program header table", errp);
> +        error_setg(errp, "dump: failed to write program header table");
>      }
>  }
>
> @@ -290,7 +284,7 @@ static void write_elf32_notes(WriteCoreDumpFunction f,
> DumpState *s,
>          id = cpu_index(cpu);
>          ret = cpu_write_elf32_note(f, cpu, id, s);
>          if (ret < 0) {
> -            dump_error(s, "dump: failed to write elf notes", errp);
> +            error_setg(errp, "dump: failed to write elf notes");
>              return;
>          }
>      }
> @@ -298,7 +292,7 @@ static void write_elf32_notes(WriteCoreDumpFunction f,
> DumpState *s,
>      CPU_FOREACH(cpu) {
>          ret = cpu_write_elf32_qemunote(f, cpu, s);
>          if (ret < 0) {
> -            dump_error(s, "dump: failed to write CPU status", errp);
> +            error_setg(errp, "dump: failed to write CPU status");
>              return;
>          }
>      }
> @@ -326,7 +320,7 @@ static void write_elf_section(DumpState *s, int type,
> Error **errp)
>
>      ret = fd_write_vmcore(&shdr, shdr_size, s);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write section header table", errp);
> +        error_setg(errp, "dump: failed to write section header table");
>      }
>  }
>
> @@ -336,7 +330,7 @@ static void write_data(DumpState *s, void *buf, int
> length, Error **errp)
>
>      ret = fd_write_vmcore(buf, length, s);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to save memory", errp);
> +        error_setg(errp, "dump: failed to save memory");
>      }
>  }
>
> @@ -568,11 +562,6 @@ static void dump_begin(DumpState *s, Error **errp)
>      }
>  }
>
> -static void dump_completed(DumpState *s)
> -{
> -    dump_cleanup(s);
> -}
> -
>  static int get_next_block(DumpState *s, GuestPhysBlock *block)
>  {
>      while (1) {
> @@ -624,8 +613,6 @@ static void dump_iterate(DumpState *s, Error **errp)
>          }
>
>      } while (!get_next_block(s, block));
> -
> -    dump_completed(s);
>  }
>
>  static void create_vmcore(DumpState *s, Error **errp)
> @@ -765,7 +752,7 @@ static void create_header32(DumpState *s, Error **errp)
>      dh->status = cpu_to_dump32(s, status);
>
>      if (write_buffer(s->fd, 0, dh, size) < 0) {
> -        dump_error(s, "dump: failed to write disk dump header", errp);
> +        error_setg(errp, "dump: failed to write disk dump header");
>          goto out;
>      }
>
> @@ -784,7 +771,7 @@ static void create_header32(DumpState *s, Error **errp)
>
>      if (write_buffer(s->fd, DISKDUMP_HEADER_BLOCKS *
>                       block_size, kh, size) < 0) {
> -        dump_error(s, "dump: failed to write kdump sub header", errp);
> +        error_setg(errp, "dump: failed to write kdump sub header");
>          goto out;
>      }
>
> @@ -800,7 +787,7 @@ static void create_header32(DumpState *s, Error **errp)
>      }
>      if (write_buffer(s->fd, offset_note, s->note_buf,
>                       s->note_size) < 0) {
> -        dump_error(s, "dump: failed to write notes", errp);
> +        error_setg(errp, "dump: failed to write notes");
>          goto out;
>      }
>
> @@ -865,7 +852,7 @@ static void create_header64(DumpState *s, Error **errp)
>      dh->status = cpu_to_dump32(s, status);
>
>      if (write_buffer(s->fd, 0, dh, size) < 0) {
> -        dump_error(s, "dump: failed to write disk dump header", errp);
> +        error_setg(errp, "dump: failed to write disk dump header");
>          goto out;
>      }
>
> @@ -884,7 +871,7 @@ static void create_header64(DumpState *s, Error **errp)
>
>      if (write_buffer(s->fd, DISKDUMP_HEADER_BLOCKS *
>                       block_size, kh, size) < 0) {
> -        dump_error(s, "dump: failed to write kdump sub header", errp);
> +        error_setg(errp, "dump: failed to write kdump sub header");
>          goto out;
>      }
>
> @@ -901,7 +888,7 @@ static void create_header64(DumpState *s, Error **errp)
>
>      if (write_buffer(s->fd, offset_note, s->note_buf,
>                       s->note_size) < 0) {
> -        dump_error(s, "dump: failed to write notes", errp);
> +        error_setg(errp, "dump: failed to write notes");
>          goto out;
>      }
>
> @@ -1064,7 +1051,7 @@ static void write_dump_bitmap(DumpState *s, Error
> **errp)
>      while (get_next_page(&block_iter, &pfn, NULL, s)) {
>          ret = set_dump_bitmap(last_pfn, pfn, true, dump_bitmap_buf, s);
>          if (ret < 0) {
> -            dump_error(s, "dump: failed to set dump_bitmap", errp);
> +            error_setg(errp, "dump: failed to set dump_bitmap");
>              goto out;
>          }
>
> @@ -1081,7 +1068,7 @@ static void write_dump_bitmap(DumpState *s, Error
> **errp)
>          ret = set_dump_bitmap(last_pfn, last_pfn + PFN_BUFBITMAP, false,
>                                dump_bitmap_buf, s);
>          if (ret < 0) {
> -            dump_error(s, "dump: failed to sync dump_bitmap", errp);
> +            error_setg(errp, "dump: failed to sync dump_bitmap");
>              goto out;
>          }
>      }
> @@ -1214,7 +1201,7 @@ static void write_dump_pages(DumpState *s, Error
> **errp)
>      ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
>      g_free(buf);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write page data (zero page)",
> errp);
> +        error_setg(errp, "dump: failed to write page data (zero page)");
>          goto out;
>      }
>
> @@ -1230,7 +1217,7 @@ static void write_dump_pages(DumpState *s, Error
> **errp)
>              ret = write_cache(&page_desc, &pd_zero,
> sizeof(PageDescriptor),
>                                false);
>              if (ret < 0) {
> -                dump_error(s, "dump: failed to write page desc", errp);
> +                error_setg(errp, "dump: failed to write page desc");
>                  goto out;
>              }
>          } else {
> @@ -1255,7 +1242,7 @@ static void write_dump_pages(DumpState *s, Error
> **errp)
>
>                  ret = write_cache(&page_data, buf_out, size_out, false);
>                  if (ret < 0) {
> -                    dump_error(s, "dump: failed to write page data",
> errp);
> +                    error_setg(errp, "dump: failed to write page data");
>                      goto out;
>                  }
>  #ifdef CONFIG_LZO
> @@ -1268,7 +1255,7 @@ static void write_dump_pages(DumpState *s, Error
> **errp)
>
>                  ret = write_cache(&page_data, buf_out, size_out, false);
>                  if (ret < 0) {
> -                    dump_error(s, "dump: failed to write page data",
> errp);
> +                    error_setg(errp, "dump: failed to write page data");
>                      goto out;
>                  }
>  #endif
> @@ -1282,7 +1269,7 @@ static void write_dump_pages(DumpState *s, Error
> **errp)
>
>                  ret = write_cache(&page_data, buf_out, size_out, false);
>                  if (ret < 0) {
> -                    dump_error(s, "dump: failed to write page data",
> errp);
> +                    error_setg(errp, "dump: failed to write page data");
>                      goto out;
>                  }
>  #endif
> @@ -1297,7 +1284,7 @@ static void write_dump_pages(DumpState *s, Error
> **errp)
>
>                  ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE,
> false);
>                  if (ret < 0) {
> -                    dump_error(s, "dump: failed to write page data",
> errp);
> +                    error_setg(errp, "dump: failed to write page data");
>                      goto out;
>                  }
>              }
> @@ -1309,7 +1296,7 @@ static void write_dump_pages(DumpState *s, Error
> **errp)
>
>              ret = write_cache(&page_desc, &pd, sizeof(PageDescriptor),
> false);
>              if (ret < 0) {
> -                dump_error(s, "dump: failed to write page desc", errp);
> +                error_setg(errp, "dump: failed to write page desc");
>                  goto out;
>              }
>          }
> @@ -1317,12 +1304,12 @@ static void write_dump_pages(DumpState *s, Error
> **errp)
>
>      ret = write_cache(&page_desc, NULL, 0, true);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to sync cache for page_desc", errp);
> +        error_setg(errp, "dump: failed to sync cache for page_desc");
>          goto out;
>      }
>      ret = write_cache(&page_data, NULL, 0, true);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to sync cache for page_data", errp);
> +        error_setg(errp, "dump: failed to sync cache for page_data");
>          goto out;
>      }
>
> @@ -1366,7 +1353,7 @@ static void create_kdump_vmcore(DumpState *s, Error
> **errp)
>
>      ret = write_start_flat_header(s->fd);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write start flat header", errp);
> +        error_setg(errp, "dump: failed to write start flat header");
>          return;
>      }
>
> @@ -1390,11 +1377,9 @@ static void create_kdump_vmcore(DumpState *s, Error
> **errp)
>
>      ret = write_end_flat_header(s->fd);
>      if (ret < 0) {
> -        dump_error(s, "dump: failed to write end flat header", errp);
> +        error_setg(errp, "dump: failed to write end flat header");
>          return;
>      }
> -
> -    dump_completed(s);
>  }
>
>  static ram_addr_t get_start_block(DumpState *s)
> @@ -1677,6 +1662,7 @@ void qmp_dump_guest_memory(bool paging, const char
> *file, bool has_begin,
>          create_vmcore(s, errp);
>      }
>
> +    dump_cleanup(s);
>      g_free(s);
>  }
>
> --
> 2.4.3
>
>
>
>
> ------------------------------
>
> Message: 9
> Date: Wed,  9 Dec 2015 10:42:14 +0800
> From: Peter Xu <pet...@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: drjo...@redhat.com, ler...@redhat.com, arm...@redhat.com,
>         pet...@redhat.com,       lcapitul...@redhat.com, f...@redhat.com,
>         pbonz...@redhat.com
> Subject: [Qemu-devel] [PATCH v6 02/11] dump-guest-memory: add "detach"
>         flag    for QMP/HMP interfaces.
> Message-ID: <1449628943-10197-3-git-send-email-pet...@redhat.com>
>
> This patch only adds the interfaces, but does not implement them.
> "detach" parameter is made optional, to make sure that all the old
> dump-guest-memory requests will still be able to work.
>
> Signed-off-by: Peter Xu <pet...@redhat.com>
> Reviewed-by: Fam Zheng <f...@redhat.com>
> ---
>  dump.c           | 5 +++--
>  hmp-commands.hx  | 5 +++--
>  hmp.c            | 9 +++++++--
>  qapi-schema.json | 8 ++++++--
>  qmp-commands.hx  | 6 ++++--
>  5 files changed, 23 insertions(+), 10 deletions(-)
>
> diff --git a/dump.c b/dump.c
> index 445e739..d79e0ed 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -1580,8 +1580,9 @@ cleanup:
>      dump_cleanup(s);
>  }
>
> -void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
> -                           int64_t begin, bool has_length,
> +void qmp_dump_guest_memory(bool paging, const char *file,
> +                           bool has_detach, bool detach,
> +                           bool has_begin, int64_t begin, bool has_length,
>                             int64_t length, bool has_format,
>                             DumpGuestMemoryFormat format, Error **errp)
>  {
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index bb52e4d..664d794 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1056,10 +1056,11 @@ ETEXI
>
>      {
>          .name       = "dump-guest-memory",
> -        .args_type  =
> "paging:-p,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?",
> -        .params     = "[-p] [-z|-l|-s] filename [begin length]",
> +        .args_type  =
> "paging:-p,detach:-d,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?",
> +        .params     = "[-p] [-d] [-z|-l|-s] filename [begin length]",
>          .help       = "dump guest memory into file 'filename'.\n\t\t\t"
>                        "-p: do paging to get guest's memory
> mapping.\n\t\t\t"
> +                      "-d: return immediately (do not wait for
> completion).\n\t\t\t"
>                        "-z: dump in kdump-compressed format, with zlib
> compression.\n\t\t\t"
>                        "-l: dump in kdump-compressed format, with lzo
> compression.\n\t\t\t"
>                        "-s: dump in kdump-compressed format, with snappy
> compression.\n\t\t\t"
> diff --git a/hmp.c b/hmp.c
> index 2140605..1f4d0b6 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -1586,8 +1586,10 @@ void hmp_dump_guest_memory(Monitor *mon, const
> QDict *qdict)
>      const char *file = qdict_get_str(qdict, "filename");
>      bool has_begin = qdict_haskey(qdict, "begin");
>      bool has_length = qdict_haskey(qdict, "length");
> +    bool has_detach = qdict_haskey(qdict, "detach");
>      int64_t begin = 0;
>      int64_t length = 0;
> +    bool detach = false;
>      enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
>      char *prot;
>
> @@ -1615,11 +1617,14 @@ void hmp_dump_guest_memory(Monitor *mon, const
> QDict *qdict)
>      if (has_length) {
>          length = qdict_get_int(qdict, "length");
>      }
> +    if (has_detach) {
> +        detach = qdict_get_bool(qdict, "detach");
> +    }
>
>      prot = g_strconcat("file:", file, NULL);
>
> -    qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length,
> length,
> -                          true, dump_format, &err);
> +    qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin,
> +                          has_length, length, true, dump_format, &err);
>      hmp_handle_error(mon, &err);
>      g_free(prot);
>  }
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 8b1a423..97c3ac4 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -2115,6 +2115,9 @@
>  #            2. fd: the protocol starts with "fd:", and the following
> string
>  #               is the fd's name.
>  #
> +# @detach: #optional if true, QMP will return immediately rather than
> +#          waiting for the dump to finish. (since 2.6).
> +#
>  # @begin: #optional if specified, the starting physical address.
>  #
>  # @length: #optional if specified, the memory size, in bytes. If you don't
> @@ -2131,8 +2134,9 @@
>  # Since: 1.2
>  ##
>  { 'command': 'dump-guest-memory',
> -  'data': { 'paging': 'bool', 'protocol': 'str', '*begin': 'int',
> -            '*length': 'int', '*format': 'DumpGuestMemoryFormat' } }
> +  'data': { 'paging': 'bool', 'protocol': 'str', '*detach': 'bool',
> +            '*begin': 'int', '*length': 'int',
> +            '*format': 'DumpGuestMemoryFormat'} }
>
>  ##
>  # @DumpGuestMemoryCapability:
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 9d8b42f..6b51585 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -840,8 +840,8 @@ EQMP
>
>      {
>          .name       = "dump-guest-memory",
> -        .args_type  = "paging:b,protocol:s,begin:i?,end:i?,format:s?",
> -        .params     = "-p protocol [begin] [length] [format]",
> +        .args_type  =
> "paging:b,protocol:s,detach:b?,begin:i?,end:i?,format:s?",
> +        .params     = "-p protocol [-d] [begin] [length] [format]",
>          .help       = "dump guest memory to file",
>          .mhandler.cmd_new = qmp_marshal_dump_guest_memory,
>      },
> @@ -857,6 +857,8 @@ Arguments:
>  - "paging": do paging to get guest's memory mapping (json-bool)
>  - "protocol": destination file(started with "file:") or destination file
>                descriptor (started with "fd:") (json-string)
> +- "detach": if specified, command will return immediately, without waiting
> +            for the dump to finish (json-bool)
>  - "begin": the starting physical address. It's optional, and should be
> specified
>             with length together (json-int)
>  - "length": the memory size, in bytes. It's optional, and should be
> specified
> --
> 2.4.3
>
>
>
>
> ------------------------------
>
> Message: 10
> Date: Wed,  9 Dec 2015 10:42:15 +0800
> From: Peter Xu <pet...@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: drjo...@redhat.com, ler...@redhat.com, arm...@redhat.com,
>         pet...@redhat.com,       lcapitul...@redhat.com, f...@redhat.com,
>         pbonz...@redhat.com
> Subject: [Qemu-devel] [PATCH v6 03/11] dump-guest-memory: using static
>         DumpState, add DumpStatus
> Message-ID: <1449628943-10197-4-git-send-email-pet...@redhat.com>
>
> Instead of malloc/free each time for DumpState, make it
> static. Added DumpStatus to show status for dump.
>
> This is to be used for detached dump.
>
> Signed-off-by: Peter Xu <pet...@redhat.com>
> Reviewed-by: Fam Zheng <f...@redhat.com>
> ---
>  dump.c                | 21 ++++++++++++++++-----
>  include/sysemu/dump.h |  2 ++
>  qapi-schema.json      | 18 ++++++++++++++++++
>  3 files changed, 36 insertions(+), 5 deletions(-)
>
> diff --git a/dump.c b/dump.c
> index d79e0ed..b48cec2 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -1418,6 +1418,14 @@ static void get_max_mapnr(DumpState *s)
>      s->max_mapnr = paddr_to_pfn(last_block->target_end);
>  }
>
> +static DumpState dump_state_global = { .status = DUMP_STATUS_NONE };
> +
> +static void dump_state_prepare(DumpState *s)
> +{
> +    /* zero the struct, setting status to active */
> +    *s = (DumpState) { .status = DUMP_STATUS_ACTIVE };
> +}
> +
>  static void dump_init(DumpState *s, int fd, bool has_format,
>                        DumpGuestMemoryFormat format, bool paging, bool
> has_filter,
>                        int64_t begin, int64_t length, Error **errp)
> @@ -1647,24 +1655,27 @@ void qmp_dump_guest_memory(bool paging, const char
> *file,
>          return;
>      }
>
> -    s = g_malloc0(sizeof(DumpState));
> +    s = &dump_state_global;
> +    dump_state_prepare(s);
>
>      dump_init(s, fd, has_format, format, paging, has_begin,
>                begin, length, &local_err);
>      if (local_err) {
> -        g_free(s);
>          error_propagate(errp, local_err);
> +        s->status = DUMP_STATUS_FAILED;
>          return;
>      }
>
>      if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
> -        create_kdump_vmcore(s, errp);
> +        create_kdump_vmcore(s, &local_err);
>      } else {
> -        create_vmcore(s, errp);
> +        create_vmcore(s, &local_err);
>      }
>
> +    s->status = (local_err ? DUMP_STATUS_FAILED : DUMP_STATUS_COMPLETED);
> +    error_propagate(errp, local_err);
> +
>      dump_cleanup(s);
> -    g_free(s);
>  }
>
>  DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error
> **errp)
> diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
> index 7e4ec5c..affef38 100644
> --- a/include/sysemu/dump.h
> +++ b/include/sysemu/dump.h
> @@ -45,6 +45,7 @@
>
>  #include "sysemu/dump-arch.h"
>  #include "sysemu/memory_mapping.h"
> +#include "qapi-types.h"
>
>  typedef struct QEMU_PACKED MakedumpfileHeader {
>      char signature[16];     /* = "makedumpfile" */
> @@ -183,6 +184,7 @@ typedef struct DumpState {
>      off_t offset_page;          /* offset of page part in vmcore */
>      size_t num_dumpable;        /* number of page that can be dumped */
>      uint32_t flag_compress;     /* indicate the compression format */
> +    DumpStatus status;          /* current dump status */
>  } DumpState;
>
>  uint16_t cpu_to_dump16(DumpState *s, uint16_t val);
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 97c3ac4..691a130 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -2139,6 +2139,24 @@
>              '*format': 'DumpGuestMemoryFormat'} }
>
>  ##
> +# @DumpStatus
> +#
> +# Describe the status of a long-running background guest memory dump.
> +#
> +# @none: no dump-guest-memory has started yet.
> +#
> +# @active: there is one dump running in background.
> +#
> +# @completed: the last dump has finished successfully.
> +#
> +# @failed: the last dump has failed.
> +#
> +# Since 2.6
> +##
> +{ 'enum': 'DumpStatus',
> +  'data': [ 'none', 'active', 'completed', 'failed' ] }
> +
> +##
>  # @DumpGuestMemoryCapability:
>  #
>  # A list of the available formats for dump-guest-memory
> --
> 2.4.3
>
>
>
>
> ------------------------------
>
> Message: 11
> Date: Wed,  9 Dec 2015 10:42:16 +0800
> From: Peter Xu <pet...@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: drjo...@redhat.com, ler...@redhat.com, arm...@redhat.com,
>         pet...@redhat.com,       lcapitul...@redhat.com, f...@redhat.com,
>         pbonz...@redhat.com
> Subject: [Qemu-devel] [PATCH v6 04/11] dump-guest-memory: add
>         dump_in_progress() helper function
> Message-ID: <1449628943-10197-5-git-send-email-pet...@redhat.com>
>
> For now, it has no effect. It will be used in dump detach support.
>
> Signed-off-by: Peter Xu <pet...@redhat.com>
> Reviewed-by: Fam Zheng <f...@redhat.com>
> ---
>  dump.c                | 13 +++++++++++++
>  include/qemu-common.h |  4 ++++
>  qmp.c                 | 14 ++++++++++++++
>  3 files changed, 31 insertions(+)
>
> diff --git a/dump.c b/dump.c
> index b48cec2..ccd56c8 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -1426,6 +1426,12 @@ static void dump_state_prepare(DumpState *s)
>      *s = (DumpState) { .status = DUMP_STATUS_ACTIVE };
>  }
>
> +bool dump_in_progress(void)
> +{
> +    DumpState *state = &dump_state_global;
> +    return (state->status == DUMP_STATUS_ACTIVE);
> +}
> +
>  static void dump_init(DumpState *s, int fd, bool has_format,
>                        DumpGuestMemoryFormat format, bool paging, bool
> has_filter,
>                        int64_t begin, int64_t length, Error **errp)
> @@ -1599,6 +1605,13 @@ void

Reply via email to