adding 2.5 pve patches and left-over extra fixes
[pve-qemu-kvm.git] / debian / patches / pve / 0031-vma-add-firewall.patch
blobbf8962517a2407910b63425da927f9ad3c3110c0
1 From b71180331cfe834000b469770c879a1277dbc273 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 9 Dec 2015 16:51:23 +0100
4 Subject: [PATCH 31/41] vma: add firewall
6 ---
7 blockdev.c | 78 ++++++++++++++++++++++++++++++++++----------------------
8 hmp.c | 2 +-
9 qapi-schema.json | 1 +
10 qmp-commands.hx | 2 +-
11 4 files changed, 51 insertions(+), 32 deletions(-)
13 diff --git a/blockdev.c b/blockdev.c
14 index 4d182d6..5e1234b 100644
15 --- a/blockdev.c
16 +++ b/blockdev.c
17 @@ -3056,6 +3056,44 @@ void qmp_backup_cancel(Error **errp)
21 +static int config_to_vma(const char *file, BackupFormat format,
22 + const char *backup_dir, VmaWriter *vmaw,
23 + Error **errp)
25 + char *cdata = NULL;
26 + gsize clen = 0;
27 + GError *err = NULL;
28 + if (!g_file_get_contents(file, &cdata, &clen, &err)) {
29 + error_setg(errp, "unable to read file '%s'", file);
30 + return 1;
31 + }
33 + char *basename = g_path_get_basename(file);
35 + if (format == BACKUP_FORMAT_VMA) {
36 + if (vma_writer_add_config(vmaw, basename, cdata, clen) != 0) {
37 + error_setg(errp, "unable to add %s config data to vma archive", file);
38 + g_free(cdata);
39 + g_free(basename);
40 + return 1;
41 + }
42 + } else if (format == BACKUP_FORMAT_DIR) {
43 + char config_path[PATH_MAX];
44 + snprintf(config_path, PATH_MAX, "%s/%s", backup_dir, basename);
45 + if (!g_file_set_contents(config_path, cdata, clen, &err)) {
46 + error_setg(errp, "unable to write config file '%s'", config_path);
47 + g_free(cdata);
48 + g_free(basename);
49 + return 1;
50 + }
51 + }
53 + g_free(basename);
54 + g_free(cdata);
56 + return 0;
59 static void pvebackup_run_next_job(void)
61 GList *l = backup_state.di_list;
62 @@ -3082,6 +3120,7 @@ static void pvebackup_run_next_job(void)
63 UuidInfo *qmp_backup(const char *backup_file, bool has_format,
64 BackupFormat format,
65 bool has_config_file, const char *config_file,
66 + bool has_firewall_file, const char *firewall_file,
67 bool has_devlist, const char *devlist,
68 bool has_speed, int64_t speed, Error **errp)
70 @@ -3234,38 +3273,17 @@ UuidInfo *qmp_backup(const char *backup_file, bool has_format,
72 /* add configuration file to archive */
73 if (has_config_file) {
74 - char *cdata = NULL;
75 - gsize clen = 0;
76 - GError *err = NULL;
77 - if (!g_file_get_contents(config_file, &cdata, &clen, &err)) {
78 - error_setg(errp, "unable to read file '%s'", config_file);
79 - goto err;
80 - }
82 - char *basename = g_path_get_basename(config_file);
84 - if (format == BACKUP_FORMAT_VMA) {
85 - if (vma_writer_add_config(vmaw, basename, cdata, clen) != 0) {
86 - error_setg(errp, "unable to add config data to vma archive");
87 - g_free(cdata);
88 - g_free(basename);
89 - goto err;
90 - }
91 - } else if (format == BACKUP_FORMAT_DIR) {
92 - char config_path[PATH_MAX];
93 - snprintf(config_path, PATH_MAX, "%s/%s", backup_dir, basename);
94 - if (!g_file_set_contents(config_path, cdata, clen, &err)) {
95 - error_setg(errp, "unable to write config file '%s'", config_path);
96 - g_free(cdata);
97 - g_free(basename);
98 - goto err;
99 - }
102 - g_free(basename);
103 - g_free(cdata);
104 + if(config_to_vma(config_file, format, backup_dir, vmaw, errp) != 0) {
105 + goto err;
109 + /* add firewall file to archive */
110 + if (has_firewall_file) {
111 + if(config_to_vma(firewall_file, format, backup_dir, vmaw, errp) != 0) {
112 + goto err;
115 /* initialize global backup_state now */
117 backup_state.cancel = false;
118 diff --git a/hmp.c b/hmp.c
119 index 724b5d3..a361e26 100644
120 --- a/hmp.c
121 +++ b/hmp.c
122 @@ -1518,7 +1518,7 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
123 int64_t speed = qdict_get_try_int(qdict, "speed", 0);
125 qmp_backup(backup_file, true, dir ? BACKUP_FORMAT_DIR : BACKUP_FORMAT_VMA,
126 - false, NULL, !!devlist,
127 + false, NULL, false, NULL, !!devlist,
128 devlist, qdict_haskey(qdict, "speed"), speed, &error);
130 hmp_handle_error(mon, &error);
131 diff --git a/qapi-schema.json b/qapi-schema.json
132 index 172e200..a02158e 100644
133 --- a/qapi-schema.json
134 +++ b/qapi-schema.json
135 @@ -422,6 +422,7 @@
136 { 'command': 'backup', 'data': { 'backup-file': 'str',
137 '*format': 'BackupFormat',
138 '*config-file': 'str',
139 + '*firewall-file': 'str',
140 '*devlist': 'str', '*speed': 'int' },
141 'returns': 'UuidInfo' }
143 diff --git a/qmp-commands.hx b/qmp-commands.hx
144 index 0ce913a..de07f54 100644
145 --- a/qmp-commands.hx
146 +++ b/qmp-commands.hx
147 @@ -1255,7 +1255,7 @@ EQMP
150 .name = "backup",
151 - .args_type = "backup-file:s,format:s?,config-file:F?,speed:o?,devlist:s?",
152 + .args_type = "backup-file:s,format:s?,config-file:F?,firewall-file:F?,speed:o?,devlist:s?",
153 .mhandler.cmd_new = qmp_marshal_input_backup,
157 2.1.4