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
7 blockdev.c | 78 ++++++++++++++++++++++++++++++++++----------------------
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
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,
28 + if (!g_file_get_contents(file, &cdata, &clen, &err)) {
29 + error_setg(errp, "unable to read file '%s'", file);
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);
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);
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,
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) {
77 - if (!g_file_get_contents(config_file, &cdata, &clen, &err)) {
78 - error_setg(errp, "unable to read file '%s'", config_file);
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");
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);
104 + if(config_to_vma(config_file, format, backup_dir, vmaw, errp) != 0) {
109 + /* add firewall file to archive */
110 + if (has_firewall_file) {
111 + if(config_to_vma(firewall_file, format, backup_dir, vmaw, errp) != 0) {
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
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
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
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,