Skip to content

Commit

Permalink
F#3244: Better mixed modes (#3574)
Browse files Browse the repository at this point in the history
  • Loading branch information
xorel authored and Ruben S. Montero committed Aug 7, 2019
1 parent 598bf6c commit e98c801
Show file tree
Hide file tree
Showing 25 changed files with 1,206 additions and 362 deletions.
2 changes: 1 addition & 1 deletion include/VirtualMachineDisk.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class VirtualMachineDisk : public VirtualMachineAttribute
/**
* Return the TM_MAD_SYSTEM attribute
*/
std::string get_tm_mad_system();
std::string get_tm_mad_system() const;

/* ---------------------------------------------------------------------- */
/* Image Manager Interface */
Expand Down
12 changes: 11 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1230,8 +1230,10 @@ TM_FS_LVM_ETC_FILES="src/tm_mad/fs_lvm/fs_lvm.conf"


TM_QCOW2_FILES="src/tm_mad/qcow2/clone \
src/tm_mad/qcow2/clone.ssh \
src/tm_mad/qcow2/delete \
src/tm_mad/qcow2/ln \
src/tm_mad/qcow2/ln.ssh \
src/tm_mad/qcow2/monitor \
src/tm_mad/qcow2/mkswap \
src/tm_mad/qcow2/mkimage \
Expand All @@ -1241,11 +1243,13 @@ TM_QCOW2_FILES="src/tm_mad/qcow2/clone \
src/tm_mad/qcow2/postmigrate \
src/tm_mad/qcow2/failmigrate \
src/tm_mad/qcow2/mvds \
src/tm_mad/qcow2/mvds.ssh \
src/tm_mad/qcow2/snap_create \
src/tm_mad/qcow2/snap_create_live \
src/tm_mad/qcow2/snap_delete \
src/tm_mad/qcow2/snap_revert \
src/tm_mad/qcow2/cpds \
src/tm_mad/qcow2/cpds.ssh \
src/tm_mad/qcow2/resize"

TM_SSH_FILES="src/tm_mad/ssh/clone \
Expand Down Expand Up @@ -1288,10 +1292,14 @@ TM_DUMMY_FILES="src/tm_mad/dummy/clone \
src/tm_mad/dummy/resize"

TM_CEPH_FILES="src/tm_mad/ceph/clone \
src/tm_mad/ceph/clone.ssh \
src/tm_mad/ceph/ln \
src/tm_mad/ceph/ln.ssh \
src/tm_mad/ceph/mv \
src/tm_mad/ceph/mvds \
src/tm_mad/ceph/mvds.ssh \
src/tm_mad/ceph/cpds \
src/tm_mad/ceph/cpds.ssh \
src/tm_mad/ceph/premigrate \
src/tm_mad/ceph/postmigrate \
src/tm_mad/ceph/snap_create \
Expand All @@ -1300,11 +1308,13 @@ TM_CEPH_FILES="src/tm_mad/ceph/clone \
src/tm_mad/ceph/snap_revert \
src/tm_mad/ceph/failmigrate \
src/tm_mad/ceph/delete \
src/tm_mad/ceph/delete.ssh \
src/tm_mad/ceph/context \
src/tm_mad/ceph/mkimage \
src/tm_mad/ceph/monitor \
src/tm_mad/ceph/mkswap \
src/tm_mad/ceph/resize"
src/tm_mad/ceph/resize \
src/tm_mad/ceph/resize.ssh"

TM_DEV_FILES="src/tm_mad/dev/clone \
src/tm_mad/dev/ln \
Expand Down
141 changes: 114 additions & 27 deletions src/tm/TransferManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ int TransferManager::prolog_transfer_command(
string size;
string format;
string tm_mad;
string tm_mad_system;
string ds_id;

int disk_id = disk->get_disk_id();
Expand Down Expand Up @@ -416,21 +417,27 @@ int TransferManager::prolog_transfer_command(

one_util::toupper(clon);

std::string tsys = disk->get_tm_mad_system();
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}

// -----------------------------------------------------------------
// CLONE or LINK disk images
// -----------------------------------------------------------------

// <CLONE|LN> tm_mad fe:SOURCE host:remote_system_ds/disk.i vmid dsid
// <CLONE|LN>(.tm_mad_system) tm_mad fe:SOURCE host:remote_system_ds/disk.i vmid dsid"
if (clon == "YES")
{
xfr << "CLONE ";
xfr << "CLONE";
}
else
{
xfr << "LN ";
xfr << "LN";
}

xfr << tm_mad << " ";
xfr << tm_mad_system << " " << tm_mad << " ";

if ( source.find(":") == string::npos ) //Regular file
{
Expand Down Expand Up @@ -722,6 +729,7 @@ void TransferManager::prolog_migr_action(int vid)
string xfr_name;

string tm_mad;
string tm_mad_system;
string vm_tm_mad;

int ds_id;
Expand Down Expand Up @@ -791,9 +799,16 @@ void TransferManager::prolog_migr_action(int vid)
}
}

//MV tm_mad prev_host:remote_system_dir/disk.i host:remote_system_dir/disk.i vmid dsid(image)
xfr << "MV "
<< tm_mad << " "
string tsys = (*disk)->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}

//MV(.tm_mad_system) tm_mad prev_host:remote_system_dir/disk.i host:remote_system_dir/disk.i vmid dsid(image)
xfr << "MV"
<< tm_mad_system
<< " " << tm_mad << " "
<< vm->get_previous_hostname() << ":"
<< vm->get_previous_system_dir() << "/disk." << disk_id << " "
<< vm->get_hostname() << ":"
Expand Down Expand Up @@ -852,6 +867,7 @@ void TransferManager::prolog_resume_action(int vid)
string xfr_name;

string tm_mad;
string tm_mad_system;
string vm_tm_mad;
string token_password;

Expand Down Expand Up @@ -926,9 +942,16 @@ void TransferManager::prolog_resume_action(int vid)
}
}

//MV tm_mad fe:system_dir/disk.i host:remote_system_dir/disk.i vmid dsid(image)
xfr << "MV "
<< tm_mad << " "
string tsys = (*disk)->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}

//MV(.tm_mad_system) tm_mad fe:system_dir/disk.i host:remote_system_dir/disk.i vmid dsid(image)
xfr << "MV"
<< tm_mad_system
<< " " << tm_mad << " "
<< nd.get_nebula_hostname() << ":"
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_hostname() << ":"
Expand Down Expand Up @@ -1102,6 +1125,7 @@ void TransferManager::epilog_transfer_command(
{
string save = disk->vector_value("SAVE");
int disk_id = disk->get_disk_id();
string tm_mad_system;

if ( one_util::toupper(save) == "YES" )
{
Expand All @@ -1121,9 +1145,15 @@ void TransferManager::epilog_transfer_command(
return;
}

//MVDS tm_mad hostname:remote_system_dir/disk.0 <fe:SOURCE|SOURCE> vmid dsid
xfr << "MVDS "
<< tm_mad << " "
string tsys = disk->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}

//MVDS(.tm_mad_system) tm_mad hostname:remote_system_dir/disk.0 <fe:SOURCE|SOURCE> vmid dsid
xfr << "MVDS" << tm_mad_system
<< " " << tm_mad << " "
<< host << ":" << vm->get_system_dir() << "/disk." << disk_id << " "
<< source << " "
<< vm->get_oid() << " "
Expand All @@ -1148,10 +1178,17 @@ void TransferManager::epilog_transfer_command(
vv_rc = disk->vector_value("DATASTORE_ID", ds_id_i);
}

string tsys = disk->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}

if ( !tm_mad.empty() && vv_rc == 0)
{
//DELETE tm_mad hostname:remote_system_dir/disk.i vmid ds_id
xfr << "DELETE "
//DELETE(.tm_mad_system) tm_mad hostname:remote_system_dir/disk.i vmid ds_id
xfr << "DELETE"
<< tm_mad_system << " "
<< tm_mad << " "
<< host << ":" << vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
Expand Down Expand Up @@ -1278,6 +1315,7 @@ void TransferManager::epilog_stop_action(int vid)

string xfr_name;
string tm_mad;
string tm_mad_system;
string vm_tm_mad;

int ds_id;
Expand Down Expand Up @@ -1346,9 +1384,16 @@ void TransferManager::epilog_stop_action(int vid)
}
}

string tsys = (*disk)->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}

//MV tm_mad host:remote_system_dir/disk.i fe:system_dir/disk.i vmid dsid(image)
xfr << "MV "
<< tm_mad << " "
xfr << "MV"
<< tm_mad_system
<< " " << tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< nd.get_nebula_hostname() << ":"
Expand Down Expand Up @@ -1409,6 +1454,7 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,

string vm_tm_mad;
string tm_mad;
string tm_mad_system;
string host;
string system_dir;

Expand Down Expand Up @@ -1487,11 +1533,17 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
}
}

//DELETE tm_mad host:remote_system_dir/disk.i vmid dsid(image)
string tsys = (*disk)->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}

//DELETE tm_mad(.tm_mad_system) host:remote_system_dir/disk.i vmid dsid(image)
// *local* DELETE tm_mad fe:system_dir/disk.i vmid dsid(image)
// *prev* DELETE tm_mad prev_host:remote_system_dir/disk.i vmid ds_id(image)
xfr << "DELETE "
<< tm_mad << " "
xfr << "DELETE" << tm_mad_system
<< " " << tm_mad << " "
<< host << ":"
<< system_dir << "/disk." << disk_id << " "
<< vm->get_oid() << " "
Expand Down Expand Up @@ -1898,6 +1950,8 @@ void TransferManager::saveas_hot_action(int vid)
string snap_id;
string tm_mad;
string ds_id;
string tsys;
string tm_mad_system;

ostringstream os;

Expand All @@ -1906,6 +1960,7 @@ void TransferManager::saveas_hot_action(int vid)

VirtualMachine * vm;
const TransferManagerDriver * tm_md;
VirtualMachineDisk * disk;

Nebula& nd = Nebula::instance();

Expand Down Expand Up @@ -1944,9 +1999,20 @@ void TransferManager::saveas_hot_action(int vid)
goto error_file;
}

disk = vm->get_disk(disk_id);

if (disk != nullptr)
{
tsys = disk->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}
}

//CPDS tm_mad hostname:remote_system_dir/disk.0 source snapid vmid dsid
xfr << "CPDS "
<< tm_mad << " "
xfr << "CPDS" << tm_mad_system
<< " " << tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< src << " "
Expand Down Expand Up @@ -2015,9 +2081,12 @@ int TransferManager::snapshot_transfer_command(
VirtualMachine * vm, const char * snap_action, ostream& xfr)
{
string tm_mad;
string tsys;
string tm_mad_system;
int ds_id;
int disk_id;
int snap_id;
VirtualMachineDisk * disk;

if (vm->get_snapshot_disk(ds_id, tm_mad, disk_id, snap_id) == -1)
{
Expand All @@ -2026,8 +2095,19 @@ int TransferManager::snapshot_transfer_command(
return -1;
}

//SNAP_CREATE tm_mad host:remote_system_dir/disk.0 snapid vmid dsid
xfr << snap_action << " "
disk = vm->get_disk(disk_id);

if (disk != nullptr)
{
tsys = disk->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}
}

//SNAP_CREATE(.tm_mad_system) tm_mad host:remote_system_dir/disk.0 snapid vmid dsid
xfr << snap_action << tm_mad_system << " "
<< tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_system_dir() << "/disk." << disk_id << " "
Expand Down Expand Up @@ -2141,6 +2221,7 @@ void TransferManager::resize_command(VirtualMachine * vm,
const VirtualMachineDisk * disk, ostream& xfr)
{
string tm_mad;
string tm_mad_system;
string ds_id;

if ( disk->is_volatile() )
Expand All @@ -2154,9 +2235,15 @@ void TransferManager::resize_command(VirtualMachine * vm,
ds_id = disk->vector_value("DATASTORE_ID");
}

//RESIZE tm_mad host:remote_system_dir/disk.i size vmid dsid
xfr << "RESIZE "
<< tm_mad << " "
string tsys = disk->vector_value("TM_MAD_SYSTEM");
if (!tsys.empty())
{
tm_mad_system = "." + tsys;
}

//RESIZE.(tm_mad_system) tm_mad host:remote_system_dir/disk.i size vmid dsid
xfr << "RESIZE" << tm_mad_system
<< " " << tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_system_dir()<< "/disk."<< disk->vector_value("DISK_ID")<< " "
<< disk->vector_value("SIZE") << " "
Expand Down
Loading

0 comments on commit e98c801

Please sign in to comment.