qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 0c3365: dump.c: allow fd_write_vmcore to retu


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 0c3365: dump.c: allow fd_write_vmcore to return errno on f...
Date: Thu, 22 Mar 2018 07:00:54 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 0c33659d09f4a8ab926846295538d6a67e8c2c63
      
https://github.com/qemu/qemu/commit/0c33659d09f4a8ab926846295538d6a67e8c2c63
  Author: Yasmin Beatriz <address@hidden>
  Date:   2018-03-21 (Wed, 21 Mar 2018)

  Changed paths:
    M dump.c

  Log Message:
  -----------
  dump.c: allow fd_write_vmcore to return errno on failure

fd_write_vmcore can fail to execute for a lot of reasons that can be
retrieved by errno, but it only returns -1. This makes difficult for
the caller to know what happened and only a generic error message is
propagated back to the user. This is an example using dump-guest-memory:

(qemu) dump-guest-memory /home/yasmin/mnt/test.dump
dump: failed to save memory

All callers of fd_write_vmcore of dump.c does error handling via
error_setg(), so at first it seems feasible to add the Error pointer as
an argument of fd_write_vmcore. This proved to be more complex than it
first looked. fd_write_vmcore is used by write_elf64_notes and
write_elf32_notes as a WriteCoreDumpFunction prototype. WriteCoreDumpFunction
is declared in include/qom/cpu.h and is used all around the code. This
leaves us with few alternatives:

- change the WriteCoreDumpFunction prototype to include an error pointer.
This would require to change all functions that implements this prototype
to also receive an Error pointer;

- change both write_elf64_notes and write_elf32_notes to no use the
WriteCoreDumpFunction. These functions use not only fd_write_vmcore
but also buf_write_note, so this would require to change buf_write_note
to handle an Error pointer. Considerable easier than the alternative
above, but it's still a lot of code just for the benefit of the callers
of fd_write_vmcore.

This patch presents an easier solution that benefits all fd_write_vmcore
callers:

- instead of returning -1 on error, return -errno. All existing callers
already checks for ret < 0 so there is no need to change the caller's
logic too much. This also allows the retrieval of the errno.

- all callers were updated to use error_setg_errno instead of just
errno_setg. Now that fd_write_vmcore can return an errno, let's update
all callers so they can benefit from a more detailed error message.

This is the same dump-guest-memory example with this patch applied:

(qemu) dump-guest-memory /home/yasmin/mnt/test.dump
dump: failed to save memory: No space left on device
(qemu)

This example illustrates an error of fd_write_vmcore when called
from write_data. All other callers will benefit from better
error messages as well.

Reported-by: address@hidden
Cc: Jose Ricardo Ziviani <address@hidden>
Signed-off-by: Yasmin Beatriz <address@hidden>
Signed-off-by: Daniel Henrique Barboza <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>


  Commit: 4b17bc933fc26f7a4a306a43597f4d97e3c2dc38
      
https://github.com/qemu/qemu/commit/4b17bc933fc26f7a4a306a43597f4d97e3c2dc38
  Author: Andrew Jones <address@hidden>
  Date:   2018-03-21 (Wed, 21 Mar 2018)

  Changed paths:
    M scripts/dump-guest-memory.py

  Log Message:
  -----------
  dump-guest-memory: more descriptive lookup_type failure

We've seen a few reports of

 (gdb) source /usr/share/qemu-kvm/dump-guest-memory.py
 Traceback (most recent call last):
   File "/usr/share/qemu-kvm/dump-guest-memory.py", line 19, in <module>
     UINTPTR_T = gdb.lookup_type("uintptr_t")
 gdb.error: No type named uintptr_t.

This occurs when symbols haven't been loaded first, i.e. neither a
QEMU binary was loaded nor a QEMU process was attached first. Let's
better inform the user of how to fix the issue themselves in order
to avoid more reports.

Acked-by: Janosch Frank <address@hidden>
Signed-off-by: Andrew Jones <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Tested-by: Fam Zheng <address@hidden>
Reviewed-by: Laszlo Ersek <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>


  Commit: 99728ba3ec9b8795ff7191ea75a2a8c0329c29a5
      
https://github.com/qemu/qemu/commit/99728ba3ec9b8795ff7191ea75a2a8c0329c29a5
  Author: Peter Maydell <address@hidden>
  Date:   2018-03-22 (Thu, 22 Mar 2018)

  Changed paths:
    M dump.c
    M scripts/dump-guest-memory.py

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/elmarco/tags/dump-pull-request' into 
staging

Pull request

# gpg: Signature made Wed 21 Mar 2018 14:37:05 GMT
# gpg:                using RSA key DAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <address@hidden>"
# gpg:                 aka "Marc-André Lureau <address@hidden>"
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* remotes/elmarco/tags/dump-pull-request:
  dump-guest-memory: more descriptive lookup_type failure
  dump.c: allow fd_write_vmcore to return errno on failure

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/b2ce07de4e0f...99728ba3ec9b

reply via email to

[Prev in Thread] Current Thread [Next in Thread]