mirror of
https://github.com/containers/podman.git
synced 2025-06-19 16:33:24 +08:00
Merge pull request #21009 from baude/hypervcheckexclusivearch
CheckExclusiveArch should use local JSON too
This commit is contained in:
@ -32,13 +32,23 @@ func VirtualizationProvider() machine.VirtProvider {
|
|||||||
|
|
||||||
func (v HyperVVirtualization) CheckExclusiveActiveVM() (bool, string, error) {
|
func (v HyperVVirtualization) CheckExclusiveActiveVM() (bool, string, error) {
|
||||||
vmm := hypervctl.NewVirtualMachineManager()
|
vmm := hypervctl.NewVirtualMachineManager()
|
||||||
// Use of GetAll is OK here because we do not want to use the same name
|
|
||||||
// as something already *actually* configured in hyperv
|
// Get all the VMs on disk (json files)
|
||||||
vms, err := vmm.GetAll()
|
onDiskVMs, err := v.loadFromLocalJson()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", err
|
return false, "", err
|
||||||
}
|
}
|
||||||
for _, vm := range vms {
|
for _, onDiskVM := range onDiskVMs {
|
||||||
|
// lookup if the vm exists in hyperv
|
||||||
|
exists, vm, err := vmm.GetMachineExists(onDiskVM.Name)
|
||||||
|
if err != nil {
|
||||||
|
return false, "", err
|
||||||
|
}
|
||||||
|
// hyperv does not know about it, move on
|
||||||
|
if !exists { // hot path
|
||||||
|
// TODO should we logrus this to show we found a JSON with no hyperv vm ?
|
||||||
|
continue
|
||||||
|
}
|
||||||
if vm.IsStarting() || vm.State() == hypervctl.Enabled {
|
if vm.IsStarting() || vm.State() == hypervctl.Enabled {
|
||||||
return true, vm.ElementName, nil
|
return true, vm.ElementName, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user