@@ -53,7 +53,7 @@ def cold_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Host, dest
5353 vdi_name : str | None = None
5454 integrity_check = not vm .is_windows
5555 dev = ""
56- checksum = ""
56+ checksums = ( '' , '' , '' )
5757
5858 if integrity_check :
5959 # the vdi will be destroyed with the vm
@@ -64,10 +64,8 @@ def cold_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Host, dest
6464 vm .wait_for_vm_running_and_ssh_up ()
6565 install_randstream (vm )
6666 dev = f'/dev/{ vbd .param_get ("device" )} '
67- logging .info (f"Generate { dev } content" )
68- checksum = randstream (vm , f'generate { dev } ' )
69- logging .info (f"Validate { dev } " )
70- randstream (vm , f'validate --expected-checksum { checksum } { dev } ' )
67+ checksums = partially_populate_device (vm , dev , config .volume_size )
68+ validate_partially_populated_device (vm , dev , config .volume_size , checksums )
7169 vm .shutdown (verify = True )
7270
7371 assert vm .is_halted ()
@@ -81,8 +79,7 @@ def cold_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Host, dest
8179 vm .wait_for_os_booted ()
8280 if integrity_check :
8381 vm .wait_for_vm_running_and_ssh_up ()
84- logging .info (f"Validate { dev } " )
85- randstream (vm , f'validate --expected-checksum { checksum } { dev } ' )
82+ validate_partially_populated_device (vm , dev , config .volume_size , checksums )
8683 vm .shutdown (verify = True )
8784
8885 # Migrate it back to the provenance SR
@@ -94,8 +91,7 @@ def cold_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Host, dest
9491 vm .wait_for_os_booted ()
9592 if integrity_check :
9693 vm .wait_for_vm_running_and_ssh_up ()
97- logging .info (f"Validate { dev } " )
98- randstream (vm , f'validate --expected-checksum { checksum } { dev } ' )
94+ validate_partially_populated_device (vm , dev , config .volume_size , checksums )
9995 vm .shutdown (verify = True )
10096
10197 if vdi_name is not None :
@@ -106,7 +102,7 @@ def live_storage_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Ho
106102 vdi_name : str | None = None
107103 integrity_check = not vm .is_windows
108104 dev = ""
109- checksum = ""
105+ checksums = ( '' , '' , '' )
110106 vbd = None
111107
112108 if integrity_check :
@@ -122,26 +118,22 @@ def live_storage_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Ho
122118 install_randstream (vm )
123119 assert vbd is not None
124120 dev = f'/dev/{ vbd .param_get ("device" )} '
125- logging .info (f"Generate { dev } content" )
126- randstream (vm , f'generate { dev } ' )
127- logging .info (f"Validate { dev } " )
128- randstream (vm , f'validate --expected-checksum { checksum } { dev } ' )
121+ checksums = partially_populate_device (vm , dev , config .volume_size )
122+ validate_partially_populated_device (vm , dev , config .volume_size , checksums )
129123
130124 # Move the VM to another host of the pool
131125 vm .migrate (dest_host , dest_sr )
132126 wait_for (lambda : vm .all_vdis_on_sr (dest_sr ), "Wait for all VDIs on destination SR" )
133127 wait_for (lambda : vm .is_running_on_host (dest_host ), "Wait for VM to be running on destination host" )
134128 if integrity_check :
135- logging .info (f"Validate { dev } " )
136- randstream (vm , f'validate --expected-checksum { checksum } { dev } ' )
129+ validate_partially_populated_device (vm , dev , config .volume_size , checksums )
137130
138131 # Migrate it back to the provenance SR
139132 vm .migrate (prov_host , prov_sr )
140133 wait_for (lambda : vm .all_vdis_on_sr (prov_sr ), "Wait for all VDIs back on provenance SR" )
141134 wait_for (lambda : vm .is_running_on_host (prov_host ), "Wait for VM to be running on provenance host" )
142135 if integrity_check :
143- logging .info (f"Validate { dev } " )
144- randstream (vm , f'validate --expected-checksum { checksum } { dev } ' )
136+ validate_partially_populated_device (vm , dev , config .volume_size , checksums )
145137
146138 vm .shutdown (verify = True )
147139
0 commit comments