F #4089: fix format for save_as images (#277)

This commit is contained in:
Christian González authored and GitHub committed 2020-10-01 18:47:36 +02:00
1 parent a477ba03b2
commit 8a875e8888
3 files changed
+28 -8

No files matched your search

+1 -1
View File
@@ -184,7 +184,7 @@ int Image::insert(SqlDB *db, string& error_str)
{
goto error_path_and_source;
}
/* MKFS image, FORMAT is mandatory, precedence:
* 1. TM_MAD_CONF/DRIVER in oned.conf
* 2. DRIVER in DS Template
+27
View File
@@ -243,6 +243,8 @@ void ImageManager::_mkfs(unique_ptr<image_msg_t> msg)
ostringstream oss;
string format;
Nebula& nd = Nebula::instance();
VirtualMachinePool * vmpool = nd.get_vmpool();
TransferManager * tm = nd.get_tm();
@@ -316,6 +318,13 @@ void ImageManager::_mkfs(unique_ptr<image_msg_t> msg)
goto error_save_state;
}
format = vm->get_disk(disk_id)->vector_value("FORMAT");
if (format.empty())
{
format = vm->get_disk(disk_id)->vector_value("DRIVER");
}
tm->trigger_saveas_hot(vm_id);
vmpool->update(vm.get());
@@ -325,6 +334,20 @@ void ImageManager::_mkfs(unique_ptr<image_msg_t> msg)
goto error_save_get;
}
if (format.empty())
{
goto error_fmt;
}
if (image = ipool->get(msg->oid()))
{
image->set_format(format);
ipool->update(image.get());
}
image.reset();
monitor_datastore(ds_id);
return;
@@ -333,6 +356,10 @@ error_img:
oss << "Error creating datablock";
goto error;
error_fmt:
oss << "Image created to save as a disk but VM disk does not contains either FORMAT or DRIVER attribute.";
goto error_save;
error_save_get:
oss << "Image created to save as a disk but VM does not exist.";
goto error_save;
-7
View File
@@ -1376,7 +1376,6 @@ void VirtualMachineDiskSaveas::request_execute(
string ds_mad;
string tm_mad;
string driver;
string target;
string dev_prefix;
@@ -1440,7 +1439,6 @@ void VirtualMachineDiskSaveas::request_execute(
iname_orig = img->get_name();
iuname_orig = img->get_uname();
img->get_template_attribute("DRIVER", driver);
img->get_template_attribute("TARGET", target);
img->get_template_attribute("DEV_PREFIX", dev_prefix);
}
@@ -1508,11 +1506,6 @@ void VirtualMachineDiskSaveas::request_execute(
itemplate->add("TYPE", img_type);
}
if (!driver.empty())
{
itemplate->add("DRIVER", driver);
}
if (!target.empty())
{
itemplate->add("TARGET", target);