[Qemu-devel] [PATCH] dump: do not dump non-existent guest memory

Cornelia Huck posted 1 patch 6 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170911132627.9505-1-cohuck@redhat.com
Test checkpatch passed
Test docker passed
Test s390x passed
dump.c | 6 ++++++
1 file changed, 6 insertions(+)
[Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Cornelia Huck 6 years, 7 months ago
It does not really make sense to dump memory that is not there.

Moreover, that fixes a segmentation fault when calling dump-guest-memory
with no filter for a machine with no memory defined.

New behaviour is:

(qemu) dump-guest-memory /dev/null
dump: no guest memory to dump
(qemu) dump-guest-memory /dev/null 0 4096
dump: no guest memory to dump

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---

Another unmaintained file. Joy. cc:ing some more-or-less random folks.

---
 dump.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dump.c b/dump.c
index a79773d0f7..d2093e141b 100644
--- a/dump.c
+++ b/dump.c
@@ -1536,6 +1536,12 @@ static void dump_init(DumpState *s, int fd, bool has_format,
     fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size);
 #endif
 
+    /* it does not make sense to dump non-existent memory */
+    if (!s->total_size) {
+        error_setg(errp, "dump: no guest memory to dump");
+        goto cleanup;
+    }
+
     s->start = get_start_block(s);
     if (s->start == -1) {
         error_setg(errp, QERR_INVALID_PARAMETER, "begin");
-- 
2.13.5


Re: [Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Laurent Vivier 6 years, 7 months ago
On 11/09/2017 15:26, Cornelia Huck wrote:
> It does not really make sense to dump memory that is not there.
> 
> Moreover, that fixes a segmentation fault when calling dump-guest-memory
> with no filter for a machine with no memory defined.
> 
> New behaviour is:
> 
> (qemu) dump-guest-memory /dev/null
> dump: no guest memory to dump
> (qemu) dump-guest-memory /dev/null 0 4096
> dump: no guest memory to dump
> 
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> ---
> 
> Another unmaintained file. Joy. cc:ing some more-or-less random folks.
> 
> ---
>  dump.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/dump.c b/dump.c
> index a79773d0f7..d2093e141b 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -1536,6 +1536,12 @@ static void dump_init(DumpState *s, int fd, bool has_format,
>      fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size);
>  #endif
>  
> +    /* it does not make sense to dump non-existent memory */
> +    if (!s->total_size) {
> +        error_setg(errp, "dump: no guest memory to dump");
> +        goto cleanup;
> +    }
> +
>      s->start = get_start_block(s);
>      if (s->start == -1) {
>          error_setg(errp, QERR_INVALID_PARAMETER, "begin");
> 

We need to update test-hmp, as with this change dump-guest-memory will
do nothing with none machine, as by default memory size is 0 MB (I'm
working on that)

Tested-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>


Re: [Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Greg Kurz 6 years, 7 months ago
On Mon, 11 Sep 2017 15:26:27 +0200
Cornelia Huck <cohuck@redhat.com> wrote:

> It does not really make sense to dump memory that is not there.
> 
> Moreover, that fixes a segmentation fault when calling dump-guest-memory
> with no filter for a machine with no memory defined.
> 
> New behaviour is:
> 
> (qemu) dump-guest-memory /dev/null
> dump: no guest memory to dump
> (qemu) dump-guest-memory /dev/null 0 4096
> dump: no guest memory to dump
> 
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>

Reviewed-by: Greg Kurz <groug@kaod.org>

> ---
> 
> Another unmaintained file. Joy. cc:ing some more-or-less random folks.
> 
> ---
>  dump.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/dump.c b/dump.c
> index a79773d0f7..d2093e141b 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -1536,6 +1536,12 @@ static void dump_init(DumpState *s, int fd, bool has_format,
>      fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size);
>  #endif
>  
> +    /* it does not make sense to dump non-existent memory */
> +    if (!s->total_size) {
> +        error_setg(errp, "dump: no guest memory to dump");
> +        goto cleanup;
> +    }
> +
>      s->start = get_start_block(s);
>      if (s->start == -1) {
>          error_setg(errp, QERR_INVALID_PARAMETER, "begin");

Re: [Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Peter Xu 6 years, 7 months ago
On Mon, Sep 11, 2017 at 03:26:27PM +0200, Cornelia Huck wrote:
> It does not really make sense to dump memory that is not there.
> 
> Moreover, that fixes a segmentation fault when calling dump-guest-memory
> with no filter for a machine with no memory defined.
> 
> New behaviour is:
> 
> (qemu) dump-guest-memory /dev/null
> dump: no guest memory to dump
> (qemu) dump-guest-memory /dev/null 0 4096
> dump: no guest memory to dump
> 
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>

Reviewed-by: Peter Xu <peterx@redhat.com>

> ---
> 
> Another unmaintained file. Joy. cc:ing some more-or-less random folks.
> 
> ---
>  dump.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/dump.c b/dump.c
> index a79773d0f7..d2093e141b 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -1536,6 +1536,12 @@ static void dump_init(DumpState *s, int fd, bool has_format,
>      fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size);
>  #endif
>  
> +    /* it does not make sense to dump non-existent memory */
> +    if (!s->total_size) {
> +        error_setg(errp, "dump: no guest memory to dump");
> +        goto cleanup;
> +    }
> +
>      s->start = get_start_block(s);
>      if (s->start == -1) {
>          error_setg(errp, QERR_INVALID_PARAMETER, "begin");
> -- 
> 2.13.5
> 

-- 
Peter Xu

Re: [Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Peter Xu 6 years, 7 months ago
On Mon, Sep 11, 2017 at 03:26:27PM +0200, Cornelia Huck wrote:
> It does not really make sense to dump memory that is not there.
> 
> Moreover, that fixes a segmentation fault when calling dump-guest-memory
> with no filter for a machine with no memory defined.
> 
> New behaviour is:
> 
> (qemu) dump-guest-memory /dev/null
> dump: no guest memory to dump
> (qemu) dump-guest-memory /dev/null 0 4096
> dump: no guest memory to dump
> 
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> ---
> 
> Another unmaintained file. Joy. cc:ing some more-or-less random folks.

I thought Marc-André had proposed to be the maintainer? But indeed I
didn't see the line in maintainer file.

Anyway, if anyone think I am ok to maintain this single file
(considering that I haven't posted patches on it for 2 years, and I
haven't been working on any kind of maintainer job), please let me
know. I'm glad to start with it (or with Marc-André).

Thanks,

-- 
Peter Xu

Re: [Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Marc-André Lureau 6 years, 7 months ago
Hi Peter

On Tue, Sep 12, 2017 at 5:33 AM, Peter Xu <peterx@redhat.com> wrote:
> On Mon, Sep 11, 2017 at 03:26:27PM +0200, Cornelia Huck wrote:
>> It does not really make sense to dump memory that is not there.
>>
>> Moreover, that fixes a segmentation fault when calling dump-guest-memory
>> with no filter for a machine with no memory defined.
>>
>> New behaviour is:
>>
>> (qemu) dump-guest-memory /dev/null
>> dump: no guest memory to dump
>> (qemu) dump-guest-memory /dev/null 0 4096
>> dump: no guest memory to dump
>>
>> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
>> ---
>>
>> Another unmaintained file. Joy. cc:ing some more-or-less random folks.
>
> I thought Marc-André had proposed to be the maintainer? But indeed I
> didn't see the line in maintainer file.
>
> Anyway, if anyone think I am ok to maintain this single file
> (considering that I haven't posted patches on it for 2 years, and I
> haven't been working on any kind of maintainer job), please let me
> know. I'm glad to start with it (or with Marc-André).
>

That would be great!
thanks



-- 
Marc-André Lureau

Re: [Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Peter Xu 6 years, 7 months ago
On Tue, Sep 12, 2017 at 12:17:51PM +0200, Marc-André Lureau wrote:
> Hi Peter
> 
> On Tue, Sep 12, 2017 at 5:33 AM, Peter Xu <peterx@redhat.com> wrote:
> > On Mon, Sep 11, 2017 at 03:26:27PM +0200, Cornelia Huck wrote:
> >> It does not really make sense to dump memory that is not there.
> >>
> >> Moreover, that fixes a segmentation fault when calling dump-guest-memory
> >> with no filter for a machine with no memory defined.
> >>
> >> New behaviour is:
> >>
> >> (qemu) dump-guest-memory /dev/null
> >> dump: no guest memory to dump
> >> (qemu) dump-guest-memory /dev/null 0 4096
> >> dump: no guest memory to dump
> >>
> >> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> >> ---
> >>
> >> Another unmaintained file. Joy. cc:ing some more-or-less random folks.
> >
> > I thought Marc-André had proposed to be the maintainer? But indeed I
> > didn't see the line in maintainer file.
> >
> > Anyway, if anyone think I am ok to maintain this single file
> > (considering that I haven't posted patches on it for 2 years, and I
> > haven't been working on any kind of maintainer job), please let me
> > know. I'm glad to start with it (or with Marc-André).
> >
> 
> That would be great!
> thanks

Let me try to draft a maintainer file change for this, to see whether
there are objections.  Thanks!

-- 
Peter Xu

Re: [Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Cornelia Huck 6 years, 7 months ago
On Tue, 12 Sep 2017 12:17:51 +0200
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi Peter
> 
> On Tue, Sep 12, 2017 at 5:33 AM, Peter Xu <peterx@redhat.com> wrote:
> > On Mon, Sep 11, 2017 at 03:26:27PM +0200, Cornelia Huck wrote:  
> >> It does not really make sense to dump memory that is not there.
> >>
> >> Moreover, that fixes a segmentation fault when calling dump-guest-memory
> >> with no filter for a machine with no memory defined.
> >>
> >> New behaviour is:
> >>
> >> (qemu) dump-guest-memory /dev/null
> >> dump: no guest memory to dump
> >> (qemu) dump-guest-memory /dev/null 0 4096
> >> dump: no guest memory to dump
> >>
> >> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> >> ---
> >>
> >> Another unmaintained file. Joy. cc:ing some more-or-less random folks.  
> >
> > I thought Marc-André had proposed to be the maintainer? But indeed I
> > didn't see the line in maintainer file.
> >
> > Anyway, if anyone think I am ok to maintain this single file
> > (considering that I haven't posted patches on it for 2 years, and I
> > haven't been working on any kind of maintainer job), please let me
> > know. I'm glad to start with it (or with Marc-André).
> >  
> 
> That would be great!
> thanks

Now on to the most important question: Will you merge this patch? :)

(It should probably go together with "tests/hmp: test "none" machine
with memory".)

Re: [Qemu-devel] [PATCH] dump: do not dump non-existent guest memory
Posted by Peter Xu 6 years, 7 months ago
On Wed, Sep 13, 2017 at 09:58:04AM +0200, Cornelia Huck wrote:
> On Tue, 12 Sep 2017 12:17:51 +0200
> Marc-André Lureau <marcandre.lureau@gmail.com> wrote:
> 
> > Hi Peter
> > 
> > On Tue, Sep 12, 2017 at 5:33 AM, Peter Xu <peterx@redhat.com> wrote:
> > > On Mon, Sep 11, 2017 at 03:26:27PM +0200, Cornelia Huck wrote:  
> > >> It does not really make sense to dump memory that is not there.
> > >>
> > >> Moreover, that fixes a segmentation fault when calling dump-guest-memory
> > >> with no filter for a machine with no memory defined.
> > >>
> > >> New behaviour is:
> > >>
> > >> (qemu) dump-guest-memory /dev/null
> > >> dump: no guest memory to dump
> > >> (qemu) dump-guest-memory /dev/null 0 4096
> > >> dump: no guest memory to dump
> > >>
> > >> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> > >> ---
> > >>
> > >> Another unmaintained file. Joy. cc:ing some more-or-less random folks.  
> > >
> > > I thought Marc-André had proposed to be the maintainer? But indeed I
> > > didn't see the line in maintainer file.
> > >
> > > Anyway, if anyone think I am ok to maintain this single file
> > > (considering that I haven't posted patches on it for 2 years, and I
> > > haven't been working on any kind of maintainer job), please let me
> > > know. I'm glad to start with it (or with Marc-André).
> > >  
> > 
> > That would be great!
> > thanks
> 
> Now on to the most important question: Will you merge this patch? :)
> 
> (It should probably go together with "tests/hmp: test "none" machine
> with memory".)

I posted a RFC to maintain this file with Marc-André Lureau, but not
getting any acks yet, so I guess at least I don't have that
permission, yet...

And I see Laruent posted this already:

  [Qemu-devel] [PATCH v4 0/4] hmp: fix "dump-quest-memory" segfault

So I assume all these four patches can go with Dave's tree.  Thanks,

-- 
Peter Xu