image_to_vm: Add some error handling and debug output for crbug.com/411693

The error handling will clean up the loopback device if/when the cp which
copies the kernel in slot B into slot A fails. That code should stay in the
script long term.

The debug output should be temporary and will hopefully give us some insight
into what's going on with crbug.com/411693

BUG=chromium:411693
TEST=Ran a tryjob with removed from the losetup command line to simulate a
partition device node not being created correctly. Verified that the debug
output was printed as expected. Ran another tryjob with -P and verified that
the debug output wasn't printed.

Change-Id: I8ca19950de11cdf301eac751362846ebce06907f
Reviewed-on: https://chromium-review.googlesource.com/217590
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
1 file changed