mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-10-04 17:01:46 +00:00
removed trailing whitespace
This commit is contained in:
parent
c2a64aa7cf
commit
afdb31d5f8
172
PVE/API2/Qemu.pm
172
PVE/API2/Qemu.pm
@ -34,8 +34,8 @@ my $resolve_cdrom_alias = sub {
|
|||||||
};
|
};
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vmlist',
|
name => 'vmlist',
|
||||||
path => '',
|
path => '',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
description => "Virtual machine index (per node).",
|
description => "Virtual machine index (per node).",
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
@ -64,8 +64,8 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'create_vm',
|
name => 'create_vm',
|
||||||
path => '',
|
path => '',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
description => "Create or restore a virtual machine.",
|
description => "Create or restore a virtual machine.",
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -87,20 +87,20 @@ __PACKAGE__->register_method({
|
|||||||
optional => 1,
|
optional => 1,
|
||||||
}),
|
}),
|
||||||
force => {
|
force => {
|
||||||
optional => 1,
|
optional => 1,
|
||||||
type => 'boolean',
|
type => 'boolean',
|
||||||
description => "Allow to overwrite existing VM.",
|
description => "Allow to overwrite existing VM.",
|
||||||
requires => 'archive',
|
requires => 'archive',
|
||||||
},
|
},
|
||||||
unique => {
|
unique => {
|
||||||
optional => 1,
|
optional => 1,
|
||||||
type => 'boolean',
|
type => 'boolean',
|
||||||
description => "Assign a unique random ethernet address.",
|
description => "Assign a unique random ethernet address.",
|
||||||
requires => 'archive',
|
requires => 'archive',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -123,19 +123,19 @@ __PACKAGE__->register_method({
|
|||||||
my $unique = extract_param($param, 'unique');
|
my $unique = extract_param($param, 'unique');
|
||||||
|
|
||||||
my $filename = PVE::QemuServer::config_file($vmid);
|
my $filename = PVE::QemuServer::config_file($vmid);
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
|
|
||||||
PVE::Cluster::check_cfs_quorum();
|
PVE::Cluster::check_cfs_quorum();
|
||||||
|
|
||||||
if (!$archive) {
|
if (!$archive) {
|
||||||
&$resolve_cdrom_alias($param);
|
&$resolve_cdrom_alias($param);
|
||||||
|
|
||||||
foreach my $opt (keys %$param) {
|
foreach my $opt (keys %$param) {
|
||||||
if (PVE::QemuServer::valid_drivename($opt)) {
|
if (PVE::QemuServer::valid_drivename($opt)) {
|
||||||
my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt});
|
my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt});
|
||||||
raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive;
|
raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive;
|
||||||
|
|
||||||
PVE::QemuServer::cleanup_drive_path($opt, $storecfg, $drive);
|
PVE::QemuServer::cleanup_drive_path($opt, $storecfg, $drive);
|
||||||
$param->{$opt} = PVE::QemuServer::print_drive($vmid, $drive);
|
$param->{$opt} = PVE::QemuServer::print_drive($vmid, $drive);
|
||||||
}
|
}
|
||||||
@ -147,14 +147,14 @@ __PACKAGE__->register_method({
|
|||||||
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 '-') {
|
if ($archive eq '-') {
|
||||||
die "pipe requires cli environment\n"
|
die "pipe requires cli environment\n"
|
||||||
&& $rpcenv->{type} ne 'cli';
|
&& $rpcenv->{type} ne 'cli';
|
||||||
} else {
|
} else {
|
||||||
my $path;
|
my $path;
|
||||||
if (PVE::Storage::parse_volume_id($archive, 1)) {
|
if (PVE::Storage::parse_volume_id($archive, 1)) {
|
||||||
$path = PVE::Storage::path($storecfg, $archive);
|
$path = PVE::Storage::path($storecfg, $archive);
|
||||||
} else {
|
} else {
|
||||||
raise_param_exc({ archive => "Only root can pass arbitrary paths." })
|
raise_param_exc({ archive => "Only root can pass arbitrary paths." })
|
||||||
if $user ne 'root@pam';
|
if $user ne 'root@pam';
|
||||||
|
|
||||||
$path = abs_path($archive);
|
$path = abs_path($archive);
|
||||||
@ -167,10 +167,10 @@ __PACKAGE__->register_method({
|
|||||||
my $restorefn = sub {
|
my $restorefn = sub {
|
||||||
|
|
||||||
if (-f $filename) {
|
if (-f $filename) {
|
||||||
die "unable to restore vm $vmid: config file already exists\n"
|
die "unable to restore vm $vmid: config file already exists\n"
|
||||||
if !$force;
|
if !$force;
|
||||||
|
|
||||||
die "unable to restore vm $vmid: vm is running\n"
|
die "unable to restore vm $vmid: vm is running\n"
|
||||||
if PVE::QemuServer::check_running($vmid);
|
if PVE::QemuServer::check_running($vmid);
|
||||||
|
|
||||||
# destroy existing data - keep empty config
|
# destroy existing data - keep empty config
|
||||||
@ -178,7 +178,7 @@ __PACKAGE__->register_method({
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $realcmd = sub {
|
my $realcmd = sub {
|
||||||
PVE::QemuServer::restore_archive($archive, $vmid, {
|
PVE::QemuServer::restore_archive($archive, $vmid, {
|
||||||
storage => $storage,
|
storage => $storage,
|
||||||
unique => $unique });
|
unique => $unique });
|
||||||
};
|
};
|
||||||
@ -189,7 +189,7 @@ __PACKAGE__->register_method({
|
|||||||
my $createfn = sub {
|
my $createfn = sub {
|
||||||
|
|
||||||
# second test (after locking test is accurate)
|
# second test (after locking test is accurate)
|
||||||
die "unable to create vm $vmid: config file already exists\n"
|
die "unable to create vm $vmid: config file already exists\n"
|
||||||
if -f $filename;
|
if -f $filename;
|
||||||
|
|
||||||
my $realcmd = sub {
|
my $realcmd = sub {
|
||||||
@ -210,7 +210,7 @@ __PACKAGE__->register_method({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$param->{bootdisk} && $firstdisk) {
|
if (!$param->{bootdisk} && $firstdisk) {
|
||||||
$param->{bootdisk} = $firstdisk;
|
$param->{bootdisk} = $firstdisk;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVE::QemuServer::create_conf_nolock($vmid, $param);
|
PVE::QemuServer::create_conf_nolock($vmid, $param);
|
||||||
@ -234,7 +234,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vmdiridx',
|
name => 'vmdiridx',
|
||||||
path => '{vmid}',
|
path => '{vmid}',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
description => "Directory index",
|
description => "Directory index",
|
||||||
@ -268,13 +268,13 @@ __PACKAGE__->register_method({
|
|||||||
{ subdir => 'rrddata' },
|
{ subdir => 'rrddata' },
|
||||||
{ subdir => 'monitor' },
|
{ subdir => 'monitor' },
|
||||||
];
|
];
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'rrd',
|
name => 'rrd',
|
||||||
path => '{vmid}/rrd',
|
path => '{vmid}/rrd',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
protected => 1, # fixme: can we avoid that?
|
protected => 1, # fixme: can we avoid that?
|
||||||
permissions => {
|
permissions => {
|
||||||
@ -313,14 +313,14 @@ __PACKAGE__->register_method({
|
|||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
return PVE::Cluster::create_rrd_graph(
|
return PVE::Cluster::create_rrd_graph(
|
||||||
"pve2-vm/$param->{vmid}", $param->{timeframe},
|
"pve2-vm/$param->{vmid}", $param->{timeframe},
|
||||||
$param->{ds}, $param->{cf});
|
$param->{ds}, $param->{cf});
|
||||||
|
|
||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'rrddata',
|
name => 'rrddata',
|
||||||
path => '{vmid}/rrddata',
|
path => '{vmid}/rrddata',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
protected => 1, # fixme: can we avoid that?
|
protected => 1, # fixme: can we avoid that?
|
||||||
permissions => {
|
permissions => {
|
||||||
@ -361,8 +361,8 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_config',
|
name => 'vm_config',
|
||||||
path => '{vmid}/config',
|
path => '{vmid}/config',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
description => "Get virtual machine configuration.",
|
description => "Get virtual machine configuration.",
|
||||||
@ -373,7 +373,7 @@ __PACKAGE__->register_method({
|
|||||||
vmid => get_standard_option('pve-vmid'),
|
vmid => get_standard_option('pve-vmid'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => "object",
|
type => "object",
|
||||||
properties => {
|
properties => {
|
||||||
digest => {
|
digest => {
|
||||||
@ -391,8 +391,8 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'update_vm',
|
name => 'update_vm',
|
||||||
path => '{vmid}/config',
|
path => '{vmid}/config',
|
||||||
method => 'PUT',
|
method => 'PUT',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
@ -419,7 +419,7 @@ __PACKAGE__->register_method({
|
|||||||
type => 'string',
|
type => 'string',
|
||||||
description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
|
description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
|
||||||
maxLength => 40,
|
maxLength => 40,
|
||||||
optional => 1,
|
optional => 1,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -443,7 +443,7 @@ __PACKAGE__->register_method({
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
my $delete = extract_param($param, 'delete');
|
my $delete = extract_param($param, 'delete');
|
||||||
@ -451,13 +451,13 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
die "no options specified\n" if !$delete && !scalar(keys %$param);
|
die "no options specified\n" if !$delete && !scalar(keys %$param);
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
|
|
||||||
&$resolve_cdrom_alias($param);
|
&$resolve_cdrom_alias($param);
|
||||||
|
|
||||||
my $conf = PVE::QemuServer::load_config($vmid);
|
my $conf = PVE::QemuServer::load_config($vmid);
|
||||||
|
|
||||||
die "checksum missmatch (file change by other user?)\n"
|
die "checksum missmatch (file change by other user?)\n"
|
||||||
if $digest && $digest ne $conf->{digest};
|
if $digest && $digest ne $conf->{digest};
|
||||||
|
|
||||||
PVE::QemuServer::check_lock($conf) if !$skiplock;
|
PVE::QemuServer::check_lock($conf) if !$skiplock;
|
||||||
@ -475,7 +475,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
if (!PVE::QemuServer::option_exists($opt)) {
|
if (!PVE::QemuServer::option_exists($opt)) {
|
||||||
raise_param_exc({ delete => "unknown option '$opt'" });
|
raise_param_exc({ delete => "unknown option '$opt'" });
|
||||||
}
|
}
|
||||||
|
|
||||||
next if !defined($conf->{$opt});
|
next if !defined($conf->{$opt});
|
||||||
|
|
||||||
@ -579,8 +579,8 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'destroy_vm',
|
name => 'destroy_vm',
|
||||||
path => '{vmid}',
|
path => '{vmid}',
|
||||||
method => 'DELETE',
|
method => 'DELETE',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
@ -593,7 +593,7 @@ __PACKAGE__->register_method({
|
|||||||
skiplock => get_standard_option('skiplock'),
|
skiplock => get_standard_option('skiplock'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -606,13 +606,13 @@ __PACKAGE__->register_method({
|
|||||||
my $vmid = $param->{vmid};
|
my $vmid = $param->{vmid};
|
||||||
|
|
||||||
my $skiplock = $param->{skiplock};
|
my $skiplock = $param->{skiplock};
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
# test if VM exists
|
# test if VM exists
|
||||||
my $conf = PVE::QemuServer::load_config($vmid);
|
my $conf = PVE::QemuServer::load_config($vmid);
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
|
|
||||||
my $realcmd = sub {
|
my $realcmd = sub {
|
||||||
my $upid = shift;
|
my $upid = shift;
|
||||||
@ -626,8 +626,8 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'unlink',
|
name => 'unlink',
|
||||||
path => '{vmid}/unlink',
|
path => '{vmid}/unlink',
|
||||||
method => 'PUT',
|
method => 'PUT',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
@ -662,8 +662,8 @@ __PACKAGE__->register_method({
|
|||||||
my $sslcert;
|
my $sslcert;
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vncproxy',
|
name => 'vncproxy',
|
||||||
path => '{vmid}/vncproxy',
|
path => '{vmid}/vncproxy',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
permissions => {
|
permissions => {
|
||||||
@ -677,7 +677,7 @@ __PACKAGE__->register_method({
|
|||||||
vmid => get_standard_option('pve-vmid'),
|
vmid => get_standard_option('pve-vmid'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => {
|
properties => {
|
||||||
user => { type => 'string' },
|
user => { type => 'string' },
|
||||||
@ -707,7 +707,7 @@ __PACKAGE__->register_method({
|
|||||||
my $port = PVE::Tools::next_vnc_port();
|
my $port = PVE::Tools::next_vnc_port();
|
||||||
|
|
||||||
my $remip;
|
my $remip;
|
||||||
|
|
||||||
if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) {
|
if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) {
|
||||||
$remip = PVE::Cluster::remote_node_ip($node);
|
$remip = PVE::Cluster::remote_node_ip($node);
|
||||||
}
|
}
|
||||||
@ -717,7 +717,7 @@ __PACKAGE__->register_method({
|
|||||||
my $remcmd = $remip ? ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes',
|
my $remcmd = $remip ? ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes',
|
||||||
'-c', 'blowfish-cbc', $remip] : [];
|
'-c', 'blowfish-cbc', $remip] : [];
|
||||||
|
|
||||||
my $timeout = 10;
|
my $timeout = 10;
|
||||||
|
|
||||||
my $realcmd = sub {
|
my $realcmd = sub {
|
||||||
my $upid = shift;
|
my $upid = shift;
|
||||||
@ -741,15 +741,15 @@ __PACKAGE__->register_method({
|
|||||||
return {
|
return {
|
||||||
user => $user,
|
user => $user,
|
||||||
ticket => $ticket,
|
ticket => $ticket,
|
||||||
port => $port,
|
port => $port,
|
||||||
upid => $upid,
|
upid => $upid,
|
||||||
cert => $sslcert,
|
cert => $sslcert,
|
||||||
};
|
};
|
||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vmcmdidx',
|
name => 'vmcmdidx',
|
||||||
path => '{vmid}/status',
|
path => '{vmid}/status',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
description => "Directory index",
|
description => "Directory index",
|
||||||
@ -781,12 +781,12 @@ __PACKAGE__->register_method({
|
|||||||
{ subdir => 'start' },
|
{ subdir => 'start' },
|
||||||
{ subdir => 'stop' },
|
{ subdir => 'stop' },
|
||||||
];
|
];
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_status',
|
name => 'vm_status',
|
||||||
path => '{vmid}/status/current',
|
path => '{vmid}/status/current',
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
@ -820,7 +820,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_start',
|
name => 'vm_start',
|
||||||
path => '{vmid}/status/start',
|
path => '{vmid}/status/start',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -835,7 +835,7 @@ __PACKAGE__->register_method({
|
|||||||
stateuri => get_standard_option('pve-qm-stateuri'),
|
stateuri => get_standard_option('pve-qm-stateuri'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -850,14 +850,14 @@ __PACKAGE__->register_method({
|
|||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
my $stateuri = extract_param($param, 'stateuri');
|
my $stateuri = extract_param($param, 'stateuri');
|
||||||
raise_param_exc({ stateuri => "Only root may use this option." })
|
raise_param_exc({ stateuri => "Only root may use this option." })
|
||||||
if $stateuri && $user ne 'root@pam';
|
if $stateuri && $user ne 'root@pam';
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
|
|
||||||
my $realcmd = sub {
|
my $realcmd = sub {
|
||||||
my $upid = shift;
|
my $upid = shift;
|
||||||
@ -873,7 +873,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_stop',
|
name => 'vm_stop',
|
||||||
path => '{vmid}/status/stop',
|
path => '{vmid}/status/stop',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -899,7 +899,7 @@ __PACKAGE__->register_method({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -914,11 +914,11 @@ __PACKAGE__->register_method({
|
|||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
my $keepActive = extract_param($param, 'keepActive');
|
my $keepActive = extract_param($param, 'keepActive');
|
||||||
raise_param_exc({ keepActive => "Only root may use this option." })
|
raise_param_exc({ keepActive => "Only root may use this option." })
|
||||||
if $keepActive && $user ne 'root@pam';
|
if $keepActive && $user ne 'root@pam';
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
@ -928,7 +928,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
syslog('info', "stop VM $vmid: $upid\n");
|
syslog('info', "stop VM $vmid: $upid\n");
|
||||||
|
|
||||||
PVE::QemuServer::vm_stop($storecfg, $vmid, $skiplock, 0,
|
PVE::QemuServer::vm_stop($storecfg, $vmid, $skiplock, 0,
|
||||||
$param->{timeout}, 0, 1, $keepActive);
|
$param->{timeout}, 0, 1, $keepActive);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -938,7 +938,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_reset',
|
name => 'vm_reset',
|
||||||
path => '{vmid}/status/reset',
|
path => '{vmid}/status/reset',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -952,7 +952,7 @@ __PACKAGE__->register_method({
|
|||||||
skiplock => get_standard_option('skiplock'),
|
skiplock => get_standard_option('skiplock'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -967,7 +967,7 @@ __PACKAGE__->register_method({
|
|||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid);
|
die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid);
|
||||||
@ -984,7 +984,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_shutdown',
|
name => 'vm_shutdown',
|
||||||
path => '{vmid}/status/shutdown',
|
path => '{vmid}/status/shutdown',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -1016,7 +1016,7 @@ __PACKAGE__->register_method({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -1031,11 +1031,11 @@ __PACKAGE__->register_method({
|
|||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
my $keepActive = extract_param($param, 'keepActive');
|
my $keepActive = extract_param($param, 'keepActive');
|
||||||
raise_param_exc({ keepActive => "Only root may use this option." })
|
raise_param_exc({ keepActive => "Only root may use this option." })
|
||||||
if $keepActive && $user ne 'root@pam';
|
if $keepActive && $user ne 'root@pam';
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
@ -1045,7 +1045,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
syslog('info', "shutdown VM $vmid: $upid\n");
|
syslog('info', "shutdown VM $vmid: $upid\n");
|
||||||
|
|
||||||
PVE::QemuServer::vm_stop($storecfg, $vmid, $skiplock, 0, $param->{timeout},
|
PVE::QemuServer::vm_stop($storecfg, $vmid, $skiplock, 0, $param->{timeout},
|
||||||
1, $param->{forceStop}, $keepActive);
|
1, $param->{forceStop}, $keepActive);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1055,7 +1055,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_suspend',
|
name => 'vm_suspend',
|
||||||
path => '{vmid}/status/suspend',
|
path => '{vmid}/status/suspend',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -1069,7 +1069,7 @@ __PACKAGE__->register_method({
|
|||||||
skiplock => get_standard_option('skiplock'),
|
skiplock => get_standard_option('skiplock'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -1084,7 +1084,7 @@ __PACKAGE__->register_method({
|
|||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid);
|
die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid);
|
||||||
@ -1103,7 +1103,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_resume',
|
name => 'vm_resume',
|
||||||
path => '{vmid}/status/resume',
|
path => '{vmid}/status/resume',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -1117,7 +1117,7 @@ __PACKAGE__->register_method({
|
|||||||
skiplock => get_standard_option('skiplock'),
|
skiplock => get_standard_option('skiplock'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -1132,7 +1132,7 @@ __PACKAGE__->register_method({
|
|||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid);
|
die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid);
|
||||||
@ -1151,7 +1151,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'vm_sendkey',
|
name => 'vm_sendkey',
|
||||||
path => '{vmid}/sendkey',
|
path => '{vmid}/sendkey',
|
||||||
method => 'PUT',
|
method => 'PUT',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -1182,7 +1182,7 @@ __PACKAGE__->register_method({
|
|||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $user ne 'root@pam';
|
if $skiplock && $user ne 'root@pam';
|
||||||
|
|
||||||
PVE::QemuServer::vm_sendkey($vmid, $skiplock, $param->{key});
|
PVE::QemuServer::vm_sendkey($vmid, $skiplock, $param->{key});
|
||||||
@ -1191,7 +1191,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'migrate_vm',
|
name => 'migrate_vm',
|
||||||
path => '{vmid}/migrate',
|
path => '{vmid}/migrate',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
@ -1215,7 +1215,7 @@ __PACKAGE__->register_method({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
type => 'string',
|
type => 'string',
|
||||||
description => "the task ID.",
|
description => "the task ID.",
|
||||||
},
|
},
|
||||||
@ -1239,7 +1239,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
raise_param_exc({ force => "Only root may use this option." })
|
raise_param_exc({ force => "Only root may use this option." })
|
||||||
if $param->{force} && $user ne 'root@pam';
|
if $param->{force} && $user ne 'root@pam';
|
||||||
|
|
||||||
# test if VM exists
|
# test if VM exists
|
||||||
@ -1250,7 +1250,7 @@ __PACKAGE__->register_method({
|
|||||||
PVE::QemuServer::check_lock($conf);
|
PVE::QemuServer::check_lock($conf);
|
||||||
|
|
||||||
if (PVE::QemuServer::check_running($vmid)) {
|
if (PVE::QemuServer::check_running($vmid)) {
|
||||||
die "cant migrate running VM without --online\n"
|
die "cant migrate running VM without --online\n"
|
||||||
if !$param->{online};
|
if !$param->{online};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1266,8 +1266,8 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'monitor',
|
name => 'monitor',
|
||||||
path => '{vmid}/monitor',
|
path => '{vmid}/monitor',
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
|
@ -39,7 +39,7 @@ cfs_register_file('/qemu-server/', \&parse_vm_config);
|
|||||||
|
|
||||||
PVE::JSONSchema::register_standard_option('skiplock', {
|
PVE::JSONSchema::register_standard_option('skiplock', {
|
||||||
description => "Ignore locks - only root is allowed to use this option.",
|
description => "Ignore locks - only root is allowed to use this option.",
|
||||||
type => 'boolean',
|
type => 'boolean',
|
||||||
optional => 1,
|
optional => 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2040,7 +2040,7 @@ sub config_to_command {
|
|||||||
foreach my $o (split(//, $bootorder)) {
|
foreach my $o (split(//, $bootorder)) {
|
||||||
$bootindex_hash->{$o} = $i*100;
|
$bootindex_hash->{$o} = $i*100;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
push @$cmd, '-boot', "menu=on";
|
push @$cmd, '-boot', "menu=on";
|
||||||
|
|
||||||
@ -2123,7 +2123,7 @@ sub config_to_command {
|
|||||||
if (PVE::Storage::parse_volume_id($drive->{file}, 1)) {
|
if (PVE::Storage::parse_volume_id($drive->{file}, 1)) {
|
||||||
push @$vollist, $drive->{file};
|
push @$vollist, $drive->{file};
|
||||||
}
|
}
|
||||||
|
|
||||||
$use_virtio = 1 if $ds =~ m/^virtio/;
|
$use_virtio = 1 if $ds =~ m/^virtio/;
|
||||||
|
|
||||||
if (drive_is_cdrom ($drive)) {
|
if (drive_is_cdrom ($drive)) {
|
||||||
@ -2193,7 +2193,7 @@ sub config_to_command {
|
|||||||
$tmpstr .= ",bootindex=$bootindex";
|
$tmpstr .= ",bootindex=$bootindex";
|
||||||
$bootindex_hash->{n} += 1;
|
$bootindex_hash->{n} += 1;
|
||||||
}
|
}
|
||||||
push @$cmd, '-device', $tmpstr;
|
push @$cmd, '-device', $tmpstr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2265,7 +2265,7 @@ sub vm_devices_list {
|
|||||||
my $bus;
|
my $bus;
|
||||||
my $addr;
|
my $addr;
|
||||||
my $id;
|
my $id;
|
||||||
|
|
||||||
foreach my $line (@lines) {
|
foreach my $line (@lines) {
|
||||||
$line =~ s/^\s+//;
|
$line =~ s/^\s+//;
|
||||||
if ($line =~ m/^Bus (\d+), device (\d+), function (\d+):$/) {
|
if ($line =~ m/^Bus (\d+), device (\d+), function (\d+):$/) {
|
||||||
@ -2285,7 +2285,7 @@ sub vm_devices_list {
|
|||||||
sub vm_deviceplug {
|
sub vm_deviceplug {
|
||||||
my ($storecfg, $conf, $vmid, $deviceid, $device) = @_;
|
my ($storecfg, $conf, $vmid, $deviceid, $device) = @_;
|
||||||
return 1 if !check_running($vmid) || !$conf->{hotplug} || $conf->{$deviceid};
|
return 1 if !check_running($vmid) || !$conf->{hotplug} || $conf->{$deviceid};
|
||||||
|
|
||||||
if ($deviceid =~ m/^(virtio)(\d+)$/) {
|
if ($deviceid =~ m/^(virtio)(\d+)$/) {
|
||||||
return undef if !qemu_driveadd($storecfg, $vmid, $device);
|
return undef if !qemu_driveadd($storecfg, $vmid, $device);
|
||||||
my $devicefull = print_drivedevice_full($storecfg, $vmid, $device);
|
my $devicefull = print_drivedevice_full($storecfg, $vmid, $device);
|
||||||
@ -2346,13 +2346,13 @@ sub qemu_deviceadd {
|
|||||||
|
|
||||||
my $ret = vm_monitor_command($vmid, "device_add $devicefull");
|
my $ret = vm_monitor_command($vmid, "device_add $devicefull");
|
||||||
$ret =~ s/^\s+//;
|
$ret =~ s/^\s+//;
|
||||||
# Otherwise, if the command succeeds, no output is sent. So any non-empty string shows an error
|
# Otherwise, if the command succeeds, no output is sent. So any non-empty string shows an error
|
||||||
return 1 if $ret eq "";
|
return 1 if $ret eq "";
|
||||||
syslog("err", "error on hotplug device : $ret");
|
syslog("err", "error on hotplug device : $ret");
|
||||||
return undef;
|
return undef;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub qemu_devicedel {
|
sub qemu_devicedel {
|
||||||
my($vmid, $deviceid) = @_;
|
my($vmid, $deviceid) = @_;
|
||||||
|
|
||||||
@ -2375,14 +2375,14 @@ sub qemu_driveadd {
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub qemu_drivedel {
|
sub qemu_drivedel {
|
||||||
my($vmid, $deviceid) = @_;
|
my($vmid, $deviceid) = @_;
|
||||||
|
|
||||||
my $ret = vm_monitor_command($vmid, "drive_del drive-$deviceid");
|
my $ret = vm_monitor_command($vmid, "drive_del drive-$deviceid");
|
||||||
$ret =~ s/^\s+//;
|
$ret =~ s/^\s+//;
|
||||||
if ($ret =~ m/Device \'.*?\' not found/s) {
|
if ($ret =~ m/Device \'.*?\' not found/s) {
|
||||||
# NB: device not found errors mean the drive was auto-deleted and we ignore the error
|
# NB: device not found errors mean the drive was auto-deleted and we ignore the error
|
||||||
}
|
}
|
||||||
elsif ($ret ne "") {
|
elsif ($ret ne "") {
|
||||||
syslog("err", "deleting drive $deviceid failed : $ret");
|
syslog("err", "deleting drive $deviceid failed : $ret");
|
||||||
@ -2398,11 +2398,11 @@ sub qemu_deviceaddverify {
|
|||||||
my $devices_list = vm_devices_list($vmid);
|
my $devices_list = vm_devices_list($vmid);
|
||||||
return 1 if defined($devices_list->{$deviceid});
|
return 1 if defined($devices_list->{$deviceid});
|
||||||
sleep 1;
|
sleep 1;
|
||||||
}
|
}
|
||||||
syslog("err", "error on hotplug device $deviceid");
|
syslog("err", "error on hotplug device $deviceid");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub qemu_devicedelverify {
|
sub qemu_devicedelverify {
|
||||||
my ($vmid,$deviceid) = @_;
|
my ($vmid,$deviceid) = @_;
|
||||||
@ -2412,7 +2412,7 @@ sub qemu_devicedelverify {
|
|||||||
my $devices_list = vm_devices_list($vmid);
|
my $devices_list = vm_devices_list($vmid);
|
||||||
return 1 if !defined($devices_list->{$deviceid});
|
return 1 if !defined($devices_list->{$deviceid});
|
||||||
sleep 1;
|
sleep 1;
|
||||||
}
|
}
|
||||||
syslog("err", "error on hot-unplugging device $deviceid");
|
syslog("err", "error on hot-unplugging device $deviceid");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -2487,14 +2487,14 @@ sub vm_start {
|
|||||||
eval { vm_monitor_command($vmid, "cont"); };
|
eval { vm_monitor_command($vmid, "cont"); };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# always set migrate speed (overwrite kvm default of 32m)
|
# always set migrate speed (overwrite kvm default of 32m)
|
||||||
# we set a very hight default of 8192m which is basically unlimited
|
# we set a very hight default of 8192m which is basically unlimited
|
||||||
my $migrate_speed = $defaults->{migrate_speed} || 8192;
|
my $migrate_speed = $defaults->{migrate_speed} || 8192;
|
||||||
$migrate_speed = $conf->{migrate_speed} || $migrate_speed;
|
$migrate_speed = $conf->{migrate_speed} || $migrate_speed;
|
||||||
eval {
|
eval {
|
||||||
my $cmd = "migrate_set_speed ${migrate_speed}m";
|
my $cmd = "migrate_set_speed ${migrate_speed}m";
|
||||||
vm_monitor_command($vmid, $cmd);
|
vm_monitor_command($vmid, $cmd);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (my $migrate_downtime =
|
if (my $migrate_downtime =
|
||||||
@ -2695,7 +2695,7 @@ sub vm_stop {
|
|||||||
vm_monitor_command($vmid, "system_powerdown", $nocheck);
|
vm_monitor_command($vmid, "system_powerdown", $nocheck);
|
||||||
} else {
|
} else {
|
||||||
vm_monitor_command($vmid, "quit", $nocheck);
|
vm_monitor_command($vmid, "quit", $nocheck);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
|
|
||||||
@ -2722,7 +2722,7 @@ sub vm_stop {
|
|||||||
warn "VM quit/powerdown failed - terminating now with SIGTERM\n";
|
warn "VM quit/powerdown failed - terminating now with SIGTERM\n";
|
||||||
kill 15, $pid;
|
kill 15, $pid;
|
||||||
} else {
|
} else {
|
||||||
die "VM quit/powerdown failed\n";
|
die "VM quit/powerdown failed\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2833,7 +2833,7 @@ sub vm_stopall {
|
|||||||
while (($try < $maxtries) && $count) {
|
while (($try < $maxtries) && $count) {
|
||||||
$try++;
|
$try++;
|
||||||
sleep $wt;
|
sleep $wt;
|
||||||
|
|
||||||
$vzlist = vzlist();
|
$vzlist = vzlist();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach my $vmid (keys %$vzlist) {
|
foreach my $vmid (keys %$vzlist) {
|
||||||
@ -2859,7 +2859,7 @@ sub vm_stopall {
|
|||||||
while (($try < $maxtries) && $count) {
|
while (($try < $maxtries) && $count) {
|
||||||
$try++;
|
$try++;
|
||||||
sleep $wt;
|
sleep $wt;
|
||||||
|
|
||||||
$vzlist = vzlist();
|
$vzlist = vzlist();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach my $vmid (keys %$vzlist) {
|
foreach my $vmid (keys %$vzlist) {
|
||||||
@ -2887,9 +2887,9 @@ sub vm_stopall {
|
|||||||
$vzlist = vzlist();
|
$vzlist = vzlist();
|
||||||
foreach my $vmid (keys %$cleanuphash) {
|
foreach my $vmid (keys %$cleanuphash) {
|
||||||
next if $vzlist->{$vmid}->{pid};
|
next if $vzlist->{$vmid}->{pid};
|
||||||
eval {
|
eval {
|
||||||
my $conf = load_config($vmid);
|
my $conf = load_config($vmid);
|
||||||
vm_stop_cleanup($storecfg, $vmid, $conf);
|
vm_stop_cleanup($storecfg, $vmid, $conf);
|
||||||
};
|
};
|
||||||
warn $@ if $@;
|
warn $@ if $@;
|
||||||
}
|
}
|
||||||
@ -2980,7 +2980,7 @@ sub pci_dev_bind_to_stub {
|
|||||||
return -d $testdir;
|
return -d $testdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub print_pci_addr {
|
sub print_pci_addr {
|
||||||
my ($id) = @_;
|
my ($id) = @_;
|
||||||
|
|
||||||
my $res = '';
|
my $res = '';
|
||||||
@ -3026,7 +3026,7 @@ sub vm_balloonset {
|
|||||||
|
|
||||||
sub archive_read_firstfile {
|
sub archive_read_firstfile {
|
||||||
my $archive = shift;
|
my $archive = shift;
|
||||||
|
|
||||||
die "ERROR: file '$archive' does not exist\n" if ! -f $archive;
|
die "ERROR: file '$archive' does not exist\n" if ! -f $archive;
|
||||||
|
|
||||||
# try to detect archive type first
|
# try to detect archive type first
|
||||||
@ -3058,12 +3058,12 @@ sub restore_cleanup {
|
|||||||
my $cfg = cfs_read_file('storage.cfg');
|
my $cfg = cfs_read_file('storage.cfg');
|
||||||
PVE::Storage::vdisk_free($cfg, $volid);
|
PVE::Storage::vdisk_free($cfg, $volid);
|
||||||
}
|
}
|
||||||
print STDERR "temporary volume '$volid' sucessfuly removed\n";
|
print STDERR "temporary volume '$volid' sucessfuly removed\n";
|
||||||
};
|
};
|
||||||
print STDERR "unable to cleanup '$volid' - $@" if $@;
|
print STDERR "unable to cleanup '$volid' - $@" if $@;
|
||||||
} else {
|
} else {
|
||||||
print STDERR "unable to parse line in statfile - $line";
|
print STDERR "unable to parse line in statfile - $line";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$fd->close();
|
$fd->close();
|
||||||
}
|
}
|
||||||
@ -3103,7 +3103,7 @@ sub restore_archive {
|
|||||||
print STDERR "got interrupt - ignored\n";
|
print STDERR "got interrupt - ignored\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
# enable interrupts
|
# enable interrupts
|
||||||
local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
|
local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
|
||||||
die "interrupted by signal\n";
|
die "interrupted by signal\n";
|
||||||
@ -3168,7 +3168,7 @@ sub restore_archive {
|
|||||||
my $net = parse_net($netstr);
|
my $net = parse_net($netstr);
|
||||||
$net->{macaddr} = PVE::Tools::random_ether_addr() if $net->{macaddr};
|
$net->{macaddr} = PVE::Tools::random_ether_addr() if $net->{macaddr};
|
||||||
$netstr = print_net($net);
|
$netstr = print_net($net);
|
||||||
print $outfd "$id: $netstr\n";
|
print $outfd "$id: $netstr\n";
|
||||||
} elsif ($line =~ m/^((ide|scsi|virtio)\d+):\s*(\S+)\s*$/) {
|
} elsif ($line =~ m/^((ide|scsi|virtio)\d+):\s*(\S+)\s*$/) {
|
||||||
my $virtdev = $1;
|
my $virtdev = $1;
|
||||||
my $value = $2;
|
my $value = $2;
|
||||||
@ -3192,14 +3192,14 @@ sub restore_archive {
|
|||||||
};
|
};
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
|
|
||||||
if ($err) {
|
if ($err) {
|
||||||
|
|
||||||
unlink $tmpfn;
|
unlink $tmpfn;
|
||||||
|
|
||||||
restore_cleanup("$tmpdir/qmrestore.stat") if !$opts->{info};
|
restore_cleanup("$tmpdir/qmrestore.stat") if !$opts->{info};
|
||||||
|
|
||||||
die $err;
|
die $err;
|
||||||
}
|
}
|
||||||
|
|
||||||
rmtree $tmpdir;
|
rmtree $tmpdir;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user