From nobody Tue Feb 10 19:14:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571317576; cv=none; d=zoho.com; s=zohoarc; b=JrJhM9Y/5i/s9EomSUDoSKkdQ+yXPYdE2WictrFiOHYAT9VmvbAp1zR+LUHG3lKKG5Bjc/V5ALLh0Y3r2mfo+xJnerHiP2qM4H0szYahbbIUXdHw5+zn/0lnet4jR2F9KmGAeamF0+AVMmpxmwzwLta/QVFKFoRaJZn64AX8ZOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571317576; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XrJeutWJ1+B92ZIe88TNK9LEJB9dJY/lQmq1pNQ1kOU=; b=JUrJY06AjVnVOPndsVFanBl8AkoCvx8Ylz7E6xORBrdlN/qhS82TPz5cLO/dsghA07ycixiUfmn+oDAb8AYUc37Hlr1mBOZSLJQGZ6falqCjeMCFFMNSDdojXIcQebK3XESBMtU3ycRV2SNE4NiI6wWlk2RaTWBz+oCGr6qdRMM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571317576664882.7937740414833; Thu, 17 Oct 2019 06:06:16 -0700 (PDT) Received: from localhost ([::1]:46828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5Tq-0002LQ-Sr for importer@patchew.org; Thu, 17 Oct 2019 09:06:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59763) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5Rt-0000OL-C4 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:04:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5Rs-0008J7-1S for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:04:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48966) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iL5Ro-0008Hc-VK; Thu, 17 Oct 2019 09:04:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BC4A796ED; Thu, 17 Oct 2019 13:04:08 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-24.ams2.redhat.com [10.36.117.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD2F11001938; Thu, 17 Oct 2019 13:04:06 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Subject: [RFC PATCH 01/18] qemu-storage-daemon: Add barebone tool Date: Thu, 17 Oct 2019 15:01:47 +0200 Message-Id: <20191017130204.16131-2-kwolf@redhat.com> In-Reply-To: <20191017130204.16131-1-kwolf@redhat.com> References: <20191017130204.16131-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 17 Oct 2019 13:04:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This adds a new binary qemu-storage-daemon that doesn't yet do more than some typical initialisation for tools and parsing the basic command options --version, --help and --trace. Signed-off-by: Kevin Wolf --- configure | 2 +- qemu-storage-daemon.c | 141 ++++++++++++++++++++++++++++++++++++++++++ Makefile | 1 + 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 qemu-storage-daemon.c diff --git a/configure b/configure index 08ca4bcb46..bb3d55fb25 100755 --- a/configure +++ b/configure @@ -6034,7 +6034,7 @@ tools=3D"" if test "$want_tools" =3D "yes" ; then tools=3D"qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools" if [ "$linux" =3D "yes" -o "$bsd" =3D "yes" -o "$solaris" =3D "yes" ] ; = then - tools=3D"qemu-nbd\$(EXESUF) $tools" + tools=3D"qemu-nbd\$(EXESUF) qemu-storage-daemon\$(EXESUF) $tools" fi if [ "$ivshmem" =3D "yes" ]; then tools=3D"ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools" diff --git a/qemu-storage-daemon.c b/qemu-storage-daemon.c new file mode 100644 index 0000000000..a251dc255c --- /dev/null +++ b/qemu-storage-daemon.c @@ -0,0 +1,141 @@ +/* + * QEMU storage daemon + * + * Copyright (c) 2019 Kevin Wolf + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" + +#include "block/block.h" +#include "crypto/init.h" + +#include "qapi/error.h" +#include "qemu-common.h" +#include "qemu-version.h" +#include "qemu/config-file.h" +#include "qemu/error-report.h" +#include "qemu/log.h" +#include "qemu/main-loop.h" +#include "qemu/module.h" + +#include "trace/control.h" + +#include + +static void help(void) +{ + printf( +"Usage: %s [options]\n" +"QEMU storage daemon\n" +"\n" +" -h, --help display this help and exit\n" +" -T, --trace [[enable=3D]][,events=3D][,file=3D]\n" +" specify tracing options\n" +" -V, --version output version information and exit\n" +"\n" +QEMU_HELP_BOTTOM "\n", + error_get_progname()); +} + +static int process_options(int argc, char *argv[], Error **errp) +{ + int c; + char *trace_file =3D NULL; + int ret =3D -EINVAL; + + static const struct option long_options[] =3D { + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, + {"trace", required_argument, NULL, 'T'}, + {0, 0, 0, 0} + }; + + while ((c =3D getopt_long(argc, argv, ":hT:V", long_options, NULL)) != =3D -1) { + switch (c) { + case '?': + error_setg(errp, "Unknown option '%s'", argv[optind - 1]); + goto out; + case ':': + error_setg(errp, "Missing option argument for '%s'", + argv[optind - 1]); + goto out; + case 'h': + help(); + exit(EXIT_SUCCESS); + case 'V': + printf("qemu-storage-daemon version " + QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n"); + exit(EXIT_SUCCESS); + case 'T': + g_free(trace_file); + trace_file =3D trace_opt_parse(optarg); + break; + } + } + if (optind !=3D argc) { + error_setg(errp, "Unexpected argument: %s", argv[optind]); + goto out; + } + + if (!trace_init_backends()) { + error_setg(errp, "Could not initialize trace backends"); + goto out; + } + trace_init_file(trace_file); + qemu_set_log(LOG_TRACE); + + ret =3D 0; +out: + g_free(trace_file); + return ret; +} + +int main(int argc, char *argv[]) +{ + Error *local_err =3D NULL; + int ret; + +#ifdef CONFIG_POSIX + signal(SIGPIPE, SIG_IGN); +#endif + + error_init(argv[0]); + qemu_init_exec_dir(argv[0]); + + module_call_init(MODULE_INIT_QOM); + module_call_init(MODULE_INIT_TRACE); + qemu_add_opts(&qemu_trace_opts); + qcrypto_init(&error_fatal); + bdrv_init(); + + if (qemu_init_main_loop(&local_err)) { + error_report_err(local_err); + return EXIT_FAILURE; + } + + ret =3D process_options(argc, argv, &local_err); + if (ret < 0) { + error_report_err(local_err); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/Makefile b/Makefile index 30f0abfb42..76338d0ab4 100644 --- a/Makefile +++ b/Makefile @@ -558,6 +558,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) =20 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS) =20 --=20 2.20.1