From 2bae733b7e3389838d824bfaeb5d6a4201e07c02 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 4 Dec 2013 10:36:25 +0100 Subject: [PATCH] vma: add an easy way to extract a configuration file --- Makefile | 2 +- debian/changelog | 6 ++ .../patches/backup-vma-add-dump-config.patch | 89 +++++++++++++++++++ debian/patches/series | 1 + 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 debian/patches/backup-vma-add-dump-config.patch diff --git a/Makefile b/Makefile index 37578f2..3ff54ac 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ RELEASE=3.1 # also update debian/changelog KVMVER=1.7 -KVMPKGREL=2 +KVMPKGREL=3 KVMPACKAGE=pve-qemu-kvm KVMDIR=qemu-kvm diff --git a/debian/changelog b/debian/changelog index 014ee47..36fd0bd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +pve-qemu-kvm (1.7-3) unstable; urgency=low + + * vma: add 'vma config' command to easily extract VM configuration + + -- Proxmox Support Team Wed, 04 Dec 2013 10:39:36 +0100 + pve-qemu-kvm (1.7-2) unstable; urgency=low * depend on latest spice server libs diff --git a/debian/patches/backup-vma-add-dump-config.patch b/debian/patches/backup-vma-add-dump-config.patch new file mode 100644 index 0000000..378d956 --- /dev/null +++ b/debian/patches/backup-vma-add-dump-config.patch @@ -0,0 +1,89 @@ +Index: new/vma.c +=================================================================== +--- new.orig/vma.c 2013-12-04 10:07:38.000000000 +0100 ++++ new/vma.c 2013-12-04 10:33:54.000000000 +0100 +@@ -32,6 +32,7 @@ + "usage: vma command [command options]\n" + "\n" + "vma list \n" ++ "vma config [-c config]\n" + "vma create [-c config] pathname ...\n" + "vma extract [-r ] \n" + "vma verify [-v]\n" +@@ -645,6 +646,67 @@ + 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; +@@ -671,6 +733,8 @@ + 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(); diff --git a/debian/patches/series b/debian/patches/series index fa4ab4a..66b0438 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -15,6 +15,7 @@ spice-use-pve-certs.patch backup-add-documenation.patch backup-add-vma-binary.patch backup-add-vma-verify-command.patch +backup-vma-add-dump-config.patch backup-vma-restore-tolerate-a-size-difference-up-to-4M.patch backup-modify-job-api.patch backup-add-pve-monitor-commands.patch -- 2.39.2