]> git.proxmox.com Git - qemu-server.git/commitdiff
save description as comment
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Mar 2012 07:13:14 +0000 (08:13 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Mar 2012 07:13:14 +0000 (08:13 +0100)
Makefile
PVE/QemuServer.pm
changelog.Debian

index 48c4b439d11072ee526eba98fe4ea99776c2b06f..d34c092f7bb4e10d74cb8fa63a7f03cfa90f2816 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ RELEASE=2.0
 
 VERSION=2.0
 PACKAGE=qemu-server
-PKGREL=23
+PKGREL=24
 
 DESTDIR=
 PREFIX=/usr
index 4ed133ebab02713b5afd3a2f0ad45b10f8f5dc55..da7b35f1efe667778349f1e848cd9f8316bb380a 100644 (file)
@@ -214,7 +214,7 @@ my $confdesc = {
     description => {
        optional => 1,
        type => 'string',
-       description => "Description for the VM. Only used on the configuration web interface.",
+       description => "Description for the VM. Only used on the configuration web interface. This is saved as comment inside the configuration file.",
     },
     ostype => {
        optional => 1,
@@ -1435,17 +1435,20 @@ sub parse_vm_config {
 
     my $vmid = $1;
 
+    my $descr = '';
+
     while ($raw && $raw =~ s/^(.*?)(\n|$)//) {
        my $line = $1;
 
-       next if $line =~ m/^\#/;
-
        next if $line =~ m/^\s*$/;
 
+       if ($line =~ m/^\#(.*)\s*$/) {
+           $descr .= PVE::Tools::decode_text($1) . "\n";
+           next;
+       }
+
        if ($line =~ m/^(description):\s*(.*\S)\s*$/) {
-           my $key = $1;
-           my $value = PVE::Tools::decode_text($2);
-           $res->{$key} = $value;
+           $descr .= PVE::Tools::decode_text($2);
        } elsif ($line =~ m/^(args):\s*(.*\S)\s*$/) {
            my $key = $1;
            my $value = $2;
@@ -1478,6 +1481,8 @@ sub parse_vm_config {
        }
     }
 
+    $res->{description} = $descr if $descr;
+
     # convert old smp to sockets
     if ($res->{smp} && !$res->{sockets}) {
        $res->{sockets} = $res->{smp};
@@ -1507,11 +1512,8 @@ sub write_vm_config {
 
     my $new_volids = {};
     foreach my $key (keys %$conf) {
-       next if $key eq 'digest';
+       next if $key eq 'digest' || $key eq 'description';
        my $value = $conf->{$key};
-       if ($key eq 'description') {
-           $value = PVE::Tools::encode_text($value);
-       }
        eval { $value = check_type($key, $value); };
        die "unable to parse value of '$key' - $@" if $@;
 
@@ -1533,8 +1535,15 @@ sub write_vm_config {
 
     # gererate RAW data
     my $raw = '';
+
+    # add description as comment to top of file
+    my $descr = $conf->{description} || '';
+    foreach my $cl (split(/\n/, $descr)) {
+       $raw .= '#' .  PVE::Tools::encode_text($cl) . "\n";
+    }
+
     foreach my $key (sort keys %$conf) {
-       next if $key eq 'digest';
+       next if $key eq 'digest' || $key eq 'description';
        $raw .= "$key: $conf->{$key}\n";
     }
 
index d6d5c29626b674d37f7fdc2517947c51a1abbacd..496823664b080a8d20936a8f835f3f511a73f0e7 100644 (file)
@@ -1,3 +1,9 @@
+qemu-server (2.0-24) unstable; urgency=low
+
+  * save description as comment.
+
+ -- Proxmox Support Team <support@proxmox.com>  Thu, 01 Mar 2012 08:12:29 +0100
+
 qemu-server (2.0-23) unstable; urgency=low
 
   * fix lvremove call: avoid 'Not a CODE reference' warning