The HyperSDK export process now integrates seamlessly with hyper2kvm for VM conversion and libvirt for VM management. This creates a complete end-to-end pipeline:
Export → Convert → Define in Libvirt
┌─────────────┐ ┌──────────────┐ ┌────────────┐ ┌──────────┐
│ vSphere │────>│ HyperSDK │────>│ hyper2kvm │────>│ libvirt │
│ VM │ │ Export │ │ Convert │ │ KVM │
└─────────────┘ └──────────────┘ └────────────┘ └──────────┘
│
v
Artifact Manifest v1.0
providers/common/pipeline.go)Executes the hyper2kvm pipeline after export completes:
providers/common/libvirt.go)Integrates converted VMs with libvirt:
virsh defineproviders/vsphere/export_options.go)Extended with pipeline configuration:
type ExportOptions struct {
// ... existing fields ...
// Pipeline integration
EnablePipeline bool
Hyper2KVMPath string
PipelineTimeout time.Duration
StreamPipelineOutput bool
PipelineDryRun bool
// Pipeline stages
PipelineInspect bool
PipelineFix bool
PipelineConvert bool
PipelineValidate bool
PipelineCompress bool
PipelineCompressLevel int
// Libvirt integration
LibvirtIntegration bool
LibvirtURI string
LibvirtAutoStart bool
LibvirtNetworkBridge string
LibvirtStoragePool string
}
cmd/hyperexport/main.go)New command-line options:
# Pipeline control
--pipeline # Enable pipeline integration
--hyper2kvm-path <path> # Path to hyper2kvm executable
--pipeline-timeout <duration> # Pipeline execution timeout
--stream-pipeline # Stream hyper2kvm output
--pipeline-dry-run # Run in dry-run mode
# Pipeline stages
--pipeline-inspect # Enable INSPECT stage
--pipeline-fix # Enable FIX stage
--pipeline-convert # Enable CONVERT stage
--pipeline-validate # Enable VALIDATE stage
--pipeline-compress # Enable qcow2 compression
--compress-level <1-9> # Compression level
# Libvirt integration
--libvirt # Define VM in libvirt
--libvirt-uri <uri> # Libvirt connection URI
--libvirt-autostart # Enable VM auto-start
--libvirt-bridge <bridge> # Network bridge
--libvirt-pool <pool> # Storage pool
hyperexport \
--vm "Ubuntu-Server" \
--output /var/lib/libvirt/images/ubuntu \
--pipeline \
--hyper2kvm-path /home/tt/hyper2kvm/hyper2kvm \
--manifest
This will:
/var/lib/libvirt/images/ubuntuhyperexport \
--vm "Ubuntu-Server" \
--output /var/lib/libvirt/images/ubuntu \
--pipeline \
--libvirt \
--libvirt-uri "qemu:///system" \
--libvirt-autostart \
--libvirt-bridge br0 \
--manifest
This will:
br0virsh start ubuntu-serverhyperexport \
--vm "Test-VM" \
--output /tmp/test \
--pipeline \
--pipeline-inspect=false \
--pipeline-fix=false \
--pipeline-validate=false \
--manifest
This will only convert the disk format without fixing the guest OS.
hyperexport \
--vm "Production-VM" \
--output /tmp/prod \
--pipeline \
--pipeline-dry-run \
--manifest
This will show what the pipeline would do without making any changes.
The pipeline uses the Artifact Manifest v1.0 as the integration contract:
{
"manifest_version": "1.0",
"source": {
"provider": "vsphere",
"vm_name": "Ubuntu-Server",
"datacenter": "DC1"
},
"vm": {
"cpu": 4,
"mem_gb": 8,
"firmware": "bios",
"os_hint": "linux"
},
"disks": [
{
"id": "disk-0",
"source_format": "vmdk",
"bytes": 107374182400,
"local_path": "/path/to/disk.vmdk",
"boot_order_hint": 0,
"disk_type": "boot"
}
],
"pipeline": {
"inspect": {"enabled": true},
"fix": {"enabled": true, "fstab_mode": "stabilize-all"},
"convert": {"enabled": true, "compress": true},
"validate": {"enabled": true}
},
"output": {
"directory": "/var/lib/libvirt/images/ubuntu",
"format": "qcow2"
}
}
<output>/manifest.json<output>/report.json<output>/<vm-name>.qcow2virsh defineThe pipeline integration is designed to be non-fatal:
result.Metadata// Default pipeline configuration
EnablePipeline: false // Opt-in
PipelineTimeout: 30 min
StreamPipelineOutput: true
PipelineInspect: true
PipelineFix: true
PipelineConvert: true
PipelineValidate: true
PipelineCompress: true
PipelineCompressLevel: 6
// Default libvirt configuration
LibvirtURI: "qemu:///system"
LibvirtNetworkBridge: "virbr0"
LibvirtStoragePool: "default"
LibvirtAutoStart: false
The libvirt integrator generates production-ready domain XML:
/usr/share/OVMF/OVMF_CODE.fd)Example generated XML:
<domain type='kvm'>
<name>ubuntu-server</name>
<memory unit='KiB'>8388608</memory>
<vcpu placement='static'>4</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<cpu mode='host-passthrough'/>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='writeback'/>
<source file='/var/lib/libvirt/images/ubuntu-server.qcow2'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='bridge'>
<source bridge='virbr0'/>
<model type='virtio'/>
</interface>
<!-- ... more devices ... -->
</devices>
</domain>
The pipeline requires hyper2kvm to be installed. HyperSDK searches:
/home/tt/hyper2kvm/hyper2kvm (default)/usr/local/bin/hyper2kvm/usr/bin/hyper2kvm./hyper2kvm../hyper2kvm/hyper2kvmOr specify manually with --hyper2kvm-path.
For libvirt integration:
virsh must be in PATHTest the pipeline integration:
# 1. Export without pipeline (just creates manifest)
hyperexport --vm Test-VM --output /tmp/test --manifest
# 2. Verify manifest
cat /tmp/test/manifest.json
# 3. Export with pipeline (dry-run)
hyperexport --vm Test-VM --output /tmp/test --pipeline --pipeline-dry-run --manifest
# 4. Full pipeline with conversion
hyperexport --vm Test-VM --output /tmp/test --pipeline --manifest
# 5. Pipeline with libvirt integration
hyperexport --vm Test-VM --output /tmp/test --pipeline --libvirt --manifest
# 6. Start the VM
virsh start test-vm
Error: hyper2kvm not found at /home/tt/hyper2kvm/hyper2kvm
Solution: Specify path manually:
--hyper2kvm-path /path/to/hyper2kvm
Error: virsh define failed: permission denied
Solution: Use session URI or add user to libvirt group:
--libvirt-uri "qemu:///session"
# OR
sudo usermod -aG libvirt $USER
Error: pipeline failed: context deadline exceeded
Solution: Increase timeout:
--pipeline-timeout 1h
Error: /usr/share/OVMF/OVMF_CODE.fd not found
Solution: Install OVMF:
# Ubuntu/Debian
sudo apt install ovmf
# RHEL/Fedora
sudo dnf install edk2-ovmf
manifest/types.go/home/tt/hyper2kvm/README.md