1 From fbe4db594bee11864b82c5839425348bc4133c9b Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 9 Dec 2015 14:46:49 +0100
4 Subject: [PATCH 13/41] vma: add 'config' command to dump the config
7 vma.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 1 file changed, 64 insertions(+)
10 diff --git a/vma.c b/vma.c
11 index d55874a..79bdd00 100644
14 @@ -26,6 +26,7 @@ static void help(void)
15 "usage: vma command [command options]\n"
17 "vma list <filename>\n"
18 + "vma config <filename> [-c config]\n"
19 "vma create <filename> [-c config] <archive> pathname ...\n"
20 "vma extract <filename> [-r <fifo>] <targetdir>\n"
21 "vma verify <filename> [-v]\n"
22 @@ -604,6 +605,67 @@ static int create_archive(int argc, char **argv)
26 +static int dump_config(int argc, char **argv)
29 + const char *filename;
30 + const char *config_name = "qemu-server.conf";
33 + c = getopt(argc, argv, "hc:");
43 + config_name = optarg;
50 + /* Get the filename */
51 + if ((optind + 1) != argc) {
54 + filename = argv[optind++];
57 + VmaReader *vmar = vma_reader_create(filename, &errp);
60 + g_error("%s", error_get_pretty(errp));
64 + GList *l = vma_reader_get_config_data(vmar);
65 + while (l && l->data) {
66 + VmaConfigData *cdata = (VmaConfigData *)l->data;
68 + if (strcmp(cdata->name, config_name) == 0) {
70 + fwrite(cdata->data, cdata->len, 1, stdout);
75 + vma_reader_destroy(vmar);
80 + fprintf(stderr, "unable to find configuration data '%s'\n", config_name);
87 int main(int argc, char **argv)
90 @@ -633,6 +695,8 @@ int main(int argc, char **argv)
91 return extract_content(argc, argv);
92 } else if (!strcmp(cmdname, "verify")) {
93 return verify_content(argc, argv);
94 + } else if (!strcmp(cmdname, "config")) {
95 + return dump_config(argc, argv);