diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index 7ece5874e6..8ea7fe53c6 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -244,13 +244,10 @@ func (q *qemu) qmpSocketPath(socketName string) (string, error) { return path, nil } -// createPod is the Hypervisor pod creation implementation for govmmQemu. -func (q *qemu) createPod(podConfig PodConfig) error { - var devices []govmmQemu.Device - +func (q *qemu) getQemuMachine(podConfig PodConfig) (govmmQemu.Machine, error) { machine, err := q.arch.machine() if err != nil { - return err + return govmmQemu.Machine{}, err } accelerators := podConfig.HypervisorConfig.MachineAccelerators @@ -261,6 +258,34 @@ func (q *qemu) createPod(podConfig PodConfig) error { machine.Options += accelerators } + return machine, nil +} + +func (q *qemu) appendImage(devices []govmmQemu.Device) ([]govmmQemu.Device, error) { + imagePath, err := q.config.ImageAssetPath() + if err != nil { + return nil, err + } + + if imagePath != "" { + devices, err = q.arch.appendImage(devices, imagePath) + if err != nil { + return nil, err + } + } + + return devices, nil +} + +// createPod is the Hypervisor pod creation implementation for govmmQemu. +func (q *qemu) createPod(podConfig PodConfig) error { + var devices []govmmQemu.Device + + machine, err := q.getQemuMachine(podConfig) + if err != nil { + return err + } + smp := q.cpuTopology() memory, err := q.memoryTopology(podConfig) @@ -343,17 +368,10 @@ func (q *qemu) createPod(podConfig PodConfig) error { devices = q.arch.appendConsole(devices, q.getPodConsole(podConfig.ID)) if initrdPath == "" { - imagePath, err := q.config.ImageAssetPath() + devices, err = q.appendImage(devices) if err != nil { return err } - - if imagePath != "" { - devices, err = q.arch.appendImage(devices, imagePath) - if err != nil { - return err - } - } } if q.config.BlockDeviceDriver == VirtioBlock {