mirror of
https://github.com/containers/podman.git
synced 2025-07-30 20:02:37 +08:00
Merge pull request #20115 from baude/hypervstarting
hyperv: set more realistic starting state
This commit is contained in:
@ -200,12 +200,12 @@ func toHumanFormat(vms []*machine.ListResponse) ([]*entities.ListReporter, error
|
|||||||
response.Name = vm.Name
|
response.Name = vm.Name
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case vm.Running:
|
|
||||||
response.LastUp = "Currently running"
|
|
||||||
response.Running = true
|
|
||||||
case vm.Starting:
|
case vm.Starting:
|
||||||
response.LastUp = "Currently starting"
|
response.LastUp = "Currently starting"
|
||||||
response.Starting = true
|
response.Starting = true
|
||||||
|
case vm.Running:
|
||||||
|
response.LastUp = "Currently running"
|
||||||
|
response.Running = true
|
||||||
default:
|
default:
|
||||||
response.LastUp = units.HumanDuration(time.Since(vm.LastUp)) + " ago"
|
response.LastUp = units.HumanDuration(time.Since(vm.LastUp)) + " ago"
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ func (v HyperVVirtualization) List(opts machine.ListOptions) ([]*machine.ListRes
|
|||||||
CreatedAt: mm.Created,
|
CreatedAt: mm.Created,
|
||||||
LastUp: mm.LastUp,
|
LastUp: mm.LastUp,
|
||||||
Running: vm.State() == hypervctl.Enabled,
|
Running: vm.State() == hypervctl.Enabled,
|
||||||
Starting: vm.IsStarting(),
|
Starting: mm.isStarting(),
|
||||||
Stream: mm.ImageStream,
|
Stream: mm.ImageStream,
|
||||||
VMType: machine.HyperVVirt.String(),
|
VMType: machine.HyperVVirt.String(),
|
||||||
CPUs: mm.CPUs,
|
CPUs: mm.CPUs,
|
||||||
|
@ -479,6 +479,14 @@ func (m *HyperVMachine) Start(name string, opts machine.StartOptions) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to start host networking: %q", err)
|
return fmt.Errorf("unable to start host networking: %q", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The "starting" status from hyper v is a very small windows and not really
|
||||||
|
// the same as what we want. so modeling starting behaviour after qemu
|
||||||
|
m.Starting = true
|
||||||
|
if err := m.writeConfig(); err != nil {
|
||||||
|
return fmt.Errorf("writing JSON file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := vm.Start(); err != nil {
|
if err := vm.Start(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -487,16 +495,18 @@ func (m *HyperVMachine) Start(name string, opts machine.StartOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set starting back false now that we are running
|
||||||
|
m.Starting = false
|
||||||
|
|
||||||
if m.HostUser.Modified {
|
if m.HostUser.Modified {
|
||||||
if machine.UpdatePodmanDockerSockService(m, name, m.UID, m.Rootful) == nil {
|
if machine.UpdatePodmanDockerSockService(m, name, m.UID, m.Rootful) == nil {
|
||||||
// Reset modification state if there are no errors, otherwise ignore errors
|
// Reset modification state if there are no errors, otherwise ignore errors
|
||||||
// which are already logged
|
// which are already logged
|
||||||
m.HostUser.Modified = false
|
m.HostUser.Modified = false
|
||||||
_ = m.writeConfig()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Write the config with updated starting status and hostuser modification
|
||||||
return nil
|
return m.writeConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *HyperVMachine) State(_ bool) (machine.Status, error) {
|
func (m *HyperVMachine) State(_ bool) (machine.Status, error) {
|
||||||
@ -718,3 +728,7 @@ func (m *HyperVMachine) resizeDisk(newSize strongunits.GiB) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *HyperVMachine) isStarting() bool {
|
||||||
|
return m.Starting
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user