Skip to content

Conversation

@yuravk
Copy link
Collaborator

@yuravk yuravk commented Nov 27, 2025

This introduces an alternative implementation for building Hyper-V Vagrant boxes using QEMU/KVM. This allows Hyper-V images to be built on Linux hosts, removing the dependency on a Windows host running the Hyper-V hypervisor.

To achieve this, the build process produces a RAW disk image via QEMU, which is subsequently converted to VHDX and packaged.

Changes:

  • Add new Packer sources (qemu.almalinux-*-hyperv-x86_64) for AlmaLinux 8, 9, 10, and Kitten. These sources utilize QEMU/KVM guest definitions combined with Vagrant-specific configurations (boot commands, credentials, and Ansible playbooks).
  • Configure a shell-local post-processor in Packer to convert the resulting QEMU RAW artifact into a VHDX-based Vagrant box.
  • Add tools/raw-to-vagrant-hyperv.sh helper script to handle the RAW-to-VHDX conversion and tar+gzip packaging.
  • Add tpl/vagrant/hyperv/box.xml as the common Vagrant box configuration template for Hyper-V.
  • Create ansible/hyperv.yml playbook to configure the QEMU guest for Hyper-V compatibility.
  • Update ansible/roles/hyperv_guest/tasks/main.yml to:
    • Remove the qemu-guest-agent package to prevent conflicts.
    • Upgrade initramfs to include hv_netvsc and hv_storvsc drivers (specifically for AL8).
  • Extend variables.pkr.hcl with hyperv_boot_command_*_x86_64 variables.

CI:

  • Add support for building Hyper-V images as Cloud Images option (non-Vagrant). They are also build with Vagrant Images 'ALL' option.
  • Enable package list extraction from the .raw file format.

This introduces an alternative implementation for building Hyper-V Vagrant
boxes using QEMU/KVM. This allows Hyper-V images to be built on Linux
hosts, removing the dependency on a Windows host running the Hyper-V
hypervisor.

To achieve this, the build process produces a RAW disk image via QEMU,
which is subsequently converted to VHDX and packaged.

Changes:

- Add new Packer sources (`qemu.almalinux-*-hyperv-x86_64`) for AlmaLinux
  8, 9, 10, and Kitten. These sources utilize QEMU/KVM guest definitions
  combined with Vagrant-specific configurations (boot commands, credentials,
  and Ansible playbooks).
- Configure a `shell-local` post-processor in Packer to convert the
  resulting QEMU RAW artifact into a VHDX-based Vagrant box.
- Add `tools/raw-to-vagrant-hyperv.sh` helper script to handle the
  RAW-to-VHDX conversion and tar+gzip packaging.
- Add `tpl/vagrant/hyperv/box.xml` as the common Vagrant box configuration
  template for Hyper-V.
- Create `ansible/hyperv.yml` playbook to configure the QEMU guest for
  Hyper-V compatibility.
- Update `ansible/roles/hyperv_guest/tasks/main.yml` to:
    - Remove the `qemu-guest-agent` package to prevent conflicts.
    - Upgrade `initramfs` to include `hv_netvsc` and `hv_storvsc` drivers
      (specifically for AL8).
- Extend `variables.pkr.hcl` with `hyperv_boot_command_*_x86_64` variables.

CI:
- Add support for building Hyper-V images as Cloud Images option (non-Vagrant).
  They are also build with Vagrant Images 'ALL' option.
- Enable package list extraction from the .raw file format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant