mirror of
https://github.com/containers/podman.git
synced 2025-12-09 23:27:09 +08:00
Podman 5 machine config file - Step 1
The following PR is the very first step in what will a series of steps to apply a "common" machine configuration file to all providers. Function names, method names, struct names, and field names are all up for debate. The purpose of this PR is to offer a glimpse at the direction we intend to take. This PR also contains temporary structs (i.e. aThing) that are not exported. These are merely placeholders. The configuration work in this PR is also unused of yet. But the code is compiled. Once merged, we can begin the next step of development. [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
67
pkg/machine/qemu/command/qemu_command_test.go
Normal file
67
pkg/machine/qemu/command/qemu_command_test.go
Normal file
@@ -0,0 +1,67 @@
|
||||
//go:build (amd64 && !windows) || (arm64 && !windows)
|
||||
// +build amd64,!windows arm64,!windows
|
||||
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/containers/podman/v4/pkg/machine/define"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestQemuCmd(t *testing.T) {
|
||||
ignFile, err := define.NewMachineFile(t.TempDir()+"demo-ignition-file.ign", nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
machineAddrFile, err := define.NewMachineFile(t.TempDir()+"tmp.sock", nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
readySocket, err := define.NewMachineFile(t.TempDir()+"readySocket.sock", nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
vmPidFile, err := define.NewMachineFile(t.TempDir()+"vmpidfile.pid", nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
monitor := Monitor{
|
||||
Address: *machineAddrFile,
|
||||
Network: "unix",
|
||||
Timeout: 3,
|
||||
}
|
||||
ignPath := ignFile.GetPath()
|
||||
addrFilePath := machineAddrFile.GetPath()
|
||||
readySocketPath := readySocket.GetPath()
|
||||
vmPidFilePath := vmPidFile.GetPath()
|
||||
bootableImagePath := t.TempDir() + "test-machine_fedora-coreos-38.20230918.2.0-qemu.x86_64.qcow2"
|
||||
|
||||
cmd := NewQemuBuilder("/usr/bin/qemu-system-x86_64", []string{})
|
||||
cmd.SetMemory(2048)
|
||||
cmd.SetCPUs(4)
|
||||
cmd.SetIgnitionFile(*ignFile)
|
||||
cmd.SetQmpMonitor(monitor)
|
||||
cmd.SetNetwork()
|
||||
cmd.SetSerialPort(*readySocket, *vmPidFile, "test-machine")
|
||||
cmd.SetVirtfsMount("/tmp/path", "vol10", "none", true)
|
||||
cmd.SetBootableImage(bootableImagePath)
|
||||
cmd.SetDisplay("none")
|
||||
|
||||
expected := []string{
|
||||
"/usr/bin/qemu-system-x86_64",
|
||||
"-m", "2048",
|
||||
"-smp", "4",
|
||||
"-fw_cfg", fmt.Sprintf("name=opt/com.coreos/config,file=%s", ignPath),
|
||||
"-qmp", fmt.Sprintf("unix:%s,server=on,wait=off", addrFilePath),
|
||||
"-netdev", "socket,id=vlan,fd=3",
|
||||
"-device", "virtio-net-pci,netdev=vlan,mac=5a:94:ef:e4:0c:ee",
|
||||
"-device", "virtio-serial",
|
||||
"-chardev", fmt.Sprintf("socket,path=%s,server=on,wait=off,id=atest-machine_ready", readySocketPath),
|
||||
"-device", "virtserialport,chardev=atest-machine_ready,name=org.fedoraproject.port.0",
|
||||
"-pidfile", vmPidFilePath,
|
||||
"-virtfs", "local,path=/tmp/path,mount_tag=vol10,security_model=none,readonly",
|
||||
"-drive", fmt.Sprintf("if=virtio,file=%s", bootableImagePath),
|
||||
"-display", "none"}
|
||||
|
||||
require.Equal(t, cmd.Build(), expected)
|
||||
}
|
||||
Reference in New Issue
Block a user