From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nl69v-0004TV-I4 for qemu-devel@nongnu.org; Fri, 26 Feb 2010 14:47:35 -0500 Received: from [199.232.76.173] (port=53247 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nl69u-0004T1-O4 for qemu-devel@nongnu.org; Fri, 26 Feb 2010 14:47:34 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nl69t-0007Ol-BF for qemu-devel@nongnu.org; Fri, 26 Feb 2010 14:47:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12343) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nl69s-0007Ob-SW for qemu-devel@nongnu.org; Fri, 26 Feb 2010 14:47:33 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1QJlWNI019783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Feb 2010 14:47:32 -0500 Date: Fri, 26 Feb 2010 16:47:25 -0300 From: Luiz Capitulino Subject: Re: [Qemu-devel] [PATCH RFC 48/48] monitor: convert do_device_add() to QObject Message-ID: <20100226164725.1b60299b@redhat.com> In-Reply-To: <1267034160-3517-49-git-send-email-armbru@redhat.com> References: <1267034160-3517-1-git-send-email-armbru@redhat.com> <1267034160-3517-49-git-send-email-armbru@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org On Wed, 24 Feb 2010 18:56:00 +0100 Markus Armbruster wrote: > > Signed-off-by: Markus Armbruster > --- > hw/qdev.c | 29 +++++++++++++++++++++-------- > hw/qdev.h | 2 +- > qemu-monitor.hx | 3 ++- > 3 files changed, 24 insertions(+), 10 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index bcd989c..a631492 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -586,7 +586,9 @@ static BusState *qbus_find(const char *path) > dev = qbus_find_dev(bus, elem); > if (!dev) { > qemu_error_new(QERR_DEVICE_NOT_FOUND, elem); > - qbus_list_dev(bus); > + if (!in_qmp_mon()) { > + qbus_list_dev(bus); > + } > return NULL; > } > > @@ -605,7 +607,9 @@ static BusState *qbus_find(const char *path) > return QLIST_FIRST(&dev->child_bus); > default: > qemu_error_new(QERR_DEVICE_MULTIPLE_BUSSES, elem); > - qbus_list_bus(dev); > + if (!in_qmp_mon()) { > + qbus_list_bus(dev); > + } > return NULL; > } > } > @@ -619,7 +623,9 @@ static BusState *qbus_find(const char *path) > bus = qbus_find_bus(dev, elem); > if (!bus) { > qemu_error_new(QERR_BUS_NOT_FOUND, elem); > - qbus_list_bus(dev); > + if (!in_qmp_mon()) { > + qbus_list_bus(dev); > + } > return NULL; > } > } > @@ -762,16 +768,23 @@ void do_info_qdm(Monitor *mon) > } > } > > -void do_device_add(Monitor *mon, const QDict *qdict) > +int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data) > { > QemuOpts *opts; > > opts = qemu_opts_from_qdict(&qemu_device_opts, qdict); > - if (opts) { > - if (qdev_device_help(opts) || qdev_device_add(opts) == NULL) { > - qemu_opts_del(opts); > - } > + if (!opts) { > + return -1; > } > + if (!in_qmp_mon() && qdev_device_help(opts)) { > + qemu_opts_del(opts); > + return 0; > + } > + if (!qdev_device_add(opts)) { > + qemu_opts_del(opts); > + return -1; > + } > + return 0; > } We need at least basic documentation of the accepted parameters and an example, just like all others QMP-enabled handlers. > > void do_device_del(Monitor *mon, const QDict *qdict) > diff --git a/hw/qdev.h b/hw/qdev.h > index 0eb45b0..c86a59d 100644 > --- a/hw/qdev.h > +++ b/hw/qdev.h > @@ -171,7 +171,7 @@ void qbus_free(BusState *bus); > > void do_info_qtree(Monitor *mon); > void do_info_qdm(Monitor *mon); > -void do_device_add(Monitor *mon, const QDict *qdict); > +int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data); > void do_device_del(Monitor *mon, const QDict *qdict); > > /*** qdev-properties.c ***/ > diff --git a/qemu-monitor.hx b/qemu-monitor.hx > index 641a8ef..e67ab20 100644 > --- a/qemu-monitor.hx > +++ b/qemu-monitor.hx > @@ -573,7 +573,8 @@ ETEXI > .args_type = "device:O", > .params = "driver[,prop=value],[,...]", > .help = "add device, like -device on the command line", > - .mhandler.cmd = do_device_add, > + .user_print = monitor_user_noop, > + .mhandler.cmd_new = do_device_add, > }, > > STEXI