destroy old data when restore with --force

This commit is contained in:
Dietmar Maurer 2011-10-18 07:42:29 +02:00
parent 3e16d5fc60
commit a6af7b3e35
2 changed files with 9 additions and 2 deletions

View File

@ -142,6 +142,9 @@ __PACKAGE__->register_method({
die "unable to restore vm $vmid: vm is running\n"
if PVE::QemuServer::check_running($vmid);
# destroy existing data - keep empty config
PVE::QemuServer::destroy_vm($storecfg, $vmid, 1);
}
my $realcmd = sub {

View File

@ -1339,7 +1339,7 @@ sub unlink_image {
}
sub destroy_vm {
my ($storecfg, $vmid) = @_;
my ($storecfg, $vmid, $keep_empty_config) = @_;
my $conffile = config_file($vmid);
@ -1362,7 +1362,11 @@ sub destroy_vm {
PVE::Storage::vdisk_free($storecfg, $volid);
});
unlink $conffile;
if ($keep_empty_config) {
PVE::Tools::file_set_contents($conffile, "mem: 128\n");
} else {
unlink $conffile;
}
# also remove unused disk
eval {