mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #19995 from wanyaoqi/automated-cherry-pick-of-#19994-upstream-master
Automated cherry pick of #19994: Automated cherry pick of #19993: fix(host): sriov bond
This commit is contained in:
@@ -404,6 +404,25 @@ func (s *SKVMGuestInstance) initLiveDescFromSourceGuest(srcDesc *desc.SGuestDesc
|
||||
srcDesc.VcpuPin = nil
|
||||
srcDesc.CpuNumaPin = nil
|
||||
} else {
|
||||
if scpuset, ok := srcDesc.Metadata[api.VM_METADATA_CGROUP_CPUSET]; ok {
|
||||
s.manager.cpuSet.Lock.Lock()
|
||||
s.manager.cpuSet.ReleaseCpus(cpus, int(srcDesc.Cpu))
|
||||
s.manager.cpuSet.Lock.Unlock()
|
||||
|
||||
cpusetJson, err := jsonutils.ParseString(scpuset)
|
||||
if err != nil {
|
||||
log.Errorf("failed parse server %s cpuset %s: %s", s.Id, scpuset, err)
|
||||
return errors.Errorf("failed parse server %s cpuset %s: %s", s.Id, scpuset, err)
|
||||
}
|
||||
input := new(api.ServerCPUSetInput)
|
||||
err = cpusetJson.Unmarshal(input)
|
||||
if err != nil {
|
||||
log.Errorf("failed unmarshal server %s cpuset %s", s.Id, err)
|
||||
return errors.Errorf("failed unmarshal server %s cpuset %s", s.Id, err)
|
||||
}
|
||||
cpus = input.CPUS
|
||||
}
|
||||
|
||||
srcDesc.VcpuPin = []desc.SCpuPin{
|
||||
{
|
||||
Vcpus: fmt.Sprintf("0-%d", srcDesc.Cpu-1),
|
||||
@@ -2746,6 +2765,10 @@ func (s *SKVMGuestInstance) allocGuestNumaCpuset() error {
|
||||
s.Desc.CpuNumaPin = cpuNumaPin
|
||||
} else if !s.manager.numaAllocate {
|
||||
if scpuset, ok := s.Desc.Metadata[api.VM_METADATA_CGROUP_CPUSET]; ok {
|
||||
s.manager.cpuSet.Lock.Lock()
|
||||
s.manager.cpuSet.ReleaseCpus(cpus, int(s.Desc.Cpu))
|
||||
s.manager.cpuSet.Lock.Unlock()
|
||||
|
||||
cpusetJson, err := jsonutils.ParseString(scpuset)
|
||||
if err != nil {
|
||||
log.Errorf("failed parse server %s cpuset %s: %s", s.Id, scpuset, err)
|
||||
|
||||
@@ -2068,18 +2068,39 @@ func (h *SHostInfo) initIsolatedDevices() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *SHostInfo) getNicsInterfaces(nics []string) []isolated_device.HostNic {
|
||||
func (h *SHostInfo) getNicsInterfaces(nics []string) ([]isolated_device.HostNic, error) {
|
||||
if len(nics) == 0 {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
log.Infof("sriov input nics %v", nics)
|
||||
res := []isolated_device.HostNic{}
|
||||
for i := 0; i < len(nics); i++ {
|
||||
found := false
|
||||
for j := 0; j < len(h.Nics); j++ {
|
||||
if nics[i] == h.Nics[j].Inter {
|
||||
if fileutils2.Exists(fmt.Sprintf("/sys/class/net/%s/bonding/slaves", h.Nics[j].Inter)) {
|
||||
interStr, err := fileutils2.FileGetContents(fmt.Sprintf("/sys/class/net/%s/bonding/slaves", h.Nics[j].Inter))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inters := strings.Split(strings.TrimSpace(interStr), " ")
|
||||
for _, inter := range inters {
|
||||
res = append(res, isolated_device.HostNic{
|
||||
Bridge: h.Nics[j].Bridge,
|
||||
Interface: inter,
|
||||
Wire: h.Nics[j].WireId,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
res = append(res, isolated_device.HostNic{
|
||||
Bridge: h.Nics[j].Bridge,
|
||||
Interface: h.Nics[j].Inter,
|
||||
Wire: h.Nics[j].WireId,
|
||||
})
|
||||
}
|
||||
|
||||
found = true
|
||||
res = append(res, isolated_device.HostNic{h.Nics[j].Bridge, h.Nics[j].Inter, h.Nics[j].WireId})
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
@@ -2087,39 +2108,6 @@ func (h *SHostInfo) getNicsInterfaces(nics []string) []isolated_device.HostNic {
|
||||
}
|
||||
}
|
||||
log.Infof("sriov output nics %v", res)
|
||||
return res
|
||||
}
|
||||
|
||||
func (h *SHostInfo) getNicsOvsOffloadInterfaces(nics []string) ([]isolated_device.HostNic, error) {
|
||||
if len(nics) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
res := []isolated_device.HostNic{}
|
||||
for i := 0; i < len(h.Nics); i++ {
|
||||
if utils.IsInStringArray(h.Nics[i].Inter, nics) {
|
||||
if fileutils2.Exists(fmt.Sprintf("/sys/class/net/%s/bonding/slaves", h.Nics[i].Inter)) {
|
||||
interStr, err := fileutils2.FileGetContents(fmt.Sprintf("/sys/class/net/%s/bonding/slaves", h.Nics[i].Inter))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inters := strings.Split(strings.TrimSpace(interStr), " ")
|
||||
for _, inter := range inters {
|
||||
res = append(res, isolated_device.HostNic{
|
||||
Bridge: h.Nics[i].Bridge,
|
||||
Interface: inter,
|
||||
Wire: h.Nics[i].WireId,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
res = append(res, isolated_device.HostNic{
|
||||
Bridge: h.Nics[i].Bridge,
|
||||
Interface: h.Nics[i].Inter,
|
||||
Wire: h.Nics[i].WireId,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -2137,12 +2125,14 @@ func (h *SHostInfo) probeSyncIsolatedDevices() (*jsonutils.JSONArray, error) {
|
||||
}
|
||||
|
||||
enableDevWhitelist := options.HostOptions.EnableIsolatedDeviceWhitelist
|
||||
|
||||
offloadNics, err := h.getNicsOvsOffloadInterfaces(options.HostOptions.OvsOffloadNics)
|
||||
offloadNics, err := h.getNicsInterfaces(options.HostOptions.OvsOffloadNics)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sriovNics, err := h.getNicsInterfaces(options.HostOptions.SRIOVNics)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sriovNics := h.getNicsInterfaces(options.HostOptions.SRIOVNics)
|
||||
h.IsolatedDeviceMan.ProbePCIDevices(
|
||||
options.HostOptions.DisableGPU, options.HostOptions.DisableUSB, options.HostOptions.DisableCustomDevice,
|
||||
sriovNics, offloadNics, options.HostOptions.PTNVMEConfigs, options.HostOptions.AMDVgpuPFs, options.HostOptions.NVIDIAVgpuPFs,
|
||||
|
||||
Reference in New Issue
Block a user