]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0053-pbs-namespace-support.patch
update submodule and patches to 7.1.0
[pve-qemu.git] / debian / patches / pve / 0053-pbs-namespace-support.patch
CommitLineData
58a5492e
WB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Tue, 26 Apr 2022 16:06:28 +0200
4Subject: [PATCH] pbs: namespace support
5
6Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7---
8 block/monitor/block-hmp-cmds.c | 1 +
9 block/pbs.c | 25 +++++++++++++++++++++----
10 pbs-restore.c | 19 ++++++++++++++++---
11 pve-backup.c | 6 +++++-
539e333e
DC
12 qapi/block-core.json | 5 ++++-
13 5 files changed, 47 insertions(+), 9 deletions(-)
58a5492e
WB
14
15diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
dc9827a6 16index 4c799f00d9..0502f42be6 100644
58a5492e
WB
17--- a/block/monitor/block-hmp-cmds.c
18+++ b/block/monitor/block-hmp-cmds.c
19@@ -1041,6 +1041,7 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
20 false, NULL, // PBS key_password
21 false, NULL, // PBS master_keyfile
22 false, NULL, // PBS fingerprint
23+ false, NULL, // PBS backup-ns
24 false, NULL, // PBS backup-id
25 false, 0, // PBS backup-time
26 false, false, // PBS use-dirty-bitmap
27diff --git a/block/pbs.c b/block/pbs.c
28index c5eb4d5bad..7471e2ef9d 100644
29--- a/block/pbs.c
30+++ b/block/pbs.c
31@@ -14,6 +14,7 @@
32 #include <proxmox-backup-qemu.h>
33
34 #define PBS_OPT_REPOSITORY "repository"
35+#define PBS_OPT_NAMESPACE "namespace"
36 #define PBS_OPT_SNAPSHOT "snapshot"
37 #define PBS_OPT_ARCHIVE "archive"
38 #define PBS_OPT_KEYFILE "keyfile"
39@@ -27,6 +28,7 @@ typedef struct {
40 int64_t length;
41
42 char *repository;
43+ char *namespace;
44 char *snapshot;
45 char *archive;
46 } BDRVPBSState;
47@@ -40,6 +42,11 @@ static QemuOptsList runtime_opts = {
48 .type = QEMU_OPT_STRING,
49 .help = "The server address and repository to connect to.",
50 },
51+ {
52+ .name = PBS_OPT_NAMESPACE,
53+ .type = QEMU_OPT_STRING,
54+ .help = "Optional: The snapshot's namespace.",
55+ },
56 {
57 .name = PBS_OPT_SNAPSHOT,
58 .type = QEMU_OPT_STRING,
59@@ -76,7 +83,7 @@ static QemuOptsList runtime_opts = {
60
61
62 // filename format:
63-// pbs:repository=<repo>,snapshot=<snap>,password=<pw>,key_password=<kpw>,fingerprint=<fp>,archive=<archive>
64+// pbs:repository=<repo>,namespace=<ns>,snapshot=<snap>,password=<pw>,key_password=<kpw>,fingerprint=<fp>,archive=<archive>
65 static void pbs_parse_filename(const char *filename, QDict *options,
66 Error **errp)
67 {
68@@ -112,6 +119,7 @@ static int pbs_open(BlockDriverState *bs, QDict *options, int flags,
69 s->archive = g_strdup(qemu_opt_get(opts, PBS_OPT_ARCHIVE));
70 const char *keyfile = qemu_opt_get(opts, PBS_OPT_KEYFILE);
71 const char *password = qemu_opt_get(opts, PBS_OPT_PASSWORD);
72+ const char *namespace = qemu_opt_get(opts, PBS_OPT_NAMESPACE);
73 const char *fingerprint = qemu_opt_get(opts, PBS_OPT_FINGERPRINT);
74 const char *key_password = qemu_opt_get(opts, PBS_OPT_ENCRYPTION_PASSWORD);
75
76@@ -124,9 +132,12 @@ static int pbs_open(BlockDriverState *bs, QDict *options, int flags,
77 if (!key_password) {
78 key_password = getenv("PBS_ENCRYPTION_PASSWORD");
79 }
80+ if (namespace) {
81+ s->namespace = g_strdup(namespace);
82+ }
83
84 /* connect to PBS server in read mode */
85- s->conn = proxmox_restore_new(s->repository, s->snapshot, password,
86+ s->conn = proxmox_restore_new_ns(s->repository, s->snapshot, s->namespace, password,
87 keyfile, key_password, fingerprint, &pbs_error);
88
89 /* invalidates qemu_opt_get char pointers from above */
90@@ -171,6 +182,7 @@ static int pbs_file_open(BlockDriverState *bs, QDict *options, int flags,
91 static void pbs_close(BlockDriverState *bs) {
92 BDRVPBSState *s = bs->opaque;
93 g_free(s->repository);
94+ g_free(s->namespace);
95 g_free(s->snapshot);
96 g_free(s->archive);
97 proxmox_restore_disconnect(s->conn);
98@@ -252,8 +264,13 @@ static coroutine_fn int pbs_co_pwritev(BlockDriverState *bs,
99 static void pbs_refresh_filename(BlockDriverState *bs)
100 {
101 BDRVPBSState *s = bs->opaque;
102- snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s(%s)",
103- s->repository, s->snapshot, s->archive);
104+ if (s->namespace) {
105+ snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s:%s(%s)",
106+ s->repository, s->namespace, s->snapshot, s->archive);
107+ } else {
108+ snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s(%s)",
109+ s->repository, s->snapshot, s->archive);
110+ }
111 }
112
113 static const char *const pbs_strong_runtime_opts[] = {
114diff --git a/pbs-restore.c b/pbs-restore.c
5b15e2ec 115index 2f834cf42e..f03d9bab8d 100644
58a5492e
WB
116--- a/pbs-restore.c
117+++ b/pbs-restore.c
5b15e2ec 118@@ -29,7 +29,7 @@
58a5492e
WB
119 static void help(void)
120 {
121 const char *help_msg =
122- "usage: pbs-restore [--repository <repo>] snapshot archive-name target [command options]\n"
123+ "usage: pbs-restore [--repository <repo>] [--ns namespace] snapshot archive-name target [command options]\n"
124 ;
125
126 printf("%s", help_msg);
5b15e2ec 127@@ -77,6 +77,7 @@ int main(int argc, char **argv)
58a5492e
WB
128 Error *main_loop_err = NULL;
129 const char *format = "raw";
130 const char *repository = NULL;
131+ const char *backup_ns = NULL;
132 const char *keyfile = NULL;
133 int verbose = false;
134 bool skip_zero = false;
5b15e2ec 135@@ -90,6 +91,7 @@ int main(int argc, char **argv)
58a5492e
WB
136 {"verbose", no_argument, 0, 'v'},
137 {"format", required_argument, 0, 'f'},
138 {"repository", required_argument, 0, 'r'},
139+ {"ns", required_argument, 0, 'n'},
140 {"keyfile", required_argument, 0, 'k'},
141 {0, 0, 0, 0}
142 };
5b15e2ec 143@@ -110,6 +112,9 @@ int main(int argc, char **argv)
58a5492e
WB
144 case 'r':
145 repository = g_strdup(argv[optind - 1]);
146 break;
147+ case 'n':
148+ backup_ns = g_strdup(argv[optind - 1]);
149+ break;
150 case 'k':
151 keyfile = g_strdup(argv[optind - 1]);
152 break;
5b15e2ec 153@@ -160,8 +165,16 @@ int main(int argc, char **argv)
58a5492e
WB
154 fprintf(stderr, "connecting to repository '%s'\n", repository);
155 }
156 char *pbs_error = NULL;
157- ProxmoxRestoreHandle *conn = proxmox_restore_new(
158- repository, snapshot, password, keyfile, key_password, fingerprint, &pbs_error);
159+ ProxmoxRestoreHandle *conn = proxmox_restore_new_ns(
160+ repository,
161+ snapshot,
162+ backup_ns,
163+ password,
164+ keyfile,
165+ key_password,
166+ fingerprint,
167+ &pbs_error
168+ );
169 if (conn == NULL) {
170 fprintf(stderr, "restore failed: %s\n", pbs_error);
171 return -1;
172diff --git a/pve-backup.c b/pve-backup.c
173index 9f6c04a512..f6a5f8c785 100644
174--- a/pve-backup.c
175+++ b/pve-backup.c
176@@ -10,6 +10,8 @@
177 #include "qapi/qmp/qerror.h"
178 #include "qemu/cutils.h"
179
180+#include <proxmox-backup-qemu.h>
181+
182 /* PVE backup state and related function */
183
184 /*
185@@ -535,6 +537,7 @@ UuidInfo coroutine_fn *qmp_backup(
186 bool has_key_password, const char *key_password,
187 bool has_master_keyfile, const char *master_keyfile,
188 bool has_fingerprint, const char *fingerprint,
189+ bool has_backup_ns, const char *backup_ns,
190 bool has_backup_id, const char *backup_id,
191 bool has_backup_time, int64_t backup_time,
192 bool has_use_dirty_bitmap, bool use_dirty_bitmap,
193@@ -674,8 +677,9 @@ UuidInfo coroutine_fn *qmp_backup(
194 firewall_name = "fw.conf";
195
196 char *pbs_err = NULL;
197- pbs = proxmox_backup_new(
198+ pbs = proxmox_backup_new_ns(
199 backup_file,
200+ has_backup_ns ? backup_ns : NULL,
201 backup_id,
202 backup_time,
203 dump_cb_block_size,
204diff --git a/qapi/block-core.json b/qapi/block-core.json
5b15e2ec 205index fc8a125451..cc2ead0b75 100644
58a5492e
WB
206--- a/qapi/block-core.json
207+++ b/qapi/block-core.json
5b15e2ec 208@@ -817,6 +817,8 @@
58a5492e
WB
209 #
210 # @fingerprint: server cert fingerprint (optional for format 'pbs')
211 #
212+# @backup-ns: backup namespace (required for format 'pbs')
213+#
214 # @backup-id: backup ID (required for format 'pbs')
215 #
216 # @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
5b15e2ec 217@@ -836,6 +838,7 @@
58a5492e
WB
218 '*key-password': 'str',
219 '*master-keyfile': 'str',
220 '*fingerprint': 'str',
221+ '*backup-ns': 'str',
222 '*backup-id': 'str',
223 '*backup-time': 'int',
224 '*use-dirty-bitmap': 'bool',
5b15e2ec 225@@ -3282,7 +3285,7 @@
539e333e
DC
226 { 'struct': 'BlockdevOptionsPbs',
227 'data': { 'repository': 'str', 'snapshot': 'str', 'archive': 'str',
228 '*keyfile': 'str', '*password': 'str', '*fingerprint': 'str',
229- '*key_password': 'str' } }
230+ '*key_password': 'str', '*namespace': 'str' } }
231
232 ##
233 # @BlockdevOptionsNVMe: