From 91c94f0a23374dbda3289814a2b9c04591fefb3e Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 9 Nov 2011 08:26:46 +0100 Subject: [PATCH] implement monitor API --- PVE/API2/Qemu.pm | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index c9d6da7d..8dfd1a53 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -264,6 +264,7 @@ __PACKAGE__->register_method({ { subdir => 'migrate' }, { subdir => 'rrd' }, { subdir => 'rrddata' }, + { subdir => 'monitor' }, ]; return $res; @@ -1245,4 +1246,39 @@ __PACKAGE__->register_method({ return $upid; }}); +__PACKAGE__->register_method({ + name => 'monitor', + path => '{vmid}/monitor', + method => 'POST', + protected => 1, + proxyto => 'node', + description => "Execute Qemu monitor commands.", + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + vmid => get_standard_option('pve-vmid'), + command => { + type => 'string', + description => "The monitor command.", + } + }, + }, + returns => { type => 'string'}, + code => sub { + my ($param) = @_; + + my $vmid = $param->{vmid}; + + my $conf = PVE::QemuServer::load_config ($vmid); # check if VM exists + + my $res = ''; + eval { + $res = PVE::QemuServer::vm_monitor_command($vmid, $param->{command}); + }; + $res = "ERROR: $@" if $@; + + return $res; + }}); + 1; -- 2.39.5