Kevin Wolf <kw...@redhat.com> writes: > This adds a --blockdev option to the storage daemon that works the same > as the -blockdev option of the system emulator. > > In order to be able to link with blockdev.o, we also need to change > stream.o from common-obj to block-obj, which is where all other block > jobs already are. > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > qemu-storage-daemon.c | 29 +++++++++++++++++++++++++++++ > Makefile | 5 ++++- > Makefile.objs | 7 +++++++ > block/Makefile.objs | 2 +- > 4 files changed, 41 insertions(+), 2 deletions(-) > > diff --git a/qemu-storage-daemon.c b/qemu-storage-daemon.c > index 48d6af43a6..904e3c3a46 100644 > --- a/qemu-storage-daemon.c > +++ b/qemu-storage-daemon.c > @@ -28,6 +28,10 @@ > #include "crypto/init.h" > > #include "qapi/error.h" > +#include "qapi/qapi-visit-block-core.h" > +#include "qapi/qapi-commands-block-core.h" > +#include "qapi/qobject-input-visitor.h" > + > #include "qemu-common.h" > #include "qemu-version.h" > #include "qemu/config-file.h" > @@ -53,6 +57,13 @@ static void help(void) > " specify tracing options\n" > " -V, --version output version information and exit\n" > "\n" > +" --blockdev [driver=]<driver>[,node-name=<N>][,discard=ignore|unmap]\n" > +" [,cache.direct=on|off][,cache.no-flush=on|off]\n" > +" [,read-only=on|off][,auto-read-only=on|off]\n" > +" [,force-share=on|off][,detect-zeroes=on|off|unmap]\n" > +" [,driver specific parameters...]\n" > +" configure a block backend\n" > +"\n" > " --object <properties> define a QOM object such as 'secret' for\n" > " passwords and/or encryption keys\n" > "\n" > @@ -62,6 +73,7 @@ QEMU_HELP_BOTTOM "\n", > > enum { > OPTION_OBJECT = 256, > + OPTION_BLOCKDEV, > }; > > static QemuOptsList qemu_object_opts = { > @@ -82,6 +94,7 @@ static int process_options(int argc, char *argv[], Error > **errp) > static const struct option long_options[] = { > {"help", no_argument, 0, 'h'}, > {"object", required_argument, 0, OPTION_OBJECT}, > + {"blockdev", required_argument, 0, OPTION_BLOCKDEV}, > {"version", no_argument, 0, 'V'}, > {"trace", required_argument, NULL, 'T'}, > {0, 0, 0, 0} > @@ -123,6 +136,22 @@ static int process_options(int argc, char *argv[], Error > **errp) > qemu_opts_del(opts); > break; > } > + break; > + case OPTION_BLOCKDEV: > + { > + Visitor *v; > + BlockdevOptions *options; > + > + v = qobject_input_visitor_new_str(optarg, "driver", > + &error_fatal); > + > + visit_type_BlockdevOptions(v, NULL, &options, &error_fatal); > + visit_free(v); > + > + qmp_blockdev_add(options, &error_fatal); > + qapi_free_BlockdevOptions(options); > + break; > + } > } > } > if (optind != argc) {
Unlike --object, --blockdev is already QAPIfied, albeit crudely. Similar difference to vl.c as for --object: vl.c records the option for later processing, while here you process it right away. Simpler and saner. I figure you intend to do all options this way. Should you explain the difference in a commit message? A comment? [...]