]> git.proxmox.com Git - pve-qemu-kvm.git/commitdiff
vma: add an easy way to extract a configuration file
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 4 Dec 2013 09:36:25 +0000 (10:36 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 4 Dec 2013 09:39:58 +0000 (10:39 +0100)
Makefile
debian/changelog
debian/patches/backup-vma-add-dump-config.patch [new file with mode: 0644]
debian/patches/series

index 37578f26a814990abbe50cda574e664e6560b6db..3ff54ac072ed31fe8331bb7c57567169e037f91a 100644 (file)
--- 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
index 014ee473cf00d681902d84bcc042a65e62f7507b..36fd0bd2d9fb2dbe10e4050406429d9907ca9c97 100644 (file)
@@ -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 <support@proxmox.com>  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 (file)
index 0000000..378d956
--- /dev/null
@@ -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 <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"
+@@ -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();
index fa4ab4a57f556ec1534da601c85e5aaf5f25da7c..66b043817a0eeae0b3ad523b896ff763c2fa94de 100644 (file)
@@ -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