clean: remove buildinfo/changes
[pve-qemu-kvm.git] / debian / patches / old / add_firewall_to_vma.patch
blob0ab20a067f96790131919cc55412366b32f184a0
1 Index: qemu-kvm-dev/qapi-schema.json
2 ===================================================================
3 --- qemu-kvm-dev.orig/qapi-schema.json
4 +++ qemu-kvm-dev/qapi-schema.json
5 @@ -416,6 +416,7 @@
6 { 'command': 'backup', 'data': { 'backup-file': 'str',
7 '*format': 'BackupFormat',
8 '*config-file': 'str',
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
20 .name = "backup",
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,
36 + Error **errp)
38 + char *cdata = NULL;
39 + gsize clen = 0;
40 + GError *err = NULL;
41 + if (!g_file_get_contents(file, &cdata, &clen, &err)) {
42 + error_setg(errp, "unable to read file '%s'", file);
43 + return 1;
44 + }
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);
51 + g_free(cdata);
52 + g_free(basename);
53 + return 1;
54 + }
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);
60 + g_free(cdata);
61 + g_free(basename);
62 + return 1;
63 + }
64 + }
66 + g_free(basename);
67 + g_free(cdata);
69 + return 0;
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,
77 BackupFormat 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) {
87 - char *cdata = NULL;
88 - gsize clen = 0;
89 - GError *err = NULL;
90 - if (!g_file_get_contents(config_file, &cdata, &clen, &err)) {
91 - error_setg(errp, "unable to read file '%s'", config_file);
92 - goto err;
93 - }
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");
100 - g_free(cdata);
101 - g_free(basename);
102 - goto err;
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);
109 - g_free(cdata);
110 - g_free(basename);
111 - goto err;
115 - g_free(basename);
116 - g_free(cdata);
117 + if(config_to_vma(config_file, format, backup_dir, vmaw, errp) != 0) {
118 + goto err;
122 + /* add firewall file to archive */
123 + if (has_firewall_file) {
124 + if(config_to_vma(firewall_file, format, backup_dir, vmaw, errp) != 0) {
125 + goto err;
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);