add the zeroinit block driver filter
[pve-qemu-kvm.git] / debian / patches / old / backup-vma-add-dump-config.patch
blob6febcc44ae102e3f63e7413177a82daf36142c90
1 Index: new/vma.c
2 ===================================================================
3 --- new.orig/vma.c 2014-11-20 08:47:30.000000000 +0100
4 +++ new/vma.c 2014-11-20 08:47:47.000000000 +0100
5 @@ -32,6 +32,7 @@
6 "usage: vma command [command options]\n"
7 "\n"
8 "vma list <filename>\n"
9 + "vma config <filename> [-c config]\n"
10 "vma create <filename> [-c config] <archive> pathname ...\n"
11 "vma extract <filename> [-r <fifo>] <targetdir>\n"
12 "vma verify <filename> [-v]\n"
13 @@ -601,6 +602,67 @@
14 return 0;
17 +static int dump_config(int argc, char **argv)
19 + int c, ret = 0;
20 + const char *filename;
21 + const char *config_name = "qemu-server.conf";
23 + for (;;) {
24 + c = getopt(argc, argv, "hc:");
25 + if (c == -1) {
26 + break;
27 + }
28 + switch (c) {
29 + case '?':
30 + case 'h':
31 + help();
32 + break;
33 + case 'c':
34 + config_name = optarg;
35 + break;
36 + default:
37 + help();
38 + }
39 + }
41 + /* Get the filename */
42 + if ((optind + 1) != argc) {
43 + help();
44 + }
45 + filename = argv[optind++];
47 + Error *errp = NULL;
48 + VmaReader *vmar = vma_reader_create(filename, &errp);
50 + if (!vmar) {
51 + g_error("%s", error_get_pretty(errp));
52 + }
54 + int found = 0;
55 + GList *l = vma_reader_get_config_data(vmar);
56 + while (l && l->data) {
57 + VmaConfigData *cdata = (VmaConfigData *)l->data;
58 + l = g_list_next(l);
59 + if (strcmp(cdata->name, config_name) == 0) {
60 + found = 1;
61 + fwrite(cdata->data, cdata->len, 1, stdout);
62 + break;
63 + }
64 + }
66 + vma_reader_destroy(vmar);
68 + bdrv_close_all();
70 + if (!found) {
71 + fprintf(stderr, "unable to find configuration data '%s'\n", config_name);
72 + return -1;
73 + }
75 + return ret;
78 int main(int argc, char **argv)
80 const char *cmdname;
81 @@ -630,6 +692,8 @@
82 return extract_content(argc, argv);
83 } else if (!strcmp(cmdname, "verify")) {
84 return verify_content(argc, argv);
85 + } else if (!strcmp(cmdname, "config")) {
86 + return dump_config(argc, argv);
89 help();