All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Simon Ruderich <simon@ruderich.org>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Peter Crosthwaite <crosthwaitepeter@gmail.com>,
	qemu-devel@nongnu.org, Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v3 5/5] qmp: add pmemload command
Date: Tue, 14 Aug 2018 17:49:12 +0200	[thread overview]
Message-ID: <871sb1t0cn.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20180814141826.GA26558@ruderich.org> (Simon Ruderich's message of "Tue, 14 Aug 2018 16:18:26 +0200")

Simon Ruderich <simon@ruderich.org> writes:

> On Fri, Aug 10, 2018 at 11:36:51AM +0100, Dr. David Alan Gilbert wrote:
>>> --- a/hmp-commands.hx
>>> +++ b/hmp-commands.hx

Subject claims "qmp: add", but the patch also adds to hmp.  Recommend to
split the patch into QMP and HMP part.

>>> @@ -822,6 +822,20 @@ STEXI
>>>  @item pmemsave @var{addr} @var{size} @var{file}
>>>  @findex pmemsave
>>>  save to disk physical memory dump starting at @var{addr} of size @var{size}.
>>> +ETEXI
>>> +
>>> +    {
>>> +        .name       = "pmemload",
>>> +        .args_type  = "val:l,size:i,offset:i,filename:s",
>>> +        .params     = "addr size offset file",
>>> +        .help       = "load from disk physical memory dump starting at 'addr' of size 'size' at file offset 'offset'",
>>> +        .cmd        = hmp_pmemload,
>>> +    },
>>> +
>>
>> I'm guessing that size and offset should be 'l' to allow large
>> sizes and offsets, and there's an 'F' type for filenames
>
> I've copied that from "pmemsave" and "memsave" which use 'i' for
> size. I'll add patches which will adapt them to use both 'l' and
> 'F' and adapt my pmemload patch as well.
>
> qapi/misc.json seems to always use 'int' for integer types. Is
> this value large enough on 64-bit architectures?

Yes.  QAPI's int translates to int64_t.

>> (see monitor.c which has a big comment table near the start).
>
> Thanks.
>
> Just curious, what is the difference between 's' and 'F'. Is that
> only for documentation purposes (and maybe tab completion) or is
> the usage different? I noticed existing code uses qdict_get_str()
> for both 's' and 'F'.

The main behavioral difference is completion.

>> Also, had you considered rearranging and making them optional,
>> for example if you do:
>>
>> val:l,filename:F,offset:i?,size:i?
>>
>> I think that would mean you can do the fairly obvious:
>>   pmemload addr "myfile"
>>
>> with the assumption that loads the whole file.
>
> I tried to keep it as similar to the existing functions
> "memsave"/"pmemsave", only adding "offset". Eric Blake already
> raised this issue in the thread, here's my response for
> reference:
>
> On Mon, Apr 23, 2018 at 02:46:57PM -0500, Eric Blake wrote:
>> Back-compat in the QMP interface matters.  The HMP interface, however,
>> exists to serve humans not machines, and we can break it at will to
>> something that makes more sense to humans.  So don't let HMP concerns
>> hold you back from a sane interface.
>
> I see. However I don't like breaking existing interfaces unless I
> have to. In this case I think not having the optional parameters
> is fine and the consistency between the existing memsave/pmemsave
> functions is more important.
>
>> Optional parameters are listed as '*name':'type' in the .json file,
>> which tells the generator to create a 'has_name' bool parameter
>> alongside the 'name' parameter in the C code for the QMP interface.  The
>> HMP interface should then call into the QMP interface.
>>
>> Recent HMP patches that I've authored may offer some inspiration: commit
>> 08fb10a added a new command, and commit dba4932 added an optional
>> parameter to an existing command.
>
> Thank you for the explanation, this looks straight-forward.
>
> Do you have strong opinions regarding the optional parameters or
> would you accept the patch as is (minus possible implementation
> issues)? I like the symmetry to the existing functions (I noticed
> that size can only be optional for pmemload because saving the
> complete memory doesn't sound useful) and having to specify
> size/offset doesn't hurt the caller too much.

I recommend to start with the QMP interface.  Parameters are unordered
there.  memsave and pmemsave both take mandatory @val, @size, @filename.
memsave additionally takes optional @cpu-index.

Your pmemload has pmemsave's arguments plus and mandatory @offset.
Rationale for adding @offset?  You may have answered this question
already; pointer to that answer would be fine.

Once we got the QMP interface nailed down, we can move to the HMP
interface.

> Thanks for your review!
>
> Regards
> Simon
>
> PS: Diff between v3 and my current local version follows:
>
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 5a43dae133..c39d745a22 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -818,7 +818,7 @@ ETEXI
>  
>      {
>          .name       = "memsave",
> -        .args_type  = "val:l,size:i,filename:s",
> +        .args_type  = "val:l,size:l,filename:F",
>          .params     = "addr size file",
>          .help       = "save to disk virtual memory dump starting at 'addr' of size 'size'",
>          .cmd        = hmp_memsave,
> @@ -832,7 +832,7 @@ ETEXI
>  
>      {
>          .name       = "pmemsave",
> -        .args_type  = "val:l,size:i,filename:s",
> +        .args_type  = "val:l,size:l,filename:F",
>          .params     = "addr size file",
>          .help       = "save to disk physical memory dump starting at 'addr' of size 'size'",
>          .cmd        = hmp_pmemsave,

These two should become a separate bug fix patch.  The bug being fixed
is completion.

> @@ -846,7 +846,7 @@ ETEXI
>  
>      {
>          .name       = "pmemload",
> -        .args_type  = "val:l,size:i,offset:i,filename:s",
> +        .args_type  = "val:l,size:l,offset:l,filename:F",
>          .params     = "addr size offset file",
>          .help       = "load from disk physical memory dump starting at 'addr' of size 'size' at file offset 'offset'",
>          .cmd        = hmp_pmemload,
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 6c34b2ff8b..becc257a76 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -1196,7 +1196,7 @@
>  #
>  # Returns: Nothing on success
>  #
> -# Since: 2.13
> +# Since: 3.1
>  ##
>  { 'command': 'pmemload',
>    'data': {'val': 'int', 'size': 'int', 'offset': 'int', 'filename': 'str'} }

  reply	other threads:[~2018-08-14 17:44 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 21:24 [Qemu-devel] [PATCH] qmp: add pmemload command Simon Ruderich
2018-04-10 21:27 ` no-reply
2018-04-10 21:33 ` Eric Blake
2018-04-11  7:36   ` Simon Ruderich
2018-04-11 13:02     ` Eric Blake
2018-04-12 12:48       ` Simon Ruderich
2018-04-12 12:50         ` [Qemu-devel] [PATCH v2 1/5] cpus: correct coding style in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-04-12 12:50           ` [Qemu-devel] [PATCH v2 2/5] cpus: convert qmp_memsave/qmp_pmemsave to use qemu_open Simon Ruderich
2018-04-17 20:58             ` Eric Blake
2018-04-12 12:50           ` [Qemu-devel] [PATCH v2 3/5] cpus: use size_t in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-04-17 20:58             ` Eric Blake
2018-04-12 12:50           ` [Qemu-devel] [PATCH v2 4/5] hmp: don't truncate size in hmp_memsave/hmp_pmemsave Simon Ruderich
2018-04-17 20:59             ` Eric Blake
2018-04-12 12:50           ` [Qemu-devel] [PATCH v2 5/5] qmp: add pmemload command Simon Ruderich
2018-04-17 21:18             ` Eric Blake
2018-04-22  9:47               ` Simon Ruderich
2018-04-23 19:46                 ` Eric Blake
2018-04-24 14:50                   ` Simon Ruderich
2018-04-17 20:56           ` [Qemu-devel] [PATCH v2 1/5] cpus: correct coding style in qmp_memsave/qmp_pmemsave Eric Blake
2018-04-22  9:19             ` Simon Ruderich
2018-05-21 15:36 ` [Qemu-devel] [PATCH v3 0/5] qmp: add pmemload command Simon Ruderich
2018-05-21 15:36   ` [Qemu-devel] [PATCH v3 1/5] cpus: correct coding style in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-05-21 15:36   ` [Qemu-devel] [PATCH v3 2/5] cpus: convert qmp_memsave/qmp_pmemsave to use qemu_open Simon Ruderich
2018-05-21 15:36   ` [Qemu-devel] [PATCH v3 3/5] cpus: use size_t in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-05-21 15:36   ` [Qemu-devel] [PATCH v3 4/5] hmp: don't truncate size in hmp_memsave/hmp_pmemsave Simon Ruderich
2018-05-21 15:36   ` [Qemu-devel] [PATCH v3 5/5] qmp: add pmemload command Simon Ruderich
2018-08-09 16:46     ` Eric Blake
2018-08-14 14:16       ` Simon Ruderich
2018-08-10 10:36     ` Dr. David Alan Gilbert
2018-08-14 14:18       ` Simon Ruderich
2018-08-14 15:49         ` Markus Armbruster [this message]
2018-08-14 19:03           ` Simon Ruderich
2018-08-15  4:22             ` Markus Armbruster
2018-08-15 12:41               ` Simon Ruderich
2018-08-15 14:29                 ` Markus Armbruster
2018-08-15 15:46                   ` Simon Ruderich
2018-08-16  5:43                     ` Markus Armbruster
2018-08-16  8:13                       ` Simon Ruderich
2018-08-16  8:26                         ` Markus Armbruster
2018-08-16  8:38                           ` Simon Ruderich
2018-08-14 19:30         ` Dr. David Alan Gilbert
2018-08-09 14:43   ` [Qemu-devel] [PATCH v3 0/5] " Simon Ruderich
2018-08-10  6:06     ` Markus Armbruster
2018-08-14 14:16       ` Simon Ruderich
2018-08-14 15:27         ` Markus Armbruster
2018-08-16  9:01 ` [Qemu-devel] [PATCH v4 0/7] qmp/hmp: " Simon Ruderich
2018-08-16  9:01   ` [Qemu-devel] [PATCH v4 1/7] cpus: correct coding style in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-08-16 19:56     ` Eric Blake
2018-08-16  9:01   ` [Qemu-devel] [PATCH v4 2/7] cpus: convert qmp_memsave/qmp_pmemsave to use qemu_open Simon Ruderich
2018-08-16 19:58     ` Eric Blake
2018-08-16  9:01   ` [Qemu-devel] [PATCH v4 3/7] cpus: use size_t in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-08-16 19:58     ` Eric Blake
2018-08-16  9:01   ` [Qemu-devel] [PATCH v4 4/7] hmp: use l for size argument in memsave/pmemsave Simon Ruderich
2018-08-16 18:51     ` Dr. David Alan Gilbert
2018-08-16  9:01   ` [Qemu-devel] [PATCH v4 5/7] hmp: use F for filename arguments " Simon Ruderich
2018-08-16 18:53     ` Dr. David Alan Gilbert
2018-08-16  9:01   ` [Qemu-devel] [PATCH v4 6/7] qmp: add pmemload command Simon Ruderich
2018-08-16 20:01     ` Eric Blake
2018-08-17  7:50       ` Simon Ruderich
2018-08-21 12:38       ` [Qemu-devel] [PATCH v5 5/6] " Simon Ruderich
     [not found]         ` <20180921110205.GA904@ruderich.org>
2018-10-09 12:14           ` Simon Ruderich
2018-08-16  9:01   ` [Qemu-devel] [PATCH v4 7/7] hmp: " Simon Ruderich
2018-08-16 18:57     ` Dr. David Alan Gilbert
2018-11-15 13:01 ` [Qemu-devel] [PATCH v6 0/6] qmp: " Simon Ruderich
2018-11-15 13:01   ` [Qemu-devel] [PATCH v6 1/6] cpus: convert qmp_memsave/qmp_pmemsave to use qemu_open Simon Ruderich
2018-11-15 13:01   ` [Qemu-devel] [PATCH v6 2/6] cpus: use size_t in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-11-15 13:01   ` [Qemu-devel] [PATCH v6 3/6] hmp: use l for size argument in memsave/pmemsave Simon Ruderich
2018-11-15 13:01   ` [Qemu-devel] [PATCH v6 4/6] hmp: use F for filename arguments " Simon Ruderich
2018-11-15 13:01   ` [Qemu-devel] [PATCH v6 5/6] qmp: add pmemload command Simon Ruderich
2018-11-15 13:01   ` [Qemu-devel] [PATCH v6 6/6] hmp: " Simon Ruderich
2018-11-15 13:22 ` [Qemu-devel] [PATCH v7 0/7] qmp: " Simon Ruderich
2018-11-15 13:22   ` [Qemu-devel] [PATCH v7 1/7] cpus: correct coding style in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-11-15 13:46     ` Eric Blake
2018-11-15 13:22   ` [Qemu-devel] [PATCH v7 2/7] cpus: convert qmp_memsave/qmp_pmemsave to use qemu_open Simon Ruderich
2018-11-15 13:49     ` Eric Blake
2018-11-15 13:22   ` [Qemu-devel] [PATCH v7 3/7] cpus: use size_t in qmp_memsave/qmp_pmemsave Simon Ruderich
2018-11-15 13:22   ` [Qemu-devel] [PATCH v7 4/7] hmp: use l for size argument in memsave/pmemsave Simon Ruderich
2018-11-15 13:22   ` [Qemu-devel] [PATCH v7 5/7] hmp: use F for filename arguments " Simon Ruderich
2018-11-15 13:22   ` [Qemu-devel] [PATCH v7 6/7] qmp: add pmemload command Simon Ruderich
2018-11-15 13:22   ` [Qemu-devel] [PATCH v7 7/7] hmp: " Simon Ruderich
2018-11-15 13:45   ` [Qemu-devel] [PATCH v7 0/7] qmp: " Eric Blake
2018-11-15 14:09     ` Simon Ruderich

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=871sb1t0cn.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=crosthwaitepeter@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=simon@ruderich.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.