Improve image mount failure handling#454
Open
petrutlucian94 wants to merge 1 commit into
Open
Conversation
a01d60e to
e963c1a
Compare
As shown in the following logs, ISO image mounting can fail silently.
We won't get a drive letter, nor a non-zero exit code. However,
attemptng to subsequently dismount the image fails.
This change will raise an exception if no drive letter was received,
including the original stderr as well as the image file size, which
can help us determine if an invalid image was received.
```
2026-06-05 13:39:01.124 DEBUG coriolis.wsman [-] Executing PS command: (Mount-DiskImage 'c:\virtio-win.iso' -PassThru | Get-Volume).DriveLetter from (pid=4517) exec_ps_command /var/log/coriolis/cori
olis/coriolis/wsman.py:149
2026-06-05 13:39:08.868 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k25\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:11.554 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k22\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:14.094 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k19\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:16.689 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k16\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:19.331 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\w10\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:21.893 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k12R2\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:24.450 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k12\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:27.054 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k8R2\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:29.755 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k8\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:32.449 DEBUG coriolis.wsman [-] Executing PS command: Test-Path -Path ":\Balloon\2k3\amd64" from (pid=4517) exec_ps_command /var/log/coriolis/coriolis/coriolis/wsman.py:149
2026-06-05 13:39:35.011 INFO coriolis.osmorphing.windows [-] Unmounting disk image: c:\virtio-win.iso
...
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server self._conn.exec_ps_command("Dismount-DiskImage '%s'" % path,
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server File "/var/log/coriolis/coriolis/coriolis/wsman.py", line 151, in exec_ps_command
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server return self.exec_command(
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server File "/var/log/coriolis/coriolis/coriolis/wsman.py", line 141, in exec_command
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server raise exception.CoriolisException(
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server coriolis.exception.CoriolisException: Command "['powershell.exe', '-EncodedCommand', 'RABpAHMAbQBvAHUAbgB0AC0ARABpAHMAawBJAG0AYQBnAGUAIAAnAGMAOgBcAHYAaQByAHQAaQBvAC0AdwBpAG4ALgBpAHMAbwAnAA==', '-NonInteractive', '-ExecutionPolicy', 'RemoteSigned']" failed with exit code: 1
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server stdout:
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server std_err: #< CLIXML
2026-06-05 13:40:04.250 TRACE coriolis.worker.rpc.server <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="2"><TNRef RefId="0" /><MS><I64 N="SourceId">3</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><S S="Error">Dismount-DiskImage : The request could not be performed because of an I/O device error. _x000D__x000A_</S><S S="Error">At line:1 char:1_x000D__x000A_</S><S S="Error">+ Dismount-DiskImage 'c:\virtio-win.iso'_x000D__x000A_</S><S S="Error">+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S S="Error"> + CategoryInfo : NotSpecified: (MSFT_DiskImage:ROOT/Microsoft/.../MSFT_DiskImage) [Dismount-DiskImage], C _x000D__x000A_</S><S S="Error"> imException_x000D__x000A_</S><S S="Error"> + FullyQualifiedErrorId : HRESULT 0x8007045d,Dismount-DiskImage_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S><Obj S="progress" RefId="3"><TNRef RefId="0" /><MS><I64 N="SourceId">4</I64><PR N="Record"><AV>Dismount-DiskImage 'c:\virtio-win.iso'</AV><AI>1393322851</AI><Nil /><PI>-1</PI><PC>100</PC><T>Completed</T><SR>0</SR><SD>1/1 completed</SD></PR></MS></Obj></Objs
```
e963c1a to
37f678f
Compare
Member
Author
|
I've corrupted the iso intentionally but the initial mount command silently passed. With this change we'll get a proper error: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As shown by the following logs, ISO image mounting can fail silently. We won't get a drive letter, nor a non-zero exit code. However, attempting to subsequently dismount the image fails.
This change will raise an exception if no drive letter was received, including the original stderr as well as the image file size, which can help us determine if an invalid image was received.