@@ -155,6 +155,20 @@ def is_need_epc(epc_section, i, config):
155
155
print ("\t \t }," , file = config )
156
156
157
157
158
+ def vcpu_affinity_output (vm_info , i , config ):
159
+ """
160
+ Output the vcpu affinity
161
+ :param vminfo: the data structure have all the xml items values
162
+ :param i: the index of vm id
163
+ :param config: file pointor to store the information
164
+ """
165
+ if vm_info .load_order [i ] == "SOS_VM" :
166
+ return
167
+
168
+ cpu_bits = vm_info .get_cpu_bitmap (i )
169
+ print ("\t \t .vcpu_num = {}U," .format (cpu_bits ['cpu_num' ]), file = config )
170
+ print ("\t \t .vcpu_affinity = VM{}_CONFIG_VCPU_AFFINITY," .format (i ), file = config )
171
+
158
172
def get_guest_flag (flag_index ):
159
173
"""
160
174
This is get flag index list
@@ -224,6 +238,7 @@ def gen_sdc_source(vm_info, config):
224
238
print ("\t \t /* Allow SOS to reboot the host since " +
225
239
"there is supposed to be the highest severity guest */" , file = config )
226
240
print ("\t \t .guest_flags = {0}," .format (sos_guest_flags ), file = config )
241
+ vcpu_affinity_output (vm_info , 0 , config )
227
242
if vm_info .clos_set [0 ] == None or not vm_info .clos_set [0 ].strip ():
228
243
print ("\t \t .clos = {0}U," .format (0 ), file = config )
229
244
else :
@@ -249,6 +264,8 @@ def gen_sdc_source(vm_info, config):
249
264
# UUID
250
265
uuid_output (uuid_1 , vm_info .uuid [1 ], config )
251
266
is_need_epc (vm_info .epc_section , 1 , config )
267
+ print ("\t \t .vcpu_num = CONFIG_MAX_PCPU_NUM - CONFIG_MAX_KATA_VM_NUM - 1U," , file = config )
268
+ print ("\t \t .vcpu_affinity = VM{}_CONFIG_VCPU_AFFINITY," .format (1 ), file = config )
252
269
# VUART
253
270
err_dic = vuart_output (1 , vm_info , config )
254
271
if err_dic :
@@ -258,6 +275,7 @@ def gen_sdc_source(vm_info, config):
258
275
print ("\t {" , file = config )
259
276
print ("\t \t .load_order = POST_LAUNCHED_VM," , file = config )
260
277
uuid_output (uuid_2 , vm_info .uuid [2 ], config )
278
+ vcpu_affinity_output (vm_info , 2 , config )
261
279
is_need_epc (vm_info .epc_section , 2 , config )
262
280
print ("\t \t .vuart[0] = {" , file = config )
263
281
print ("\t \t \t .type = VUART_LEGACY_PIO," , file = config )
@@ -304,6 +322,7 @@ def gen_sdc2_source(vm_info, config):
304
322
print ("\t \t /* Allow SOS to reboot the host since " +
305
323
"there is supposed to be the highest severity guest */" , file = config )
306
324
print ("\t \t .guest_flags = {0}," .format (sos_guest_flags ), file = config )
325
+ vcpu_affinity_output (vm_info , 0 , config )
307
326
if vm_info .clos_set [0 ] == None or not vm_info .clos_set [0 ].strip ():
308
327
print ("\t \t .clos = {0}U," .format (0 ), file = config )
309
328
else :
@@ -329,6 +348,7 @@ def gen_sdc2_source(vm_info, config):
329
348
print ("\t \t .load_order = {0}," .format (vm_info .load_order [1 ]), file = config )
330
349
# UUID
331
350
uuid_output (uuid_1 , vm_info .uuid [1 ], config )
351
+ vcpu_affinity_output (vm_info , 1 , config )
332
352
is_need_epc (vm_info .epc_section , 1 , config )
333
353
# VUART
334
354
err_dic = vuart_output (1 , vm_info , config )
@@ -340,6 +360,7 @@ def gen_sdc2_source(vm_info, config):
340
360
print ("\t \t .load_order = {0}," .format (vm_info .load_order [1 ]), file = config )
341
361
# UUID
342
362
uuid_output (uuid_2 , vm_info .uuid [2 ], config )
363
+ vcpu_affinity_output (vm_info , 2 , config )
343
364
is_need_epc (vm_info .epc_section , 2 , config )
344
365
# VUART
345
366
err_dic = vuart_output (1 , vm_info , config )
@@ -352,6 +373,7 @@ def gen_sdc2_source(vm_info, config):
352
373
print ("\t \t .load_order = POST_LAUNCHED_VM," , file = config )
353
374
uuid_output (uuid_3 , vm_info .uuid [3 ], config )
354
375
is_need_epc (vm_info .epc_section , 3 , config )
376
+ vcpu_affinity_output (vm_info , 3 , config )
355
377
print ("\t \t .vuart[0] = {" , file = config )
356
378
print ("\t \t \t .type = VUART_LEGACY_PIO," , file = config )
357
379
print ("\t \t \t .addr.port_base = INVALID_COM_BASE," , file = config )
@@ -412,7 +434,7 @@ def gen_logical_partition_source(vm_info, config):
412
434
print ('\t \t .name = "{0}",' .format (vm_info .name [i ]), file = config )
413
435
# UUID
414
436
uuid_output (uuid , vm_info .uuid [i ], config )
415
- print ( " \t \t .pcpu_bitmap = VM{0}_CONFIG_PCPU_BITMAP," . format ( i ), file = config )
437
+ vcpu_affinity_output ( vm_info , i , config )
416
438
# skip the vm0 for guest flag
417
439
418
440
# guest flags
@@ -480,6 +502,10 @@ def gen_industry_source(vm_info, config):
480
502
return err_dic
481
503
print ("\t \t " )
482
504
print ("\t \t .guest_flags = {0}," .format (sos_guest_flags ), file = config )
505
+
506
+ vcpu_affinity_output (vm_info , i , config )
507
+
508
+ if i == 0 :
483
509
if vm_info .clos_set [i ] == None or not vm_info .clos_set [i ].strip ():
484
510
print ("\t \t .clos = {0}U," .format (0 ), file = config )
485
511
else :
@@ -544,8 +570,10 @@ def gen_hybrid_source(vm_info, config):
544
570
if err_dic :
545
571
return err_dic
546
572
print ("\t \t .guest_flags = {0}," .format (sos_guest_flags ), file = config )
547
- if i == 0 :
548
- print ("\t \t .pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP," , file = config )
573
+
574
+ vcpu_affinity_output (vm_info , i , config )
575
+
576
+ if i != 2 :
549
577
if vm_info .clos_set [i ] == None or not vm_info .clos_set [i ].strip ():
550
578
print ("\t \t .clos = {0}U," .format (0 ), file = config )
551
579
else :
0 commit comments