1 From 4e55ff68ec7aef1e2ea602890495cd862dd1161c 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 27/48] vma: add firewall
7 blockdev.c | 78 ++++++++++++++++++++++++++++++++++----------------------
10 3 files changed, 50 insertions(+), 31 deletions(-)
12 diff --git a/blockdev.c b/blockdev.c
13 index 36b4083..3b82339 100644
16 @@ -3163,6 +3163,44 @@ void qmp_backup_cancel(Error **errp)
20 +static int config_to_vma(const char *file, BackupFormat format,
21 + const char *backup_dir, VmaWriter *vmaw,
27 + if (!g_file_get_contents(file, &cdata, &clen, &err)) {
28 + error_setg(errp, "unable to read file '%s'", file);
32 + char *basename = g_path_get_basename(file);
34 + if (format == BACKUP_FORMAT_VMA) {
35 + if (vma_writer_add_config(vmaw, basename, cdata, clen) != 0) {
36 + error_setg(errp, "unable to add %s config data to vma archive", file);
41 + } else if (format == BACKUP_FORMAT_DIR) {
42 + char config_path[PATH_MAX];
43 + snprintf(config_path, PATH_MAX, "%s/%s", backup_dir, basename);
44 + if (!g_file_set_contents(config_path, cdata, clen, &err)) {
45 + error_setg(errp, "unable to write config file '%s'", config_path);
58 bool block_job_should_pause(BlockJob *job);
59 static void pvebackup_run_next_job(void)
61 @@ -3190,6 +3228,7 @@ static void pvebackup_run_next_job(void)
62 UuidInfo *qmp_backup(const char *backup_file, bool has_format,
64 bool has_config_file, const char *config_file,
65 + bool has_firewall_file, const char *firewall_file,
66 bool has_devlist, const char *devlist,
67 bool has_speed, int64_t speed, Error **errp)
69 @@ -3342,38 +3381,17 @@ UuidInfo *qmp_backup(const char *backup_file, bool has_format,
71 /* add configuration file to archive */
72 if (has_config_file) {
76 - if (!g_file_get_contents(config_file, &cdata, &clen, &err)) {
77 - error_setg(errp, "unable to read file '%s'", config_file);
81 - char *basename = g_path_get_basename(config_file);
83 - if (format == BACKUP_FORMAT_VMA) {
84 - if (vma_writer_add_config(vmaw, basename, cdata, clen) != 0) {
85 - error_setg(errp, "unable to add config data to vma archive");
90 - } else if (format == BACKUP_FORMAT_DIR) {
91 - char config_path[PATH_MAX];
92 - snprintf(config_path, PATH_MAX, "%s/%s", backup_dir, basename);
93 - if (!g_file_set_contents(config_path, cdata, clen, &err)) {
94 - error_setg(errp, "unable to write config file '%s'", config_path);
103 + if(config_to_vma(config_file, format, backup_dir, vmaw, errp) != 0) {
108 + /* add firewall file to archive */
109 + if (has_firewall_file) {
110 + if(config_to_vma(firewall_file, format, backup_dir, vmaw, errp) != 0) {
114 /* initialize global backup_state now */
116 backup_state.cancel = false;
117 diff --git a/hmp.c b/hmp.c
118 index aaf0de1..12f1f46 100644
121 @@ -1670,7 +1670,7 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
122 int64_t speed = qdict_get_try_int(qdict, "speed", 0);
124 qmp_backup(backup_file, true, dir ? BACKUP_FORMAT_DIR : BACKUP_FORMAT_VMA,
125 - false, NULL, !!devlist,
126 + false, NULL, false, NULL, !!devlist,
127 devlist, qdict_haskey(qdict, "speed"), speed, &error);
129 hmp_handle_error(mon, &error);
130 diff --git a/qapi-schema.json b/qapi-schema.json
131 index 79bfd97..6334018 100644
132 --- a/qapi-schema.json
133 +++ b/qapi-schema.json
135 { 'command': 'backup', 'data': { 'backup-file': 'str',
136 '*format': 'BackupFormat',
137 '*config-file': 'str',
138 + '*firewall-file': 'str',
139 '*devlist': 'str', '*speed': 'int' },
140 'returns': 'UuidInfo' }