qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Baojun Wang <wangbj@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V3 1/1] Add pmemsave command for both monitor and qmp, which could be useful to have qemu-softmmu as a cross debugger to load guest physical memory.
Date: Tue, 08 Apr 2014 13:42:53 -0600	[thread overview]
Message-ID: <5344513D.7050806@redhat.com> (raw)
In-Reply-To: <1396985438-19741-1-git-send-email-wangbj@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3365 bytes --]

On 04/08/2014 01:30 PM, Baojun Wang wrote:

Your subject line is extremely long.  In general, we strive for
something less than 60 characters, so that 'git shortlog -30' can
display the entire line in an 80-column terminal.  Also, the subject
mentions pmemsave, but your commit mentions pmemload - it's very
misleading to provide a patch where the commit message doesn't even
mention the name of the command the patch is adding.  I would suggest a
subject line of:

qmp: add pmemload command

> I found this could be useful to have qemu-softmmu as a cross debugger (launch
> with -s -S command line option), then if we can have a command to load guest
> physical memory, we can use cross gdb to do some target debug which gdb cannot
> do directly.
> 

Your patch is lacking a Signed-off-by designation, therefore we cannot
accept it yet.

> Many thanks to Eric Blake for review the patch.

This comment may be useful to reviewers, but is not part of the commit
itself, so it belongs better...

> 
> ---

...here, after the --- separator.


>  
> +void qmp_pmemload(int64_t addr, int64_t size, const char *filename,
> +                  Error **errp)
> +{
> +    FILE *f;
> +    uint32_t l;
> +    uint8_t buf[1024];
> +
> +    f = fopen(filename, "rb");

Rather than using fopen() and FILE* operations, I'd prefer you use
qemu_open() and lower-level read() operations.  In particular, this will
automatically make it possible for management applications to pass in
'/dev/fdset/1' to reuse a file descriptor that they passed in to qemu,
rather than forcing qemu to directly open the file.

> +    if (!f) {
> +        error_setg_file_open(errp, errno, filename);
> +        return;
> +    }
> +
> +    while (size != 0) {
> +        l = fread(buf, 1, sizeof(buf), f);
> +        if (l > size)
> +            l = size;

This is lousy at error detection.  Again, you should be using read(),
not fread(), and properly erroring out on read failures rather than
silently ignoring them.


> +        .name       = "pmemload",
> +        .args_type  = "val:l,size:i,filename:s",

Would it make sense to put filename as the FIRST argument, with val and
size as optional arguments (defaulting to reading in at address 0 and
for the size determined by the length of the input file), rather than
forcing the user to pass in a size up front?

> +++ b/qapi-schema.json
> @@ -1708,6 +1708,26 @@
>    'data': {'val': 'int', 'size': 'int', 'filename': 'str'} }
>  
>  ##
> +# @pmemload:
> +#
> +# Load a portion of guest physical memory from a file.
> +#
> +# @val: the physical address of the guest to start from
> +#
> +# @size: the size of memory region to load
> +#
> +# @filename: the file to load the memory from as binary data
> +#
> +# Returns: Nothing on success
> +#
> +# Since: 2.1
> +#
> +# Notes: Errors were not reliably returned until 2.1

Delete this line.  I guess I didn't make it clear in my first review
that this line is bogus copy and paste.  You don't need it.  pmemsave
needed it, because pmemsave went through some iterations where earlier
versions were buggy.  But your pmemload command is brand new, and should
not have bugs worth worrying about.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-04-08 19:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-08 19:30 [Qemu-devel] [PATCH V3 1/1] Add pmemsave command for both monitor and qmp, which could be useful to have qemu-softmmu as a cross debugger to load guest physical memory Baojun Wang
2014-04-08 19:42 ` Eric Blake [this message]
2014-04-08 23:29   ` Baojun Wang
2014-04-09 16:54     ` [Qemu-devel] [PATCH V4 1/1] qmp: add pmemload command Baojun Wang
2014-04-09 17:02       ` Eric Blake
2014-04-09 17:49         ` [Qemu-devel] [PATCH V5 " Baojun Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5344513D.7050806@redhat.com \
    --to=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=wangbj@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).