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

Bug #4042: Use disk size in vm saveas

(cherry picked from commit f42a8d8693)
This commit is contained in:
Carlos Martín 2015-10-16 17:56:29 +02:00
parent 41b929d4b3
commit 23fefa0256
3 changed files with 16 additions and 9 deletions

View File

@ -1335,10 +1335,13 @@ public:
* Mark the disk that is going to be "save as"
* @param disk_id of the VM
* @param snap_id of the disk to save, -1 to select the active snapshot
* @param err_str describing the error
* @return -1 if the image cannot saveas or image_id of current disk
* @param img_id The image id used by the disk
* @param size The disk size. This may be different to the original
* image size
* @param err_str describing the error if any
* @return -1 if the image cannot saveas, 0 on success
*/
int set_saveas_disk(int disk_id, int snap_id, string& err_str);
int set_saveas_disk(int disk_id, int snap_id, int &img_id, long long &size, string& err_str);
/**
* Set save attributes for the disk

View File

@ -1235,9 +1235,9 @@ void VirtualMachineDiskSaveas::request_execute(
goto error_state;
}
iid_orig = vm->set_saveas_disk(disk_id, snap_id, error);
rc = vm->set_saveas_disk(disk_id, snap_id, iid_orig, size, error);
if (iid_orig == -1)
if (rc == -1)
{
goto error_disk;
}
@ -1259,7 +1259,6 @@ void VirtualMachineDiskSaveas::request_execute(
ds_id = img->get_ds_id();
ds_name = img->get_ds_name();
size = img->get_size();
type = img->get_type();
iname_orig = img->get_name();

View File

@ -3375,9 +3375,10 @@ const VectorAttribute* VirtualMachine::get_disk(int disk_id) const
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachine::set_saveas_disk(int disk_id, int snap_id, string& err_str)
int VirtualMachine::set_saveas_disk(int disk_id, int snap_id, int &iid,
long long &size, string& err_str)
{
int iid = -1;
iid = -1;
VectorAttribute * disk = get_disk(disk_id);
@ -3389,6 +3390,7 @@ int VirtualMachine::set_saveas_disk(int disk_id, int snap_id, string& err_str)
if (disk->vector_value("IMAGE_ID", iid) != 0)
{
iid = -1;
err_str = "DISK does not have a valid IMAGE_ID.";
return -1;
}
@ -3407,7 +3409,10 @@ int VirtualMachine::set_saveas_disk(int disk_id, int snap_id, string& err_str)
disk->replace("HOTPLUG_SAVE_AS_ACTIVE", "YES");
disk->replace("HOTPLUG_SAVE_AS_SNAPSHOT_ID", snap_id);
return iid;
size = 0;
disk->vector_value("SIZE", size);
return 0;
}
/* -------------------------------------------------------------------------- */