4 * Copyright (c) 2003-2008 Fabrice Bellard
5 * Copyright (c) 2019 Kevin Wolf <kwolf@redhat.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 #include "qemu/osdep.h"
30 #include "block/block.h"
31 #include "crypto/init.h"
33 #include "qapi/error.h"
34 #include "qemu-common.h"
35 #include "qemu-version.h"
36 #include "qemu/config-file.h"
37 #include "qemu/error-report.h"
39 #include "qemu/main-loop.h"
40 #include "qemu/module.h"
42 #include "trace/control.h"
44 static void help(void)
47 "Usage: %s [options]\n"
48 "QEMU storage daemon\n"
50 " -h, --help display this help and exit\n"
51 " -T, --trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
52 " specify tracing options\n"
53 " -V, --version output version information and exit\n"
55 QEMU_HELP_BOTTOM
"\n",
56 error_get_progname());
59 static void process_options(int argc
, char *argv
[])
63 static const struct option long_options
[] = {
64 {"help", no_argument
, NULL
, 'h'},
65 {"trace", required_argument
, NULL
, 'T'},
66 {"version", no_argument
, NULL
, 'V'},
71 * In contrast to the system emulator, options are processed in the order
72 * they are given on the command lines. This means that things must be
73 * defined first before they can be referenced in another option.
75 while ((c
= getopt_long(argc
, argv
, "hT:V", long_options
, NULL
)) != -1) {
84 char *trace_file
= trace_opt_parse(optarg
);
85 trace_init_file(trace_file
);
90 printf("qemu-storage-daemon version "
91 QEMU_FULL_VERSION
"\n" QEMU_COPYRIGHT
"\n");
94 g_assert_not_reached();
98 error_report("Unexpected argument: %s", argv
[optind
]);
103 int main(int argc
, char *argv
[])
106 signal(SIGPIPE
, SIG_IGN
);
110 qemu_init_exec_dir(argv
[0]);
112 module_call_init(MODULE_INIT_QOM
);
113 module_call_init(MODULE_INIT_TRACE
);
114 qemu_add_opts(&qemu_trace_opts
);
115 qcrypto_init(&error_fatal
);
118 if (!trace_init_backends()) {
121 qemu_set_log(LOG_TRACE
);
123 qemu_init_main_loop(&error_fatal
);
124 process_options(argc
, argv
);