All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com,
	coiby.xu@gmail.com, mreitz@redhat.com, stefanha@redhat.com
Subject: [PATCH v2 06/20] qemu-storage-daemon: Add --blockdev option
Date: Mon, 24 Feb 2020 15:29:54 +0100	[thread overview]
Message-ID: <20200224143008.13362-7-kwolf@redhat.com> (raw)
In-Reply-To: <20200224143008.13362-1-kwolf@redhat.com>

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.

In contrast to the system emulator, qemu-storage-daemon options will be
processed in the order they are given. The user needs to take care to
refer to other objects only after defining them.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-storage-daemon.c | 31 +++++++++++++++++++++++++++++++
 Makefile              |  5 ++++-
 Makefile.objs         |  7 +++++++
 block/Makefile.objs   |  2 +-
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/qemu-storage-daemon.c b/qemu-storage-daemon.c
index fc4aef572b..c30caaf59e 100644
--- a/qemu-storage-daemon.c
+++ b/qemu-storage-daemon.c
@@ -31,6 +31,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"
@@ -52,15 +56,27 @@ 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"
 QEMU_HELP_BOTTOM "\n",
     error_get_progname());
 }
 
+enum {
+    OPTION_BLOCKDEV = 256,
+};
+
 static void process_options(int argc, char *argv[])
 {
     int c;
 
     static const struct option long_options[] = {
+        {"blockdev", required_argument, NULL, OPTION_BLOCKDEV},
         {"help", no_argument, NULL, 'h'},
         {"trace", required_argument, NULL, 'T'},
         {"version", no_argument, NULL, 'V'},
@@ -90,6 +106,21 @@ static void process_options(int argc, char *argv[])
             printf("qemu-storage-daemon version "
                    QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
             exit(EXIT_SUCCESS);
+        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;
+            }
         default:
             g_assert_not_reached();
         }
diff --git a/Makefile b/Makefile
index 44b3c8a342..750cff8d0a 100644
--- a/Makefile
+++ b/Makefile
@@ -450,6 +450,8 @@ dummy := $(call unnest-vars,, \
                 qga-vss-dll-obj-y \
                 block-obj-y \
                 block-obj-m \
+                storage-daemon-obj-y \
+                storage-daemon-obj-m \
                 crypto-obj-y \
                 qom-obj-y \
                 io-obj-y \
@@ -482,6 +484,7 @@ TARGET_DIRS_RULES := $(foreach t, all clean install, $(addsuffix /$(t), $(TARGET
 SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
 $(SOFTMMU_ALL_RULES): $(authz-obj-y)
 $(SOFTMMU_ALL_RULES): $(block-obj-y)
+$(SOFTMMU_ALL_RULES): $(storage-daemon-obj-y)
 $(SOFTMMU_ALL_RULES): $(chardev-obj-y)
 $(SOFTMMU_ALL_RULES): $(crypto-obj-y)
 $(SOFTMMU_ALL_RULES): $(io-obj-y)
@@ -573,7 +576,7 @@ qemu-img.o: qemu-img-cmds.h
 qemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
 qemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
 qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
-qemu-storage-daemon$(EXESUF): qemu-storage-daemon.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
+qemu-storage-daemon$(EXESUF): qemu-storage-daemon.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(storage-daemon-obj-y) $(COMMON_LDADDS)
 
 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
 
diff --git a/Makefile.objs b/Makefile.objs
index 26b9cff954..c7e1b36130 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -27,6 +27,13 @@ io-obj-y = io/
 
 endif # CONFIG_SOFTMMU or CONFIG_TOOLS
 
+#######################################################################
+# storage-daemon-obj-y is code used by qemu-storage-daemon (these objects are
+# used for system emulation, too, but specified separately there)
+
+storage-daemon-obj-y = block/
+storage-daemon-obj-y += blockdev.o iothread.o
+
 ######################################################################
 # Target independent part of system emulation. The long term path is to
 # suppress *all* target specific code in case of system emulation, i.e. a
diff --git a/block/Makefile.objs b/block/Makefile.objs
index e06cf0b284..cb36ae2503 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -46,7 +46,7 @@ block-obj-y += aio_task.o
 block-obj-y += backup-top.o
 block-obj-y += filter-compress.o
 
-common-obj-y += stream.o
+block-obj-y += stream.o
 
 common-obj-y += qapi-sysemu.o
 
-- 
2.20.1



  parent reply	other threads:[~2020-02-24 14:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-24 14:29 [PATCH v2 00/20] Add qemu-storage-daemon Kevin Wolf
2020-02-24 14:29 ` [PATCH v2 01/20] qemu-storage-daemon: Add barebone tool Kevin Wolf
2020-02-24 14:29 ` [PATCH v2 02/20] stubs: Add arch_type Kevin Wolf
2020-02-24 14:29 ` [PATCH v2 03/20] block: Move system emulator QMP commands to block/qapi-sysemu.c Kevin Wolf
2020-02-24 14:29 ` [PATCH v2 04/20] block: Move common QMP commands to block-core QAPI module Kevin Wolf
2020-02-24 14:29 ` [PATCH v2 05/20] block: Move sysemu QMP commands to QAPI block module Kevin Wolf
2020-02-24 14:29 ` Kevin Wolf [this message]
2020-02-24 14:29 ` [PATCH v2 07/20] qapi: Flatten object-add Kevin Wolf
2020-02-24 14:29 ` [PATCH v2 08/20] qemu-storage-daemon: Add --object option Kevin Wolf
2020-04-16  5:20   ` Coiby Xu
2020-06-09 23:25   ` Coiby Xu
2020-02-24 14:29 ` [PATCH v2 09/20] qemu-storage-daemon: Add --nbd-server option Kevin Wolf
2020-02-24 14:29 ` [PATCH v2 10/20] blockdev-nbd: Boxed argument type for nbd-server-add Kevin Wolf
2020-02-24 14:29 ` [PATCH v2 11/20] qemu-storage-daemon: Add --export option Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 12/20] qemu-storage-daemon: Add main loop Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 13/20] qemu-storage-daemon: Add --chardev option Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 14/20] stubs: Update monitor stubs for qemu-storage-daemon Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 15/20] qapi: Create 'pragma' module Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 16/20] monitor: Create QAPIfied monitor_init() Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 17/20] qmp: Fail gracefully if chardev is already in use Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 18/20] hmp: " Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 19/20] monitor: Add allow_hmp parameter to monitor_init() Kevin Wolf
2020-02-24 14:30 ` [PATCH v2 20/20] qemu-storage-daemon: Add --monitor option Kevin Wolf
2020-02-24 15:34 ` [PATCH v2 00/20] Add qemu-storage-daemon no-reply
2020-02-28 11:16 ` Stefan Hajnoczi
2020-03-03 17:00   ` Kevin Wolf

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=20200224143008.13362-7-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=coiby.xu@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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.