From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu0EF-0005r5-4S for qemu-devel@nongnu.org; Fri, 20 Dec 2013 08:35:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vu0E9-00017O-VP for qemu-devel@nongnu.org; Fri, 20 Dec 2013 08:34:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu0E9-000178-N9 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 08:34:53 -0500 Date: Fri, 20 Dec 2013 08:33:25 -0500 From: Luiz Capitulino Message-ID: <20131220083325.4e5435ce@redhat.com> In-Reply-To: References: <1387386003-8949-1-git-send-email-lcapitulino@redhat.com> <1387386003-8949-12-git-send-email-lcapitulino@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL 11/13] monitor: add object-add (QMP) and object_add (HMP) command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: Paolo Bonzini , "qemu-devel@nongnu.org Developers" , Anthony Liguori , Igor Mammedov On Fri, 20 Dec 2013 12:15:53 +1000 Peter Crosthwaite wrote: > On Thu, Dec 19, 2013 at 3:00 AM, Luiz Capitulino wrote: > > From: Paolo Bonzini > > > > Add two commands that are the monitor counterparts of -object. The commands > > have the same Visitor-based implementation, but use different kinds of > > visitors so that the HMP command has a DWIM string-based syntax, while > > the QMP variant accepts a stricter JSON-based properties dictionary. > > > > Signed-off-by: Paolo Bonzini > > Reviewed-By: Igor Mammedov > > Signed-off-by: Luiz Capitulino > > --- > > hmp-commands.hx | 14 +++++++++++ > > hmp.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ > > hmp.h | 1 + > > include/monitor/monitor.h | 3 +++ > > include/qapi/visitor.h | 3 +-- > > include/qemu/typedefs.h | 2 ++ > > qapi-schema.json | 20 +++++++++++++++ > > qmp-commands.hx | 27 +++++++++++++++++++++ > > qmp.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ > > 9 files changed, 188 insertions(+), 2 deletions(-) > > > > diff --git a/hmp-commands.hx b/hmp-commands.hx > > index ebe8e78..2951d1e 100644 > > --- a/hmp-commands.hx > > +++ b/hmp-commands.hx > > @@ -1243,6 +1243,20 @@ STEXI > > Remove host network device. > > ETEXI > > > > + { > > + .name = "object_add", > > + .args_type = "object:O", > > + .params = "[qom-type=]type,id=str[,prop=value][,...]", > > + .help = "create QOM object", > > + .mhandler.cmd = hmp_object_add, > > + }, > > + > > +STEXI > > +@item object_add > > +@findex object_add > > +Create QOM object. > > +ETEXI > > + > > #ifdef CONFIG_SLIRP > > { > > .name = "hostfwd_add", > > diff --git a/hmp.c b/hmp.c > > index 32ee285..a1669ab 100644 > > --- a/hmp.c > > +++ b/hmp.c > > @@ -21,6 +21,7 @@ > > #include "qmp-commands.h" > > #include "qemu/sockets.h" > > #include "monitor/monitor.h" > > +#include "qapi/opts-visitor.h" > > #include "ui/console.h" > > #include "block/qapi.h" > > #include "qemu-io.h" > > @@ -1354,6 +1355,63 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict) > > hmp_handle_error(mon, &err); > > } > > > > +void hmp_object_add(Monitor *mon, const QDict *qdict) > > +{ > > + Error *err = NULL; > > + QemuOpts *opts; > > + char *type = NULL; > > + char *id = NULL; > > + void *dummy = NULL; > > + OptsVisitor *ov; > > + QDict *pdict; > > + > > + opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err); > > + if (error_is_set(&err)) { > > + goto out; > > + } > > + > > + ov = opts_visitor_new(opts); > > + pdict = qdict_clone_shallow(qdict); > > + > > + visit_start_struct(opts_get_visitor(ov), &dummy, NULL, NULL, 0, &err); > > + if (error_is_set(&err)) { > > + goto out_clean; > > + } > > + > > + qdict_del(pdict, "qom-type"); > > + visit_type_str(opts_get_visitor(ov), &type, "qom-type", &err); > > + if (error_is_set(&err)) { > > + goto out_clean; > > + } > > + > > + qdict_del(pdict, "id"); > > + visit_type_str(opts_get_visitor(ov), &id, "id", &err); > > + if (error_is_set(&err)) { > > + goto out_clean; > > + } > > + > > + object_add(type, id, pdict, opts_get_visitor(ov), &err); > > + if (error_is_set(&err)) { > > + goto out_clean; > > + } > > + visit_end_struct(opts_get_visitor(ov), &err); > > + if (error_is_set(&err)) { > > + qmp_object_del(id, NULL); > > This is not bisect-able as you add this function in the next commit: Thanks for catching it. This was a bad pull request. Paolo, can resend?