1 Index: qemu-kvm-dev/qapi-schema.json
2 ===================================================================
3 --- qemu-kvm-dev.orig/qapi-schema.json
4 +++ qemu-kvm-dev/qapi-schema.json
6 { 'command': 'backup', 'data': { 'backup-file': 'str',
7 '*format': 'BackupFormat',
9 + '*firewall-file': 'str',
10 '*devlist': 'str', '*speed': 'int' },
11 'returns': 'UuidInfo' }
13 Index: qemu-kvm-dev/qmp-commands.hx
14 ===================================================================
15 --- qemu-kvm-dev.orig/qmp-commands.hx
16 +++ qemu-kvm-dev/qmp-commands.hx
17 @@ -1204,7 +1204,7 @@ EQMP
21 - .args_type = "backup-file:s,format:s?,config-file:F?,speed:o?,devlist:s?",
22 + .args_type = "backup-file:s,format:s?,config-file:F?,firewall-file:F?,speed:o?,devlist:s?",
23 .mhandler.cmd_new = qmp_marshal_input_backup,
26 Index: qemu-kvm-dev/blockdev.c
27 ===================================================================
28 --- qemu-kvm-dev.orig/blockdev.c
29 +++ qemu-kvm-dev/blockdev.c
30 @@ -2457,6 +2457,44 @@ void qmp_backup_cancel(Error **errp)
34 +static int config_to_vma(const char *file, BackupFormat format,
35 + const char *backup_dir, VmaWriter *vmaw,
41 + if (!g_file_get_contents(file, &cdata, &clen, &err)) {
42 + error_setg(errp, "unable to read file '%s'", file);
46 + char *basename = g_path_get_basename(file);
48 + if (format == BACKUP_FORMAT_VMA) {
49 + if (vma_writer_add_config(vmaw, basename, cdata, clen) != 0) {
50 + error_setg(errp, "unable to add %s config data to vma archive", file);
55 + } else if (format == BACKUP_FORMAT_DIR) {
56 + char config_path[PATH_MAX];
57 + snprintf(config_path, PATH_MAX, "%s/%s", backup_dir, basename);
58 + if (!g_file_set_contents(config_path, cdata, clen, &err)) {
59 + error_setg(errp, "unable to write config file '%s'", config_path);
72 static void pvebackup_run_next_job(void)
74 GList *l = backup_state.di_list;
75 @@ -2483,6 +2521,7 @@ static void pvebackup_run_next_job(void)
76 UuidInfo *qmp_backup(const char *backup_file, bool has_format,
78 bool has_config_file, const char *config_file,
79 + bool has_firewall_file, const char *firewall_file,
80 bool has_devlist, const char *devlist,
81 bool has_speed, int64_t speed, Error **errp)
83 @@ -2635,38 +2674,17 @@ UuidInfo *qmp_backup(const char *backup_
85 /* add configuration file to archive */
86 if (has_config_file) {
90 - if (!g_file_get_contents(config_file, &cdata, &clen, &err)) {
91 - error_setg(errp, "unable to read file '%s'", config_file);
95 - char *basename = g_path_get_basename(config_file);
97 - if (format == BACKUP_FORMAT_VMA) {
98 - if (vma_writer_add_config(vmaw, basename, cdata, clen) != 0) {
99 - error_setg(errp, "unable to add config data to vma archive");
104 - } else if (format == BACKUP_FORMAT_DIR) {
105 - char config_path[PATH_MAX];
106 - snprintf(config_path, PATH_MAX, "%s/%s", backup_dir, basename);
107 - if (!g_file_set_contents(config_path, cdata, clen, &err)) {
108 - error_setg(errp, "unable to write config file '%s'", config_path);
117 + if(config_to_vma(config_file, format, backup_dir, vmaw, errp) != 0) {
122 + /* add firewall file to archive */
123 + if (has_firewall_file) {
124 + if(config_to_vma(firewall_file, format, backup_dir, vmaw, errp) != 0) {
128 /* initialize global backup_state now */
130 backup_state.cancel = false;
131 Index: qemu-kvm-dev/hmp.c
132 ===================================================================
133 --- qemu-kvm-dev.orig/hmp.c
134 +++ qemu-kvm-dev/hmp.c
135 @@ -1465,7 +1465,7 @@ void hmp_backup(Monitor *mon, const QDic
136 int64_t speed = qdict_get_try_int(qdict, "speed", 0);
138 qmp_backup(backup_file, true, dir ? BACKUP_FORMAT_DIR : BACKUP_FORMAT_VMA,
139 - false, NULL, !!devlist,
140 + false, NULL, false, NULL, !!devlist,
141 devlist, qdict_haskey(qdict, "speed"), speed, &error);
143 hmp_handle_error(mon, &error);