Skip to contentSkip to conversation

dump: do not dump non-existent guest memory

PATCH In review Cornelia Huck 5 participants 9 messages Sep 11, 2017 – Sep 14, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dump: do not dump non-existent guest memory

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

---

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

---
 dump.c | 6 ++++++
 1 file changed, 6 insertions(+)
dump.c +6 -0
index a79773d0f7..d2093e141b 100644
@@ -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");
Signature · 1 line
2.13.5
Tested-by Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Cornelia Huck

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

---

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

---
 dump.c | 6 ++++++
 1 file changed, 6 insertions(+)
dump.c +0 -0
index a79773d0f7..d2093e141b 100644
@@ -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

dump.c static void dump_init(DumpState *s, int fd, bool has_format, · line 1547

Quoted 10 lines
dump.c +6 -0
 
+    /* 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)

Reviewed-by on v1 1/1
#2 lore raw
In reply to Cornelia Huck
Quoted 5 lines · On Mon, 11 Sep 2017 15:26:27 +0200 Cornelia Huck <[email protected]> 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.

Quoted 8 lines

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

Quoted 25 lines

---

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

---
 dump.c | 6 ++++++
 1 file changed, 6 insertions(+)
dump.c +6 -0
index a79773d0f7..d2093e141b 100644
@@ -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");
Reviewed-by on v1 1/1
#3 lore raw
In reply to Cornelia Huck
Quoted 5 lines · Cornelia Huck

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.

Quoted 8 lines

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

Quoted 28 lines

---

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

---
 dump.c | 6 ++++++
 1 file changed, 6 insertions(+)
dump.c +6 -0
index a79773d0f7..d2093e141b 100644
@@ -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");
Signature · 1 line
2.13.5
Signature · 1 line
Peter Xu
#4 lore raw
In reply to Cornelia Huck
Quoted 12 lines · Cornelia Huck

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

Quoted 4 lines

---

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,

Signature · 1 line
Peter Xu
#5 lore raw

Hi Peter

Quoted 18 lines · Peter Xu
Quoted 12 lines · Cornelia Huck

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

Quoted 4 lines

---

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

Quoted 8 lines

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

Signature · 1 line
Marc-André Lureau
#6 lore raw
Quoted 24 lines · Marc-André Lureau

Hi Peter

Quoted 21 lines · Peter Xu
Quoted 12 lines · Cornelia Huck

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

Quoted 4 lines

---

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.

Quoted 8 lines
Quoted 5 lines

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!

Signature · 1 line
Peter Xu
#7 lore raw
In reply to Marc-André Lureau
Quoted 24 lines · On Tue, 12 Sep 2017 12:17:51 +0200 Marc-André Lureau…

Hi Peter

Quoted 21 lines · Peter Xu
Quoted 12 lines · Cornelia Huck

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

Quoted 4 lines

---

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.

Quoted 8 lines
Quoted 5 lines

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".)

#8 lore raw
Quoted 33 lines · Cornelia Huck
Quoted 30 lines · On Tue, 12 Sep 2017 12:17:51 +0200 Marc-André Lureau…

Hi Peter

Quoted 26 lines · Peter Xu
Quoted 12 lines · Cornelia Huck

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

Quoted 4 lines

---

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é).

Quoted 7 lines
Quoted 2 lines

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,

Signature · 1 line
Peter Xu