1 From 4cf741ef0ec95b62dab484f5630e0f5fd608220a 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/55] 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 3ad2f18..6a33352 100644
14 @@ -32,6 +32,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 @@ -601,6 +602,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 @@ -630,6 +692,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);