mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +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
|
||||
}
|
||||
switch {
|
||||
case vm.Running:
|
||||
response.LastUp = "Currently running"
|
||||
response.Running = true
|
||||
case vm.Starting:
|
||||
response.LastUp = "Currently starting"
|
||||
response.Starting = true
|
||||
case vm.Running:
|
||||
response.LastUp = "Currently running"
|
||||
response.Running = true
|
||||
default:
|
||||
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,
|
||||
LastUp: mm.LastUp,
|
||||
Running: vm.State() == hypervctl.Enabled,
|
||||
Starting: vm.IsStarting(),
|
||||
Starting: mm.isStarting(),
|
||||
Stream: mm.ImageStream,
|
||||
VMType: machine.HyperVVirt.String(),
|
||||
CPUs: mm.CPUs,
|
||||
|
@ -479,6 +479,14 @@ func (m *HyperVMachine) Start(name string, opts machine.StartOptions) error {
|
||||
if err != nil {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@ -487,16 +495,18 @@ func (m *HyperVMachine) Start(name string, opts machine.StartOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// set starting back false now that we are running
|
||||
m.Starting = false
|
||||
|
||||
if m.HostUser.Modified {
|
||||
if machine.UpdatePodmanDockerSockService(m, name, m.UID, m.Rootful) == nil {
|
||||
// Reset modification state if there are no errors, otherwise ignore errors
|
||||
// which are already logged
|
||||
m.HostUser.Modified = false
|
||||
_ = m.writeConfig()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
// Write the config with updated starting status and hostuser modification
|
||||
return m.writeConfig()
|
||||
}
|
||||
|
||||
func (m *HyperVMachine) State(_ bool) (machine.Status, error) {
|
||||
@ -718,3 +728,7 @@ func (m *HyperVMachine) resizeDisk(newSize strongunits.GiB) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *HyperVMachine) isStarting() bool {
|
||||
return m.Starting
|
||||
}
|
||||
|
Reference in New Issue
Block a user