mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-22 22:03:39 +03:00
F #5681: Support for block context devices
Add support for block context CD's. System Datastore can include CONTEXT_DISK_TYPE to specify the type (FILER or BLOCK) of the context CD's co-authored-by: Victor Palma
This commit is contained in:
parent
8689d5d49b
commit
4df86811b9
@ -188,6 +188,8 @@ public:
|
||||
return type;
|
||||
};
|
||||
|
||||
Image::DiskType context_disk_type() const;
|
||||
|
||||
/**
|
||||
* Modifies the given VM disk attribute adding the relevant datastore
|
||||
* attributes
|
||||
|
@ -1173,3 +1173,40 @@ int Datastore::get_tm_mad_targets(const string &tm_mad, string& ln_target,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
Image::DiskType Datastore::context_disk_type() const
|
||||
{
|
||||
Image::DiskType ctxt_dt = Image::FILE;
|
||||
string ctxt_dt_s;
|
||||
|
||||
get_template_attribute("CONTEXT_DISK_TYPE", ctxt_dt_s);
|
||||
|
||||
if (!ctxt_dt_s.empty())
|
||||
{
|
||||
ctxt_dt = Image::str_to_disk_type(ctxt_dt_s);
|
||||
}
|
||||
|
||||
switch(ctxt_dt)
|
||||
{
|
||||
//Valid disk types for context devices
|
||||
case Image::FILE:
|
||||
case Image::BLOCK:
|
||||
return ctxt_dt;
|
||||
|
||||
case Image::NONE:
|
||||
case Image::ISCSI:
|
||||
case Image::RBD:
|
||||
case Image::GLUSTER:
|
||||
case Image::SHEEPDOG:
|
||||
case Image::CD_ROM:
|
||||
case Image::RBD_CDROM:
|
||||
case Image::SHEEPDOG_CDROM:
|
||||
case Image::GLUSTER_CDROM:
|
||||
break;
|
||||
}
|
||||
|
||||
return Image::FILE;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "VirtualNetwork.h"
|
||||
#include "ObjectXML.h"
|
||||
#include "Nebula.h"
|
||||
#include "Image.h"
|
||||
#include "DatastorePool.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
@ -1517,10 +1519,31 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
if ( !target.empty() )
|
||||
{
|
||||
ostringstream fname;
|
||||
Image::DiskType ctxt_disk_type = Image::FILE;
|
||||
|
||||
string s_cdt;
|
||||
|
||||
if (auto ds = nd.get_dspool()->get_ro(vm->get_ds_id()))
|
||||
{
|
||||
ctxt_disk_type = ds->context_disk_type();
|
||||
}
|
||||
|
||||
switch (ctxt_disk_type)
|
||||
{
|
||||
case Image::FILE:
|
||||
s_cdt = "file";
|
||||
break;
|
||||
case Image::BLOCK:
|
||||
s_cdt = "block";
|
||||
break;
|
||||
default:
|
||||
s_cdt = "file";
|
||||
break;
|
||||
}
|
||||
|
||||
fname << vm->get_system_dir() << "/disk." << disk_id;
|
||||
|
||||
file << "\t\t<disk type='file' device='cdrom'>\n"
|
||||
file << "\t\t<disk type='" << s_cdt << "' device='cdrom'>\n"
|
||||
<< "\t\t\t<source file="
|
||||
<< one_util::escape_xml_attr(fname.str()) << "/>\n"
|
||||
<< "\t\t\t<target dev=" << one_util::escape_xml_attr(target);
|
||||
|
Loading…
x
Reference in New Issue
Block a user