1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-04-02 10:50:07 +03:00

B #3687: check snap ID on disk snapshot revert (#3693)

This commit is contained in:
Christian González 2019-09-12 17:55:45 +02:00 committed by Ruben S. Montero
parent e692b9ecdd
commit 68a76aa9ba
3 changed files with 22 additions and 0 deletions

View File

@ -245,6 +245,17 @@ public:
return (snapshots != 0);
}
bool has_snapshot(int snap_id)
{
if (!has_snapshots())
{
return false;
}
return snapshots->exists(snap_id);
}
/**
* Renames a snapshot
*

View File

@ -2071,6 +2071,12 @@ int DispatchManager::disk_snapshot_revert(int vid, int did, int snap_id,
if (vm->set_snapshot_disk(did, snap_id) == -1)
{
oss << "Disk id (" << did << ") or snapshot id ("
<< snap_id << ") is not invalid.";
error_str = oss.str();
NebulaLog::log("DiM", Log::ERROR, error_str);
vm->unlock();
return -1;
}

View File

@ -1270,6 +1270,11 @@ int VirtualMachineDisks::set_active_snapshot(int id, int snap_id)
return -1;
}
if (!disk->has_snapshot(snap_id))
{
return -1;
}
disk->set_active_snapshot();
disk->replace("DISK_SNAPSHOT_ID", snap_id);