1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-05 09:17:41 +03:00

F #6524: Check free space on backup DS (#3214)

This commit is contained in:
Pavel Czerný 2024-09-04 13:27:33 +02:00 committed by GitHub
parent c8c66b1d8f
commit ccc8ccfc34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 11 deletions

View File

@ -3956,6 +3956,7 @@ Request::ErrorCode VirtualMachineBackup::request_execute(RequestAttributes& att,
Backups::Mode mode;
int li_id;
int bk_id = -1;
long long backup_size = 0;
// ------------------------------------------------------------------------
// Get VM & Backup Information
@ -3964,7 +3965,7 @@ Request::ErrorCode VirtualMachineBackup::request_execute(RequestAttributes& att,
{
vm->get_permissions(vm_perms);
vm->backup_size(quota_tmpl);
backup_size = vm->backup_size(quota_tmpl);
mode = vm->backups().mode();
li_id = vm->backups().last_increment_id();
@ -4005,6 +4006,16 @@ Request::ErrorCode VirtualMachineBackup::request_execute(RequestAttributes& att,
return ACTION;
}
long long free_mb;
bool check_capacity = ds->get_avail_mb(free_mb);
if (check_capacity && free_mb < backup_size)
{
att.resp_msg = "Not enough free space on target datastore";
return ACTION;
}
ds->get_permissions(ds_perms);
}
else

View File

@ -1571,19 +1571,14 @@ long long VirtualMachineDisks::backup_size(Template &ds_quotas, bool do_volatile
{
long long size = 0;
for (const auto disk : *this)
vector<int> ids;
backup_disk_ids(do_volatile, ids);
for (int id : ids)
{
auto disk = get_disk(id);
long long disk_size = 0;
string type = disk->vector_value("TYPE");
one_util::toupper(type);
if ((type == "SWAP") || ((type == "FS") && !do_volatile))
{
continue;
}
disk->vector_value("SIZE", disk_size);
size += disk_size;