@@ -1394,9 +1394,13 @@ func (guest *SGuest) SetCpuNumaPin(
13941394 }
13951395 }
13961396
1397+ var cpuNumaPinType string
13971398 var schedCpuNumaPinJ jsonutils.JSONObject
13981399 if schedCpuNumaPin != nil {
13991400 schedCpuNumaPinJ = jsonutils .Marshal (schedCpuNumaPin )
1401+ cpuNumaPinType = api .VM_CPU_NUMA_PIN_SCHEDULER
1402+ } else if cpuNumaPin != nil {
1403+ schedCpuNumaPinJ = jsonutils .Marshal (cpuNumaPin )
14001404 }
14011405 diff , err := db .Update (guest , func () error {
14021406 guest .CpuNumaPin = schedCpuNumaPinJ
@@ -1410,7 +1414,11 @@ func (guest *SGuest) SetCpuNumaPin(
14101414 if cpuNumaPin != nil {
14111415 jcpuNumaPin = jsonutils .Marshal (cpuNumaPin )
14121416 }
1413- err = guest .SetMetadata (ctx , api .VM_METADATA_CPU_NUMA_PIN , jcpuNumaPin , userCred )
1417+ metadataMap := map [string ]interface {}{
1418+ api .VM_METADATA_CPU_NUMA_PIN : jcpuNumaPin ,
1419+ api .VM_METADATA_CPU_NUMA_PIN_TYPE : cpuNumaPinType ,
1420+ }
1421+ err = guest .SetAllMetadata (ctx , metadataMap , userCred )
14141422 if err != nil {
14151423 return err
14161424 }
@@ -5003,7 +5011,7 @@ func (self *SGuest) createDiskOnHost(
50035011
50045012func (self * SGuest ) CreateIsolatedDeviceOnHost (ctx context.Context , userCred mcclient.TokenCredential , host * SHost , devs []* api.IsolatedDeviceConfig , pendingUsage quotas.IQuota ) error {
50055013 var numaNodes []int
5006- if self .CpuNumaPin != nil {
5014+ if self .IsSchedulerNumaAllocate () {
50075015 numaNodes = make ([]int , 0 )
50085016 cpuNumaPin := make ([]schedapi.SCpuNumaPin , 0 )
50095017 self .CpuNumaPin .Unmarshal (& cpuNumaPin )
@@ -5296,6 +5304,11 @@ func (self *SGuest) isNeedDoResetPasswd() bool {
52965304 return true
52975305}
52985306
5307+ func (self * SGuest ) IsSchedulerNumaAllocate () bool {
5308+ cpuNumaPinType := self .GetMetadata (context .Background (), api .VM_METADATA_CPU_NUMA_PIN_TYPE , nil )
5309+ return cpuNumaPinType == api .VM_CPU_NUMA_PIN_SCHEDULER && self .CpuNumaPin != nil
5310+ }
5311+
52995312func (self * SGuest ) GetDeployConfigOnHost (ctx context.Context , userCred mcclient.TokenCredential , host * SHost , params * jsonutils.JSONDict ) (* jsonutils.JSONDict , error ) {
53005313 config := jsonutils .NewDict ()
53015314
@@ -5563,7 +5576,7 @@ func (self *SGuest) GetJsonDescAtHypervisor(ctx context.Context, host *SHost) *a
55635576 desc .IsolatedDevices = append (desc .IsolatedDevices , dev .getDesc ())
55645577 }
55655578
5566- if self .CpuNumaPin != nil {
5579+ if self .IsSchedulerNumaAllocate () {
55675580 cpuNumaPin := make ([]api.SCpuNumaPin , 0 )
55685581 cpuNumaPinStr := self .GetMetadata (ctx , api .VM_METADATA_CPU_NUMA_PIN , nil )
55695582 cpuNumaPinJson , err := jsonutils .ParseString (cpuNumaPinStr )
0 commit comments