summaryrefslogtreecommitdiff
path: root/pkg/machine/qemu
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/machine/qemu')
-rw-r--r--pkg/machine/qemu/machine.go20
-rw-r--r--pkg/machine/qemu/options_darwin.go15
-rw-r--r--pkg/machine/qemu/options_darwin_amd64.go18
-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.go7
-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()
-}