@@ -221,7 +221,9 @@ string VirtualMachineManager::format_message(
221221 const string& tmpl,
222222 int ds_id,
223223 int sgid,
224- int nicid)
224+ int nicid,
225+ const string& lmfile,
226+ const string& rmfile)
225227{
226228 ostringstream oss;
227229
@@ -266,6 +268,17 @@ string VirtualMachineManager::format_message(
266268 oss << " <REMOTE_DEPLOYMENT_FILE/>" ;
267269 }
268270
271+ if (!lmfile.empty ())
272+ {
273+ oss << " <LOCAL_MIGRATE_FILE>" << lmfile << " </LOCAL_MIGRATE_FILE>" ;
274+ oss << " <REMOTE_MIGRATE_FILE>" << rmfile << " </REMOTE_MIGRATE_FILE>" ;
275+ }
276+ else
277+ {
278+ oss << " <LOCAL_MIGRATE_FILE/>" ;
279+ oss << " <REMOTE_MIGRATE_FILE/>" ;
280+ }
281+
269282 if (!cfile.empty ())
270283 {
271284 oss << " <CHECKPOINT_FILE>" << cfile << " </CHECKPOINT_FILE>" ;
@@ -495,8 +508,9 @@ void VirtualMachineManager::trigger_save(int vid)
495508 trigger ([this , vid]
496509 {
497510 const VirtualMachineManagerDriver * vmd;
511+ int rc;
498512
499- string hostname, checkpoint_file;
513+ string hostname, checkpoint_file, migrate_file, rmigrate_file ;
500514 string vm_tmpl;
501515 string drv_msg;
502516 int ds_id;
@@ -535,12 +549,31 @@ void VirtualMachineManager::trigger_save(int vid)
535549 hostname = vm->get_previous_hostname ();
536550 checkpoint_file = vm->get_previous_checkpoint_file ();
537551 ds_id = vm->get_previous_ds_id ();
552+
553+ // Generate VM description file
554+ os << " Generating migrate file: " << vm->get_migrate_file ();
555+
556+ vm->log (" VMM" , Log::INFO, os);
557+
558+ os.str (" " );
559+
560+ rc = vmd->deployment_description (vm.get (), vm->get_migrate_file ());
561+
562+ if (rc != 0 )
563+ {
564+ goto error_file;
565+ }
566+
567+ migrate_file = vm->get_migrate_file ();
568+ rmigrate_file = vm->get_rmigrate_file ();
538569 }
539570 else
540571 {
541572 hostname = vm->get_hostname ();
542573 checkpoint_file = vm->get_checkpoint_file ();
543574 ds_id = vm->get_ds_id ();
575+ migrate_file = " " ;
576+ rmigrate_file = " " ;
544577 }
545578
546579 // Invoke driver method
@@ -556,7 +589,10 @@ void VirtualMachineManager::trigger_save(int vid)
556589 " " ,
557590 vm->to_xml (vm_tmpl),
558591 ds_id,
559- -1 );
592+ -1 ,
593+ -1 ,
594+ migrate_file,
595+ rmigrate_file);
560596
561597 vmd->save (vid, drv_msg);
562598
@@ -570,6 +606,11 @@ void VirtualMachineManager::trigger_save(int vid)
570606 os << " save_action, error getting driver " << vm->get_vmm_mad ();
571607 goto error_common;
572608
609+ error_file:
610+ os << " save_action, error generating migrate file: "
611+ << vm->get_migrate_file ();
612+ goto error_common;
613+
573614error_previous_history:
574615 os << " save_action, VM has no previous history" ;
575616
@@ -1154,10 +1195,12 @@ void VirtualMachineManager::trigger_migrate(int vid)
11541195 trigger ([this , vid]
11551196 {
11561197 const VirtualMachineManagerDriver * vmd;
1198+ int rc;
11571199
11581200 ostringstream os;
11591201 string vm_tmpl;
11601202 string drv_msg;
1203+ string tm_command = " " ;
11611204
11621205 // Get the VM from the pool
11631206 auto vm = vmpool->get (vid);
@@ -1187,6 +1230,24 @@ void VirtualMachineManager::trigger_migrate(int vid)
11871230
11881231 Nebula::instance ().get_tm ()->migrate_transfer_command (vm.get (), os);
11891232
1233+ tm_command = os.str ();
1234+
1235+ os.str (" " );
1236+
1237+ // Generate VM description file
1238+ os << " Generating migrate file: " << vm->get_migrate_file ();
1239+
1240+ vm->log (" VMM" , Log::INFO, os);
1241+
1242+ os.str (" " );
1243+
1244+ rc = vmd->deployment_description (vm.get (), vm->get_migrate_file ());
1245+
1246+ if (rc != 0 )
1247+ {
1248+ goto error_file;
1249+ }
1250+
11901251 // Invoke driver method
11911252 drv_msg = format_message (
11921253 vm->get_previous_hostname (),
@@ -1195,12 +1256,15 @@ void VirtualMachineManager::trigger_migrate(int vid)
11951256 " " ,
11961257 " " ,
11971258 " " ,
1198- os. str () ,
1259+ tm_command ,
11991260 " " ,
12001261 vm->get_system_dir (),
12011262 vm->to_xml (vm_tmpl),
12021263 vm->get_previous_ds_id (),
1203- -1 );
1264+ -1 ,
1265+ -1 ,
1266+ vm->get_migrate_file (),
1267+ vm->get_rmigrate_file ());
12041268
12051269 vmd->migrate (vid, drv_msg);
12061270
@@ -1214,6 +1278,11 @@ void VirtualMachineManager::trigger_migrate(int vid)
12141278 os << " migrate_action, error getting driver " << vm->get_vmm_mad ();
12151279 goto error_common;
12161280
1281+ error_file:
1282+ os << " migrate_action, error generating migrate file: "
1283+ << vm->get_migrate_file ();
1284+ goto error_common;
1285+
12171286error_previous_history:
12181287 os << " migrate_action, error VM has no previous history" ;
12191288
0 commit comments