102 lines
2.5 KiB
Diff
102 lines
2.5 KiB
Diff
From 7462043311f01c05c98a1f60f696ac4b465a7f38 Mon Sep 17 00:00:00 2001
|
|
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
|
Date: Wed, 9 Dec 2015 14:46:49 +0100
|
|
Subject: [PATCH 13/49] vma: add 'config' command to dump the config
|
|
|
|
---
|
|
vma.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 64 insertions(+)
|
|
|
|
diff --git a/vma.c b/vma.c
|
|
index ab7b766014..89254070c4 100644
|
|
--- a/vma.c
|
|
+++ b/vma.c
|
|
@@ -27,6 +27,7 @@ static void help(void)
|
|
"usage: vma command [command options]\n"
|
|
"\n"
|
|
"vma list <filename>\n"
|
|
+ "vma config <filename> [-c config]\n"
|
|
"vma create <filename> [-c config] <archive> pathname ...\n"
|
|
"vma extract <filename> [-r <fifo>] <targetdir>\n"
|
|
"vma verify <filename> [-v]\n"
|
|
@@ -605,6 +606,67 @@ static int create_archive(int argc, char **argv)
|
|
return 0;
|
|
}
|
|
|
|
+static int dump_config(int argc, char **argv)
|
|
+{
|
|
+ int c, ret = 0;
|
|
+ const char *filename;
|
|
+ const char *config_name = "qemu-server.conf";
|
|
+
|
|
+ for (;;) {
|
|
+ c = getopt(argc, argv, "hc:");
|
|
+ if (c == -1) {
|
|
+ break;
|
|
+ }
|
|
+ switch (c) {
|
|
+ case '?':
|
|
+ case 'h':
|
|
+ help();
|
|
+ break;
|
|
+ case 'c':
|
|
+ config_name = optarg;
|
|
+ break;
|
|
+ default:
|
|
+ help();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /* Get the filename */
|
|
+ if ((optind + 1) != argc) {
|
|
+ help();
|
|
+ }
|
|
+ filename = argv[optind++];
|
|
+
|
|
+ Error *errp = NULL;
|
|
+ VmaReader *vmar = vma_reader_create(filename, &errp);
|
|
+
|
|
+ if (!vmar) {
|
|
+ g_error("%s", error_get_pretty(errp));
|
|
+ }
|
|
+
|
|
+ int found = 0;
|
|
+ GList *l = vma_reader_get_config_data(vmar);
|
|
+ while (l && l->data) {
|
|
+ VmaConfigData *cdata = (VmaConfigData *)l->data;
|
|
+ l = g_list_next(l);
|
|
+ if (strcmp(cdata->name, config_name) == 0) {
|
|
+ found = 1;
|
|
+ fwrite(cdata->data, cdata->len, 1, stdout);
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ vma_reader_destroy(vmar);
|
|
+
|
|
+ bdrv_close_all();
|
|
+
|
|
+ if (!found) {
|
|
+ fprintf(stderr, "unable to find configuration data '%s'\n", config_name);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
int main(int argc, char **argv)
|
|
{
|
|
const char *cmdname;
|
|
@@ -634,6 +696,8 @@ int main(int argc, char **argv)
|
|
return extract_content(argc, argv);
|
|
} else if (!strcmp(cmdname, "verify")) {
|
|
return verify_content(argc, argv);
|
|
+ } else if (!strcmp(cmdname, "config")) {
|
|
+ return dump_config(argc, argv);
|
|
}
|
|
|
|
help();
|
|
--
|
|
2.11.0
|
|
|