]> git.proxmox.com Git - qemu-server.git/commitdiff
qm agent: directly return result
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Dec 2016 05:58:36 +0000 (06:58 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Dec 2016 06:23:16 +0000 (07:23 +0100)
This is required for correct error handling. The previous
code simply cought all exceptions.

PVE/API2/Qemu.pm

index c4d648e26acb2641aa699612308708d5670997b5..fa8b2e58a4ce018895aa94c165bf4928fc255973 100644 (file)
@@ -2877,7 +2877,11 @@ __PACKAGE__->register_method({
            },
        },
     },
-    returns => { type => 'object' },
+    returns => {
+       type => 'object',
+       description => "Returns an object with a single `result` property. The type of that
+property depends on the executed command.",
+    },
     code => sub {
        my ($param) = @_;
 
@@ -2889,16 +2893,9 @@ __PACKAGE__->register_method({
        die "No Qemu Guest Agent\n" if !defined($conf->{agent});
        die "VM $vmid is not running\n" if !PVE::QemuServer::check_running($vmid);
 
-       my $res = '';
-       eval {
-           $res = PVE::QemuServer::vm_mon_cmd($vmid, $param->{command});
-       };
+       my $res = PVE::QemuServer::vm_mon_cmd($vmid, $param->{command});
 
-       if (my $err = $@) {
-           return {'ERROR:', $err};
-       } else {
-           return {'OK:', $res};
-       }
+       return { result => $res };
     }});
 
 __PACKAGE__->register_method({