On Fri, 20 Dec 2013 12:15:53 +1000 Peter Crosthwaite <peter.crosthwa...@xilinx.com> wrote:
> On Thu, Dec 19, 2013 at 3:00 AM, Luiz Capitulino <lcapitul...@redhat.com> > wrote: > > From: Paolo Bonzini <pbonz...@redhat.com> > > > > 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 <pbonz...@redhat.com> > > Reviewed-By: Igor Mammedov <imamm...@redhat.com> > > Signed-off-by: Luiz Capitulino <lcapitul...@redhat.com> > > --- > > 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?