aboutsummaryrefslogtreecommitdiff
path: root/pkg/machine
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/machine')
-rw-r--r--pkg/machine/applehv/machine.go70
-rw-r--r--pkg/machine/config.go1
-rw-r--r--pkg/machine/e2e/init_test.go19
-rw-r--r--pkg/machine/e2e/set_test.go20
-rw-r--r--pkg/machine/qemu/machine.go2
-rw-r--r--pkg/machine/wsl/machine.go16
6 files changed, 95 insertions, 33 deletions
diff --git a/pkg/machine/applehv/machine.go b/pkg/machine/applehv/machine.go
new file mode 100644
index 000000000..35a8e9851
--- /dev/null
+++ b/pkg/machine/applehv/machine.go
@@ -0,0 +1,70 @@
+//go:build arm64 && !windows && !linux
+// +build darwin
+
+package applehv
+
+import (
+ "time"
+
+ "github.com/containers/podman/v4/pkg/machine"
+)
+
+type Provider struct{}
+
+var (
+ hvProvider = &Provider{}
+ // vmtype refers to qemu (vs libvirt, krun, etc).
+ vmtype = "apple"
+)
+
+func GetVirtualizationProvider() machine.Provider {
+ return hvProvider
+}
+
+const (
+ // Some of this will need to change when we are closer to having
+ // working code.
+ VolumeTypeVirtfs = "virtfs"
+ MountType9p = "9p"
+ dockerSock = "/var/run/docker.sock"
+ dockerConnectTimeout = 5 * time.Second
+ apiUpTimeout = 20 * time.Second
+)
+
+type apiForwardingState int
+
+const (
+ noForwarding apiForwardingState = iota
+ claimUnsupported
+ notInstalled
+ machineLocal
+ dockerGlobal
+)
+
+func (p *Provider) NewMachine(opts machine.InitOptions) (machine.VM, error) {
+ return nil, machine.ErrNotImplemented
+}
+
+func (p *Provider) LoadVMByName(name string) (machine.VM, error) {
+ return nil, machine.ErrNotImplemented
+}
+
+func (p *Provider) List(opts machine.ListOptions) ([]*machine.ListResponse, error) {
+ return nil, machine.ErrNotImplemented
+}
+
+func (p *Provider) IsValidVMName(name string) (bool, error) {
+ return false, machine.ErrNotImplemented
+}
+
+func (p *Provider) CheckExclusiveActiveVM() (bool, string, error) {
+ return false, "", machine.ErrNotImplemented
+}
+
+func (p *Provider) RemoveAndCleanMachines() error {
+ return machine.ErrNotImplemented
+}
+
+func (p *Provider) VMType() string {
+ return vmtype
+}
diff --git a/pkg/machine/config.go b/pkg/machine/config.go
index 253601dad..5162006db 100644
--- a/pkg/machine/config.go
+++ b/pkg/machine/config.go
@@ -66,6 +66,7 @@ var (
ErrVMAlreadyExists = errors.New("VM already exists")
ErrVMAlreadyRunning = errors.New("VM already running or starting")
ErrMultipleActiveVM = errors.New("only one VM can be active at a time")
+ ErrNotImplemented = errors.New("functionality not implemented")
ForwarderBinaryName = "gvproxy"
)
diff --git a/pkg/machine/e2e/init_test.go b/pkg/machine/e2e/init_test.go
index b246dc4da..859a3ca46 100644
--- a/pkg/machine/e2e/init_test.go
+++ b/pkg/machine/e2e/init_test.go
@@ -3,7 +3,7 @@ package e2e_test
import (
"io/ioutil"
"os"
- "runtime"
+ "strconv"
"time"
"github.com/containers/podman/v4/pkg/machine"
@@ -80,7 +80,7 @@ var _ = Describe("podman machine init", func() {
It("machine init with cpus, disk size, memory, timezone", func() {
name := randomString()
i := new(initMachine)
- session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withCPUs(2).withDiskSize(102).withMemory(4000).withTimezone("Pacific/Honolulu")).run()
+ session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withCPUs(2).withDiskSize(102).withMemory(4096).withTimezone("Pacific/Honolulu")).run()
Expect(err).To(BeNil())
Expect(session).To(Exit(0))
@@ -102,18 +102,13 @@ var _ = Describe("podman machine init", func() {
Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
sshMemory := sshMachine{}
- memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "numfmt", "--field", "2", "--from-unit=Ki", "--to-unit=Mi", "|", "sed", "'s/ kB/M/g'", "|", "grep", "MemTotal"})).run()
+ memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "grep", "-i", "'memtotal'", "|", "grep", "-o", "'[[:digit:]]*'"})).run()
Expect(err).To(BeNil())
Expect(memorySession).To(Exit(0))
- switch runtime.GOOS {
- // os's handle memory differently
- case "linux":
- Expect(memorySession.outputToString()).To(ContainSubstring("3822"))
- case "darwin":
- Expect(memorySession.outputToString()).To(ContainSubstring("3824"))
- default:
- // add windows when testing on that platform
- }
+ foundMemory, err := strconv.Atoi(memorySession.outputToString())
+ Expect(err).To(BeNil())
+ Expect(foundMemory).To(BeNumerically(">", 3800000))
+ Expect(foundMemory).To(BeNumerically("<", 4200000))
sshTimezone := sshMachine{}
timezoneSession, err := mb.setName(name).setCmd(sshTimezone.withSSHComand([]string{"date"})).run()
diff --git a/pkg/machine/e2e/set_test.go b/pkg/machine/e2e/set_test.go
index 4839e33da..a32bb72f2 100644
--- a/pkg/machine/e2e/set_test.go
+++ b/pkg/machine/e2e/set_test.go
@@ -1,7 +1,7 @@
package e2e_test
import (
- "runtime"
+ "strconv"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -29,7 +29,7 @@ var _ = Describe("podman machine set", func() {
Expect(session).To(Exit(0))
set := setMachine{}
- setSession, err := mb.setName(name).setCmd(set.withCPUs(2).withDiskSize(102).withMemory(4000)).run()
+ setSession, err := mb.setName(name).setCmd(set.withCPUs(2).withDiskSize(102).withMemory(4096)).run()
Expect(err).To(BeNil())
Expect(setSession).To(Exit(0))
@@ -56,18 +56,14 @@ var _ = Describe("podman machine set", func() {
Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
sshMemory := sshMachine{}
- memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "numfmt", "--field", "2", "--from-unit=Ki", "--to-unit=Mi", "|", "sed", "'s/ kB/M/g'", "|", "grep", "MemTotal"})).run()
+ memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "grep", "-i", "'memtotal'", "|", "grep", "-o", "'[[:digit:]]*'"})).run()
Expect(err).To(BeNil())
Expect(memorySession).To(Exit(0))
- switch runtime.GOOS {
- // it seems macos and linux handle memory differently
- case "linux":
- Expect(memorySession.outputToString()).To(ContainSubstring("3822"))
- case "darwin":
- Expect(memorySession.outputToString()).To(ContainSubstring("3824"))
- default:
- // windows can go here if we ever run tests there
- }
+ foundMemory, err := strconv.Atoi(memorySession.outputToString())
+ Expect(err).To(BeNil())
+ Expect(foundMemory).To(BeNumerically(">", 3800000))
+ Expect(foundMemory).To(BeNumerically("<", 4200000))
+
// Setting a running machine results in 125
runner, err := mb.setName(name).setCmd(set.withCPUs(4)).run()
Expect(err).To(BeNil())
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index 7974c261e..213f7ce5d 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -42,7 +42,7 @@ var (
vmtype = "qemu"
)
-func GetQemuProvider() machine.Provider {
+func GetVirtualizationProvider() machine.Provider {
return qemuProvider
}
diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go
index 9a57102f0..8f6ef7a43 100644
--- a/pkg/machine/wsl/machine.go
+++ b/pkg/machine/wsl/machine.go
@@ -364,14 +364,6 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
return false, err
}
- if err := v.writeConfig(); err != nil {
- return false, err
- }
-
- if err := setupConnections(v, opts, sshDir); err != nil {
- return false, err
- }
-
dist, err := provisionWSLDist(v)
if err != nil {
return false, err
@@ -393,6 +385,14 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
// Cycle so that user change goes into effect
_ = terminateDist(dist)
+ if err := v.writeConfig(); err != nil {
+ return false, err
+ }
+
+ if err := setupConnections(v, opts, sshDir); err != nil {
+ return false, err
+ }
+
return true, nil
}