-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathquery_capacity_data.c
1227 lines (1128 loc) · 48.3 KB
/
query_capacity_data.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright IBM Corp. 2013, 2020 */
#include "query_capacity_data.h"
/*
* Below are the structures that define the attributes. The attributes are
* referenced as an enum, see documentation in query_capacity.h.
*
* Note that strings (char pointers) carry the trailing zero byte.
*/
#define QC_LEN_CAPPING 5
#define QC_LEN_CLUSTER_NAME 9
#define QC_LEN_CONTROL_PROGRAM_ID 17
#define QC_LEN_LAYER_CATEGORY 6
#define QC_LEN_LAYER_EXTENDED_NAME 257
#define QC_LEN_LAYER_NAME 9
#define QC_LEN_LAYER_TYPE 27
#define QC_LEN_LAYER_UUID 37
#define QC_LEN_LIC_IDENTIFIER 17
#define QC_LEN_MANUFACTURER 17
#define QC_LEN_MODEL 17
#define QC_LEN_MODEL_CAPACITY 17
#define QC_LEN_PARTITION_CHAR 26
#define QC_LEN_PLANT 5
#define QC_LEN_SEQUENCE_CODE 17
#define QC_LEN_TYPE 17
#define QC_LEN_TYPE_NAME 31
// Returns length of string attributes as defined in the respective struct
static unsigned int qc_get_str_attr_len(enum qc_attr_id id) {
switch (id) {
case qc_capping: return QC_LEN_CAPPING;
case qc_cluster_name: return QC_LEN_CLUSTER_NAME;
case qc_control_program_id: return QC_LEN_CONTROL_PROGRAM_ID;
case qc_layer_category: return QC_LEN_LAYER_CATEGORY;
case qc_layer_extended_name: return QC_LEN_LAYER_EXTENDED_NAME;
case qc_layer_name: return QC_LEN_LAYER_NAME;
case qc_layer_type: return QC_LEN_LAYER_TYPE;
case qc_layer_uuid: return QC_LEN_LAYER_UUID;
case qc_lic_identifier: return QC_LEN_LIC_IDENTIFIER;
case qc_manufacturer: return QC_LEN_MANUFACTURER;
case qc_model: return QC_LEN_MODEL;
case qc_model_capacity: return QC_LEN_MODEL_CAPACITY;
case qc_partition_char: return QC_LEN_PARTITION_CHAR;
case qc_plant: return QC_LEN_PLANT;
case qc_sequence_code: return QC_LEN_SEQUENCE_CODE;
case qc_type: return QC_LEN_TYPE;
case qc_type_name: return QC_LEN_TYPE_NAME;
default: break;
}
return 0;
}
struct qc_cec {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
char manufacturer[QC_LEN_MANUFACTURER];
char type[QC_LEN_TYPE];
char model_capacity[QC_LEN_MODEL_CAPACITY];
char model[QC_LEN_MODEL];
char type_name[QC_LEN_TYPE_NAME];
int type_family;
char sequence_code[QC_LEN_SEQUENCE_CODE];
char lic_identifier[QC_LEN_LIC_IDENTIFIER];
char plant[QC_LEN_PLANT];
int num_core_total;
int num_core_configured;
int num_core_standby;
int num_core_reserved;
int num_core_dedicated;
int num_core_shared;
int num_cp_total;
int num_cp_dedicated;
int num_cp_shared;
int num_ifl_total;
int num_ifl_dedicated;
int num_ifl_shared;
int num_ziip_total;
int num_ziip_dedicated;
int num_ziip_shared;
int num_cp_threads;
int num_ifl_threads;
int num_ziip_threads;
float capability;
float secondary_capability;
int capacity_adjustment_indication;
int capacity_change_reason;
};
/*
* valid attributes for a layer, where "layer-type"=="LPAR-Group"
*/
struct qc_lpar_group {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
int cp_absolute_capping;
int ifl_absolute_capping;
int ziip_absolute_capping;
};
/*
* valid attributes for a layer, where "layer-type"=="LPAR"
*/
struct qc_lpar {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
int partition_number;
char partition_char[QC_LEN_PARTITION_CHAR];
int partition_char_num;
char layer_name[QC_LEN_LAYER_NAME];
char layer_extended_name[QC_LEN_LAYER_EXTENDED_NAME];
char layer_uuid[QC_LEN_LAYER_UUID];
int adjustment;
int has_secure;
int secure;
int num_core_total;
int num_core_configured;
int num_core_standby;
int num_core_reserved;
int num_core_dedicated;
int num_core_shared;
int num_cp_total;
int num_cp_dedicated;
int num_cp_shared;
int num_ifl_total;
int num_ifl_dedicated;
int num_ifl_shared;
int num_ziip_total;
int num_ziip_dedicated;
int num_ziip_shared;
int num_cp_threads;
int num_ifl_threads;
int num_ziip_threads;
int cp_absolute_capping;
int ifl_absolute_capping;
int ziip_absolute_capping;
int cp_weight_capping;
int ifl_weight_capping;
int ziip_weight_capping;
};
struct qc_zvm_pool {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
int cp_limithard_cap;
int cp_capacity_cap;
int ifl_limithard_cap;
int ifl_capacity_cap;
int ziip_limithard_cap;
int ziip_capacity_cap;
int cp_capped_capacity;
int ifl_capped_capacity;
int ziip_capped_capacity;
};
struct qc_zvm_hypervisor {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
char cluster_name[QC_LEN_CLUSTER_NAME];
char control_program_id[QC_LEN_CONTROL_PROGRAM_ID];
int adjustment;
int limithard_consumption;
int prorated_core_time;
int num_core_total;
int num_core_dedicated;
int num_core_shared;
int num_cp_total;
int num_cp_dedicated;
int num_cp_shared;
int num_ifl_total;
int num_ifl_dedicated;
int num_ifl_shared;
int num_ziip_total;
int num_ziip_dedicated;
int num_ziip_shared;
int num_cp_threads;
int num_ifl_threads;
int num_ziip_threads;
};
struct qc_zvm_guest {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
char capping[QC_LEN_CAPPING];
int capping_num;
int mobility_enabled;
int has_secure;
int secure;
int num_cpu_total;
int num_cpu_configured;
int num_cpu_standby;
int num_cpu_reserved;
int num_cpu_dedicated;
int num_cpu_shared;
int num_cp_total;
int num_cp_dedicated;
int num_cp_shared;
int num_ifl_total;
int num_ifl_dedicated;
int num_ifl_shared;
int num_ziip_total;
int num_ziip_dedicated;
int num_ziip_shared;
int has_multiple_cpu_types;
int cp_dispatch_limithard;
int cp_dispatch_type;
int cp_capped_capacity;
int ifl_dispatch_limithard;
int ifl_dispatch_type;
int ifl_capped_capacity;
int ziip_dispatch_limithard;
int ziip_dispatch_type;
int ziip_capped_capacity;
};
struct qc_zos_hypervisor {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
char cluster_name[QC_LEN_CLUSTER_NAME];
char control_program_id[QC_LEN_CONTROL_PROGRAM_ID];
int adjustment;
int num_core_total;
int num_core_dedicated;
int num_core_shared;
int num_cp_total;
int num_cp_dedicated;
int num_cp_shared;
int num_ziip_total;
int num_ziip_dedicated;
int num_ziip_shared;
int num_cp_threads;
int num_ziip_threads;
};
struct qc_zos_tenant_resource_group {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
int cp_limithard_cap;
int cp_capacity_cap;
int cp_capped_capacity;
int ziip_limithard_cap;
int ziip_capacity_cap;
int ziip_capped_capacity;
};
struct qc_zos_zcx_server {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
char capping[QC_LEN_CAPPING];
int capping_num;
int has_secure;
int secure;
int num_cpu_total;
int num_cpu_configured;
int num_cpu_standby;
int num_cpu_reserved;
int num_cpu_dedicated;
int num_cpu_shared;
int num_cp_total;
int num_cp_dedicated;
int num_cp_shared;
int num_ziip_total;
int num_ziip_dedicated;
int num_ziip_shared;
int has_multiple_cpu_types;
int cp_dispatch_limithard;
int cp_dispatch_type;
int cp_capped_capacity;
int ziip_dispatch_limithard;
int ziip_dispatch_type;
int ziip_capped_capacity;
};
struct qc_kvm_hypervisor {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char control_program_id[QC_LEN_CONTROL_PROGRAM_ID];
int adjustment;
int num_core_total;
int num_core_dedicated;
int num_core_shared;
int num_cp_total;
int num_cp_dedicated;
int num_cp_shared;
int num_ifl_total;
int num_ifl_dedicated;
int num_ifl_shared;
};
struct qc_kvm_guest {
int layer_type_num;
int layer_category_num;
char layer_type[QC_LEN_LAYER_TYPE];
char layer_category[QC_LEN_LAYER_CATEGORY];
char layer_name[QC_LEN_LAYER_NAME];
char layer_extended_name[QC_LEN_LAYER_EXTENDED_NAME];
char layer_uuid[QC_LEN_LAYER_UUID];
int has_secure;
int secure;
int num_cpu_total;
int num_cpu_configured;
int num_cpu_standby;
int num_cpu_reserved;
int num_cpu_dedicated;
int num_cpu_shared;
int num_ifl_total;
int num_ifl_dedicated;
int num_ifl_shared;
int ifl_dispatch_type;
};
enum qc_data_type {
string,
integer,
floatingpoint
};
struct qc_attr {
enum qc_attr_id id;
enum qc_data_type type;
int offset;
};
static struct qc_attr cec_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_cec, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_cec, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_cec, layer_type)},
{qc_layer_category, string, offsetof(struct qc_cec, layer_category)},
{qc_layer_name, string, offsetof(struct qc_cec, layer_name)},
{qc_manufacturer, string, offsetof(struct qc_cec, manufacturer)},
{qc_type, string, offsetof(struct qc_cec, type)},
{qc_model_capacity, string, offsetof(struct qc_cec, model_capacity)},
{qc_model, string, offsetof(struct qc_cec, model)},
{qc_type_name, string, offsetof(struct qc_cec, type_name)},
{qc_type_family, integer, offsetof(struct qc_cec, type_family)},
{qc_sequence_code, string, offsetof(struct qc_cec, sequence_code)},
{qc_lic_identifier, string, offsetof(struct qc_cec, lic_identifier)},
{qc_plant, string, offsetof(struct qc_cec, plant)},
{qc_num_core_total, integer, offsetof(struct qc_cec, num_core_total)},
{qc_num_core_configured, integer, offsetof(struct qc_cec, num_core_configured)},
{qc_num_core_standby, integer, offsetof(struct qc_cec, num_core_standby)},
{qc_num_core_reserved, integer, offsetof(struct qc_cec, num_core_reserved)},
{qc_num_core_dedicated, integer, offsetof(struct qc_cec, num_core_dedicated)},
{qc_num_core_shared, integer, offsetof(struct qc_cec, num_core_shared)},
{qc_num_cp_total, integer, offsetof(struct qc_cec, num_cp_total)},
{qc_num_cp_dedicated, integer, offsetof(struct qc_cec, num_cp_dedicated)},
{qc_num_cp_shared, integer, offsetof(struct qc_cec, num_cp_shared)},
{qc_num_ifl_total, integer, offsetof(struct qc_cec, num_ifl_total)},
{qc_num_ifl_dedicated, integer, offsetof(struct qc_cec, num_ifl_dedicated)},
{qc_num_ifl_shared, integer, offsetof(struct qc_cec, num_ifl_shared)},
{qc_num_ziip_total, integer, offsetof(struct qc_cec, num_ziip_total)},
{qc_num_ziip_dedicated, integer, offsetof(struct qc_cec, num_ziip_dedicated)},
{qc_num_ziip_shared, integer, offsetof(struct qc_cec, num_ziip_shared)},
{qc_num_cp_threads, integer, offsetof(struct qc_cec, num_cp_threads)},
{qc_num_ifl_threads, integer, offsetof(struct qc_cec, num_ifl_threads)},
{qc_num_ziip_threads, integer, offsetof(struct qc_cec, num_ziip_threads)},
{qc_capability, floatingpoint, offsetof(struct qc_cec, capability)},
{qc_secondary_capability, floatingpoint, offsetof(struct qc_cec, secondary_capability)},
{qc_capacity_adjustment_indication, integer, offsetof(struct qc_cec, capacity_adjustment_indication)},
{qc_capacity_change_reason, integer, offsetof(struct qc_cec, capacity_change_reason)},
{-1, string, -1}
};
static struct qc_attr lpar_group_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_lpar_group, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_lpar_group, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_lpar_group, layer_type)},
{qc_layer_category, string, offsetof(struct qc_lpar_group, layer_category)},
{qc_layer_name, string, offsetof(struct qc_lpar_group, layer_name)},
{qc_cp_absolute_capping, integer, offsetof(struct qc_lpar_group, cp_absolute_capping)},
{qc_ifl_absolute_capping, integer, offsetof(struct qc_lpar_group, ifl_absolute_capping)},
{qc_ziip_absolute_capping, integer, offsetof(struct qc_lpar_group, ziip_absolute_capping)},
{-1, string, -1}
};
static struct qc_attr lpar_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_lpar, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_lpar, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_lpar, layer_type)},
{qc_layer_category, string, offsetof(struct qc_lpar, layer_category)},
{qc_partition_number, integer, offsetof(struct qc_lpar, partition_number)},
{qc_partition_char, string, offsetof(struct qc_lpar, partition_char)},
{qc_partition_char_num, integer, offsetof(struct qc_lpar, partition_char_num)},
{qc_layer_name, string, offsetof(struct qc_lpar, layer_name)},
{qc_layer_extended_name, string, offsetof(struct qc_lpar, layer_extended_name)},
{qc_layer_uuid, string, offsetof(struct qc_lpar, layer_uuid)},
{qc_adjustment, integer, offsetof(struct qc_lpar, adjustment)},
{qc_has_secure, integer, offsetof(struct qc_lpar, has_secure)},
{qc_secure, integer, offsetof(struct qc_lpar, secure)},
{qc_num_core_total, integer, offsetof(struct qc_lpar, num_core_total)},
{qc_num_core_configured, integer, offsetof(struct qc_lpar, num_core_configured)},
{qc_num_core_standby, integer, offsetof(struct qc_lpar, num_core_standby)},
{qc_num_core_reserved, integer, offsetof(struct qc_lpar, num_core_reserved)},
{qc_num_core_dedicated, integer, offsetof(struct qc_lpar, num_core_dedicated)},
{qc_num_core_shared, integer, offsetof(struct qc_lpar, num_core_shared)},
{qc_num_cp_total, integer, offsetof(struct qc_lpar, num_cp_total)},
{qc_num_cp_dedicated, integer, offsetof(struct qc_lpar, num_cp_dedicated)},
{qc_num_cp_shared, integer, offsetof(struct qc_lpar, num_cp_shared)},
{qc_num_ifl_total, integer, offsetof(struct qc_lpar, num_ifl_total)},
{qc_num_ifl_dedicated, integer, offsetof(struct qc_lpar, num_ifl_dedicated)},
{qc_num_ifl_shared, integer, offsetof(struct qc_lpar, num_ifl_shared)},
{qc_num_ziip_total, integer, offsetof(struct qc_lpar, num_ziip_total)},
{qc_num_ziip_dedicated, integer, offsetof(struct qc_lpar, num_ziip_dedicated)},
{qc_num_ziip_shared, integer, offsetof(struct qc_lpar, num_ziip_shared)},
{qc_num_cp_threads, integer, offsetof(struct qc_lpar, num_cp_threads)},
{qc_num_ifl_threads, integer, offsetof(struct qc_lpar, num_ifl_threads)},
{qc_num_ziip_threads, integer, offsetof(struct qc_lpar, num_ziip_threads)},
{qc_cp_absolute_capping, integer, offsetof(struct qc_lpar, cp_absolute_capping)},
{qc_ifl_absolute_capping, integer, offsetof(struct qc_lpar, ifl_absolute_capping)},
{qc_ziip_absolute_capping, integer, offsetof(struct qc_lpar, ziip_absolute_capping)},
{qc_cp_weight_capping, integer, offsetof(struct qc_lpar, cp_weight_capping)},
{qc_ifl_weight_capping, integer, offsetof(struct qc_lpar, ifl_weight_capping)},
{qc_ziip_weight_capping, integer, offsetof(struct qc_lpar, ziip_weight_capping)},
{-1, string, -1}
};
static struct qc_attr zvm_hv_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_zvm_hypervisor, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_zvm_hypervisor, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_zvm_hypervisor, layer_type)},
{qc_layer_category, string, offsetof(struct qc_zvm_hypervisor, layer_category)},
{qc_layer_name, string, offsetof(struct qc_zvm_hypervisor, layer_name)},
{qc_cluster_name, string, offsetof(struct qc_zvm_hypervisor, cluster_name)},
{qc_control_program_id, string, offsetof(struct qc_zvm_hypervisor, control_program_id)},
{qc_adjustment, integer, offsetof(struct qc_zvm_hypervisor, adjustment)},
{qc_limithard_consumption, integer, offsetof(struct qc_zvm_hypervisor, limithard_consumption)},
{qc_prorated_core_time, integer, offsetof(struct qc_zvm_hypervisor, prorated_core_time)},
{qc_num_core_total, integer, offsetof(struct qc_zvm_hypervisor, num_core_total)},
{qc_num_core_dedicated, integer, offsetof(struct qc_zvm_hypervisor, num_core_dedicated)},
{qc_num_core_shared, integer, offsetof(struct qc_zvm_hypervisor, num_core_shared)},
{qc_num_cp_total, integer, offsetof(struct qc_zvm_hypervisor, num_cp_total)},
{qc_num_cp_dedicated, integer, offsetof(struct qc_zvm_hypervisor, num_cp_dedicated)},
{qc_num_cp_shared, integer, offsetof(struct qc_zvm_hypervisor, num_cp_shared)},
{qc_num_ifl_total, integer, offsetof(struct qc_zvm_hypervisor, num_ifl_total)},
{qc_num_ifl_dedicated, integer, offsetof(struct qc_zvm_hypervisor, num_ifl_dedicated)},
{qc_num_ifl_shared, integer, offsetof(struct qc_zvm_hypervisor, num_ifl_shared)},
{qc_num_ziip_total, integer, offsetof(struct qc_zvm_hypervisor, num_ziip_total)},
{qc_num_ziip_dedicated, integer, offsetof(struct qc_zvm_hypervisor, num_ziip_dedicated)},
{qc_num_ziip_shared, integer, offsetof(struct qc_zvm_hypervisor, num_ziip_shared)},
{qc_num_cp_threads, integer, offsetof(struct qc_zvm_hypervisor, num_cp_threads)},
{qc_num_ifl_threads, integer, offsetof(struct qc_zvm_hypervisor, num_ifl_threads)},
{qc_num_ziip_threads, integer, offsetof(struct qc_zvm_hypervisor, num_ziip_threads)},
{-1, string, -1}
};
static struct qc_attr zos_hv_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_zos_hypervisor, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_zos_hypervisor, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_zos_hypervisor, layer_type)},
{qc_layer_category, string, offsetof(struct qc_zos_hypervisor, layer_category)},
{qc_layer_name, string, offsetof(struct qc_zos_hypervisor, layer_name)},
{qc_cluster_name, string, offsetof(struct qc_zos_hypervisor, cluster_name)},
{qc_control_program_id, string, offsetof(struct qc_zos_hypervisor, control_program_id)},
{qc_adjustment, integer, offsetof(struct qc_zos_hypervisor, adjustment)},
{qc_num_core_total, integer, offsetof(struct qc_zos_hypervisor, num_core_total)},
{qc_num_core_dedicated, integer, offsetof(struct qc_zos_hypervisor, num_core_dedicated)},
{qc_num_core_shared, integer, offsetof(struct qc_zos_hypervisor, num_core_shared)},
{qc_num_cp_total, integer, offsetof(struct qc_zos_hypervisor, num_cp_total)},
{qc_num_cp_dedicated, integer, offsetof(struct qc_zos_hypervisor, num_cp_dedicated)},
{qc_num_cp_shared, integer, offsetof(struct qc_zos_hypervisor, num_cp_shared)},
{qc_num_ziip_total, integer, offsetof(struct qc_zos_hypervisor, num_ziip_total)},
{qc_num_ziip_dedicated, integer, offsetof(struct qc_zos_hypervisor, num_ziip_dedicated)},
{qc_num_ziip_shared, integer, offsetof(struct qc_zos_hypervisor, num_ziip_shared)},
{qc_num_cp_threads, integer, offsetof(struct qc_zos_hypervisor, num_cp_threads)},
{qc_num_ziip_threads, integer, offsetof(struct qc_zos_hypervisor, num_ziip_threads)},
{-1, string, -1}
};
static struct qc_attr zos_tenant_resgroup_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_zos_tenant_resource_group, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_zos_tenant_resource_group, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_zos_tenant_resource_group, layer_type)},
{qc_layer_category, string, offsetof(struct qc_zos_tenant_resource_group, layer_category)},
{qc_layer_name, string, offsetof(struct qc_zos_tenant_resource_group, layer_name)},
{qc_cp_limithard_cap, integer, offsetof(struct qc_zos_tenant_resource_group, cp_limithard_cap)},
{qc_cp_capacity_cap, integer, offsetof(struct qc_zos_tenant_resource_group, cp_capacity_cap)},
{qc_ziip_limithard_cap, integer, offsetof(struct qc_zos_tenant_resource_group, ziip_limithard_cap)},
{qc_ziip_capacity_cap, integer, offsetof(struct qc_zos_tenant_resource_group, ziip_capacity_cap)},
{qc_cp_capped_capacity, integer, offsetof(struct qc_zos_tenant_resource_group, cp_capped_capacity)},
{qc_ziip_capped_capacity, integer, offsetof(struct qc_zos_tenant_resource_group, ziip_capped_capacity)},
{-1, string, -1}
};
static struct qc_attr kvm_hv_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_kvm_hypervisor, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_kvm_hypervisor, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_kvm_hypervisor, layer_type)},
{qc_layer_category, string, offsetof(struct qc_kvm_hypervisor, layer_category)},
{qc_control_program_id, string, offsetof(struct qc_kvm_hypervisor, control_program_id)},
{qc_adjustment, integer, offsetof(struct qc_kvm_hypervisor, adjustment)},
{qc_num_core_total, integer, offsetof(struct qc_kvm_hypervisor, num_core_total)},
{qc_num_core_dedicated, integer, offsetof(struct qc_kvm_hypervisor, num_core_dedicated)},
{qc_num_core_shared, integer, offsetof(struct qc_kvm_hypervisor, num_core_shared)},
{qc_num_cp_total, integer, offsetof(struct qc_kvm_hypervisor, num_cp_total)},
{qc_num_cp_dedicated, integer, offsetof(struct qc_kvm_hypervisor, num_cp_dedicated)},
{qc_num_cp_shared, integer, offsetof(struct qc_kvm_hypervisor, num_cp_shared)},
{qc_num_ifl_total, integer, offsetof(struct qc_kvm_hypervisor, num_ifl_total)},
{qc_num_ifl_dedicated, integer, offsetof(struct qc_kvm_hypervisor, num_ifl_dedicated)},
{qc_num_ifl_shared, integer, offsetof(struct qc_kvm_hypervisor, num_ifl_shared)},
{-1, string, -1}
};
static struct qc_attr zvm_pool_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_zvm_pool, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_zvm_pool, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_zvm_pool, layer_type)},
{qc_layer_category, string, offsetof(struct qc_zvm_pool, layer_category)},
{qc_layer_name, string, offsetof(struct qc_zvm_pool, layer_name)},
{qc_cp_limithard_cap, integer, offsetof(struct qc_zvm_pool, cp_limithard_cap)},
{qc_cp_capacity_cap, integer, offsetof(struct qc_zvm_pool, cp_capacity_cap)},
{qc_ifl_limithard_cap, integer, offsetof(struct qc_zvm_pool, ifl_limithard_cap)},
{qc_ifl_capacity_cap, integer, offsetof(struct qc_zvm_pool, ifl_capacity_cap)},
{qc_ziip_limithard_cap, integer, offsetof(struct qc_zvm_pool, ziip_limithard_cap)},
{qc_ziip_capacity_cap, integer, offsetof(struct qc_zvm_pool, ziip_capacity_cap)},
{qc_cp_capped_capacity, integer, offsetof(struct qc_zvm_pool, cp_capped_capacity)},
{qc_ifl_capped_capacity, integer, offsetof(struct qc_zvm_pool, ifl_capped_capacity)},
{qc_ziip_capped_capacity, integer, offsetof(struct qc_zvm_pool, ziip_capped_capacity)},
{-1, string, -1}
};
static struct qc_attr zvm_guest_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_zvm_guest, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_zvm_guest, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_zvm_guest, layer_type)},
{qc_layer_category, string, offsetof(struct qc_zvm_guest, layer_category)},
{qc_layer_name, string, offsetof(struct qc_zvm_guest, layer_name)},
{qc_capping, string, offsetof(struct qc_zvm_guest, capping)},
{qc_capping_num, integer, offsetof(struct qc_zvm_guest, capping_num)},
{qc_mobility_enabled, integer, offsetof(struct qc_zvm_guest, mobility_enabled)},
{qc_has_secure, integer, offsetof(struct qc_zvm_guest, has_secure)},
{qc_secure, integer, offsetof(struct qc_zvm_guest, secure)},
{qc_num_cpu_total, integer, offsetof(struct qc_zvm_guest, num_cpu_total)},
{qc_num_cpu_configured, integer, offsetof(struct qc_zvm_guest, num_cpu_configured)},
{qc_num_cpu_standby, integer, offsetof(struct qc_zvm_guest, num_cpu_standby)},
{qc_num_cpu_reserved, integer, offsetof(struct qc_zvm_guest, num_cpu_reserved)},
{qc_num_cpu_dedicated, integer, offsetof(struct qc_zvm_guest, num_cpu_dedicated)},
{qc_num_cpu_shared, integer, offsetof(struct qc_zvm_guest, num_cpu_shared)},
{qc_num_cp_total, integer, offsetof(struct qc_zvm_guest, num_cp_total)},
{qc_num_cp_dedicated, integer, offsetof(struct qc_zvm_guest, num_cp_dedicated)},
{qc_num_cp_shared, integer, offsetof(struct qc_zvm_guest, num_cp_shared)},
{qc_num_ifl_total, integer, offsetof(struct qc_zvm_guest, num_ifl_total)},
{qc_num_ifl_dedicated, integer, offsetof(struct qc_zvm_guest, num_ifl_dedicated)},
{qc_num_ifl_shared, integer, offsetof(struct qc_zvm_guest, num_ifl_shared)},
{qc_num_ziip_total, integer, offsetof(struct qc_zvm_guest, num_ziip_total)},
{qc_num_ziip_dedicated, integer, offsetof(struct qc_zvm_guest, num_ziip_dedicated)},
{qc_num_ziip_shared, integer, offsetof(struct qc_zvm_guest, num_ziip_shared)},
{qc_has_multiple_cpu_types, integer, offsetof(struct qc_zvm_guest, has_multiple_cpu_types)},
{qc_cp_dispatch_limithard, integer, offsetof(struct qc_zvm_guest, cp_dispatch_limithard)},
{qc_cp_capped_capacity, integer, offsetof(struct qc_zvm_guest, cp_capped_capacity)},
{qc_ifl_dispatch_limithard, integer, offsetof(struct qc_zvm_guest, ifl_dispatch_limithard)},
{qc_ifl_capped_capacity, integer, offsetof(struct qc_zvm_guest, ifl_capped_capacity)},
{qc_ziip_dispatch_limithard, integer, offsetof(struct qc_zvm_guest, ziip_dispatch_limithard)},
{qc_ziip_capped_capacity, integer, offsetof(struct qc_zvm_guest, ziip_capped_capacity)},
{qc_cp_dispatch_type, integer, offsetof(struct qc_zvm_guest, cp_dispatch_type)},
{qc_ifl_dispatch_type, integer, offsetof(struct qc_zvm_guest, ifl_dispatch_type)},
{qc_ziip_dispatch_type, integer, offsetof(struct qc_zvm_guest, ziip_dispatch_type)},
{-1, string, -1}
};
static struct qc_attr zos_zcx_server_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_zos_zcx_server, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_zos_zcx_server, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_zos_zcx_server, layer_type)},
{qc_layer_category, string, offsetof(struct qc_zos_zcx_server, layer_category)},
{qc_layer_name, string, offsetof(struct qc_zos_zcx_server, layer_name)},
{qc_capping, string, offsetof(struct qc_zos_zcx_server, capping)},
{qc_capping_num, integer, offsetof(struct qc_zos_zcx_server, capping_num)},
{qc_has_secure, integer, offsetof(struct qc_zos_zcx_server, has_secure)},
{qc_secure, integer, offsetof(struct qc_zos_zcx_server, secure)},
{qc_num_cpu_total, integer, offsetof(struct qc_zos_zcx_server, num_cpu_total)},
{qc_num_cpu_configured, integer, offsetof(struct qc_zos_zcx_server, num_cpu_configured)},
{qc_num_cpu_standby, integer, offsetof(struct qc_zos_zcx_server, num_cpu_standby)},
{qc_num_cpu_reserved, integer, offsetof(struct qc_zos_zcx_server, num_cpu_reserved)},
{qc_num_cpu_dedicated, integer, offsetof(struct qc_zos_zcx_server, num_cpu_dedicated)},
{qc_num_cpu_shared, integer, offsetof(struct qc_zos_zcx_server, num_cpu_shared)},
{qc_num_cp_total, integer, offsetof(struct qc_zos_zcx_server, num_cp_total)},
{qc_num_cp_dedicated, integer, offsetof(struct qc_zos_zcx_server, num_cp_dedicated)},
{qc_num_cp_shared, integer, offsetof(struct qc_zos_zcx_server, num_cp_shared)},
{qc_num_ziip_total, integer, offsetof(struct qc_zos_zcx_server, num_ziip_total)},
{qc_num_ziip_dedicated, integer, offsetof(struct qc_zos_zcx_server, num_ziip_dedicated)},
{qc_num_ziip_shared, integer, offsetof(struct qc_zos_zcx_server, num_ziip_shared)},
{qc_has_multiple_cpu_types, integer, offsetof(struct qc_zos_zcx_server, has_multiple_cpu_types)},
{qc_cp_dispatch_limithard, integer, offsetof(struct qc_zos_zcx_server, cp_dispatch_limithard)},
{qc_cp_capped_capacity, integer, offsetof(struct qc_zos_zcx_server, cp_capped_capacity)},
{qc_ziip_dispatch_limithard, integer, offsetof(struct qc_zos_zcx_server, ziip_dispatch_limithard)},
{qc_ziip_capped_capacity, integer, offsetof(struct qc_zos_zcx_server, ziip_capped_capacity)},
{qc_cp_dispatch_type, integer, offsetof(struct qc_zos_zcx_server, cp_dispatch_type)},
{qc_ziip_dispatch_type, integer, offsetof(struct qc_zos_zcx_server, ziip_dispatch_type)},
{-1, string, -1}
};
static struct qc_attr kvm_guest_attrs[] = {
{qc_layer_type_num, integer, offsetof(struct qc_kvm_guest, layer_type_num)},
{qc_layer_category_num, integer, offsetof(struct qc_kvm_guest, layer_category_num)},
{qc_layer_type, string, offsetof(struct qc_kvm_guest, layer_type)},
{qc_layer_category, string, offsetof(struct qc_kvm_guest, layer_category)},
{qc_layer_name, string, offsetof(struct qc_kvm_guest, layer_name)},
{qc_layer_extended_name, string, offsetof(struct qc_kvm_guest, layer_extended_name)},
{qc_layer_uuid, string, offsetof(struct qc_kvm_guest, layer_uuid)},
{qc_has_secure, integer, offsetof(struct qc_kvm_guest, has_secure)},
{qc_secure, integer, offsetof(struct qc_kvm_guest, secure)},
{qc_num_cpu_total, integer, offsetof(struct qc_kvm_guest, num_cpu_total)},
{qc_num_cpu_configured, integer, offsetof(struct qc_kvm_guest, num_cpu_configured)},
{qc_num_cpu_standby, integer, offsetof(struct qc_kvm_guest, num_cpu_standby)},
{qc_num_cpu_reserved, integer, offsetof(struct qc_kvm_guest, num_cpu_reserved)},
{qc_num_cpu_dedicated, integer, offsetof(struct qc_kvm_guest, num_cpu_dedicated)},
{qc_num_cpu_shared, integer, offsetof(struct qc_kvm_guest, num_cpu_shared)},
{qc_num_ifl_total, integer, offsetof(struct qc_kvm_guest, num_ifl_total)},
{qc_num_ifl_dedicated, integer, offsetof(struct qc_kvm_guest, num_ifl_dedicated)},
{qc_num_ifl_shared, integer, offsetof(struct qc_kvm_guest, num_ifl_shared)},
{qc_ifl_dispatch_type, integer, offsetof(struct qc_kvm_guest, ifl_dispatch_type)},
{-1, string, -1}
};
const char *qc_attr_id_to_char(struct qc_handle *hdl, enum qc_attr_id id) {
switch (id) {
case qc_layer_type_num: return "layer_type_num";
case qc_layer_category_num: return "layer_category_num";
case qc_layer_type: return "layer_type";
case qc_layer_category: return "layer_category";
case qc_layer_name: return "layer_name";
case qc_layer_extended_name: return "layer_extended_name";
case qc_layer_uuid: return "layer_uuid";
case qc_lic_identifier: return "lic_identifier";
case qc_manufacturer: return "manufacturer";
case qc_type: return "type";
case qc_model_capacity: return "model_capacity";
case qc_type_family: return "type_family";
case qc_model: return "model";
case qc_type_name: return "type_name";
case qc_sequence_code: return "sequence_code";
case qc_plant: return "plant";
case qc_num_cpu_total: return "num_cpu_total";
case qc_num_cpu_configured: return "num_cpu_configured";
case qc_num_cpu_standby: return "num_cpu_standby";
case qc_num_cpu_reserved: return "num_cpu_reserved";
case qc_num_cpu_dedicated: return "num_cpu_dedicated";
case qc_num_cpu_shared: return "num_cpu_shared";
case qc_num_cp_total: return "num_cp_total";
case qc_num_cp_dedicated: return "num_cp_dedicated";
case qc_num_cp_shared: return "num_cp_shared";
case qc_num_ifl_total: return "num_ifl_total";
case qc_num_ifl_dedicated: return "num_ifl_dedicated";
case qc_num_ifl_shared: return "num_ifl_shared";
case qc_capability: return "capability";
case qc_secondary_capability: return "secondary_capability";
case qc_capacity_adjustment_indication: return "capacity_adjustment_indication";
case qc_capacity_change_reason: return "capacity_change_reason";
case qc_partition_number: return "partition_number";
case qc_partition_char: return "partition_char";
case qc_partition_char_num: return "partition_char_num";
case qc_adjustment: return "adjustment";
case qc_cp_absolute_capping: return "cp_absolute_capping";
case qc_ifl_absolute_capping: return "ifl_absolute_capping";
case qc_cp_weight_capping: return "cp_weight_capping";
case qc_ifl_weight_capping: return "ifl_weight_capping";
case qc_cluster_name: return "cluster_name";
case qc_control_program_id: return "control_program_id";
case qc_limithard_consumption: return "limithard_consumption";
case qc_prorated_core_time: return "prorated_core_time";
case qc_cp_limithard_cap: return "pool_cp_limithard_cap";
case qc_cp_capacity_cap: return "pool_cp_capacity_cap";
case qc_ifl_limithard_cap: return "pool_ifl_limithard_cap";
case qc_ifl_capacity_cap: return "pool_ifl_capacity_cap";
case qc_capping: return "capping";
case qc_capping_num: return "capping_num";
case qc_mobility_enabled: return "mobility_enabled";
case qc_has_secure: return "has_secure";
case qc_secure: return "secure";
case qc_has_multiple_cpu_types: return "has_multiple_cpu_types";
case qc_cp_dispatch_limithard: return "cp_dispatch_limithard";
case qc_ifl_dispatch_limithard: return "ifl_dispatch_limithard";
case qc_cp_dispatch_type: return "cp_dispatch_type";
case qc_ifl_dispatch_type: return "ifl_dispatch_type";
case qc_cp_capped_capacity: return "cp_capped_capacity";
case qc_ifl_capped_capacity: return "ifl_capped_capacity";
case qc_num_cp_threads: return "num_cp_threads";
case qc_num_ifl_threads: return "num_ifl_threads";
case qc_num_core_total: return "num_core_total";
case qc_num_core_configured: return "num_core_configured";
case qc_num_core_standby: return "num_core_standby";
case qc_num_core_reserved: return "num_core_reserved";
case qc_num_core_dedicated: return "num_core_dedicated";
case qc_num_core_shared: return "num_core_shared";
case qc_ziip_absolute_capping: return "ziip_absolute_capping";
case qc_ziip_capacity_cap: return "ziip_capacity_cap";
case qc_ziip_capped_capacity: return "ziip_capped_capacity";
case qc_ziip_dispatch_limithard: return "ziip_dispatch_limithard";
case qc_ziip_dispatch_type: return "ziip_dispatch_type";
case qc_ziip_limithard_cap: return "ziip_limithard_cap";
case qc_ziip_weight_capping: return "ziip_weight_capping";
case qc_num_ziip_dedicated: return "num_ziip_dedicated";
case qc_num_ziip_shared: return "num_ziip_shared";
case qc_num_ziip_total: return "num_ziip_total";
case qc_num_ziip_threads: return "num_ziip_threads";
default: break;
}
qc_debug(hdl, "Error: Cannot convert unknown attribute '%d' to char*\n", id);
return NULL;
}
struct qc_handle *qc_hdl_get_cec(struct qc_handle *hdl) {
return hdl ? hdl->root : hdl;
}
struct qc_handle *qc_hdl_get_lpar(struct qc_handle *hdl) {
for (hdl = hdl->root; hdl != NULL && *(int *)(hdl->layer) != QC_LAYER_TYPE_LPAR; hdl = hdl->next);
return hdl;
}
// 'hdl' is for error reporting, as 'tgthdl' might not be part of the pointer lists yet
int qc_hdl_new(struct qc_handle *hdl, struct qc_handle **tgthdl, int layer_no,
int layer_type_num) {
int num_attrs, layer_category_num;
char *layer_type, *layer_category;
struct qc_attr *attrs;
size_t layer_sz;
switch (layer_type_num) {
case QC_LAYER_TYPE_CEC:
layer_sz = sizeof(struct qc_cec);
attrs = cec_attrs;
layer_category_num = QC_LAYER_CAT_HOST;
layer_category = "HOST";
layer_type = "CEC";
break;
case QC_LAYER_TYPE_LPAR_GROUP:
layer_sz = sizeof(struct qc_lpar);
attrs = lpar_group_attrs;
layer_category_num = QC_LAYER_CAT_POOL;
layer_category = "POOL";
layer_type = "LPAR-GROUP";
break;
case QC_LAYER_TYPE_LPAR:
layer_sz = sizeof(struct qc_lpar);
attrs = lpar_attrs;
layer_category_num = QC_LAYER_CAT_GUEST;
layer_category = "GUEST";
layer_type = "LPAR";
break;
case QC_LAYER_TYPE_ZVM_HYPERVISOR:
layer_sz = sizeof(struct qc_zvm_hypervisor);
attrs = zvm_hv_attrs;
layer_category_num = QC_LAYER_CAT_HOST;
layer_category = "HOST";
layer_type = "z/VM-hypervisor";
break;
case QC_LAYER_TYPE_ZVM_RESOURCE_POOL:
layer_sz = sizeof(struct qc_zvm_pool);
attrs = zvm_pool_attrs;
layer_category_num = QC_LAYER_CAT_POOL;
layer_category = "POOL";
#ifdef CONFIG_V1_COMPATIBILITY
layer_type = "z/VM-CPU-pool";
#else
layer_type = "z/VM-resource-pool";
#endif
break;
case QC_LAYER_TYPE_ZVM_GUEST:
layer_sz = sizeof(struct qc_zvm_guest);
attrs = zvm_guest_attrs;
layer_category_num = QC_LAYER_CAT_GUEST;
layer_category = "GUEST";
layer_type = "z/VM-guest";
break;
case QC_LAYER_TYPE_ZOS_HYPERVISOR:
layer_sz = sizeof(struct qc_zos_hypervisor);
attrs = zos_hv_attrs;
layer_category_num = QC_LAYER_CAT_HOST;
layer_category = "HOST";
layer_type = "z/OS-hypervisor";
break;
case QC_LAYER_TYPE_ZOS_TENANT_RESOURCE_GROUP:
layer_sz = sizeof(struct qc_zos_tenant_resource_group);
attrs = zos_tenant_resgroup_attrs;
layer_category_num = QC_LAYER_CAT_POOL;
layer_category = "POOL";
layer_type = "z/OS-tenant-resource-group";
break;
case QC_LAYER_TYPE_KVM_HYPERVISOR:
layer_sz = sizeof(struct qc_kvm_hypervisor);
attrs = kvm_hv_attrs;
layer_category_num = QC_LAYER_CAT_HOST;
layer_category = "HOST";
layer_type = "KVM-hypervisor";
break;
case QC_LAYER_TYPE_KVM_GUEST:
layer_sz = sizeof(struct qc_kvm_guest);
attrs = kvm_guest_attrs;
layer_category_num = QC_LAYER_CAT_GUEST;
layer_category = "GUEST";
layer_type = "KVM-guest";
break;
case QC_LAYER_TYPE_ZOS_ZCX_SERVER:
layer_sz = sizeof(struct qc_zos_zcx_server);
attrs = zos_zcx_server_attrs;
layer_category_num = QC_LAYER_CAT_GUEST;
layer_category = "GUEST";
layer_type = "z/OS-zCX-Server";
break;
default:
qc_debug(hdl, "Error: Unhandled layer type in qc_hdl_new()\n");
return -1;
}
// determine number of attributes
for (num_attrs = 0; attrs[num_attrs].offset >= 0; ++num_attrs);
num_attrs++;
if (hdl || *tgthdl == NULL) {
// Possibly reuse existing handle when alloc'ing the cec layer.
// Otherwise we'd change the handle which serves as an identified in
// our log output, which could be confusing.
*tgthdl = malloc(sizeof(struct qc_handle));
if (!*tgthdl) {
qc_debug(hdl, "Error: Failed to allocate handle\n");
return -2;
}
}
memset(*tgthdl, 0, sizeof(struct qc_handle));
(*tgthdl)->layer_no = layer_no;
(*tgthdl)->attr_list = attrs;
if (hdl)
(*tgthdl)->root = hdl->root;
else
(*tgthdl)->root = *tgthdl;
(*tgthdl)->layer = malloc(layer_sz);
if (!(*tgthdl)->layer) {
qc_debug(hdl, "Error: Failed to allocate layer\n");
free(*tgthdl);
*tgthdl = NULL;
return -3;
}
memset((*tgthdl)->layer, 0, layer_sz);
(*tgthdl)->attr_present = calloc(num_attrs, sizeof(int));
(*tgthdl)->src = calloc(num_attrs, sizeof(int));
if (!(*tgthdl)->attr_present || !(*tgthdl)->src) {
qc_debug(hdl, "Error: Failed to allocate attr_present array\n");
free((*tgthdl)->layer);
free(*tgthdl);
*tgthdl = NULL;
return -4;
}
if (qc_set_attr_int(*tgthdl, qc_layer_type_num, layer_type_num, ATTR_SRC_UNDEF) ||
qc_set_attr_int(*tgthdl, qc_layer_category_num, layer_category_num, ATTR_SRC_UNDEF) ||
qc_set_attr_string(*tgthdl, qc_layer_type, layer_type, ATTR_SRC_UNDEF) ||
qc_set_attr_string(*tgthdl, qc_layer_category, layer_category, ATTR_SRC_UNDEF))
return -5;
return 0;
}
int qc_hdl_insert(struct qc_handle *hdl, struct qc_handle **inserted_hdl, int type) {
struct qc_handle *prev_hdl = qc_hdl_get_prev(hdl);
if (!prev_hdl)
return -1;
if (qc_hdl_new(hdl, inserted_hdl, hdl->layer_no, type))
return -2;
(*inserted_hdl)->next = hdl;
prev_hdl->next = *inserted_hdl;
// adjust layer_no in remaining layers
for (; hdl != NULL; hdl = hdl->next)
hdl->layer_no++;
return 0;
}
void qc_hdl_prune(struct qc_handle *hdl) {
struct qc_handle *ptr = hdl, *skip = NULL;
// Pruning at the root needs special handling as does intermediate pruning
if (hdl == qc_hdl_get_root(hdl))
skip = hdl;
else {
hdl = qc_hdl_get_prev(hdl);
hdl->next = NULL;
}
while (ptr) {
free(ptr->layer);
free(ptr->attr_present);
free(ptr->src);
hdl = ptr->next;
if (ptr == skip) {
memset(ptr, 0, sizeof(struct qc_handle));
ptr->root = ptr;
} else
free(ptr);
ptr = hdl;
}
return;
}
int qc_hdl_get_layer_no(struct qc_handle *hdl) {
return hdl->layer_no;
}
int qc_hdl_append(struct qc_handle *hdl, struct qc_handle **appended_hdl, int type) {
struct qc_handle *next_hdl = hdl->next;
if (qc_hdl_new(hdl, appended_hdl, hdl->layer_no + 1, type))
return -1;
hdl->next = *appended_hdl;
(*appended_hdl)->next = next_hdl;
// adjust layer_no in remaining layers
for (hdl = next_hdl; hdl != NULL; hdl = hdl->next)
hdl->layer_no++;
return 0;
}
#ifdef CONFIG_V1_COMPATIBILITY
/* Maps qc_num_cpu_* to qc_num_core_* attributes where required to preserve backwards compatibility.
* Should be removed in a qclib v2.0 release. */
static enum qc_attr_id preserve_v1_attr_compatibility(struct qc_handle *hdl, enum qc_attr_id id) {
if (id != qc_layer_type_num) {
int *layer_type = qc_get_attr_value_int(hdl, qc_layer_type_num);
switch (*layer_type) {
case QC_LAYER_TYPE_CEC:
case QC_LAYER_TYPE_LPAR:
switch (id) {
case qc_num_cpu_configured: return qc_num_core_configured;
case qc_num_cpu_standby: return qc_num_core_standby;
case qc_num_cpu_reserved: return qc_num_core_reserved;
default: break;
}
// fallthrough
case QC_LAYER_TYPE_ZVM_HYPERVISOR:
case QC_LAYER_TYPE_KVM_HYPERVISOR:
switch (id) {
case qc_num_cpu_total: return qc_num_core_total;
case qc_num_cpu_dedicated: return qc_num_core_dedicated;
case qc_num_cpu_shared: return qc_num_core_shared;
default: break;
}
}
}
return id;
}
#endif
// Indicates the attribute as 'set', returning a ptr to its content
static char *qc_set_attr(struct qc_handle *hdl, enum qc_attr_id id, enum qc_data_type type, char src, int *prev_set) {
struct qc_attr *attr_list = hdl->attr_list;
int count;
for (count = 0; attr_list[count].offset >= 0; ++count) {
if (attr_list[count].id == id && attr_list[count].type == type) {
*prev_set = hdl->attr_present[count];
hdl->attr_present[count] = 1;
hdl->src[count] = src;
return (char *)hdl->layer + attr_list[count].offset;
}
}
qc_debug(hdl, "Error: Failed to set attr=%s (not found)\n", qc_attr_id_to_char(hdl, id));
return NULL;
}
// Sets attribute 'id' in layer as pointed to by 'hdl'
int qc_set_attr_int(struct qc_handle *hdl, enum qc_attr_id id, int val, char src) {
char orig_src = qc_get_attr_value_src_int(hdl, id);
int *ptr, prev_set;