qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 08/20] qemu-storage-daemon: Add --object option


From: Coiby Xu
Subject: Re: [PATCH v2 08/20] qemu-storage-daemon: Add --object option
Date: Wed, 10 Jun 2020 07:25:11 +0800

On Mon, Feb 24, 2020 at 03:29:56PM +0100, Kevin Wolf wrote:
Add a command line option to create user-creatable QOM objects.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-storage-daemon.c | 47 +++++++++++++++++++++++++++++++++++++++++++
Makefile.objs         |  2 +-
qom/Makefile.objs     |  1 +
3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/qemu-storage-daemon.c b/qemu-storage-daemon.c
index c30caaf59e..0cd8144c81 100644
--- a/qemu-storage-daemon.c
+++ b/qemu-storage-daemon.c
@@ -33,15 +33,19 @@
#include "qapi/error.h"
#include "qapi/qapi-visit-block-core.h"
#include "qapi/qapi-commands-block-core.h"
+#include "qapi/qmp/qdict.h"
#include "qapi/qobject-input-visitor.h"

#include "qemu-common.h"
#include "qemu-version.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
+#include "qemu/help_option.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
+#include "qemu/option.h"
+#include "qom/object_interfaces.h"

#include "trace/control.h"

@@ -63,12 +67,31 @@ static void help(void)
"             [,driver specific parameters...]\n"
"                         configure a block backend\n"
"\n"
+"  --object help          list object types that can be added\n"
+"  --object <type>,help   list properties for the given object type\n"
+"  --object <type>[,<property>=<value>...]\n"
+"                         create a new object of type <type>, setting\n"
+"                         properties in the order they are specified. Note\n"
+"                         that the 'id' property must be set.\n"
+"                         See the qemu(1) man page for documentation of the\n"
+"                         objects that can be added.\n"
+"\n"
QEMU_HELP_BOTTOM "\n",
    error_get_progname());
}

enum {
    OPTION_BLOCKDEV = 256,
+    OPTION_OBJECT,
+};
+
+static QemuOptsList qemu_object_opts = {
+    .name = "object",
+    .implied_opt_name = "qom-type",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
+    .desc = {
+        { }
+    },
};

I'm not sure whether qemu-storage-daemon's QMP monitor is supposed to support
`object-del` or not. If it's yes, we should add 
`qemu_add_opts(&qemu_object_opts);`,
otherwise, qemu-storage-daemon will exit with the following error,


   Unexpected error in find_list() at util/qemu-config.c:24:

The steps to reproduce this error,

  1. start qemu-storage-daemon

    ./qemu-storage-daemon --object iothread,id=iothread0 --chardev 
socket,id=qmp,path=abc,server,nowait --monitor chardev=qmp

  2. send object-del command

    echo '{ "execute": "qmp_capabilities" }'\
            '{ 'object-del', 'arguments': {'id': 'iothread0'} }'\
            '{ "execute": "quit" } ' | socat - UNIX-CONNECT:abc



reply via email to

[Prev in Thread] Current Thread [Next in Thread]