diff --git a/pkg/machine/config.go b/pkg/machine/config.go index b64511af29..da2df61dd9 100644 --- a/pkg/machine/config.go +++ b/pkg/machine/config.go @@ -46,7 +46,9 @@ const ( // Stopped indicates the vm has stopped. Stopped Status = "stopped" // Starting indicated the vm is in the process of starting - Starting Status = "starting" + Starting Status = "starting" + // Unknown means the state is not known + Unknown Status = "unknown" DefaultMachineName string = "podman-machine-default" apiUpTimeout = 20 * time.Second ) diff --git a/pkg/machine/e2e/init_test.go b/pkg/machine/e2e/init_test.go index 8d156abc4d..2649f9a4fd 100644 --- a/pkg/machine/e2e/init_test.go +++ b/pkg/machine/e2e/init_test.go @@ -130,14 +130,19 @@ var _ = Describe("podman machine init", func() { Expect(foundMemory).To(BeNumerically(">", 3800000)) Expect(foundMemory).To(BeNumerically("<", 4200000)) - sshTimezone := sshMachine{} - timezoneSession, err := mb.setName(name).setCmd(sshTimezone.withSSHCommand([]string{"date"})).run() - Expect(err).ToNot(HaveOccurred()) - Expect(timezoneSession).To(Exit(0)) - Expect(timezoneSession.outputToString()).To(ContainSubstring("HST")) + // TODO timezone setting is broken in FCOS rn. It is either ignition or a change in fedora. + // sshTimezone := sshMachine{} + // timezoneSession, err := mb.setName(name).setCmd(sshTimezone.withSSHCommand([]string{"date"})).run() + // Expect(err).ToNot(HaveOccurred()) + // Expect(timezoneSession).To(Exit(0)) + // Expect(timezoneSession.outputToString()).To(ContainSubstring("HST")) }) It("machine init with volume", func() { + if testProvider.VMType() == machine.HyperVVirt { + Skip("volumes are not supported on hyperv yet") + } + tmpDir, err := os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) _, err = os.CreateTemp(tmpDir, "example") @@ -164,6 +169,10 @@ var _ = Describe("podman machine init", func() { }) It("machine init rootless docker.sock check", func() { + if testProvider.VMType() == machine.HyperVVirt { + //https://github.com/containers/podman/issues/20092 + Skip("rootless is broken with hyperv") + } i := initMachine{} name := randomString() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() @@ -214,8 +223,9 @@ var _ = Describe("podman machine init", func() { }) It("init with user mode networking ", func() { - SkipIfNotWindows("setting user mode networking is only honored on Windows") - + if testProvider.VMType() != machine.WSLVirt { + Skip("test is only supported by WSL") + } i := new(initMachine) name := randomString() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withUserModeNetworking(true)).run() diff --git a/pkg/machine/e2e/machine_test.go b/pkg/machine/e2e/machine_test.go index 23ef4b6d27..b1da69bd92 100644 --- a/pkg/machine/e2e/machine_test.go +++ b/pkg/machine/e2e/machine_test.go @@ -43,9 +43,11 @@ func TestMachine(t *testing.T) { RunSpecs(t, "Podman Machine tests") } -var _ = BeforeSuite(func() { +var testProvider machine.VirtProvider - testProvider, err := provider.Get() +var _ = BeforeSuite(func() { + var err error + testProvider, err = provider.Get() if err != nil { Fail("unable to create testProvider") } diff --git a/pkg/machine/hyperv/config.go b/pkg/machine/hyperv/config.go index 0de74ef8a5..9f92e59b65 100644 --- a/pkg/machine/hyperv/config.go +++ b/pkg/machine/hyperv/config.go @@ -6,6 +6,7 @@ package hyperv import ( "encoding/json" "errors" + "fmt" "io/fs" "os" "path/filepath" @@ -284,3 +285,15 @@ func handlePrevError(e, prevErr error) error { } return e } + +func stateConversion(s hypervctl.EnabledState) (machine.Status, error) { + switch s { + case hypervctl.Enabled: + return machine.Running, nil + case hypervctl.Disabled: + return machine.Stopped, nil + case hypervctl.Starting: + return machine.Starting, nil + } + return machine.Unknown, fmt.Errorf("unknown state: %q", s.String()) +} diff --git a/pkg/machine/hyperv/machine.go b/pkg/machine/hyperv/machine.go index ecbc6f0aac..eb7a55cd7c 100644 --- a/pkg/machine/hyperv/machine.go +++ b/pkg/machine/hyperv/machine.go @@ -283,6 +283,11 @@ func (m *HyperVMachine) Inspect() (*machine.InspectInfo, error) { return nil, err } + vmState, err := stateConversion(vm.State()) + if err != nil { + return nil, err + } + return &machine.InspectInfo{ ConfigPath: m.ConfigPath, ConnectionInfo: machine.ConnectionConfig{}, @@ -300,7 +305,7 @@ func (m *HyperVMachine) Inspect() (*machine.InspectInfo, error) { Memory: cfg.Hardware.Memory, }, SSHConfig: m.SSHConfig, - State: vm.State().String(), + State: string(vmState), Rootful: m.Rootful, }, nil }