]> git.proxmox.com Git - qemu-server.git/blobdiff - qm
correctly handle empty description in pending section
[qemu-server.git] / qm
diff --git a/qm b/qm
index 6830c6c155afdd00539a397c5fcf88b8eed32c1d..b6617230a6d767cc95cc424d8ffd75d096400aa7 100755 (executable)
--- a/qm
+++ b/qm
@@ -45,9 +45,7 @@ my $upid_exit = sub {
 my $nodename = PVE::INotify::nodename();
 
 sub run_vnc_proxy {
-    my ($vmid) = @_;
-
-    my $path = PVE::QemuServer::vnc_socket($vmid);
+    my ($path) = @_;
 
     my $c;
     while ( ++$c < 10 && !-e $path ) { sleep(1); }
@@ -165,8 +163,17 @@ __PACKAGE__->register_method ({
        my ($param) = @_;
 
        my $vmid = $param->{vmid};
+       my $vnc_socket = PVE::QemuServer::vnc_socket($vmid);
+
+       if (my $ticket = $ENV{LC_PVE_TICKET}) {  # NOTE: ssh on debian only pass LC_* variables
+           PVE::QemuServer::vm_mon_cmd($vmid, "change", device => 'vnc', target => "unix:$vnc_socket,password");
+           PVE::QemuServer::vm_mon_cmd($vmid, "set_password", protocol => 'vnc', password => $ticket);
+           PVE::QemuServer::vm_mon_cmd($vmid, "expire_password", protocol => 'vnc', time => "+30");
+       } else {
+           PVE::QemuServer::vm_mon_cmd($vmid, "change", device => 'vnc', target => "unix:$vnc_socket,x509,password");
+       }
 
-       run_vnc_proxy ($vmid);
+       run_vnc_proxy($vnc_socket);
 
        return undef;
     }});
@@ -191,6 +198,7 @@ __PACKAGE__->register_method ({
        PVE::QemuServer::lock_config ($vmid, sub {
            my $conf = PVE::QemuServer::load_config($vmid);
            delete $conf->{lock};
+           delete $conf->{pending}->{lock} if $conf->{pending}; # just to be sure
            PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
        });
 
@@ -415,7 +423,7 @@ my $cmddef = {
 
     move_disk => [ "PVE::API2::Qemu", 'move_vm_disk', ['vmid', 'disk', 'storage'], { node => $nodename }, $upid_exit ],
 
-    unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid', 'idlist'], { node => $nodename } ],
+    unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid'], { node => $nodename } ],
 
     config => [ "PVE::API2::Qemu", 'vm_config', ['vmid'], 
                { node => $nodename }, sub {
@@ -430,6 +438,33 @@ my $cmddef = {
                    }
                }],
        
+    pending => [ "PVE::API2::Qemu", 'vm_pending', ['vmid'],
+               { node => $nodename }, sub {
+                   my $data = shift;
+                   foreach my $item (sort { $a->{key} cmp $b->{key}} @$data) {
+                       my $k = $item->{key};
+                       next if $k eq 'digest';
+                       my $v = $item->{value};
+                       my $p = $item->{pending};
+                       if ($k eq 'description') {
+                           $v = PVE::Tools::encode_text($v) if defined($v);
+                           $p = PVE::Tools::encode_text($p) if defined($p);
+                       }
+                       if (defined($v)) {
+                           if ($item->{delete}) {
+                               print "del $k: $v\n";
+                           } elsif (defined($p)) {
+                               print "cur $k: $v\n";
+                               print "new $k: $p\n";
+                           } else {
+                               print "cur $k: $v\n";
+                           }
+                       } elsif (defined($p)) {
+                           print "new $k: $p\n";
+                       }
+                   }
+               }],
+
     showcmd => [ __PACKAGE__, 'showcmd', ['vmid']],
 
     status => [ __PACKAGE__, 'status', ['vmid']],