mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-05 10:50:32 +00:00
qm agent: directly return result
This is required for correct error handling. The previous code simply cought all exceptions.
This commit is contained in:
parent
a5d5341cb2
commit
57bdd45943
@ -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 {
|
code => sub {
|
||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
@ -2889,16 +2893,9 @@ __PACKAGE__->register_method({
|
|||||||
die "No Qemu Guest Agent\n" if !defined($conf->{agent});
|
die "No Qemu Guest Agent\n" if !defined($conf->{agent});
|
||||||
die "VM $vmid is not running\n" if !PVE::QemuServer::check_running($vmid);
|
die "VM $vmid is not running\n" if !PVE::QemuServer::check_running($vmid);
|
||||||
|
|
||||||
my $res = '';
|
my $res = PVE::QemuServer::vm_mon_cmd($vmid, $param->{command});
|
||||||
eval {
|
|
||||||
$res = PVE::QemuServer::vm_mon_cmd($vmid, $param->{command});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (my $err = $@) {
|
return { result => $res };
|
||||||
return {'ERROR:', $err};
|
|
||||||
} else {
|
|
||||||
return {'OK:', $res};
|
|
||||||
}
|
|
||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
|
Loading…
Reference in New Issue
Block a user