mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-02 15:25:36 +00:00
destroy old data when restore with --force
This commit is contained in:
parent
3e16d5fc60
commit
a6af7b3e35
@ -142,6 +142,9 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
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
|
||||||
|
PVE::QemuServer::destroy_vm($storecfg, $vmid, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $realcmd = sub {
|
my $realcmd = sub {
|
||||||
|
@ -1339,7 +1339,7 @@ sub unlink_image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub destroy_vm {
|
sub destroy_vm {
|
||||||
my ($storecfg, $vmid) = @_;
|
my ($storecfg, $vmid, $keep_empty_config) = @_;
|
||||||
|
|
||||||
my $conffile = config_file($vmid);
|
my $conffile = config_file($vmid);
|
||||||
|
|
||||||
@ -1362,7 +1362,11 @@ sub destroy_vm {
|
|||||||
PVE::Storage::vdisk_free($storecfg, $volid);
|
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
|
# also remove unused disk
|
||||||
eval {
|
eval {
|
||||||
|
Loading…
Reference in New Issue
Block a user