Skip to content

Create Virtual Machine in Containerized Libvirt #8

@abhibongale

Description

@abhibongale

Create a virtual machine using libvirt/KVM inside the containerized libvirt service that will act as a baremetal node for Ironic to manage. This VM will be controlled by Ironic through the Redfish BMC emulator (sushy-tools).

The VM needs to be configured to boot from network (PXE) and have characteristics similar to a real baremetal server.

Fully Containerized: VMs run inside the stackbox-libvirt container (Metal3 style), ensuring zero impact on host libvirt configuration.

Benefits of Containerized Approach

  • Zero host impact: No changes to host libvirt
  • Portable: Same setup on any machine with Docker
  • Clean removal: docker-compose down removes everything
  • Matches CI: Identical to Metal3/upstream CI setup
  • Isolated: Multiple StackBox instances won't conflict
  • No permissions: No need for user in libvirt group

Goals

  • Create libvirt VM programmatically
  • Configure VM for PXE boot
  • Set appropriate hardware specs (memory, CPU, disk)
  • Make VM accessible to Ironic
  • Store VM definition persistently

Tasks

  • Create stackbox/core/vm.py for VM management
  • Define VM XML template
  • Implement VM creation function
  • Configure PXE boot order
  • Set up virtual disk
  • Configure network interface
  • Integrate VM creation with init command
  • Handle libvirt connection
  • Test VM can be created and started
  • Document VM configuration

Acceptance Criteria

  • VM is created successfully
  • VM has correct specs (2 vCPUs, 4GB RAM, 20GB disk)
  • VM boots from network first
  • VM is visible to libvirt
  • VM can be started and stopped
  • VM XML is saved for persistence
  • VM network is properly configured
  • Multiple VMs can be created

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions