From nobody Tue Nov 26 11:21:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708550231289598.6427855961172; Wed, 21 Feb 2024 13:17:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rctxb-0002Yo-M4; Wed, 21 Feb 2024 16:16:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rctxK-000252-Oe; Wed, 21 Feb 2024 16:16:43 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rctxH-0000lj-UI; Wed, 21 Feb 2024 16:16:42 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 28D744F7EC; Thu, 22 Feb 2024 00:16:45 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id D39D4869A5; Thu, 22 Feb 2024 00:16:22 +0300 (MSK) Received: (nullmailer pid 2335259 invoked by uid 1000); Wed, 21 Feb 2024 21:16:22 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-block@nongnu.org Cc: Michael Tokarev Subject: [PATCH 05/28] qemu-img: pass current cmd info into command handlers Date: Thu, 22 Feb 2024 00:15:46 +0300 Message-Id: <20240221211622.2335170-5-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1708550237118100001 Content-Type: text/plain; charset="utf-8" This info will be used to generate --help output. Signed-off-by: Michael Tokarev Reviewed-by: Daniel P. Berrang=C3=A9 --- qemu-img.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 44dbf5be4f..38ac0f1845 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -60,7 +60,7 @@ =20 typedef struct img_cmd_t { const char *name; - int (*handler)(int argc, char **argv); + int (*handler)(const struct img_cmd_t *ccmd, int argc, char **argv); } img_cmd_t; =20 enum { @@ -514,7 +514,7 @@ static int64_t cvtnum(const char *name, const char *val= ue) return cvtnum_full(name, value, 0, INT64_MAX); } =20 -static int img_create(int argc, char **argv) +static int img_create(const img_cmd_t *ccmd, int argc, char **argv) { int c; int64_t img_size =3D -1; @@ -719,7 +719,7 @@ static int collect_image_check(BlockDriverState *bs, * 3 - Check completed, image has leaked clusters, but is good otherwise * 63 - Checks are not supported by the image format */ -static int img_check(int argc, char **argv) +static int img_check(const img_cmd_t *ccmd, int argc, char **argv) { int c, ret; OutputFormat output_format =3D OFORMAT_HUMAN; @@ -951,7 +951,7 @@ static void run_block_job(BlockJob *job, Error **errp) } } =20 -static int img_commit(int argc, char **argv) +static int img_commit(const img_cmd_t *ccmd, int argc, char **argv) { int c, ret, flags; const char *filename, *fmt, *cache, *base; @@ -1358,7 +1358,7 @@ static int check_empty_sectors(BlockBackend *blk, int= 64_t offset, * 1 - Images differ * >1 - Error occurred */ -static int img_compare(int argc, char **argv) +static int img_compare(const img_cmd_t *ccmd, int argc, char **argv) { const char *fmt1 =3D NULL, *fmt2 =3D NULL, *cache, *filename1, *filena= me2; BlockBackend *blk1, *blk2; @@ -2234,7 +2234,7 @@ static void set_rate_limit(BlockBackend *blk, int64_t= rate_limit) blk_set_io_limits(blk, &cfg); } =20 -static int img_convert(int argc, char **argv) +static int img_convert(const img_cmd_t *ccmd, int argc, char **argv) { int c, bs_i, flags, src_flags =3D BDRV_O_NO_SHARE; const char *fmt =3D NULL, *out_fmt =3D NULL, *cache =3D "unsafe", @@ -3002,7 +3002,7 @@ err: return NULL; } =20 -static int img_info(int argc, char **argv) +static int img_info(const img_cmd_t *ccmd, int argc, char **argv) { int c; OutputFormat output_format =3D OFORMAT_HUMAN; @@ -3227,7 +3227,7 @@ static inline bool entry_mergeable(const MapEntry *cu= rr, const MapEntry *next) return true; } =20 -static int img_map(int argc, char **argv) +static int img_map(const img_cmd_t *ccmd, int argc, char **argv) { int c; OutputFormat output_format =3D OFORMAT_HUMAN; @@ -3376,7 +3376,7 @@ out: #define SNAPSHOT_APPLY 3 #define SNAPSHOT_DELETE 4 =20 -static int img_snapshot(int argc, char **argv) +static int img_snapshot(const img_cmd_t *ccmd, int argc, char **argv) { BlockBackend *blk; BlockDriverState *bs; @@ -3534,7 +3534,7 @@ static int img_snapshot(int argc, char **argv) return 0; } =20 -static int img_rebase(int argc, char **argv) +static int img_rebase(const img_cmd_t *ccmd, int argc, char **argv) { BlockBackend *blk =3D NULL, *blk_old_backing =3D NULL, *blk_new_backin= g =3D NULL; uint8_t *buf_old =3D NULL; @@ -4028,7 +4028,7 @@ out: return 0; } =20 -static int img_resize(int argc, char **argv) +static int img_resize(const img_cmd_t *ccmd, int argc, char **argv) { Error *err =3D NULL; int c, ret, relative; @@ -4241,7 +4241,7 @@ static int print_amend_option_help(const char *format) return 0; } =20 -static int img_amend(int argc, char **argv) +static int img_amend(const img_cmd_t *ccmd, int argc, char **argv) { Error *err =3D NULL; int c, ret =3D 0; @@ -4505,7 +4505,7 @@ static void bench_cb(void *opaque, int ret) } } =20 -static int img_bench(int argc, char **argv) +static int img_bench(const img_cmd_t *ccmd, int argc, char **argv) { int c, ret =3D 0; const char *fmt =3D NULL, *filename; @@ -4775,7 +4775,7 @@ typedef struct ImgBitmapAction { QSIMPLEQ_ENTRY(ImgBitmapAction) next; } ImgBitmapAction; =20 -static int img_bitmap(int argc, char **argv) +static int img_bitmap(const img_cmd_t *ccmd, int argc, char **argv) { Error *err =3D NULL; int c, ret =3D 1; @@ -5075,7 +5075,7 @@ static int img_dd_skip(const char *arg, return 0; } =20 -static int img_dd(int argc, char **argv) +static int img_dd(const img_cmd_t *ccmd, int argc, char **argv) { int ret =3D 0; char *arg =3D NULL; @@ -5341,7 +5341,7 @@ static void dump_json_block_measure_info(BlockMeasure= Info *info) g_string_free(str, true); } =20 -static int img_measure(int argc, char **argv) +static int img_measure(const img_cmd_t *ccmd, int argc, char **argv) { static const struct option long_options[] =3D { {"help", no_argument, 0, 'h'}, @@ -5603,7 +5603,7 @@ int main(int argc, char **argv) for (cmd =3D img_cmds; cmd->name !=3D NULL; cmd++) { if (!strcmp(cmdname, cmd->name)) { argv[0] =3D g_strdup_printf("%s %s", argv[0], cmdname); - return cmd->handler(argc, argv); + return cmd->handler(cmd, argc, argv); } } =20 --=20 2.39.2