diff options
author | baude <bbaude@redhat.com> | 2021-03-22 13:29:25 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2021-03-25 11:02:33 -0500 |
commit | 4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0 (patch) | |
tree | 00743bf608cc5700fe8a7fca1bb3b0f3a4457b7d /pkg/machine/qemu | |
parent | e7661137373b5f87bf6ec45e32326821b172ce7b (diff) | |
download | podman-4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0.tar.gz podman-4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0.tar.bz2 podman-4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0.zip |
Improvements for machine
clean up ci failures and add appropriate arch,os exclusion tags
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/machine/qemu')
-rw-r--r-- | pkg/machine/qemu/machine.go | 20 | ||||
-rw-r--r-- | pkg/machine/qemu/options_darwin.go | 15 | ||||
-rw-r--r-- | pkg/machine/qemu/options_darwin_amd64.go | 18 | ||||
-rw-r--r-- | pkg/machine/qemu/options_darwin_arm64.go (renamed from pkg/machine/qemu/options_arm64.go) | 4 | ||||
-rw-r--r-- | pkg/machine/qemu/options_linux.go | 7 | ||||
-rw-r--r-- | pkg/machine/qemu/options_linux_amd64.go (renamed from pkg/machine/qemu/options_amd64.go) | 8 |
6 files changed, 54 insertions, 18 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index 30d96ce08..504b64bd5 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -10,8 +10,9 @@ import ( "strconv" "time" + "github.com/containers/podman/v3/utils" + "github.com/containers/podman/v3/pkg/machine" - "github.com/containers/podman/v3/pkg/specgen" "github.com/containers/storage/pkg/homedir" "github.com/digitalocean/go-qemu/qmp" "github.com/pkg/errors" @@ -56,7 +57,7 @@ func NewMachine(opts machine.CreateOptions) (machine.VM, error) { } // Add a random port for ssh - port, err := specgen.GetRandomPort() + port, err := utils.GetRandomPort() if err != nil { return nil, err } @@ -170,7 +171,7 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error { attr := new(os.ProcAttr) files := []*os.File{os.Stdin, os.Stdout, os.Stderr} attr.Files = files - fmt.Print(v.CmdLine) + logrus.Debug(v.CmdLine) _, err = os.StartProcess(v.CmdLine[0], v.CmdLine, attr) return err } @@ -211,22 +212,29 @@ func (v *MachineVM) Stop(name string, _ machine.StopOptions) error { // NewQMPMonitor creates the monitor subsection of our vm func NewQMPMonitor(network, name string, timeout time.Duration) (Monitor, error) { - rtDir, err := getDataDir() + rtDir, err := getSocketDir() if err != nil { return Monitor{}, err } + rtDir = filepath.Join(rtDir, "podman") + if _, err := os.Stat(filepath.Join(rtDir)); os.IsNotExist(err) { + // TODO 0644 is fine on linux but macos is weird + if err := os.MkdirAll(rtDir, 0755); err != nil { + return Monitor{}, err + } + } if timeout == 0 { timeout = defaultQMPTimeout } monitor := Monitor{ Network: network, - Address: filepath.Join(rtDir, "podman", "qmp_"+name+".sock"), + Address: filepath.Join(rtDir, "qmp_"+name+".sock"), Timeout: timeout, } return monitor, nil } -func (v *MachineVM) Destroy(name string, opts machine.DestroyOptions) (string, func() error, error) { +func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, func() error, error) { var ( files []string ) diff --git a/pkg/machine/qemu/options_darwin.go b/pkg/machine/qemu/options_darwin.go new file mode 100644 index 000000000..46ccf24cb --- /dev/null +++ b/pkg/machine/qemu/options_darwin.go @@ -0,0 +1,15 @@ +package qemu + +import ( + "os" + + "github.com/pkg/errors" +) + +func getSocketDir() (string, error) { + tmpDir, ok := os.LookupEnv("TMPDIR") + if !ok { + return "", errors.New("unable to resolve TMPDIR") + } + return tmpDir, nil +} diff --git a/pkg/machine/qemu/options_darwin_amd64.go b/pkg/machine/qemu/options_darwin_amd64.go new file mode 100644 index 000000000..69f7982b2 --- /dev/null +++ b/pkg/machine/qemu/options_darwin_amd64.go @@ -0,0 +1,18 @@ +package qemu + +var ( + QemuCommand = "qemu-system-x86_64" +) + +func (v *MachineVM) addArchOptions() []string { + opts := []string{"-cpu", "host"} + return opts +} + +func (v *MachineVM) prepare() error { + return nil +} + +func (v *MachineVM) archRemovalFiles() []string { + return []string{} +} diff --git a/pkg/machine/qemu/options_arm64.go b/pkg/machine/qemu/options_darwin_arm64.go index c5b0ea16b..7513b3048 100644 --- a/pkg/machine/qemu/options_arm64.go +++ b/pkg/machine/qemu/options_darwin_arm64.go @@ -31,10 +31,6 @@ func (v *MachineVM) archRemovalFiles() []string { return []string{ovmDir} } -func getDataDir() (string, error) { - return "/tmp", nil -} - func getOvmfDir(imagePath, vmName string) string { return filepath.Join(filepath.Dir(imagePath), vmName+"_ovmf_vars.fd") } diff --git a/pkg/machine/qemu/options_linux.go b/pkg/machine/qemu/options_linux.go new file mode 100644 index 000000000..0a2e40d8f --- /dev/null +++ b/pkg/machine/qemu/options_linux.go @@ -0,0 +1,7 @@ +package qemu + +import "github.com/containers/podman/v3/pkg/util" + +func getSocketDir() (string, error) { + return util.GetRuntimeDir() +} diff --git a/pkg/machine/qemu/options_amd64.go b/pkg/machine/qemu/options_linux_amd64.go index 85a2c4b3e..cc0a4bab2 100644 --- a/pkg/machine/qemu/options_amd64.go +++ b/pkg/machine/qemu/options_linux_amd64.go @@ -1,9 +1,5 @@ package qemu -import ( - "github.com/containers/podman/v3/pkg/util" -) - var ( QemuCommand = "qemu-kvm" ) @@ -20,7 +16,3 @@ func (v *MachineVM) prepare() error { func (v *MachineVM) archRemovalFiles() []string { return []string{} } - -func getDataDir() (string, error) { - return util.GetRuntimeDir() -} |