1 /*****************************************************************************\
2 * slurmdb_pack.h - un/pack definitions used by slurmdb api
3 ******************************************************************************
4 * Copyright (C) 2011-2015 SchedMD LLC.
5 * Copyright (C) 2010 Lawrence Livermore National Security.
6 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
7 * Written by Danny Auble da@schedmd.com, et. al.
8 * CODE-OCEC-09-009. All rights reserved.
9 *
10 * This file is part of Slurm, a resource management program.
11 * For details, see <https://slurm.schedmd.com/>.
12 * Please also read the included file: DISCLAIMER.
13 *
14 * Slurm is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option)
17 * any later version.
18 *
19 * In addition, as a special exception, the copyright holders give permission
20 * to link the code of portions of this program with the OpenSSL library under
21 * certain conditions as described in each individual source file, and
22 * distribute linked combinations including the two. You must obey the GNU
23 * General Public License in all respects for all of the code used other than
24 * OpenSSL. If you modify file(s) with this exception, you may extend this
25 * exception to your version of the file(s), but you are not obligated to do
26 * so. If you do not wish to do so, delete this exception statement from your
27 * version. If you delete this exception statement from all source files in
28 * the program, then also delete it here.
29 *
30 * Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
31 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
32 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
33 * details.
34 *
35 * You should have received a copy of the GNU General Public License along
36 * with Slurm; if not, write to the Free Software Foundation, Inc.,
37 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
38 \*****************************************************************************/
39
40 #include <stdlib.h>
41 #include "slurmdb_pack.h"
42 #include "slurmdbd_defs.h"
43 #include "slurm_protocol_defs.h"
44 #include "slurm_jobacct_gather.h"
45 #include "list.h"
46 #include "pack.h"
47
48 #define KB_ADJ 1024
49 #define MB_ADJ 1048576
50
_pack_list_of_str(List l,Buf buffer)51 static void _pack_list_of_str(List l, Buf buffer)
52 {
53 uint32_t count = NO_VAL;
54 ListIterator itr = NULL;
55 char *str;
56
57 if (l)
58 count = list_count(l);
59
60 pack32(count, buffer);
61 if (count && (count != NO_VAL)) {
62 itr = list_iterator_create(l);
63 while ((str = list_next(itr)))
64 packstr(str, buffer);
65 list_iterator_destroy(itr);
66 }
67 }
68
_pack_slurmdb_stats(slurmdb_stats_t * stats,uint16_t protocol_version,Buf buffer)69 static void _pack_slurmdb_stats(slurmdb_stats_t *stats,
70 uint16_t protocol_version, Buf buffer)
71 {
72 int i=0;
73
74 xassert(buffer);
75
76 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
77 if (!stats) {
78 packdouble(0, buffer);
79
80 pack64(0, buffer);
81
82 for (i=0; i<16; i++) {
83 packnull(buffer);
84 }
85 return;
86 }
87
88 packdouble(stats->act_cpufreq, buffer);
89
90 pack64(stats->consumed_energy, buffer);
91
92 packstr(stats->tres_usage_in_ave, buffer);
93 packstr(stats->tres_usage_in_max, buffer);
94 packstr(stats->tres_usage_in_max_nodeid, buffer);
95 packstr(stats->tres_usage_in_max_taskid, buffer);
96 packstr(stats->tres_usage_in_min, buffer);
97 packstr(stats->tres_usage_in_min_nodeid, buffer);
98 packstr(stats->tres_usage_in_min_taskid, buffer);
99 packstr(stats->tres_usage_in_tot, buffer);
100 packstr(stats->tres_usage_out_ave, buffer);
101 packstr(stats->tres_usage_out_max, buffer);
102 packstr(stats->tres_usage_out_max_nodeid, buffer);
103 packstr(stats->tres_usage_out_max_taskid, buffer);
104 packstr(stats->tres_usage_out_min, buffer);
105 packstr(stats->tres_usage_out_min_nodeid, buffer);
106 packstr(stats->tres_usage_out_min_taskid, buffer);
107 packstr(stats->tres_usage_out_tot, buffer);
108 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
109 if (!stats) {
110 packdouble(0, buffer);
111
112 pack64(0, buffer);
113
114 for (i=0; i<16; i++) {
115 packnull(buffer);
116 }
117 return;
118 }
119
120 packdouble(stats->act_cpufreq, buffer);
121
122 pack64(stats->consumed_energy, buffer);
123
124 packstr(stats->tres_usage_in_ave, buffer);
125 packstr(stats->tres_usage_in_max, buffer);
126 packstr(stats->tres_usage_in_max_nodeid, buffer);
127 packstr(stats->tres_usage_in_max_taskid, buffer);
128 packstr(stats->tres_usage_in_min, buffer);
129 packstr(stats->tres_usage_in_min_nodeid, buffer);
130 packstr(stats->tres_usage_in_min_taskid, buffer);
131 packstr(stats->tres_usage_in_tot, buffer);
132 packstr(stats->tres_usage_out_ave, buffer);
133 packstr(stats->tres_usage_out_max, buffer);
134 packstr(stats->tres_usage_out_max_nodeid, buffer);
135 packstr(stats->tres_usage_out_max_taskid, buffer);
136 packstr(stats->tres_usage_out_min, buffer);
137 packstr(stats->tres_usage_out_min_nodeid, buffer);
138 packstr(stats->tres_usage_out_min_taskid, buffer);
139 packstr(stats->tres_usage_out_tot, buffer);
140 } else {
141 error("%s: protocol_version %hu not supported",
142 __func__, protocol_version);
143 }
144 }
145
_unpack_slurmdb_stats(slurmdb_stats_t * stats,uint16_t protocol_version,Buf buffer)146 static int _unpack_slurmdb_stats(slurmdb_stats_t *stats,
147 uint16_t protocol_version, Buf buffer)
148 {
149 uint32_t uint32_tmp;
150
151 xassert(stats);
152 xassert(buffer);
153
154 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
155 safe_unpackdouble(&stats->act_cpufreq, buffer);
156
157 safe_unpack64(&stats->consumed_energy, buffer);
158
159 safe_unpackstr_xmalloc(&stats->tres_usage_in_ave,
160 &uint32_tmp, buffer);
161 safe_unpackstr_xmalloc(&stats->tres_usage_in_max,
162 &uint32_tmp, buffer);
163 safe_unpackstr_xmalloc(&stats->tres_usage_in_max_nodeid,
164 &uint32_tmp, buffer);
165 safe_unpackstr_xmalloc(&stats->tres_usage_in_max_taskid,
166 &uint32_tmp, buffer);
167 safe_unpackstr_xmalloc(&stats->tres_usage_in_min,
168 &uint32_tmp, buffer);
169 safe_unpackstr_xmalloc(&stats->tres_usage_in_min_nodeid,
170 &uint32_tmp, buffer);
171 safe_unpackstr_xmalloc(&stats->tres_usage_in_min_taskid,
172 &uint32_tmp, buffer);
173 safe_unpackstr_xmalloc(&stats->tres_usage_in_tot,
174 &uint32_tmp, buffer);
175 safe_unpackstr_xmalloc(&stats->tres_usage_out_ave,
176 &uint32_tmp, buffer);
177 safe_unpackstr_xmalloc(&stats->tres_usage_out_max,
178 &uint32_tmp, buffer);
179 safe_unpackstr_xmalloc(&stats->tres_usage_out_max_nodeid,
180 &uint32_tmp, buffer);
181 safe_unpackstr_xmalloc(&stats->tres_usage_out_max_taskid,
182 &uint32_tmp, buffer);
183 safe_unpackstr_xmalloc(&stats->tres_usage_out_min,
184 &uint32_tmp, buffer);
185 safe_unpackstr_xmalloc(&stats->tres_usage_out_min_nodeid,
186 &uint32_tmp, buffer);
187 safe_unpackstr_xmalloc(&stats->tres_usage_out_min_taskid,
188 &uint32_tmp, buffer);
189 safe_unpackstr_xmalloc(&stats->tres_usage_out_tot,
190 &uint32_tmp, buffer);
191 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
192 safe_unpackdouble(&stats->act_cpufreq, buffer);
193
194 safe_unpack64(&stats->consumed_energy, buffer);
195
196 safe_unpackstr_xmalloc(&stats->tres_usage_in_ave,
197 &uint32_tmp, buffer);
198 safe_unpackstr_xmalloc(&stats->tres_usage_in_max,
199 &uint32_tmp, buffer);
200 safe_unpackstr_xmalloc(&stats->tres_usage_in_max_nodeid,
201 &uint32_tmp, buffer);
202 safe_unpackstr_xmalloc(&stats->tres_usage_in_max_taskid,
203 &uint32_tmp, buffer);
204 safe_unpackstr_xmalloc(&stats->tres_usage_in_min,
205 &uint32_tmp, buffer);
206 safe_unpackstr_xmalloc(&stats->tres_usage_in_min_nodeid,
207 &uint32_tmp, buffer);
208 safe_unpackstr_xmalloc(&stats->tres_usage_in_min_taskid,
209 &uint32_tmp, buffer);
210 safe_unpackstr_xmalloc(&stats->tres_usage_in_tot,
211 &uint32_tmp, buffer);
212 safe_unpackstr_xmalloc(&stats->tres_usage_out_ave,
213 &uint32_tmp, buffer);
214 safe_unpackstr_xmalloc(&stats->tres_usage_out_max,
215 &uint32_tmp, buffer);
216 safe_unpackstr_xmalloc(&stats->tres_usage_out_max_nodeid,
217 &uint32_tmp, buffer);
218 safe_unpackstr_xmalloc(&stats->tres_usage_out_max_taskid,
219 &uint32_tmp, buffer);
220 safe_unpackstr_xmalloc(&stats->tres_usage_out_min,
221 &uint32_tmp, buffer);
222 safe_unpackstr_xmalloc(&stats->tres_usage_out_min_nodeid,
223 &uint32_tmp, buffer);
224 safe_unpackstr_xmalloc(&stats->tres_usage_out_min_taskid,
225 &uint32_tmp, buffer);
226 safe_unpackstr_xmalloc(&stats->tres_usage_out_tot,
227 &uint32_tmp, buffer);
228 } else {
229 error("%s: protocol_version %hu not supported",
230 __func__, protocol_version);
231 goto unpack_error;
232 }
233
234 return SLURM_SUCCESS;
235
236 unpack_error:
237 memset(stats, 0, sizeof(slurmdb_stats_t));
238 return SLURM_ERROR;
239 }
240
241
slurmdb_pack_user_rec(void * in,uint16_t protocol_version,Buf buffer)242 extern void slurmdb_pack_user_rec(void *in, uint16_t protocol_version,
243 Buf buffer)
244 {
245 slurmdb_user_rec_t *object = (slurmdb_user_rec_t *)in;
246
247 xassert(buffer);
248
249 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
250 if (!object) {
251 pack16(0, buffer);
252 pack32(NO_VAL, buffer);
253 pack32(NO_VAL, buffer);
254 packnull(buffer);
255 packnull(buffer);
256 packnull(buffer);
257 packnull(buffer);
258 pack32(0, buffer);
259 pack32(NO_VAL, buffer);
260 return;
261 }
262
263 pack16(object->admin_level, buffer);
264
265 slurm_pack_list(object->assoc_list, slurmdb_pack_assoc_rec,
266 buffer, protocol_version);
267
268 slurm_pack_list(object->coord_accts, slurmdb_pack_coord_rec,
269 buffer, protocol_version);
270
271 packstr(object->default_acct, buffer);
272 packstr(object->default_wckey, buffer);
273 packstr(object->name, buffer);
274 packstr(object->old_name, buffer);
275
276 pack32(object->uid, buffer);
277
278 slurm_pack_list(object->wckey_list, slurmdb_pack_wckey_rec,
279 buffer, protocol_version);
280 } else {
281 error("%s: protocol_version %hu not supported",
282 __func__, protocol_version);
283 }
284 }
285
slurmdb_unpack_user_rec(void ** object,uint16_t protocol_version,Buf buffer)286 extern int slurmdb_unpack_user_rec(void **object, uint16_t protocol_version,
287 Buf buffer)
288 {
289 uint32_t uint32_tmp;
290 slurmdb_user_rec_t *object_ptr = xmalloc(sizeof(slurmdb_user_rec_t));
291 uint32_t count = NO_VAL;
292 slurmdb_coord_rec_t *coord = NULL;
293 slurmdb_assoc_rec_t *assoc = NULL;
294 slurmdb_wckey_rec_t *wckey = NULL;
295 int i;
296
297 xassert(object);
298 xassert(buffer);
299
300 *object = object_ptr;
301
302 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
303 safe_unpack16(&object_ptr->admin_level, buffer);
304 safe_unpack32(&count, buffer);
305 if (count > NO_VAL)
306 goto unpack_error;
307 if (count != NO_VAL) {
308 object_ptr->assoc_list =
309 list_create(slurmdb_destroy_assoc_rec);
310 for (i = 0; i < count; i++) {
311 if (slurmdb_unpack_assoc_rec(
312 (void *)&assoc, protocol_version,
313 buffer)
314 == SLURM_ERROR)
315 goto unpack_error;
316 list_append(object_ptr->assoc_list, assoc);
317 }
318 }
319 safe_unpack32(&count, buffer);
320 if (count > NO_VAL)
321 goto unpack_error;
322 if (count != NO_VAL) {
323 object_ptr->coord_accts =
324 list_create(slurmdb_destroy_coord_rec);
325 for (i = 0; i < count; i++) {
326 if (slurmdb_unpack_coord_rec(
327 (void *)&coord, protocol_version,
328 buffer)
329 == SLURM_ERROR)
330 goto unpack_error;
331 list_append(object_ptr->coord_accts, coord);
332 }
333 }
334 safe_unpackstr_xmalloc(&object_ptr->default_acct, &uint32_tmp,
335 buffer);
336 safe_unpackstr_xmalloc(&object_ptr->default_wckey, &uint32_tmp,
337 buffer);
338 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
339 safe_unpackstr_xmalloc(&object_ptr->old_name,
340 &uint32_tmp, buffer);
341 safe_unpack32(&object_ptr->uid, buffer);
342 safe_unpack32(&count, buffer);
343 if (count > NO_VAL)
344 goto unpack_error;
345 if (count != NO_VAL) {
346 object_ptr->wckey_list =
347 list_create(slurmdb_destroy_wckey_rec);
348 for (i = 0; i < count; i++) {
349 if (slurmdb_unpack_wckey_rec(
350 (void *)&wckey, protocol_version,
351 buffer)
352 == SLURM_ERROR)
353 goto unpack_error;
354 list_append(object_ptr->wckey_list, wckey);
355 }
356 }
357
358 } else {
359 error("%s: protocol_version %hu not supported",
360 __func__, protocol_version);
361 goto unpack_error;
362 }
363
364 return SLURM_SUCCESS;
365
366 unpack_error:
367 slurmdb_destroy_user_rec(object_ptr);
368 *object = NULL;
369 return SLURM_ERROR;
370 }
371
slurmdb_pack_used_limits(void * in,uint32_t tres_cnt,uint16_t protocol_version,Buf buffer)372 extern void slurmdb_pack_used_limits(void *in, uint32_t tres_cnt,
373 uint16_t protocol_version, Buf buffer)
374 {
375 slurmdb_used_limits_t *object = (slurmdb_used_limits_t *)in;
376
377 xassert(buffer);
378
379 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
380 if (!object) {
381 pack32(0, buffer);
382 packnull(buffer);
383 pack32(0, buffer);
384 pack32(0, buffer);
385 pack64_array(NULL, 0, buffer);
386 pack64_array(NULL, 0, buffer);
387 pack32(0, buffer);
388 return;
389 }
390
391 pack32(object->accrue_cnt, buffer);
392 packstr(object->acct, buffer);
393 pack32(object->jobs, buffer);
394 pack32(object->submit_jobs, buffer);
395 pack64_array(object->tres, tres_cnt, buffer);
396 pack64_array(object->tres_run_mins, tres_cnt, buffer);
397 pack32(object->uid, buffer);
398 } else {
399 error("%s: protocol_version %hu not supported",
400 __func__, protocol_version);
401 }
402 }
403
slurmdb_unpack_used_limits(void ** object,uint32_t tres_cnt,uint16_t protocol_version,Buf buffer)404 extern int slurmdb_unpack_used_limits(void **object, uint32_t tres_cnt,
405 uint16_t protocol_version, Buf buffer)
406 {
407 slurmdb_used_limits_t *object_ptr =
408 xmalloc(sizeof(slurmdb_used_limits_t));
409 uint32_t tmp32;
410
411 xassert(object);
412 xassert(buffer);
413
414 *object = (void *)object_ptr;
415
416 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
417 safe_unpack32(&object_ptr->accrue_cnt, buffer);
418 safe_unpackstr_xmalloc(&object_ptr->acct, &tmp32, buffer);
419 safe_unpack32(&object_ptr->jobs, buffer);
420 safe_unpack32(&object_ptr->submit_jobs, buffer);
421 safe_unpack64_array(&object_ptr->tres, &tmp32, buffer);
422 if (tmp32 != tres_cnt)
423 goto unpack_error;
424 safe_unpack64_array(&object_ptr->tres_run_mins, &tmp32, buffer);
425 if (tmp32 != tres_cnt)
426 goto unpack_error;
427
428 safe_unpack32(&object_ptr->uid, buffer);
429 } else {
430 error("%s: too old of a version %u", __func__, protocol_version);
431 goto unpack_error;
432 }
433
434 return SLURM_SUCCESS;
435
436 unpack_error:
437 slurmdb_destroy_used_limits(object_ptr);
438 *object = NULL;
439 return SLURM_ERROR;
440 }
441
slurmdb_pack_account_rec(void * in,uint16_t protocol_version,Buf buffer)442 extern void slurmdb_pack_account_rec(void *in, uint16_t protocol_version,
443 Buf buffer)
444 {
445 slurmdb_account_rec_t *object = (slurmdb_account_rec_t *)in;
446
447 xassert(buffer);
448
449 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
450 if (!object) {
451 pack32(NO_VAL, buffer);
452 pack32(NO_VAL, buffer);
453 packnull(buffer);
454 packnull(buffer);
455 packnull(buffer);
456 return;
457 }
458
459 slurm_pack_list(object->assoc_list, slurmdb_pack_assoc_rec,
460 buffer, protocol_version);
461 slurm_pack_list(object->coordinators, slurmdb_pack_coord_rec,
462 buffer, protocol_version);
463
464 packstr(object->description, buffer);
465 packstr(object->name, buffer);
466 packstr(object->organization, buffer);
467 } else {
468 error("%s: protocol_version %hu not supported",
469 __func__, protocol_version);
470 }
471 }
472
slurmdb_unpack_account_rec(void ** object,uint16_t protocol_version,Buf buffer)473 extern int slurmdb_unpack_account_rec(void **object, uint16_t protocol_version,
474 Buf buffer)
475 {
476 uint32_t uint32_tmp;
477 int i;
478 uint32_t count;
479 slurmdb_coord_rec_t *coord = NULL;
480 slurmdb_assoc_rec_t *assoc = NULL;
481 slurmdb_account_rec_t *object_ptr =
482 xmalloc(sizeof(slurmdb_account_rec_t));
483
484 xassert(object);
485 xassert(buffer);
486
487 *object = object_ptr;
488
489 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
490 safe_unpack32(&count, buffer);
491 if (count != NO_VAL) {
492 object_ptr->assoc_list =
493 list_create(slurmdb_destroy_assoc_rec);
494 for(i=0; i<count; i++) {
495 if (slurmdb_unpack_assoc_rec(
496 (void *)&assoc, protocol_version,
497 buffer)
498 == SLURM_ERROR)
499 goto unpack_error;
500 list_append(object_ptr->assoc_list, assoc);
501 }
502 }
503 safe_unpack32(&count, buffer);
504 if (count != NO_VAL) {
505 object_ptr->coordinators =
506 list_create(slurmdb_destroy_coord_rec);
507 for(i=0; i<count; i++) {
508 if (slurmdb_unpack_coord_rec(
509 (void *)&coord, protocol_version,
510 buffer)
511 == SLURM_ERROR)
512 goto unpack_error;
513 list_append(object_ptr->coordinators, coord);
514 }
515 }
516 safe_unpackstr_xmalloc(&object_ptr->description,
517 &uint32_tmp, buffer);
518 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
519 safe_unpackstr_xmalloc(&object_ptr->organization,
520 &uint32_tmp, buffer);
521 } else {
522 error("%s: protocol_version %hu not supported",
523 __func__, protocol_version);
524 goto unpack_error;
525 }
526
527 return SLURM_SUCCESS;
528
529 unpack_error:
530 slurmdb_destroy_account_rec(object_ptr);
531 *object = NULL;
532 return SLURM_ERROR;
533 }
534
slurmdb_pack_coord_rec(void * in,uint16_t protocol_version,Buf buffer)535 extern void slurmdb_pack_coord_rec(void *in, uint16_t protocol_version,
536 Buf buffer)
537 {
538 slurmdb_coord_rec_t *object = (slurmdb_coord_rec_t *)in;
539
540 xassert(buffer);
541
542 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
543 if (!object) {
544 packnull(buffer);
545 pack16(0, buffer);
546 return;
547 }
548
549 packstr(object->name, buffer);
550 pack16(object->direct, buffer);
551 } else {
552 error("%s: protocol_version %hu not supported",
553 __func__, protocol_version);
554 }
555 }
556
slurmdb_unpack_coord_rec(void ** object,uint16_t protocol_version,Buf buffer)557 extern int slurmdb_unpack_coord_rec(void **object, uint16_t protocol_version,
558 Buf buffer)
559 {
560 uint32_t uint32_tmp;
561 slurmdb_coord_rec_t *object_ptr = xmalloc(sizeof(slurmdb_coord_rec_t));
562
563 xassert(object);
564 xassert(buffer);
565
566 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
567 *object = object_ptr;
568 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
569 safe_unpack16(&object_ptr->direct, buffer);
570 } else {
571 error("%s: protocol_version %hu not supported",
572 __func__, protocol_version);
573 goto unpack_error;
574 }
575
576 return SLURM_SUCCESS;
577
578 unpack_error:
579 slurmdb_destroy_coord_rec(object_ptr);
580 *object = NULL;
581 return SLURM_ERROR;
582 }
583
slurmdb_pack_cluster_accounting_rec(void * in,uint16_t protocol_version,Buf buffer)584 extern void slurmdb_pack_cluster_accounting_rec(void *in,
585 uint16_t protocol_version,
586 Buf buffer)
587 {
588 slurmdb_cluster_accounting_rec_t *object =
589 (slurmdb_cluster_accounting_rec_t *)in;
590
591 xassert(buffer);
592
593 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
594 if (!object) {
595 pack64(0, buffer);
596 slurmdb_pack_tres_rec(NULL, protocol_version, buffer);
597 pack64(0, buffer);
598 pack64(0, buffer);
599 pack64(0, buffer);
600 pack64(0, buffer);
601 pack64(0, buffer);
602 pack_time(0, buffer);
603 pack64(0, buffer);
604 return;
605 }
606
607 pack64(object->alloc_secs, buffer);
608 slurmdb_pack_tres_rec(&object->tres_rec, protocol_version,
609 buffer);
610 pack64(object->down_secs, buffer);
611 pack64(object->idle_secs, buffer);
612 pack64(object->over_secs, buffer);
613 pack64(object->pdown_secs, buffer);
614 pack_time(object->period_start, buffer);
615 pack64(object->resv_secs, buffer);
616 } else {
617 error("%s: protocol_version %hu not supported",
618 __func__, protocol_version);
619 }
620 }
621
slurmdb_unpack_cluster_accounting_rec(void ** object,uint16_t protocol_version,Buf buffer)622 extern int slurmdb_unpack_cluster_accounting_rec(void **object,
623 uint16_t protocol_version,
624 Buf buffer)
625 {
626 slurmdb_cluster_accounting_rec_t *object_ptr =
627 xmalloc(sizeof(slurmdb_cluster_accounting_rec_t));
628
629 xassert(object);
630 xassert(buffer);
631
632 *object = object_ptr;
633
634 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
635 safe_unpack64(&object_ptr->alloc_secs, buffer);
636 if (slurmdb_unpack_tres_rec_noalloc(
637 &object_ptr->tres_rec, protocol_version, buffer)
638 != SLURM_SUCCESS)
639 goto unpack_error;
640 safe_unpack64(&object_ptr->down_secs, buffer);
641 safe_unpack64(&object_ptr->idle_secs, buffer);
642 safe_unpack64(&object_ptr->over_secs, buffer);
643 safe_unpack64(&object_ptr->pdown_secs, buffer);
644 safe_unpack_time(&object_ptr->period_start, buffer);
645 safe_unpack64(&object_ptr->resv_secs, buffer);
646 } else {
647 error("%s: protocol_version %hu not supported",
648 __func__, protocol_version);
649 goto unpack_error;
650 }
651
652 return SLURM_SUCCESS;
653
654 unpack_error:
655 slurmdb_destroy_cluster_accounting_rec(object_ptr);
656 *object = NULL;
657 return SLURM_ERROR;
658 }
659
slurmdb_pack_clus_res_rec(void * in,uint16_t protocol_version,Buf buffer)660 extern void slurmdb_pack_clus_res_rec(void *in, uint16_t protocol_version,
661 Buf buffer)
662 {
663 slurmdb_clus_res_rec_t *object = (slurmdb_clus_res_rec_t *)in;
664
665 xassert(buffer);
666
667 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
668 if (!object) {
669 packnull(buffer);
670 pack16(NO_VAL16, buffer);
671 return;
672 }
673 packstr(object->cluster, buffer);
674 pack16(object->percent_allowed, buffer);
675 } else {
676 error("%s: protocol_version %hu not supported",
677 __func__, protocol_version);
678 }
679 }
680
slurmdb_unpack_clus_res_rec(void ** object,uint16_t protocol_version,Buf buffer)681 extern int slurmdb_unpack_clus_res_rec(void **object, uint16_t protocol_version,
682 Buf buffer)
683 {
684 uint32_t uint32_tmp;
685 slurmdb_clus_res_rec_t *object_ptr =
686 xmalloc(sizeof(slurmdb_clus_res_rec_t));
687
688 xassert(object);
689 xassert(buffer);
690
691 *object = object_ptr;
692
693 slurmdb_init_clus_res_rec(object_ptr, 0);
694
695 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
696 safe_unpackstr_xmalloc(&object_ptr->cluster, &uint32_tmp,
697 buffer);
698 safe_unpack16(&object_ptr->percent_allowed, buffer);
699 } else {
700 error("%s: protocol_version %hu not supported",
701 __func__, protocol_version);
702 goto unpack_error;
703 }
704
705 return SLURM_SUCCESS;
706
707 unpack_error:
708 slurmdb_destroy_clus_res_rec(object_ptr);
709 *object = NULL;
710 return SLURM_ERROR;
711 }
712
slurmdb_pack_cluster_rec(void * in,uint16_t protocol_version,Buf buffer)713 extern void slurmdb_pack_cluster_rec(void *in, uint16_t protocol_version,
714 Buf buffer)
715 {
716 slurmdb_cluster_rec_t *object = (slurmdb_cluster_rec_t *)in;
717 slurm_persist_conn_t *persist_conn;
718
719 if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
720 if (!object) {
721 pack32(NO_VAL, buffer); /* count */
722 pack16(0, buffer);
723 packnull(buffer);
724 pack32(0, buffer);
725 pack16(1, buffer);
726
727 pack32(NO_VAL, buffer); /* count */
728 packnull(buffer);
729 pack32(0, buffer);
730 pack32(0, buffer);
731 pack8(0, buffer);
732 pack8(0, buffer);
733
734 pack32(NO_VAL, buffer); /* flags */
735
736 packnull(buffer);
737 packnull(buffer);
738
739 pack32(NO_VAL, buffer); /* plugin_id_select */
740
741 slurmdb_pack_assoc_rec(NULL, protocol_version, buffer);
742
743 pack16(0, buffer);
744 pack8(0, buffer);
745 pack8(0, buffer);
746 packnull(buffer);
747 return;
748 }
749
750 slurm_pack_list(object->accounting_list,
751 slurmdb_pack_cluster_accounting_rec,
752 buffer, protocol_version);
753
754 pack16(object->classification, buffer);
755 packstr(object->control_host, buffer);
756 pack32(object->control_port, buffer);
757 pack16(object->dimensions, buffer);
758
759 _pack_list_of_str(object->fed.feature_list, buffer);
760
761 packstr(object->fed.name, buffer);
762 pack32(object->fed.id, buffer);
763 pack32(object->fed.state, buffer);
764 pack8((uint8_t)object->fed.sync_recvd, buffer);
765 pack8((uint8_t)object->fed.sync_sent, buffer);
766
767 pack32(object->flags, buffer);
768
769 packstr(object->name, buffer);
770 packstr(object->nodes, buffer);
771
772 pack32(object->plugin_id_select, buffer);
773
774 slurmdb_pack_assoc_rec(object->root_assoc,
775 protocol_version, buffer);
776
777 pack16(object->rpc_version, buffer);
778 persist_conn = object->fed.recv;
779 pack8((persist_conn && persist_conn->fd != -1) ? 1 : 0, buffer);
780 persist_conn = object->fed.send;
781 pack8((persist_conn && persist_conn->fd != -1) ? 1 : 0, buffer);
782 packstr(object->tres_str, buffer);
783 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
784 if (!object) {
785 pack32(NO_VAL, buffer);
786 pack16(0, buffer);
787 packnull(buffer);
788 pack32(0, buffer);
789 pack16(1, buffer);
790
791 pack32(NO_VAL, buffer);
792 packnull(buffer);
793 pack32(0, buffer);
794 pack32(0, buffer);
795
796 pack32(NO_VAL, buffer);
797
798 packnull(buffer);
799 packnull(buffer);
800
801 pack32(NO_VAL, buffer);
802
803 slurmdb_pack_assoc_rec(NULL, protocol_version, buffer);
804
805 pack16(0, buffer);
806 pack8(0, buffer);
807 pack8(0, buffer);
808 packnull(buffer);
809 return;
810 }
811
812 slurm_pack_list(object->accounting_list,
813 slurmdb_pack_cluster_accounting_rec,
814 buffer, protocol_version);
815
816 pack16(object->classification, buffer);
817 packstr(object->control_host, buffer);
818 pack32(object->control_port, buffer);
819 pack16(object->dimensions, buffer);
820
821 _pack_list_of_str(object->fed.feature_list, buffer);
822
823 packstr(object->fed.name, buffer);
824 pack32(object->fed.id, buffer);
825 pack32(object->fed.state, buffer);
826
827 pack32(object->flags, buffer);
828
829 packstr(object->name, buffer);
830 packstr(object->nodes, buffer);
831
832 pack32(object->plugin_id_select, buffer);
833
834 slurmdb_pack_assoc_rec(object->root_assoc,
835 protocol_version, buffer);
836
837 pack16(object->rpc_version, buffer);
838 persist_conn = object->fed.recv;
839 pack8((persist_conn && persist_conn->fd != -1) ? 1 : 0, buffer);
840 persist_conn = object->fed.send;
841 pack8((persist_conn && persist_conn->fd != -1) ? 1 : 0, buffer);
842 packstr(object->tres_str, buffer);
843 } else {
844 error("%s: protocol_version %hu not supported",
845 __func__, protocol_version);
846 }
847 }
848
slurmdb_unpack_cluster_rec(void ** object,uint16_t protocol_version,Buf buffer)849 extern int slurmdb_unpack_cluster_rec(void **object, uint16_t protocol_version,
850 Buf buffer)
851 {
852 uint32_t uint32_tmp;
853 uint8_t uint8_tmp;
854 int i;
855 uint32_t count;
856 slurmdb_cluster_rec_t *object_ptr =
857 xmalloc(sizeof(slurmdb_cluster_rec_t));
858 slurmdb_cluster_accounting_rec_t *slurmdb_info = NULL;
859 slurm_persist_conn_t *conn;
860
861 *object = object_ptr;
862
863 slurmdb_init_cluster_rec(object_ptr, 0);
864 if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
865 safe_unpack32(&count, buffer);
866 if (count > NO_VAL)
867 goto unpack_error;
868 if (count != NO_VAL) {
869 object_ptr->accounting_list = list_create(
870 slurmdb_destroy_cluster_accounting_rec);
871 for (i = 0; i < count; i++) {
872 if (slurmdb_unpack_cluster_accounting_rec(
873 (void *)&slurmdb_info,
874 protocol_version, buffer) ==
875 SLURM_ERROR)
876 goto unpack_error;
877 list_append(object_ptr->accounting_list,
878 slurmdb_info);
879 }
880 }
881
882 safe_unpack16(&object_ptr->classification, buffer);
883 safe_unpackstr_xmalloc(&object_ptr->control_host,
884 &uint32_tmp, buffer);
885 safe_unpack32(&object_ptr->control_port, buffer);
886 safe_unpack16(&object_ptr->dimensions, buffer);
887
888 safe_unpack32(&count, buffer);
889 if (count > NO_VAL)
890 goto unpack_error;
891 if (count != NO_VAL) {
892 object_ptr->fed.feature_list = list_create(xfree_ptr);
893 for (i = 0; i < count; i++) {
894 char *tmp_feature = NULL;
895 safe_unpackstr_xmalloc(&tmp_feature,
896 &uint32_tmp, buffer);
897 list_append(object_ptr->fed.feature_list,
898 tmp_feature);
899 }
900 }
901 safe_unpackstr_xmalloc(&object_ptr->fed.name,
902 &uint32_tmp, buffer);
903 safe_unpack32(&object_ptr->fed.id, buffer);
904 safe_unpack32(&object_ptr->fed.state, buffer);
905 safe_unpack8(&uint8_tmp, buffer);
906 object_ptr->fed.sync_recvd = uint8_tmp;
907 safe_unpack8(&uint8_tmp, buffer);
908 object_ptr->fed.sync_sent = uint8_tmp;
909
910 safe_unpack32(&object_ptr->flags, buffer);
911
912 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
913 safe_unpackstr_xmalloc(&object_ptr->nodes, &uint32_tmp, buffer);
914
915 safe_unpack32(&object_ptr->plugin_id_select, buffer);
916
917 if (slurmdb_unpack_assoc_rec(
918 (void **)&object_ptr->root_assoc,
919 protocol_version, buffer)
920 == SLURM_ERROR)
921 goto unpack_error;
922
923 safe_unpack16(&object_ptr->rpc_version, buffer);
924 safe_unpack8(&uint8_tmp, buffer);
925 if (uint8_tmp) {
926 conn = xmalloc(sizeof(slurm_persist_conn_t));
927 conn->fd = -1;
928 object_ptr->fed.recv = conn;
929 }
930 safe_unpack8(&uint8_tmp, buffer);
931 if (uint8_tmp) {
932 conn = xmalloc(sizeof(slurm_persist_conn_t));
933 conn->fd = -1;
934 object_ptr->fed.send = conn;
935 }
936 safe_unpackstr_xmalloc(&object_ptr->tres_str,
937 &uint32_tmp, buffer);
938 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
939 safe_unpack32(&count, buffer);
940 if (count > NO_VAL)
941 goto unpack_error;
942 if (count != NO_VAL) {
943 object_ptr->accounting_list = list_create(
944 slurmdb_destroy_cluster_accounting_rec);
945 for (i = 0; i < count; i++) {
946 if (slurmdb_unpack_cluster_accounting_rec(
947 (void *)&slurmdb_info,
948 protocol_version, buffer) ==
949 SLURM_ERROR)
950 goto unpack_error;
951 list_append(object_ptr->accounting_list,
952 slurmdb_info);
953 }
954 }
955
956 safe_unpack16(&object_ptr->classification, buffer);
957 safe_unpackstr_xmalloc(&object_ptr->control_host,
958 &uint32_tmp, buffer);
959 safe_unpack32(&object_ptr->control_port, buffer);
960 safe_unpack16(&object_ptr->dimensions, buffer);
961
962 safe_unpack32(&count, buffer);
963 if (count > NO_VAL)
964 goto unpack_error;
965 if (count != NO_VAL) {
966 object_ptr->fed.feature_list = list_create(xfree_ptr);
967 for (i = 0; i < count; i++) {
968 char *tmp_feature = NULL;
969 safe_unpackstr_xmalloc(&tmp_feature,
970 &uint32_tmp, buffer);
971 list_append(object_ptr->fed.feature_list,
972 tmp_feature);
973 }
974 }
975 safe_unpackstr_xmalloc(&object_ptr->fed.name,
976 &uint32_tmp, buffer);
977 safe_unpack32(&object_ptr->fed.id, buffer);
978 safe_unpack32(&object_ptr->fed.state, buffer);
979
980 safe_unpack32(&object_ptr->flags, buffer);
981
982 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
983 safe_unpackstr_xmalloc(&object_ptr->nodes, &uint32_tmp, buffer);
984
985 safe_unpack32(&object_ptr->plugin_id_select, buffer);
986
987 if (slurmdb_unpack_assoc_rec(
988 (void **)&object_ptr->root_assoc,
989 protocol_version, buffer)
990 == SLURM_ERROR)
991 goto unpack_error;
992
993 safe_unpack16(&object_ptr->rpc_version, buffer);
994 safe_unpack8(&uint8_tmp, buffer);
995 if (uint8_tmp) {
996 conn = xmalloc(sizeof(slurm_persist_conn_t));
997 conn->fd = -1;
998 object_ptr->fed.recv = conn;
999 }
1000 safe_unpack8(&uint8_tmp, buffer);
1001 if (uint8_tmp) {
1002 conn = xmalloc(sizeof(slurm_persist_conn_t));
1003 conn->fd = -1;
1004 object_ptr->fed.send = conn;
1005 }
1006 safe_unpackstr_xmalloc(&object_ptr->tres_str,
1007 &uint32_tmp, buffer);
1008 } else {
1009 error("%s: protocol_version %hu not supported",
1010 __func__, protocol_version);
1011 goto unpack_error;
1012 }
1013
1014 /* Take the lower of the remote cluster is using and what I am or I
1015 * won't be able to talk to the remote cluster. domo arigato. */
1016 object_ptr->rpc_version = MIN(SLURM_PROTOCOL_VERSION,
1017 object_ptr->rpc_version);
1018
1019 return SLURM_SUCCESS;
1020
1021 unpack_error:
1022 slurmdb_destroy_cluster_rec(object_ptr);
1023 *object = NULL;
1024 return SLURM_ERROR;
1025 }
1026
slurmdb_pack_federation_rec(void * in,uint16_t protocol_version,Buf buffer)1027 extern void slurmdb_pack_federation_rec(void *in, uint16_t protocol_version,
1028 Buf buffer)
1029 {
1030 slurmdb_federation_rec_t *object = (slurmdb_federation_rec_t *)in;
1031
1032 xassert(buffer);
1033
1034 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1035 if (!object) {
1036 pack8(0, buffer); /* NULL */
1037 return;
1038 }
1039 pack8(1, buffer); /* Not NULL */
1040 packstr(object->name, buffer);
1041 pack32(object->flags, buffer);
1042
1043 slurm_pack_list(object->cluster_list, slurmdb_pack_cluster_rec,
1044 buffer, protocol_version);
1045 } else {
1046 error("%s: protocol_version %hu not supported.",
1047 __func__, protocol_version);
1048 }
1049 }
1050
slurmdb_unpack_federation_rec(void ** object,uint16_t protocol_version,Buf buffer)1051 extern int slurmdb_unpack_federation_rec(void **object,
1052 uint16_t protocol_version, Buf buffer)
1053 {
1054 uint8_t uint8_tmp;
1055 uint32_t uint32_tmp;
1056 uint32_t count;
1057 int i;
1058 slurmdb_cluster_rec_t *tmp_cluster = NULL;
1059 slurmdb_federation_rec_t *object_ptr = NULL;
1060
1061 xassert(object);
1062 xassert(buffer);
1063
1064 *object = NULL;
1065
1066 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1067 safe_unpack8(&uint8_tmp, buffer);
1068 if (!uint8_tmp) /* NULL fed_rec */
1069 return SLURM_SUCCESS;
1070
1071 object_ptr = xmalloc(sizeof(slurmdb_federation_rec_t));
1072 slurmdb_init_federation_rec(object_ptr, 0);
1073 *object = object_ptr;
1074
1075 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
1076 safe_unpack32(&object_ptr->flags, buffer);
1077
1078 safe_unpack32(&count, buffer);
1079 if (count != NO_VAL) {
1080 object_ptr->cluster_list =
1081 list_create(slurmdb_destroy_cluster_rec);
1082 for(i = 0; i < count; i++) {
1083 if (slurmdb_unpack_cluster_rec(
1084 (void **)&tmp_cluster,
1085 protocol_version, buffer)
1086 != SLURM_SUCCESS) {
1087 error("unpacking cluster_rec");
1088 goto unpack_error;
1089 }
1090 list_append(object_ptr->cluster_list,
1091 tmp_cluster);
1092 }
1093 }
1094 } else {
1095 error("%s: protocol_version %hu is not supported.",
1096 __func__, protocol_version);
1097 goto unpack_error;
1098 }
1099
1100 return SLURM_SUCCESS;
1101
1102 unpack_error:
1103 slurmdb_destroy_federation_rec(object_ptr);
1104 *object = NULL;
1105 return SLURM_ERROR;
1106 }
1107
slurmdb_pack_accounting_rec(void * in,uint16_t protocol_version,Buf buffer)1108 extern void slurmdb_pack_accounting_rec(void *in, uint16_t protocol_version,
1109 Buf buffer)
1110 {
1111 slurmdb_accounting_rec_t *object = (slurmdb_accounting_rec_t *)in;
1112
1113 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1114 if (!object) {
1115 pack64(0, buffer);
1116 slurmdb_pack_tres_rec(NULL, protocol_version, buffer);
1117 pack32(0, buffer);
1118 pack_time(0, buffer);
1119 return;
1120 }
1121
1122 pack64(object->alloc_secs, buffer);
1123 slurmdb_pack_tres_rec(&object->tres_rec,
1124 protocol_version, buffer);
1125 pack32(object->id, buffer);
1126 pack_time(object->period_start, buffer);
1127 } else {
1128 error("%s: protocol_version %hu not supported",
1129 __func__, protocol_version);
1130 }
1131 }
1132
slurmdb_unpack_accounting_rec(void ** object,uint16_t protocol_version,Buf buffer)1133 extern int slurmdb_unpack_accounting_rec(void **object,
1134 uint16_t protocol_version,
1135 Buf buffer)
1136 {
1137 slurmdb_accounting_rec_t *object_ptr =
1138 xmalloc(sizeof(slurmdb_accounting_rec_t));
1139
1140 *object = object_ptr;
1141
1142 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1143 safe_unpack64(&object_ptr->alloc_secs, buffer);
1144 if (slurmdb_unpack_tres_rec_noalloc(
1145 &object_ptr->tres_rec, protocol_version, buffer)
1146 != SLURM_SUCCESS)
1147 goto unpack_error;
1148 safe_unpack32(&object_ptr->id, buffer);
1149 safe_unpack_time(&object_ptr->period_start, buffer);
1150 } else {
1151 error("%s: protocol_version %hu not supported",
1152 __func__, protocol_version);
1153 goto unpack_error;
1154 }
1155
1156 return SLURM_SUCCESS;
1157
1158 unpack_error:
1159 slurmdb_destroy_accounting_rec(object_ptr);
1160 *object = NULL;
1161 return SLURM_ERROR;
1162 }
1163
slurmdb_pack_assoc_rec(void * in,uint16_t protocol_version,Buf buffer)1164 extern void slurmdb_pack_assoc_rec(void *in, uint16_t protocol_version,
1165 Buf buffer)
1166 {
1167 slurmdb_assoc_rec_t *object = (slurmdb_assoc_rec_t *)in;
1168
1169 if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
1170 if (!object) {
1171 pack32(NO_VAL, buffer);
1172 packnull(buffer);
1173 packnull(buffer);
1174
1175 pack32(NO_VAL, buffer);
1176
1177 pack32(NO_VAL, buffer);
1178
1179 packnull(buffer);
1180 packnull(buffer);
1181 packnull(buffer);
1182 pack32(NO_VAL, buffer);
1183 pack32(NO_VAL, buffer);
1184 pack32(NO_VAL, buffer);
1185 pack32(NO_VAL, buffer);
1186
1187 pack32(0, buffer);
1188 pack16(0, buffer);
1189 pack32(0, buffer);
1190
1191 packnull(buffer);
1192 packnull(buffer);
1193 packnull(buffer);
1194 packnull(buffer);
1195 pack32(NO_VAL, buffer);
1196 pack32(NO_VAL, buffer);
1197 pack32(NO_VAL, buffer);
1198 pack32(NO_VAL, buffer);
1199 pack32(NO_VAL, buffer);
1200
1201 packnull(buffer);
1202 pack32(0, buffer);
1203 packnull(buffer);
1204 pack32(0, buffer);
1205
1206 pack32(NO_VAL, buffer);
1207
1208 pack32(0, buffer);
1209 pack32(0, buffer);
1210
1211 packnull(buffer);
1212 return;
1213 }
1214
1215 slurm_pack_list(object->accounting_list,
1216 slurmdb_pack_accounting_rec,
1217 buffer, protocol_version);
1218
1219 packstr(object->acct, buffer);
1220 packstr(object->cluster, buffer);
1221
1222 pack32(object->def_qos_id, buffer);
1223
1224 /* this used to be named fairshare to not have to redo
1225 the order of things just to be in alpha order we
1226 just renamed it and called it good */
1227 pack32(object->shares_raw, buffer);
1228
1229 packstr(object->grp_tres_mins, buffer);
1230 packstr(object->grp_tres_run_mins, buffer);
1231 packstr(object->grp_tres, buffer);
1232 pack32(object->grp_jobs, buffer);
1233 pack32(object->grp_jobs_accrue, buffer);
1234 pack32(object->grp_submit_jobs, buffer);
1235 pack32(object->grp_wall, buffer);
1236
1237 pack32(object->id, buffer);
1238 pack16(object->is_def, buffer);
1239 pack32(object->lft, buffer);
1240
1241 packstr(object->max_tres_mins_pj, buffer);
1242 packstr(object->max_tres_run_mins, buffer);
1243 packstr(object->max_tres_pj, buffer);
1244 packstr(object->max_tres_pn, buffer);
1245 pack32(object->max_jobs, buffer);
1246 pack32(object->max_jobs_accrue, buffer);
1247 pack32(object->min_prio_thresh, buffer);
1248 pack32(object->max_submit_jobs, buffer);
1249 pack32(object->max_wall_pj, buffer);
1250
1251 packstr(object->parent_acct, buffer);
1252 pack32(object->parent_id, buffer);
1253 packstr(object->partition, buffer);
1254 pack32(object->priority, buffer);
1255
1256 _pack_list_of_str(object->qos_list, buffer);
1257
1258 pack32(object->rgt, buffer);
1259 pack32(object->uid, buffer);
1260
1261 packstr(object->user, buffer);
1262 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1263 if (!object) {
1264 pack32(NO_VAL, buffer);
1265 packnull(buffer);
1266 packnull(buffer);
1267
1268 pack32(NO_VAL, buffer);
1269
1270 pack32(NO_VAL, buffer);
1271
1272 packnull(buffer);
1273 packnull(buffer);
1274 packnull(buffer);
1275 pack32(NO_VAL, buffer);
1276 pack32(NO_VAL, buffer);
1277 pack32(NO_VAL, buffer);
1278 pack32(NO_VAL, buffer);
1279
1280 pack32(0, buffer);
1281 pack16(0, buffer);
1282 pack32(0, buffer);
1283
1284 packnull(buffer);
1285 packnull(buffer);
1286 packnull(buffer);
1287 packnull(buffer);
1288 pack32(NO_VAL, buffer);
1289 pack32(NO_VAL, buffer);
1290 pack32(NO_VAL, buffer);
1291 pack32(NO_VAL, buffer);
1292 pack32(NO_VAL, buffer);
1293
1294 packnull(buffer);
1295 pack32(0, buffer);
1296 packnull(buffer);
1297
1298 pack32(NO_VAL, buffer);
1299
1300 pack32(0, buffer);
1301 pack32(0, buffer);
1302
1303 packnull(buffer);
1304 return;
1305 }
1306
1307 slurm_pack_list(object->accounting_list,
1308 slurmdb_pack_accounting_rec,
1309 buffer, protocol_version);
1310
1311 packstr(object->acct, buffer);
1312 packstr(object->cluster, buffer);
1313
1314 pack32(object->def_qos_id, buffer);
1315
1316 /* this used to be named fairshare to not have to redo
1317 the order of things just to be in alpha order we
1318 just renamed it and called it good */
1319 pack32(object->shares_raw, buffer);
1320
1321 packstr(object->grp_tres_mins, buffer);
1322 packstr(object->grp_tres_run_mins, buffer);
1323 packstr(object->grp_tres, buffer);
1324 pack32(object->grp_jobs, buffer);
1325 pack32(object->grp_jobs_accrue, buffer);
1326 pack32(object->grp_submit_jobs, buffer);
1327 pack32(object->grp_wall, buffer);
1328
1329 pack32(object->id, buffer);
1330 pack16(object->is_def, buffer);
1331 pack32(object->lft, buffer);
1332
1333 packstr(object->max_tres_mins_pj, buffer);
1334 packstr(object->max_tres_run_mins, buffer);
1335 packstr(object->max_tres_pj, buffer);
1336 packstr(object->max_tres_pn, buffer);
1337 pack32(object->max_jobs, buffer);
1338 pack32(object->max_jobs_accrue, buffer);
1339 pack32(object->min_prio_thresh, buffer);
1340 pack32(object->max_submit_jobs, buffer);
1341 pack32(object->max_wall_pj, buffer);
1342
1343 packstr(object->parent_acct, buffer);
1344 pack32(object->parent_id, buffer);
1345 packstr(object->partition, buffer);
1346
1347 _pack_list_of_str(object->qos_list, buffer);
1348
1349 pack32(object->rgt, buffer);
1350 pack32(object->uid, buffer);
1351
1352 packstr(object->user, buffer);
1353 } else {
1354 error("%s: protocol_version %hu not supported",
1355 __func__, protocol_version);
1356 }
1357 }
1358
slurmdb_unpack_assoc_rec_members(slurmdb_assoc_rec_t * object_ptr,uint16_t protocol_version,Buf buffer)1359 extern int slurmdb_unpack_assoc_rec_members(slurmdb_assoc_rec_t *object_ptr,
1360 uint16_t protocol_version,
1361 Buf buffer)
1362 {
1363 uint32_t uint32_tmp;
1364 int i;
1365 uint32_t count;
1366 char *tmp_info = NULL;
1367 slurmdb_accounting_rec_t *slurmdb_info = NULL;
1368
1369 slurmdb_init_assoc_rec(object_ptr, 0);
1370
1371 if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
1372 safe_unpack32(&count, buffer);
1373 if (count > NO_VAL)
1374 goto unpack_error;
1375 if (count != NO_VAL) {
1376 object_ptr->accounting_list =
1377 list_create(slurmdb_destroy_accounting_rec);
1378 for (i = 0; i < count; i++) {
1379 if (slurmdb_unpack_accounting_rec(
1380 (void **)&slurmdb_info,
1381 protocol_version,
1382 buffer) == SLURM_ERROR)
1383 goto unpack_error;
1384 list_append(object_ptr->accounting_list,
1385 slurmdb_info);
1386 }
1387 }
1388
1389 safe_unpackstr_xmalloc(&object_ptr->acct, &uint32_tmp, buffer);
1390 safe_unpackstr_xmalloc(&object_ptr->cluster, &uint32_tmp,
1391 buffer);
1392
1393 safe_unpack32(&object_ptr->def_qos_id, buffer);
1394
1395 safe_unpack32(&object_ptr->shares_raw, buffer);
1396
1397 safe_unpackstr_xmalloc(&object_ptr->grp_tres_mins,
1398 &uint32_tmp, buffer);
1399 safe_unpackstr_xmalloc(&object_ptr->grp_tres_run_mins,
1400 &uint32_tmp, buffer);
1401 safe_unpackstr_xmalloc(&object_ptr->grp_tres,
1402 &uint32_tmp, buffer);
1403 safe_unpack32(&object_ptr->grp_jobs, buffer);
1404 safe_unpack32(&object_ptr->grp_jobs_accrue, buffer);
1405 safe_unpack32(&object_ptr->grp_submit_jobs, buffer);
1406 safe_unpack32(&object_ptr->grp_wall, buffer);
1407
1408 safe_unpack32(&object_ptr->id, buffer);
1409 safe_unpack16(&object_ptr->is_def, buffer);
1410 safe_unpack32(&object_ptr->lft, buffer);
1411
1412 safe_unpackstr_xmalloc(&object_ptr->max_tres_mins_pj,
1413 &uint32_tmp, buffer);
1414 safe_unpackstr_xmalloc(&object_ptr->max_tres_run_mins,
1415 &uint32_tmp, buffer);
1416 safe_unpackstr_xmalloc(&object_ptr->max_tres_pj,
1417 &uint32_tmp, buffer);
1418 safe_unpackstr_xmalloc(&object_ptr->max_tres_pn,
1419 &uint32_tmp, buffer);
1420 safe_unpack32(&object_ptr->max_jobs, buffer);
1421 safe_unpack32(&object_ptr->max_jobs_accrue, buffer);
1422 safe_unpack32(&object_ptr->min_prio_thresh, buffer);
1423 safe_unpack32(&object_ptr->max_submit_jobs, buffer);
1424 safe_unpack32(&object_ptr->max_wall_pj, buffer);
1425
1426 safe_unpackstr_xmalloc(&object_ptr->parent_acct, &uint32_tmp,
1427 buffer);
1428 safe_unpack32(&object_ptr->parent_id, buffer);
1429 safe_unpackstr_xmalloc(&object_ptr->partition, &uint32_tmp,
1430 buffer);
1431 safe_unpack32(&object_ptr->priority, buffer);
1432
1433 safe_unpack32(&count, buffer);
1434 /* This needs to look for zero to tell if something
1435 has changed */
1436 if (count != NO_VAL) {
1437 object_ptr->qos_list = list_create(xfree_ptr);
1438 for(i=0; i<count; i++) {
1439 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
1440 buffer);
1441 list_append(object_ptr->qos_list, tmp_info);
1442 }
1443 }
1444
1445 safe_unpack32(&object_ptr->rgt, buffer);
1446 safe_unpack32(&object_ptr->uid, buffer);
1447
1448 safe_unpackstr_xmalloc(&object_ptr->user, &uint32_tmp, buffer);
1449 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1450 safe_unpack32(&count, buffer);
1451 if (count > NO_VAL)
1452 goto unpack_error;
1453 if (count != NO_VAL) {
1454 object_ptr->accounting_list =
1455 list_create(slurmdb_destroy_accounting_rec);
1456 for (i = 0; i < count; i++) {
1457 if (slurmdb_unpack_accounting_rec(
1458 (void **)&slurmdb_info,
1459 protocol_version,
1460 buffer) == SLURM_ERROR)
1461 goto unpack_error;
1462 list_append(object_ptr->accounting_list,
1463 slurmdb_info);
1464 }
1465 }
1466
1467 safe_unpackstr_xmalloc(&object_ptr->acct, &uint32_tmp, buffer);
1468 safe_unpackstr_xmalloc(&object_ptr->cluster, &uint32_tmp,
1469 buffer);
1470
1471 safe_unpack32(&object_ptr->def_qos_id, buffer);
1472
1473 safe_unpack32(&object_ptr->shares_raw, buffer);
1474
1475 safe_unpackstr_xmalloc(&object_ptr->grp_tres_mins,
1476 &uint32_tmp, buffer);
1477 safe_unpackstr_xmalloc(&object_ptr->grp_tres_run_mins,
1478 &uint32_tmp, buffer);
1479 safe_unpackstr_xmalloc(&object_ptr->grp_tres,
1480 &uint32_tmp, buffer);
1481 safe_unpack32(&object_ptr->grp_jobs, buffer);
1482 safe_unpack32(&object_ptr->grp_jobs_accrue, buffer);
1483 safe_unpack32(&object_ptr->grp_submit_jobs, buffer);
1484 safe_unpack32(&object_ptr->grp_wall, buffer);
1485
1486 safe_unpack32(&object_ptr->id, buffer);
1487 safe_unpack16(&object_ptr->is_def, buffer);
1488 safe_unpack32(&object_ptr->lft, buffer);
1489
1490 safe_unpackstr_xmalloc(&object_ptr->max_tres_mins_pj,
1491 &uint32_tmp, buffer);
1492 safe_unpackstr_xmalloc(&object_ptr->max_tres_run_mins,
1493 &uint32_tmp, buffer);
1494 safe_unpackstr_xmalloc(&object_ptr->max_tres_pj,
1495 &uint32_tmp, buffer);
1496 safe_unpackstr_xmalloc(&object_ptr->max_tres_pn,
1497 &uint32_tmp, buffer);
1498 safe_unpack32(&object_ptr->max_jobs, buffer);
1499 safe_unpack32(&object_ptr->max_jobs_accrue, buffer);
1500 safe_unpack32(&object_ptr->min_prio_thresh, buffer);
1501 safe_unpack32(&object_ptr->max_submit_jobs, buffer);
1502 safe_unpack32(&object_ptr->max_wall_pj, buffer);
1503
1504 safe_unpackstr_xmalloc(&object_ptr->parent_acct, &uint32_tmp,
1505 buffer);
1506 safe_unpack32(&object_ptr->parent_id, buffer);
1507 safe_unpackstr_xmalloc(&object_ptr->partition, &uint32_tmp,
1508 buffer);
1509
1510 safe_unpack32(&count, buffer);
1511 /* This needs to look for zero to tell if something
1512 has changed */
1513 if (count != NO_VAL) {
1514 object_ptr->qos_list = list_create(xfree_ptr);
1515 for(i=0; i<count; i++) {
1516 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
1517 buffer);
1518 list_append(object_ptr->qos_list, tmp_info);
1519 }
1520 }
1521
1522 safe_unpack32(&object_ptr->rgt, buffer);
1523 safe_unpack32(&object_ptr->uid, buffer);
1524
1525 safe_unpackstr_xmalloc(&object_ptr->user, &uint32_tmp, buffer);
1526 } else {
1527 error("%s: protocol_version %hu not supported",
1528 __func__, protocol_version);
1529 goto unpack_error;
1530 }
1531
1532 return SLURM_SUCCESS;
1533
1534 unpack_error:
1535
1536 return SLURM_ERROR;
1537 }
1538
slurmdb_unpack_assoc_rec(void ** object,uint16_t protocol_version,Buf buffer)1539 extern int slurmdb_unpack_assoc_rec(void **object, uint16_t protocol_version,
1540 Buf buffer)
1541 {
1542 int rc;
1543 slurmdb_assoc_rec_t *object_ptr = xmalloc(sizeof(slurmdb_assoc_rec_t));
1544
1545 *object = object_ptr;
1546
1547 slurmdb_init_assoc_rec(object_ptr, 0);
1548
1549 if ((rc = slurmdb_unpack_assoc_rec_members(
1550 object_ptr, protocol_version, buffer)) != SLURM_SUCCESS) {
1551 slurmdb_destroy_assoc_rec(object_ptr);
1552 *object = NULL;
1553 }
1554 return rc;
1555 }
1556
slurmdb_pack_assoc_usage(void * in,uint16_t protocol_version,Buf buffer)1557 extern void slurmdb_pack_assoc_usage(void *in, uint16_t protocol_version,
1558 Buf buffer)
1559 {
1560 slurmdb_assoc_usage_t *usage = (slurmdb_assoc_usage_t *)in;
1561
1562 xassert(buffer);
1563 xassert(usage);
1564
1565 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1566 pack32(usage->accrue_cnt, buffer);
1567 pack64_array(usage->grp_used_tres, usage->tres_cnt, buffer);
1568 pack64_array(usage->grp_used_tres_run_secs, usage->tres_cnt,
1569 buffer);
1570 packdouble(usage->grp_used_wall, buffer);
1571 packdouble(usage->fs_factor, buffer);
1572 pack32(usage->level_shares, buffer);
1573 packdouble(usage->shares_norm, buffer);
1574 packlongdouble(usage->usage_efctv, buffer);
1575 packlongdouble(usage->usage_norm, buffer);
1576 packlongdouble(usage->usage_raw, buffer);
1577 packlongdouble_array(usage->usage_tres_raw, usage->tres_cnt,
1578 buffer);
1579 pack32(usage->used_jobs, buffer);
1580 pack32(usage->used_submit_jobs, buffer);
1581 packlongdouble(usage->level_fs, buffer);
1582 pack_bit_str_hex(usage->valid_qos, buffer);
1583 } else {
1584 error("%s: protocol_version %hu not supported",
1585 __func__, protocol_version);
1586 }
1587 }
1588
slurmdb_unpack_assoc_usage(void ** object,uint16_t protocol_version,Buf buffer)1589 extern int slurmdb_unpack_assoc_usage(void **object, uint16_t protocol_version,
1590 Buf buffer)
1591 {
1592 slurmdb_assoc_usage_t *object_ptr =
1593 xmalloc(sizeof(slurmdb_assoc_usage_t));
1594 uint32_t tmp32;
1595 *object = object_ptr;
1596
1597 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1598 safe_unpack32(&object_ptr->accrue_cnt, buffer);
1599 safe_unpack64_array(&object_ptr->grp_used_tres, &tmp32, buffer);
1600 object_ptr->tres_cnt = tmp32;
1601 safe_unpack64_array(&object_ptr->grp_used_tres_run_secs,
1602 &tmp32, buffer);
1603 safe_unpackdouble(&object_ptr->grp_used_wall, buffer);
1604 safe_unpackdouble(&object_ptr->fs_factor, buffer);
1605 safe_unpack32(&object_ptr->level_shares, buffer);
1606 safe_unpackdouble(&object_ptr->shares_norm, buffer);
1607 safe_unpacklongdouble(&object_ptr->usage_efctv, buffer);
1608 safe_unpacklongdouble(&object_ptr->usage_norm, buffer);
1609 safe_unpacklongdouble(&object_ptr->usage_raw, buffer);
1610 safe_unpacklongdouble_array(&object_ptr->usage_tres_raw,
1611 &tmp32, buffer);
1612
1613 safe_unpack32(&object_ptr->used_jobs, buffer);
1614 safe_unpack32(&object_ptr->used_submit_jobs, buffer);
1615 safe_unpacklongdouble(&object_ptr->level_fs, buffer);
1616 unpack_bit_str_hex(&object_ptr->valid_qos, buffer);
1617 } else {
1618 error("%s: protocol_version %hu not supported",
1619 __func__, protocol_version);
1620 goto unpack_error;
1621 }
1622
1623 return SLURM_SUCCESS;
1624
1625 unpack_error:
1626 slurmdb_destroy_assoc_usage(object_ptr);
1627 *object = NULL;
1628
1629 return SLURM_ERROR;
1630 }
1631
slurmdb_pack_assoc_rec_with_usage(void * in,uint16_t protocol_version,Buf buffer)1632 extern void slurmdb_pack_assoc_rec_with_usage(void *in,
1633 uint16_t protocol_version,
1634 Buf buffer)
1635 {
1636 slurmdb_assoc_rec_t *object = (slurmdb_assoc_rec_t *)in;
1637
1638 slurmdb_pack_assoc_rec(in, protocol_version, buffer);
1639 slurmdb_pack_assoc_usage(object->usage, protocol_version, buffer);
1640
1641 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1642 pack64_array(object->grp_tres_mins_ctld,
1643 object->usage->tres_cnt, buffer);
1644 pack64_array(object->grp_tres_run_mins_ctld,
1645 object->usage->tres_cnt, buffer);
1646 pack64_array(object->grp_tres_ctld,
1647 object->usage->tres_cnt, buffer);
1648
1649 pack64_array(object->max_tres_mins_ctld,
1650 object->usage->tres_cnt, buffer);
1651 pack64_array(object->max_tres_run_mins_ctld,
1652 object->usage->tres_cnt, buffer);
1653 pack64_array(object->max_tres_ctld,
1654 object->usage->tres_cnt, buffer);
1655 pack64_array(object->max_tres_pn_ctld,
1656 object->usage->tres_cnt, buffer);
1657 } else {
1658 error("%s: protocol_version %hu not supported",
1659 __func__, protocol_version);
1660 }
1661
1662 }
1663
slurmdb_unpack_assoc_rec_with_usage(void ** object,uint16_t protocol_version,Buf buffer)1664 extern int slurmdb_unpack_assoc_rec_with_usage(void **object,
1665 uint16_t protocol_version,
1666 Buf buffer)
1667 {
1668 int rc;
1669 uint32_t uint32_tmp;
1670 slurmdb_assoc_rec_t *object_ptr;
1671
1672 xassert(object);
1673 xassert(buffer);
1674
1675 if ((rc = slurmdb_unpack_assoc_rec(object, protocol_version, buffer))
1676 != SLURM_SUCCESS)
1677 return rc;
1678
1679 object_ptr = *object;
1680
1681 if ((rc = slurmdb_unpack_assoc_usage((void **)&object_ptr->usage,
1682 protocol_version, buffer)))
1683 goto unpack_error;
1684
1685 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1686 safe_unpack64_array(&object_ptr->grp_tres_mins_ctld,
1687 &uint32_tmp, buffer);
1688 safe_unpack64_array(&object_ptr->grp_tres_run_mins_ctld,
1689 &uint32_tmp, buffer);
1690 safe_unpack64_array(&object_ptr->grp_tres_ctld,
1691 &uint32_tmp, buffer);
1692
1693 safe_unpack64_array(&object_ptr->max_tres_mins_ctld,
1694 &uint32_tmp, buffer);
1695 safe_unpack64_array(&object_ptr->max_tres_run_mins_ctld,
1696 &uint32_tmp, buffer);
1697 safe_unpack64_array(&object_ptr->max_tres_ctld,
1698 &uint32_tmp, buffer);
1699 safe_unpack64_array(&object_ptr->max_tres_pn_ctld,
1700 &uint32_tmp, buffer);
1701 } else {
1702 error("%s: protocol_version %hu not supported",
1703 __func__, protocol_version);
1704 goto unpack_error;
1705 }
1706
1707 return rc;
1708
1709 unpack_error:
1710 slurmdb_destroy_assoc_rec(object_ptr);
1711 *object = NULL;
1712 return SLURM_ERROR;
1713 }
1714
slurmdb_pack_event_rec(void * in,uint16_t protocol_version,Buf buffer)1715 extern void slurmdb_pack_event_rec(void *in, uint16_t protocol_version,
1716 Buf buffer)
1717 {
1718 slurmdb_event_rec_t *object = (slurmdb_event_rec_t *)in;
1719
1720 xassert(buffer);
1721
1722 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
1723 if (!object) {
1724 packnull(buffer);
1725 packnull(buffer);
1726 pack16(0, buffer);
1727 packnull(buffer);
1728 pack_time(0, buffer);
1729 pack_time(0, buffer);
1730 packnull(buffer);
1731 pack32(NO_VAL, buffer);
1732 pack32(NO_VAL, buffer);
1733 packnull(buffer);
1734 return;
1735 }
1736
1737 packstr(object->cluster, buffer);
1738 packstr(object->cluster_nodes, buffer);
1739 pack16(object->event_type, buffer);
1740 packstr(object->node_name, buffer);
1741 pack_time(object->period_start, buffer);
1742 pack_time(object->period_end, buffer);
1743 packstr(object->reason, buffer);
1744 pack32(object->reason_uid, buffer);
1745 pack32(object->state, buffer);
1746 packstr(object->tres_str, buffer);
1747 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1748 if (!object) {
1749 packnull(buffer);
1750 packnull(buffer);
1751 pack16(0, buffer);
1752 packnull(buffer);
1753 pack_time(0, buffer);
1754 pack_time(0, buffer);
1755 packnull(buffer);
1756 pack32(NO_VAL, buffer);
1757 pack16(NO_VAL16, buffer);
1758 packnull(buffer);
1759 return;
1760 }
1761
1762 packstr(object->cluster, buffer);
1763 packstr(object->cluster_nodes, buffer);
1764 pack16(object->event_type, buffer);
1765 packstr(object->node_name, buffer);
1766 pack_time(object->period_start, buffer);
1767 pack_time(object->period_end, buffer);
1768 packstr(object->reason, buffer);
1769 pack32(object->reason_uid, buffer);
1770 pack16(object->state, buffer);
1771 packstr(object->tres_str, buffer);
1772 } else {
1773 error("%s: protocol_version %hu not supported",
1774 __func__, protocol_version);
1775 }
1776 }
1777
slurmdb_unpack_event_rec(void ** object,uint16_t protocol_version,Buf buffer)1778 extern int slurmdb_unpack_event_rec(void **object, uint16_t protocol_version,
1779 Buf buffer)
1780 {
1781 uint32_t uint32_tmp;
1782 uint16_t uint16_tmp;
1783 slurmdb_event_rec_t *object_ptr = xmalloc(sizeof(slurmdb_event_rec_t));
1784
1785 xassert(buffer);
1786 xassert(object);
1787
1788 *object = object_ptr;
1789
1790 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
1791 safe_unpackstr_xmalloc(&object_ptr->cluster,
1792 &uint32_tmp, buffer);
1793 safe_unpackstr_xmalloc(&object_ptr->cluster_nodes,
1794 &uint32_tmp, buffer);
1795 safe_unpack16(&object_ptr->event_type, buffer);
1796 safe_unpackstr_xmalloc(&object_ptr->node_name,
1797 &uint32_tmp, buffer);
1798 safe_unpack_time(&object_ptr->period_start, buffer);
1799 safe_unpack_time(&object_ptr->period_end, buffer);
1800 safe_unpackstr_xmalloc(&object_ptr->reason,
1801 &uint32_tmp, buffer);
1802 safe_unpack32(&object_ptr->reason_uid, buffer);
1803 safe_unpack32(&object_ptr->state, buffer);
1804 safe_unpackstr_xmalloc(&object_ptr->tres_str,
1805 &uint32_tmp, buffer);
1806 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1807 safe_unpackstr_xmalloc(&object_ptr->cluster,
1808 &uint32_tmp, buffer);
1809 safe_unpackstr_xmalloc(&object_ptr->cluster_nodes,
1810 &uint32_tmp, buffer);
1811 safe_unpack16(&object_ptr->event_type, buffer);
1812 safe_unpackstr_xmalloc(&object_ptr->node_name,
1813 &uint32_tmp, buffer);
1814 safe_unpack_time(&object_ptr->period_start, buffer);
1815 safe_unpack_time(&object_ptr->period_end, buffer);
1816 safe_unpackstr_xmalloc(&object_ptr->reason,
1817 &uint32_tmp, buffer);
1818 safe_unpack32(&object_ptr->reason_uid, buffer);
1819 safe_unpack16(&uint16_tmp, buffer);
1820 object_ptr->state = uint16_tmp;
1821 safe_unpackstr_xmalloc(&object_ptr->tres_str,
1822 &uint32_tmp, buffer);
1823 } else {
1824 error("%s: protocol_version %hu not supported",
1825 __func__, protocol_version);
1826 goto unpack_error;
1827 }
1828
1829 return SLURM_SUCCESS;
1830
1831 unpack_error:
1832 slurmdb_destroy_event_rec(object_ptr);
1833 *object = NULL;
1834 return SLURM_ERROR;
1835 }
1836
slurmdb_pack_qos_rec(void * in,uint16_t protocol_version,Buf buffer)1837 extern void slurmdb_pack_qos_rec(void *in, uint16_t protocol_version, Buf buffer)
1838 {
1839 slurmdb_qos_rec_t *object = (slurmdb_qos_rec_t *)in;
1840
1841 if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
1842 if (!object) {
1843 packnull(buffer);
1844 pack32(0, buffer);
1845
1846 pack32(QOS_FLAG_NOTSET, buffer);
1847
1848 pack32(NO_VAL, buffer);
1849 packnull(buffer);
1850 packnull(buffer);
1851 packnull(buffer);
1852 pack32(NO_VAL, buffer);
1853 pack32(NO_VAL, buffer);
1854 pack32(NO_VAL, buffer);
1855 pack32(NO_VAL, buffer);
1856
1857 packnull(buffer);
1858 packnull(buffer);
1859 packnull(buffer);
1860 packnull(buffer);
1861 packnull(buffer);
1862 packnull(buffer);
1863 packnull(buffer);
1864 pack32(NO_VAL, buffer);
1865 pack32(NO_VAL, buffer);
1866 pack32(NO_VAL, buffer);
1867 pack32(NO_VAL, buffer);
1868 pack32(NO_VAL, buffer);
1869 pack32(NO_VAL, buffer);
1870 pack32(NO_VAL, buffer);
1871 pack32(NO_VAL, buffer);
1872 packnull(buffer);
1873
1874 packnull(buffer);
1875
1876 pack_bit_str_hex(NULL, buffer);
1877 pack32(NO_VAL, buffer);
1878
1879 pack16(0, buffer);
1880 pack32(0, buffer);
1881 pack32(0, buffer);
1882
1883 packdouble(NO_VAL64, buffer);
1884 packdouble(NO_VAL64, buffer);
1885 return;
1886 }
1887 packstr(object->description, buffer);
1888 pack32(object->id, buffer);
1889
1890 pack32(object->flags, buffer);
1891
1892 pack32(object->grace_time, buffer);
1893 packstr(object->grp_tres_mins, buffer);
1894 packstr(object->grp_tres_run_mins, buffer);
1895 packstr(object->grp_tres, buffer);
1896 pack32(object->grp_jobs, buffer);
1897 pack32(object->grp_jobs_accrue, buffer);
1898 pack32(object->grp_submit_jobs, buffer);
1899 pack32(object->grp_wall, buffer);
1900
1901 packstr(object->max_tres_mins_pj, buffer);
1902 packstr(object->max_tres_run_mins_pa, buffer);
1903 packstr(object->max_tres_run_mins_pu, buffer);
1904 packstr(object->max_tres_pa, buffer);
1905 packstr(object->max_tres_pj, buffer);
1906 packstr(object->max_tres_pn, buffer);
1907 packstr(object->max_tres_pu, buffer);
1908 pack32(object->max_jobs_pa, buffer);
1909 pack32(object->max_jobs_pu, buffer);
1910 pack32(object->max_jobs_accrue_pa, buffer);
1911 pack32(object->max_jobs_accrue_pu, buffer);
1912 pack32(object->min_prio_thresh, buffer);
1913 pack32(object->max_submit_jobs_pa, buffer);
1914 pack32(object->max_submit_jobs_pu, buffer);
1915 pack32(object->max_wall_pj, buffer);
1916 packstr(object->min_tres_pj, buffer);
1917
1918 packstr(object->name, buffer);
1919
1920 pack_bit_str_hex(object->preempt_bitstr, buffer);
1921
1922 _pack_list_of_str(object->preempt_list, buffer);
1923
1924 pack16(object->preempt_mode, buffer);
1925 pack32(object->preempt_exempt_time, buffer);
1926 pack32(object->priority, buffer);
1927
1928 packdouble(object->usage_factor, buffer);
1929 packdouble(object->usage_thres, buffer);
1930 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
1931 if (!object) {
1932 packnull(buffer);
1933 pack32(0, buffer);
1934
1935 pack32(QOS_FLAG_NOTSET, buffer);
1936
1937 pack32(NO_VAL, buffer);
1938 packnull(buffer);
1939 packnull(buffer);
1940 packnull(buffer);
1941 pack32(NO_VAL, buffer);
1942 pack32(NO_VAL, buffer);
1943 pack32(NO_VAL, buffer);
1944 pack32(NO_VAL, buffer);
1945
1946 packnull(buffer);
1947 packnull(buffer);
1948 packnull(buffer);
1949 packnull(buffer);
1950 packnull(buffer);
1951 packnull(buffer);
1952 packnull(buffer);
1953 pack32(NO_VAL, buffer);
1954 pack32(NO_VAL, buffer);
1955 pack32(NO_VAL, buffer);
1956 pack32(NO_VAL, buffer);
1957 pack32(NO_VAL, buffer);
1958 pack32(NO_VAL, buffer);
1959 pack32(NO_VAL, buffer);
1960 pack32(NO_VAL, buffer);
1961 packnull(buffer);
1962
1963 packnull(buffer);
1964
1965 pack_bit_str_hex(NULL, buffer);
1966 pack32(NO_VAL, buffer);
1967
1968 pack16(0, buffer);
1969 pack32(0, buffer);
1970
1971 packdouble(NO_VAL64, buffer);
1972 packdouble(NO_VAL64, buffer);
1973 return;
1974 }
1975 packstr(object->description, buffer);
1976 pack32(object->id, buffer);
1977
1978 pack32(object->flags, buffer);
1979
1980 pack32(object->grace_time, buffer);
1981 packstr(object->grp_tres_mins, buffer);
1982 packstr(object->grp_tres_run_mins, buffer);
1983 packstr(object->grp_tres, buffer);
1984 pack32(object->grp_jobs, buffer);
1985 pack32(object->grp_jobs_accrue, buffer);
1986 pack32(object->grp_submit_jobs, buffer);
1987 pack32(object->grp_wall, buffer);
1988
1989 packstr(object->max_tres_mins_pj, buffer);
1990 packstr(object->max_tres_run_mins_pa, buffer);
1991 packstr(object->max_tres_run_mins_pu, buffer);
1992 packstr(object->max_tres_pa, buffer);
1993 packstr(object->max_tres_pj, buffer);
1994 packstr(object->max_tres_pn, buffer);
1995 packstr(object->max_tres_pu, buffer);
1996 pack32(object->max_jobs_pa, buffer);
1997 pack32(object->max_jobs_pu, buffer);
1998 pack32(object->max_jobs_accrue_pa, buffer);
1999 pack32(object->max_jobs_accrue_pu, buffer);
2000 pack32(object->min_prio_thresh, buffer);
2001 pack32(object->max_submit_jobs_pa, buffer);
2002 pack32(object->max_submit_jobs_pu, buffer);
2003 pack32(object->max_wall_pj, buffer);
2004 packstr(object->min_tres_pj, buffer);
2005
2006 packstr(object->name, buffer);
2007
2008 pack_bit_str_hex(object->preempt_bitstr, buffer);
2009
2010 _pack_list_of_str(object->preempt_list, buffer);
2011
2012 pack16(object->preempt_mode, buffer);
2013 pack32(object->priority, buffer);
2014
2015 packdouble(object->usage_factor, buffer);
2016 packdouble(object->usage_thres, buffer);
2017 } else {
2018 error("%s: protocol_version %hu not supported",
2019 __func__, protocol_version);
2020 }
2021 }
2022
slurmdb_unpack_qos_rec(void ** object,uint16_t protocol_version,Buf buffer)2023 extern int slurmdb_unpack_qos_rec(void **object, uint16_t protocol_version,
2024 Buf buffer)
2025 {
2026 uint32_t uint32_tmp;
2027 int i;
2028 slurmdb_qos_rec_t *object_ptr = xmalloc(sizeof(slurmdb_qos_rec_t));
2029 uint32_t count = NO_VAL;
2030 char *tmp_info = NULL;
2031
2032 *object = object_ptr;
2033
2034 slurmdb_init_qos_rec(object_ptr, 0, NO_VAL);
2035
2036 if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
2037 safe_unpackstr_xmalloc(&object_ptr->description,
2038 &uint32_tmp, buffer);
2039 safe_unpack32(&object_ptr->id, buffer);
2040
2041 safe_unpack32(&object_ptr->flags, buffer);
2042
2043 safe_unpack32(&object_ptr->grace_time, buffer);
2044 safe_unpackstr_xmalloc(&object_ptr->grp_tres_mins,
2045 &uint32_tmp, buffer);
2046 safe_unpackstr_xmalloc(&object_ptr->grp_tres_run_mins,
2047 &uint32_tmp, buffer);
2048 safe_unpackstr_xmalloc(&object_ptr->grp_tres,
2049 &uint32_tmp, buffer);
2050 safe_unpack32(&object_ptr->grp_jobs, buffer);
2051 safe_unpack32(&object_ptr->grp_jobs_accrue, buffer);
2052 safe_unpack32(&object_ptr->grp_submit_jobs, buffer);
2053 safe_unpack32(&object_ptr->grp_wall, buffer);
2054
2055 safe_unpackstr_xmalloc(&object_ptr->max_tres_mins_pj,
2056 &uint32_tmp, buffer);
2057 safe_unpackstr_xmalloc(&object_ptr->max_tres_run_mins_pa,
2058 &uint32_tmp, buffer);
2059 safe_unpackstr_xmalloc(&object_ptr->max_tres_run_mins_pu,
2060 &uint32_tmp, buffer);
2061 safe_unpackstr_xmalloc(&object_ptr->max_tres_pa,
2062 &uint32_tmp, buffer);
2063 safe_unpackstr_xmalloc(&object_ptr->max_tres_pj,
2064 &uint32_tmp, buffer);
2065 safe_unpackstr_xmalloc(&object_ptr->max_tres_pn,
2066 &uint32_tmp, buffer);
2067 safe_unpackstr_xmalloc(&object_ptr->max_tres_pu,
2068 &uint32_tmp, buffer);
2069 safe_unpack32(&object_ptr->max_jobs_pa, buffer);
2070 safe_unpack32(&object_ptr->max_jobs_pu, buffer);
2071 safe_unpack32(&object_ptr->max_jobs_accrue_pa, buffer);
2072 safe_unpack32(&object_ptr->max_jobs_accrue_pu, buffer);
2073 safe_unpack32(&object_ptr->min_prio_thresh, buffer);
2074 safe_unpack32(&object_ptr->max_submit_jobs_pa, buffer);
2075 safe_unpack32(&object_ptr->max_submit_jobs_pu, buffer);
2076 safe_unpack32(&object_ptr->max_wall_pj, buffer);
2077 safe_unpackstr_xmalloc(&object_ptr->min_tres_pj,
2078 &uint32_tmp, buffer);
2079
2080 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
2081
2082 unpack_bit_str_hex(&object_ptr->preempt_bitstr, buffer);
2083
2084 safe_unpack32(&count, buffer);
2085 if (count > NO_VAL)
2086 goto unpack_error;
2087 if (count != NO_VAL) {
2088 object_ptr->preempt_list = list_create(xfree_ptr);
2089 for (i = 0; i < count; i++) {
2090 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
2091 buffer);
2092 list_append(object_ptr->preempt_list,
2093 tmp_info);
2094 }
2095 }
2096
2097 safe_unpack16(&object_ptr->preempt_mode, buffer);
2098 safe_unpack32(&object_ptr->preempt_exempt_time, buffer);
2099 safe_unpack32(&object_ptr->priority, buffer);
2100
2101 safe_unpackdouble(&object_ptr->usage_factor, buffer);
2102 safe_unpackdouble(&object_ptr->usage_thres, buffer);
2103 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2104 safe_unpackstr_xmalloc(&object_ptr->description,
2105 &uint32_tmp, buffer);
2106 safe_unpack32(&object_ptr->id, buffer);
2107
2108 safe_unpack32(&object_ptr->flags, buffer);
2109
2110 safe_unpack32(&object_ptr->grace_time, buffer);
2111 safe_unpackstr_xmalloc(&object_ptr->grp_tres_mins,
2112 &uint32_tmp, buffer);
2113 safe_unpackstr_xmalloc(&object_ptr->grp_tres_run_mins,
2114 &uint32_tmp, buffer);
2115 safe_unpackstr_xmalloc(&object_ptr->grp_tres,
2116 &uint32_tmp, buffer);
2117 safe_unpack32(&object_ptr->grp_jobs, buffer);
2118 safe_unpack32(&object_ptr->grp_jobs_accrue, buffer);
2119 safe_unpack32(&object_ptr->grp_submit_jobs, buffer);
2120 safe_unpack32(&object_ptr->grp_wall, buffer);
2121
2122 safe_unpackstr_xmalloc(&object_ptr->max_tres_mins_pj,
2123 &uint32_tmp, buffer);
2124 safe_unpackstr_xmalloc(&object_ptr->max_tres_run_mins_pa,
2125 &uint32_tmp, buffer);
2126 safe_unpackstr_xmalloc(&object_ptr->max_tres_run_mins_pu,
2127 &uint32_tmp, buffer);
2128 safe_unpackstr_xmalloc(&object_ptr->max_tres_pa,
2129 &uint32_tmp, buffer);
2130 safe_unpackstr_xmalloc(&object_ptr->max_tres_pj,
2131 &uint32_tmp, buffer);
2132 safe_unpackstr_xmalloc(&object_ptr->max_tres_pn,
2133 &uint32_tmp, buffer);
2134 safe_unpackstr_xmalloc(&object_ptr->max_tres_pu,
2135 &uint32_tmp, buffer);
2136 safe_unpack32(&object_ptr->max_jobs_pa, buffer);
2137 safe_unpack32(&object_ptr->max_jobs_pu, buffer);
2138 safe_unpack32(&object_ptr->max_jobs_accrue_pa, buffer);
2139 safe_unpack32(&object_ptr->max_jobs_accrue_pu, buffer);
2140 safe_unpack32(&object_ptr->min_prio_thresh, buffer);
2141 safe_unpack32(&object_ptr->max_submit_jobs_pa, buffer);
2142 safe_unpack32(&object_ptr->max_submit_jobs_pu, buffer);
2143 safe_unpack32(&object_ptr->max_wall_pj, buffer);
2144 safe_unpackstr_xmalloc(&object_ptr->min_tres_pj,
2145 &uint32_tmp, buffer);
2146
2147 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
2148
2149 unpack_bit_str_hex(&object_ptr->preempt_bitstr, buffer);
2150
2151 safe_unpack32(&count, buffer);
2152 if (count > NO_VAL)
2153 goto unpack_error;
2154 if (count != NO_VAL) {
2155 object_ptr->preempt_list = list_create(xfree_ptr);
2156 for (i = 0; i < count; i++) {
2157 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
2158 buffer);
2159 list_append(object_ptr->preempt_list,
2160 tmp_info);
2161 }
2162 }
2163
2164 safe_unpack16(&object_ptr->preempt_mode, buffer);
2165 safe_unpack32(&object_ptr->priority, buffer);
2166
2167 safe_unpackdouble(&object_ptr->usage_factor, buffer);
2168 safe_unpackdouble(&object_ptr->usage_thres, buffer);
2169 } else {
2170 error("%s: protocol_version %hu not supported",
2171 __func__, protocol_version);
2172 goto unpack_error;
2173 }
2174
2175 return SLURM_SUCCESS;
2176
2177 unpack_error:
2178 slurmdb_destroy_qos_rec(object_ptr);
2179 *object = NULL;
2180 return SLURM_ERROR;
2181 }
2182
slurmdb_pack_qos_usage(void * in,uint16_t protocol_version,Buf buffer)2183 extern void slurmdb_pack_qos_usage(void *in, uint16_t protocol_version,
2184 Buf buffer)
2185 {
2186 slurmdb_qos_usage_t *usage = (slurmdb_qos_usage_t *)in;
2187 uint32_t count;
2188 ListIterator itr;
2189 void *used_limits;
2190
2191 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2192 pack32(usage->accrue_cnt, buffer);
2193 pack32(usage->grp_used_jobs, buffer);
2194 pack32(usage->grp_used_submit_jobs, buffer);
2195 pack64_array(usage->grp_used_tres, usage->tres_cnt, buffer);
2196 pack64_array(usage->grp_used_tres_run_secs,
2197 usage->tres_cnt, buffer);
2198 packdouble(usage->grp_used_wall, buffer);
2199 packdouble(usage->norm_priority, buffer);
2200 packlongdouble(usage->usage_raw, buffer);
2201 packlongdouble_array(usage->usage_tres_raw,
2202 usage->tres_cnt, buffer);
2203
2204 if (!usage->user_limit_list ||
2205 !(count = list_count(usage->user_limit_list)))
2206 count = NO_VAL;
2207
2208 /* We have to pack anything that is verified by
2209 * tres_cnt after this. It is used in the unpack,
2210 * that is the reason it isn't alpha.
2211 */
2212 pack32(count, buffer);
2213 if (count != NO_VAL) {
2214 itr = list_iterator_create(usage->user_limit_list);
2215 while ((used_limits = list_next(itr)))
2216 slurmdb_pack_used_limits(
2217 used_limits, usage->tres_cnt,
2218 protocol_version, buffer);
2219 list_iterator_destroy(itr);
2220 }
2221 if (!usage->acct_limit_list ||
2222 !(count = list_count(usage->acct_limit_list)))
2223 count = NO_VAL;
2224
2225 pack32(count, buffer);
2226 if (count != NO_VAL) {
2227 itr = list_iterator_create(usage->acct_limit_list);
2228 while ((used_limits = list_next(itr)))
2229 slurmdb_pack_used_limits(
2230 used_limits, usage->tres_cnt,
2231 protocol_version, buffer);
2232 list_iterator_destroy(itr);
2233 }
2234 } else {
2235 error("%s: version too old %u", __func__, protocol_version);
2236 return;
2237 }
2238
2239 }
2240
slurmdb_unpack_qos_usage(void ** object,uint16_t protocol_version,Buf buffer)2241 extern int slurmdb_unpack_qos_usage(void **object, uint16_t protocol_version,
2242 Buf buffer)
2243 {
2244 slurmdb_qos_usage_t *object_ptr = xmalloc(sizeof(slurmdb_qos_usage_t));
2245
2246 uint32_t count;
2247 void *used_limits;
2248 int i;
2249
2250 *object = object_ptr;
2251
2252 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2253 safe_unpack32(&object_ptr->accrue_cnt, buffer);
2254 safe_unpack32(&object_ptr->grp_used_jobs, buffer);
2255 safe_unpack32(&object_ptr->grp_used_submit_jobs, buffer);
2256 safe_unpack64_array(&object_ptr->grp_used_tres,
2257 &object_ptr->tres_cnt, buffer);
2258 safe_unpack64_array(&object_ptr->grp_used_tres_run_secs,
2259 &object_ptr->tres_cnt, buffer);
2260 safe_unpackdouble(&object_ptr->grp_used_wall, buffer);
2261 safe_unpackdouble(&object_ptr->norm_priority, buffer);
2262 safe_unpacklongdouble(&object_ptr->usage_raw, buffer);
2263 safe_unpacklongdouble_array(&object_ptr->usage_tres_raw,
2264 &count, buffer);
2265
2266 safe_unpack32(&count, buffer);
2267 if (count > NO_VAL)
2268 goto unpack_error;
2269 if (count != NO_VAL) {
2270 object_ptr->user_limit_list =
2271 list_create(slurmdb_destroy_used_limits);
2272 for (i = 0; i < count; i++) {
2273 if (slurmdb_unpack_used_limits(
2274 &used_limits,
2275 object_ptr->tres_cnt,
2276 protocol_version, buffer)
2277 != SLURM_SUCCESS)
2278 goto unpack_error;
2279 list_append(object_ptr->user_limit_list,
2280 used_limits);
2281 }
2282 }
2283
2284 safe_unpack32(&count, buffer);
2285 if (count > NO_VAL)
2286 goto unpack_error;
2287 if (count != NO_VAL) {
2288 object_ptr->acct_limit_list =
2289 list_create(slurmdb_destroy_used_limits);
2290 for (i = 0; i < count; i++) {
2291 if (slurmdb_unpack_used_limits(
2292 &used_limits,
2293 object_ptr->tres_cnt,
2294 protocol_version, buffer)
2295 != SLURM_SUCCESS)
2296 goto unpack_error;
2297 list_append(object_ptr->acct_limit_list,
2298 used_limits);
2299 }
2300 }
2301 } else {
2302 error("%s: version too old %u", __func__, protocol_version);
2303 goto unpack_error;
2304 }
2305
2306 return SLURM_SUCCESS;
2307
2308 unpack_error:
2309 slurmdb_destroy_qos_usage(object_ptr);
2310 *object = NULL;
2311
2312 return SLURM_ERROR;
2313 }
2314
slurmdb_pack_qos_rec_with_usage(void * in,uint16_t protocol_version,Buf buffer)2315 extern void slurmdb_pack_qos_rec_with_usage(void *in, uint16_t protocol_version,
2316 Buf buffer)
2317 {
2318 slurmdb_qos_rec_t *object = (slurmdb_qos_rec_t *)in;
2319
2320 slurmdb_pack_qos_rec(in, protocol_version, buffer);
2321
2322 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2323 pack64_array(object->grp_tres_mins_ctld,
2324 object->usage->tres_cnt, buffer);
2325 pack64_array(object->grp_tres_run_mins_ctld,
2326 object->usage->tres_cnt, buffer);
2327 pack64_array(object->grp_tres_ctld,
2328 object->usage->tres_cnt, buffer);
2329
2330 pack64_array(object->max_tres_mins_pj_ctld,
2331 object->usage->tres_cnt, buffer);
2332 pack64_array(object->max_tres_run_mins_pa_ctld,
2333 object->usage->tres_cnt, buffer);
2334 pack64_array(object->max_tres_run_mins_pu_ctld,
2335 object->usage->tres_cnt, buffer);
2336 pack64_array(object->max_tres_pa_ctld,
2337 object->usage->tres_cnt, buffer);
2338 pack64_array(object->max_tres_pj_ctld,
2339 object->usage->tres_cnt, buffer);
2340 pack64_array(object->max_tres_pn_ctld,
2341 object->usage->tres_cnt, buffer);
2342 pack64_array(object->max_tres_pu_ctld,
2343 object->usage->tres_cnt, buffer);
2344 pack64_array(object->min_tres_pj_ctld,
2345 object->usage->tres_cnt, buffer);
2346 } else {
2347 error("%s: version too old %u", __func__, protocol_version);
2348 return;
2349 }
2350
2351 slurmdb_pack_qos_usage(object->usage,
2352 protocol_version, buffer);
2353
2354 }
2355
slurmdb_unpack_qos_rec_with_usage(void ** object,uint16_t protocol_version,Buf buffer)2356 extern int slurmdb_unpack_qos_rec_with_usage(void **object,
2357 uint16_t protocol_version,
2358 Buf buffer)
2359 {
2360 int rc;
2361 slurmdb_qos_rec_t *object_ptr;
2362 uint32_t uint32_tmp;
2363
2364 if ((rc = slurmdb_unpack_qos_rec(object, protocol_version, buffer))
2365 != SLURM_SUCCESS)
2366 return rc;
2367
2368 object_ptr = *object;
2369
2370 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2371 safe_unpack64_array(&object_ptr->grp_tres_mins_ctld,
2372 &uint32_tmp, buffer);
2373 safe_unpack64_array(&object_ptr->grp_tres_run_mins_ctld,
2374 &uint32_tmp, buffer);
2375 safe_unpack64_array(&object_ptr->grp_tres_ctld,
2376 &uint32_tmp, buffer);
2377
2378 safe_unpack64_array(&object_ptr->max_tres_mins_pj_ctld,
2379 &uint32_tmp, buffer);
2380 safe_unpack64_array(&object_ptr->max_tres_run_mins_pa_ctld,
2381 &uint32_tmp, buffer);
2382 safe_unpack64_array(&object_ptr->max_tres_run_mins_pu_ctld,
2383 &uint32_tmp, buffer);
2384 safe_unpack64_array(&object_ptr->max_tres_pa_ctld,
2385 &uint32_tmp, buffer);
2386 safe_unpack64_array(&object_ptr->max_tres_pj_ctld,
2387 &uint32_tmp, buffer);
2388 safe_unpack64_array(&object_ptr->max_tres_pn_ctld,
2389 &uint32_tmp, buffer);
2390 safe_unpack64_array(&object_ptr->max_tres_pu_ctld,
2391 &uint32_tmp, buffer);
2392 safe_unpack64_array(&object_ptr->min_tres_pj_ctld,
2393 &uint32_tmp, buffer);
2394 } else {
2395 error("%s: version too old %u", __func__, protocol_version);
2396 goto unpack_error;
2397 }
2398
2399 rc = slurmdb_unpack_qos_usage((void **)&object_ptr->usage,
2400 protocol_version, buffer);
2401
2402 return rc;
2403
2404 unpack_error:
2405 slurmdb_destroy_qos_rec(object_ptr);
2406 *object = NULL;
2407 return SLURM_ERROR;
2408 }
2409
slurmdb_pack_reservation_rec(void * in,uint16_t protocol_version,Buf buffer)2410 extern void slurmdb_pack_reservation_rec(void *in, uint16_t protocol_version,
2411 Buf buffer)
2412 {
2413 slurmdb_reservation_rec_t *object = (slurmdb_reservation_rec_t *)in;
2414
2415 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
2416 if (!object) {
2417 packnull(buffer);
2418 packnull(buffer);
2419 pack64(NO_VAL64, buffer);
2420 pack32(NO_VAL, buffer);
2421 packnull(buffer);
2422 packnull(buffer);
2423 packnull(buffer);
2424 pack_time(0, buffer);
2425 pack_time(0, buffer);
2426 pack_time(0, buffer);
2427 packnull(buffer);
2428 pack32(NO_VAL, buffer);
2429 packdouble(0.0, buffer);
2430 return;
2431 }
2432
2433 packstr(object->assocs, buffer);
2434 packstr(object->cluster, buffer);
2435 pack64(object->flags, buffer);
2436 pack32(object->id, buffer);
2437 packstr(object->name, buffer);
2438 packstr(object->nodes, buffer);
2439 packstr(object->node_inx, buffer);
2440 pack_time(object->time_end, buffer);
2441 pack_time(object->time_start, buffer);
2442 pack_time(object->time_start_prev, buffer);
2443 packstr(object->tres_str, buffer);
2444
2445 slurm_pack_list(object->tres_list, slurmdb_pack_tres_rec,
2446 buffer, protocol_version);
2447
2448 packdouble(object->unused_wall, buffer);
2449 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2450 if (!object) {
2451 packnull(buffer);
2452 packnull(buffer);
2453 pack32(NO_VAL, buffer);
2454 pack32(NO_VAL, buffer);
2455 packnull(buffer);
2456 packnull(buffer);
2457 packnull(buffer);
2458 pack_time(0, buffer);
2459 pack_time(0, buffer);
2460 pack_time(0, buffer);
2461 packnull(buffer);
2462 pack32(NO_VAL, buffer);
2463 packdouble(0.0, buffer);
2464 return;
2465 }
2466
2467 packstr(object->assocs, buffer);
2468 packstr(object->cluster, buffer);
2469 pack32((uint32_t)object->flags, buffer);
2470 pack32(object->id, buffer);
2471 packstr(object->name, buffer);
2472 packstr(object->nodes, buffer);
2473 packstr(object->node_inx, buffer);
2474 pack_time(object->time_end, buffer);
2475 pack_time(object->time_start, buffer);
2476 pack_time(object->time_start_prev, buffer);
2477 packstr(object->tres_str, buffer);
2478
2479 slurm_pack_list(object->tres_list, slurmdb_pack_tres_rec,
2480 buffer, protocol_version);
2481
2482 packdouble(object->unused_wall, buffer);
2483 } else {
2484 error("%s: protocol_version %hu not supported",
2485 __func__, protocol_version);
2486 }
2487 }
2488
slurmdb_unpack_reservation_rec(void ** object,uint16_t protocol_version,Buf buffer)2489 extern int slurmdb_unpack_reservation_rec(void **object,
2490 uint16_t protocol_version,
2491 Buf buffer)
2492 {
2493 uint32_t uint32_tmp, count;
2494 int i;
2495 void *tmp_info;
2496 slurmdb_reservation_rec_t *object_ptr =
2497 xmalloc(sizeof(slurmdb_reservation_rec_t));
2498
2499 *object = object_ptr;
2500
2501 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
2502 safe_unpackstr_xmalloc(&object_ptr->assocs, &uint32_tmp,
2503 buffer);
2504 safe_unpackstr_xmalloc(&object_ptr->cluster, &uint32_tmp,
2505 buffer);
2506 safe_unpack64(&object_ptr->flags, buffer);
2507 safe_unpack32(&object_ptr->id, buffer);
2508 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
2509 safe_unpackstr_xmalloc(&object_ptr->nodes, &uint32_tmp, buffer);
2510 safe_unpackstr_xmalloc(&object_ptr->node_inx, &uint32_tmp,
2511 buffer);
2512 safe_unpack_time(&object_ptr->time_end, buffer);
2513 safe_unpack_time(&object_ptr->time_start, buffer);
2514 safe_unpack_time(&object_ptr->time_start_prev, buffer);
2515 safe_unpackstr_xmalloc(&object_ptr->tres_str,
2516 &uint32_tmp, buffer);
2517 safe_unpack32(&count, buffer);
2518 if (count != NO_VAL) {
2519 object_ptr->tres_list =
2520 list_create(slurmdb_destroy_tres_rec);
2521 for (i = 0; i < count; i++) {
2522 if (slurmdb_unpack_tres_rec(&tmp_info,
2523 protocol_version,
2524 buffer)
2525 != SLURM_SUCCESS)
2526 goto unpack_error;
2527 list_append(object_ptr->tres_list, tmp_info);
2528 }
2529 }
2530 safe_unpackdouble(&object_ptr->unused_wall, buffer);
2531 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2532 uint32_t flags;
2533 safe_unpackstr_xmalloc(&object_ptr->assocs, &uint32_tmp,
2534 buffer);
2535 safe_unpackstr_xmalloc(&object_ptr->cluster, &uint32_tmp,
2536 buffer);
2537 safe_unpack32(&flags, buffer);
2538 if (flags == NO_VAL)
2539 object_ptr->flags = NO_VAL64;
2540 else
2541 object_ptr->flags = flags;
2542 safe_unpack32(&object_ptr->id, buffer);
2543 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
2544 safe_unpackstr_xmalloc(&object_ptr->nodes, &uint32_tmp, buffer);
2545 safe_unpackstr_xmalloc(&object_ptr->node_inx, &uint32_tmp,
2546 buffer);
2547 safe_unpack_time(&object_ptr->time_end, buffer);
2548 safe_unpack_time(&object_ptr->time_start, buffer);
2549 safe_unpack_time(&object_ptr->time_start_prev, buffer);
2550 safe_unpackstr_xmalloc(&object_ptr->tres_str,
2551 &uint32_tmp, buffer);
2552 safe_unpack32(&count, buffer);
2553 if (count != NO_VAL) {
2554 object_ptr->tres_list =
2555 list_create(slurmdb_destroy_tres_rec);
2556 for (i=0; i<count; i++) {
2557 if (slurmdb_unpack_tres_rec(
2558 &tmp_info, protocol_version, buffer)
2559 != SLURM_SUCCESS)
2560 goto unpack_error;
2561 list_append(object_ptr->tres_list, tmp_info);
2562 }
2563 }
2564 safe_unpackdouble(&object_ptr->unused_wall, buffer);
2565 } else {
2566 error("%s: protocol_version %hu not supported",
2567 __func__, protocol_version);
2568 goto unpack_error;
2569 }
2570
2571 return SLURM_SUCCESS;
2572
2573 unpack_error:
2574 slurmdb_destroy_reservation_rec(object_ptr);
2575 *object = NULL;
2576 return SLURM_ERROR;
2577 }
2578
2579
slurmdb_pack_res_rec(void * in,uint16_t protocol_version,Buf buffer)2580 extern void slurmdb_pack_res_rec(void *in, uint16_t protocol_version, Buf buffer)
2581 {
2582 slurmdb_res_rec_t *object = (slurmdb_res_rec_t *)in;
2583
2584 if (!object) {
2585 pack32(NO_VAL, buffer); // clus_res_list
2586 pack32(NO_VAL, buffer); // clus_res_rec
2587 pack32(NO_VAL, buffer); // count
2588 packnull(buffer); // description
2589 pack32(SLURMDB_RES_FLAG_NOTSET, buffer); // flags
2590 pack32(NO_VAL, buffer); // id
2591 packnull(buffer); // manager
2592 packnull(buffer); // name
2593 pack16(0, buffer); // percent_used
2594 packnull(buffer); // server
2595 pack32(SLURMDB_RESOURCE_NOTSET, buffer); // type
2596
2597 return;
2598 }
2599
2600 slurm_pack_list(object->clus_res_list, slurmdb_pack_clus_res_rec,
2601 buffer, protocol_version);
2602
2603 if (object->clus_res_rec) {
2604 pack32(0, buffer); /* anything not NO_VAL */
2605 slurmdb_pack_clus_res_rec(
2606 object->clus_res_rec, protocol_version, buffer);
2607 } else
2608 pack32(NO_VAL, buffer);
2609
2610 pack32(object->count, buffer);
2611 packstr(object->description, buffer);
2612 pack32(object->flags, buffer);
2613 pack32(object->id, buffer);
2614 packstr(object->manager, buffer);
2615 packstr(object->name, buffer);
2616 pack16(object->percent_used, buffer);
2617 packstr(object->server, buffer);
2618 pack32(object->type, buffer);
2619 }
2620
slurmdb_unpack_res_rec(void ** object,uint16_t protocol_version,Buf buffer)2621 extern int slurmdb_unpack_res_rec(void **object, uint16_t protocol_version,
2622 Buf buffer)
2623 {
2624 uint32_t uint32_tmp;
2625 uint32_t count;
2626 int i;
2627 slurmdb_res_rec_t *object_ptr =
2628 xmalloc(sizeof(slurmdb_res_rec_t));
2629 slurmdb_clus_res_rec_t *clus_res;
2630
2631 *object = object_ptr;
2632
2633 slurmdb_init_res_rec(object_ptr, 0);
2634
2635 safe_unpack32(&count, buffer);
2636 if (count != NO_VAL) {
2637 object_ptr->clus_res_list =
2638 list_create(slurmdb_destroy_clus_res_rec);
2639 for (i=0; i<count; i++) {
2640 if (slurmdb_unpack_clus_res_rec(
2641 (void **)&clus_res, protocol_version, buffer)
2642 != SLURM_SUCCESS)
2643 goto unpack_error;
2644 list_append(object_ptr->clus_res_list, clus_res);
2645 }
2646 }
2647
2648 safe_unpack32(&count, buffer);
2649 if (count != NO_VAL) {
2650 if (slurmdb_unpack_clus_res_rec(
2651 (void **)&object_ptr->clus_res_rec,
2652 protocol_version, buffer) != SLURM_SUCCESS)
2653 goto unpack_error;
2654 }
2655
2656 safe_unpack32(&object_ptr->count, buffer);
2657 safe_unpackstr_xmalloc(&object_ptr->description, &uint32_tmp, buffer);
2658 safe_unpack32(&object_ptr->flags, buffer);
2659 safe_unpack32(&object_ptr->id, buffer);
2660 safe_unpackstr_xmalloc(&object_ptr->manager, &uint32_tmp, buffer);
2661 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
2662 safe_unpack16(&object_ptr->percent_used, buffer);
2663 safe_unpackstr_xmalloc(&object_ptr->server, &uint32_tmp, buffer);
2664 safe_unpack32(&object_ptr->type, buffer);
2665
2666 return SLURM_SUCCESS;
2667
2668 unpack_error:
2669 slurmdb_destroy_res_rec(object_ptr);
2670 *object = NULL;
2671 return SLURM_ERROR;
2672 }
2673
slurmdb_pack_txn_rec(void * in,uint16_t protocol_version,Buf buffer)2674 extern void slurmdb_pack_txn_rec(void *in, uint16_t protocol_version, Buf buffer)
2675 {
2676 slurmdb_txn_rec_t *object = (slurmdb_txn_rec_t *)in;
2677
2678 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2679 if (!object) {
2680 packnull(buffer);
2681 pack16(0, buffer);
2682 packnull(buffer);
2683 packnull(buffer);
2684 pack32(0, buffer);
2685 packnull(buffer);
2686 pack_time(0, buffer);
2687 packnull(buffer);
2688 packnull(buffer);
2689 return;
2690 }
2691
2692 packstr(object->accts, buffer);
2693 pack16(object->action, buffer);
2694 packstr(object->actor_name, buffer);
2695 packstr(object->clusters, buffer);
2696 pack32(object->id, buffer);
2697 packstr(object->set_info, buffer);
2698 pack_time(object->timestamp, buffer);
2699 packstr(object->users, buffer);
2700 packstr(object->where_query, buffer);
2701 }
2702 }
2703
slurmdb_unpack_txn_rec(void ** object,uint16_t protocol_version,Buf buffer)2704 extern int slurmdb_unpack_txn_rec(
2705 void **object, uint16_t protocol_version, Buf buffer)
2706 {
2707 uint32_t uint32_tmp;
2708 slurmdb_txn_rec_t *object_ptr = xmalloc(sizeof(slurmdb_txn_rec_t));
2709
2710 *object = object_ptr;
2711 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2712 safe_unpackstr_xmalloc(&object_ptr->accts,
2713 &uint32_tmp, buffer);
2714 safe_unpack16(&object_ptr->action, buffer);
2715 safe_unpackstr_xmalloc(&object_ptr->actor_name,
2716 &uint32_tmp, buffer);
2717 safe_unpackstr_xmalloc(&object_ptr->clusters,
2718 &uint32_tmp, buffer);
2719 safe_unpack32(&object_ptr->id, buffer);
2720 safe_unpackstr_xmalloc(&object_ptr->set_info,
2721 &uint32_tmp, buffer);
2722 safe_unpack_time(&object_ptr->timestamp, buffer);
2723 safe_unpackstr_xmalloc(&object_ptr->users,
2724 &uint32_tmp, buffer);
2725 safe_unpackstr_xmalloc(&object_ptr->where_query,
2726 &uint32_tmp, buffer);
2727 }
2728 return SLURM_SUCCESS;
2729
2730 unpack_error:
2731 slurmdb_destroy_txn_rec(object_ptr);
2732 *object = NULL;
2733 return SLURM_ERROR;
2734
2735 }
2736
slurmdb_pack_wckey_rec(void * in,uint16_t protocol_version,Buf buffer)2737 extern void slurmdb_pack_wckey_rec(void *in, uint16_t protocol_version,
2738 Buf buffer)
2739 {
2740 slurmdb_wckey_rec_t *object = (slurmdb_wckey_rec_t *)in;
2741
2742 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2743 if (!object) {
2744 pack32(NO_VAL, buffer);
2745
2746 packnull(buffer);
2747
2748 pack32(NO_VAL, buffer);
2749
2750 packnull(buffer);
2751
2752 pack32(NO_VAL, buffer);
2753
2754 packnull(buffer);
2755 return;
2756 }
2757
2758 slurm_pack_list(object->accounting_list,
2759 slurmdb_pack_accounting_rec,
2760 buffer, protocol_version);
2761
2762 packstr(object->cluster, buffer);
2763
2764 pack32(object->id, buffer);
2765
2766 pack16(object->is_def, buffer);
2767
2768 packstr(object->name, buffer);
2769
2770 pack32(object->uid, buffer);
2771
2772 packstr(object->user, buffer);
2773 }
2774 }
2775
slurmdb_unpack_wckey_rec(void ** object,uint16_t protocol_version,Buf buffer)2776 extern int slurmdb_unpack_wckey_rec(void **object, uint16_t protocol_version,
2777 Buf buffer)
2778 {
2779 uint32_t uint32_tmp;
2780 int i;
2781 uint32_t count;
2782 slurmdb_wckey_rec_t *object_ptr =
2783 xmalloc(sizeof(slurmdb_wckey_rec_t));
2784 slurmdb_accounting_rec_t *slurmdb_info = NULL;
2785
2786 *object = object_ptr;
2787
2788 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2789 safe_unpack32(&count, buffer);
2790 if (count > NO_VAL)
2791 goto unpack_error;
2792 if (count != NO_VAL) {
2793 object_ptr->accounting_list =
2794 list_create(slurmdb_destroy_accounting_rec);
2795 for (i = 0; i < count; i++) {
2796 if (slurmdb_unpack_accounting_rec(
2797 (void **)&slurmdb_info,
2798 protocol_version,
2799 buffer) == SLURM_ERROR)
2800 goto unpack_error;
2801 list_append(object_ptr->accounting_list,
2802 slurmdb_info);
2803 }
2804 }
2805
2806 safe_unpackstr_xmalloc(&object_ptr->cluster, &uint32_tmp,
2807 buffer);
2808
2809 safe_unpack32(&object_ptr->id, buffer);
2810
2811 safe_unpack16(&object_ptr->is_def, buffer);
2812
2813 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
2814
2815 safe_unpack32(&object_ptr->uid, buffer);
2816
2817 safe_unpackstr_xmalloc(&object_ptr->user, &uint32_tmp, buffer);
2818 }
2819
2820 return SLURM_SUCCESS;
2821
2822 unpack_error:
2823 slurmdb_destroy_wckey_rec(object_ptr);
2824 *object = NULL;
2825 return SLURM_ERROR;
2826 }
2827
slurmdb_pack_archive_rec(void * in,uint16_t protocol_version,Buf buffer)2828 extern void slurmdb_pack_archive_rec(void *in, uint16_t protocol_version,
2829 Buf buffer)
2830 {
2831 slurmdb_archive_rec_t *object = (slurmdb_archive_rec_t *)in;
2832
2833 if (!object) {
2834 packnull(buffer);
2835 packnull(buffer);
2836 return;
2837 }
2838
2839 packstr(object->archive_file, buffer);
2840 packstr(object->insert, buffer);
2841 }
2842
slurmdb_unpack_archive_rec(void ** object,uint16_t protocol_version,Buf buffer)2843 extern int slurmdb_unpack_archive_rec(void **object, uint16_t protocol_version,
2844 Buf buffer)
2845 {
2846 uint32_t uint32_tmp;
2847 slurmdb_archive_rec_t *object_ptr =
2848 xmalloc(sizeof(slurmdb_archive_rec_t));
2849
2850 *object = object_ptr;
2851
2852 safe_unpackstr_xmalloc(&object_ptr->archive_file, &uint32_tmp, buffer);
2853 safe_unpackstr_xmalloc(&object_ptr->insert, &uint32_tmp, buffer);
2854
2855 return SLURM_SUCCESS;
2856
2857 unpack_error:
2858 slurmdb_destroy_archive_rec(object_ptr);
2859 *object = NULL;
2860 return SLURM_ERROR;
2861
2862 }
2863
slurmdb_pack_tres_cond(void * in,uint16_t protocol_version,Buf buffer)2864 extern void slurmdb_pack_tres_cond(void *in, uint16_t protocol_version,
2865 Buf buffer)
2866 {
2867 slurmdb_tres_cond_t *object = (slurmdb_tres_cond_t *)in;
2868
2869 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2870 if (!object) {
2871 pack64(NO_VAL, buffer);
2872 pack32(NO_VAL, buffer);
2873 pack32(NO_VAL, buffer);
2874 pack32(NO_VAL, buffer);
2875 pack32(NO_VAL, buffer);
2876 pack16(0, buffer);
2877 return;
2878 }
2879
2880 pack64(object->count, buffer);
2881 _pack_list_of_str(object->format_list, buffer);
2882 _pack_list_of_str(object->id_list, buffer);
2883 _pack_list_of_str(object->name_list, buffer);
2884 _pack_list_of_str(object->type_list, buffer);
2885 pack16(object->with_deleted, buffer);
2886 }
2887 }
2888
slurmdb_unpack_tres_cond(void ** object,uint16_t protocol_version,Buf buffer)2889 extern int slurmdb_unpack_tres_cond(void **object, uint16_t protocol_version,
2890 Buf buffer)
2891 {
2892 uint32_t uint32_tmp;
2893 int i;
2894 uint32_t count;
2895 char *tmp_info = NULL;
2896 slurmdb_tres_cond_t *object_ptr =
2897 xmalloc(sizeof(slurmdb_tres_cond_t));
2898
2899 *object = object_ptr;
2900
2901 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
2902
2903 safe_unpack64(&object_ptr->count, buffer);
2904
2905 safe_unpack32(&count, buffer);
2906 if (count > NO_VAL)
2907 goto unpack_error;
2908 if (count != NO_VAL) {
2909 object_ptr->format_list = list_create(xfree_ptr);
2910 for (i = 0; i < count; i++) {
2911 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
2912 buffer);
2913 list_append(object_ptr->format_list, tmp_info);
2914 }
2915 }
2916
2917 safe_unpack32(&count, buffer);
2918 if (count > NO_VAL)
2919 goto unpack_error;
2920 if (count != NO_VAL) {
2921 if (!object_ptr->id_list)
2922 object_ptr->id_list = list_create(xfree_ptr);
2923 for (i=0; i<count; i++) {
2924 safe_unpackstr_xmalloc(
2925 &tmp_info, &uint32_tmp, buffer);
2926 list_append(object_ptr->id_list,
2927 tmp_info);
2928 }
2929 }
2930
2931 safe_unpack32(&count, buffer);
2932 if (count > NO_VAL)
2933 goto unpack_error;
2934 if (count != NO_VAL) {
2935 if (!object_ptr->name_list)
2936 object_ptr->name_list = list_create(xfree_ptr);
2937 for (i=0; i<count; i++) {
2938 safe_unpackstr_xmalloc(
2939 &tmp_info, &uint32_tmp, buffer);
2940 list_append(object_ptr->name_list,
2941 tmp_info);
2942 }
2943 }
2944 safe_unpack32(&count, buffer);
2945 if (count > NO_VAL)
2946 goto unpack_error;
2947 if (count != NO_VAL) {
2948 if (!object_ptr->type_list)
2949 object_ptr->type_list = list_create(xfree_ptr);
2950 for (i=0; i<count; i++) {
2951 safe_unpackstr_xmalloc(
2952 &tmp_info, &uint32_tmp, buffer);
2953 list_append(object_ptr->type_list,
2954 tmp_info);
2955 }
2956 }
2957
2958 safe_unpack16(&object_ptr->with_deleted, buffer);
2959 } else
2960 goto unpack_error;
2961
2962 return SLURM_SUCCESS;
2963
2964 unpack_error:
2965 slurmdb_destroy_tres_cond(object_ptr);
2966 *object = NULL;
2967
2968 return SLURM_ERROR;
2969 }
2970
slurmdb_pack_tres_rec(void * in,uint16_t protocol_version,Buf buffer)2971 extern void slurmdb_pack_tres_rec(void *in, uint16_t protocol_version,
2972 Buf buffer)
2973 {
2974 slurmdb_tres_rec_t *object = (slurmdb_tres_rec_t *)in;
2975
2976 if (!object) {
2977 pack64(0, buffer);
2978 pack64(0, buffer);
2979 pack32(0, buffer);
2980 packnull(buffer);
2981 packnull(buffer);
2982 return;
2983 }
2984
2985 pack64(object->alloc_secs, buffer);
2986 pack64(object->count, buffer);
2987 pack32(object->id, buffer);
2988 packstr(object->name, buffer);
2989 packstr(object->type, buffer);
2990 }
2991
slurmdb_unpack_tres_rec_noalloc(slurmdb_tres_rec_t * object_ptr,uint16_t protocol_version,Buf buffer)2992 extern int slurmdb_unpack_tres_rec_noalloc(
2993 slurmdb_tres_rec_t *object_ptr, uint16_t protocol_version, Buf buffer)
2994 {
2995 uint32_t uint32_tmp;
2996
2997 safe_unpack64(&object_ptr->alloc_secs, buffer);
2998 safe_unpack64(&object_ptr->count, buffer);
2999 safe_unpack32(&object_ptr->id, buffer);
3000 safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
3001 safe_unpackstr_xmalloc(&object_ptr->type, &uint32_tmp, buffer);
3002
3003 return SLURM_SUCCESS;
3004
3005 unpack_error:
3006 return SLURM_ERROR;
3007
3008 }
3009
slurmdb_unpack_tres_rec(void ** object,uint16_t protocol_version,Buf buffer)3010 extern int slurmdb_unpack_tres_rec(void **object, uint16_t protocol_version,
3011 Buf buffer)
3012 {
3013 int rc;
3014 slurmdb_tres_rec_t *object_ptr =
3015 xmalloc(sizeof(slurmdb_tres_rec_t));
3016
3017 *object = object_ptr;
3018
3019 rc = slurmdb_unpack_tres_rec_noalloc(object_ptr, protocol_version,
3020 buffer);
3021
3022 if (rc != SLURM_SUCCESS) {
3023 slurmdb_destroy_tres_rec(object_ptr);
3024 *object = NULL;
3025 }
3026
3027 return rc;
3028 }
3029
slurmdb_pack_user_cond(void * in,uint16_t protocol_version,Buf buffer)3030 extern void slurmdb_pack_user_cond(void *in, uint16_t protocol_version, Buf buffer)
3031 {
3032 slurmdb_user_cond_t *object = (slurmdb_user_cond_t *)in;
3033
3034 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3035 if (!object) {
3036 pack16(0, buffer);
3037 slurmdb_pack_assoc_cond(
3038 NULL, protocol_version, buffer);
3039 pack32(NO_VAL, buffer);
3040 pack32(NO_VAL, buffer);
3041 pack16(0, buffer);
3042 pack16(0, buffer);
3043 pack16(0, buffer);
3044 pack16(0, buffer);
3045 return;
3046 }
3047
3048 pack16(object->admin_level, buffer);
3049
3050 slurmdb_pack_assoc_cond(object->assoc_cond,
3051 protocol_version, buffer);
3052
3053 _pack_list_of_str(object->def_acct_list, buffer);
3054 _pack_list_of_str(object->def_wckey_list, buffer);
3055
3056 pack16(object->with_assocs, buffer);
3057 pack16(object->with_coords, buffer);
3058 pack16(object->with_deleted, buffer);
3059 pack16(object->with_wckeys, buffer);
3060 }
3061 }
3062
slurmdb_unpack_user_cond(void ** object,uint16_t protocol_version,Buf buffer)3063 extern int slurmdb_unpack_user_cond(void **object, uint16_t protocol_version,
3064 Buf buffer)
3065 {
3066 uint32_t uint32_tmp;
3067 int i;
3068 uint32_t count;
3069 slurmdb_user_cond_t *object_ptr = xmalloc(sizeof(slurmdb_user_cond_t));
3070 char *tmp_info = NULL;
3071
3072 *object = object_ptr;
3073
3074 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3075 safe_unpack16(&object_ptr->admin_level, buffer);
3076
3077 if (slurmdb_unpack_assoc_cond(
3078 (void **)&object_ptr->assoc_cond,
3079 protocol_version, buffer) == SLURM_ERROR)
3080 goto unpack_error;
3081
3082 safe_unpack32(&count, buffer);
3083 if (count > NO_VAL)
3084 goto unpack_error;
3085 if (count != NO_VAL) {
3086 if (!object_ptr->def_acct_list)
3087 object_ptr->def_acct_list =
3088 list_create(xfree_ptr);
3089 for (i = 0; i < count; i++) {
3090 safe_unpackstr_xmalloc(
3091 &tmp_info, &uint32_tmp, buffer);
3092 list_append(object_ptr->def_acct_list,
3093 tmp_info);
3094 }
3095 }
3096
3097 safe_unpack32(&count, buffer);
3098 if (count > NO_VAL)
3099 goto unpack_error;
3100 if (count != NO_VAL) {
3101 object_ptr->def_wckey_list = list_create(xfree_ptr);
3102 for (i = 0; i < count; i++) {
3103 safe_unpackstr_xmalloc(&tmp_info,
3104 &uint32_tmp, buffer);
3105 list_append(object_ptr->def_wckey_list,
3106 tmp_info);
3107 }
3108 }
3109 safe_unpack16(&object_ptr->with_assocs, buffer);
3110 safe_unpack16(&object_ptr->with_coords, buffer);
3111 safe_unpack16(&object_ptr->with_deleted, buffer);
3112 safe_unpack16(&object_ptr->with_wckeys, buffer);
3113 }
3114
3115 return SLURM_SUCCESS;
3116
3117 unpack_error:
3118 slurmdb_destroy_user_cond(object_ptr);
3119 *object = NULL;
3120 return SLURM_ERROR;
3121 }
3122
slurmdb_pack_account_cond(void * in,uint16_t protocol_version,Buf buffer)3123 extern void slurmdb_pack_account_cond(void *in, uint16_t protocol_version,
3124 Buf buffer)
3125 {
3126 slurmdb_account_cond_t *object = (slurmdb_account_cond_t *)in;
3127
3128 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3129 if (!object) {
3130 slurmdb_pack_assoc_cond(NULL, protocol_version,
3131 buffer);
3132 pack32(NO_VAL, buffer);
3133 pack32(NO_VAL, buffer);
3134 pack16(0, buffer);
3135 pack16(0, buffer);
3136 pack16(0, buffer);
3137 return;
3138 }
3139 slurmdb_pack_assoc_cond(object->assoc_cond,
3140 protocol_version, buffer);
3141
3142 _pack_list_of_str(object->description_list, buffer);
3143 _pack_list_of_str(object->organization_list, buffer);
3144
3145 pack16(object->with_assocs, buffer);
3146 pack16(object->with_coords, buffer);
3147 pack16(object->with_deleted, buffer);
3148 }
3149 }
3150
slurmdb_unpack_account_cond(void ** object,uint16_t protocol_version,Buf buffer)3151 extern int slurmdb_unpack_account_cond(void **object, uint16_t protocol_version,
3152 Buf buffer)
3153 {
3154 uint32_t uint32_tmp;
3155 int i;
3156 uint32_t count;
3157 slurmdb_account_cond_t *object_ptr =
3158 xmalloc(sizeof(slurmdb_account_cond_t));
3159 char *tmp_info = NULL;
3160
3161 *object = object_ptr;
3162
3163 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3164 if (slurmdb_unpack_assoc_cond(
3165 (void **)&object_ptr->assoc_cond,
3166 protocol_version, buffer) == SLURM_ERROR)
3167 goto unpack_error;
3168
3169 safe_unpack32(&count, buffer);
3170 if (count != NO_VAL) {
3171 object_ptr->description_list = list_create(xfree_ptr);
3172 for(i=0; i<count; i++) {
3173 safe_unpackstr_xmalloc(&tmp_info,
3174 &uint32_tmp, buffer);
3175 list_append(object_ptr->description_list,
3176 tmp_info);
3177 }
3178 }
3179 safe_unpack32(&count, buffer);
3180 if (count != NO_VAL) {
3181 object_ptr->organization_list = list_create(xfree_ptr);
3182 for(i=0; i<count; i++) {
3183 safe_unpackstr_xmalloc(&tmp_info,
3184 &uint32_tmp, buffer);
3185 list_append(object_ptr->organization_list,
3186 tmp_info);
3187 }
3188 }
3189
3190 safe_unpack16(&object_ptr->with_assocs, buffer);
3191 safe_unpack16(&object_ptr->with_coords, buffer);
3192 safe_unpack16(&object_ptr->with_deleted, buffer);
3193 }
3194 return SLURM_SUCCESS;
3195
3196 unpack_error:
3197 slurmdb_destroy_account_cond(object_ptr);
3198 *object = NULL;
3199 return SLURM_ERROR;
3200 }
3201
slurmdb_pack_cluster_cond(void * in,uint16_t protocol_version,Buf buffer)3202 extern void slurmdb_pack_cluster_cond(void *in, uint16_t protocol_version,
3203 Buf buffer)
3204 {
3205 slurmdb_cluster_cond_t *object = (slurmdb_cluster_cond_t *)in;
3206
3207 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3208 if (!object) {
3209 pack16(0, buffer);
3210 pack32(NO_VAL, buffer);
3211 pack32(NO_VAL, buffer);
3212 pack32(NO_VAL, buffer);
3213 pack32(NO_VAL, buffer);
3214 pack32(NO_VAL, buffer);
3215 pack32(NO_VAL, buffer);
3216 pack_time(0, buffer);
3217 pack_time(0, buffer);
3218 pack16(0, buffer);
3219 pack16(0, buffer);
3220 return;
3221 }
3222
3223 pack16(object->classification, buffer);
3224
3225 _pack_list_of_str(object->cluster_list, buffer);
3226 _pack_list_of_str(object->federation_list, buffer);
3227
3228 pack32(object->flags, buffer);
3229
3230 _pack_list_of_str(object->format_list, buffer);
3231 _pack_list_of_str(object->plugin_id_select_list, buffer);
3232 _pack_list_of_str(object->rpc_version_list, buffer);
3233
3234 pack_time(object->usage_end, buffer);
3235 pack_time(object->usage_start, buffer);
3236
3237 pack16(object->with_usage, buffer);
3238 pack16(object->with_deleted, buffer);
3239 }
3240 }
3241
slurmdb_unpack_cluster_cond(void ** object,uint16_t protocol_version,Buf buffer)3242 extern int slurmdb_unpack_cluster_cond(void **object, uint16_t protocol_version,
3243 Buf buffer)
3244 {
3245 uint32_t uint32_tmp;
3246 int i;
3247 uint32_t count;
3248 slurmdb_cluster_cond_t *object_ptr =
3249 xmalloc(sizeof(slurmdb_cluster_cond_t));
3250 char *tmp_info = NULL;
3251
3252 *object = object_ptr;
3253
3254 slurmdb_init_cluster_cond(object_ptr, 0);
3255 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3256 safe_unpack16(&object_ptr->classification, buffer);
3257 safe_unpack32(&count, buffer);
3258 if (count > NO_VAL)
3259 goto unpack_error;
3260 if (count && (count != NO_VAL)) {
3261 object_ptr->cluster_list = list_create(xfree_ptr);
3262 for (i = 0; i < count; i++) {
3263 safe_unpackstr_xmalloc(&tmp_info,
3264 &uint32_tmp, buffer);
3265 list_append(object_ptr->cluster_list, tmp_info);
3266 }
3267 }
3268
3269 safe_unpack32(&count, buffer);
3270 if (count > NO_VAL)
3271 goto unpack_error;
3272 if (count && (count != NO_VAL)) {
3273 object_ptr->federation_list = list_create(xfree_ptr);
3274 for (i = 0; i < count; i++) {
3275 safe_unpackstr_xmalloc(&tmp_info,
3276 &uint32_tmp, buffer);
3277 list_append(object_ptr->federation_list,
3278 tmp_info);
3279 }
3280 }
3281
3282 safe_unpack32(&object_ptr->flags, buffer);
3283
3284 safe_unpack32(&count, buffer);
3285 if (count > NO_VAL)
3286 goto unpack_error;
3287 if (count && (count != NO_VAL)) {
3288 object_ptr->format_list = list_create(xfree_ptr);
3289 for (i = 0; i < count; i++) {
3290 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3291 buffer);
3292 list_append(object_ptr->format_list, tmp_info);
3293 }
3294 }
3295
3296 safe_unpack32(&count, buffer);
3297 if (count > NO_VAL)
3298 goto unpack_error;
3299 if (count && (count != NO_VAL)) {
3300 object_ptr->plugin_id_select_list =
3301 list_create(xfree_ptr);
3302 for (i = 0; i < count; i++) {
3303 safe_unpackstr_xmalloc(&tmp_info,
3304 &uint32_tmp, buffer);
3305 list_append(object_ptr->plugin_id_select_list,
3306 tmp_info);
3307 }
3308 }
3309
3310 safe_unpack32(&count, buffer);
3311 if (count > NO_VAL)
3312 goto unpack_error;
3313 if (count && (count != NO_VAL)) {
3314 object_ptr->rpc_version_list = list_create(xfree_ptr);
3315 for (i = 0; i < count; i++) {
3316 safe_unpackstr_xmalloc(&tmp_info,
3317 &uint32_tmp, buffer);
3318 list_append(object_ptr->rpc_version_list,
3319 tmp_info);
3320 }
3321 }
3322
3323 safe_unpack_time(&object_ptr->usage_end, buffer);
3324 safe_unpack_time(&object_ptr->usage_start, buffer);
3325
3326 safe_unpack16(&object_ptr->with_usage, buffer);
3327 safe_unpack16(&object_ptr->with_deleted, buffer);
3328 } else
3329 goto unpack_error;
3330
3331 return SLURM_SUCCESS;
3332
3333 unpack_error:
3334 slurmdb_destroy_cluster_cond(object_ptr);
3335 *object = NULL;
3336 return SLURM_ERROR;
3337 }
3338
slurmdb_pack_federation_cond(void * in,uint16_t protocol_version,Buf buffer)3339 extern void slurmdb_pack_federation_cond(void *in, uint16_t protocol_version,
3340 Buf buffer)
3341 {
3342 slurmdb_federation_cond_t *object = (slurmdb_federation_cond_t *)in;
3343
3344 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3345 if (!object) {
3346 pack32(NO_VAL, buffer);
3347 pack32(NO_VAL, buffer);
3348 pack32(NO_VAL, buffer);
3349 pack16(0, buffer);
3350 return;
3351 }
3352
3353 _pack_list_of_str(object->cluster_list, buffer);
3354 _pack_list_of_str(object->federation_list, buffer);
3355 _pack_list_of_str(object->format_list, buffer);
3356
3357 pack16(object->with_deleted, buffer);
3358 }
3359 }
3360
slurmdb_unpack_federation_cond(void ** object,uint16_t protocol_version,Buf buffer)3361 extern int slurmdb_unpack_federation_cond(void **object,
3362 uint16_t protocol_version,
3363 Buf buffer)
3364 {
3365 uint32_t uint32_tmp;
3366 int i;
3367 uint32_t count;
3368 slurmdb_federation_cond_t *object_ptr =
3369 xmalloc(sizeof(slurmdb_federation_cond_t));
3370 char *tmp_info = NULL;
3371
3372 *object = object_ptr;
3373
3374 slurmdb_init_federation_cond(object_ptr, 0);
3375 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3376 safe_unpack32(&count, buffer);
3377 if (count > NO_VAL)
3378 goto unpack_error;
3379 if (count && (count != NO_VAL)) {
3380 object_ptr->cluster_list = list_create(xfree_ptr);
3381 for (i = 0; i < count; i++) {
3382 safe_unpackstr_xmalloc(&tmp_info,
3383 &uint32_tmp, buffer);
3384 list_append(object_ptr->cluster_list,
3385 tmp_info);
3386 }
3387 }
3388
3389 safe_unpack32(&count, buffer);
3390 if (count > NO_VAL)
3391 goto unpack_error;
3392 if (count && (count != NO_VAL)) {
3393 object_ptr->federation_list = list_create(xfree_ptr);
3394 for (i = 0; i < count; i++) {
3395 safe_unpackstr_xmalloc(&tmp_info,
3396 &uint32_tmp, buffer);
3397 list_append(object_ptr->federation_list,
3398 tmp_info);
3399 }
3400 }
3401
3402 safe_unpack32(&count, buffer);
3403 if (count > NO_VAL)
3404 goto unpack_error;
3405 if (count && (count != NO_VAL)) {
3406 object_ptr->format_list = list_create(xfree_ptr);
3407 for (i = 0; i < count; i++) {
3408 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3409 buffer);
3410 list_append(object_ptr->format_list, tmp_info);
3411 }
3412 }
3413
3414 safe_unpack16(&object_ptr->with_deleted, buffer);
3415 } else
3416 goto unpack_error;
3417
3418 return SLURM_SUCCESS;
3419
3420 unpack_error:
3421 slurmdb_destroy_federation_cond(object_ptr);
3422 *object = NULL;
3423 return SLURM_ERROR;
3424 }
3425
slurmdb_pack_assoc_cond(void * in,uint16_t protocol_version,Buf buffer)3426 extern void slurmdb_pack_assoc_cond(void *in, uint16_t protocol_version,
3427 Buf buffer)
3428 {
3429 slurmdb_assoc_cond_t *object = (slurmdb_assoc_cond_t *)in;
3430
3431 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3432 if (!object) {
3433 pack32(NO_VAL, buffer);
3434 pack32(NO_VAL, buffer);
3435
3436 pack32(NO_VAL, buffer);
3437
3438 pack32(NO_VAL, buffer);
3439 pack32(NO_VAL, buffer);
3440
3441 pack16(0, buffer);
3442
3443 pack32(NO_VAL, buffer);
3444 pack32(NO_VAL, buffer);
3445
3446 pack32(NO_VAL, buffer);
3447
3448 pack_time(0, buffer);
3449 pack_time(0, buffer);
3450
3451 pack32(NO_VAL, buffer);
3452
3453 pack16(0, buffer);
3454 pack16(0, buffer);
3455 pack16(0, buffer);
3456 pack16(0, buffer);
3457 pack16(0, buffer);
3458 pack16(0, buffer);
3459 return;
3460 }
3461
3462 _pack_list_of_str(object->acct_list, buffer);
3463 _pack_list_of_str(object->cluster_list, buffer);
3464 _pack_list_of_str(object->def_qos_id_list, buffer);
3465 _pack_list_of_str(object->format_list, buffer);
3466 _pack_list_of_str(object->id_list, buffer);
3467
3468 pack16(object->only_defs, buffer);
3469
3470 _pack_list_of_str(object->partition_list, buffer);
3471 _pack_list_of_str(object->parent_acct_list, buffer);
3472 _pack_list_of_str(object->qos_list, buffer);
3473
3474 pack_time(object->usage_end, buffer);
3475 pack_time(object->usage_start, buffer);
3476
3477 _pack_list_of_str(object->user_list, buffer);
3478
3479 pack16(object->with_usage, buffer);
3480 pack16(object->with_deleted, buffer);
3481 pack16(object->with_raw_qos, buffer);
3482 pack16(object->with_sub_accts, buffer);
3483 pack16(object->without_parent_info, buffer);
3484 pack16(object->without_parent_limits, buffer);
3485 } else {
3486 error("%s: protocol_version %hu not supported",
3487 __func__, protocol_version);
3488 }
3489 }
3490
slurmdb_unpack_assoc_cond(void ** object,uint16_t protocol_version,Buf buffer)3491 extern int slurmdb_unpack_assoc_cond(void **object,
3492 uint16_t protocol_version, Buf buffer)
3493 {
3494 uint32_t uint32_tmp;
3495 int i;
3496 uint32_t count;
3497 slurmdb_assoc_cond_t *object_ptr =
3498 xmalloc(sizeof(slurmdb_assoc_cond_t));
3499 char *tmp_info = NULL;
3500 *object = object_ptr;
3501
3502 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3503 safe_unpack32(&count, buffer);
3504 if (count > NO_VAL)
3505 goto unpack_error;
3506 if (count != NO_VAL) {
3507 object_ptr->acct_list = list_create(xfree_ptr);
3508 for (i = 0; i < count; i++) {
3509 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3510 buffer);
3511 list_append(object_ptr->acct_list, tmp_info);
3512 }
3513 }
3514 safe_unpack32(&count, buffer);
3515 if (count > NO_VAL)
3516 goto unpack_error;
3517 if (count != NO_VAL) {
3518 object_ptr->cluster_list = list_create(xfree_ptr);
3519 for (i = 0; i < count; i++) {
3520 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3521 buffer);
3522 list_append(object_ptr->cluster_list,
3523 tmp_info);
3524 }
3525 }
3526
3527 safe_unpack32(&count, buffer);
3528 if (count > NO_VAL)
3529 goto unpack_error;
3530 if (count != NO_VAL) {
3531 object_ptr->def_qos_id_list = list_create(xfree_ptr);
3532 for (i = 0; i < count; i++) {
3533 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3534 buffer);
3535 list_append(object_ptr->def_qos_id_list,
3536 tmp_info);
3537 }
3538 }
3539
3540 safe_unpack32(&count, buffer);
3541 if (count > NO_VAL)
3542 goto unpack_error;
3543 if (count && (count != NO_VAL)) {
3544 object_ptr->format_list = list_create(xfree_ptr);
3545 for (i = 0; i < count; i++) {
3546 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3547 buffer);
3548 list_append(object_ptr->format_list, tmp_info);
3549 }
3550 }
3551
3552 safe_unpack32(&count, buffer);
3553 if (count != NO_VAL) {
3554 object_ptr->id_list = list_create(xfree_ptr);
3555 for(i=0; i<count; i++) {
3556 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3557 buffer);
3558 list_append(object_ptr->id_list, tmp_info);
3559 }
3560 }
3561
3562 safe_unpack16(&object_ptr->only_defs, buffer);
3563
3564 safe_unpack32(&count, buffer);
3565 if (count > NO_VAL)
3566 goto unpack_error;
3567 if (count != NO_VAL) {
3568 object_ptr->partition_list = list_create(xfree_ptr);
3569 for (i = 0; i < count; i++) {
3570 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3571 buffer);
3572 list_append(object_ptr->partition_list,
3573 tmp_info);
3574 }
3575 }
3576
3577 safe_unpack32(&count, buffer);
3578 if (count > NO_VAL)
3579 goto unpack_error;
3580 if (count != NO_VAL) {
3581 object_ptr->parent_acct_list = list_create(xfree_ptr);
3582 for (i = 0; i < count; i++) {
3583 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3584 buffer);
3585 list_append(object_ptr->parent_acct_list,
3586 tmp_info);
3587 }
3588 }
3589
3590 safe_unpack32(&count, buffer);
3591 if (count > NO_VAL)
3592 goto unpack_error;
3593 if (count != NO_VAL) {
3594 object_ptr->qos_list = list_create(xfree_ptr);
3595 for (i = 0; i < count; i++) {
3596 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3597 buffer);
3598 list_append(object_ptr->qos_list, tmp_info);
3599 }
3600 }
3601
3602 safe_unpack_time(&object_ptr->usage_end, buffer);
3603 safe_unpack_time(&object_ptr->usage_start, buffer);
3604
3605 safe_unpack32(&count, buffer);
3606 if (count > NO_VAL)
3607 goto unpack_error;
3608 if (count != NO_VAL) {
3609 object_ptr->user_list = list_create(xfree_ptr);
3610 for (i = 0; i < count; i++) {
3611 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3612 buffer);
3613 list_append(object_ptr->user_list, tmp_info);
3614 }
3615 }
3616
3617 safe_unpack16(&object_ptr->with_usage, buffer);
3618 safe_unpack16(&object_ptr->with_deleted, buffer);
3619 safe_unpack16(&object_ptr->with_raw_qos, buffer);
3620 safe_unpack16(&object_ptr->with_sub_accts, buffer);
3621 safe_unpack16(&object_ptr->without_parent_info, buffer);
3622 safe_unpack16(&object_ptr->without_parent_limits, buffer);
3623 } else {
3624 error("%s: protocol_version %hu not supported",
3625 __func__, protocol_version);
3626 goto unpack_error;
3627 }
3628
3629 return SLURM_SUCCESS;
3630
3631 unpack_error:
3632 slurmdb_destroy_assoc_cond(object_ptr);
3633 *object = NULL;
3634 return SLURM_ERROR;
3635 }
3636
slurmdb_pack_event_cond(void * in,uint16_t protocol_version,Buf buffer)3637 extern void slurmdb_pack_event_cond(void *in, uint16_t protocol_version,
3638 Buf buffer)
3639 {
3640 slurmdb_event_cond_t *object = (slurmdb_event_cond_t *)in;
3641
3642 xassert(object);
3643
3644 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
3645 _pack_list_of_str(object->cluster_list, buffer);
3646
3647 pack32(object->cpus_max, buffer);
3648 pack32(object->cpus_min, buffer);
3649 pack16(object->event_type, buffer);
3650
3651 _pack_list_of_str(object->format_list, buffer);
3652
3653 packstr(object->node_list, buffer);
3654
3655 pack_time(object->period_end, buffer);
3656 pack_time(object->period_start, buffer);
3657
3658 _pack_list_of_str(object->reason_list, buffer);
3659 _pack_list_of_str(object->reason_uid_list, buffer);
3660 _pack_list_of_str(object->state_list, buffer);
3661 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3662 List tmp_list = NULL;
3663
3664 _pack_list_of_str(object->cluster_list, buffer);
3665
3666 pack32(object->cpus_max, buffer);
3667 pack32(object->cpus_min, buffer);
3668 pack16(object->event_type, buffer);
3669
3670 _pack_list_of_str(object->format_list, buffer);
3671
3672 if (object->node_list) {
3673 tmp_list = list_create(xfree_ptr);
3674 slurm_addto_char_list(tmp_list, object->node_list);
3675 }
3676 _pack_list_of_str(tmp_list, buffer);
3677
3678 pack_time(object->period_end, buffer);
3679 pack_time(object->period_start, buffer);
3680
3681 _pack_list_of_str(object->reason_list, buffer);
3682 _pack_list_of_str(object->reason_uid_list, buffer);
3683 _pack_list_of_str(object->state_list, buffer);
3684 }
3685 }
3686
slurmdb_unpack_event_cond(void ** object,uint16_t protocol_version,Buf buffer)3687 extern int slurmdb_unpack_event_cond(void **object, uint16_t protocol_version,
3688 Buf buffer)
3689 {
3690 uint32_t uint32_tmp;
3691 int i;
3692 uint32_t count;
3693 slurmdb_event_cond_t *object_ptr =
3694 xmalloc(sizeof(slurmdb_event_cond_t));
3695 char *tmp_info = NULL;
3696
3697 *object = object_ptr;
3698
3699 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
3700 safe_unpack32(&count, buffer);
3701 if (count > NO_VAL)
3702 goto unpack_error;
3703 if (count != NO_VAL) {
3704 object_ptr->cluster_list = list_create(xfree_ptr);
3705 for (i = 0; i < count; i++) {
3706 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3707 buffer);
3708 list_append(object_ptr->cluster_list, tmp_info);
3709 }
3710 }
3711 safe_unpack32(&object_ptr->cpus_max, buffer);
3712 safe_unpack32(&object_ptr->cpus_min, buffer);
3713 safe_unpack16(&object_ptr->event_type, buffer);
3714
3715 safe_unpack32(&count, buffer);
3716 if (count > NO_VAL)
3717 goto unpack_error;
3718 if (count && (count != NO_VAL)) {
3719 object_ptr->format_list = list_create(xfree_ptr);
3720 for (i = 0; i < count; i++) {
3721 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3722 buffer);
3723 list_append(object_ptr->format_list, tmp_info);
3724 }
3725 }
3726
3727 safe_unpackstr_xmalloc(&object_ptr->node_list, &uint32_tmp,
3728 buffer);
3729
3730 safe_unpack_time(&object_ptr->period_end, buffer);
3731 safe_unpack_time(&object_ptr->period_start, buffer);
3732
3733 safe_unpack32(&count, buffer);
3734 if (count > NO_VAL)
3735 goto unpack_error;
3736 if (count != NO_VAL) {
3737 object_ptr->reason_list = list_create(xfree_ptr);
3738 for (i = 0; i < count; i++) {
3739 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3740 buffer);
3741 list_append(object_ptr->reason_list, tmp_info);
3742 }
3743 }
3744
3745 safe_unpack32(&count, buffer);
3746 if (count > NO_VAL)
3747 goto unpack_error;
3748 if (count != NO_VAL) {
3749 object_ptr->reason_uid_list = list_create(xfree_ptr);
3750 for (i = 0; i < count; i++) {
3751 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3752 buffer);
3753 list_append(object_ptr->reason_uid_list,
3754 tmp_info);
3755 }
3756 }
3757
3758 safe_unpack32(&count, buffer);
3759 if (count > NO_VAL)
3760 goto unpack_error;
3761 if (count != NO_VAL) {
3762 object_ptr->state_list = list_create(xfree_ptr);
3763 for (i = 0; i < count; i++) {
3764 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3765 buffer);
3766 list_append(object_ptr->state_list, tmp_info);
3767 }
3768 }
3769 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3770 safe_unpack32(&count, buffer);
3771 if (count > NO_VAL)
3772 goto unpack_error;
3773 if (count != NO_VAL) {
3774 object_ptr->cluster_list = list_create(xfree_ptr);
3775 for (i = 0; i < count; i++) {
3776 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3777 buffer);
3778 list_append(object_ptr->cluster_list, tmp_info);
3779 }
3780 }
3781 safe_unpack32(&object_ptr->cpus_max, buffer);
3782 safe_unpack32(&object_ptr->cpus_min, buffer);
3783 safe_unpack16(&object_ptr->event_type, buffer);
3784
3785 safe_unpack32(&count, buffer);
3786 if (count > NO_VAL)
3787 goto unpack_error;
3788 if (count && (count != NO_VAL)) {
3789 object_ptr->format_list = list_create(xfree_ptr);
3790 for (i = 0; i < count; i++) {
3791 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3792 buffer);
3793 list_append(object_ptr->format_list, tmp_info);
3794 }
3795 }
3796
3797 safe_unpack32(&count, buffer);
3798 if (count > NO_VAL)
3799 goto unpack_error;
3800 if (count != NO_VAL) {
3801 for (i = 0; i < count; i++) {
3802 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3803 buffer);
3804 xstrfmtcat(object_ptr->node_list, "%s%s",
3805 (object_ptr->node_list ? "," : ""),
3806 tmp_info);
3807 xfree(tmp_info);
3808 }
3809 }
3810
3811 safe_unpack_time(&object_ptr->period_end, buffer);
3812 safe_unpack_time(&object_ptr->period_start, buffer);
3813
3814 safe_unpack32(&count, buffer);
3815 if (count > NO_VAL)
3816 goto unpack_error;
3817 if (count != NO_VAL) {
3818 object_ptr->reason_list = list_create(xfree_ptr);
3819 for (i = 0; i < count; i++) {
3820 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3821 buffer);
3822 list_append(object_ptr->reason_list, tmp_info);
3823 }
3824 }
3825
3826 safe_unpack32(&count, buffer);
3827 if (count > NO_VAL)
3828 goto unpack_error;
3829 if (count != NO_VAL) {
3830 object_ptr->reason_uid_list = list_create(xfree_ptr);
3831 for (i = 0; i < count; i++) {
3832 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3833 buffer);
3834 list_append(object_ptr->reason_uid_list,
3835 tmp_info);
3836 }
3837 }
3838
3839 safe_unpack32(&count, buffer);
3840 if (count > NO_VAL)
3841 goto unpack_error;
3842 if (count != NO_VAL) {
3843 object_ptr->state_list = list_create(xfree_ptr);
3844 for (i = 0; i < count; i++) {
3845 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
3846 buffer);
3847 list_append(object_ptr->state_list, tmp_info);
3848 }
3849 }
3850 } else
3851 goto unpack_error;
3852
3853 return SLURM_SUCCESS;
3854
3855 unpack_error:
3856 slurmdb_destroy_event_cond(object_ptr);
3857 *object = NULL;
3858 return SLURM_ERROR;
3859 }
3860
slurmdb_pack_job_cond(void * in,uint16_t protocol_version,Buf buffer)3861 extern void slurmdb_pack_job_cond(void *in, uint16_t protocol_version,
3862 Buf buffer)
3863 {
3864 slurmdb_job_cond_t *object = (slurmdb_job_cond_t *)in;
3865
3866 if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
3867 if (!object) {
3868 pack32(NO_VAL, buffer); /* count(acct_list) */
3869 pack32(NO_VAL, buffer); /* count(associd_list) */
3870 pack32(NO_VAL, buffer); /* count(cluster_list) */
3871 pack32(NO_VAL, buffer); /* count(constraint_list) */
3872 pack32(0, buffer); /* cpus_max */
3873 pack32(0, buffer); /* cpus_min */
3874 pack32(SLURMDB_JOB_FLAG_NOTSET, buffer); /* db_flags */
3875 pack32(0, buffer); /* exitcode */
3876 pack32(0, buffer); /* job cond flags */
3877 pack32(NO_VAL, buffer); /* count(format_list) */
3878 pack32(NO_VAL, buffer); /* count(groupid_list) */
3879 pack32(NO_VAL, buffer); /* count(jobname_list) */
3880 pack32(0, buffer); /* nodes_max */
3881 pack32(0, buffer); /* nodes_min */
3882 pack32(NO_VAL, buffer); /* count(partition_list) */
3883 pack32(NO_VAL, buffer); /* count(qos_list) */
3884 pack32(NO_VAL, buffer); /* count(reason_list) */
3885 pack32(NO_VAL, buffer); /* count(resv_list) */
3886 pack32(NO_VAL, buffer); /* count(resvid_list) */
3887 pack32(NO_VAL, buffer); /* count(step_list) */
3888 pack32(NO_VAL, buffer); /* count(state_list) */
3889 pack32(0, buffer); /* timelimit_max */
3890 pack32(0, buffer); /* timelimit_min */
3891 pack_time(0, buffer); /* usage_end */
3892 pack_time(0, buffer); /* usage_start */
3893 packnull(buffer); /* used_nodes */
3894 pack32(NO_VAL, buffer); /* count(userid_list) */
3895 pack32(NO_VAL, buffer); /* count(wckey_list) */
3896 return;
3897 }
3898
3899 _pack_list_of_str(object->acct_list, buffer);
3900 _pack_list_of_str(object->associd_list, buffer);
3901 _pack_list_of_str(object->cluster_list, buffer);
3902 _pack_list_of_str(object->constraint_list, buffer);
3903
3904 pack32(object->cpus_max, buffer);
3905 pack32(object->cpus_min, buffer);
3906 pack32(object->db_flags, buffer);
3907 pack32((uint32_t)object->exitcode, buffer);
3908 pack32(object->flags, buffer);
3909
3910 _pack_list_of_str(object->format_list, buffer);
3911 _pack_list_of_str(object->groupid_list, buffer);
3912 _pack_list_of_str(object->jobname_list, buffer);
3913
3914 pack32(object->nodes_max, buffer);
3915 pack32(object->nodes_min, buffer);
3916
3917 _pack_list_of_str(object->partition_list, buffer);
3918 _pack_list_of_str(object->qos_list, buffer);
3919 _pack_list_of_str(object->reason_list, buffer);
3920 _pack_list_of_str(object->resv_list, buffer);
3921 _pack_list_of_str(object->resvid_list, buffer);
3922
3923 slurm_pack_list(object->step_list, slurmdb_pack_selected_step,
3924 buffer, protocol_version);
3925
3926 _pack_list_of_str(object->state_list, buffer);
3927
3928 pack32(object->timelimit_max, buffer);
3929 pack32(object->timelimit_min, buffer);
3930 pack_time(object->usage_end, buffer);
3931 pack_time(object->usage_start, buffer);
3932
3933 packstr(object->used_nodes, buffer);
3934
3935 _pack_list_of_str(object->userid_list, buffer);
3936 _pack_list_of_str(object->wckey_list, buffer);
3937 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
3938 if (!object) {
3939 pack32(NO_VAL, buffer); /* count(acct_list) */
3940 pack32(NO_VAL, buffer); /* count(associd_list) */
3941 pack32(NO_VAL, buffer); /* count(cluster_list) */
3942 pack32(0, buffer); /* cpus_max */
3943 pack32(0, buffer); /* cpus_min */
3944 pack32(0, buffer); /* exitcode */
3945 pack32(0, buffer); /* job cond flags */
3946 pack32(NO_VAL, buffer); /* count(format_list) */
3947 pack32(NO_VAL, buffer); /* count(groupid_list) */
3948 pack32(NO_VAL, buffer); /* count(jobname_list) */
3949 pack32(0, buffer); /* nodes_max */
3950 pack32(0, buffer); /* nodes_min */
3951 pack32(NO_VAL, buffer); /* count(partition_list) */
3952 pack32(NO_VAL, buffer); /* count(qos_list) */
3953 pack32(NO_VAL, buffer); /* count(resv_list) */
3954 pack32(NO_VAL, buffer); /* count(resvid_list) */
3955 pack32(NO_VAL, buffer); /* count(step_list) */
3956 pack32(NO_VAL, buffer); /* count(state_list) */
3957 pack32(0, buffer); /* timelimit_max */
3958 pack32(0, buffer); /* timelimit_min */
3959 pack_time(0, buffer); /* usage_end */
3960 pack_time(0, buffer); /* usage_start */
3961 packnull(buffer); /* used_nodes */
3962 pack32(NO_VAL, buffer); /* count(userid_list) */
3963 pack32(NO_VAL, buffer); /* count(wckey_list) */
3964 return;
3965 }
3966
3967 _pack_list_of_str(object->acct_list, buffer);
3968 _pack_list_of_str(object->associd_list, buffer);
3969 _pack_list_of_str(object->cluster_list, buffer);
3970
3971 pack32(object->cpus_max, buffer);
3972 pack32(object->cpus_min, buffer);
3973 pack32((uint32_t)object->exitcode, buffer);
3974 pack32(object->flags, buffer);
3975
3976 _pack_list_of_str(object->format_list, buffer);
3977 _pack_list_of_str(object->groupid_list, buffer);
3978 _pack_list_of_str(object->jobname_list, buffer);
3979
3980 pack32(object->nodes_max, buffer);
3981 pack32(object->nodes_min, buffer);
3982
3983 _pack_list_of_str(object->partition_list, buffer);
3984 _pack_list_of_str(object->qos_list, buffer);
3985 _pack_list_of_str(object->resv_list, buffer);
3986 _pack_list_of_str(object->resvid_list, buffer);
3987
3988 slurm_pack_list(object->step_list, slurmdb_pack_selected_step,
3989 buffer, protocol_version);
3990
3991 _pack_list_of_str(object->state_list, buffer);
3992
3993 pack32(object->timelimit_max, buffer);
3994 pack32(object->timelimit_min, buffer);
3995 pack_time(object->usage_end, buffer);
3996 pack_time(object->usage_start, buffer);
3997
3998 packstr(object->used_nodes, buffer);
3999
4000 _pack_list_of_str(object->userid_list, buffer);
4001 _pack_list_of_str(object->wckey_list, buffer);
4002 }
4003 }
4004
slurmdb_unpack_job_cond(void ** object,uint16_t protocol_version,Buf buffer)4005 extern int slurmdb_unpack_job_cond(void **object, uint16_t protocol_version,
4006 Buf buffer)
4007 {
4008 uint32_t uint32_tmp;
4009 int i;
4010 uint32_t count;
4011 slurmdb_job_cond_t *object_ptr = xmalloc(sizeof(slurmdb_job_cond_t));
4012 char *tmp_info = NULL;
4013 slurmdb_selected_step_t *job = NULL;
4014
4015 *object = object_ptr;
4016
4017 if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
4018 safe_unpack32(&count, buffer);
4019 if (count > NO_VAL)
4020 goto unpack_error;
4021 if (count != NO_VAL) {
4022 object_ptr->acct_list = list_create(xfree_ptr);
4023 for (i = 0; i < count; i++) {
4024 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4025 buffer);
4026 list_append(object_ptr->acct_list, tmp_info);
4027 }
4028 }
4029
4030 safe_unpack32(&count, buffer);
4031 if (count > NO_VAL)
4032 goto unpack_error;
4033 if (count != NO_VAL) {
4034 object_ptr->associd_list = list_create(xfree_ptr);
4035 for (i = 0; i < count; i++) {
4036 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4037 buffer);
4038 list_append(object_ptr->associd_list, tmp_info);
4039 }
4040 }
4041
4042 safe_unpack32(&count, buffer);
4043 if (count > NO_VAL)
4044 goto unpack_error;
4045 if (count != NO_VAL) {
4046 object_ptr->cluster_list = list_create(xfree_ptr);
4047 for (i = 0; i < count; i++) {
4048 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4049 buffer);
4050 list_append(object_ptr->cluster_list, tmp_info);
4051 }
4052 }
4053
4054 safe_unpack32(&count, buffer);
4055 if (count > NO_VAL)
4056 goto unpack_error;
4057 if (count && (count != NO_VAL)) {
4058 object_ptr->constraint_list = list_create(xfree_ptr);
4059 for (i = 0; i < count; i++) {
4060 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4061 buffer);
4062 list_append(object_ptr->constraint_list,
4063 tmp_info);
4064 }
4065 }
4066
4067 safe_unpack32(&object_ptr->cpus_max, buffer);
4068 safe_unpack32(&object_ptr->cpus_min, buffer);
4069 safe_unpack32(&object_ptr->db_flags, buffer);
4070 safe_unpack32(&uint32_tmp, buffer);
4071 object_ptr->exitcode = (int32_t)uint32_tmp;
4072 safe_unpack32(&object_ptr->flags, buffer);
4073
4074 safe_unpack32(&count, buffer);
4075 if (count > NO_VAL)
4076 goto unpack_error;
4077 if (count && (count != NO_VAL)) {
4078 object_ptr->format_list = list_create(xfree_ptr);
4079 for (i = 0; i < count; i++) {
4080 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4081 buffer);
4082 list_append(object_ptr->format_list, tmp_info);
4083 }
4084 }
4085
4086 safe_unpack32(&count, buffer);
4087 if (count > NO_VAL)
4088 goto unpack_error;
4089 if (count != NO_VAL) {
4090 object_ptr->groupid_list = list_create(xfree_ptr);
4091 for (i = 0; i < count; i++) {
4092 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4093 buffer);
4094 list_append(object_ptr->groupid_list, tmp_info);
4095 }
4096 }
4097
4098 safe_unpack32(&count, buffer);
4099 if (count > NO_VAL)
4100 goto unpack_error;
4101 if (count != NO_VAL) {
4102 object_ptr->jobname_list = list_create(xfree_ptr);
4103 for (i = 0; i < count; i++) {
4104 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4105 buffer);
4106 list_append(object_ptr->jobname_list, tmp_info);
4107 }
4108 }
4109
4110 safe_unpack32(&object_ptr->nodes_max, buffer);
4111 safe_unpack32(&object_ptr->nodes_min, buffer);
4112
4113 safe_unpack32(&count, buffer);
4114 if (count > NO_VAL)
4115 goto unpack_error;
4116 if (count != NO_VAL) {
4117 object_ptr->partition_list = list_create(xfree_ptr);
4118 for (i = 0; i < count; i++) {
4119 safe_unpackstr_xmalloc(&tmp_info,
4120 &uint32_tmp, buffer);
4121 list_append(object_ptr->partition_list,
4122 tmp_info);
4123 }
4124 }
4125
4126 safe_unpack32(&count, buffer);
4127 if (count > NO_VAL)
4128 goto unpack_error;
4129 if (count != NO_VAL) {
4130 object_ptr->qos_list = list_create(xfree_ptr);
4131 for (i = 0; i < count; i++) {
4132 safe_unpackstr_xmalloc(&tmp_info,
4133 &uint32_tmp, buffer);
4134 list_append(object_ptr->qos_list,
4135 tmp_info);
4136 }
4137 }
4138
4139 safe_unpack32(&count, buffer);
4140 if (count != NO_VAL) {
4141 object_ptr->reason_list = list_create(xfree_ptr);
4142 for (i = 0; i < count; i++) {
4143 safe_unpackstr_xmalloc(&tmp_info,
4144 &uint32_tmp, buffer);
4145 list_append(object_ptr->reason_list,
4146 tmp_info);
4147 }
4148 }
4149
4150 safe_unpack32(&count, buffer);
4151 if (count != NO_VAL) {
4152 object_ptr->resv_list = list_create(xfree_ptr);
4153 for (i = 0; i < count; i++) {
4154 safe_unpackstr_xmalloc(&tmp_info,
4155 &uint32_tmp, buffer);
4156 list_append(object_ptr->resv_list,
4157 tmp_info);
4158 }
4159 }
4160
4161 safe_unpack32(&count, buffer);
4162 if (count > NO_VAL)
4163 goto unpack_error;
4164 if (count != NO_VAL) {
4165 object_ptr->resvid_list = list_create(xfree_ptr);
4166 for (i = 0; i < count; i++) {
4167 safe_unpackstr_xmalloc(&tmp_info,
4168 &uint32_tmp, buffer);
4169 list_append(object_ptr->resvid_list,
4170 tmp_info);
4171 }
4172 }
4173
4174 safe_unpack32(&count, buffer);
4175 if (count > NO_VAL)
4176 goto unpack_error;
4177 if (count != NO_VAL) {
4178 object_ptr->step_list =
4179 list_create(slurmdb_destroy_selected_step);
4180 for (i = 0; i < count; i++) {
4181 if (slurmdb_unpack_selected_step(
4182 &job, protocol_version, buffer)
4183 != SLURM_SUCCESS) {
4184 error("unpacking selected step");
4185 goto unpack_error;
4186 }
4187 /* There is no such thing as jobid 0,
4188 * if we process it the database will
4189 * return all jobs. */
4190 if (!job->jobid)
4191 slurmdb_destroy_selected_step(job);
4192 else
4193 list_append(object_ptr->step_list, job);
4194 }
4195 if (!list_count(object_ptr->step_list))
4196 FREE_NULL_LIST(object_ptr->step_list);
4197 }
4198
4199 safe_unpack32(&count, buffer);
4200 if (count > NO_VAL)
4201 goto unpack_error;
4202 if (count != NO_VAL) {
4203 object_ptr->state_list = list_create(xfree_ptr);
4204 for (i = 0; i < count; i++) {
4205 safe_unpackstr_xmalloc(&tmp_info,
4206 &uint32_tmp, buffer);
4207 list_append(object_ptr->state_list, tmp_info);
4208 }
4209 }
4210
4211 safe_unpack32(&object_ptr->timelimit_max, buffer);
4212 safe_unpack32(&object_ptr->timelimit_min, buffer);
4213 safe_unpack_time(&object_ptr->usage_end, buffer);
4214 safe_unpack_time(&object_ptr->usage_start, buffer);
4215
4216 safe_unpackstr_xmalloc(&object_ptr->used_nodes,
4217 &uint32_tmp, buffer);
4218
4219 safe_unpack32(&count, buffer);
4220 if (count > NO_VAL)
4221 goto unpack_error;
4222 if (count != NO_VAL) {
4223 object_ptr->userid_list = list_create(xfree_ptr);
4224 for (i = 0; i < count; i++) {
4225 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4226 buffer);
4227 list_append(object_ptr->userid_list, tmp_info);
4228 }
4229 }
4230
4231 safe_unpack32(&count, buffer);
4232 if (count > NO_VAL)
4233 goto unpack_error;
4234 if (count != NO_VAL) {
4235 object_ptr->wckey_list = list_create(xfree_ptr);
4236 for (i = 0; i < count; i++) {
4237 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4238 buffer);
4239 list_append(object_ptr->wckey_list, tmp_info);
4240 }
4241 }
4242 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
4243 safe_unpack32(&count, buffer);
4244 if (count > NO_VAL)
4245 goto unpack_error;
4246 if (count != NO_VAL) {
4247 object_ptr->acct_list = list_create(xfree_ptr);
4248 for (i = 0; i < count; i++) {
4249 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4250 buffer);
4251 list_append(object_ptr->acct_list, tmp_info);
4252 }
4253 }
4254
4255 safe_unpack32(&count, buffer);
4256 if (count > NO_VAL)
4257 goto unpack_error;
4258 if (count != NO_VAL) {
4259 object_ptr->associd_list = list_create(xfree_ptr);
4260 for (i = 0; i < count; i++) {
4261 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4262 buffer);
4263 list_append(object_ptr->associd_list, tmp_info);
4264 }
4265 }
4266
4267 safe_unpack32(&count, buffer);
4268 if (count > NO_VAL)
4269 goto unpack_error;
4270 if (count != NO_VAL) {
4271 object_ptr->cluster_list = list_create(xfree_ptr);
4272 for (i = 0; i < count; i++) {
4273 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4274 buffer);
4275 list_append(object_ptr->cluster_list, tmp_info);
4276 }
4277 }
4278
4279 safe_unpack32(&object_ptr->cpus_max, buffer);
4280 safe_unpack32(&object_ptr->cpus_min, buffer);
4281 object_ptr->db_flags = SLURMDB_JOB_FLAG_NOTSET;
4282
4283 safe_unpack32(&uint32_tmp, buffer);
4284 object_ptr->exitcode = (int32_t)uint32_tmp;
4285 safe_unpack32(&object_ptr->flags, buffer);
4286
4287 safe_unpack32(&count, buffer);
4288 if (count > NO_VAL)
4289 goto unpack_error;
4290 if (count && (count != NO_VAL)) {
4291 object_ptr->format_list = list_create(xfree_ptr);
4292 for (i = 0; i < count; i++) {
4293 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4294 buffer);
4295 list_append(object_ptr->format_list, tmp_info);
4296 }
4297 }
4298
4299 safe_unpack32(&count, buffer);
4300 if (count > NO_VAL)
4301 goto unpack_error;
4302 if (count != NO_VAL) {
4303 object_ptr->groupid_list = list_create(xfree_ptr);
4304 for (i = 0; i < count; i++) {
4305 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4306 buffer);
4307 list_append(object_ptr->groupid_list, tmp_info);
4308 }
4309 }
4310
4311 safe_unpack32(&count, buffer);
4312 if (count > NO_VAL)
4313 goto unpack_error;
4314 if (count != NO_VAL) {
4315 object_ptr->jobname_list = list_create(xfree_ptr);
4316 for (i = 0; i < count; i++) {
4317 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4318 buffer);
4319 list_append(object_ptr->jobname_list, tmp_info);
4320 }
4321 }
4322
4323 safe_unpack32(&object_ptr->nodes_max, buffer);
4324 safe_unpack32(&object_ptr->nodes_min, buffer);
4325
4326 safe_unpack32(&count, buffer);
4327 if (count > NO_VAL)
4328 goto unpack_error;
4329 if (count != NO_VAL) {
4330 object_ptr->partition_list = list_create(xfree_ptr);
4331 for (i = 0; i < count; i++) {
4332 safe_unpackstr_xmalloc(&tmp_info,
4333 &uint32_tmp, buffer);
4334 list_append(object_ptr->partition_list,
4335 tmp_info);
4336 }
4337 }
4338
4339 safe_unpack32(&count, buffer);
4340 if (count > NO_VAL)
4341 goto unpack_error;
4342 if (count != NO_VAL) {
4343 object_ptr->qos_list = list_create(xfree_ptr);
4344 for (i = 0; i < count; i++) {
4345 safe_unpackstr_xmalloc(&tmp_info,
4346 &uint32_tmp, buffer);
4347 list_append(object_ptr->qos_list,
4348 tmp_info);
4349 }
4350 }
4351
4352 safe_unpack32(&count, buffer);
4353 if (count != NO_VAL) {
4354 object_ptr->resv_list = list_create(xfree_ptr);
4355 for (i = 0; i < count; i++) {
4356 safe_unpackstr_xmalloc(&tmp_info,
4357 &uint32_tmp, buffer);
4358 list_append(object_ptr->resv_list,
4359 tmp_info);
4360 }
4361 }
4362
4363 safe_unpack32(&count, buffer);
4364 if (count > NO_VAL)
4365 goto unpack_error;
4366 if (count != NO_VAL) {
4367 object_ptr->resvid_list = list_create(xfree_ptr);
4368 for (i = 0; i < count; i++) {
4369 safe_unpackstr_xmalloc(&tmp_info,
4370 &uint32_tmp, buffer);
4371 list_append(object_ptr->resvid_list,
4372 tmp_info);
4373 }
4374 }
4375
4376 safe_unpack32(&count, buffer);
4377 if (count > NO_VAL)
4378 goto unpack_error;
4379 if (count != NO_VAL) {
4380 object_ptr->step_list =
4381 list_create(slurmdb_destroy_selected_step);
4382 for (i = 0; i < count; i++) {
4383 if (slurmdb_unpack_selected_step(
4384 &job, protocol_version, buffer)
4385 != SLURM_SUCCESS) {
4386 error("unpacking selected step");
4387 goto unpack_error;
4388 }
4389 /* There is no such thing as jobid 0,
4390 * if we process it the database will
4391 * return all jobs. */
4392 if (!job->jobid)
4393 slurmdb_destroy_selected_step(job);
4394 else
4395 list_append(object_ptr->step_list, job);
4396 }
4397 if (!list_count(object_ptr->step_list))
4398 FREE_NULL_LIST(object_ptr->step_list);
4399 }
4400
4401 safe_unpack32(&count, buffer);
4402 if (count > NO_VAL)
4403 goto unpack_error;
4404 if (count != NO_VAL) {
4405 object_ptr->state_list = list_create(xfree_ptr);
4406 for (i = 0; i < count; i++) {
4407 safe_unpackstr_xmalloc(&tmp_info,
4408 &uint32_tmp, buffer);
4409 list_append(object_ptr->state_list, tmp_info);
4410 }
4411 }
4412
4413 safe_unpack32(&object_ptr->timelimit_max, buffer);
4414 safe_unpack32(&object_ptr->timelimit_min, buffer);
4415 safe_unpack_time(&object_ptr->usage_end, buffer);
4416 safe_unpack_time(&object_ptr->usage_start, buffer);
4417
4418 safe_unpackstr_xmalloc(&object_ptr->used_nodes,
4419 &uint32_tmp, buffer);
4420
4421 safe_unpack32(&count, buffer);
4422 if (count > NO_VAL)
4423 goto unpack_error;
4424 if (count != NO_VAL) {
4425 object_ptr->userid_list = list_create(xfree_ptr);
4426 for (i = 0; i < count; i++) {
4427 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4428 buffer);
4429 list_append(object_ptr->userid_list, tmp_info);
4430 }
4431 }
4432
4433 safe_unpack32(&count, buffer);
4434 if (count > NO_VAL)
4435 goto unpack_error;
4436 if (count != NO_VAL) {
4437 object_ptr->wckey_list = list_create(xfree_ptr);
4438 for (i = 0; i < count; i++) {
4439 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
4440 buffer);
4441 list_append(object_ptr->wckey_list, tmp_info);
4442 }
4443 }
4444 } else
4445 goto unpack_error;
4446
4447 return SLURM_SUCCESS;
4448
4449 unpack_error:
4450 slurmdb_destroy_job_cond(object_ptr);
4451 *object = NULL;
4452 return SLURM_ERROR;
4453 }
4454
slurmdb_pack_job_modify_cond(void * in,uint16_t protocol_version,Buf buffer)4455 extern void slurmdb_pack_job_modify_cond(void *in, uint16_t protocol_version,
4456 Buf buffer)
4457 {
4458 slurmdb_job_cond_t *cond = (slurmdb_job_cond_t *)in;
4459
4460 /* This is no longer valid for current Slurm */
4461 xassert(protocol_version < SLURM_20_02_PROTOCOL_VERSION);
4462
4463 if (!cond) {
4464 packnull(buffer);
4465 pack32(0, buffer);
4466 pack32(NO_VAL, buffer);
4467 pack_time(0, buffer);
4468 return;
4469 }
4470
4471 if (!cond->cluster_list || !list_count(cond->cluster_list)) {
4472 char *cluster = slurm_get_cluster_name();
4473 packstr(cluster, buffer);
4474 xfree(cluster);
4475 } else
4476 packstr(list_peek(cond->cluster_list), buffer);
4477 pack32(cond->flags, buffer);
4478
4479 if (!cond->step_list || !list_count(cond->step_list))
4480 pack32(NO_VAL, buffer);
4481 else {
4482 slurmdb_selected_step_t *selected_step =
4483 list_peek(cond->step_list);
4484 pack32(selected_step->jobid, buffer);
4485 }
4486
4487 pack_time(cond->usage_start, buffer);
4488 }
4489
slurmdb_unpack_job_modify_cond(void ** object,uint16_t protocol_version,Buf buffer)4490 extern int slurmdb_unpack_job_modify_cond(void **object,
4491 uint16_t protocol_version,
4492 Buf buffer)
4493 {
4494 uint32_t uint32_tmp;
4495 char *cluster = NULL;
4496 slurmdb_selected_step_t *selected_step = NULL;
4497 slurmdb_job_cond_t *object_ptr = NULL;
4498
4499 /* This is no longer valid for current Slurm */
4500 xassert(protocol_version < SLURM_20_02_PROTOCOL_VERSION);
4501
4502 object_ptr = xmalloc(sizeof(slurmdb_job_cond_t));
4503 *object = object_ptr;
4504
4505 safe_unpackstr_xmalloc(&cluster, &uint32_tmp, buffer);
4506
4507 object_ptr->cluster_list = list_create(xfree_ptr);
4508 list_append(object_ptr->cluster_list, cluster);
4509
4510 safe_unpack32(&object_ptr->flags, buffer);
4511
4512 object_ptr->step_list = list_create(slurmdb_destroy_selected_step);
4513 selected_step = xmalloc(sizeof(slurmdb_selected_step_t));
4514 list_append(object_ptr->step_list, selected_step);
4515 selected_step->array_task_id = NO_VAL;
4516 safe_unpack32(&selected_step->jobid, buffer);
4517 selected_step->het_job_offset = NO_VAL;
4518 selected_step->stepid = NO_VAL;
4519
4520 safe_unpack_time(&object_ptr->usage_start, buffer);
4521
4522 return SLURM_SUCCESS;
4523
4524 unpack_error:
4525 slurmdb_destroy_job_cond(object_ptr);
4526 *object = NULL;
4527 return SLURM_ERROR;
4528 }
4529
slurmdb_pack_job_rec(void * object,uint16_t protocol_version,Buf buffer)4530 extern void slurmdb_pack_job_rec(void *object, uint16_t protocol_version,
4531 Buf buffer)
4532 {
4533 slurmdb_job_rec_t *job = (slurmdb_job_rec_t *)object;
4534 ListIterator itr = NULL;
4535 slurmdb_step_rec_t *step = NULL;
4536 uint32_t count = 0;
4537
4538 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
4539 packstr(job->account, buffer);
4540 packstr(job->admin_comment, buffer);
4541 packstr(job->alloc_gres, buffer);
4542 pack32(job->alloc_nodes, buffer);
4543 pack32(job->array_job_id, buffer);
4544 pack32(job->array_max_tasks, buffer);
4545 pack32(job->array_task_id, buffer);
4546 packstr(job->array_task_str, buffer);
4547
4548 pack32(job->associd, buffer);
4549 packstr(job->blockid, buffer);
4550 packstr(job->cluster, buffer);
4551 packstr(job->constraints, buffer);
4552 pack64(job->db_index, buffer);
4553 pack32((uint32_t)job->derived_ec, buffer);
4554 packstr(job->derived_es, buffer);
4555 pack32(job->elapsed, buffer);
4556 pack_time(job->eligible, buffer);
4557 pack_time(job->end, buffer);
4558 pack32((uint32_t)job->exitcode, buffer);
4559 pack32(job->flags, buffer);
4560 /* the first_step_ptr
4561 is set up on the client side so does
4562 not need to be packed */
4563 pack32(job->gid, buffer);
4564 pack32(job->jobid, buffer);
4565 packstr(job->jobname, buffer);
4566 pack32(job->lft, buffer);
4567 packstr(job->mcs_label, buffer);
4568 packstr(job->nodes, buffer);
4569 pack32(job->het_job_id, buffer);
4570 pack32(job->het_job_offset, buffer);
4571 packstr(job->partition, buffer);
4572 pack32(job->priority, buffer);
4573 pack32(job->qosid, buffer);
4574 pack32(job->req_cpus, buffer);
4575 packstr(job->req_gres, buffer);
4576 pack64(job->req_mem, buffer);
4577 pack32(job->requid, buffer);
4578 packstr(job->resv_name, buffer);
4579 pack32(job->resvid, buffer);
4580 pack32(job->show_full, buffer);
4581 pack_time(job->start, buffer);
4582 pack32(job->state, buffer);
4583 pack32(job->state_reason_prev, buffer);
4584 _pack_slurmdb_stats(&job->stats, protocol_version, buffer);
4585
4586 if (job->steps)
4587 count = list_count(job->steps);
4588 else
4589 count = 0;
4590
4591 pack32(count, buffer);
4592 if (count) {
4593 itr = list_iterator_create(job->steps);
4594 while ((step = list_next(itr))) {
4595 slurmdb_pack_step_rec(step, protocol_version,
4596 buffer);
4597 }
4598 list_iterator_destroy(itr);
4599 }
4600 pack_time(job->submit, buffer);
4601 pack32(job->suspended, buffer);
4602 packstr(job->system_comment, buffer);
4603 pack32(job->sys_cpu_sec, buffer);
4604 pack32(job->sys_cpu_usec, buffer);
4605 pack32(job->timelimit, buffer);
4606 pack32(job->tot_cpu_sec, buffer);
4607 pack32(job->tot_cpu_usec, buffer);
4608 pack16(job->track_steps, buffer);
4609
4610 packstr(job->tres_alloc_str, buffer);
4611 packstr(job->tres_req_str, buffer);
4612
4613 pack32(job->uid, buffer);
4614 packstr(job->user, buffer);
4615 pack32(job->user_cpu_sec, buffer);
4616 pack32(job->user_cpu_usec, buffer);
4617 packstr(job->wckey, buffer);
4618 pack32(job->wckeyid, buffer);
4619 packstr(job->work_dir, buffer);
4620 } else if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
4621 packstr(job->account, buffer);
4622 packstr(job->admin_comment, buffer);
4623 packstr(job->alloc_gres, buffer);
4624 pack32(job->alloc_nodes, buffer);
4625 pack32(job->array_job_id, buffer);
4626 pack32(job->array_max_tasks, buffer);
4627 pack32(job->array_task_id, buffer);
4628 packstr(job->array_task_str, buffer);
4629
4630 pack32(job->associd, buffer);
4631 packstr(job->blockid, buffer);
4632 packstr(job->cluster, buffer);
4633 packstr(job->constraints, buffer);
4634 pack32((uint32_t)job->derived_ec, buffer);
4635 packstr(job->derived_es, buffer);
4636 pack32(job->elapsed, buffer);
4637 pack_time(job->eligible, buffer);
4638 pack_time(job->end, buffer);
4639 pack32((uint32_t)job->exitcode, buffer);
4640 pack32(job->flags, buffer);
4641 /* the first_step_ptr
4642 is set up on the client side so does
4643 not need to be packed */
4644 pack32(job->gid, buffer);
4645 pack32(job->jobid, buffer);
4646 packstr(job->jobname, buffer);
4647 pack32(job->lft, buffer);
4648 packstr(job->mcs_label, buffer);
4649 packstr(job->nodes, buffer);
4650 pack32(job->het_job_id, buffer);
4651 pack32(job->het_job_offset, buffer);
4652 packstr(job->partition, buffer);
4653 pack32(job->priority, buffer);
4654 pack32(job->qosid, buffer);
4655 pack32(job->req_cpus, buffer);
4656 packstr(job->req_gres, buffer);
4657 pack64(job->req_mem, buffer);
4658 pack32(job->requid, buffer);
4659 packstr(job->resv_name, buffer);
4660 pack32(job->resvid, buffer);
4661 pack32(job->show_full, buffer);
4662 pack_time(job->start, buffer);
4663 pack32(job->state, buffer);
4664 pack32(job->state_reason_prev, buffer);
4665 _pack_slurmdb_stats(&job->stats, protocol_version, buffer);
4666
4667 if (job->steps)
4668 count = list_count(job->steps);
4669 else
4670 count = 0;
4671
4672 pack32(count, buffer);
4673 if (count) {
4674 itr = list_iterator_create(job->steps);
4675 while ((step = list_next(itr))) {
4676 slurmdb_pack_step_rec(step, protocol_version,
4677 buffer);
4678 }
4679 list_iterator_destroy(itr);
4680 }
4681 pack_time(job->submit, buffer);
4682 pack32(job->suspended, buffer);
4683 packstr(job->system_comment, buffer);
4684 pack32(job->sys_cpu_sec, buffer);
4685 pack32(job->sys_cpu_usec, buffer);
4686 pack32(job->timelimit, buffer);
4687 pack32(job->tot_cpu_sec, buffer);
4688 pack32(job->tot_cpu_usec, buffer);
4689 pack16(job->track_steps, buffer);
4690
4691 packstr(job->tres_alloc_str, buffer);
4692 packstr(job->tres_req_str, buffer);
4693
4694 pack32(job->uid, buffer);
4695 packstr(job->user, buffer);
4696 pack32(job->user_cpu_sec, buffer);
4697 pack32(job->user_cpu_usec, buffer);
4698 packstr(job->wckey, buffer);
4699 pack32(job->wckeyid, buffer);
4700 packstr(job->work_dir, buffer);
4701 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
4702 packstr(job->account, buffer);
4703 packstr(job->admin_comment, buffer);
4704 packstr(job->alloc_gres, buffer);
4705 pack32(job->alloc_nodes, buffer);
4706 pack32(job->array_job_id, buffer);
4707 pack32(job->array_max_tasks, buffer);
4708 pack32(job->array_task_id, buffer);
4709 packstr(job->array_task_str, buffer);
4710
4711 pack32(job->associd, buffer);
4712 packstr(job->blockid, buffer);
4713 packstr(job->cluster, buffer);
4714 pack32((uint32_t)job->derived_ec, buffer);
4715 packstr(job->derived_es, buffer);
4716 pack32(job->elapsed, buffer);
4717 pack_time(job->eligible, buffer);
4718 pack_time(job->end, buffer);
4719 pack32((uint32_t)job->exitcode, buffer);
4720 /* the first_step_ptr
4721 is set up on the client side so does
4722 not need to be packed */
4723 pack32(job->gid, buffer);
4724 pack32(job->jobid, buffer);
4725 packstr(job->jobname, buffer);
4726 pack32(job->lft, buffer);
4727 packstr(job->mcs_label, buffer);
4728 packstr(job->nodes, buffer);
4729 pack32(job->het_job_id, buffer);
4730 pack32(job->het_job_offset, buffer);
4731 packstr(job->partition, buffer);
4732 pack32(job->priority, buffer);
4733 pack32(job->qosid, buffer);
4734 pack32(job->req_cpus, buffer);
4735 packstr(job->req_gres, buffer);
4736 pack64(job->req_mem, buffer);
4737 pack32(job->requid, buffer);
4738 packstr(job->resv_name, buffer);
4739 pack32(job->resvid, buffer);
4740 pack32(job->show_full, buffer);
4741 pack_time(job->start, buffer);
4742 pack32(job->state, buffer);
4743 _pack_slurmdb_stats(&job->stats, protocol_version, buffer);
4744
4745 if (job->steps)
4746 count = list_count(job->steps);
4747 else
4748 count = 0;
4749
4750 pack32(count, buffer);
4751 if (count) {
4752 itr = list_iterator_create(job->steps);
4753 while ((step = list_next(itr))) {
4754 slurmdb_pack_step_rec(step, protocol_version,
4755 buffer);
4756 }
4757 list_iterator_destroy(itr);
4758 }
4759 pack_time(job->submit, buffer);
4760 pack32(job->suspended, buffer);
4761 packstr(job->system_comment, buffer);
4762 pack32(job->sys_cpu_sec, buffer);
4763 pack32(job->sys_cpu_usec, buffer);
4764 pack32(job->timelimit, buffer);
4765 pack32(job->tot_cpu_sec, buffer);
4766 pack32(job->tot_cpu_usec, buffer);
4767 pack16(job->track_steps, buffer);
4768
4769 packstr(job->tres_alloc_str, buffer);
4770 packstr(job->tres_req_str, buffer);
4771
4772 pack32(job->uid, buffer);
4773 packstr(job->user, buffer);
4774 pack32(job->user_cpu_sec, buffer);
4775 pack32(job->user_cpu_usec, buffer);
4776 packstr(job->wckey, buffer);
4777 pack32(job->wckeyid, buffer);
4778 packstr(job->work_dir, buffer);
4779 } else {
4780 error("%s: protocol_version %hu not supported",
4781 __func__, protocol_version);
4782 }
4783 }
4784
slurmdb_unpack_job_rec(void ** job,uint16_t protocol_version,Buf buffer)4785 extern int slurmdb_unpack_job_rec(void **job, uint16_t protocol_version,
4786 Buf buffer)
4787 {
4788 slurmdb_job_rec_t *job_ptr = xmalloc(sizeof(slurmdb_job_rec_t));
4789 int i = 0;
4790 slurmdb_step_rec_t *step = NULL;
4791 uint32_t count = 0;
4792 uint32_t uint32_tmp;
4793
4794 *job = job_ptr;
4795
4796 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
4797 safe_unpackstr_xmalloc(&job_ptr->account, &uint32_tmp, buffer);
4798 safe_unpackstr_xmalloc(&job_ptr->admin_comment, &uint32_tmp,
4799 buffer);
4800 safe_unpackstr_xmalloc(&job_ptr->alloc_gres, &uint32_tmp,
4801 buffer);
4802 safe_unpack32(&job_ptr->alloc_nodes, buffer);
4803 safe_unpack32(&job_ptr->array_job_id, buffer);
4804 safe_unpack32(&job_ptr->array_max_tasks, buffer);
4805 safe_unpack32(&job_ptr->array_task_id, buffer);
4806 safe_unpackstr_xmalloc(&job_ptr->array_task_str,
4807 &uint32_tmp, buffer);
4808 safe_unpack32(&job_ptr->associd, buffer);
4809 safe_unpackstr_xmalloc(&job_ptr->blockid, &uint32_tmp, buffer);
4810 safe_unpackstr_xmalloc(&job_ptr->cluster, &uint32_tmp, buffer);
4811 safe_unpackstr_xmalloc(&job_ptr->constraints,
4812 &uint32_tmp, buffer);
4813 safe_unpack64(&job_ptr->db_index, buffer);
4814 safe_unpack32(&uint32_tmp, buffer);
4815 job_ptr->derived_ec = (int32_t)uint32_tmp;
4816 safe_unpackstr_xmalloc(&job_ptr->derived_es, &uint32_tmp,
4817 buffer);
4818 safe_unpack32(&job_ptr->elapsed, buffer);
4819 safe_unpack_time(&job_ptr->eligible, buffer);
4820 safe_unpack_time(&job_ptr->end, buffer);
4821 safe_unpack32(&uint32_tmp, buffer);
4822 job_ptr->exitcode = (int32_t)uint32_tmp;
4823 safe_unpack32(&job_ptr->flags, buffer);
4824
4825 safe_unpack32(&job_ptr->gid, buffer);
4826 safe_unpack32(&job_ptr->jobid, buffer);
4827 safe_unpackstr_xmalloc(&job_ptr->jobname, &uint32_tmp, buffer);
4828 safe_unpack32(&job_ptr->lft, buffer);
4829 safe_unpackstr_xmalloc(&job_ptr->mcs_label,
4830 &uint32_tmp, buffer);
4831 safe_unpackstr_xmalloc(&job_ptr->nodes, &uint32_tmp, buffer);
4832 safe_unpack32(&job_ptr->het_job_id, buffer);
4833 safe_unpack32(&job_ptr->het_job_offset, buffer);
4834 safe_unpackstr_xmalloc(&job_ptr->partition, &uint32_tmp,
4835 buffer);
4836 safe_unpack32(&job_ptr->priority, buffer);
4837 safe_unpack32(&job_ptr->qosid, buffer);
4838 safe_unpack32(&job_ptr->req_cpus, buffer);
4839 safe_unpackstr_xmalloc(&job_ptr->req_gres, &uint32_tmp, buffer);
4840 safe_unpack64(&job_ptr->req_mem, buffer);
4841 safe_unpack32(&job_ptr->requid, buffer);
4842 safe_unpackstr_xmalloc(&job_ptr->resv_name, &uint32_tmp,
4843 buffer);
4844 safe_unpack32(&job_ptr->resvid, buffer);
4845 safe_unpack32(&job_ptr->show_full, buffer);
4846 safe_unpack_time(&job_ptr->start, buffer);
4847 safe_unpack32(&uint32_tmp, buffer);
4848 job_ptr->state = uint32_tmp;
4849 safe_unpack32(&job_ptr->state_reason_prev, buffer);
4850 if (_unpack_slurmdb_stats(&job_ptr->stats, protocol_version,
4851 buffer)
4852 != SLURM_SUCCESS)
4853 goto unpack_error;
4854
4855 safe_unpack32(&count, buffer);
4856 job_ptr->steps = list_create(slurmdb_destroy_step_rec);
4857 for (i = 0; i < count; i++) {
4858 if (slurmdb_unpack_step_rec(&step, protocol_version,
4859 buffer)
4860 == SLURM_ERROR)
4861 goto unpack_error;
4862
4863 step->job_ptr = job_ptr;
4864 if (!job_ptr->first_step_ptr)
4865 job_ptr->first_step_ptr = step;
4866 list_append(job_ptr->steps, step);
4867 }
4868
4869 safe_unpack_time(&job_ptr->submit, buffer);
4870 safe_unpack32(&job_ptr->suspended, buffer);
4871 safe_unpackstr_xmalloc(&job_ptr->system_comment, &uint32_tmp,
4872 buffer);
4873 safe_unpack32(&job_ptr->sys_cpu_sec, buffer);
4874 safe_unpack32(&job_ptr->sys_cpu_usec, buffer);
4875 safe_unpack32(&job_ptr->timelimit, buffer);
4876 safe_unpack32(&job_ptr->tot_cpu_sec, buffer);
4877 safe_unpack32(&job_ptr->tot_cpu_usec, buffer);
4878 safe_unpack16(&job_ptr->track_steps, buffer);
4879 safe_unpackstr_xmalloc(&job_ptr->tres_alloc_str,
4880 &uint32_tmp, buffer);
4881 safe_unpackstr_xmalloc(&job_ptr->tres_req_str,
4882 &uint32_tmp, buffer);
4883 safe_unpack32(&job_ptr->uid, buffer);
4884 safe_unpackstr_xmalloc(&job_ptr->user, &uint32_tmp, buffer);
4885 safe_unpack32(&job_ptr->user_cpu_sec, buffer);
4886 safe_unpack32(&job_ptr->user_cpu_usec, buffer);
4887 safe_unpackstr_xmalloc(&job_ptr->wckey, &uint32_tmp, buffer);
4888 safe_unpack32(&job_ptr->wckeyid, buffer);
4889 safe_unpackstr_xmalloc(&job_ptr->work_dir, &uint32_tmp, buffer);
4890 } else if (protocol_version >= SLURM_19_05_PROTOCOL_VERSION) {
4891 safe_unpackstr_xmalloc(&job_ptr->account, &uint32_tmp, buffer);
4892 safe_unpackstr_xmalloc(&job_ptr->admin_comment, &uint32_tmp,
4893 buffer);
4894 safe_unpackstr_xmalloc(&job_ptr->alloc_gres, &uint32_tmp,
4895 buffer);
4896 safe_unpack32(&job_ptr->alloc_nodes, buffer);
4897 safe_unpack32(&job_ptr->array_job_id, buffer);
4898 safe_unpack32(&job_ptr->array_max_tasks, buffer);
4899 safe_unpack32(&job_ptr->array_task_id, buffer);
4900 safe_unpackstr_xmalloc(&job_ptr->array_task_str,
4901 &uint32_tmp, buffer);
4902 safe_unpack32(&job_ptr->associd, buffer);
4903 safe_unpackstr_xmalloc(&job_ptr->blockid, &uint32_tmp, buffer);
4904 safe_unpackstr_xmalloc(&job_ptr->cluster, &uint32_tmp, buffer);
4905 safe_unpackstr_xmalloc(&job_ptr->constraints,
4906 &uint32_tmp, buffer);
4907 safe_unpack32(&uint32_tmp, buffer);
4908 job_ptr->derived_ec = (int32_t)uint32_tmp;
4909 safe_unpackstr_xmalloc(&job_ptr->derived_es, &uint32_tmp,
4910 buffer);
4911 safe_unpack32(&job_ptr->elapsed, buffer);
4912 safe_unpack_time(&job_ptr->eligible, buffer);
4913 safe_unpack_time(&job_ptr->end, buffer);
4914 safe_unpack32(&uint32_tmp, buffer);
4915 job_ptr->exitcode = (int32_t)uint32_tmp;
4916 safe_unpack32(&job_ptr->flags, buffer);
4917
4918 safe_unpack32(&job_ptr->gid, buffer);
4919 safe_unpack32(&job_ptr->jobid, buffer);
4920 safe_unpackstr_xmalloc(&job_ptr->jobname, &uint32_tmp, buffer);
4921 safe_unpack32(&job_ptr->lft, buffer);
4922 safe_unpackstr_xmalloc(&job_ptr->mcs_label,
4923 &uint32_tmp, buffer);
4924 safe_unpackstr_xmalloc(&job_ptr->nodes, &uint32_tmp, buffer);
4925 safe_unpack32(&job_ptr->het_job_id, buffer);
4926 safe_unpack32(&job_ptr->het_job_offset, buffer);
4927 safe_unpackstr_xmalloc(&job_ptr->partition, &uint32_tmp,
4928 buffer);
4929 safe_unpack32(&job_ptr->priority, buffer);
4930 safe_unpack32(&job_ptr->qosid, buffer);
4931 safe_unpack32(&job_ptr->req_cpus, buffer);
4932 safe_unpackstr_xmalloc(&job_ptr->req_gres, &uint32_tmp, buffer);
4933 safe_unpack64(&job_ptr->req_mem, buffer);
4934 safe_unpack32(&job_ptr->requid, buffer);
4935 safe_unpackstr_xmalloc(&job_ptr->resv_name, &uint32_tmp,
4936 buffer);
4937 safe_unpack32(&job_ptr->resvid, buffer);
4938 safe_unpack32(&job_ptr->show_full, buffer);
4939 safe_unpack_time(&job_ptr->start, buffer);
4940 safe_unpack32(&uint32_tmp, buffer);
4941 job_ptr->state = uint32_tmp;
4942 safe_unpack32(&job_ptr->state_reason_prev, buffer);
4943 if (_unpack_slurmdb_stats(&job_ptr->stats, protocol_version,
4944 buffer)
4945 != SLURM_SUCCESS)
4946 goto unpack_error;
4947
4948 safe_unpack32(&count, buffer);
4949 job_ptr->steps = list_create(slurmdb_destroy_step_rec);
4950 for (i = 0; i < count; i++) {
4951 if (slurmdb_unpack_step_rec(&step, protocol_version,
4952 buffer)
4953 == SLURM_ERROR)
4954 goto unpack_error;
4955
4956 step->job_ptr = job_ptr;
4957 if (!job_ptr->first_step_ptr)
4958 job_ptr->first_step_ptr = step;
4959 list_append(job_ptr->steps, step);
4960 }
4961
4962 safe_unpack_time(&job_ptr->submit, buffer);
4963 safe_unpack32(&job_ptr->suspended, buffer);
4964 safe_unpackstr_xmalloc(&job_ptr->system_comment, &uint32_tmp,
4965 buffer);
4966 safe_unpack32(&job_ptr->sys_cpu_sec, buffer);
4967 safe_unpack32(&job_ptr->sys_cpu_usec, buffer);
4968 safe_unpack32(&job_ptr->timelimit, buffer);
4969 safe_unpack32(&job_ptr->tot_cpu_sec, buffer);
4970 safe_unpack32(&job_ptr->tot_cpu_usec, buffer);
4971 safe_unpack16(&job_ptr->track_steps, buffer);
4972 safe_unpackstr_xmalloc(&job_ptr->tres_alloc_str,
4973 &uint32_tmp, buffer);
4974 safe_unpackstr_xmalloc(&job_ptr->tres_req_str,
4975 &uint32_tmp, buffer);
4976 safe_unpack32(&job_ptr->uid, buffer);
4977 safe_unpackstr_xmalloc(&job_ptr->user, &uint32_tmp, buffer);
4978 safe_unpack32(&job_ptr->user_cpu_sec, buffer);
4979 safe_unpack32(&job_ptr->user_cpu_usec, buffer);
4980 safe_unpackstr_xmalloc(&job_ptr->wckey, &uint32_tmp, buffer);
4981 safe_unpack32(&job_ptr->wckeyid, buffer);
4982 safe_unpackstr_xmalloc(&job_ptr->work_dir, &uint32_tmp, buffer);
4983 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
4984 safe_unpackstr_xmalloc(&job_ptr->account, &uint32_tmp, buffer);
4985 safe_unpackstr_xmalloc(&job_ptr->admin_comment, &uint32_tmp,
4986 buffer);
4987 safe_unpackstr_xmalloc(&job_ptr->alloc_gres, &uint32_tmp,
4988 buffer);
4989 safe_unpack32(&job_ptr->alloc_nodes, buffer);
4990 safe_unpack32(&job_ptr->array_job_id, buffer);
4991 safe_unpack32(&job_ptr->array_max_tasks, buffer);
4992 safe_unpack32(&job_ptr->array_task_id, buffer);
4993 safe_unpackstr_xmalloc(&job_ptr->array_task_str,
4994 &uint32_tmp, buffer);
4995 safe_unpack32(&job_ptr->associd, buffer);
4996 safe_unpackstr_xmalloc(&job_ptr->blockid, &uint32_tmp, buffer);
4997 safe_unpackstr_xmalloc(&job_ptr->cluster, &uint32_tmp, buffer);
4998 safe_unpack32(&uint32_tmp, buffer);
4999 job_ptr->derived_ec = (int32_t)uint32_tmp;
5000 safe_unpackstr_xmalloc(&job_ptr->derived_es, &uint32_tmp,
5001 buffer);
5002 safe_unpack32(&job_ptr->elapsed, buffer);
5003 safe_unpack_time(&job_ptr->eligible, buffer);
5004 safe_unpack_time(&job_ptr->end, buffer);
5005 safe_unpack32(&uint32_tmp, buffer);
5006 job_ptr->exitcode = (int32_t)uint32_tmp;
5007 safe_unpack32(&job_ptr->gid, buffer);
5008 safe_unpack32(&job_ptr->jobid, buffer);
5009 safe_unpackstr_xmalloc(&job_ptr->jobname, &uint32_tmp, buffer);
5010 safe_unpack32(&job_ptr->lft, buffer);
5011 safe_unpackstr_xmalloc(&job_ptr->mcs_label,
5012 &uint32_tmp, buffer);
5013 safe_unpackstr_xmalloc(&job_ptr->nodes, &uint32_tmp, buffer);
5014 safe_unpack32(&job_ptr->het_job_id, buffer);
5015 safe_unpack32(&job_ptr->het_job_offset, buffer);
5016 safe_unpackstr_xmalloc(&job_ptr->partition, &uint32_tmp,
5017 buffer);
5018 safe_unpack32(&job_ptr->priority, buffer);
5019 safe_unpack32(&job_ptr->qosid, buffer);
5020 safe_unpack32(&job_ptr->req_cpus, buffer);
5021 safe_unpackstr_xmalloc(&job_ptr->req_gres, &uint32_tmp, buffer);
5022 safe_unpack64(&job_ptr->req_mem, buffer);
5023 safe_unpack32(&job_ptr->requid, buffer);
5024 safe_unpackstr_xmalloc(&job_ptr->resv_name, &uint32_tmp,
5025 buffer);
5026 safe_unpack32(&job_ptr->resvid, buffer);
5027 safe_unpack32(&job_ptr->show_full, buffer);
5028 safe_unpack_time(&job_ptr->start, buffer);
5029 safe_unpack32(&uint32_tmp, buffer);
5030 job_ptr->state = uint32_tmp;
5031 if (_unpack_slurmdb_stats(&job_ptr->stats, protocol_version,
5032 buffer)
5033 != SLURM_SUCCESS)
5034 goto unpack_error;
5035
5036 safe_unpack32(&count, buffer);
5037 job_ptr->steps = list_create(slurmdb_destroy_step_rec);
5038 for (i = 0; i < count; i++) {
5039 if (slurmdb_unpack_step_rec(&step, protocol_version,
5040 buffer)
5041 == SLURM_ERROR)
5042 goto unpack_error;
5043
5044 step->job_ptr = job_ptr;
5045 if (!job_ptr->first_step_ptr)
5046 job_ptr->first_step_ptr = step;
5047 list_append(job_ptr->steps, step);
5048 }
5049
5050 safe_unpack_time(&job_ptr->submit, buffer);
5051 safe_unpack32(&job_ptr->suspended, buffer);
5052 safe_unpackstr_xmalloc(&job_ptr->system_comment, &uint32_tmp,
5053 buffer);
5054 safe_unpack32(&job_ptr->sys_cpu_sec, buffer);
5055 safe_unpack32(&job_ptr->sys_cpu_usec, buffer);
5056 safe_unpack32(&job_ptr->timelimit, buffer);
5057 safe_unpack32(&job_ptr->tot_cpu_sec, buffer);
5058 safe_unpack32(&job_ptr->tot_cpu_usec, buffer);
5059 safe_unpack16(&job_ptr->track_steps, buffer);
5060 safe_unpackstr_xmalloc(&job_ptr->tres_alloc_str,
5061 &uint32_tmp, buffer);
5062 safe_unpackstr_xmalloc(&job_ptr->tres_req_str,
5063 &uint32_tmp, buffer);
5064 safe_unpack32(&job_ptr->uid, buffer);
5065 safe_unpackstr_xmalloc(&job_ptr->user, &uint32_tmp, buffer);
5066 safe_unpack32(&job_ptr->user_cpu_sec, buffer);
5067 safe_unpack32(&job_ptr->user_cpu_usec, buffer);
5068 safe_unpackstr_xmalloc(&job_ptr->wckey, &uint32_tmp, buffer);
5069 safe_unpack32(&job_ptr->wckeyid, buffer);
5070 safe_unpackstr_xmalloc(&job_ptr->work_dir, &uint32_tmp, buffer);
5071 } else {
5072 error("%s: protocol_version %hu not supported",
5073 __func__, protocol_version);
5074 goto unpack_error;
5075 }
5076
5077 return SLURM_SUCCESS;
5078
5079 unpack_error:
5080 slurmdb_destroy_job_rec(job_ptr);
5081 *job = NULL;
5082 return SLURM_ERROR;
5083 }
5084
slurmdb_pack_qos_cond(void * in,uint16_t protocol_version,Buf buffer)5085 extern void slurmdb_pack_qos_cond(void *in, uint16_t protocol_version,
5086 Buf buffer)
5087 {
5088 slurmdb_qos_cond_t *object = (slurmdb_qos_cond_t *)in;
5089
5090 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5091 if (!object) {
5092 pack32(NO_VAL, buffer);
5093 pack32(NO_VAL, buffer);
5094 pack32(NO_VAL, buffer);
5095 pack32(NO_VAL, buffer);
5096 pack16(0, buffer);
5097 pack16(0, buffer);
5098 return;
5099 }
5100
5101 _pack_list_of_str(object->description_list, buffer);
5102 _pack_list_of_str(object->format_list, buffer);
5103 _pack_list_of_str(object->id_list, buffer);
5104 _pack_list_of_str(object->name_list, buffer);
5105
5106 pack16(object->preempt_mode, buffer);
5107 pack16(object->with_deleted, buffer);
5108 }
5109 }
5110
slurmdb_unpack_qos_cond(void ** object,uint16_t protocol_version,Buf buffer)5111 extern int slurmdb_unpack_qos_cond(void **object, uint16_t protocol_version,
5112 Buf buffer)
5113 {
5114 uint32_t uint32_tmp;
5115 int i;
5116 uint32_t count;
5117 slurmdb_qos_cond_t *object_ptr = xmalloc(sizeof(slurmdb_qos_cond_t));
5118 char *tmp_info = NULL;
5119
5120 *object = object_ptr;
5121
5122 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5123 safe_unpack32(&count, buffer);
5124 if (count > NO_VAL)
5125 goto unpack_error;
5126 if (count != NO_VAL) {
5127 object_ptr->description_list = list_create(xfree_ptr);
5128 for (i = 0; i < count; i++) {
5129 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5130 buffer);
5131 list_append(object_ptr->description_list,
5132 tmp_info);
5133 }
5134 }
5135
5136 safe_unpack32(&count, buffer);
5137 if (count > NO_VAL)
5138 goto unpack_error;
5139 if (count && (count != NO_VAL)) {
5140 object_ptr->format_list = list_create(xfree_ptr);
5141 for (i = 0; i < count; i++) {
5142 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5143 buffer);
5144 list_append(object_ptr->format_list, tmp_info);
5145 }
5146 }
5147
5148 safe_unpack32(&count, buffer);
5149 if (count > NO_VAL)
5150 goto unpack_error;
5151 if (count != NO_VAL) {
5152 object_ptr->id_list = list_create(xfree_ptr);
5153 for (i = 0; i < count; i++) {
5154 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5155 buffer);
5156 list_append(object_ptr->id_list, tmp_info);
5157 }
5158 }
5159
5160 safe_unpack32(&count, buffer);
5161 if (count > NO_VAL)
5162 goto unpack_error;
5163 if (count != NO_VAL) {
5164 object_ptr->name_list = list_create(xfree_ptr);
5165 for (i = 0; i < count; i++) {
5166 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5167 buffer);
5168 list_append(object_ptr->name_list, tmp_info);
5169 }
5170 }
5171
5172 safe_unpack16(&object_ptr->preempt_mode, buffer);
5173 safe_unpack16(&object_ptr->with_deleted, buffer);
5174 } else
5175 goto unpack_error;
5176
5177 return SLURM_SUCCESS;
5178
5179 unpack_error:
5180 slurmdb_destroy_qos_cond(object_ptr);
5181 *object = NULL;
5182 return SLURM_ERROR;
5183 }
5184
slurmdb_pack_reservation_cond(void * in,uint16_t protocol_version,Buf buffer)5185 extern void slurmdb_pack_reservation_cond(void *in, uint16_t protocol_version,
5186 Buf buffer)
5187 {
5188 slurmdb_reservation_cond_t *object = (slurmdb_reservation_cond_t *)in;
5189
5190 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
5191 if (!object) {
5192 pack32(NO_VAL, buffer);
5193 pack64(0, buffer);
5194 pack32(NO_VAL, buffer);
5195 pack32(NO_VAL, buffer);
5196 pack32(NO_VAL, buffer);
5197 packnull(buffer);
5198 pack_time(0, buffer);
5199 pack_time(0, buffer);
5200 pack16(0, buffer);
5201 return;
5202 }
5203
5204 _pack_list_of_str(object->cluster_list, buffer);
5205
5206 pack64(object->flags, buffer);
5207
5208 _pack_list_of_str(object->format_list, buffer);
5209 _pack_list_of_str(object->id_list, buffer);
5210 _pack_list_of_str(object->name_list, buffer);
5211
5212 packstr(object->nodes, buffer);
5213 pack_time(object->time_end, buffer);
5214 pack_time(object->time_start, buffer);
5215 pack16(object->with_usage, buffer);
5216 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5217 if (!object) {
5218 pack32(NO_VAL, buffer);
5219 pack32(0, buffer);
5220 pack32(NO_VAL, buffer);
5221 pack32(NO_VAL, buffer);
5222 pack32(NO_VAL, buffer);
5223 packnull(buffer);
5224 pack_time(0, buffer);
5225 pack_time(0, buffer);
5226 pack16(0, buffer);
5227 return;
5228 }
5229
5230 _pack_list_of_str(object->cluster_list, buffer);
5231
5232 pack32((uint32_t)object->flags, buffer);
5233
5234 _pack_list_of_str(object->format_list, buffer);
5235 _pack_list_of_str(object->id_list, buffer);
5236 _pack_list_of_str(object->name_list, buffer);
5237
5238 packstr(object->nodes, buffer);
5239 pack_time(object->time_end, buffer);
5240 pack_time(object->time_start, buffer);
5241 pack16(object->with_usage, buffer);
5242 }
5243 }
5244
slurmdb_unpack_reservation_cond(void ** object,uint16_t protocol_version,Buf buffer)5245 extern int slurmdb_unpack_reservation_cond(void **object,
5246 uint16_t protocol_version,
5247 Buf buffer)
5248 {
5249 uint32_t uint32_tmp, count;
5250 int i = 0;
5251 char *tmp_info = NULL;
5252 slurmdb_reservation_cond_t *object_ptr =
5253 xmalloc(sizeof(slurmdb_reservation_cond_t));
5254
5255 *object = object_ptr;
5256
5257 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
5258 safe_unpack32(&count, buffer);
5259 if (count > NO_VAL)
5260 goto unpack_error;
5261 if (count != NO_VAL) {
5262 object_ptr->cluster_list = list_create(xfree_ptr);
5263 for (i = 0; i < count; i++) {
5264 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5265 buffer);
5266 list_append(object_ptr->cluster_list, tmp_info);
5267 }
5268 }
5269
5270 safe_unpack64(&object_ptr->flags, buffer);
5271
5272 safe_unpack32(&count, buffer);
5273 if (count > NO_VAL)
5274 goto unpack_error;
5275 if (count != NO_VAL) {
5276 object_ptr->format_list = list_create(xfree_ptr);
5277 for (i = 0; i < count; i++) {
5278 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5279 buffer);
5280 list_append(object_ptr->format_list, tmp_info);
5281 }
5282 }
5283
5284 safe_unpack32(&count, buffer);
5285 if (count > NO_VAL)
5286 goto unpack_error;
5287 if (count != NO_VAL) {
5288 object_ptr->id_list = list_create(xfree_ptr);
5289 for (i = 0; i < count; i++) {
5290 safe_unpackstr_xmalloc(&tmp_info,
5291 &uint32_tmp, buffer);
5292 list_append(object_ptr->id_list, tmp_info);
5293 }
5294 }
5295
5296 safe_unpack32(&count, buffer);
5297 if (count > NO_VAL)
5298 goto unpack_error;
5299 if (count != NO_VAL) {
5300 object_ptr->name_list = list_create(xfree_ptr);
5301 for (i = 0; i < count; i++) {
5302 safe_unpackstr_xmalloc(&tmp_info,
5303 &uint32_tmp, buffer);
5304 list_append(object_ptr->name_list, tmp_info);
5305 }
5306 }
5307
5308 safe_unpackstr_xmalloc(&object_ptr->nodes, &uint32_tmp, buffer);
5309 safe_unpack_time(&object_ptr->time_end, buffer);
5310 safe_unpack_time(&object_ptr->time_start, buffer);
5311 safe_unpack16(&object_ptr->with_usage, buffer);
5312 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5313 uint32_t flags;
5314 safe_unpack32(&count, buffer);
5315 if (count > NO_VAL)
5316 goto unpack_error;
5317 if (count != NO_VAL) {
5318 object_ptr->cluster_list = list_create(xfree_ptr);
5319 for (i = 0; i < count; i++) {
5320 safe_unpackstr_xmalloc(&tmp_info,
5321 &uint32_tmp, buffer);
5322 list_append(object_ptr->cluster_list, tmp_info);
5323 }
5324 }
5325
5326 safe_unpack32(&flags, buffer);
5327 if (flags == NO_VAL)
5328 object_ptr->flags = NO_VAL64;
5329 else
5330 object_ptr->flags = flags;
5331
5332 safe_unpack32(&count, buffer);
5333 if (count > NO_VAL)
5334 goto unpack_error;
5335 if (count != NO_VAL) {
5336 object_ptr->format_list = list_create(xfree_ptr);
5337 for (i = 0; i < count; i++) {
5338 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5339 buffer);
5340 list_append(object_ptr->format_list, tmp_info);
5341 }
5342 }
5343
5344 safe_unpack32(&count, buffer);
5345 if (count > NO_VAL)
5346 goto unpack_error;
5347 if (count != NO_VAL) {
5348 object_ptr->id_list = list_create(xfree_ptr);
5349 for (i = 0; i < count; i++) {
5350 safe_unpackstr_xmalloc(&tmp_info,
5351 &uint32_tmp, buffer);
5352 list_append(object_ptr->id_list, tmp_info);
5353 }
5354 }
5355
5356 safe_unpack32(&count, buffer);
5357 if (count > NO_VAL)
5358 goto unpack_error;
5359 if (count != NO_VAL) {
5360 object_ptr->name_list = list_create(xfree_ptr);
5361 for (i = 0; i < count; i++) {
5362 safe_unpackstr_xmalloc(&tmp_info,
5363 &uint32_tmp, buffer);
5364 list_append(object_ptr->name_list, tmp_info);
5365 }
5366 }
5367
5368 safe_unpackstr_xmalloc(&object_ptr->nodes, &uint32_tmp, buffer);
5369 safe_unpack_time(&object_ptr->time_end, buffer);
5370 safe_unpack_time(&object_ptr->time_start, buffer);
5371 safe_unpack16(&object_ptr->with_usage, buffer);
5372 } else
5373 goto unpack_error;
5374
5375 return SLURM_SUCCESS;
5376
5377 unpack_error:
5378 slurmdb_destroy_reservation_cond(object_ptr);
5379 *object = NULL;
5380 return SLURM_ERROR;
5381 }
5382
slurmdb_pack_selected_step(void * in,uint16_t protocol_version,Buf buffer)5383 extern void slurmdb_pack_selected_step(void *in, uint16_t protocol_version,
5384 Buf buffer)
5385 {
5386 slurmdb_selected_step_t *step = (slurmdb_selected_step_t *) in;
5387
5388 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5389 pack32(step->array_task_id, buffer);
5390 pack32(step->jobid, buffer);
5391 pack32(step->het_job_offset, buffer);
5392 pack32(step->stepid, buffer);
5393 }
5394 }
5395
slurmdb_unpack_selected_step(slurmdb_selected_step_t ** step,uint16_t protocol_version,Buf buffer)5396 extern int slurmdb_unpack_selected_step(slurmdb_selected_step_t **step,
5397 uint16_t protocol_version, Buf buffer)
5398 {
5399 slurmdb_selected_step_t *step_ptr =
5400 xmalloc(sizeof(slurmdb_selected_step_t));
5401
5402 *step = step_ptr;
5403
5404 step_ptr->array_task_id = NO_VAL;
5405
5406 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5407 safe_unpack32(&step_ptr->array_task_id, buffer);
5408 safe_unpack32(&step_ptr->jobid, buffer);
5409 safe_unpack32(&step_ptr->het_job_offset, buffer);
5410 safe_unpack32(&step_ptr->stepid, buffer);
5411 } else
5412 goto unpack_error;
5413
5414 return SLURM_SUCCESS;
5415
5416 unpack_error:
5417 slurmdb_destroy_selected_step(step_ptr);
5418 *step = NULL;
5419 return SLURM_ERROR;
5420 }
5421
slurmdb_pack_step_rec(slurmdb_step_rec_t * step,uint16_t protocol_version,Buf buffer)5422 extern void slurmdb_pack_step_rec(slurmdb_step_rec_t *step,
5423 uint16_t protocol_version, Buf buffer)
5424 {
5425
5426 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5427 pack32(step->elapsed, buffer);
5428 pack_time(step->end, buffer);
5429 pack32((uint32_t)step->exitcode, buffer);
5430 pack32(step->nnodes, buffer);
5431 packstr(step->nodes, buffer);
5432 pack32(step->ntasks, buffer);
5433 pack32(step->req_cpufreq_min, buffer);
5434 pack32(step->req_cpufreq_max, buffer);
5435 pack32(step->req_cpufreq_gov, buffer);
5436 pack32(step->requid, buffer);
5437 _pack_slurmdb_stats(&step->stats, protocol_version, buffer);
5438 pack_time(step->start, buffer);
5439 pack16(step->state, buffer);
5440 pack32(step->stepid, buffer); /* job's step number */
5441 packstr(step->stepname, buffer);
5442 pack32(step->suspended, buffer);
5443 pack32(step->sys_cpu_sec, buffer);
5444 pack32(step->sys_cpu_usec, buffer);
5445 pack32(step->task_dist, buffer);
5446 pack32(step->tot_cpu_sec, buffer);
5447 pack32(step->tot_cpu_usec, buffer);
5448 packstr(step->tres_alloc_str, buffer);
5449 pack32(step->user_cpu_sec, buffer);
5450 pack32(step->user_cpu_usec, buffer);
5451 } else {
5452 error("%s: protocol_version %hu not supported",
5453 __func__, protocol_version);
5454 }
5455 }
5456
slurmdb_unpack_step_rec(slurmdb_step_rec_t ** step,uint16_t protocol_version,Buf buffer)5457 extern int slurmdb_unpack_step_rec(slurmdb_step_rec_t **step,
5458 uint16_t protocol_version, Buf buffer)
5459 {
5460 uint32_t uint32_tmp = 0;
5461 uint16_t uint16_tmp = 0;
5462 slurmdb_step_rec_t *step_ptr = xmalloc(sizeof(slurmdb_step_rec_t));
5463
5464 *step = step_ptr;
5465
5466 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5467 safe_unpack32(&step_ptr->elapsed, buffer);
5468 safe_unpack_time(&step_ptr->end, buffer);
5469 safe_unpack32(&uint32_tmp, buffer);
5470 step_ptr->exitcode = (int32_t)uint32_tmp;
5471 safe_unpack32(&step_ptr->nnodes, buffer);
5472 safe_unpackstr_xmalloc(&step_ptr->nodes, &uint32_tmp, buffer);
5473 safe_unpack32(&step_ptr->ntasks, buffer);
5474 safe_unpack32(&step_ptr->req_cpufreq_min, buffer);
5475 safe_unpack32(&step_ptr->req_cpufreq_max, buffer);
5476 safe_unpack32(&step_ptr->req_cpufreq_gov, buffer);
5477 safe_unpack32(&step_ptr->requid, buffer);
5478 if (_unpack_slurmdb_stats(&step_ptr->stats, protocol_version,
5479 buffer)
5480 != SLURM_SUCCESS)
5481 goto unpack_error;
5482 safe_unpack_time(&step_ptr->start, buffer);
5483 safe_unpack16(&uint16_tmp, buffer);
5484 step_ptr->state = uint16_tmp;
5485 safe_unpack32(&step_ptr->stepid, buffer);
5486 safe_unpackstr_xmalloc(&step_ptr->stepname,
5487 &uint32_tmp, buffer);
5488 safe_unpack32(&step_ptr->suspended, buffer);
5489 safe_unpack32(&step_ptr->sys_cpu_sec, buffer);
5490 safe_unpack32(&step_ptr->sys_cpu_usec, buffer);
5491 safe_unpack32(&step_ptr->task_dist, buffer);
5492 safe_unpack32(&step_ptr->tot_cpu_sec, buffer);
5493 safe_unpack32(&step_ptr->tot_cpu_usec, buffer);
5494 safe_unpackstr_xmalloc(&step_ptr->tres_alloc_str,
5495 &uint32_tmp, buffer);
5496 safe_unpack32(&step_ptr->user_cpu_sec, buffer);
5497 safe_unpack32(&step_ptr->user_cpu_usec, buffer);
5498 } else {
5499 error("%s: protocol_version %hu not supported",
5500 __func__, protocol_version);
5501 goto unpack_error;
5502 }
5503
5504 return SLURM_SUCCESS;
5505
5506 unpack_error:
5507 slurmdb_destroy_step_rec(step_ptr);
5508 *step = NULL;
5509 return SLURM_ERROR;
5510 }
5511
slurmdb_pack_res_cond(void * in,uint16_t protocol_version,Buf buffer)5512 extern void slurmdb_pack_res_cond(void *in, uint16_t protocol_version,
5513 Buf buffer)
5514 {
5515 slurmdb_res_cond_t *object = (slurmdb_res_cond_t *)in;
5516
5517 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5518 if (!object) {
5519 pack32(NO_VAL, buffer);
5520 pack32(NO_VAL, buffer);
5521 pack32(SLURMDB_RES_FLAG_NOTSET, buffer);
5522 pack32(NO_VAL, buffer);
5523 pack32(NO_VAL, buffer);
5524 pack32(NO_VAL, buffer);
5525 pack32(NO_VAL, buffer);
5526 pack32(NO_VAL, buffer);
5527 pack32(NO_VAL, buffer);
5528 pack32(NO_VAL, buffer);
5529 pack16(0, buffer);
5530 pack16(0, buffer);
5531
5532 return;
5533 }
5534
5535 _pack_list_of_str(object->cluster_list, buffer);
5536 _pack_list_of_str(object->description_list, buffer);
5537
5538 pack32(object->flags, buffer);
5539
5540 _pack_list_of_str(object->format_list, buffer);
5541 _pack_list_of_str(object->id_list, buffer);
5542 _pack_list_of_str(object->manager_list, buffer);
5543 _pack_list_of_str(object->name_list, buffer);
5544 _pack_list_of_str(object->percent_list, buffer);
5545 _pack_list_of_str(object->server_list, buffer);
5546 _pack_list_of_str(object->type_list, buffer);
5547
5548 pack16(object->with_deleted, buffer);
5549 pack16(object->with_clusters, buffer);
5550 }
5551 }
5552
slurmdb_unpack_res_cond(void ** object,uint16_t protocol_version,Buf buffer)5553 extern int slurmdb_unpack_res_cond(void **object, uint16_t protocol_version,
5554 Buf buffer)
5555 {
5556 uint32_t uint32_tmp;
5557 int i;
5558 uint32_t count = 0;
5559 slurmdb_res_cond_t *object_ptr =
5560 xmalloc(sizeof(slurmdb_res_cond_t));
5561 char *tmp_info = NULL;
5562
5563 *object = object_ptr;
5564
5565 slurmdb_init_res_cond(object_ptr, 0);
5566
5567 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5568 safe_unpack32(&count, buffer);
5569 if (count > NO_VAL)
5570 goto unpack_error;
5571 if (count && (count != NO_VAL)) {
5572 object_ptr->cluster_list = list_create(xfree_ptr);
5573 for (i = 0; i < count; i++) {
5574 safe_unpackstr_xmalloc(&tmp_info,
5575 &uint32_tmp, buffer);
5576 list_append(object_ptr->cluster_list, tmp_info);
5577 }
5578 }
5579
5580 safe_unpack32(&count, buffer);
5581 if (count > NO_VAL)
5582 goto unpack_error;
5583 if (count && (count != NO_VAL)) {
5584 object_ptr->description_list = list_create(xfree_ptr);
5585 for (i = 0; i < count; i++) {
5586 safe_unpackstr_xmalloc(&tmp_info,
5587 &uint32_tmp, buffer);
5588 list_append(object_ptr->description_list,
5589 tmp_info);
5590 }
5591 }
5592
5593 safe_unpack32(&object_ptr->flags, buffer);
5594
5595 safe_unpack32(&count, buffer);
5596 if (count > NO_VAL)
5597 goto unpack_error;
5598 if (count && (count != NO_VAL)) {
5599 object_ptr->format_list = list_create(xfree_ptr);
5600 for (i = 0; i < count; i++) {
5601 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5602 buffer);
5603 list_append(object_ptr->format_list, tmp_info);
5604 }
5605 }
5606
5607 safe_unpack32(&count, buffer);
5608 if (count > NO_VAL)
5609 goto unpack_error;
5610 if (count && (count != NO_VAL)) {
5611 object_ptr->id_list = list_create(xfree_ptr);
5612 for (i = 0; i < count; i++) {
5613 safe_unpackstr_xmalloc(&tmp_info,
5614 &uint32_tmp, buffer);
5615 list_append(object_ptr->id_list, tmp_info);
5616 }
5617 }
5618
5619 safe_unpack32(&count, buffer);
5620 if (count > NO_VAL)
5621 goto unpack_error;
5622 if (count && (count != NO_VAL)) {
5623 object_ptr->manager_list = list_create(xfree_ptr);
5624 for (i = 0; i < count; i++) {
5625 safe_unpackstr_xmalloc(&tmp_info,
5626 &uint32_tmp, buffer);
5627 list_append(object_ptr->manager_list, tmp_info);
5628 }
5629 }
5630
5631 safe_unpack32(&count, buffer);
5632 if (count > NO_VAL)
5633 goto unpack_error;
5634 if (count && (count != NO_VAL)) {
5635 object_ptr->name_list = list_create(xfree_ptr);
5636 for (i = 0; i < count; i++) {
5637 safe_unpackstr_xmalloc(&tmp_info,
5638 &uint32_tmp, buffer);
5639 list_append(object_ptr->name_list, tmp_info);
5640 }
5641 }
5642
5643 safe_unpack32(&count, buffer);
5644 if (count > NO_VAL)
5645 goto unpack_error;
5646 if (count && (count != NO_VAL)) {
5647 object_ptr->percent_list = list_create(xfree_ptr);
5648 for (i = 0; i < count; i++) {
5649 safe_unpackstr_xmalloc(&tmp_info,
5650 &uint32_tmp, buffer);
5651 list_append(object_ptr->percent_list, tmp_info);
5652 }
5653 }
5654
5655 safe_unpack32(&count, buffer);
5656 if (count > NO_VAL)
5657 goto unpack_error;
5658 if (count && (count != NO_VAL)) {
5659 object_ptr->server_list = list_create(xfree_ptr);
5660 for (i = 0; i < count; i++) {
5661 safe_unpackstr_xmalloc(&tmp_info,
5662 &uint32_tmp, buffer);
5663 list_append(object_ptr->server_list, tmp_info);
5664 }
5665 }
5666
5667 safe_unpack32(&count, buffer);
5668 if (count > NO_VAL)
5669 goto unpack_error;
5670 if (count && (count != NO_VAL)) {
5671 object_ptr->type_list = list_create(xfree_ptr);
5672 for (i = 0; i < count; i++) {
5673 safe_unpackstr_xmalloc(&tmp_info,
5674 &uint32_tmp, buffer);
5675 list_append(object_ptr->type_list, tmp_info);
5676 }
5677 }
5678
5679 safe_unpack16(&object_ptr->with_deleted, buffer);
5680 safe_unpack16(&object_ptr->with_clusters, buffer);
5681 } else
5682 goto unpack_error;
5683
5684 return SLURM_SUCCESS;
5685
5686 unpack_error:
5687 slurmdb_destroy_res_cond(object_ptr);
5688 *object = NULL;
5689 return SLURM_ERROR;
5690 }
5691
slurmdb_pack_txn_cond(void * in,uint16_t protocol_version,Buf buffer)5692 extern void slurmdb_pack_txn_cond(void *in, uint16_t protocol_version,
5693 Buf buffer)
5694 {
5695 slurmdb_txn_cond_t *object = (slurmdb_txn_cond_t *)in;
5696
5697 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5698 if (!object) {
5699 pack32(NO_VAL, buffer);
5700 pack32(NO_VAL, buffer);
5701 pack32(NO_VAL, buffer);
5702 pack32(NO_VAL, buffer);
5703 pack32(NO_VAL, buffer);
5704 pack32(NO_VAL, buffer);
5705 pack32(NO_VAL, buffer);
5706 pack_time(0, buffer);
5707 pack_time(0, buffer);
5708 pack32(NO_VAL, buffer);
5709 pack16(0, buffer);
5710 return;
5711 }
5712
5713 _pack_list_of_str(object->acct_list, buffer);
5714 _pack_list_of_str(object->action_list, buffer);
5715 _pack_list_of_str(object->actor_list, buffer);
5716 _pack_list_of_str(object->cluster_list, buffer);
5717 _pack_list_of_str(object->format_list, buffer);
5718 _pack_list_of_str(object->id_list, buffer);
5719 _pack_list_of_str(object->info_list, buffer);
5720 _pack_list_of_str(object->name_list, buffer);
5721
5722 pack_time(object->time_end, buffer);
5723 pack_time(object->time_start, buffer);
5724
5725 _pack_list_of_str(object->user_list, buffer);
5726
5727 pack16(object->with_assoc_info, buffer);
5728 }
5729 }
5730
slurmdb_unpack_txn_cond(void ** object,uint16_t protocol_version,Buf buffer)5731 extern int slurmdb_unpack_txn_cond(void **object, uint16_t protocol_version,
5732 Buf buffer)
5733 {
5734 uint32_t uint32_tmp;
5735 int i;
5736 uint32_t count;
5737 slurmdb_txn_cond_t *object_ptr = xmalloc(sizeof(slurmdb_txn_cond_t));
5738 char *tmp_info = NULL;
5739
5740 *object = object_ptr;
5741 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5742 safe_unpack32(&count, buffer);
5743 if (count > NO_VAL)
5744 goto unpack_error;
5745 if (count != NO_VAL) {
5746 object_ptr->acct_list = list_create(xfree_ptr);
5747 for (i = 0; i < count; i++) {
5748 safe_unpackstr_xmalloc(&tmp_info,
5749 &uint32_tmp, buffer);
5750 list_append(object_ptr->acct_list, tmp_info);
5751 }
5752 }
5753
5754 safe_unpack32(&count, buffer);
5755 if (count > NO_VAL)
5756 goto unpack_error;
5757 if (count != NO_VAL) {
5758 object_ptr->action_list = list_create(xfree_ptr);
5759 for (i = 0; i < count; i++) {
5760 safe_unpackstr_xmalloc(&tmp_info,
5761 &uint32_tmp, buffer);
5762 list_append(object_ptr->action_list, tmp_info);
5763 }
5764 }
5765
5766 safe_unpack32(&count, buffer);
5767 if (count > NO_VAL)
5768 goto unpack_error;
5769 if (count != NO_VAL) {
5770 object_ptr->actor_list = list_create(xfree_ptr);
5771 for (i = 0; i < count; i++) {
5772 safe_unpackstr_xmalloc(&tmp_info,
5773 &uint32_tmp, buffer);
5774 list_append(object_ptr->actor_list, tmp_info);
5775 }
5776 }
5777
5778 safe_unpack32(&count, buffer);
5779 if (count > NO_VAL)
5780 goto unpack_error;
5781 if (count != NO_VAL) {
5782 object_ptr->cluster_list = list_create(xfree_ptr);
5783 for (i = 0; i < count; i++) {
5784 safe_unpackstr_xmalloc(&tmp_info,
5785 &uint32_tmp, buffer);
5786 list_append(object_ptr->cluster_list, tmp_info);
5787 }
5788 }
5789
5790 safe_unpack32(&count, buffer);
5791 if (count > NO_VAL)
5792 goto unpack_error;
5793 if (count && (count != NO_VAL)) {
5794 object_ptr->format_list = list_create(xfree_ptr);
5795 for (i = 0; i < count; i++) {
5796 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5797 buffer);
5798 list_append(object_ptr->format_list, tmp_info);
5799 }
5800 }
5801
5802 safe_unpack32(&count, buffer);
5803 if (count > NO_VAL)
5804 goto unpack_error;
5805 if (count != NO_VAL) {
5806 object_ptr->id_list = list_create(xfree_ptr);
5807 for (i = 0; i < count; i++) {
5808 safe_unpackstr_xmalloc(&tmp_info,
5809 &uint32_tmp, buffer);
5810 list_append(object_ptr->id_list, tmp_info);
5811 }
5812 }
5813
5814 safe_unpack32(&count, buffer);
5815 if (count > NO_VAL)
5816 goto unpack_error;
5817 if (count != NO_VAL) {
5818 object_ptr->info_list = list_create(xfree_ptr);
5819 for (i = 0; i < count; i++) {
5820 safe_unpackstr_xmalloc(&tmp_info,
5821 &uint32_tmp, buffer);
5822 list_append(object_ptr->info_list, tmp_info);
5823 }
5824 }
5825
5826 safe_unpack32(&count, buffer);
5827 if (count > NO_VAL)
5828 goto unpack_error;
5829 if (count != NO_VAL) {
5830 object_ptr->name_list = list_create(xfree_ptr);
5831 for (i = 0; i < count; i++) {
5832 safe_unpackstr_xmalloc(&tmp_info,
5833 &uint32_tmp, buffer);
5834 list_append(object_ptr->name_list, tmp_info);
5835 }
5836 }
5837
5838 safe_unpack_time(&object_ptr->time_end, buffer);
5839 safe_unpack_time(&object_ptr->time_start, buffer);
5840
5841 safe_unpack32(&count, buffer);
5842 if (count > NO_VAL)
5843 goto unpack_error;
5844 if (count != NO_VAL) {
5845 object_ptr->user_list = list_create(xfree_ptr);
5846 for (i = 0; i < count; i++) {
5847 safe_unpackstr_xmalloc(&tmp_info,
5848 &uint32_tmp, buffer);
5849 list_append(object_ptr->user_list, tmp_info);
5850 }
5851 }
5852
5853 safe_unpack16(&object_ptr->with_assoc_info, buffer);
5854 } else
5855 goto unpack_error;
5856
5857 return SLURM_SUCCESS;
5858
5859 unpack_error:
5860 slurmdb_destroy_txn_cond(object_ptr);
5861 *object = NULL;
5862 return SLURM_ERROR;
5863 }
5864
slurmdb_pack_wckey_cond(void * in,uint16_t protocol_version,Buf buffer)5865 extern void slurmdb_pack_wckey_cond(void *in, uint16_t protocol_version,
5866 Buf buffer)
5867 {
5868 slurmdb_wckey_cond_t *object = (slurmdb_wckey_cond_t *)in;
5869
5870 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5871 if (!object) {
5872 pack32(NO_VAL, buffer);
5873 pack32(NO_VAL, buffer);
5874 pack32(NO_VAL, buffer);
5875 pack32(NO_VAL, buffer);
5876
5877 pack16(0, buffer);
5878
5879 pack_time(0, buffer);
5880 pack_time(0, buffer);
5881
5882 pack32(NO_VAL, buffer);
5883
5884 pack16(0, buffer);
5885 pack16(0, buffer);
5886 return;
5887 }
5888
5889 _pack_list_of_str(object->cluster_list, buffer);
5890 _pack_list_of_str(object->format_list, buffer);
5891 _pack_list_of_str(object->id_list, buffer);
5892 _pack_list_of_str(object->name_list, buffer);
5893
5894 pack16(object->only_defs, buffer);
5895
5896 pack_time(object->usage_end, buffer);
5897 pack_time(object->usage_start, buffer);
5898
5899 _pack_list_of_str(object->user_list, buffer);
5900
5901 pack16(object->with_usage, buffer);
5902 pack16(object->with_deleted, buffer);
5903 }
5904 }
5905
slurmdb_unpack_wckey_cond(void ** object,uint16_t protocol_version,Buf buffer)5906 extern int slurmdb_unpack_wckey_cond(void **object, uint16_t protocol_version,
5907 Buf buffer)
5908 {
5909 uint32_t uint32_tmp;
5910 int i;
5911 uint32_t count;
5912 slurmdb_wckey_cond_t *object_ptr =
5913 xmalloc(sizeof(slurmdb_wckey_cond_t));
5914 char *tmp_info = NULL;
5915
5916 *object = object_ptr;
5917
5918 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
5919 safe_unpack32(&count, buffer);
5920 if (count > NO_VAL)
5921 goto unpack_error;
5922 if (count != NO_VAL) {
5923 object_ptr->cluster_list = list_create(xfree_ptr);
5924 for (i = 0; i < count; i++) {
5925 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5926 buffer);
5927 list_append(object_ptr->cluster_list,
5928 tmp_info);
5929 }
5930 }
5931
5932 safe_unpack32(&count, buffer);
5933 if (count > NO_VAL)
5934 goto unpack_error;
5935 if (count && (count != NO_VAL)) {
5936 object_ptr->format_list = list_create(xfree_ptr);
5937 for (i = 0; i < count; i++) {
5938 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5939 buffer);
5940 list_append(object_ptr->format_list, tmp_info);
5941 }
5942 }
5943
5944 safe_unpack32(&count, buffer);
5945 if (count > NO_VAL)
5946 goto unpack_error;
5947 if (count != NO_VAL) {
5948 object_ptr->id_list = list_create(xfree_ptr);
5949 for (i = 0; i < count; i++) {
5950 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5951 buffer);
5952 list_append(object_ptr->id_list, tmp_info);
5953 }
5954 }
5955
5956 safe_unpack32(&count, buffer);
5957 if (count > NO_VAL)
5958 goto unpack_error;
5959 if (count != NO_VAL) {
5960 object_ptr->name_list = list_create(xfree_ptr);
5961 for (i = 0; i < count; i++) {
5962 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5963 buffer);
5964 list_append(object_ptr->name_list, tmp_info);
5965 }
5966 }
5967
5968 safe_unpack16(&object_ptr->only_defs, buffer);
5969
5970 safe_unpack_time(&object_ptr->usage_end, buffer);
5971 safe_unpack_time(&object_ptr->usage_start, buffer);
5972
5973 safe_unpack32(&count, buffer);
5974 if (count > NO_VAL)
5975 goto unpack_error;
5976 if (count != NO_VAL) {
5977 object_ptr->user_list = list_create(xfree_ptr);
5978 for (i = 0; i < count; i++) {
5979 safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp,
5980 buffer);
5981 list_append(object_ptr->user_list, tmp_info);
5982 }
5983 }
5984
5985 safe_unpack16(&object_ptr->with_usage, buffer);
5986 safe_unpack16(&object_ptr->with_deleted, buffer);
5987 } else
5988 goto unpack_error;
5989
5990 return SLURM_SUCCESS;
5991
5992 unpack_error:
5993 slurmdb_destroy_wckey_cond(object_ptr);
5994 *object = NULL;
5995 return SLURM_ERROR;
5996 }
5997
slurmdb_pack_archive_cond(void * in,uint16_t protocol_version,Buf buffer)5998 extern void slurmdb_pack_archive_cond(void *in, uint16_t protocol_version,
5999 Buf buffer)
6000 {
6001 slurmdb_archive_cond_t *object = (slurmdb_archive_cond_t *)in;
6002
6003 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
6004 if (!object) {
6005 packnull(buffer);
6006 packnull(buffer);
6007 slurmdb_pack_job_cond(NULL, protocol_version, buffer);
6008 pack32(NO_VAL, buffer);
6009 pack32(NO_VAL, buffer);
6010 pack32(NO_VAL, buffer);
6011 pack32(NO_VAL, buffer);
6012 pack32(NO_VAL, buffer);
6013 pack32(NO_VAL, buffer);
6014 pack32(NO_VAL, buffer);
6015 return;
6016 }
6017
6018 packstr(object->archive_dir, buffer);
6019 packstr(object->archive_script, buffer);
6020 slurmdb_pack_job_cond(object->job_cond,
6021 protocol_version, buffer);
6022 pack32(object->purge_event, buffer);
6023 pack32(object->purge_job, buffer);
6024 pack32(object->purge_resv, buffer);
6025 pack32(object->purge_step, buffer);
6026 pack32(object->purge_suspend, buffer);
6027 pack32(object->purge_txn, buffer);
6028 pack32(object->purge_usage, buffer);
6029 }
6030 }
6031
slurmdb_unpack_archive_cond(void ** object,uint16_t protocol_version,Buf buffer)6032 extern int slurmdb_unpack_archive_cond(void **object, uint16_t protocol_version,
6033 Buf buffer)
6034 {
6035 uint32_t uint32_tmp;
6036 slurmdb_archive_cond_t *object_ptr =
6037 xmalloc(sizeof(slurmdb_archive_cond_t));
6038
6039 *object = object_ptr;
6040
6041 if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
6042 safe_unpackstr_xmalloc(&object_ptr->archive_dir,
6043 &uint32_tmp, buffer);
6044 safe_unpackstr_xmalloc(&object_ptr->archive_script,
6045 &uint32_tmp, buffer);
6046 if (slurmdb_unpack_job_cond((void *)&object_ptr->job_cond,
6047 protocol_version, buffer) ==
6048 SLURM_ERROR)
6049 goto unpack_error;
6050 safe_unpack32(&object_ptr->purge_event, buffer);
6051 safe_unpack32(&object_ptr->purge_job, buffer);
6052 safe_unpack32(&object_ptr->purge_resv, buffer);
6053 safe_unpack32(&object_ptr->purge_step, buffer);
6054 safe_unpack32(&object_ptr->purge_suspend, buffer);
6055 safe_unpack32(&object_ptr->purge_txn, buffer);
6056 safe_unpack32(&object_ptr->purge_usage, buffer);
6057 }
6058
6059 return SLURM_SUCCESS;
6060
6061 unpack_error:
6062 slurmdb_destroy_archive_cond(object_ptr);
6063 *object = NULL;
6064 return SLURM_ERROR;
6065
6066 }
6067
slurmdb_pack_rpc_obj(void * in,uint16_t protocol_version,Buf buffer)6068 extern void slurmdb_pack_rpc_obj(void *in, uint16_t protocol_version,
6069 Buf buffer)
6070 {
6071 slurmdb_rpc_obj_t *object = (slurmdb_rpc_obj_t *)in;
6072
6073 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
6074 pack32(object->cnt, buffer);
6075 pack32(object->id, buffer);
6076 pack64(object->time, buffer);
6077 /* pack64(object->time_ave, buffer); NO need to pack */
6078 } else {
6079 error("%s: protocol_version %hu not supported",
6080 __func__, protocol_version);
6081 }
6082 }
6083
slurmdb_unpack_rpc_obj(void ** object,uint16_t protocol_version,Buf buffer)6084 extern int slurmdb_unpack_rpc_obj(void **object, uint16_t protocol_version,
6085 Buf buffer)
6086 {
6087 slurmdb_rpc_obj_t *object_ptr = xmalloc(sizeof(slurmdb_rpc_obj_t));
6088
6089 *object = object_ptr;
6090
6091 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
6092 safe_unpack32(&object_ptr->cnt, buffer);
6093 safe_unpack32(&object_ptr->id, buffer);
6094 safe_unpack64(&object_ptr->time, buffer);
6095 if (object_ptr->cnt)
6096 object_ptr->time_ave =
6097 object_ptr->time / object_ptr->cnt;
6098 } else {
6099 error("%s: protocol_version %hu not supported",
6100 __func__, protocol_version);
6101 goto unpack_error;
6102 }
6103
6104 return SLURM_SUCCESS;
6105
6106 unpack_error:
6107 slurmdb_destroy_rollup_stats(object_ptr);
6108 *object = NULL;
6109 return SLURM_ERROR;
6110 }
6111
slurmdb_pack_rollup_stats(void * in,uint16_t protocol_version,Buf buffer)6112 extern void slurmdb_pack_rollup_stats(void *in, uint16_t protocol_version,
6113 Buf buffer)
6114 {
6115 slurmdb_rollup_stats_t *object = (slurmdb_rollup_stats_t *) in;
6116 uint32_t i;
6117
6118 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
6119 packstr(object->cluster_name, buffer);
6120 pack16(DBD_ROLLUP_COUNT, buffer);
6121 for (i = 0; i < DBD_ROLLUP_COUNT; i++) {
6122 pack16(object->count[i], buffer);
6123 pack_time(object->timestamp[i], buffer);
6124 pack64(object->time_last[i], buffer);
6125 pack64(object->time_max[i], buffer);
6126 pack64(object->time_total[i], buffer);
6127 }
6128 } else {
6129 error("%s: protocol_version %hu not supported",
6130 __func__, protocol_version);
6131 }
6132
6133 }
6134
slurmdb_unpack_rollup_stats(void ** object,uint16_t protocol_version,Buf buffer)6135 extern int slurmdb_unpack_rollup_stats(void **object, uint16_t protocol_version,
6136 Buf buffer)
6137 {
6138 uint32_t uint32_tmp;
6139 uint16_t rollup_count;
6140 int i;
6141 slurmdb_rollup_stats_t *object_ptr =
6142 xmalloc(sizeof(slurmdb_rollup_stats_t));
6143
6144 *object = object_ptr;
6145
6146 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
6147 safe_unpackstr_xmalloc(&object_ptr->cluster_name,
6148 &uint32_tmp, buffer);
6149 safe_unpack16(&rollup_count, buffer);
6150 /*
6151 * If we got more than we can handle just overwrite the
6152 * last one. This is more just to avoid potential
6153 * overflows. It shouldn't happen in practice.
6154 */
6155 if (rollup_count > DBD_ROLLUP_COUNT) {
6156 error("%s: our DBD_ROLLUP_COUNT = %d, but we just got a count of %d. We can't handle this.",
6157 __func__, DBD_ROLLUP_COUNT, rollup_count);
6158 goto unpack_error;
6159 }
6160
6161 for (i = 0; i < rollup_count; i++) {
6162 safe_unpack16(&object_ptr->count[i], buffer);
6163 safe_unpack_time(&object_ptr->timestamp[i], buffer);
6164 safe_unpack64(&object_ptr->time_last[i], buffer);
6165 safe_unpack64(&object_ptr->time_max[i], buffer);
6166 safe_unpack64(&object_ptr->time_total[i], buffer);
6167 }
6168 } else {
6169 error("%s: protocol_version %hu not supported",
6170 __func__, protocol_version);
6171 goto unpack_error;
6172 }
6173
6174 return SLURM_SUCCESS;
6175
6176 unpack_error:
6177 slurmdb_destroy_rollup_stats(object_ptr);
6178 *object = NULL;
6179 return SLURM_ERROR;
6180
6181 }
6182
slurmdb_pack_stats_msg(void * object,uint16_t protocol_version,Buf buffer)6183 extern void slurmdb_pack_stats_msg(void *object, uint16_t protocol_version,
6184 Buf buffer)
6185 {
6186 slurmdb_stats_rec_t *stats_ptr = (slurmdb_stats_rec_t *) object;
6187 uint32_t i;
6188
6189 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
6190 slurmdb_pack_rollup_stats(stats_ptr->dbd_rollup_stats,
6191 protocol_version, buffer);
6192 slurm_pack_list(stats_ptr->rollup_stats,
6193 slurmdb_pack_rollup_stats,
6194 buffer, protocol_version);
6195
6196 slurm_pack_list(stats_ptr->rpc_list,
6197 slurmdb_pack_rpc_obj,
6198 buffer, protocol_version);
6199
6200 pack_time(stats_ptr->time_start, buffer);
6201
6202 slurm_pack_list(stats_ptr->user_list,
6203 slurmdb_pack_rpc_obj,
6204 buffer, protocol_version);
6205 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
6206 ListIterator itr;
6207 slurmdb_rpc_obj_t *rpc_obj;
6208
6209 /* Rollup statistics */
6210 i = 3;
6211 pack32(i, buffer);
6212 pack16_array((uint16_t *)stats_ptr->dbd_rollup_stats->count,
6213 i, buffer);
6214 pack64_array(stats_ptr->dbd_rollup_stats->time_total,
6215 i, buffer);
6216 pack64_array(stats_ptr->dbd_rollup_stats->time_max, i, buffer);
6217
6218 pack32(list_count(stats_ptr->rpc_list), buffer);
6219
6220 itr = list_iterator_create(stats_ptr->rpc_list);
6221 pack32(list_count(stats_ptr->rpc_list), buffer);
6222 while ((rpc_obj = list_next(itr)))
6223 pack16(rpc_obj->id, buffer);
6224
6225 list_iterator_reset(itr);
6226 pack32(list_count(stats_ptr->rpc_list), buffer);
6227 while ((rpc_obj = list_next(itr)))
6228 pack32(rpc_obj->cnt, buffer);
6229
6230 list_iterator_reset(itr);
6231 pack32(list_count(stats_ptr->rpc_list), buffer);
6232 while ((rpc_obj = list_next(itr)))
6233 pack64(rpc_obj->time, buffer);
6234 list_iterator_destroy(itr);
6235
6236 itr = list_iterator_create(stats_ptr->user_list);
6237 pack32(list_count(stats_ptr->rpc_list), buffer);
6238 while ((rpc_obj = list_next(itr)))
6239 pack32(rpc_obj->id, buffer);
6240
6241 list_iterator_reset(itr);
6242 pack32(list_count(stats_ptr->rpc_list), buffer);
6243 while ((rpc_obj = list_next(itr)))
6244 pack32(rpc_obj->cnt, buffer);
6245
6246 list_iterator_reset(itr);
6247 pack32(list_count(stats_ptr->rpc_list), buffer);
6248 while ((rpc_obj = list_next(itr)))
6249 pack64(rpc_obj->time, buffer);
6250 list_iterator_destroy(itr);
6251 } else {
6252 error("%s: protocol_version %hu not supported",
6253 __func__, protocol_version);
6254 }
6255 }
6256
slurmdb_unpack_stats_msg(void ** object,uint16_t protocol_version,Buf buffer)6257 extern int slurmdb_unpack_stats_msg(void **object, uint16_t protocol_version,
6258 Buf buffer)
6259 {
6260 uint32_t uint32_tmp = 0;
6261 slurmdb_stats_rec_t *stats_ptr =
6262 xmalloc(sizeof(slurmdb_stats_rec_t));
6263
6264 *object = stats_ptr;
6265 if (protocol_version >= SLURM_20_02_PROTOCOL_VERSION) {
6266 /* Rollup statistics */
6267 if (slurmdb_unpack_rollup_stats(
6268 (void **)&stats_ptr->dbd_rollup_stats,
6269 protocol_version, buffer)
6270 != SLURM_SUCCESS)
6271 goto unpack_error;
6272 if (slurm_unpack_list(&stats_ptr->rollup_stats,
6273 slurmdb_unpack_rollup_stats,
6274 slurmdb_destroy_rollup_stats,
6275 buffer, protocol_version)
6276 != SLURM_SUCCESS)
6277 goto unpack_error;
6278
6279 if (slurm_unpack_list(&stats_ptr->rpc_list,
6280 slurmdb_unpack_rpc_obj,
6281 slurmdb_destroy_rpc_obj,
6282 buffer, protocol_version)
6283 != SLURM_SUCCESS)
6284 goto unpack_error;
6285
6286 safe_unpack_time(&stats_ptr->time_start, buffer);
6287
6288 if (slurm_unpack_list(&stats_ptr->user_list,
6289 slurmdb_unpack_rpc_obj,
6290 slurmdb_destroy_rpc_obj,
6291 buffer, protocol_version)
6292 != SLURM_SUCCESS)
6293 goto unpack_error;
6294 } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
6295 uint16_t *tmp16;
6296 uint32_t *tmp32, *tmp32_2;
6297 uint64_t *tmp64;
6298 slurmdb_rpc_obj_t *rpc_obj;
6299 uint32_t cnt;
6300
6301 /* Rollup statistics */
6302 safe_unpack32(&uint32_tmp, buffer);
6303 if (uint32_tmp != 3)
6304 goto unpack_error;
6305 safe_unpack16_array(&tmp16, &uint32_tmp,
6306 buffer);
6307 stats_ptr->dbd_rollup_stats =
6308 xmalloc(sizeof(slurmdb_rollup_stats_t));
6309 stats_ptr->dbd_rollup_stats->count[0] = tmp16[0];
6310 xfree(tmp16);
6311 if (uint32_tmp != 3)
6312 goto unpack_error;
6313 safe_unpack64_array(&tmp64, &uint32_tmp,
6314 buffer);
6315 stats_ptr->dbd_rollup_stats->time_total[0] = tmp64[0];
6316 xfree(tmp64);
6317 if (uint32_tmp != 3)
6318 goto unpack_error;
6319 safe_unpack64_array(&tmp64, &uint32_tmp,
6320 buffer);
6321 stats_ptr->dbd_rollup_stats->time_max[0] = tmp64[0];
6322 xfree(tmp64);
6323 if (uint32_tmp != 3)
6324 goto unpack_error;
6325
6326 stats_ptr->rpc_list = list_create(slurmdb_destroy_rpc_obj);
6327
6328 /* RPC type statistics */
6329 safe_unpack32(&cnt, buffer);
6330 safe_unpack16_array(&tmp16, &uint32_tmp, buffer);
6331 if (uint32_tmp != cnt)
6332 goto unpack_error;
6333 safe_unpack32_array(&tmp32, &uint32_tmp, buffer);
6334 if (uint32_tmp != cnt)
6335 goto unpack_error;
6336 safe_unpack64_array(&tmp64, &uint32_tmp, buffer);
6337 if (uint32_tmp != cnt)
6338 goto unpack_error;
6339
6340 for (int i = 0; i < cnt; i++) {
6341 rpc_obj = xmalloc(sizeof(slurmdb_rpc_obj_t));
6342 list_append(stats_ptr->rpc_list, rpc_obj);
6343 rpc_obj->id = tmp16[i];
6344 rpc_obj->cnt = tmp32[i];
6345 rpc_obj->time = tmp64[i];
6346 }
6347
6348 /* RPC user statistics */
6349 safe_unpack32(&cnt, buffer);
6350 safe_unpack32_array(&tmp32, &uint32_tmp, buffer);
6351 if (uint32_tmp != cnt)
6352 goto unpack_error;
6353 safe_unpack32_array(&tmp32_2, &uint32_tmp, buffer);
6354 if (uint32_tmp != cnt)
6355 goto unpack_error;
6356 safe_unpack64_array(&tmp64, &uint32_tmp, buffer);
6357 if (uint32_tmp != cnt)
6358 goto unpack_error;
6359
6360 for (int i = 0; i < cnt; i++) {
6361 rpc_obj = xmalloc(sizeof(slurmdb_rpc_obj_t));
6362 list_append(stats_ptr->user_list, rpc_obj);
6363 rpc_obj->id = tmp32[i];
6364 rpc_obj->cnt = tmp32_2[i];
6365 rpc_obj->time = tmp64[i];
6366 }
6367 } else {
6368 error("%s: protocol_version %hu not supported",
6369 __func__, protocol_version);
6370 goto unpack_error;
6371 }
6372
6373 return SLURM_SUCCESS;
6374
6375 unpack_error:
6376 slurmdb_destroy_stats_rec(stats_ptr);
6377 *object = NULL;
6378 return SLURM_ERROR;
6379 }
6380
slurmdb_pack_update_object(slurmdb_update_object_t * object,uint16_t protocol_version,Buf buffer)6381 extern void slurmdb_pack_update_object(slurmdb_update_object_t *object,
6382 uint16_t protocol_version, Buf buffer)
6383 {
6384 uint32_t count = NO_VAL;
6385 ListIterator itr = NULL;
6386 void *slurmdb_object = NULL;
6387 void (*my_function) (void *object, uint16_t protocol_version,
6388 Buf buffer);
6389
6390 switch (object->type) {
6391 case SLURMDB_MODIFY_USER:
6392 case SLURMDB_ADD_USER:
6393 case SLURMDB_REMOVE_USER:
6394 case SLURMDB_ADD_COORD:
6395 case SLURMDB_REMOVE_COORD:
6396 my_function = slurmdb_pack_user_rec;
6397 break;
6398 case SLURMDB_ADD_ASSOC:
6399 case SLURMDB_MODIFY_ASSOC:
6400 case SLURMDB_REMOVE_ASSOC:
6401 case SLURMDB_REMOVE_ASSOC_USAGE:
6402 my_function = slurmdb_pack_assoc_rec;
6403 break;
6404 case SLURMDB_ADD_QOS:
6405 case SLURMDB_MODIFY_QOS:
6406 case SLURMDB_REMOVE_QOS:
6407 case SLURMDB_REMOVE_QOS_USAGE:
6408 my_function = slurmdb_pack_qos_rec;
6409 break;
6410 case SLURMDB_ADD_WCKEY:
6411 case SLURMDB_MODIFY_WCKEY:
6412 case SLURMDB_REMOVE_WCKEY:
6413 my_function = slurmdb_pack_wckey_rec;
6414 break;
6415 case SLURMDB_ADD_CLUSTER:
6416 case SLURMDB_REMOVE_CLUSTER:
6417 pack16(object->type, buffer);
6418 return;
6419 case SLURMDB_ADD_RES:
6420 case SLURMDB_MODIFY_RES:
6421 case SLURMDB_REMOVE_RES:
6422 my_function = slurmdb_pack_res_rec;
6423 break;
6424 case SLURMDB_ADD_TRES:
6425 my_function = slurmdb_pack_tres_rec;
6426 break;
6427 case DBD_GOT_STATS:
6428 my_function = slurmdb_pack_stats_msg;
6429 break;
6430 case SLURMDB_UPDATE_FEDS:
6431 my_function = slurmdb_pack_federation_rec;
6432 break;
6433 case SLURMDB_UPDATE_NOTSET:
6434 default:
6435 error("pack: unknown type set in update_object: %d",
6436 object->type);
6437 return;
6438 }
6439
6440 pack16(object->type, buffer);
6441 if (object->objects)
6442 count = list_count(object->objects);
6443
6444 pack32(count, buffer);
6445 if (count && (count != NO_VAL)) {
6446 itr = list_iterator_create(object->objects);
6447 while ((slurmdb_object = list_next(itr))) {
6448 (*(my_function))(
6449 slurmdb_object, protocol_version, buffer);
6450 }
6451 list_iterator_destroy(itr);
6452 }
6453 }
6454
slurmdb_unpack_update_object(slurmdb_update_object_t ** object,uint16_t protocol_version,Buf buffer)6455 extern int slurmdb_unpack_update_object(slurmdb_update_object_t **object,
6456 uint16_t protocol_version, Buf buffer)
6457 {
6458 int i;
6459 uint32_t count;
6460 slurmdb_update_object_t *object_ptr =
6461 xmalloc(sizeof(slurmdb_update_object_t));
6462 void *slurmdb_object = NULL;
6463 int (*my_function) (void **object, uint16_t protocol_version,
6464 Buf buffer);
6465 void (*my_destroy) (void *object);
6466
6467 *object = object_ptr;
6468
6469 safe_unpack16(&object_ptr->type, buffer);
6470 switch (object_ptr->type) {
6471 case SLURMDB_MODIFY_USER:
6472 case SLURMDB_ADD_USER:
6473 case SLURMDB_REMOVE_USER:
6474 case SLURMDB_ADD_COORD:
6475 case SLURMDB_REMOVE_COORD:
6476 my_function = slurmdb_unpack_user_rec;
6477 my_destroy = slurmdb_destroy_user_rec;
6478 break;
6479 case SLURMDB_ADD_ASSOC:
6480 case SLURMDB_MODIFY_ASSOC:
6481 case SLURMDB_REMOVE_ASSOC:
6482 case SLURMDB_REMOVE_ASSOC_USAGE:
6483 my_function = slurmdb_unpack_assoc_rec;
6484 my_destroy = slurmdb_destroy_assoc_rec;
6485 break;
6486 case SLURMDB_ADD_QOS:
6487 case SLURMDB_MODIFY_QOS:
6488 case SLURMDB_REMOVE_QOS:
6489 case SLURMDB_REMOVE_QOS_USAGE:
6490 my_function = slurmdb_unpack_qos_rec;
6491 my_destroy = slurmdb_destroy_qos_rec;
6492 break;
6493 case SLURMDB_ADD_WCKEY:
6494 case SLURMDB_MODIFY_WCKEY:
6495 case SLURMDB_REMOVE_WCKEY:
6496 my_function = slurmdb_unpack_wckey_rec;
6497 my_destroy = slurmdb_destroy_wckey_rec;
6498 break;
6499 case SLURMDB_ADD_CLUSTER:
6500 case SLURMDB_REMOVE_CLUSTER:
6501 /* we don't pack anything on these */
6502 return SLURM_SUCCESS;
6503 case SLURMDB_ADD_RES:
6504 case SLURMDB_MODIFY_RES:
6505 case SLURMDB_REMOVE_RES:
6506 my_function = slurmdb_unpack_res_rec;
6507 my_destroy = slurmdb_destroy_res_rec;
6508 break;
6509 case SLURMDB_ADD_TRES:
6510 my_function = slurmdb_unpack_tres_rec;
6511 my_destroy = slurmdb_destroy_tres_rec;
6512 break;
6513 case DBD_GOT_STATS:
6514 my_function = slurmdb_unpack_stats_msg;
6515 my_destroy = slurmdb_destroy_stats_rec;
6516 break;
6517 case SLURMDB_UPDATE_FEDS:
6518 my_function = slurmdb_unpack_federation_rec;
6519 my_destroy = slurmdb_destroy_federation_rec;
6520 break;
6521 case SLURMDB_UPDATE_NOTSET:
6522 default:
6523 error("unpack: unknown type set in update_object: %d",
6524 object_ptr->type);
6525 goto unpack_error;
6526 }
6527 safe_unpack32(&count, buffer);
6528 if (count > NO_VAL)
6529 goto unpack_error;
6530 if (count != NO_VAL) {
6531 object_ptr->objects = list_create((*(my_destroy)));
6532 for (i = 0; i < count; i++) {
6533 if (((*(my_function))(&slurmdb_object,
6534 protocol_version, buffer))
6535 == SLURM_ERROR)
6536 goto unpack_error;
6537 list_append(object_ptr->objects, slurmdb_object);
6538 }
6539 }
6540 return SLURM_SUCCESS;
6541
6542 unpack_error:
6543 slurmdb_destroy_update_object(object_ptr);
6544 *object = NULL;
6545 return SLURM_ERROR;
6546 }
6547