use strict;
use warnings;
+use Cwd 'abs_path';
use PVE::Cluster;
use PVE::SafeSyslog;
PVE::QemuServer::add_random_macs($param);
} else {
my $keystr = join(' ', keys %$param);
- raise_param_exc({ archive => "option conflicts with other options ($keystr)"}) if $keystr;
- }
+ raise_param_exc({ archive => "option conflicts with other options ($keystr)"}) if $keystr;
+
+ if ($archive eq '-') {
+ die "pipe requires cli environment\n"
+ && $rpcenv->{type} ne 'cli';
+ } else {
+ if (PVE::Storage::parse_volume_id($archive, 1)) {
+ $archive = PVE::Storage::path($storecfg, $archive);
+ } else {
+ raise_param_exc({ archive => "Only root can pass arbitrary paths." })
+ if $user ne 'root@pam';
- # fixme: archive eq '-' (read from stdin)
+ $archive = abs_path($archive);
+ }
+ die "can't find file '$archive'\n" if ! -f $archive;
+ }
+ }
my $restorefn = sub {
{ subdir => 'migrate' },
{ subdir => 'rrd' },
{ subdir => 'rrddata' },
+ { subdir => 'monitor' },
];
return $res;
my $remip;
- if ($node ne PVE::INotify::nodename()) {
+ if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) {
$remip = PVE::Cluster::remote_node_ip($node);
}
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;