summaryrefslogtreecommitdiff
path: root/usr/src/man/man3pool/pool_conf_alloc.3pool
blob: 011584af79bfda9808a422f20e7b9f55754be0f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
'\" te
.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH POOL_CONF_ALLOC 3POOL "Aug 3, 2009"
.SH NAME
pool_conf_alloc, pool_conf_close, pool_conf_commit, pool_conf_export,
pool_conf_free, pool_conf_info, pool_conf_location, pool_conf_open,
pool_conf_remove, pool_conf_rollback, pool_conf_status, pool_conf_update,
pool_conf_validate \- manipulate resource pool configurations
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lpool\fR [ \fIlibrary\fR\&.\|.\|. ]
#include <pool.h>

\fBpool_conf_t *\fR\fBpool_conf_alloc\fR(\fBvoid\fR);
.fi

.LP
.nf
\fBint\fR \fBpool_conf_close\fR(\fBpool_conf_t *\fR\fIconf\fR);
.fi

.LP
.nf
\fBint\fR \fBpool_conf_commit\fR(\fBpool_conf_t *\fR\fIconf\fR, \fBint\fR \fIactive\fR);
.fi

.LP
.nf
\fBint\fR \fBpool_conf_export\fR(\fBpool_conf_t *\fR\fIconf\fR, \fBconst char *\fR\fIlocation\fR,
     \fBpool_export_format_t\fR \fIformat\fR);
.fi

.LP
.nf
\fBvoid\fR \fBpool_conf_free\fR(\fBpool_conf_t *\fR\fIconf\fR);
.fi

.LP
.nf
\fBchar *\fR\fBpool_conf_info\fR(\fBconst pool_conf_t *\fR\fIconf\fR, \fBint\fR \fIflags\fR);
.fi

.LP
.nf
\fBconst char *\fR\fBpool_conf_location\fR(\fBpool_conf_t *\fR\fIconf\fR);
.fi

.LP
.nf
\fBint\fR \fBpool_conf_open\fR(\fBpool_conf_t *\fR\fIconf\fR, \fBconst char *\fR\fIlocation\fR,
     \fBint\fR \fIflags\fR);
.fi

.LP
.nf
\fBint\fR \fBpool_conf_remove\fR(\fBpool_conf_t *\fR\fIconf\fR);
.fi

.LP
.nf
\fBint\fR \fBpool_conf_rollback\fR(\fBpool_conf_t *\fR\fIconf\fR);
.fi

.LP
.nf
\fBpool_conf_state_t\fR \fBpool_conf_status\fR(\fBconst pool_conf_t *\fR\fIconf\fR);
.fi

.LP
.nf
\fBint\fR \fBpool_conf_update\fR(\fBconst pool_conf_t *\fR\fIconf\fR, \fBint *\fR\fIchanged\fR);
.fi

.LP
.nf
\fBint\fR \fBpool_conf_validate\fR(\fBpool_conf_t *\fR\fIconf\fR,
     \fBpool_valid_level_t\fR \fIlevel\fR);
.fi

.SH DESCRIPTION
.sp
.LP
These functions enable the access and creation of configuration files
associated with the pools facility.  Since the pool configuration is an opaque
type, an initial configuration is obtained with \fBpool_conf_alloc()\fR and
released with \fBpool_conf_free()\fR when the configuration is no longer of
interest. The \fIconf\fR argument for each function refers to the target
configuration to which the operation applies.
.sp
.LP
The \fBpool_conf_close()\fR function closes the given configuration, releasing
associated resources.
.sp
.LP
The \fBpool_conf_commit()\fR function commits changes made to the given
\fBpool_conf_t\fR to permanent storage. If the \fIactive\fR flag is non-zero,
the state of the system will be configured to match that described in the
supplied \fBpool_conf_t\fR. If configuring the system fails,
\fBpool_conf_commit()\fR will attempt to restore the system to its previous
state.
.sp
.LP
The \fBpool_conf_export()\fR function saves the given configuration to the
specified location. The only currently supported value of \fIformat\fR is
\fBPOX_NATIVE\fR, which is the format native to \fBlibpool\fR, the output of
which can be used as input to \fBpool_conf_open()\fR.
.sp
.LP
The \fBpool_conf_info()\fR function returns a string describing the entire
configuration.  The string is allocated with \fBmalloc\fR(3C). The caller is
responsible for freeing the returned string. If the flags option is non-zero,
the string returned also describes the sub-elements (if any) contained in the
configuration.
.sp
.LP
The \fBpool_conf_location()\fR function returns the location string provided to
\fBpool_conf_open()\fR for the given \fBpool_conf_t\fR.
.sp
.LP
The \fBpool_conf_open()\fR function creates a \fBpool_conf_t\fR given a
location at which the configuration is stored. The valid flags are a bitmap of
the following:
.sp
.ne 2
.na
\fB\fBPO_RDONLY\fR\fR
.ad
.RS 13n
Open for reading only.
.RE

.sp
.ne 2
.na
\fB\fBPO_RDWR\fR\fR
.ad
.RS 13n
Open read-write.
.RE

.sp
.ne 2
.na
\fB\fBPO_CREAT\fR\fR
.ad
.RS 13n
Create a configuration at the given location if it does not exist. If it does,
truncate it.
.RE

.sp
.ne 2
.na
\fB\fBPO_DISCO\fR\fR
.ad
.RS 13n
Perform `discovery'. This option only makes sense when used in conjunction with
\fBPO_CREAT\fR, and causes the returned \fBpool_conf_t\fR to contain the
resources and components currently active on the system.
.sp
The use of this flag is deprecated. \fBPO_CREAT\fR always performs discovery.
If supplied, this flag is ignored.
.RE

.sp
.ne 2
.na
\fB\fBPO_UPDATE\fR\fR
.ad
.RS 13n
Use when opening the dynamic state file, which is the configuration at
\fBpool_dynamic_location\fR(3POOL), to ensure that the contents of the dynamic
state file are updated to represent the current state of the system.
.sp
The use of this flag is deprecated. The dynamic state is always current and
does not require updating. If supplied, this flag is ignored.
.RE

.sp
.LP
A call to \fBpool_conf_open()\fR with the pool dynamic location and write
permission will hang if the dynamic location has already been opened for
writing.
.sp
.LP
The \fBpool_conf_remove()\fR function removes the configuration's permanent
storage. If the configuration is still open, it is first closed.
.sp
.LP
The \fBpool_conf_rollback()\fR function restores the configuration state to
that held in the configuration's permanent storage. This will either be the
state last successfully committed (using \fBpool_conf_commit()\fR) or the state
when the configuration was opened if there have been no successfully committed
changes since then.
.sp
.LP
The \fBpool_conf_status()\fR function returns the status of a configuration,
which can be one of the following values:
.sp
.ne 2
.na
\fB\fBPOF_INVALID\fR\fR
.ad
.RS 15n
The configuration is not in a suitable state for use.
.RE

.sp
.ne 2
.na
\fB\fBPOF_VALID\fR\fR
.ad
.RS 15n
The configuration is in a suitable state for use.
.RE

.sp
.LP
The \fBpool_conf_update()\fR function updates the library snapshot of kernel
state. If \fIchanged\fR is non-null, it is updated to identify which types of
configuration elements changed during the update. To check for change, treat
the \fIchanged\fR value as a bitmap of possible element types.
.sp
.LP
A change is defined for the different element classes as follows:
.sp
.ne 2
.na
\fB\fBPOU_SYSTEM\fR\fR
.ad
.RS 14n
A property on the system element has been created, modified, or removed.
.RE

.sp
.ne 2
.na
\fB\fBPOU_POOL\fR\fR
.ad
.RS 14n
A property on a pool element has been created, modified, or removed. A pool has
changed a resource association.
.RE

.sp
.ne 2
.na
\fB\fBPOU_PSET\fR\fR
.ad
.RS 14n
A property on a pset element has been created, modified, or removed. A pset's
resource composition has changed.
.RE

.sp
.ne 2
.na
\fB\fBPOU_CPU\fR\fR
.ad
.RS 14n
A property on a CPU element has been created, modified, or removed.
.RE

.sp
.LP
The \fBpool_conf_validate()\fR function checks the validity of the contents of
the given configuration. The validation can be at several (increasing) levels
of strictness:
.sp
.ne 2
.na
\fB\fBPOV_LOOSE\fR\fR
.ad
.RS 15n
Performs basic internal syntax validation.
.RE

.sp
.ne 2
.na
\fB\fBPOV_STRICT\fR\fR
.ad
.RS 15n
Performs a more thorough syntax validation and internal consistency checks.
.RE

.sp
.ne 2
.na
\fB\fBPOV_RUNTIME\fR\fR
.ad
.RS 15n
Performs an estimate of whether attempting to commit the given configuration on
the system would succeed or fail. It is optimistic in that a successful
validation does not guarantee a subsequent commit operation will be successful;
it is conservative in that a failed validation indicates that a subsequent
commit operation on the current system will always fail.
.RE

.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBpool_conf_alloc()\fR returns an initialized
\fBpool_conf_t\fR pointer. Otherwise it returns \fINULL\fR and
\fBpool_error\fR(3POOL) returns the pool-specific error value.
.sp
.LP
Upon successful completion, \fBpool_conf_close()\fR, \fBpool_conf_commit()\fR,
\fBpool_conf_export()\fR, \fBpool_conf_open()\fR, \fBpool_conf_remove()\fR,
\fBpool_conf_rollback()\fR, \fBpool_conf_update()\fR, and
\fBpool_conf_validate()\fR return 0. Otherwise they return -1 and
\fBpool_error()\fR returns the pool-specific error value.
.sp
.LP
The \fBpool_conf_status()\fR function returns either \fBPOF_INVALID\fR or
\fBPOF_VALID\fR.
.SH ERRORS
.sp
.LP
The \fBpool_conf_alloc()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_SYSTEM\fR\fR
.ad
.RS 20n
There is not enough memory available to allocate the configuration. Check
\fBerrno\fR for the specific system error code.
.RE

.sp
.ne 2
.na
\fB\fBPOE_INVALID_CONF\fR\fR
.ad
.RS 20n
The configuration is invalid.
.RE

.sp
.LP
The \fBpool_conf_close()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 16n
The supplied configuration's status is not \fBPOF_VALID\fR.
.RE

.sp
.ne 2
.na
\fB\fBPOE_SYSTEM\fR\fR
.ad
.RS 16n
The configuration's permanent store cannot be closed.  Check \fBerrno\fR for
the specific system error code.
.RE

.sp
.LP
The \fBpool_conf_commit()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 20n
The supplied configuration's status is not \fBPOF_VALID\fR or the active flag
is non-zero and the system could not be modified.
.RE

.sp
.ne 2
.na
\fB\fBPOE_SYSTEM\fR\fR
.ad
.RS 20n
The permanent store could not be updated. Check \fBerrno\fR for the specific
system error code.
.RE

.sp
.ne 2
.na
\fB\fBPOE_INVALID_CONF\fR\fR
.ad
.RS 20n
The configuration is not valid for this system.
.RE

.sp
.ne 2
.na
\fB\fBPOE_ACCESS\fR\fR
.ad
.RS 20n
The configuration was not opened with the correct permissions.
.RE

.sp
.ne 2
.na
\fB\fBPOE_DATASTORE\fR\fR
.ad
.RS 20n
The update of the permanent store has failed and the contents could be
corrupted. Check for a \fB\&.bak\fR file at the datastore location if manual
recovery is required.
.RE

.sp
.LP
The \fBpool_conf_export()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 17n
The supplied configuration's status is not \fBPOF_VALID\fR or the requested
export format is not supported.
.RE

.sp
.ne 2
.na
\fB\fBPOE_DATASTORE\fR\fR
.ad
.RS 17n
The creation of the export file failed. A file might have been created at the
specified location but the contents of the file might not be correct.
.RE

.sp
.LP
The \fBpool_conf_info()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 20n
The supplied configuration's status is not \fBPOF_VALID\fR or \fIflags\fR is
neither 0 nor 1.
.RE

.sp
.ne 2
.na
\fB\fBPOE_SYSTEM\fR\fR
.ad
.RS 20n
There is not enough memory available to allocate the buffer used to build the
information string. Check \fBerrno\fR for the specific system error code.
.RE

.sp
.ne 2
.na
\fB\fBPOE_INVALID_CONF\fR\fR
.ad
.RS 20n
The configuration is invalid.
.RE

.sp
.LP
The \fBpool_conf_location()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 16n
The supplied configuration's status is not \fBPOF_VALID\fR.
.RE

.sp
.LP
The \fBpool_conf_open()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 20n
The supplied configuration's status is already \fBPOF_VALID\fR.
.RE

.sp
.ne 2
.na
\fB\fBPOE_SYSTEM\fR\fR
.ad
.RS 20n
There is not enough memory available to store the supplied location, or the
pools facility is not active. Check \fBerrno\fR for the specific system error
code.
.RE

.sp
.ne 2
.na
\fB\fBPOE_INVALID_CONF\fR\fR
.ad
.RS 20n
The configuration to be opened is at \fBpool_dynamic_location\fR(3POOL) and the
configuration is not valid for this system.
.RE

.sp
.LP
The \fBpool_conf_remove()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 16n
The supplied configuration's status is not \fBPOF_VALID\fR.
.RE

.sp
.ne 2
.na
\fB\fBPOE_SYSTEM\fR\fR
.ad
.RS 16n
The configuration's permanent storage could not be removed. Check \fBerrno\fR
for the specific system error code.
.RE

.sp
.LP
The \fBpool_conf_rollback()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 16n
The supplied configuration's status is not \fBPOF_VALID\fR.
.RE

.sp
.ne 2
.na
\fB\fBPOE_SYSTEM\fR\fR
.ad
.RS 16n
The permanent store could not be accessed. Check \fBerrno\fR for the specific
system error code.
.RE

.sp
.LP
The \fBpool_conf_update()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 20n
The supplied configuration's status is not \fBPOF_VALID\fR or the configuration
is not the dynamic configuration.
.RE

.sp
.ne 2
.na
\fB\fBPOE_DATASTORE\fR\fR
.ad
.RS 20n
The kernel snapshot cannot be correctly unpacked.
.RE

.sp
.ne 2
.na
\fB\fBPOE_INVALID_CONF\fR\fR
.ad
.RS 20n
The configuration contains uncommitted transactions.
.RE

.sp
.ne 2
.na
\fB\fBPOE_SYSTEM\fR\fR
.ad
.RS 20n
A system error occurred during snapshot retrieval and update.
.RE

.sp
.LP
The \fBpool_conf_validate()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBPOE_BADPARAM\fR\fR
.ad
.RS 20n
The supplied configuration's status is not \fBPOF_VALID\fR.
.RE

.sp
.ne 2
.na
\fB\fBPOE_INVALID_CONF\fR\fR
.ad
.RS 20n
The configuration is invalid.
.RE

.SH EXAMPLES
.LP
\fBExample 1 \fRCreate the configuration at the specified location.
.sp
.in +2
.nf
#include <pool.h>
#include <stdio.h>

\&...

pool_conf_t *pool_conf;
pool_conf = pool_conf_alloc();
char *input_location = "/tmp/poolconf.example";

if (pool_conf_open(pool_conf, input_location,
    PO_RDONLY) < 0) {
        fprintf(stderr, "Opening pool configuration %s
                failed\en", input_location);
}
.fi
.in -2

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
CSI	Enabled
_
Interface Stability	Uncommitted
_
MT-Level	Safe
.TE

.SH SEE ALSO
.sp
.LP
\fBlibpool\fR(3LIB), \fBpool_error\fR(3POOL), \fBattributes\fR(5)