small cleanups for pbs-restore

Add trailing newline to two error messages, and drop an extra
unconditional `qdict_put_str(options, "driver", format);`
Besides that it's just formatting.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-05-30 15:24:11 +02:00
parent 4e74eca7ed
commit c6979241f1
2 changed files with 31 additions and 35 deletions

View File

@ -6,8 +6,8 @@ Subject: [PATCH] PVE-Backup: pbs-restore - new command to restore from proxmox
--- ---
Makefile | 4 +- Makefile | 4 +-
pbs-restore.c | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++ pbs-restore.c | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 211 insertions(+), 1 deletion(-) 2 files changed, 209 insertions(+), 1 deletion(-)
create mode 100644 pbs-restore.c create mode 100644 pbs-restore.c
diff --git a/Makefile b/Makefile diff --git a/Makefile b/Makefile
@ -34,10 +34,10 @@ index dbd9542ae4..7c1fb58e18 100644
diff --git a/pbs-restore.c b/pbs-restore.c diff --git a/pbs-restore.c b/pbs-restore.c
new file mode 100644 new file mode 100644
index 0000000000..f65de8b890 index 0000000000..0b24e35403
--- /dev/null --- /dev/null
+++ b/pbs-restore.c +++ b/pbs-restore.c
@@ -0,0 +1,208 @@ @@ -0,0 +1,206 @@
+/* +/*
+ * Qemu image restore helper for Proxmox Backup + * Qemu image restore helper for Proxmox Backup
+ * + *
@ -124,7 +124,7 @@ index 0000000000..f65de8b890
+ +
+ error_init(argv[0]); + error_init(argv[0]);
+ +
+ for(;;) { + for (;;) {
+ static const struct option long_options[] = { + static const struct option long_options[] = {
+ {"help", no_argument, 0, 'h'}, + {"help", no_argument, 0, 'h'},
+ {"skip-zero", no_argument, 0, 'S'}, + {"skip-zero", no_argument, 0, 'S'},
@ -138,31 +138,31 @@ index 0000000000..f65de8b890
+ if (c == -1) { + if (c == -1) {
+ break; + break;
+ } + }
+ switch(c) { + switch (c) {
+ case ':': + case ':':
+ fprintf(stderr, "missing argument for option '%s'", argv[optind - 1]); + fprintf(stderr, "missing argument for option '%s'\n", argv[optind - 1]);
+ return -1; + return -1;
+ case '?': + case '?':
+ fprintf(stderr, "unrecognized option '%s'", argv[optind - 1]); + fprintf(stderr, "unrecognized option '%s'\n", argv[optind - 1]);
+ return -1; + return -1;
+ case 'f': + case 'f':
+ format = g_strdup(argv[optind - 1]); + format = g_strdup(argv[optind - 1]);
+ break; + break;
+ case 'r': + case 'r':
+ repository = g_strdup(argv[optind - 1]); + repository = g_strdup(argv[optind - 1]);
+ break; + break;
+ case 'k': + case 'k':
+ keyfile = g_strdup(argv[optind - 1]); + keyfile = g_strdup(argv[optind - 1]);
+ break; + break;
+ case 'v': + case 'v':
+ verbose = true; + verbose = true;
+ break; + break;
+ case 'S': + case 'S':
+ skip_zero = true; + skip_zero = true;
+ break; + break;
+ case 'h': + case 'h':
+ help(); + help();
+ return 0; + return 0;
+ } + }
+ } + }
+ +
@ -206,7 +206,6 @@ index 0000000000..f65de8b890
+ } + }
+ +
+ QDict *options = qdict_new(); + QDict *options = qdict_new();
+ qdict_put_str(options, "driver", format);
+ +
+ if (format) { + if (format) {
+ qdict_put_str(options, "driver", format); + qdict_put_str(options, "driver", format);
@ -214,14 +213,13 @@ index 0000000000..f65de8b890
+ +
+ Error *local_err = NULL; + Error *local_err = NULL;
+ int flags = BDRV_O_RDWR; + int flags = BDRV_O_RDWR;
+
+ BlockBackend *blk = blk_new_open(target, NULL, options, flags, &local_err); + BlockBackend *blk = blk_new_open(target, NULL, options, flags, &local_err);
+ if (!blk) { + if (!blk) {
+ fprintf(stderr, "%s\n", error_get_pretty(local_err)); + fprintf(stderr, "%s\n", error_get_pretty(local_err));
+ return -1; + return -1;
+ } + }
+ +
+ CallbackData *callback_data = calloc(sizeof( CallbackData), 1); + CallbackData *callback_data = calloc(sizeof(CallbackData), 1);
+ +
+ callback_data->target = blk; + callback_data->target = blk;
+ callback_data->skip_zero = skip_zero; + callback_data->skip_zero = skip_zero;

View File

@ -3,8 +3,6 @@ From: Kevin Wolf <kwolf@redhat.com>
Date: Wed, 27 May 2020 11:33:20 +0200 Date: Wed, 27 May 2020 11:33:20 +0200
Subject: [PATCH] util/async: Add aio_co_reschedule_self() Subject: [PATCH] util/async: Add aio_co_reschedule_self()
From: Kevin Wolf <kwolf@redhat.com>
Add a function that can be used to move the currently running coroutine Add a function that can be used to move the currently running coroutine
to a different AioContext (and therefore potentially a different to a different AioContext (and therefore potentially a different
thread). thread).