qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, afaerber@suse.de, ehabkost@redhat.com,
	dgilbert@redhat.com, armbru@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/3] fix qmp/hmp query-memdev not repporting IDs of memory backends
Date: Mon, 9 Jan 2017 14:26:28 -0600	[thread overview]
Message-ID: <76f63302-2cb2-199e-317f-7d44212188b9@redhat.com> (raw)
In-Reply-To: <20170109151733.34510569@nial.brq.redhat.com>

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

On 01/09/2017 08:17 AM, Igor Mammedov wrote:

>> Wait. Isn't this going to inject an 'id' dict member to every use of
>> user_creatable_add_type()?  But not all QAPI structs contain an id
>> member.  Which means that you are now explicitly relying on the visitor
>> to silently ignore garbage in the dictionary, rather than our desired
>> goal of only validating if the dictionary exactly matches what the QAPI
>> says it will match.
>>
>> I'm not sure if I like this hack, or if there is a better way to do
>> things when using a strict (rather than relaxed) input visitor.
> a bit less ugly variant but with the same basic idea would look like:
> --------------
> Subject: [PATCH] fix qmp/hmp query-memdev not reporting IDs of memory backends   
>                                                                                  
> Considering 'id' is mandatory for user_creatable objects/backends                
> and user_creatable_add_type() always has it as an argument                       
> regardless of where from it is called CLI/monitor or QMP,                        
> Fix issue by adding 'id' property to hostmem backends and                        
> set it in user_creatable_add_type() for every object that                        
> implements 'id' property. Then later at query-memdev time                        
> get 'id' from object directly.                     

Yes, that seems like an improved message.

>                                                                                  
> Signed-off-by: Igor Mammedov <imammedo@redhat.com> 
> 
> [...]
> 
> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> index 9b4155a..03a95c3 100644
> --- a/qom/object_interfaces.c
> +++ b/qom/object_interfaces.c
> @@ -62,6 +62,12 @@ Object *user_creatable_add_type(const char *type, const char *id,
>  
>      assert(qdict);
>      obj = object_new(type);
> +    if (object_property_find(obj, "id", NULL)) {
> +        object_property_set_str(obj, id, "id", &local_err);
> +        if (local_err) {
> +            goto out;
> +        }
> +    }

Works for me.

-- 
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:[~2017-01-09 20:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-02 15:44 [Qemu-devel] [PATCH 0/3] fix query-memdev not repporting IDs of memory backends Igor Mammedov
2017-01-02 15:44 ` [Qemu-devel] [PATCH 1/3] cleanup: remove not used header Igor Mammedov
2017-01-03 15:25   ` Eric Blake
2017-01-03 15:26     ` Andreas Färber
2017-01-03 16:54       ` Igor Mammedov
2017-01-02 15:44 ` [Qemu-devel] [PATCH 2/3] reuse user_creatable_add_opts() instead of user_creatable_add() in monitor Igor Mammedov
2017-01-03 15:29   ` Eric Blake
2017-01-03 15:30   ` Eric Blake
2017-01-02 15:44 ` [Qemu-devel] [PATCH 3/3] fix qmp/hmp query-memdev not repporting IDs of memory backends Igor Mammedov
2017-01-03 15:34   ` Eric Blake
2017-01-03 17:19     ` Igor Mammedov
2017-01-09 14:17     ` Igor Mammedov
2017-01-09 20:26       ` Eric Blake [this message]
2017-01-10  9:07         ` Igor Mammedov

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=76f63302-2cb2-199e-317f-7d44212188b9@redhat.com \
    --to=eblake@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.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 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).