Hyper-V on Windows Server 2022 cannot load images converted from OVA to VHDX by qemu-img: Boot failure. Reboot and Select proper Boot device or Insert Boot Media in selected Boot device

I used latest available qemu on Windows 2022: 8.2.0 12045 g3d58f9b5c5 from https://qemu.weilnetz.de/w64/2023/

Description of problem

We have reference OVA image: https://storage.googleapis.com/fastnetmon_advanced_vm_images/fastnetmon-ubuntu-22.04-amd64-2.0.360.0.ova and we want to convert it to VMDX format.

Steps to reproduce

I downloaded reference OVA and converted it to VMDX with three possible options.

With subformat dynamic:

qemu-img convert fastnetmon-ubuntu-22.04-amd64-2.0.360.0.ova -O vhdx -o subformat=dynamic fastnetmon-ubuntu-22.04-amd64-2.0.360.0.vhdx

And without it:

qemu-img convert fastnetmon-ubuntu-22.04-amd64-2.0.360.0.ova -O vhdx fastnetmon-ubuntu-22.04-amd64-2.0.360.0.vhdx

And with explicitly setting fixed:

qemu-img convert fastnetmon-ubuntu-22.04-amd64-2.0.360.0.ova -O vhdx -o subformat=fixed fastnetmon-ubuntu-22.04-amd64-2.0.360.0.vhdx

In all cases I tried loading images using VM of Generation 1 and Generation 2:

The application encountered an error while attempting to change the state of
'New Virtual Machine'.

'New Virtual Machine' failed to start.

Microsoft Emulated IDE Controller (Instance ID 83F8638B-8DCA-4152-9EDA-2CA8B33039B4): Failed to Power on with Error 'The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse..

Failed to open attachment 'C:\Program Files\qemu\fastnetmon_non_dynamic.hdx''. Error: 'The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse..

Failed to open attachment 'C:\Program Files\qemu\fastnetmon_non_dynamic.vhdx'. Error: 'The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.'.

I noticed some similarities with #136 and applied workaround to fix it:

fsutil sparse setflag fastnetmon-ubuntu-22.04-amd64-2.0.360.0.vhdx 0

It started complaining that file is being used by another app. I waited long enough and then rebooted server.

After that error changed to:

Boot failure. Reboot and Select proper Boot device or Insert Boot Media in selected Boot device_

As image:

Screenshot_from_2024-03-02_21-15-10

For Generation 2 error is slightly different:

Virtual Machine Boot Summary
1. SCSI Disk
(0,0)
The boot loader did not load an operating system.
2. Network Adapter (00155D01770C)
A boot image was not found.

As image: Screenshot_from_2024-03-02_21-36-37

I tried doing conversion from VirtualBox with same OVA and it worked just fine:

VBoxManage clonehd fastnetmon-ubuntu-22.04-amd64-disk1.vmdk fastnetmon.vhd --format vhd

I believe something is wrong with boot records for VMDX images.

Example of converted VHDX with dynamic flag can be found here: https://storage.googleapis.com/fastnetmon_advanced_vm_images/fastnetmon-ubuntu-22.04-amd64-2.0.356.0.vhdx

By Pavel Odintsov at FastNetMon.com

Edited by Pavel Odintsov