All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Hu Tao <hutao@cn.fujitsu.com>,
	Anthony Liguori <aliguori@amazon.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL v2 078/106] vl: redo -object parsing
Date: Wed, 18 Jun 2014 19:20:45 +0300	[thread overview]
Message-ID: <1403108034-32054-79-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1403108034-32054-1-git-send-email-mst@redhat.com>

From: Paolo Bonzini <pbonzini@redhat.com>

Follow the lines of the HMP implementation, using OptsVisitor
to parse the options.  This gives access to OptsVisitor's
rich parsing of integer lists.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 vl.c | 65 ++++++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/vl.c b/vl.c
index 469aa9c..c05f068 100644
--- a/vl.c
+++ b/vl.c
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
 
 #include "ui/qemu-spice.h"
 #include "qapi/string-input-visitor.h"
-#include "qom/object_interfaces.h"
+#include "qapi/opts-visitor.h"
 
 #define DEFAULT_RAM_SIZE 128
 
@@ -2822,44 +2822,51 @@ static int object_set_property(const char *name, const char *value, void *opaque
 
 static int object_create(QemuOpts *opts, void *opaque)
 {
-    const char *type = qemu_opt_get(opts, "qom-type");
-    const char *id = qemu_opts_id(opts);
-    Error *local_err = NULL;
-    Object *obj;
-
-    g_assert(type != NULL);
-
-    if (id == NULL) {
-        qerror_report(QERR_MISSING_PARAMETER, "id");
-        return -1;
+    Error *err = NULL;
+    char *type = NULL;
+    char *id = NULL;
+    void *dummy = NULL;
+    OptsVisitor *ov;
+    QDict *pdict;
+
+    ov = opts_visitor_new(opts);
+    pdict = qemu_opts_to_qdict(opts, NULL);
+
+    visit_start_struct(opts_get_visitor(ov), &dummy, NULL, NULL, 0, &err);
+    if (err) {
+        goto out;
     }
 
-    obj = object_new(type);
-    if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) {
-        object_unref(obj);
-        return -1;
+    qdict_del(pdict, "qom-type");
+    visit_type_str(opts_get_visitor(ov), &type, "qom-type", &err);
+    if (err) {
+        goto out;
     }
 
-    if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
-        error_setg(&local_err, "object '%s' isn't supported by -object",
-                   id);
+    qdict_del(pdict, "id");
+    visit_type_str(opts_get_visitor(ov), &id, "id", &err);
+    if (err) {
         goto out;
     }
 
-    object_property_add_child(container_get(object_get_root(), "/objects"),
-                              id, obj, &local_err);
-
-    user_creatable_complete(obj, &local_err);
-    if (local_err) {
-        object_property_del(container_get(object_get_root(), "/objects"),
-                            id, &error_abort);
+    object_add(type, id, pdict, opts_get_visitor(ov), &err);
+    if (err) {
         goto out;
     }
+    visit_end_struct(opts_get_visitor(ov), &err);
+    if (err) {
+        qmp_object_del(id, NULL);
+    }
+
 out:
-    object_unref(obj);
-    if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
+    opts_visitor_cleanup(ov);
+
+    QDECREF(pdict);
+    g_free(id);
+    g_free(type);
+    g_free(dummy);
+    if (err) {
+        qerror_report_err(err);
         return -1;
     }
     return 0;
-- 
MST

  parent reply	other threads:[~2014-06-18 16:20 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 16:15 [Qemu-devel] [PULL v2 000/106] pc, pci, virtio, hotplug fixes, enhancements Michael S. Tsirkin
2014-06-18 16:15 ` [Qemu-devel] [PULL v2 001/106] pc: create custom generic PC machine type Michael S. Tsirkin
2014-06-18 16:15 ` [Qemu-devel] [PULL v2 002/106] pc: ACPI BIOS: use enum for defining memory affinity flags Michael S. Tsirkin
2014-06-18 16:15 ` [Qemu-devel] [PULL v2 003/106] object_add: allow completion handler to get canonical path Michael S. Tsirkin
2014-06-18 16:15 ` [Qemu-devel] [PULL v2 004/106] vl.c: daemonize before guest memory allocation Michael S. Tsirkin
2014-06-18 16:15 ` [Qemu-devel] [PULL v2 005/106] add memdev backend infrastructure Michael S. Tsirkin
2014-06-18 16:15 ` [Qemu-devel] [PULL v2 007/106] qdev: hotplug for bus-less devices Michael S. Tsirkin
2014-06-18 16:15 ` [Qemu-devel] [PULL v2 008/106] qdev: expose DeviceState.hotplugged field as a property Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 009/106] pc: implement pc-dimm device abstraction Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 010/106] memory: add memory_region_is_mapped() API Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 011/106] pc-dimm: do not allow setting an in-use memdev Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 012/106] pc: initialize memory hotplug address space Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 013/106] pc: exit QEMU if number of slots more than supported 256 Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 014/106] pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 015/106] pc: exit QEMU if compat machine doesn't support memory hotlpug Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 016/106] pc: add memory hotplug handler to PC_MACHINE Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 017/106] pc-dimm: add busy address check and address auto-allocation Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 018/106] pc-dimm: add busy slot check and slot auto-allocation Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 019/106] acpi: rename cpu_hotplug_defs.h to pc-hotplug.h Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 020/106] acpi: memory hotplug ACPI hardware implementation Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 021/106] trace: add acpi memory hotplug IO region events Michael S. Tsirkin
2014-06-18 16:16 ` [Qemu-devel] [PULL v2 022/106] trace: pc: add PC_DIMM slot & address allocation Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 023/106] acpi:piix4: allow plug/unlug callbacks handle not only PCI devices Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 024/106] acpi:piix4: add memory hotplug handling Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 025/106] pc: ich9 lpc: make it work with global/compat properties Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 026/106] acpi:ich9: add memory hotplug handling Michael S. Tsirkin
2014-06-24 16:44   ` [Qemu-devel] per-machine vs per-qemu-version compat_props macros (was Re: acpi:ich9: add memory hotplug handling) Eduardo Habkost
2014-06-24 16:47     ` Peter Maydell
2014-06-24 17:55       ` Eduardo Habkost
2014-06-24 19:13         ` Marcel Apfelbaum
2014-06-24 22:30         ` Peter Maydell
2014-06-25  0:18           ` Eduardo Habkost
2014-06-25  1:31         ` Eduardo Habkost
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 027/106] pc: migrate piix4 & ich9 MemHotplugState Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 028/106] pc: add acpi-device link to PCMachineState Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 029/106] pc: propagate memory hotplug event to ACPI device Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 030/106] pc: ACPI BIOS: implement memory hotplug interface Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 031/106] pc: add "hotplug-memory-region-size" property to PC_MACHINE Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 032/106] pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 033/106] pc: ACPI BIOS: make GPE.3 handle memory hotplug event on PIIX and Q35 machines Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 034/106] acpi: update generated files Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 035/106] acpi-test: update expected tables Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 036/106] virtio: Drop superfluous conditionals around g_free() Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 037/106] virtio: Drop superfluous conditionals around g_strdup() Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 038/106] ich: get rid of spaces in type name Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 039/106] pc: q35: acpi: report error to user on unsupported unplug request Michael S. Tsirkin
2014-06-18 16:17 ` [Qemu-devel] [PULL v2 040/106] migration: export SELF_ANNOUNCE_ROUNDS Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 041/106] migration: introduce self_announce_delay() Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 042/106] virtio-net: announce self by guest Michael S. Tsirkin
2014-06-18 16:18 ` [PULL v2 043/106] Add kvm_eventfds_enabled function Michael S. Tsirkin
2014-06-18 16:18   ` [Qemu-devel] " Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 044/106] Add chardev API qemu_chr_fe_read_all Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 045/106] Add chardev API qemu_chr_fe_set_msgfds Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 046/106] Add chardev API qemu_chr_fe_get_msgfds Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 047/106] Add G_IO_HUP handler for socket chardev Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 048/106] vhost: add vhost_get_features and vhost_ack_features Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 049/106] vhost_net should call the poll callback only when it is set Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 050/106] Refactor virtio-net to use generic get_vhost_net Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 051/106] vhost_net_init will use VhostNetOptions to get all its arguments Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 052/106] Add vhost_ops to vhost_dev struct and replace all relevant ioctls Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 053/106] Add vhost-backend and VhostBackendType Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 054/106] Add vhost-user as a vhost backend Michael S. Tsirkin
2014-06-18 16:18 ` [Qemu-devel] [PULL v2 055/106] vhost-net: vhost-user feature bits support Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 056/106] Add new vhost-user netdev backend Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 057/106] Add the vhost-user netdev backend to the command line Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 058/106] Add vhost-user protocol documentation Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 059/106] libqemustub: add stubs to be able to use qemu-char.c Michael S. Tsirkin
2014-06-23  6:15   ` Riku Voipio
2014-06-23  7:20     ` Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 060/106] Add qtest for vhost-user Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 061/106] NUMA: move numa related code to new file numa.c Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 062/106] NUMA: check if the total numa memory size is equal to ram_size Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 063/106] NUMA: Add numa_info structure to contain numa nodes info Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 064/106] NUMA: convert -numa option to use OptsVisitor Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 065/106] NUMA: expand MAX_NODES from 64 to 128 Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 066/106] man: improve -numa doc Michael S. Tsirkin
2014-06-18 16:19 ` [Qemu-devel] [PULL v2 067/106] qmp: improve error reporting for -object and object-add Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 068/106] numa: introduce memory_region_allocate_system_memory Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 069/106] memory: reorganize file-based allocation Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 070/106] memory: move preallocation code out of exec.c Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 071/106] memory: move RAM_PREALLOC_MASK to exec.c, rename Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 072/106] configure: add Linux libnuma detection Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 073/106] Introduce signed range Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 074/106] qom: introduce object_property_get_enum and object_property_get_uint16List Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 075/106] numa: add -numa node, memdev= option Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 076/106] memory: move mem_path handling to memory_region_allocate_system_memory Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 077/106] memory: add error propagation to file-based RAM allocation Michael S. Tsirkin
2014-06-18 16:20 ` Michael S. Tsirkin [this message]
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 079/106] pc: pass MachineState to pc_memory_init Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 080/106] backend:hostmem: replace hostmemory with host_memory Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 081/106] hostmem: separate allocation from UserCreatable complete method Michael S. Tsirkin
2014-06-18 16:20 ` [Qemu-devel] [PULL v2 082/106] hostmem: add file-based HostMemoryBackend Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 083/106] hostmem: add merge and dump properties Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 084/106] hostmem: allow preallocation of any memory region Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 085/106] hostmem: add property to map memory with MAP_SHARED Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 086/106] hostmem: add properties for NUMA memory policy Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 087/106] qmp: add query-memdev Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 088/106] hmp: add info memdev Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 089/106] tests: fix memory leak in test of string input visitor Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 090/106] qapi: make string input visitor parse int list Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 091/106] qapi: make string output " Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 092/106] qapi: fix build on glib < 2.28 Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 093/106] qdev: reorganize error reporting in bus_set_realized Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 094/106] qdev: recursively unrealize devices when unrealizing bus Michael S. Tsirkin
2014-06-18 16:21 ` [Qemu-devel] [PULL v2 095/106] qmp: clean out whitespace Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 096/106] pc: acpi: do not hardcode preprocessor Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 097/106] numa: handle mmaped memory allocation failure correctly Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 098/106] qmp: add query-memory-devices command Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 099/106] acpi: introduce TYPE_ACPI_DEVICE_IF interface Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 100/106] acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 101/106] qmp: add query-acpi-ospm-status command Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 102/106] qmp: add ACPI_DEVICE_OST event handling Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 103/106] acpi: rephrase comment Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 104/106] qapi: fix input visitor bugs Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 105/106] tests: simplify code Michael S. Tsirkin
2014-06-18 16:22 ` [Qemu-devel] [PULL v2 106/106] qapi/string-output-visitor: fix bugs Michael S. Tsirkin
2014-06-18 17:25 ` [Qemu-devel] [PULL v2 006/106] vl.c: extend -m option to support options for memory hotplug Michael S. Tsirkin
2014-06-18 17:48 ` [Qemu-devel] [PULL v2 000/106] pc, pci, virtio, hotplug fixes, enhancements Michael S. Tsirkin

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=1403108034-32054-79-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 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.