@@ -24,23 +24,53 @@ def try_to_create_sr_with_missing_device(sr_type, label, host):
2424 return
2525 assert False , 'SR creation should not have succeeded!'
2626
27- def cold_migration_then_come_back (vm , prov_host , dest_host , dest_sr ):
27+ def cold_migration_then_come_back (vm : VM , prov_host : Host , dest_host : Host , dest_sr : SR ):
2828 """ Storage migration of a shutdown VM, then migrate it back. """
2929 prov_sr = vm .get_sr ()
30+ vdi_name = None
31+
32+ if not vm .is_windows :
33+ # the vdi will be destroyed with the vm
34+ vdi = prov_sr .create_vdi (virtual_size = 1 * GiB )
35+ vdi_name = vdi .name ()
36+ vm .connect_vdi (vdi , 'xvdb' )
37+ vm .start ()
38+ vm .wait_for_vm_running_and_ssh_up ()
39+ install_randstream (vm )
40+ logging .info ("Generate /dev/xvdb content" )
41+ vm .ssh ("randstream generate -v /dev/xvdb" )
42+ logging .info ("Validate /dev/xvdb" )
43+ vm .ssh (f"randstream validate -v --expected-checksum { RANDSTREAM_1GIB_CHECKSUM } /dev/xvdb" )
44+ vm .shutdown (verify = True )
45+
3046 assert vm .is_halted ()
47+
3148 # Move the VM to another host of the pool
3249 vm .migrate (dest_host , dest_sr )
3350 wait_for (lambda : vm .all_vdis_on_sr (dest_sr ), "Wait for all VDIs on destination SR" )
51+
3452 # Start VM to make sure it works
3553 vm .start (on = dest_host .uuid )
36- vm .wait_for_os_booted ()
54+ if vm .is_windows :
55+ vm .wait_for_os_booted ()
56+ else :
57+ vm .wait_for_vm_running_and_ssh_up ()
58+ logging .info ("Validate /dev/xvdb" )
59+ vm .ssh (f"randstream validate -v --expected-checksum { RANDSTREAM_1GIB_CHECKSUM } /dev/xvdb" )
3760 vm .shutdown (verify = True )
61+
3862 # Migrate it back to the provenance SR
3963 vm .migrate (prov_host , prov_sr )
4064 wait_for (lambda : vm .all_vdis_on_sr (prov_sr ), "Wait for all VDIs back on provenance SR" )
65+
4166 # Start VM to make sure it works
4267 vm .start (on = prov_host .uuid )
43- vm .wait_for_os_booted ()
68+ if vm .is_windows :
69+ vm .wait_for_os_booted ()
70+ else :
71+ vm .wait_for_vm_running_and_ssh_up ()
72+ logging .info ("Validate /dev/xvdb" )
73+ vm .ssh (f"randstream validate -v --expected-checksum { RANDSTREAM_1GIB_CHECKSUM } /dev/xvdb" )
4474 vm .shutdown (verify = True )
4575
4676 if vdi_name is not None :
0 commit comments