1 /* -*- c -*-
2 *
3 * Copyright (C) 2006 Red Hat
4 * Copyright (C) 2006-2007 Daniel P. Berrange
5 *
6 * This program is free software; You can redistribute it and/or modify
7 * it under either:
8 *
9 * a) the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any
11 * later version,
12 *
13 * or
14 *
15 * b) the "Artistic License"
16 *
17 * The file "LICENSE" distributed along with this file provides full
18 * details of the terms and conditions of the two licenses.
19 */
20
21 #include "EXTERN.h"
22 #include "perl.h"
23 #include "XSUB.h"
24
25 #include <libvirt/virterror.h>
26 #include <libvirt/libvirt.h>
27
28 /*
29 * On 32-bit OS (and some 64-bit) Perl does not have an
30 * integer type capable of storing 64 bit numbers. So
31 * we serialize to/from strings on these platforms
32 */
33
34 static long long
virt_SvIVll(SV * sv)35 virt_SvIVll(SV *sv) {
36 #ifdef USE_64_BIT_ALL
37 return SvIV(sv);
38 #else
39 return strtoll(SvPV_nolen(sv), NULL, 10);
40 #endif
41 }
42
43
44 static unsigned long long
virt_SvIVull(SV * sv)45 virt_SvIVull(SV *sv) {
46 #ifdef USE_64_BIT_ALL
47 return SvIV(sv);
48 #else
49 return strtoull(SvPV_nolen(sv), NULL, 10);
50 #endif
51 }
52
53
54 #ifndef PRId64
55 #define PRId64 "lld"
56 #endif
57
58
59 static SV *
virt_newSVll(long long val)60 virt_newSVll(long long val) {
61 #ifdef USE_64_BIT_ALL
62 return newSViv(val);
63 #else
64 char buf[100];
65 int len;
66 len = snprintf(buf, 100, "%" PRId64, val);
67 return newSVpv(buf, len);
68 #endif
69 }
70
71
72 #ifndef PRIu64
73 #define PRIu64 "llu"
74 #endif
75
76 static SV *
virt_newSVull(unsigned long long val)77 virt_newSVull(unsigned long long val) {
78 #ifdef USE_64_BIT_ALL
79 return newSVuv(val);
80 #else
81 char buf[100];
82 int len;
83 len = snprintf(buf, 100, "%" PRIu64, val);
84 return newSVpv(buf, len);
85 #endif
86 }
87
88
89
90 static void
ignoreVirErrorFunc(void * userData,virErrorPtr error)91 ignoreVirErrorFunc(void * userData, virErrorPtr error) {
92 /* Do nothing */
93 }
94
95
96 static SV *
_sv_from_error(virErrorPtr error)97 _sv_from_error(virErrorPtr error)
98 {
99 HV *hv;
100
101 hv = newHV ();
102
103 /* Map virErrorPtr attributes to hash keys */
104 (void)hv_store (hv, "level", 5, newSViv (error ? error->level : 0), 0);
105 (void)hv_store (hv, "code", 4, newSViv (error ? error->code : 0), 0);
106 (void)hv_store (hv, "domain", 6, newSViv (error ? error->domain : VIR_FROM_NONE), 0);
107 (void)hv_store (hv, "message", 7, newSVpv (error && error->message ? error->message : "Unknown problem", 0), 0);
108
109 return sv_bless (newRV_noinc ((SV*) hv), gv_stashpv ("Sys::Virt::Error", TRUE));
110 }
111
112
113 static void
_croak_error(void)114 _croak_error(void)
115 {
116 virErrorPtr error = virGetLastError();
117 sv_setsv(ERRSV, _sv_from_error (error));
118
119 /* croak does not return, so we free this now to avoid leaking */
120 virResetError(error);
121
122 croak (Nullch);
123 }
124
125
126 static void
_populate_constant(HV * stash,const char * name,int val)127 _populate_constant(HV *stash, const char *name, int val)
128 {
129 SV *valsv;
130
131 valsv = newSViv(0);
132 sv_setuv(valsv,val);
133 newCONSTSUB(stash, name, valsv);
134 }
135
136
137 static void
_populate_constant_str(HV * stash,const char * name,const char * value)138 _populate_constant_str(HV *stash, const char *name, const char *value)
139 {
140 SV *valsv;
141
142 valsv = newSVpv(value, strlen(value));
143 newCONSTSUB(stash, name, valsv);
144 }
145
146
147 static void
_populate_constant_ull(HV * stash,const char * name,unsigned long long val)148 _populate_constant_ull(HV *stash, const char *name, unsigned long long val)
149 {
150 SV *valsv;
151
152 valsv = virt_newSVull(val);
153 newCONSTSUB(stash, name, valsv);
154 }
155
156
157 #define REGISTER_CONSTANT(name, key) _populate_constant(stash, #key, name)
158 #define REGISTER_CONSTANT_STR(name, key) _populate_constant_str(stash, #key, name)
159 #define REGISTER_CONSTANT_ULL(name, key) _populate_constant_ull(stash, #key, name)
160
161 static int
_domain_event_lifecycle_callback(virConnectPtr con,virDomainPtr dom,int event,int detail,void * opaque)162 _domain_event_lifecycle_callback(virConnectPtr con,
163 virDomainPtr dom,
164 int event,
165 int detail,
166 void *opaque)
167 {
168 AV *data = opaque;
169 SV **self;
170 SV **cb;
171 SV *domref;
172 dSP;
173
174 self = av_fetch(data, 0, 0);
175 cb = av_fetch(data, 1, 0);
176
177 SvREFCNT_inc(*self);
178
179 ENTER;
180 SAVETMPS;
181
182 PUSHMARK(SP);
183 XPUSHs(*self);
184 domref = sv_newmortal();
185 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
186 virDomainRef(dom);
187 XPUSHs(domref);
188 XPUSHs(sv_2mortal(newSViv(event)));
189 XPUSHs(sv_2mortal(newSViv(detail)));
190 PUTBACK;
191
192 call_sv(*cb, G_DISCARD);
193
194 FREETMPS;
195 LEAVE;
196
197 return 0;
198 }
199
200
201 static int
_domain_event_generic_callback(virConnectPtr con,virDomainPtr dom,void * opaque)202 _domain_event_generic_callback(virConnectPtr con,
203 virDomainPtr dom,
204 void *opaque)
205 {
206 AV *data = opaque;
207 SV **self;
208 SV **cb;
209 SV *domref;
210 dSP;
211
212 self = av_fetch(data, 0, 0);
213 cb = av_fetch(data, 1, 0);
214
215 SvREFCNT_inc(*self);
216
217 ENTER;
218 SAVETMPS;
219
220 PUSHMARK(SP);
221 XPUSHs(*self);
222 domref = sv_newmortal();
223 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
224 virDomainRef(dom);
225 XPUSHs(domref);
226 PUTBACK;
227
228 call_sv(*cb, G_DISCARD);
229
230 FREETMPS;
231 LEAVE;
232
233 return 0;
234 }
235
236
237 static int
_domain_event_rtcchange_callback(virConnectPtr con,virDomainPtr dom,long long utcoffset,void * opaque)238 _domain_event_rtcchange_callback(virConnectPtr con,
239 virDomainPtr dom,
240 long long utcoffset,
241 void *opaque)
242 {
243 AV *data = opaque;
244 SV **self;
245 SV **cb;
246 SV *domref;
247 dSP;
248
249 self = av_fetch(data, 0, 0);
250 cb = av_fetch(data, 1, 0);
251
252 SvREFCNT_inc(*self);
253
254 ENTER;
255 SAVETMPS;
256
257 PUSHMARK(SP);
258 XPUSHs(*self);
259 domref = sv_newmortal();
260 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
261 virDomainRef(dom);
262 XPUSHs(domref);
263 XPUSHs(sv_2mortal(virt_newSVll(utcoffset)));
264 PUTBACK;
265
266 call_sv(*cb, G_DISCARD);
267
268 FREETMPS;
269 LEAVE;
270
271 return 0;
272 }
273
274
275 static int
_domain_event_watchdog_callback(virConnectPtr con,virDomainPtr dom,int action,void * opaque)276 _domain_event_watchdog_callback(virConnectPtr con,
277 virDomainPtr dom,
278 int action,
279 void *opaque)
280 {
281 AV *data = opaque;
282 SV **self;
283 SV **cb;
284 SV *domref;
285 dSP;
286
287 self = av_fetch(data, 0, 0);
288 cb = av_fetch(data, 1, 0);
289
290 SvREFCNT_inc(*self);
291
292 ENTER;
293 SAVETMPS;
294
295 PUSHMARK(SP);
296 XPUSHs(*self);
297 domref = sv_newmortal();
298 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
299 virDomainRef(dom);
300 XPUSHs(domref);
301 XPUSHs(sv_2mortal(newSViv(action)));
302 PUTBACK;
303
304 call_sv(*cb, G_DISCARD);
305
306 FREETMPS;
307 LEAVE;
308
309 return 0;
310 }
311
312
313 static int
_domain_event_io_error_callback(virConnectPtr con,virDomainPtr dom,const char * srcPath,const char * devAlias,int action,void * opaque)314 _domain_event_io_error_callback(virConnectPtr con,
315 virDomainPtr dom,
316 const char *srcPath,
317 const char *devAlias,
318 int action,
319 void *opaque)
320 {
321 AV *data = opaque;
322 SV **self;
323 SV **cb;
324 SV *domref;
325 dSP;
326
327 self = av_fetch(data, 0, 0);
328 cb = av_fetch(data, 1, 0);
329
330 SvREFCNT_inc(*self);
331
332 ENTER;
333 SAVETMPS;
334
335 PUSHMARK(SP);
336 XPUSHs(*self);
337 domref = sv_newmortal();
338 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
339 virDomainRef(dom);
340 XPUSHs(domref);
341 XPUSHs(sv_2mortal(newSVpv(srcPath, 0)));
342 XPUSHs(sv_2mortal(newSVpv(devAlias, 0)));
343 XPUSHs(sv_2mortal(newSViv(action)));
344 PUTBACK;
345
346 call_sv(*cb, G_DISCARD);
347
348 FREETMPS;
349 LEAVE;
350
351 return 0;
352 }
353
354
355 static int
_domain_event_disk_change_callback(virConnectPtr con,virDomainPtr dom,const char * oldSrcPath,const char * newSrcPath,const char * devAlias,int reason,void * opaque)356 _domain_event_disk_change_callback(virConnectPtr con,
357 virDomainPtr dom,
358 const char *oldSrcPath,
359 const char *newSrcPath,
360 const char *devAlias,
361 int reason,
362 void *opaque)
363 {
364 AV *data = opaque;
365 SV **self;
366 SV **cb;
367 SV *domref;
368 dSP;
369
370 self = av_fetch(data, 0, 0);
371 cb = av_fetch(data, 1, 0);
372
373 SvREFCNT_inc(*self);
374
375 ENTER;
376 SAVETMPS;
377
378 PUSHMARK(SP);
379 XPUSHs(*self);
380 domref = sv_newmortal();
381 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
382 virDomainRef(dom);
383 XPUSHs(domref);
384 XPUSHs(sv_2mortal(newSVpv(oldSrcPath, 0)));
385 XPUSHs(sv_2mortal(newSVpv(newSrcPath, 0)));
386 XPUSHs(sv_2mortal(newSVpv(devAlias, 0)));
387 XPUSHs(sv_2mortal(newSViv(reason)));
388 PUTBACK;
389
390 call_sv(*cb, G_DISCARD);
391
392 FREETMPS;
393 LEAVE;
394
395 return 0;
396 }
397
398
399 static int
_domain_event_tray_change_callback(virConnectPtr con,virDomainPtr dom,const char * devAlias,int reason,void * opaque)400 _domain_event_tray_change_callback(virConnectPtr con,
401 virDomainPtr dom,
402 const char *devAlias,
403 int reason,
404 void *opaque)
405 {
406 AV *data = opaque;
407 SV **self;
408 SV **cb;
409 SV *domref;
410 dSP;
411
412 self = av_fetch(data, 0, 0);
413 cb = av_fetch(data, 1, 0);
414
415 SvREFCNT_inc(*self);
416
417 ENTER;
418 SAVETMPS;
419
420 PUSHMARK(SP);
421 XPUSHs(*self);
422 domref = sv_newmortal();
423 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
424 virDomainRef(dom);
425 XPUSHs(domref);
426 XPUSHs(sv_2mortal(newSVpv(devAlias, 0)));
427 XPUSHs(sv_2mortal(newSViv(reason)));
428 PUTBACK;
429
430 call_sv(*cb, G_DISCARD);
431
432 FREETMPS;
433 LEAVE;
434
435 return 0;
436 }
437
438
439 static int
_domain_event_pmwakeup_callback(virConnectPtr con,virDomainPtr dom,int reason,void * opaque)440 _domain_event_pmwakeup_callback(virConnectPtr con,
441 virDomainPtr dom,
442 int reason,
443 void *opaque)
444 {
445 AV *data = opaque;
446 SV **self;
447 SV **cb;
448 SV *domref;
449 dSP;
450
451 self = av_fetch(data, 0, 0);
452 cb = av_fetch(data, 1, 0);
453
454 SvREFCNT_inc(*self);
455
456 ENTER;
457 SAVETMPS;
458
459 PUSHMARK(SP);
460 XPUSHs(*self);
461 domref = sv_newmortal();
462 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
463 virDomainRef(dom);
464 XPUSHs(domref);
465 XPUSHs(sv_2mortal(newSViv(reason)));
466 PUTBACK;
467
468 call_sv(*cb, G_DISCARD);
469
470 FREETMPS;
471 LEAVE;
472
473 return 0;
474 }
475
476
477 static int
_domain_event_pmsuspend_callback(virConnectPtr con,virDomainPtr dom,int reason,void * opaque)478 _domain_event_pmsuspend_callback(virConnectPtr con,
479 virDomainPtr dom,
480 int reason,
481 void *opaque)
482 {
483 AV *data = opaque;
484 SV **self;
485 SV **cb;
486 SV *domref;
487 dSP;
488
489 self = av_fetch(data, 0, 0);
490 cb = av_fetch(data, 1, 0);
491
492 SvREFCNT_inc(*self);
493
494 ENTER;
495 SAVETMPS;
496
497 PUSHMARK(SP);
498 XPUSHs(*self);
499 domref = sv_newmortal();
500 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
501 virDomainRef(dom);
502 XPUSHs(domref);
503 XPUSHs(sv_2mortal(newSViv(reason)));
504 PUTBACK;
505
506 call_sv(*cb, G_DISCARD);
507
508 FREETMPS;
509 LEAVE;
510
511 return 0;
512 }
513
514
515 static int
_domain_event_pmsuspend_disk_callback(virConnectPtr con,virDomainPtr dom,int reason,void * opaque)516 _domain_event_pmsuspend_disk_callback(virConnectPtr con,
517 virDomainPtr dom,
518 int reason,
519 void *opaque)
520 {
521 AV *data = opaque;
522 SV **self;
523 SV **cb;
524 SV *domref;
525 dSP;
526
527 self = av_fetch(data, 0, 0);
528 cb = av_fetch(data, 1, 0);
529
530 SvREFCNT_inc(*self);
531
532 ENTER;
533 SAVETMPS;
534
535 PUSHMARK(SP);
536 XPUSHs(*self);
537 domref = sv_newmortal();
538 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
539 virDomainRef(dom);
540 XPUSHs(domref);
541 XPUSHs(sv_2mortal(newSViv(reason)));
542 PUTBACK;
543
544 call_sv(*cb, G_DISCARD);
545
546 FREETMPS;
547 LEAVE;
548
549 return 0;
550 }
551
552
553 static int
_domain_event_io_error_reason_callback(virConnectPtr con,virDomainPtr dom,const char * srcPath,const char * devAlias,int action,const char * reason,void * opaque)554 _domain_event_io_error_reason_callback(virConnectPtr con,
555 virDomainPtr dom,
556 const char *srcPath,
557 const char *devAlias,
558 int action,
559 const char *reason,
560 void *opaque)
561 {
562 AV *data = opaque;
563 SV **self;
564 SV **cb;
565 SV *domref;
566 dSP;
567
568 self = av_fetch(data, 0, 0);
569 cb = av_fetch(data, 1, 0);
570
571 SvREFCNT_inc(*self);
572
573 ENTER;
574 SAVETMPS;
575
576 PUSHMARK(SP);
577 XPUSHs(*self);
578 domref = sv_newmortal();
579 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
580 virDomainRef(dom);
581 XPUSHs(domref);
582 XPUSHs(sv_2mortal(newSVpv(srcPath, 0)));
583 XPUSHs(sv_2mortal(newSVpv(devAlias, 0)));
584 XPUSHs(sv_2mortal(newSViv(action)));
585 XPUSHs(sv_2mortal(newSVpv(reason, 0)));
586 PUTBACK;
587
588 call_sv(*cb, G_DISCARD);
589
590 FREETMPS;
591 LEAVE;
592
593 return 0;
594 }
595
596
597 static int
_domain_event_graphics_callback(virConnectPtr con,virDomainPtr dom,int phase,virDomainEventGraphicsAddressPtr local,virDomainEventGraphicsAddressPtr remote,const char * authScheme,virDomainEventGraphicsSubjectPtr subject,void * opaque)598 _domain_event_graphics_callback(virConnectPtr con,
599 virDomainPtr dom,
600 int phase,
601 virDomainEventGraphicsAddressPtr local,
602 virDomainEventGraphicsAddressPtr remote,
603 const char *authScheme,
604 virDomainEventGraphicsSubjectPtr subject,
605 void *opaque)
606 {
607 AV *data = opaque;
608 SV **self;
609 SV **cb;
610 SV *domref;
611 HV *local_hv;
612 HV *remote_hv;
613 AV *subject_av;
614 int i;
615 dSP;
616
617 self = av_fetch(data, 0, 0);
618 cb = av_fetch(data, 1, 0);
619
620 local_hv = newHV();
621 (void)hv_store(local_hv, "family", 6, newSViv(local->family), 0);
622 (void)hv_store(local_hv, "node", 4, newSVpv(local->node, 0), 0);
623 (void)hv_store(local_hv, "service", 7, newSVpv(local->service, 0), 0);
624
625 remote_hv = newHV();
626 (void)hv_store(remote_hv, "family", 6, newSViv(remote->family), 0);
627 (void)hv_store(remote_hv, "node", 4, newSVpv(remote->node, 0), 0);
628 (void)hv_store(remote_hv, "service", 7, newSVpv(remote->service, 0), 0);
629
630 subject_av = newAV();
631 for (i = 0 ; i < subject->nidentity ; i++) {
632 HV *identity = newHV();
633 (void)hv_store(identity, "type", 4, newSVpv(subject->identities[i].type, 0), 0);
634 (void)hv_store(identity, "name", 4, newSVpv(subject->identities[i].name, 0), 0);
635
636 av_push(subject_av, newRV_noinc((SV *)identity));
637 }
638
639 SvREFCNT_inc(*self);
640
641 ENTER;
642 SAVETMPS;
643
644 PUSHMARK(SP);
645 XPUSHs(*self);
646 domref = sv_newmortal();
647 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
648 virDomainRef(dom);
649 XPUSHs(domref);
650 XPUSHs(sv_2mortal(newSViv(phase)));
651 XPUSHs(newRV_noinc((SV*)local_hv));
652 XPUSHs(newRV_noinc((SV*)remote_hv));
653 XPUSHs(sv_2mortal(newSVpv(authScheme, 0)));
654 XPUSHs(newRV_noinc((SV*)subject_av));
655 PUTBACK;
656
657 call_sv(*cb, G_DISCARD);
658
659 FREETMPS;
660 LEAVE;
661
662 return 0;
663 }
664
665
666 static int
_domain_event_block_job_callback(virConnectPtr con,virDomainPtr dom,const char * path,int type,int status,void * opaque)667 _domain_event_block_job_callback(virConnectPtr con,
668 virDomainPtr dom,
669 const char *path,
670 int type,
671 int status,
672 void *opaque)
673 {
674 AV *data = opaque;
675 SV **self;
676 SV **cb;
677 SV *domref;
678 dSP;
679
680 self = av_fetch(data, 0, 0);
681 cb = av_fetch(data, 1, 0);
682
683 SvREFCNT_inc(*self);
684
685 ENTER;
686 SAVETMPS;
687
688 PUSHMARK(SP);
689 XPUSHs(*self);
690 domref = sv_newmortal();
691 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
692 virDomainRef(dom);
693 XPUSHs(domref);
694 XPUSHs(sv_2mortal(newSVpv(path, 0)));
695 XPUSHs(sv_2mortal(newSViv(type)));
696 XPUSHs(sv_2mortal(newSViv(status)));
697 PUTBACK;
698
699 call_sv(*cb, G_DISCARD);
700
701 FREETMPS;
702 LEAVE;
703
704 return 0;
705 }
706
707
708 static int
_domain_event_balloonchange_callback(virConnectPtr con,virDomainPtr dom,unsigned long long actual,void * opaque)709 _domain_event_balloonchange_callback(virConnectPtr con,
710 virDomainPtr dom,
711 unsigned long long actual,
712 void *opaque)
713 {
714 AV *data = opaque;
715 SV **self;
716 SV **cb;
717 SV *domref;
718 dSP;
719
720 self = av_fetch(data, 0, 0);
721 cb = av_fetch(data, 1, 0);
722
723 SvREFCNT_inc(*self);
724
725 ENTER;
726 SAVETMPS;
727
728 PUSHMARK(SP);
729 XPUSHs(*self);
730 domref = sv_newmortal();
731 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
732 virDomainRef(dom);
733 XPUSHs(domref);
734 XPUSHs(sv_2mortal(virt_newSVull(actual)));
735 PUTBACK;
736
737 call_sv(*cb, G_DISCARD);
738
739 FREETMPS;
740 LEAVE;
741
742 return 0;
743 }
744
745
746 static int
_domain_event_device_removed_callback(virConnectPtr con,virDomainPtr dom,const char * devAlias,void * opaque)747 _domain_event_device_removed_callback(virConnectPtr con,
748 virDomainPtr dom,
749 const char *devAlias,
750 void *opaque)
751 {
752 AV *data = opaque;
753 SV **self;
754 SV **cb;
755 SV *domref;
756 dSP;
757
758 self = av_fetch(data, 0, 0);
759 cb = av_fetch(data, 1, 0);
760
761 SvREFCNT_inc(*self);
762
763 ENTER;
764 SAVETMPS;
765
766 PUSHMARK(SP);
767 XPUSHs(*self);
768 domref = sv_newmortal();
769 sv_setref_pv(domref, "Sys::Virt::Domain", (void*)dom);
770 virDomainRef(dom);
771 XPUSHs(domref);
772 XPUSHs(sv_2mortal(newSVpv(devAlias, 0)));
773 PUTBACK;
774
775 call_sv(*cb, G_DISCARD);
776
777 FREETMPS;
778 LEAVE;
779
780 return 0;
781 }
782
783
784 static void
_domain_event_free(void * opaque)785 _domain_event_free(void *opaque)
786 {
787 SV *sv = opaque;
788 SvREFCNT_dec(sv);
789 }
790
791
792 static void
_close_callback(virConnectPtr con,int reason,void * opaque)793 _close_callback(virConnectPtr con,
794 int reason,
795 void *opaque)
796 {
797 AV *data = opaque;
798 SV **self;
799 SV **cb;
800 dSP;
801
802 self = av_fetch(data, 0, 0);
803 cb = av_fetch(data, 1, 0);
804
805 SvREFCNT_inc(*self);
806
807 ENTER;
808 SAVETMPS;
809
810 PUSHMARK(SP);
811 XPUSHs(*self);
812 XPUSHs(sv_2mortal(newSViv(reason)));
813 PUTBACK;
814
815 call_sv(*cb, G_DISCARD);
816
817 FREETMPS;
818 LEAVE;
819 }
820
821
822 static void
_close_callback_free(void * opaque)823 _close_callback_free(void *opaque)
824 {
825 SV *sv = opaque;
826 SvREFCNT_dec(sv);
827 }
828
829
830 static int
_event_add_handle(int fd,int events,virEventHandleCallback cb,void * opaque,virFreeCallback ff)831 _event_add_handle(int fd,
832 int events,
833 virEventHandleCallback cb,
834 void *opaque,
835 virFreeCallback ff)
836 {
837 SV *cbref;
838 SV *opaqueref;
839 SV *ffref;
840 int ret;
841 int watch = 0;
842 dSP;
843
844 ENTER;
845 SAVETMPS;
846
847 cbref= sv_newmortal();
848 opaqueref= sv_newmortal();
849 ffref= sv_newmortal();
850
851 sv_setref_pv(cbref, NULL, cb);
852 sv_setref_pv(opaqueref, NULL, opaque);
853 sv_setref_pv(ffref, NULL, ff);
854
855 PUSHMARK(SP);
856 XPUSHs(sv_2mortal(newSViv(fd)));
857 XPUSHs(sv_2mortal(newSViv(events)));
858 XPUSHs(cbref);
859 XPUSHs(opaqueref);
860 XPUSHs(ffref);
861 PUTBACK;
862
863 ret = call_pv("Sys::Virt::Event::_add_handle", G_SCALAR);
864
865 SPAGAIN;
866
867 if (ret == 1)
868 watch = POPi;
869
870 FREETMPS;
871 LEAVE;
872
873 if (ret != 1)
874 return -1;
875
876 return watch;
877 }
878
879
880 static void
_event_update_handle(int watch,int events)881 _event_update_handle(int watch,
882 int events)
883 {
884 dSP;
885
886 ENTER;
887 SAVETMPS;
888
889 PUSHMARK(SP);
890 XPUSHs(sv_2mortal(newSViv(watch)));
891 XPUSHs(sv_2mortal(newSViv(events)));
892 PUTBACK;
893
894 call_pv("Sys::Virt::Event::_update_handle", G_DISCARD);
895
896 FREETMPS;
897 LEAVE;
898 }
899
900
901 static int
_event_remove_handle(int watch)902 _event_remove_handle(int watch)
903 {
904 dSP;
905
906 ENTER;
907 SAVETMPS;
908
909 PUSHMARK(SP);
910 XPUSHs(sv_2mortal(newSViv(watch)));
911 PUTBACK;
912
913 call_pv("Sys::Virt::Event::_remove_handle", G_DISCARD);
914
915 FREETMPS;
916 LEAVE;
917
918 return 0;
919 return 0;
920 }
921
922
923 static int
_event_add_timeout(int interval,virEventTimeoutCallback cb,void * opaque,virFreeCallback ff)924 _event_add_timeout(int interval,
925 virEventTimeoutCallback cb,
926 void *opaque,
927 virFreeCallback ff)
928 {
929 SV *cbref;
930 SV *opaqueref;
931 SV *ffref;
932 int ret;
933 int timer = 0;
934 dSP;
935
936 ENTER;
937 SAVETMPS;
938
939 cbref = sv_newmortal();
940 opaqueref = sv_newmortal();
941 ffref = sv_newmortal();
942
943 sv_setref_pv(cbref, NULL, cb);
944 sv_setref_pv(opaqueref, NULL, opaque);
945 sv_setref_pv(ffref, NULL, ff);
946
947 PUSHMARK(SP);
948 XPUSHs(sv_2mortal(newSViv(interval)));
949 XPUSHs(cbref);
950 XPUSHs(opaqueref);
951 XPUSHs(ffref);
952 PUTBACK;
953
954 ret = call_pv("Sys::Virt::Event::_add_timeout", G_SCALAR);
955
956 SPAGAIN;
957
958 if (ret == 1)
959 timer = POPi;
960
961 FREETMPS;
962 LEAVE;
963
964 if (ret != 1)
965 return -1;
966
967 return timer;
968 }
969
970
971 static void
_event_update_timeout(int timer,int interval)972 _event_update_timeout(int timer,
973 int interval)
974 {
975 dSP;
976
977 ENTER;
978 SAVETMPS;
979
980 PUSHMARK(SP);
981 XPUSHs(sv_2mortal(newSViv(timer)));
982 XPUSHs(sv_2mortal(newSViv(interval)));
983 PUTBACK;
984
985 call_pv("Sys::Virt::Event::_update_timeout", G_DISCARD);
986
987 FREETMPS;
988 LEAVE;
989 }
990
991
992 static int
_event_remove_timeout(int timer)993 _event_remove_timeout(int timer)
994 {
995 dSP;
996
997 ENTER;
998 SAVETMPS;
999
1000 PUSHMARK(SP);
1001 XPUSHs(sv_2mortal(newSViv(timer)));
1002 PUTBACK;
1003
1004 call_pv("Sys::Virt::Event::_remove_timeout", G_DISCARD);
1005
1006 FREETMPS;
1007 LEAVE;
1008
1009 return 0;
1010 }
1011
1012
1013 static int
_open_auth_callback(virConnectCredentialPtr cred,unsigned int ncred,void * cbdata)1014 _open_auth_callback(virConnectCredentialPtr cred,
1015 unsigned int ncred,
1016 void *cbdata)
1017 {
1018 dSP;
1019 int i, ret, success = -1;
1020 AV *credlist;
1021
1022 credlist = newAV();
1023
1024 ENTER;
1025 SAVETMPS;
1026 PUSHMARK(SP);
1027
1028 for (i = 0 ; i < ncred ; i++) {
1029 HV *credrec = newHV();
1030
1031 (void)hv_store(credrec, "type", 4, newSViv(cred[i].type), 0);
1032 (void)hv_store(credrec, "prompt", 6, newSVpv(cred[i].prompt, 0), 0);
1033 (void)hv_store(credrec, "challenge", 9, newSVpv(cred[i].challenge, 0), 0);
1034 if (cred[i].defresult != NULL)
1035 (void)hv_store(credrec, "result", 6, newSVpv(cred[i].defresult, 0), 0);
1036 else
1037 (void)hv_fetch(credrec, "result", 6, 1);
1038
1039 av_push(credlist, newRV_noinc((SV *)credrec));
1040 }
1041 SvREFCNT_inc((SV*)credlist);
1042
1043 XPUSHs(newRV_noinc((SV*)credlist));
1044 PUTBACK;
1045
1046 ret = call_sv((SV*)cbdata, G_SCALAR);
1047
1048 SPAGAIN;
1049
1050 if (ret == 1)
1051 success = POPi;
1052
1053 for (i = 0 ; i < ncred ; i++) {
1054 SV **credsv = av_fetch(credlist, i, 0);
1055 HV *credrec = (HV*)SvRV(*credsv);
1056 SV **val = hv_fetch(credrec, "result", 6, 0);
1057
1058 if (val && SvOK(*val)) {
1059 STRLEN len;
1060 char *result = SvPV(*val, len);
1061 if (!(cred[i].result = malloc(len+1)))
1062 abort();
1063 memcpy(cred[i].result, result, len+1);
1064 cred[i].resultlen = (unsigned int)len;
1065 } else {
1066 cred[i].resultlen = 0;
1067 cred[i].result = NULL;
1068 }
1069 }
1070
1071 FREETMPS;
1072 LEAVE;
1073
1074 return success;
1075 }
1076
1077
1078 static void
_event_handle_helper(int watch,int fd,int events,void * opaque)1079 _event_handle_helper(int watch,
1080 int fd,
1081 int events,
1082 void *opaque)
1083 {
1084 SV *cb = opaque;
1085 dSP;
1086
1087 SvREFCNT_inc(cb);
1088
1089 ENTER;
1090 SAVETMPS;
1091
1092 PUSHMARK(SP);
1093 XPUSHs(sv_2mortal(newSViv(watch)));
1094 XPUSHs(sv_2mortal(newSViv(fd)));
1095 XPUSHs(sv_2mortal(newSViv(events)));
1096 PUTBACK;
1097
1098 call_sv(cb, G_DISCARD);
1099
1100 FREETMPS;
1101 LEAVE;
1102 }
1103
1104
1105 static void
_event_timeout_helper(int timer,void * opaque)1106 _event_timeout_helper(int timer,
1107 void *opaque)
1108 {
1109 SV *cb = opaque;
1110 dSP;
1111
1112 SvREFCNT_inc(cb);
1113
1114 ENTER;
1115 SAVETMPS;
1116
1117 PUSHMARK(SP);
1118 XPUSHs(sv_2mortal(newSViv(timer)));
1119 PUTBACK;
1120
1121 call_sv(cb, G_DISCARD);
1122
1123 FREETMPS;
1124 LEAVE;
1125 }
1126
1127
1128 static void
_event_cb_free(void * opaque)1129 _event_cb_free(void *opaque)
1130 {
1131 SV *data = opaque;
1132 SvREFCNT_dec(data);
1133 }
1134
1135
1136 static void
_stream_event_callback(virStreamPtr st,int events,void * opaque)1137 _stream_event_callback(virStreamPtr st,
1138 int events,
1139 void *opaque)
1140 {
1141 AV *data = opaque;
1142 SV **self;
1143 SV **cb;
1144 dSP;
1145
1146 self = av_fetch(data, 0, 0);
1147 cb = av_fetch(data, 1, 0);
1148
1149 SvREFCNT_inc(*self);
1150
1151 ENTER;
1152 SAVETMPS;
1153
1154 PUSHMARK(SP);
1155 XPUSHs(*self);
1156 XPUSHs(sv_2mortal(newSViv(events)));
1157 PUTBACK;
1158
1159 call_sv(*cb, G_DISCARD);
1160
1161 FREETMPS;
1162 LEAVE;
1163 }
1164
1165
1166 static void
_stream_event_free(void * opaque)1167 _stream_event_free(void *opaque)
1168 {
1169 AV *data = opaque;
1170 SvREFCNT_dec(data);
1171 }
1172
1173
1174 static int
_stream_send_all_source(virStreamPtr st,char * data,size_t nbytes,void * opaque)1175 _stream_send_all_source(virStreamPtr st,
1176 char *data,
1177 size_t nbytes,
1178 void *opaque)
1179 {
1180 AV *av = opaque;
1181 SV **self;
1182 SV **handler;
1183 SV *datasv;
1184 int rv;
1185 int ret;
1186 dSP;
1187
1188 self = av_fetch(av, 0, 0);
1189 handler = av_fetch(av, 1, 0);
1190 datasv = newSVpv("", 0);
1191
1192 SvREFCNT_inc(*self);
1193
1194 ENTER;
1195 SAVETMPS;
1196
1197 PUSHMARK(SP);
1198 XPUSHs(*self);
1199 XPUSHs(datasv);
1200 XPUSHs(sv_2mortal(newSViv(nbytes)));
1201 PUTBACK;
1202
1203 rv = call_sv((SV*)*handler, G_SCALAR);
1204
1205 SPAGAIN;
1206
1207 if (rv == 1) {
1208 ret = POPi;
1209 } else {
1210 ret = -1;
1211 }
1212
1213 if (ret > 0) {
1214 const char *newdata = SvPV_nolen(datasv);
1215 if (ret > nbytes)
1216 ret = nbytes;
1217 strncpy(data, newdata, nbytes);
1218 }
1219
1220 FREETMPS;
1221 LEAVE;
1222
1223 SvREFCNT_dec(datasv);
1224
1225 return ret;
1226 }
1227
1228
1229 static int
_stream_recv_all_sink(virStreamPtr st,const char * data,size_t nbytes,void * opaque)1230 _stream_recv_all_sink(virStreamPtr st,
1231 const char *data,
1232 size_t nbytes,
1233 void *opaque)
1234 {
1235 AV *av = opaque;
1236 SV **self;
1237 SV **handler;
1238 SV *datasv;
1239 int rv;
1240 int ret;
1241 dSP;
1242
1243 self = av_fetch(av, 0, 0);
1244 handler = av_fetch(av, 1, 0);
1245 datasv = newSVpv(data, nbytes);
1246
1247 SvREFCNT_inc(*self);
1248
1249 ENTER;
1250 SAVETMPS;
1251
1252 PUSHMARK(SP);
1253 XPUSHs(*self);
1254 XPUSHs(datasv);
1255 XPUSHs(sv_2mortal(newSViv(nbytes)));
1256 PUTBACK;
1257
1258 rv = call_sv((SV*)*handler, G_SCALAR);
1259
1260 SPAGAIN;
1261
1262 if (rv == 1) {
1263 ret = POPi;
1264 } else {
1265 ret = -1;
1266 }
1267
1268 FREETMPS;
1269 LEAVE;
1270
1271 SvREFCNT_dec(datasv);
1272
1273 return ret;
1274 }
1275
1276
1277 static HV *
vir_typed_param_to_hv(virTypedParameter * params,int nparams)1278 vir_typed_param_to_hv(virTypedParameter *params, int nparams)
1279 {
1280 HV *ret = (HV *)sv_2mortal((SV*)newHV());
1281 unsigned int i;
1282 const char *field;
1283 STRLEN val_length;
1284
1285 for (i = 0 ; i < nparams ; i++) {
1286 SV *val = NULL;
1287
1288 switch (params[i].type) {
1289 case VIR_TYPED_PARAM_INT:
1290 val = newSViv(params[i].value.i);
1291 break;
1292
1293 case VIR_TYPED_PARAM_UINT:
1294 val = newSViv((int)params[i].value.ui);
1295 break;
1296
1297 case VIR_TYPED_PARAM_LLONG:
1298 val = virt_newSVll(params[i].value.l);
1299 break;
1300
1301 case VIR_TYPED_PARAM_ULLONG:
1302 val = virt_newSVull(params[i].value.ul);
1303 break;
1304
1305 case VIR_TYPED_PARAM_DOUBLE:
1306 val = newSVnv(params[i].value.d);
1307 break;
1308
1309 case VIR_TYPED_PARAM_BOOLEAN:
1310 val = newSViv(params[i].value.b);
1311 break;
1312
1313 case VIR_TYPED_PARAM_STRING:
1314 val_length = strlen(params[i].value.s);
1315 val = newSVpv(params[i].value.s, val_length);
1316 break;
1317
1318 }
1319
1320 field = params[i].field;
1321 (void)hv_store(ret, field, strlen(params[i].field), val, 0);
1322 }
1323
1324 return ret;
1325 }
1326
1327
1328 static int
vir_typed_param_from_hv(HV * newparams,virTypedParameter * params,int nparams)1329 vir_typed_param_from_hv(HV *newparams, virTypedParameter *params, int nparams)
1330 {
1331 unsigned int i;
1332 char * ptr;
1333 STRLEN len;
1334
1335 /* We only want to set parameters which we're actually changing
1336 * so here we figure out which elements of 'params' we need to
1337 * update, and overwrite the others
1338 */
1339 for (i = 0 ; i < nparams ;) {
1340 if (!hv_exists(newparams, params[i].field, strlen(params[i].field))) {
1341 if ((nparams-i) > 1)
1342 memmove(params+i, params+i+1, sizeof(*params)*(nparams-(i+1)));
1343 nparams--;
1344 continue;
1345 }
1346
1347 i++;
1348 }
1349
1350 for (i = 0 ; i < nparams ; i++) {
1351 SV **val;
1352
1353 val = hv_fetch (newparams, params[i].field, strlen(params[i].field), 0);
1354
1355 switch (params[i].type) {
1356 case VIR_TYPED_PARAM_INT:
1357 params[i].value.i = SvIV(*val);
1358 break;
1359
1360 case VIR_TYPED_PARAM_UINT:
1361 params[i].value.ui = SvIV(*val);
1362 break;
1363
1364 case VIR_TYPED_PARAM_LLONG:
1365 params[i].value.l = virt_SvIVll(*val);
1366 break;
1367
1368 case VIR_TYPED_PARAM_ULLONG:
1369 params[i].value.ul = virt_SvIVull(*val);
1370 break;
1371
1372 case VIR_TYPED_PARAM_DOUBLE:
1373 params[i].value.d = SvNV(*val);
1374 break;
1375
1376 case VIR_TYPED_PARAM_BOOLEAN:
1377 params[i].value.b = SvIV(*val);
1378 break;
1379
1380 case VIR_TYPED_PARAM_STRING:
1381 ptr = SvPV(*val, len);
1382 params[i].value.s = (char *)ptr;
1383 break;
1384 }
1385 }
1386
1387 return nparams;
1388 }
1389
1390
1391 MODULE = Sys::Virt PACKAGE = Sys::Virt
1392
1393 PROTOTYPES: ENABLE
1394
1395 virConnectPtr
1396 _open(name, flags)
1397 SV *name;
1398 unsigned int flags;
1399 PREINIT:
1400 const char *uri = NULL;
1401 CODE:
1402 if (SvOK(name))
1403 uri = SvPV_nolen(name);
1404
1405 if (!(RETVAL = virConnectOpenAuth(uri, NULL, flags)))
1406 _croak_error();
1407 OUTPUT:
1408 RETVAL
1409
1410
1411 virConnectPtr
1412 _open_auth(name, creds, cb, flags)
1413 SV *name;
1414 SV *creds;
1415 SV *cb;
1416 unsigned int flags;
1417 PREINIT:
1418 AV *credlist;
1419 virConnectAuth auth;
1420 int i;
1421 const char *uri = NULL;
1422 CODE:
1423 if (SvOK(name))
1424 uri = SvPV_nolen(name);
1425
1426 if (SvOK(cb) && SvOK(creds)) {
1427 memset(&auth, 0, sizeof auth);
1428 credlist = (AV*)SvRV(creds);
1429 auth.ncredtype = av_len(credlist) + 1;
1430 Newx(auth.credtype, auth.ncredtype, int);
1431 for (i = 0 ; i < auth.ncredtype ; i++) {
1432 SV **type = av_fetch(credlist, i, 0);
1433 auth.credtype[i] = SvIV(*type);
1434 }
1435
1436 auth.cb = _open_auth_callback;
1437 auth.cbdata = cb;
1438 RETVAL = virConnectOpenAuth(uri,
1439 &auth,
1440 flags);
1441 Safefree(auth.credtype);
1442 } else {
1443 RETVAL = virConnectOpenAuth(uri,
1444 virConnectAuthPtrDefault,
1445 flags);
1446 }
1447 if (!RETVAL)
1448 _croak_error();
1449 OUTPUT:
1450 RETVAL
1451
1452
1453 void
1454 restore_domain(con, from, dxmlsv=&PL_sv_undef, flags=0)
1455 virConnectPtr con;
1456 const char *from;
1457 SV *dxmlsv;
1458 unsigned int flags;
1459 PREINIT:
1460 const char *dxml = NULL;
1461 PPCODE:
1462 if (SvOK(dxmlsv))
1463 dxml = SvPV_nolen(dxmlsv);
1464
1465 if (dxml || flags) {
1466 if (virDomainRestoreFlags(con, from, dxml, flags) < 0)
1467 _croak_error();
1468 } else {
1469 if (virDomainRestore(con, from) < 0)
1470 _croak_error();
1471 }
1472
1473
1474 SV *
1475 get_save_image_xml_description(con, file, flags=0)
1476 virConnectPtr con;
1477 const char *file;
1478 unsigned int flags;
1479 PREINIT:
1480 char *xml;
1481 CODE:
1482 if (!(xml = virDomainSaveImageGetXMLDesc(con, file, flags)))
1483 _croak_error();
1484 RETVAL = newSVpv(xml, 0);
1485 free(xml);
1486 OUTPUT:
1487 RETVAL
1488
1489
1490 void
1491 define_save_image_xml(con, file, xml, flags=0)
1492 virConnectPtr con;
1493 const char *file;
1494 const char *xml;
1495 unsigned int flags;
1496 PPCODE:
1497 if (virDomainSaveImageDefineXML(con, file, xml, flags) < 0)
1498 _croak_error();
1499
1500
1501
1502 unsigned long
1503 _get_library_version(void)
1504 PREINIT:
1505 unsigned long version;
1506 CODE:
1507 if (virGetVersion(&version, NULL, NULL) < 0)
1508 _croak_error();
1509 RETVAL = version;
1510 OUTPUT:
1511 RETVAL
1512
1513
1514 unsigned long
1515 _get_conn_version(con)
1516 virConnectPtr con;
1517 PREINIT:
1518 unsigned long version;
1519 CODE:
1520 if (virConnectGetVersion(con, &version) < 0)
1521 _croak_error();
1522 RETVAL = version;
1523 OUTPUT:
1524 RETVAL
1525
1526
1527 unsigned long
1528 _get_conn_library_version(con)
1529 virConnectPtr con;
1530 PREINIT:
1531 unsigned long version;
1532 CODE:
1533 if (virConnectGetLibVersion(con, &version) < 0)
1534 _croak_error();
1535 RETVAL = version;
1536 OUTPUT:
1537 RETVAL
1538
1539
1540 int
1541 is_encrypted(conn)
1542 virConnectPtr conn;
1543 CODE:
1544 if ((RETVAL = virConnectIsEncrypted(conn)) < 0)
1545 _croak_error();
1546 OUTPUT:
1547 RETVAL
1548
1549
1550 int
1551 is_secure(conn)
1552 virConnectPtr conn;
1553 CODE:
1554 if ((RETVAL = virConnectIsSecure(conn)) < 0)
1555 _croak_error();
1556 OUTPUT:
1557 RETVAL
1558
1559
1560 int
1561 is_alive(conn)
1562 virConnectPtr conn;
1563 CODE:
1564 if ((RETVAL = virConnectIsAlive(conn)) < 0)
1565 _croak_error();
1566 OUTPUT:
1567 RETVAL
1568
1569
1570 void
1571 set_keep_alive(conn, interval, count)
1572 virConnectPtr conn;
1573 int interval;
1574 unsigned int count;
1575 PPCODE:
1576 if (virConnectSetKeepAlive(conn, interval, count) < 0)
1577 _croak_error();
1578
1579
1580 const char *
1581 get_type(con)
1582 virConnectPtr con;
1583 CODE:
1584 RETVAL = virConnectGetType(con);
1585 OUTPUT:
1586 RETVAL
1587
1588
1589 char *
1590 get_uri(con)
1591 virConnectPtr con;
1592 CODE:
1593 RETVAL = virConnectGetURI(con);
1594 OUTPUT:
1595 RETVAL
1596
1597
1598 char *
1599 get_sysinfo(con, flags=0)
1600 virConnectPtr con;
1601 unsigned int flags;
1602 CODE:
1603 RETVAL = virConnectGetSysinfo(con, flags);
1604 OUTPUT:
1605 RETVAL
1606
1607
1608 HV *
1609 get_node_info(con)
1610 virConnectPtr con;
1611 PREINIT:
1612 virNodeInfo info;
1613 CODE:
1614 if (virNodeGetInfo(con, &info) < 0)
1615 _croak_error();
1616
1617 RETVAL = (HV *)sv_2mortal((SV*)newHV());
1618 (void)hv_store (RETVAL, "model", 5, newSVpv(info.model, 0), 0);
1619 (void)hv_store (RETVAL, "memory", 6, newSViv(info.memory), 0);
1620 (void)hv_store (RETVAL, "cpus", 4, newSViv(info.cpus), 0);
1621 (void)hv_store (RETVAL, "mhz", 3, newSViv(info.mhz), 0);
1622 (void)hv_store (RETVAL, "nodes", 5, newSViv(info.nodes), 0);
1623 (void)hv_store (RETVAL, "sockets", 7, newSViv(info.sockets), 0);
1624 (void)hv_store (RETVAL, "cores", 5, newSViv(info.cores), 0);
1625 (void)hv_store (RETVAL, "threads", 7, newSViv(info.threads), 0);
1626 OUTPUT:
1627 RETVAL
1628
1629
1630 HV *
1631 get_node_security_model(con)
1632 virConnectPtr con;
1633 PREINIT:
1634 virSecurityModel secmodel;
1635 CODE:
1636 if (virNodeGetSecurityModel(con, &secmodel) < 0)
1637 _croak_error();
1638
1639 RETVAL = (HV *)sv_2mortal((SV*)newHV());
1640 (void)hv_store (RETVAL, "model", 5, newSVpv(secmodel.model, 0), 0);
1641 (void)hv_store (RETVAL, "doi", 3, newSVpv(secmodel.doi, 0), 0);
1642 OUTPUT:
1643 RETVAL
1644
1645 void
1646 get_node_cpu_map(con, flags=0)
1647 virConnectPtr con;
1648 unsigned int flags;
1649 PREINIT:
1650 unsigned char *cpumaps;
1651 unsigned int online;
1652 int ncpus;
1653 PPCODE:
1654 if ((ncpus = virNodeGetCPUMap(con, &cpumaps, &online, flags)) < 0)
1655 _croak_error();
1656
1657 EXTEND(SP, 3);
1658 PUSHs(sv_2mortal(newSViv(ncpus)));
1659 PUSHs(sv_2mortal(newSVpvn((char*)cpumaps, VIR_CPU_MAPLEN(ncpus))));
1660 PUSHs(sv_2mortal(newSViv(online)));
1661 free(cpumaps);
1662
1663 SV *
1664 get_node_free_memory(con)
1665 virConnectPtr con;
1666 PREINIT:
1667 unsigned long long mem;
1668 CODE:
1669 if ((mem = virNodeGetFreeMemory(con)) == 0)
1670 _croak_error();
1671
1672 RETVAL = virt_newSVull(mem);
1673 OUTPUT:
1674 RETVAL
1675
1676
1677 void
1678 get_node_cells_free_memory(con, start, end)
1679 virConnectPtr con;
1680 int start;
1681 int end;
1682 PREINIT:
1683 unsigned long long *mem;
1684 int i, num;
1685 PPCODE:
1686 Newx(mem, end-start, unsigned long long);
1687 if ((num = virNodeGetCellsFreeMemory(con, mem, start, end)) < 0) {
1688 Safefree(mem);
1689 _croak_error();
1690 }
1691 EXTEND(SP, num);
1692 for (i = 0 ; i < num ; i++) {
1693 SV *val = newSViv(mem[i]);
1694 PUSHs(sv_2mortal(val));
1695 }
1696 Safefree(mem);
1697
1698
1699 HV *
1700 get_node_cpu_stats(con, cpuNum=VIR_NODE_CPU_STATS_ALL_CPUS, flags=0)
1701 virConnectPtr con;
1702 int cpuNum;
1703 unsigned int flags;
1704 PREINIT:
1705 virNodeCPUStatsPtr params;
1706 int nparams = 0;
1707 int i;
1708 CODE:
1709 if (virNodeGetCPUStats(con, cpuNum, NULL, &nparams, flags) < 0)
1710 _croak_error();
1711
1712 Newx(params, nparams, virNodeCPUStats);
1713 if (virNodeGetCPUStats(con, cpuNum, params, &nparams, flags) < 0) {
1714 Safefree(params);
1715 _croak_error();
1716 }
1717 RETVAL = (HV *)sv_2mortal((SV*)newHV());
1718 for (i = 0 ; i < nparams ; i++) {
1719 if (strcmp(params[i].field, VIR_NODE_CPU_STATS_KERNEL) == 0) {
1720 (void)hv_store (RETVAL, "kernel", 6, virt_newSVull(params[i].value), 0);
1721 } else if (strcmp(params[i].field, VIR_NODE_CPU_STATS_USER) == 0) {
1722 (void)hv_store (RETVAL, "user", 4, virt_newSVull(params[i].value), 0);
1723 } else if (strcmp(params[i].field, VIR_NODE_CPU_STATS_IDLE) == 0) {
1724 (void)hv_store (RETVAL, "idle", 4, virt_newSVull(params[i].value), 0);
1725 } else if (strcmp(params[i].field, VIR_NODE_CPU_STATS_IOWAIT) == 0) {
1726 (void)hv_store (RETVAL, "iowait", 6, virt_newSVull(params[i].value), 0);
1727 } else if (strcmp(params[i].field, VIR_NODE_CPU_STATS_UTILIZATION) == 0) {
1728 (void)hv_store (RETVAL, "utilization", 11, virt_newSVull(params[i].value), 0);
1729 }
1730 }
1731 Safefree(params);
1732 OUTPUT:
1733 RETVAL
1734
1735
1736 HV *
1737 get_node_memory_stats(con, cellNum=VIR_NODE_MEMORY_STATS_ALL_CELLS, flags=0)
1738 virConnectPtr con;
1739 int cellNum;
1740 unsigned int flags;
1741 PREINIT:
1742 virNodeMemoryStatsPtr params;
1743 int nparams = 0;
1744 int i;
1745 CODE:
1746 if (virNodeGetMemoryStats(con, cellNum, NULL, &nparams, flags) < 0)
1747 _croak_error();
1748
1749 Newx(params, nparams, virNodeMemoryStats);
1750 if (virNodeGetMemoryStats(con, cellNum, params, &nparams, flags) < 0) {
1751 Safefree(params);
1752 _croak_error();
1753 }
1754 RETVAL = (HV *)sv_2mortal((SV*)newHV());
1755 for (i = 0 ; i < nparams ; i++) {
1756 if (strcmp(params[i].field, VIR_NODE_MEMORY_STATS_TOTAL) == 0) {
1757 (void)hv_store (RETVAL, "total", 5, virt_newSVull(params[i].value), 0);
1758 } else if (strcmp(params[i].field, VIR_NODE_MEMORY_STATS_FREE) == 0) {
1759 (void)hv_store (RETVAL, "free", 4, virt_newSVull(params[i].value), 0);
1760 } else if (strcmp(params[i].field, VIR_NODE_MEMORY_STATS_BUFFERS) == 0) {
1761 (void)hv_store (RETVAL, "buffers", 7, virt_newSVull(params[i].value), 0);
1762 } else if (strcmp(params[i].field, VIR_NODE_MEMORY_STATS_CACHED) == 0) {
1763 (void)hv_store (RETVAL, "cached", 6, virt_newSVull(params[i].value), 0);
1764 }
1765 }
1766 Safefree(params);
1767 OUTPUT:
1768 RETVAL
1769
1770
1771 HV *
1772 get_node_memory_parameters(conn, flags=0)
1773 virConnectPtr conn;
1774 unsigned int flags;
1775 PREINIT:
1776 virTypedParameter *params;
1777 int nparams;
1778 CODE:
1779 nparams = 0;
1780 if (virNodeGetMemoryParameters(conn, NULL, &nparams, flags) < 0)
1781 _croak_error();
1782
1783 Newx(params, nparams, virTypedParameter);
1784
1785 if (virNodeGetMemoryParameters(conn, params, &nparams, flags) < 0) {
1786 Safefree(params);
1787 _croak_error();
1788 }
1789
1790 RETVAL = vir_typed_param_to_hv(params, nparams);
1791 Safefree(params);
1792 OUTPUT:
1793 RETVAL
1794
1795
1796 void
1797 set_node_memory_parameters(conn, newparams, flags=0)
1798 virConnectPtr conn;
1799 HV *newparams;
1800 unsigned int flags;
1801 PREINIT:
1802 virTypedParameter *params;
1803 int nparams;
1804 PPCODE:
1805 nparams = 0;
1806 if (virNodeGetMemoryParameters(conn, NULL, &nparams, flags) < 0)
1807 _croak_error();
1808
1809 Newx(params, nparams, virTypedParameter);
1810
1811 if (virNodeGetMemoryParameters(conn, params, &nparams, flags) < 0) {
1812 Safefree(params);
1813 _croak_error();
1814 }
1815
1816 nparams = vir_typed_param_from_hv(newparams, params, nparams);
1817
1818 if (virNodeSetMemoryParameters(conn, params, nparams, flags) < 0)
1819 _croak_error();
1820 Safefree(params);
1821
1822
1823
1824 void
1825 node_suspend_for_duration(conn, target, duration, flags=0)
1826 virConnectPtr conn;
1827 unsigned int target;
1828 SV *duration;
1829 unsigned int flags;
1830 PPCODE:
1831 if (virNodeSuspendForDuration(conn, target, virt_SvIVull(duration), flags) < 0)
1832 _croak_error();
1833
1834
1835 char *
1836 find_storage_pool_sources(con, type, srcspec, flags=0)
1837 virConnectPtr con;
1838 const char *type;
1839 const char *srcspec;
1840 unsigned int flags;
1841 CODE:
1842 if ((RETVAL = virConnectFindStoragePoolSources(con, type, srcspec, flags)) == NULL)
1843 _croak_error();
1844 OUTPUT:
1845 RETVAL
1846
1847
1848 SV *
1849 get_capabilities(con)
1850 virConnectPtr con;
1851 PREINIT:
1852 char *xml;
1853 CODE:
1854 if (!(xml = virConnectGetCapabilities(con)))
1855 _croak_error();
1856
1857 RETVAL = newSVpv(xml, 0);
1858 free(xml);
1859 OUTPUT:
1860 RETVAL
1861
1862
1863 SV *
1864 compare_cpu(con, xml, flags=0)
1865 virConnectPtr con;
1866 char *xml;
1867 unsigned int flags;
1868 PREINIT:
1869 int rc;
1870 CODE:
1871 if ((rc = virConnectCompareCPU(con, xml, flags)) < 0)
1872 _croak_error();
1873
1874 RETVAL = newSViv(rc);
1875 OUTPUT:
1876 RETVAL
1877
1878
1879 SV *
1880 baseline_cpu(con, xml, flags=0)
1881 virConnectPtr con;
1882 SV *xml;
1883 unsigned int flags;
1884 PREINIT:
1885 AV *xmllist;
1886 const char **xmlstr;
1887 int xmllen;
1888 int i;
1889 char *retxml;
1890 CODE:
1891 xmllist = (AV*)SvRV(xml);
1892 xmllen = av_len(xmllist) + 1;
1893 Newx(xmlstr, xmllen, const char *);
1894 for (i = 0 ; i < xmllen ; i++) {
1895 SV **doc = av_fetch(xmllist, i, 0);
1896 xmlstr[i] = SvPV_nolen(*doc);
1897 }
1898
1899 if (!(retxml = virConnectBaselineCPU(con, xmlstr, xmllen, flags))) {
1900 Safefree(xmlstr);
1901 _croak_error();
1902 }
1903
1904 Safefree(xmlstr);
1905 RETVAL = newSVpv(retxml, 0);
1906 free(retxml);
1907 OUTPUT:
1908 RETVAL
1909
1910
1911 int
1912 get_max_vcpus(con, type)
1913 virConnectPtr con;
1914 char *type;
1915 CODE:
1916 if ((RETVAL = virConnectGetMaxVcpus(con, type)) < 0)
1917 _croak_error();
1918 OUTPUT:
1919 RETVAL
1920
1921
1922 SV *
1923 get_hostname(con)
1924 virConnectPtr con;
1925 PREINIT:
1926 char *host;
1927 CODE:
1928 if (!(host = virConnectGetHostname(con)))
1929 _croak_error();
1930
1931 RETVAL = newSVpv(host, 0);
1932 free(host);
1933 OUTPUT:
1934 RETVAL
1935
1936
1937 int
1938 num_of_domains(con)
1939 virConnectPtr con;
1940 CODE:
1941 if ((RETVAL = virConnectNumOfDomains(con)) < 0)
1942 _croak_error();
1943 OUTPUT:
1944 RETVAL
1945
1946
1947 void
1948 list_domain_ids(con, maxids)
1949 virConnectPtr con;
1950 int maxids
1951 PREINIT:
1952 int *ids;
1953 int i, nid;
1954 PPCODE:
1955 Newx(ids, maxids, int);
1956 if ((nid = virConnectListDomains(con, ids, maxids)) < 0) {
1957 Safefree(ids);
1958 _croak_error();
1959 }
1960 EXTEND(SP, nid);
1961 for (i = 0 ; i < nid ; i++) {
1962 PUSHs(sv_2mortal(newSViv(ids[i])));
1963 }
1964 Safefree(ids);
1965
1966
1967 int
1968 num_of_defined_domains(con)
1969 virConnectPtr con;
1970 CODE:
1971 if ((RETVAL = virConnectNumOfDefinedDomains(con)) < 0)
1972 _croak_error();
1973 OUTPUT:
1974 RETVAL
1975
1976
1977 void
1978 list_defined_domain_names(con, maxnames)
1979 virConnectPtr con;
1980 int maxnames;
1981 PREINIT:
1982 char **names;
1983 int ndom;
1984 int i;
1985 PPCODE:
1986 Newx(names, maxnames, char *);
1987 if ((ndom = virConnectListDefinedDomains(con, names, maxnames)) < 0) {
1988 Safefree(names);
1989 _croak_error();
1990 }
1991 EXTEND(SP, ndom);
1992 for (i = 0 ; i < ndom ; i++) {
1993 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
1994 free(names[i]);
1995 }
1996 Safefree(names);
1997
1998
1999 void
2000 list_all_domains(con, flags=0)
2001 virConnectPtr con;
2002 unsigned int flags;
2003 PREINIT:
2004 virDomainPtr *doms;
2005 int i, ndom;
2006 SV *domrv;
2007 PPCODE:
2008 if ((ndom = virConnectListAllDomains(con, &doms, flags)) < 0)
2009 _croak_error();
2010
2011 EXTEND(SP, ndom);
2012 for (i = 0 ; i < ndom ; i++) {
2013 domrv = sv_newmortal();
2014 sv_setref_pv(domrv, "Sys::Virt::Domain", doms[i]);
2015 PUSHs(domrv);
2016 }
2017 free(doms);
2018
2019
2020 void
2021 list_all_interfaces(con, flags=0)
2022 virConnectPtr con;
2023 unsigned int flags;
2024 PREINIT:
2025 virInterfacePtr *ifaces;
2026 int i, niface;
2027 SV *ifacerv;
2028 PPCODE:
2029 if ((niface = virConnectListAllInterfaces(con, &ifaces, flags)) < 0)
2030 _croak_error();
2031
2032 EXTEND(SP, niface);
2033 for (i = 0 ; i < niface ; i++) {
2034 ifacerv = sv_newmortal();
2035 sv_setref_pv(ifacerv, "Sys::Virt::Interface", ifaces[i]);
2036 PUSHs(ifacerv);
2037 }
2038 free(ifaces);
2039
2040
2041 void
2042 list_all_nwfilters(con, flags=0)
2043 virConnectPtr con;
2044 unsigned int flags;
2045 PREINIT:
2046 virNWFilterPtr *nwfilters;
2047 int i, nnwfilter;
2048 SV *nwfilterrv;
2049 PPCODE:
2050 if ((nnwfilter = virConnectListAllNWFilters(con, &nwfilters, flags)) < 0)
2051 _croak_error();
2052
2053 EXTEND(SP, nnwfilter);
2054 for (i = 0 ; i < nnwfilter ; i++) {
2055 nwfilterrv = sv_newmortal();
2056 sv_setref_pv(nwfilterrv, "Sys::Virt::NWFilter", nwfilters[i]);
2057 PUSHs(nwfilterrv);
2058 }
2059 free(nwfilters);
2060
2061
2062 void
2063 list_all_networks(con, flags=0)
2064 virConnectPtr con;
2065 unsigned int flags;
2066 PREINIT:
2067 virNetworkPtr *nets;
2068 int i, nnet;
2069 SV *netrv;
2070 PPCODE:
2071 if ((nnet = virConnectListAllNetworks(con, &nets, flags)) < 0)
2072 _croak_error();
2073
2074 EXTEND(SP, nnet);
2075 for (i = 0 ; i < nnet ; i++) {
2076 netrv = sv_newmortal();
2077 sv_setref_pv(netrv, "Sys::Virt::Network", nets[i]);
2078 PUSHs(netrv);
2079 }
2080 free(nets);
2081
2082
2083 void
2084 list_all_node_devices(con, flags=0)
2085 virConnectPtr con;
2086 unsigned int flags;
2087 PREINIT:
2088 virNodeDevicePtr *devs;
2089 int i, ndev;
2090 SV *devrv;
2091 PPCODE:
2092 if ((ndev = virConnectListAllNodeDevices(con, &devs, flags)) < 0)
2093 _croak_error();
2094
2095 EXTEND(SP, ndev);
2096 for (i = 0 ; i < ndev ; i++) {
2097 devrv = sv_newmortal();
2098 sv_setref_pv(devrv, "Sys::Virt::NodeDevice", devs[i]);
2099 PUSHs(devrv);
2100 }
2101 free(devs);
2102
2103
2104 void
2105 list_all_secrets(con, flags=0)
2106 virConnectPtr con;
2107 unsigned int flags;
2108 PREINIT:
2109 virSecretPtr *secrets;
2110 int i, nsecret;
2111 SV *secretrv;
2112 PPCODE:
2113 if ((nsecret = virConnectListAllSecrets(con, &secrets, flags)) < 0)
2114 _croak_error();
2115
2116 EXTEND(SP, nsecret);
2117 for (i = 0 ; i < nsecret ; i++) {
2118 secretrv = sv_newmortal();
2119 sv_setref_pv(secretrv, "Sys::Virt::Secret", secrets[i]);
2120 PUSHs(secretrv);
2121 }
2122 free(secrets);
2123
2124
2125 void
2126 list_all_storage_pools(con, flags=0)
2127 virConnectPtr con;
2128 unsigned int flags;
2129 PREINIT:
2130 virStoragePoolPtr *pools;
2131 int i, npool;
2132 SV *poolrv;
2133 PPCODE:
2134 if ((npool = virConnectListAllStoragePools(con, &pools, flags)) < 0)
2135 _croak_error();
2136
2137 EXTEND(SP, npool);
2138 for (i = 0 ; i < npool ; i++) {
2139 poolrv = sv_newmortal();
2140 sv_setref_pv(poolrv, "Sys::Virt::StoragePool", pools[i]);
2141 PUSHs(poolrv);
2142 }
2143 free(pools);
2144
2145
2146 int
2147 num_of_networks(con)
2148 virConnectPtr con;
2149 CODE:
2150 if ((RETVAL = virConnectNumOfNetworks(con)) < 0)
2151 _croak_error();
2152 OUTPUT:
2153 RETVAL
2154
2155
2156 void
2157 list_network_names(con, maxnames)
2158 virConnectPtr con;
2159 int maxnames;
2160 PREINIT:
2161 char **names;
2162 int i, nnet;
2163 PPCODE:
2164 Newx(names, maxnames, char *);
2165 if ((nnet = virConnectListNetworks(con, names, maxnames)) < 0) {
2166 Safefree(names);
2167 _croak_error();
2168 }
2169 EXTEND(SP, nnet);
2170 for (i = 0 ; i < nnet ; i++) {
2171 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
2172 free(names[i]);
2173 }
2174 Safefree(names);
2175
2176
2177 int
2178 num_of_defined_networks(con)
2179 virConnectPtr con;
2180 CODE:
2181 if ((RETVAL = virConnectNumOfDefinedNetworks(con)) < 0)
2182 _croak_error();
2183 OUTPUT:
2184 RETVAL
2185
2186
2187 void
2188 list_defined_network_names(con, maxnames)
2189 virConnectPtr con;
2190 int maxnames;
2191 PREINIT:
2192 char **names;
2193 int ndom;
2194 int i;
2195 PPCODE:
2196 Newx(names, maxnames, char *);
2197 if ((ndom = virConnectListDefinedNetworks(con, names, maxnames)) < 0) {
2198 Safefree(names);
2199 _croak_error();
2200 }
2201 EXTEND(SP, ndom);
2202 for (i = 0 ; i < ndom ; i++) {
2203 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
2204 free(names[i]);
2205 }
2206 Safefree(names);
2207
2208
2209 int
2210 num_of_storage_pools(con)
2211 virConnectPtr con;
2212 CODE:
2213 if ((RETVAL = virConnectNumOfStoragePools(con)) < 0)
2214 _croak_error();
2215 OUTPUT:
2216 RETVAL
2217
2218
2219 void
2220 list_storage_pool_names(con, maxnames)
2221 virConnectPtr con;
2222 int maxnames;
2223 PREINIT:
2224 char **names;
2225 int i, nnet;
2226 PPCODE:
2227 Newx(names, maxnames, char *);
2228 if ((nnet = virConnectListStoragePools(con, names, maxnames)) < 0) {
2229 Safefree(names);
2230 _croak_error();
2231 }
2232 EXTEND(SP, nnet);
2233 for (i = 0 ; i < nnet ; i++) {
2234 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
2235 free(names[i]);
2236 }
2237 Safefree(names);
2238
2239
2240 int
2241 num_of_defined_storage_pools(con)
2242 virConnectPtr con;
2243 CODE:
2244 if ((RETVAL = virConnectNumOfDefinedStoragePools(con)) < 0)
2245 _croak_error();
2246 OUTPUT:
2247 RETVAL
2248
2249 void
2250 list_defined_storage_pool_names(con, maxnames)
2251 virConnectPtr con;
2252 int maxnames;
2253 PREINIT:
2254 char **names;
2255 int ndom;
2256 int i;
2257 PPCODE:
2258 Newx(names, maxnames, char *);
2259 if ((ndom = virConnectListDefinedStoragePools(con, names, maxnames)) < 0) {
2260 Safefree(names);
2261 _croak_error();
2262 }
2263 EXTEND(SP, ndom);
2264 for (i = 0 ; i < ndom ; i++) {
2265 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
2266 free(names[i]);
2267 }
2268 Safefree(names);
2269
2270
2271 int
2272 num_of_node_devices(con, cap, flags=0)
2273 virConnectPtr con;
2274 SV *cap;
2275 int flags
2276 PREINIT:
2277 const char *capname = NULL;
2278 CODE:
2279 if (SvOK(cap))
2280 capname = SvPV_nolen(cap);
2281 if ((RETVAL = virNodeNumOfDevices(con, capname, flags)) < 0)
2282 _croak_error();
2283 OUTPUT:
2284 RETVAL
2285
2286
2287 void
2288 list_node_device_names(con, cap, maxnames, flags=0)
2289 virConnectPtr con;
2290 SV *cap;
2291 int maxnames;
2292 int flags;
2293 PREINIT:
2294 char **names;
2295 int i, nnet;
2296 const char *capname = NULL;
2297 PPCODE:
2298 if (SvOK(cap))
2299 capname = SvPV_nolen(cap);
2300 Newx(names, maxnames, char *);
2301 if ((nnet = virNodeListDevices(con, capname, names, maxnames, flags)) < 0) {
2302 Safefree(names);
2303 _croak_error();
2304 }
2305 EXTEND(SP, nnet);
2306 for (i = 0 ; i < nnet ; i++) {
2307 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
2308 free(names[i]);
2309 }
2310 Safefree(names);
2311
2312
2313 int
2314 num_of_interfaces(con)
2315 virConnectPtr con;
2316 CODE:
2317 if ((RETVAL = virConnectNumOfInterfaces(con)) < 0)
2318 _croak_error();
2319 OUTPUT:
2320 RETVAL
2321
2322
2323 void
2324 list_interface_names(con, maxnames)
2325 virConnectPtr con;
2326 int maxnames;
2327 PREINIT:
2328 char **names;
2329 int i, nnet;
2330 PPCODE:
2331 Newx(names, maxnames, char *);
2332 if ((nnet = virConnectListInterfaces(con, names, maxnames)) < 0) {
2333 Safefree(names);
2334 _croak_error();
2335 }
2336 EXTEND(SP, nnet);
2337 for (i = 0 ; i < nnet ; i++) {
2338 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
2339 free(names[i]);
2340 }
2341 Safefree(names);
2342
2343
2344 int
2345 num_of_defined_interfaces(con)
2346 virConnectPtr con;
2347 CODE:
2348 if ((RETVAL = virConnectNumOfDefinedInterfaces(con)) < 0)
2349 _croak_error();
2350 OUTPUT:
2351 RETVAL
2352
2353
2354 void
2355 list_defined_interface_names(con, maxnames)
2356 virConnectPtr con;
2357 int maxnames;
2358 PREINIT:
2359 char **names;
2360 int i, nnet;
2361 PPCODE:
2362 Newx(names, maxnames, char *);
2363 if ((nnet = virConnectListDefinedInterfaces(con, names, maxnames)) < 0) {
2364 Safefree(names);
2365 _croak_error();
2366 }
2367 EXTEND(SP, nnet);
2368 for (i = 0 ; i < nnet ; i++) {
2369 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
2370 free(names[i]);
2371 }
2372 Safefree(names);
2373
2374
2375 int
2376 num_of_secrets(con)
2377 virConnectPtr con;
2378 CODE:
2379 if ((RETVAL = virConnectNumOfSecrets(con)) < 0)
2380 _croak_error();
2381 OUTPUT:
2382 RETVAL
2383
2384
2385 void
2386 list_secret_uuids(con, maxuuids)
2387 virConnectPtr con;
2388 int maxuuids;
2389 PREINIT:
2390 char **uuids;
2391 int i, nsecret;
2392 PPCODE:
2393 Newx(uuids, maxuuids, char *);
2394 if ((nsecret = virConnectListSecrets(con, uuids, maxuuids)) < 0) {
2395 Safefree(uuids);
2396 _croak_error();
2397 }
2398 EXTEND(SP, nsecret);
2399 for (i = 0 ; i < nsecret ; i++) {
2400 PUSHs(sv_2mortal(newSVpv(uuids[i], 0)));
2401 free(uuids[i]);
2402 }
2403 Safefree(uuids);
2404
2405
2406 int
2407 num_of_nwfilters(con)
2408 virConnectPtr con;
2409 CODE:
2410 if ((RETVAL = virConnectNumOfNWFilters(con)) < 0)
2411 _croak_error();
2412 OUTPUT:
2413 RETVAL
2414
2415
2416 void
2417 list_nwfilter_names(con, maxnames)
2418 virConnectPtr con;
2419 int maxnames;
2420 PREINIT:
2421 char **names;
2422 int i, nnet;
2423 PPCODE:
2424 Newx(names, maxnames, char *);
2425 if ((nnet = virConnectListNWFilters(con, names, maxnames)) < 0) {
2426 Safefree(names);
2427 _croak_error();
2428 }
2429 EXTEND(SP, nnet);
2430 for (i = 0 ; i < nnet ; i++) {
2431 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
2432 free(names[i]);
2433 }
2434 Safefree(names);
2435
2436
2437 SV *
2438 domain_xml_from_native(con, configtype, configdata, flags=0)
2439 virConnectPtr con;
2440 const char *configtype;
2441 const char *configdata;
2442 unsigned int flags;
2443 PREINIT:
2444 char *xmldata;
2445 CODE:
2446 if (!(xmldata = virConnectDomainXMLFromNative(con, configtype, configdata, flags)))
2447 _croak_error();
2448
2449 RETVAL = newSVpv(xmldata, 0);
2450 free(xmldata);
2451 OUTPUT:
2452 RETVAL
2453
2454
2455 SV *
2456 domain_xml_to_native(con, configtype, xmldata, flags=0)
2457 virConnectPtr con;
2458 const char *configtype;
2459 const char *xmldata;
2460 unsigned int flags;
2461 PREINIT:
2462 char *configdata;
2463 CODE:
2464 if (!(configdata = virConnectDomainXMLToNative(con, configtype, xmldata, flags)))
2465 _croak_error();
2466
2467 RETVAL = newSVpv(configdata, 0);
2468 free(configdata);
2469 OUTPUT:
2470 RETVAL
2471
2472
2473 void
2474 domain_event_register(conref, cb)
2475 SV* conref;
2476 SV* cb;
2477 PREINIT:
2478 AV *opaque;
2479 virConnectPtr con;
2480 PPCODE:
2481 con = (virConnectPtr)SvIV((SV*)SvRV(conref));
2482 opaque = newAV();
2483 SvREFCNT_inc(cb);
2484 SvREFCNT_inc(conref);
2485 av_push(opaque, conref);
2486 av_push(opaque, cb);
2487 if (virConnectDomainEventRegister(con, _domain_event_lifecycle_callback,
2488 opaque, _domain_event_free) < 0)
2489 _croak_error();
2490
2491
2492 void
2493 domain_event_deregister(con)
2494 virConnectPtr con;
2495 PPCODE:
2496 virConnectDomainEventDeregister(con, _domain_event_lifecycle_callback);
2497
2498
2499 int
2500 domain_event_register_any(conref, domref, eventID, cb)
2501 SV* conref;
2502 SV* domref;
2503 int eventID;
2504 SV* cb;
2505 PREINIT:
2506 AV *opaque;
2507 virConnectPtr con;
2508 virDomainPtr dom;
2509 virConnectDomainEventGenericCallback callback;
2510 CODE:
2511 con = (virConnectPtr)SvIV((SV*)SvRV(conref));
2512 if (SvROK(domref)) {
2513 dom = (virDomainPtr)SvIV((SV*)SvRV(domref));
2514 } else {
2515 dom = NULL;
2516 }
2517
2518 switch (eventID) {
2519 case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
2520 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_lifecycle_callback);
2521 break;
2522 case VIR_DOMAIN_EVENT_ID_REBOOT:
2523 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_generic_callback);
2524 break;
2525 case VIR_DOMAIN_EVENT_ID_RTC_CHANGE:
2526 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_rtcchange_callback);
2527 break;
2528 case VIR_DOMAIN_EVENT_ID_WATCHDOG:
2529 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_watchdog_callback);
2530 break;
2531 case VIR_DOMAIN_EVENT_ID_IO_ERROR:
2532 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_io_error_callback);
2533 break;
2534 case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON:
2535 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_io_error_reason_callback);
2536 break;
2537 case VIR_DOMAIN_EVENT_ID_GRAPHICS:
2538 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_graphics_callback);
2539 break;
2540 case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR:
2541 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_generic_callback);
2542 break;
2543 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB:
2544 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_block_job_callback);
2545 break;
2546 case VIR_DOMAIN_EVENT_ID_DISK_CHANGE:
2547 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_disk_change_callback);
2548 break;
2549 case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE:
2550 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_tray_change_callback);
2551 break;
2552 case VIR_DOMAIN_EVENT_ID_PMSUSPEND:
2553 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_pmsuspend_callback);
2554 break;
2555 case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK:
2556 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_pmsuspend_disk_callback);
2557 break;
2558 case VIR_DOMAIN_EVENT_ID_PMWAKEUP:
2559 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_pmwakeup_callback);
2560 break;
2561 case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE:
2562 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_balloonchange_callback);
2563 break;
2564 case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
2565 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_device_removed_callback);
2566 break;
2567 default:
2568 callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_generic_callback);
2569 break;
2570 }
2571
2572 opaque = newAV();
2573 SvREFCNT_inc(cb);
2574 SvREFCNT_inc(conref);
2575 av_push(opaque, conref);
2576 av_push(opaque, cb);
2577 if ((RETVAL = virConnectDomainEventRegisterAny(con, dom, eventID, callback, opaque, _domain_event_free)) < 0)
2578 _croak_error();
2579 OUTPUT:
2580 RETVAL
2581
2582
2583 void
2584 domain_event_deregister_any(con, callbackID)
2585 virConnectPtr con;
2586 int callbackID;
2587 PPCODE:
2588 virConnectDomainEventDeregisterAny(con, callbackID);
2589
2590
2591 void
2592 register_close_callback(conref, cb)
2593 SV* conref;
2594 SV* cb;
2595 PREINIT:
2596 AV *opaque;
2597 virConnectPtr con;
2598 PPCODE:
2599 con = (virConnectPtr)SvIV((SV*)SvRV(conref));
2600 opaque = newAV();
2601 SvREFCNT_inc(cb);
2602 SvREFCNT_inc(conref);
2603 av_push(opaque, conref);
2604 av_push(opaque, cb);
2605 if (virConnectRegisterCloseCallback(con, _close_callback,
2606 opaque, _close_callback_free) < 0)
2607 _croak_error();
2608
2609
2610 void
2611 unregister_close_callback(con)
2612 virConnectPtr con;
2613 PPCODE:
2614 virConnectUnregisterCloseCallback(con, _close_callback);
2615
2616
2617 void
2618 interface_change_begin(conn, flags=0)
2619 virConnectPtr conn;
2620 unsigned int flags;
2621 PPCODE:
2622 if (virInterfaceChangeBegin(conn, flags) < 0)
2623 _croak_error();
2624
2625
2626 void
2627 interface_change_commit(conn, flags=0)
2628 virConnectPtr conn;
2629 unsigned int flags;
2630 PPCODE:
2631 if (virInterfaceChangeCommit(conn, flags) < 0)
2632 _croak_error();
2633
2634
2635 void
2636 interface_change_rollback(conn, flags=0)
2637 virConnectPtr conn;
2638 unsigned int flags;
2639 PPCODE:
2640 if (virInterfaceChangeRollback(conn, flags) < 0)
2641 _croak_error();
2642
2643
2644 void
2645 DESTROY(con_rv)
2646 SV *con_rv;
2647 PREINIT:
2648 virConnectPtr con;
2649 PPCODE:
2650 con = (virConnectPtr)SvIV((SV*)SvRV(con_rv));
2651 if (con) {
2652 virConnectClose(con);
2653 sv_setiv((SV*)SvRV(con_rv), 0);
2654 }
2655
2656
2657 MODULE = Sys::Virt::Domain PACKAGE = Sys::Virt::Domain
2658
2659
2660 virDomainPtr
2661 _create(con, xml, flags=0)
2662 virConnectPtr con;
2663 const char *xml;
2664 unsigned int flags;
2665 CODE:
2666 if (flags) {
2667 if (!(RETVAL = virDomainCreateXML(con, xml, flags)))
2668 _croak_error();
2669 } else {
2670 if (!(RETVAL = virDomainCreateLinux(con, xml, 0)))
2671 _croak_error();
2672 }
2673 OUTPUT:
2674 RETVAL
2675
2676
2677 virDomainPtr
2678 _create_with_files(con, xml, fdssv, flags=0)
2679 virConnectPtr con;
2680 const char *xml;
2681 SV *fdssv;
2682 unsigned int flags;
2683 PREINIT:
2684 AV *fdsav;
2685 unsigned int nfds;
2686 int *fds;
2687 int i;
2688 CODE:
2689 if (!SvROK(fdssv))
2690 return;
2691 fdsav = (AV*)SvRV(fdssv);
2692 nfds = av_len(fdsav) + 1;
2693 Newx(fds, nfds, int);
2694
2695 for (i = 0 ; i < nfds ; i++) {
2696 SV **fd = av_fetch(fdsav, i, 0);
2697 fds[i] = SvIV(*fd);
2698 }
2699
2700 if (!(RETVAL = virDomainCreateXMLWithFiles(con, xml, nfds, fds, flags))) {
2701 Safefree(fds);
2702 _croak_error();
2703 }
2704
2705 Safefree(fds);
2706 OUTPUT:
2707 RETVAL
2708
2709
2710 virDomainPtr
2711 _define_xml(con, xml)
2712 virConnectPtr con;
2713 const char *xml;
2714 CODE:
2715 if (!(RETVAL = virDomainDefineXML(con, xml)))
2716 _croak_error();
2717 OUTPUT:
2718 RETVAL
2719
2720
2721 virDomainPtr
2722 _lookup_by_id(con, id)
2723 virConnectPtr con;
2724 int id;
2725 CODE:
2726 if (!(RETVAL = virDomainLookupByID(con, id)))
2727 _croak_error();
2728 OUTPUT:
2729 RETVAL
2730
2731
2732 virDomainPtr
2733 _lookup_by_name(con, name)
2734 virConnectPtr con;
2735 const char *name;
2736 CODE:
2737 if (!(RETVAL = virDomainLookupByName(con, name)))
2738 _croak_error();
2739 OUTPUT:
2740 RETVAL
2741
2742
2743 virDomainPtr
2744 _lookup_by_uuid(con, uuid)
2745 virConnectPtr con;
2746 const unsigned char *uuid;
2747 CODE:
2748 if (!(RETVAL = virDomainLookupByUUID(con, uuid)))
2749 _croak_error();
2750 OUTPUT:
2751 RETVAL
2752
2753
2754 virDomainPtr
2755 _lookup_by_uuid_string(con, uuid)
2756 virConnectPtr con;
2757 const char *uuid;
2758 CODE:
2759 if (!(RETVAL = virDomainLookupByUUIDString(con, uuid)))
2760 _croak_error();
2761 OUTPUT:
2762 RETVAL
2763
2764
2765 int
2766 get_id(dom)
2767 virDomainPtr dom;
2768 CODE:
2769 RETVAL = virDomainGetID(dom);
2770 OUTPUT:
2771 RETVAL
2772
2773
2774 SV *
2775 get_uuid(dom)
2776 virDomainPtr dom;
2777 PREINIT:
2778 unsigned char rawuuid[VIR_UUID_BUFLEN];
2779 CODE:
2780 if ((virDomainGetUUID(dom, rawuuid)) < 0)
2781 _croak_error();
2782
2783 RETVAL = newSVpv((char*)rawuuid, sizeof(rawuuid));
2784 OUTPUT:
2785 RETVAL
2786
2787
2788 SV *
2789 get_uuid_string(dom)
2790 virDomainPtr dom;
2791 PREINIT:
2792 char uuid[VIR_UUID_STRING_BUFLEN];
2793 CODE:
2794 if ((virDomainGetUUIDString(dom, uuid)) < 0)
2795 _croak_error();
2796
2797 RETVAL = newSVpv(uuid, 0);
2798 OUTPUT:
2799 RETVAL
2800
2801
2802 const char *
2803 get_name(dom)
2804 virDomainPtr dom;
2805 CODE:
2806 if (!(RETVAL = virDomainGetName(dom)))
2807 _croak_error();
2808 OUTPUT:
2809 RETVAL
2810
2811
2812 const char *
2813 get_hostname(dom, flags=0)
2814 virDomainPtr dom;
2815 unsigned int flags;
2816 CODE:
2817 if (!(RETVAL = virDomainGetHostname(dom, flags)))
2818 _croak_error();
2819 OUTPUT:
2820 RETVAL
2821
2822
2823 char *
2824 get_metadata(dom, type, uri=&PL_sv_undef, flags=0)
2825 virDomainPtr dom;
2826 int type;
2827 SV *uri;
2828 unsigned int flags;
2829 PREINIT:
2830 const char *uristr = NULL;
2831 CODE:
2832 if (SvOK(uri))
2833 uristr = SvPV_nolen(uri);
2834
2835 if (!(RETVAL = virDomainGetMetadata(dom, type, uristr, flags)))
2836 _croak_error();
2837 OUTPUT:
2838 RETVAL
2839
2840
2841 void
2842 set_metadata(dom, type, metadata=&PL_sv_undef, key=&PL_sv_undef, uri=&PL_sv_undef, flags=0)
2843 virDomainPtr dom;
2844 int type;
2845 SV *metadata;
2846 SV *key;
2847 SV *uri;
2848 unsigned int flags;
2849 PREINIT:
2850 const char *metadatastr = NULL;
2851 const char *keystr = NULL;
2852 const char *uristr = NULL;
2853 PPCODE:
2854 if (SvOK(metadata))
2855 metadatastr = SvPV_nolen(metadata);
2856 if (SvOK(key))
2857 keystr = SvPV_nolen(key);
2858 if (SvOK(uri))
2859 uristr = SvPV_nolen(uri);
2860
2861 if (virDomainSetMetadata(dom, type, metadatastr, keystr, uristr, flags) < 0)
2862 _croak_error();
2863
2864
2865
2866 int
2867 is_active(dom)
2868 virDomainPtr dom;
2869 CODE:
2870 if ((RETVAL = virDomainIsActive(dom)) < 0)
2871 _croak_error();
2872 OUTPUT:
2873 RETVAL
2874
2875
2876 int
2877 is_persistent(dom)
2878 virDomainPtr dom;
2879 CODE:
2880 if ((RETVAL = virDomainIsPersistent(dom)) < 0)
2881 _croak_error();
2882 OUTPUT:
2883 RETVAL
2884
2885
2886 int
2887 is_updated(dom)
2888 virDomainPtr dom;
2889 CODE:
2890 if ((RETVAL = virDomainIsUpdated(dom)) < 0)
2891 _croak_error();
2892 OUTPUT:
2893 RETVAL
2894
2895
2896 void
2897 suspend(dom)
2898 virDomainPtr dom;
2899 PPCODE:
2900 if ((virDomainSuspend(dom)) < 0)
2901 _croak_error();
2902
2903
2904 void
2905 resume(dom)
2906 virDomainPtr dom;
2907 PPCODE:
2908 if ((virDomainResume(dom)) < 0)
2909 _croak_error();
2910
2911
2912 void
2913 pm_wakeup(dom, flags=0)
2914 virDomainPtr dom;
2915 unsigned int flags;
2916 PPCODE:
2917 if ((virDomainPMWakeup(dom, flags)) < 0)
2918 _croak_error();
2919
2920
2921 void
2922 save(dom, to, dxmlsv=&PL_sv_undef, flags=0)
2923 virDomainPtr dom;
2924 const char *to;
2925 SV *dxmlsv;
2926 unsigned int flags;
2927 PREINIT:
2928 const char *dxml = NULL;
2929 PPCODE:
2930 if (SvOK(dxmlsv))
2931 dxml = SvPV_nolen(dxmlsv);
2932
2933 if (dxml || flags) {
2934 if ((virDomainSaveFlags(dom, to, dxml, flags)) < 0)
2935 _croak_error();
2936 } else {
2937 if ((virDomainSave(dom, to)) < 0)
2938 _croak_error();
2939 }
2940
2941
2942 void
2943 managed_save(dom, flags=0)
2944 virDomainPtr dom;
2945 unsigned int flags;
2946 PPCODE:
2947 if ((virDomainManagedSave(dom, flags)) < 0)
2948 _croak_error();
2949
2950
2951 int
2952 has_managed_save_image(dom, flags=0)
2953 virDomainPtr dom;
2954 unsigned int flags;
2955 CODE:
2956 if ((RETVAL = virDomainHasManagedSaveImage(dom, flags)) < 0)
2957 _croak_error();
2958 OUTPUT:
2959 RETVAL
2960
2961
2962 void
2963 managed_save_remove(dom, flags=0)
2964 virDomainPtr dom;
2965 unsigned int flags;
2966 PPCODE:
2967 if ((virDomainManagedSaveRemove(dom, flags)) < 0)
2968 _croak_error();
2969
2970
2971 void
2972 core_dump(dom, to, flags=0)
2973 virDomainPtr dom;
2974 const char *to
2975 unsigned int flags;
2976 PPCODE:
2977 if (virDomainCoreDump(dom, to, flags) < 0)
2978 _croak_error();
2979
2980
2981 HV *
2982 get_info(dom)
2983 virDomainPtr dom;
2984 PREINIT:
2985 virDomainInfo info;
2986 CODE:
2987 if (virDomainGetInfo(dom, &info) < 0)
2988 _croak_error();
2989
2990 RETVAL = (HV *)sv_2mortal((SV*)newHV());
2991 (void)hv_store (RETVAL, "state", 5, newSViv(info.state), 0);
2992 (void)hv_store (RETVAL, "maxMem", 6, newSViv(info.maxMem), 0);
2993 (void)hv_store (RETVAL, "memory", 6, newSViv(info.memory), 0);
2994 (void)hv_store (RETVAL, "nrVirtCpu", 9, newSViv(info.nrVirtCpu), 0);
2995 (void)hv_store (RETVAL, "cpuTime", 7, virt_newSVull(info.cpuTime), 0);
2996 OUTPUT:
2997 RETVAL
2998
2999
3000 HV *
3001 get_control_info(dom, flags=0)
3002 virDomainPtr dom;
3003 unsigned int flags;
3004 PREINIT:
3005 virDomainControlInfo info;
3006 CODE:
3007 if (virDomainGetControlInfo(dom, &info, flags) < 0)
3008 _croak_error();
3009
3010 RETVAL = (HV *)sv_2mortal((SV*)newHV());
3011 (void)hv_store (RETVAL, "state", 5, newSViv(info.state), 0);
3012 (void)hv_store (RETVAL, "details", 7, newSViv(info.details), 0);
3013 (void)hv_store (RETVAL, "stateTime", 9, virt_newSVull(info.stateTime), 0);
3014 OUTPUT:
3015 RETVAL
3016
3017
3018 void
3019 get_state(dom, flags=0)
3020 virDomainPtr dom;
3021 unsigned int flags;
3022 PREINIT:
3023 int state;
3024 int reason;
3025 PPCODE:
3026 if (virDomainGetState(dom, &state, &reason, flags) < 0)
3027 _croak_error();
3028
3029 XPUSHs(sv_2mortal(newSViv(state)));
3030 XPUSHs(sv_2mortal(newSViv(reason)));
3031
3032
3033 void
3034 open_console(dom, st, devname, flags=0)
3035 virDomainPtr dom;
3036 virStreamPtr st;
3037 SV *devname;
3038 unsigned int flags;
3039 PREINIT:
3040 const char *devnamestr = NULL;
3041 PPCODE:
3042 if (SvOK(devname))
3043 devnamestr = SvPV_nolen(devname);
3044
3045 if (virDomainOpenConsole(dom, devnamestr, st, flags) < 0)
3046 _croak_error();
3047
3048
3049 void
3050 open_channel(dom, st, devname, flags=0)
3051 virDomainPtr dom;
3052 virStreamPtr st;
3053 SV *devname;
3054 unsigned int flags;
3055 PREINIT:
3056 const char *devnamestr = NULL;
3057 PPCODE:
3058 if (SvOK(devname))
3059 devnamestr = SvPV_nolen(devname);
3060
3061 if (virDomainOpenChannel(dom, devnamestr, st, flags) < 0)
3062 _croak_error();
3063
3064
3065 void
3066 open_graphics(dom, idx, fd, flags=0)
3067 virDomainPtr dom;
3068 unsigned int idx;
3069 int fd;
3070 unsigned int flags;
3071 PPCODE:
3072 if (virDomainOpenGraphics(dom, idx, fd, flags) < 0)
3073 _croak_error();
3074
3075
3076 SV *
3077 screenshot(dom, st, screen, flags=0)
3078 virDomainPtr dom;
3079 virStreamPtr st;
3080 unsigned int screen;
3081 unsigned int flags;
3082 PREINIT:
3083 char *mimetype;
3084 CODE:
3085 if (!(mimetype = virDomainScreenshot(dom, st, screen, flags)))
3086 _croak_error();
3087 RETVAL = newSVpv(mimetype, 0);
3088 free(mimetype);
3089 OUTPUT:
3090 RETVAL
3091
3092
3093 HV *
3094 get_block_info(dom, dev, flags=0)
3095 virDomainPtr dom;
3096 const char *dev;
3097 unsigned int flags;
3098 PREINIT:
3099 virDomainBlockInfo info;
3100 CODE:
3101 if (virDomainGetBlockInfo(dom, dev, &info, flags) < 0)
3102 _croak_error();
3103
3104 RETVAL = (HV *)sv_2mortal((SV*)newHV());
3105 (void)hv_store (RETVAL, "capacity", 8, virt_newSVull(info.capacity), 0);
3106 (void)hv_store (RETVAL, "allocation", 10, virt_newSVull(info.allocation), 0);
3107 (void)hv_store (RETVAL, "physical", 8, virt_newSVull(info.physical), 0);
3108 OUTPUT:
3109 RETVAL
3110
3111
3112 HV *
3113 get_job_info(dom)
3114 virDomainPtr dom;
3115 PREINIT:
3116 virDomainJobInfo info;
3117 CODE:
3118 if (virDomainGetJobInfo(dom, &info) < 0)
3119 _croak_error();
3120
3121 RETVAL = (HV *)sv_2mortal((SV*)newHV());
3122 (void)hv_store (RETVAL, "type", 4, newSViv(info.type), 0);
3123 (void)hv_store (RETVAL, "timeElapsed", 11, virt_newSVull(info.timeElapsed), 0);
3124 (void)hv_store (RETVAL, "timeRemaining", 13, virt_newSVull(info.timeRemaining), 0);
3125 (void)hv_store (RETVAL, "dataTotal", 9, virt_newSVull(info.dataTotal), 0);
3126 (void)hv_store (RETVAL, "dataProcessed", 13, virt_newSVull(info.dataProcessed), 0);
3127 (void)hv_store (RETVAL, "dataRemaining", 13, virt_newSVull(info.dataRemaining), 0);
3128 (void)hv_store (RETVAL, "memTotal", 8, virt_newSVull(info.memTotal), 0);
3129 (void)hv_store (RETVAL, "memProcessed", 12, virt_newSVull(info.memProcessed), 0);
3130 (void)hv_store (RETVAL, "memRemaining", 12, virt_newSVull(info.memRemaining), 0);
3131 (void)hv_store (RETVAL, "fileTotal", 9, virt_newSVull(info.fileTotal), 0);
3132 (void)hv_store (RETVAL, "fileProcessed", 13, virt_newSVull(info.fileProcessed), 0);
3133 (void)hv_store (RETVAL, "fileRemaining", 13, virt_newSVull(info.fileRemaining), 0);
3134 OUTPUT:
3135 RETVAL
3136
3137
3138 void
3139 get_job_stats(dom, flags=0)
3140 virDomainPtr dom;
3141 unsigned int flags;
3142 PREINIT:
3143 int type;
3144 virTypedParameter *params;
3145 int nparams;
3146 HV *paramsHv;
3147 SV *typeSv;
3148 PPCODE:
3149 if (virDomainGetJobStats(dom, &type, ¶ms, &nparams, flags) < 0) {
3150 Safefree(params);
3151 _croak_error();
3152 }
3153
3154 typeSv = newSViv(type);
3155 paramsHv = vir_typed_param_to_hv(params, nparams);
3156 Safefree(params);
3157
3158 EXTEND(SP, 2);
3159 PUSHs(newRV_noinc((SV*)typeSv));
3160 PUSHs(newRV_noinc((SV*)paramsHv));
3161
3162
3163 void
3164 abort_job(dom)
3165 virDomainPtr dom;
3166 PPCODE:
3167 if (virDomainAbortJob(dom) < 0)
3168 _croak_error();
3169
3170
3171 void
3172 abort_block_job(dom, path, flags=0)
3173 virDomainPtr dom;
3174 const char *path;
3175 unsigned int flags;
3176 PPCODE:
3177 if (virDomainBlockJobAbort(dom, path, flags) < 0)
3178 _croak_error();
3179
3180
3181 HV *
3182 get_block_job_info(dom, path, flags=0)
3183 virDomainPtr dom;
3184 const char *path;
3185 unsigned int flags;
3186 PREINIT:
3187 virDomainBlockJobInfo info;
3188 CODE:
3189 if (virDomainGetBlockJobInfo(dom, path, &info, flags) < 0)
3190 _croak_error();
3191
3192 RETVAL = (HV *)sv_2mortal((SV*)newHV());
3193 (void)hv_store (RETVAL, "type", 4, newSViv(info.type), 0);
3194 (void)hv_store (RETVAL, "bandwidth", 9, virt_newSVull(info.bandwidth), 0);
3195 (void)hv_store (RETVAL, "cur", 3, virt_newSVull(info.cur), 0);
3196 (void)hv_store (RETVAL, "end", 3, virt_newSVull(info.end), 0);
3197 OUTPUT:
3198 RETVAL
3199
3200
3201 void
3202 set_block_job_speed(dom, path, bandwidth, flags=0)
3203 virDomainPtr dom;
3204 const char *path;
3205 unsigned long bandwidth;
3206 unsigned int flags;
3207 PPCODE:
3208 if (virDomainBlockJobSetSpeed(dom, path, bandwidth, flags) < 0)
3209 _croak_error();
3210
3211
3212 void
3213 block_pull(dom, path, bandwidth, flags=0)
3214 virDomainPtr dom;
3215 const char *path;
3216 unsigned long bandwidth;
3217 unsigned int flags;
3218 PPCODE:
3219 if (virDomainBlockPull(dom, path, bandwidth, flags) < 0)
3220 _croak_error();
3221
3222
3223 void
3224 block_rebase(dom, path, base, bandwidth, flags=0)
3225 virDomainPtr dom;
3226 const char *path;
3227 const char *base;
3228 unsigned long bandwidth;
3229 unsigned int flags;
3230 PPCODE:
3231 if (virDomainBlockRebase(dom, path, base, bandwidth, flags) < 0)
3232 _croak_error();
3233
3234
3235 void
3236 block_commit(dom, path, base, top, bandwidth, flags=0)
3237 virDomainPtr dom;
3238 const char *path;
3239 const char *base;
3240 const char *top;
3241 unsigned long bandwidth;
3242 unsigned int flags;
3243 PPCODE:
3244 if (virDomainBlockCommit(dom, path, base, top, bandwidth, flags) < 0)
3245 _croak_error();
3246
3247
3248 void
3249 get_disk_errors(dom, flags=0)
3250 virDomainPtr dom;
3251 unsigned int flags;
3252 PREINIT:
3253 virDomainDiskErrorPtr errors;
3254 unsigned int maxerrors;
3255 int ret;
3256 int i;
3257 PPCODE:
3258 if ((ret = virDomainGetDiskErrors(dom, NULL, 0, 0)) < 0)
3259 _croak_error();
3260 maxerrors = ret;
3261 Newx(errors, maxerrors, virDomainDiskError);
3262 if ((ret = virDomainGetDiskErrors(dom, errors, maxerrors, flags)) < 0) {
3263 Safefree(errors);
3264 _croak_error();
3265 }
3266 EXTEND(SP, ret);
3267 for (i = 0 ; i < ret ; i++) {
3268 HV *rec = newHV();
3269 (void)hv_store(rec, "path", 4, newSVpv(errors[i].disk, 0), 0);
3270 (void)hv_store(rec, "error", 5, newSViv(errors[i].error), 0);
3271 PUSHs(newRV_noinc((SV *)rec));
3272 }
3273
3274 Safefree(errors);
3275
3276
3277 HV *
3278 get_scheduler_parameters(dom, flags=0)
3279 virDomainPtr dom;
3280 unsigned int flags;
3281 PREINIT:
3282 virTypedParameter *params;
3283 int nparams;
3284 char *type;
3285 CODE:
3286 if (!(type = virDomainGetSchedulerType(dom, &nparams)))
3287 _croak_error();
3288
3289 free(type);
3290 Newx(params, nparams, virTypedParameter);
3291 if (flags) {
3292 if (virDomainGetSchedulerParametersFlags(dom, params, &nparams, flags) < 0) {
3293 Safefree(params);
3294 _croak_error();
3295 }
3296 } else {
3297 if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0) {
3298 Safefree(params);
3299 _croak_error();
3300 }
3301 }
3302 RETVAL = vir_typed_param_to_hv(params, nparams);
3303 Safefree(params);
3304 OUTPUT:
3305 RETVAL
3306
3307
3308 void
3309 set_scheduler_parameters(dom, newparams, flags=0)
3310 virDomainPtr dom;
3311 HV *newparams;
3312 unsigned int flags;
3313 PREINIT:
3314 virTypedParameter *params;
3315 int nparams;
3316 char *type;
3317 PPCODE:
3318 if (!(type = virDomainGetSchedulerType(dom, &nparams)))
3319 _croak_error();
3320
3321 free(type);
3322 Newx(params, nparams, virTypedParameter);
3323 if (flags) {
3324 if (virDomainGetSchedulerParametersFlags(dom, params, &nparams, flags) < 0) {
3325 Safefree(params);
3326 _croak_error();
3327 }
3328 } else {
3329 if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0) {
3330 Safefree(params);
3331 _croak_error();
3332 }
3333 }
3334 nparams = vir_typed_param_from_hv(newparams, params, nparams);
3335 if (flags) {
3336 if (virDomainSetSchedulerParametersFlags(dom, params, nparams, flags) < 0)
3337 _croak_error();
3338 } else {
3339 if (virDomainSetSchedulerParameters(dom, params, nparams) < 0)
3340 _croak_error();
3341 }
3342 Safefree(params);
3343
3344
3345 HV *
3346 get_memory_parameters(dom, flags=0)
3347 virDomainPtr dom;
3348 unsigned int flags;
3349 PREINIT:
3350 virMemoryParameter *params;
3351 int nparams;
3352 CODE:
3353 nparams = 0;
3354 if (virDomainGetMemoryParameters(dom, NULL, &nparams, flags) < 0)
3355 _croak_error();
3356
3357 Newx(params, nparams, virMemoryParameter);
3358
3359 if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0) {
3360 Safefree(params);
3361 _croak_error();
3362 }
3363
3364 RETVAL = vir_typed_param_to_hv(params, nparams);
3365 Safefree(params);
3366 OUTPUT:
3367 RETVAL
3368
3369
3370 void
3371 set_memory_parameters(dom, newparams, flags=0)
3372 virDomainPtr dom;
3373 HV *newparams;
3374 unsigned int flags;
3375 PREINIT:
3376 virTypedParameter *params;
3377 int nparams;
3378 PPCODE:
3379 nparams = 0;
3380 if (virDomainGetMemoryParameters(dom, NULL, &nparams, flags) < 0)
3381 _croak_error();
3382
3383 Newx(params, nparams, virMemoryParameter);
3384
3385 if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0) {
3386 Safefree(params);
3387 _croak_error();
3388 }
3389
3390 nparams = vir_typed_param_from_hv(newparams, params, nparams);
3391
3392 if (virDomainSetMemoryParameters(dom, params, nparams, flags) < 0)
3393 _croak_error();
3394 Safefree(params);
3395
3396
3397 HV *
3398 get_numa_parameters(dom, flags=0)
3399 virDomainPtr dom;
3400 unsigned int flags;
3401 PREINIT:
3402 virTypedParameter *params;
3403 int nparams;
3404 CODE:
3405 nparams = 0;
3406 if (virDomainGetNumaParameters(dom, NULL, &nparams, flags) < 0)
3407 _croak_error();
3408
3409 Newx(params, nparams, virTypedParameter);
3410
3411 if (virDomainGetNumaParameters(dom, params, &nparams, flags) < 0) {
3412 Safefree(params);
3413 _croak_error();
3414 }
3415
3416 RETVAL = vir_typed_param_to_hv(params, nparams);
3417 Safefree(params);
3418 OUTPUT:
3419 RETVAL
3420
3421
3422 void
3423 set_numa_parameters(dom, newparams, flags=0)
3424 virDomainPtr dom;
3425 HV *newparams;
3426 unsigned int flags;
3427 PREINIT:
3428 virTypedParameter *params;
3429 int nparams;
3430 PPCODE:
3431 nparams = 0;
3432 if (virDomainGetNumaParameters(dom, NULL, &nparams, flags) < 0)
3433 _croak_error();
3434
3435 Newx(params, nparams, virTypedParameter);
3436
3437 if (virDomainGetNumaParameters(dom, params, &nparams, flags) < 0) {
3438 Safefree(params);
3439 _croak_error();
3440 }
3441
3442 nparams = vir_typed_param_from_hv(newparams, params, nparams);
3443
3444 if (virDomainSetNumaParameters(dom, params, nparams, flags) < 0)
3445 _croak_error();
3446 Safefree(params);
3447
3448
3449 HV *
3450 get_blkio_parameters(dom, flags=0)
3451 virDomainPtr dom;
3452 unsigned int flags;
3453 PREINIT:
3454 virTypedParameter *params;
3455 int nparams;
3456 CODE:
3457 nparams = 0;
3458 if (virDomainGetBlkioParameters(dom, NULL, &nparams, flags) < 0)
3459 _croak_error();
3460
3461 Newx(params, nparams, virBlkioParameter);
3462
3463 if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0) {
3464 Safefree(params);
3465 _croak_error();
3466 }
3467
3468 RETVAL = vir_typed_param_to_hv(params, nparams);
3469 Safefree(params);
3470 OUTPUT:
3471 RETVAL
3472
3473
3474 void
3475 set_blkio_parameters(dom, newparams, flags=0)
3476 virDomainPtr dom;
3477 HV *newparams;
3478 unsigned int flags;
3479 PREINIT:
3480 virTypedParameter *params;
3481 int nparams;
3482 PPCODE:
3483 nparams = 0;
3484 if (virDomainGetBlkioParameters(dom, NULL, &nparams, flags) < 0)
3485 _croak_error();
3486
3487 Newx(params, nparams, virBlkioParameter);
3488
3489 if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0) {
3490 Safefree(params);
3491 _croak_error();
3492 }
3493
3494 nparams = vir_typed_param_from_hv(newparams, params, nparams);
3495
3496 if (virDomainSetBlkioParameters(dom, params, nparams,
3497 flags) < 0)
3498 _croak_error();
3499 Safefree(params);
3500
3501
3502 unsigned long
3503 get_max_memory(dom)
3504 virDomainPtr dom;
3505 CODE:
3506 if (!(RETVAL = virDomainGetMaxMemory(dom)))
3507 _croak_error();
3508 OUTPUT:
3509 RETVAL
3510
3511
3512 void
3513 set_max_memory(dom, val)
3514 virDomainPtr dom;
3515 unsigned long val;
3516 PPCODE:
3517 if (virDomainSetMaxMemory(dom, val) < 0)
3518 _croak_error();
3519
3520
3521 void
3522 set_memory(dom, val, flags=0)
3523 virDomainPtr dom;
3524 unsigned long val;
3525 unsigned int flags;
3526 PPCODE:
3527 if (flags) {
3528 if (virDomainSetMemoryFlags(dom, val, flags) < 0)
3529 _croak_error();
3530 } else {
3531 if (virDomainSetMemory(dom, val) < 0)
3532 _croak_error();
3533 }
3534
3535
3536 void
3537 set_memory_stats_period(dom, val, flags=0)
3538 virDomainPtr dom;
3539 int val;
3540 unsigned int flags;
3541 PPCODE:
3542 if (virDomainSetMemoryStatsPeriod(dom, val, flags) < 0)
3543 _croak_error();
3544
3545
3546 int
3547 get_max_vcpus(dom)
3548 virDomainPtr dom;
3549 CODE:
3550 if (!(RETVAL = virDomainGetMaxVcpus(dom)))
3551 _croak_error();
3552 OUTPUT:
3553 RETVAL
3554
3555
3556 void
3557 set_vcpus(dom, num, flags=0)
3558 virDomainPtr dom;
3559 int num;
3560 int flags;
3561 PPCODE:
3562 if (flags) {
3563 if (virDomainSetVcpusFlags(dom, num, flags) < 0)
3564 _croak_error();
3565 } else {
3566 if (virDomainSetVcpus(dom, num) < 0)
3567 _croak_error();
3568 }
3569
3570
3571 int
3572 get_vcpus(dom, flags=0)
3573 virDomainPtr dom;
3574 int flags;
3575 CODE:
3576 if ((RETVAL = virDomainGetVcpusFlags(dom, flags)) < 0)
3577 _croak_error();
3578 OUTPUT:
3579 RETVAL
3580
3581
3582 void
3583 set_autostart(dom, autostart)
3584 virDomainPtr dom;
3585 int autostart;
3586 PPCODE:
3587 if (virDomainSetAutostart(dom, autostart) < 0)
3588 _croak_error();
3589
3590
3591 int
3592 get_autostart(dom)
3593 virDomainPtr dom;
3594 PREINIT:
3595 int autostart;
3596 CODE:
3597 if (virDomainGetAutostart(dom, &autostart) < 0)
3598 _croak_error();
3599 RETVAL = autostart;
3600 OUTPUT:
3601 RETVAL
3602
3603
3604 char *
3605 get_scheduler_type(dom)
3606 virDomainPtr dom;
3607 PREINIT:
3608 int nparams;
3609 CODE:
3610 if ((RETVAL = virDomainGetSchedulerType(dom, &nparams)) == NULL)
3611 _croak_error();
3612 OUTPUT:
3613 RETVAL
3614
3615
3616 SV *
3617 get_os_type(dom)
3618 virDomainPtr dom;
3619 PREINIT:
3620 char *type;
3621 CODE:
3622 if (!(type = virDomainGetOSType(dom)))
3623 _croak_error();
3624
3625 RETVAL = newSVpv(type, 0);
3626 free(type);
3627 OUTPUT:
3628 RETVAL
3629
3630
3631 SV *
3632 get_xml_description(dom, flags=0)
3633 virDomainPtr dom;
3634 unsigned int flags;
3635 PREINIT:
3636 char *xml;
3637 CODE:
3638 if (!(xml = virDomainGetXMLDesc(dom, flags)))
3639 _croak_error();
3640
3641 RETVAL = newSVpv(xml, 0);
3642 free(xml);
3643 OUTPUT:
3644 RETVAL
3645
3646
3647 void
3648 shutdown(dom, flags=0)
3649 virDomainPtr dom;
3650 unsigned int flags;
3651 PPCODE:
3652 if (flags) {
3653 if (virDomainShutdownFlags(dom, flags) < 0)
3654 _croak_error();
3655 } else {
3656 if (virDomainShutdown(dom) < 0)
3657 _croak_error();
3658 }
3659
3660
3661 void
3662 reboot(dom, flags=0)
3663 virDomainPtr dom;
3664 unsigned int flags;
3665 PPCODE:
3666 if (virDomainReboot(dom, flags) < 0)
3667 _croak_error();
3668
3669
3670 void
3671 pm_suspend_for_duration(dom, target, duration, flags=0)
3672 virDomainPtr dom;
3673 unsigned int target;
3674 SV *duration;
3675 unsigned int flags;
3676 PPCODE:
3677 if (virDomainPMSuspendForDuration(dom, target, virt_SvIVull(duration), flags) < 0)
3678 _croak_error();
3679
3680
3681 void
3682 reset(dom, flags=0)
3683 virDomainPtr dom;
3684 unsigned int flags;
3685 PPCODE:
3686 if (virDomainReset(dom, flags) < 0)
3687 _croak_error();
3688
3689
3690 void
3691 inject_nmi(dom, flags=0)
3692 virDomainPtr dom;
3693 unsigned int flags;
3694 PPCODE:
3695 if (virDomainInjectNMI(dom, flags) < 0)
3696 _croak_error();
3697
3698
3699 void
3700 undefine(dom, flags=0)
3701 virDomainPtr dom;
3702 unsigned int flags;
3703 PPCODE:
3704 if (flags) {
3705 if (virDomainUndefineFlags(dom, flags) < 0)
3706 _croak_error();
3707 } else {
3708 if (virDomainUndefine(dom) < 0)
3709 _croak_error();
3710 }
3711
3712
3713 void
3714 create(dom, flags=0)
3715 virDomainPtr dom;
3716 unsigned int flags;
3717 PPCODE:
3718 if (flags) {
3719 if (virDomainCreateWithFlags(dom, flags) < 0)
3720 _croak_error();
3721 } else {
3722 if (virDomainCreate(dom) < 0)
3723 _croak_error();
3724 }
3725
3726
3727
3728 void
3729 create_with_files(dom, fdssv, flags=0)
3730 virDomainPtr dom;
3731 SV *fdssv;
3732 unsigned int flags;
3733 PREINIT:
3734 AV *fdsav;
3735 unsigned int nfds;
3736 int *fds;
3737 int i;
3738 PPCODE:
3739 if (!SvROK(fdssv))
3740 return;
3741 fdsav = (AV*)SvRV(fdssv);
3742 nfds = av_len(fdsav) + 1;
3743 Newx(fds, nfds, int);
3744
3745 for (i = 0 ; i < nfds ; i++) {
3746 SV **fd = av_fetch(fdsav, i, 0);
3747 fds[i] = SvIV(*fd);
3748 }
3749
3750 if (virDomainCreateWithFiles(dom, nfds, fds, flags) < 0) {
3751 Safefree(fds);
3752 _croak_error();
3753 }
3754
3755 Safefree(fds);
3756
3757
3758 virDomainPtr
3759 _migrate(dom, destcon, newparams, flags=0)
3760 virDomainPtr dom;
3761 virConnectPtr destcon;
3762 HV *newparams;
3763 unsigned long flags;
3764 PREINIT:
3765 virTypedParameter *params;
3766 int nparams;
3767 CODE:
3768 nparams = 5;
3769 Newx(params, nparams, virTypedParameter);
3770
3771 memcpy(params[0].field, VIR_MIGRATE_PARAM_URI,
3772 VIR_TYPED_PARAM_FIELD_LENGTH);
3773 params[0].type = VIR_TYPED_PARAM_STRING;
3774
3775 memcpy(params[1].field, VIR_MIGRATE_PARAM_DEST_NAME,
3776 VIR_TYPED_PARAM_FIELD_LENGTH);
3777 params[1].type = VIR_TYPED_PARAM_STRING;
3778
3779 memcpy(params[2].field, VIR_MIGRATE_PARAM_DEST_XML,
3780 VIR_TYPED_PARAM_FIELD_LENGTH);
3781 params[2].type = VIR_TYPED_PARAM_STRING;
3782
3783 memcpy(params[3].field, VIR_MIGRATE_PARAM_GRAPHICS_URI,
3784 VIR_TYPED_PARAM_FIELD_LENGTH);
3785 params[3].type = VIR_TYPED_PARAM_STRING;
3786
3787 memcpy(params[4].field, VIR_MIGRATE_PARAM_BANDWIDTH,
3788 VIR_TYPED_PARAM_FIELD_LENGTH);
3789 params[4].type = VIR_TYPED_PARAM_ULLONG;
3790
3791
3792 nparams = vir_typed_param_from_hv(newparams, params, nparams);
3793
3794 /* No need to support virDomainMigrate/virDomainMigrate2, since
3795 * virDomainMigrate3 takes care to call the older APIs internally
3796 * if it is possible todo so
3797 */
3798 if ((RETVAL = virDomainMigrate3(dom, destcon, params, nparams, flags)) == NULL) {
3799 Safefree(params);
3800 _croak_error();
3801 }
3802 Safefree(params);
3803 OUTPUT:
3804 RETVAL
3805
3806
3807 void
3808 _migrate_to_uri(dom, desturi, newparams, flags=0)
3809 virDomainPtr dom;
3810 const char *desturi;
3811 HV *newparams;
3812 unsigned long flags;
3813 PREINIT:
3814 virTypedParameter *params;
3815 int nparams;
3816 PPCODE:
3817 nparams = 5;
3818 Newx(params, nparams, virTypedParameter);
3819
3820 memcpy(params[0].field, VIR_MIGRATE_PARAM_URI,
3821 VIR_TYPED_PARAM_FIELD_LENGTH);
3822 params[0].type = VIR_TYPED_PARAM_STRING;
3823
3824 memcpy(params[1].field, VIR_MIGRATE_PARAM_DEST_NAME,
3825 VIR_TYPED_PARAM_FIELD_LENGTH);
3826 params[1].type = VIR_TYPED_PARAM_STRING;
3827
3828 memcpy(params[2].field, VIR_MIGRATE_PARAM_DEST_XML,
3829 VIR_TYPED_PARAM_FIELD_LENGTH);
3830 params[2].type = VIR_TYPED_PARAM_STRING;
3831
3832 memcpy(params[3].field, VIR_MIGRATE_PARAM_GRAPHICS_URI,
3833 VIR_TYPED_PARAM_FIELD_LENGTH);
3834 params[3].type = VIR_TYPED_PARAM_STRING;
3835
3836 memcpy(params[4].field, VIR_MIGRATE_PARAM_BANDWIDTH,
3837 VIR_TYPED_PARAM_FIELD_LENGTH);
3838 params[4].type = VIR_TYPED_PARAM_ULLONG;
3839
3840 nparams = vir_typed_param_from_hv(newparams, params, nparams);
3841
3842 /* No need to support virDomainMigrateToURI/virDomainMigrateToURI2, since
3843 * virDomainMigrate3 takes care to call the older APIs internally
3844 * if it is possible todo so
3845 */
3846 if (virDomainMigrateToURI3(dom, desturi, params, nparams, flags) < 0) {
3847 Safefree(params);
3848 _croak_error();
3849 }
3850 Safefree(params);
3851
3852
3853 void
3854 migrate_set_max_downtime(dom, downtime, flags=0)
3855 virDomainPtr dom;
3856 SV *downtime;
3857 unsigned int flags;
3858 PREINIT:
3859 unsigned long long downtimeVal;
3860 PPCODE:
3861 downtimeVal = virt_SvIVull(downtime);
3862 if (virDomainMigrateSetMaxDowntime(dom, downtimeVal, flags) < 0)
3863 _croak_error();
3864
3865
3866 void
3867 migrate_set_max_speed(dom, bandwidth, flags=0)
3868 virDomainPtr dom;
3869 unsigned long bandwidth;
3870 unsigned int flags;
3871 PPCODE:
3872 if (virDomainMigrateSetMaxSpeed(dom, bandwidth, flags) < 0)
3873 _croak_error();
3874
3875
3876 unsigned long
3877 migrate_get_max_speed(dom, flags=0)
3878 virDomainPtr dom;
3879 unsigned int flags;
3880 PREINIT:
3881 unsigned long speed;
3882 CODE:
3883 if (virDomainMigrateGetMaxSpeed(dom, &speed, flags) < 0)
3884 _croak_error();
3885
3886 RETVAL = speed;
3887 OUTPUT:
3888 RETVAL
3889
3890
3891 void
3892 migrate_set_compression_cache(dom, cacheSizeSv, flags=0)
3893 virDomainPtr dom;
3894 SV *cacheSizeSv;
3895 unsigned int flags;
3896 PREINIT:
3897 unsigned long long cacheSize;
3898 PPCODE:
3899 cacheSize = virt_SvIVull(cacheSizeSv);
3900 if (virDomainMigrateSetCompressionCache(dom, cacheSize, flags) < 0)
3901 _croak_error();
3902
3903
3904 SV *
3905 migrate_get_compression_cache(dom, flags=0)
3906 virDomainPtr dom;
3907 unsigned int flags;
3908 PREINIT:
3909 unsigned long long cacheSize;
3910 CODE:
3911 if (virDomainMigrateGetCompressionCache(dom, &cacheSize, flags) < 0)
3912 _croak_error();
3913
3914 RETVAL = virt_newSVull(cacheSize);
3915 OUTPUT:
3916 RETVAL
3917
3918
3919 void
3920 attach_device(dom, xml, flags=0)
3921 virDomainPtr dom;
3922 const char *xml;
3923 unsigned int flags;
3924 PPCODE:
3925 if (flags) {
3926 if (virDomainAttachDeviceFlags(dom, xml, flags) < 0)
3927 _croak_error();
3928 } else {
3929 if (virDomainAttachDevice(dom, xml) < 0)
3930 _croak_error();
3931 }
3932
3933
3934 void
3935 detach_device(dom, xml, flags=0)
3936 virDomainPtr dom;
3937 const char *xml;
3938 unsigned int flags;
3939 PPCODE:
3940 if (flags) {
3941 if (virDomainDetachDeviceFlags(dom, xml, flags) < 0)
3942 _croak_error();
3943 } else {
3944 if (virDomainDetachDevice(dom, xml) < 0)
3945 _croak_error();
3946 }
3947
3948
3949 void
3950 update_device(dom, xml, flags=0)
3951 virDomainPtr dom;
3952 const char *xml;
3953 unsigned int flags;
3954 PPCODE:
3955 if (virDomainUpdateDeviceFlags(dom, xml, flags) < 0)
3956 _croak_error();
3957
3958
3959 HV *
3960 get_block_iotune(dom, disk, flags=0)
3961 virDomainPtr dom;
3962 const char *disk;
3963 unsigned int flags;
3964 PREINIT:
3965 virTypedParameter *params;
3966 int nparams;
3967 CODE:
3968 nparams = 0;
3969 RETVAL = NULL;
3970 if (virDomainGetBlockIoTune(dom, disk, NULL, &nparams, flags) < 0)
3971 _croak_error();
3972
3973 Newx(params, nparams, virTypedParameter);
3974 if (virDomainGetBlockIoTune(dom, disk, params, &nparams, flags) < 0) {
3975 Safefree(params);
3976 _croak_error();
3977 }
3978
3979 RETVAL = vir_typed_param_to_hv(params, nparams);
3980 Safefree(params);
3981 OUTPUT:
3982 RETVAL
3983
3984
3985 void
3986 set_block_iotune(dom, disk, newparams, flags=0)
3987 virDomainPtr dom;
3988 const char *disk;
3989 HV *newparams;
3990 unsigned int flags;
3991 PREINIT:
3992 virTypedParameter *params;
3993 int nparams;
3994 PPCODE:
3995 nparams = 0;
3996 if (virDomainGetBlockIoTune(dom, disk, NULL, &nparams, flags) < 0)
3997 _croak_error();
3998 Newx(params, nparams, virTypedParameter);
3999
4000 if (virDomainGetBlockIoTune(dom, disk, params, &nparams, flags) < 0) {
4001 Safefree(params);
4002 _croak_error();
4003 }
4004
4005 nparams = vir_typed_param_from_hv(newparams, params, nparams);
4006 if (virDomainSetBlockIoTune(dom, disk, params, nparams, flags) < 0)
4007 _croak_error();
4008
4009
4010 HV *
4011 get_interface_parameters(dom, intf, flags=0)
4012 virDomainPtr dom;
4013 const char *intf;
4014 unsigned int flags;
4015 PREINIT:
4016 virTypedParameter *params;
4017 int nparams;
4018 CODE:
4019 nparams = 0;
4020 RETVAL = NULL;
4021 if (virDomainGetInterfaceParameters(dom, intf, NULL, &nparams, flags) < 0)
4022 _croak_error();
4023
4024 Newx(params, nparams, virTypedParameter);
4025 if (virDomainGetInterfaceParameters(dom, intf, params, &nparams, flags) < 0) {
4026 Safefree(params);
4027 _croak_error();
4028 }
4029
4030 RETVAL = vir_typed_param_to_hv(params, nparams);
4031 Safefree(params);
4032 OUTPUT:
4033 RETVAL
4034
4035
4036 void
4037 set_interface_parameters(dom, intf, newparams, flags=0)
4038 virDomainPtr dom;
4039 const char *intf;
4040 HV *newparams;
4041 unsigned int flags;
4042 PREINIT:
4043 virTypedParameter *params;
4044 int nparams;
4045 PPCODE:
4046 nparams = 0;
4047 if (virDomainGetInterfaceParameters(dom, intf, NULL, &nparams, flags) < 0)
4048 _croak_error();
4049 Newx(params, nparams, virTypedParameter);
4050
4051 if (virDomainGetInterfaceParameters(dom, intf, params, &nparams, flags) < 0) {
4052 Safefree(params);
4053 _croak_error();
4054 }
4055
4056 nparams = vir_typed_param_from_hv(newparams, params, nparams);
4057 if (virDomainSetInterfaceParameters(dom, intf, params, nparams, flags) < 0)
4058 _croak_error();
4059
4060
4061 HV *
4062 block_stats(dom, path, flags=0)
4063 virDomainPtr dom;
4064 const char *path;
4065 unsigned int flags;
4066 PREINIT:
4067 virDomainBlockStatsStruct stats;
4068 virTypedParameter *params;
4069 int nparams;
4070 unsigned int i;
4071 const char *field;
4072 CODE:
4073 nparams = 0;
4074 RETVAL = NULL;
4075 if (virDomainBlockStatsFlags(dom, path, NULL, &nparams, flags) < 0) {
4076 virErrorPtr err = virGetLastError();
4077 if (err && err->code == VIR_ERR_NO_SUPPORT && !flags) {
4078 if (virDomainBlockStats(dom, path, &stats, sizeof(stats)) < 0)
4079 _croak_error();
4080
4081 RETVAL = (HV *)sv_2mortal((SV*)newHV());
4082 (void)hv_store (RETVAL, "rd_req", 6, virt_newSVll(stats.rd_req), 0);
4083 (void)hv_store (RETVAL, "rd_bytes", 8, virt_newSVll(stats.rd_bytes), 0);
4084 (void)hv_store (RETVAL, "wr_req", 6, virt_newSVll(stats.wr_req), 0);
4085 (void)hv_store (RETVAL, "wr_bytes", 8, virt_newSVll(stats.wr_bytes), 0);
4086 (void)hv_store (RETVAL, "errs", 4, virt_newSVll(stats.errs), 0);
4087 } else {
4088 _croak_error();
4089 }
4090 } else {
4091 Newx(params, nparams, virTypedParameter);
4092
4093 if (virDomainBlockStatsFlags(dom, path, params, &nparams, flags) < 0) {
4094 Safefree(params);
4095 _croak_error();
4096 }
4097
4098 RETVAL = vir_typed_param_to_hv(params, nparams);
4099 for (i = 0 ; i < nparams ; i++) {
4100 field = NULL;
4101 /* For back compat with previous hash above */
4102 if (strcmp(params[i].field, "rd_operations") == 0)
4103 field = "rd_reqs";
4104 else if (strcmp(params[i].field, "wr_operations") == 0)
4105 field = "wr_reqs";
4106 else if (strcmp(params[i].field, "flush_operations") == 0)
4107 field = "flush_reqs";
4108 if (field) {
4109 SV *val = hv_delete(RETVAL, params[i].field, strlen(params[i].field), 0);
4110 SvREFCNT_inc(val);
4111 (void)hv_store(RETVAL, field, strlen(field), val, 0);
4112 }
4113 }
4114 Safefree(params);
4115 }
4116 OUTPUT:
4117 RETVAL
4118
4119
4120 HV *
4121 interface_stats(dom, path)
4122 virDomainPtr dom;
4123 const char *path;
4124 PREINIT:
4125 virDomainInterfaceStatsStruct stats;
4126 CODE:
4127 if (virDomainInterfaceStats(dom, path, &stats, sizeof(stats)) < 0)
4128 _croak_error();
4129
4130 RETVAL = (HV *)sv_2mortal((SV*)newHV());
4131 (void)hv_store (RETVAL, "rx_bytes", 8, virt_newSVll(stats.rx_bytes), 0);
4132 (void)hv_store (RETVAL, "rx_packets", 10, virt_newSVll(stats.rx_packets), 0);
4133 (void)hv_store (RETVAL, "rx_errs", 7, virt_newSVll(stats.rx_errs), 0);
4134 (void)hv_store (RETVAL, "rx_drop", 7, virt_newSVll(stats.rx_drop), 0);
4135 (void)hv_store (RETVAL, "tx_bytes", 8, virt_newSVll(stats.tx_bytes), 0);
4136 (void)hv_store (RETVAL, "tx_packets", 10, virt_newSVll(stats.tx_packets), 0);
4137 (void)hv_store (RETVAL, "tx_errs", 7, virt_newSVll(stats.tx_errs), 0);
4138 (void)hv_store (RETVAL, "tx_drop", 7, virt_newSVll(stats.tx_drop), 0);
4139 OUTPUT:
4140 RETVAL
4141
4142
4143 HV *
4144 memory_stats(dom, flags=0)
4145 virDomainPtr dom;
4146 unsigned int flags;
4147 PREINIT:
4148 virDomainMemoryStatPtr stats;
4149 int i, got;
4150 CODE:
4151 Newx(stats, VIR_DOMAIN_MEMORY_STAT_NR, virDomainMemoryStatStruct);
4152 if ((got = virDomainMemoryStats(dom, stats, VIR_DOMAIN_MEMORY_STAT_NR, flags)) < 0) {
4153 Safefree(stats);
4154 _croak_error();
4155 }
4156 RETVAL = (HV *)sv_2mortal((SV*)newHV());
4157 for (i = 0 ; i < got ; i++) {
4158 switch (stats[i].tag) {
4159 case VIR_DOMAIN_MEMORY_STAT_SWAP_IN:
4160 (void)hv_store (RETVAL, "swap_in", 7, virt_newSVll(stats[i].val), 0);
4161 break;
4162
4163 case VIR_DOMAIN_MEMORY_STAT_SWAP_OUT:
4164 (void)hv_store (RETVAL, "swap_out", 8, virt_newSVll(stats[i].val), 0);
4165 break;
4166
4167 case VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT:
4168 (void)hv_store (RETVAL, "major_fault", 11, virt_newSVll(stats[i].val), 0);
4169 break;
4170
4171 case VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT:
4172 (void)hv_store (RETVAL, "minor_fault", 11, virt_newSVll(stats[i].val), 0);
4173 break;
4174
4175 case VIR_DOMAIN_MEMORY_STAT_UNUSED:
4176 (void)hv_store (RETVAL, "unused", 6, virt_newSVll(stats[i].val), 0);
4177 break;
4178
4179 case VIR_DOMAIN_MEMORY_STAT_AVAILABLE:
4180 (void)hv_store (RETVAL, "available", 9, virt_newSVll(stats[i].val), 0);
4181 break;
4182
4183 case VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON:
4184 (void)hv_store (RETVAL, "actual_balloon", 14, virt_newSVll(stats[i].val), 0);
4185 break;
4186
4187 case VIR_DOMAIN_MEMORY_STAT_RSS:
4188 (void)hv_store (RETVAL, "rss", 14, virt_newSVll(stats[i].val), 0);
4189 break;
4190 }
4191 }
4192 Safefree(stats);
4193 OUTPUT:
4194 RETVAL
4195
4196
4197 void
4198 send_key(dom, codeset, holdtime, keycodesSV, flags=0)
4199 virDomainPtr dom;
4200 unsigned int codeset;
4201 unsigned int holdtime;
4202 SV *keycodesSV;
4203 unsigned int flags;
4204 PREINIT:
4205 AV *keycodesAV;
4206 unsigned int *keycodes;
4207 int nkeycodes;
4208 int i;
4209 PPCODE:
4210 if (!SvROK(keycodesSV))
4211 return;
4212 keycodesAV = (AV*)SvRV(keycodesSV);
4213 nkeycodes = av_len(keycodesAV) + 1;
4214 Newx(keycodes, nkeycodes, unsigned int);
4215
4216 for (i = 0 ; i < nkeycodes ; i++) {
4217 SV **code = av_fetch(keycodesAV, i, 0);
4218 keycodes[i] = SvIV(*code);
4219 }
4220
4221 if (virDomainSendKey(dom, codeset, holdtime, keycodes, nkeycodes, flags) < 0) {
4222 Safefree(keycodes);
4223 _croak_error();
4224 }
4225
4226 Safefree(keycodes);
4227
4228
4229 void
4230 block_resize(dom, disk, size, flags=0)
4231 virDomainPtr dom;
4232 const char *disk;
4233 SV *size;
4234 unsigned int flags;
4235 PPCODE:
4236 if (virDomainBlockResize(dom, disk, virt_SvIVull(size), flags) < 0)
4237 _croak_error();
4238
4239
4240 SV *
4241 block_peek(dom, path, offset, size, flags=0)
4242 virDomainPtr dom;
4243 const char *path;
4244 unsigned int offset;
4245 size_t size;
4246 unsigned int flags;
4247 PREINIT:
4248 char *buf;
4249 CODE:
4250 Newx(buf, size, char);
4251 if (virDomainBlockPeek(dom, path, offset, size, buf, flags) < 0) {
4252 Safefree(buf);
4253 _croak_error();
4254 }
4255 RETVAL = newSVpvn(buf, size);
4256 OUTPUT:
4257 RETVAL
4258
4259
4260 SV *
4261 memory_peek(dom, offset, size, flags=0)
4262 virDomainPtr dom;
4263 unsigned int offset;
4264 size_t size;
4265 unsigned int flags;
4266 PREINIT:
4267 char *buf;
4268 CODE:
4269 Newx(buf, size, char);
4270 if (virDomainMemoryPeek(dom, offset, size, buf, flags) < 0) {
4271 Safefree(buf);
4272 _croak_error();
4273 }
4274 RETVAL = newSVpvn(buf, size);
4275 OUTPUT:
4276 RETVAL
4277
4278
4279 HV *
4280 get_security_label(dom)
4281 virDomainPtr dom;
4282 PREINIT:
4283 virSecurityLabel seclabel;
4284 CODE:
4285 if (virDomainGetSecurityLabel(dom, &seclabel) < 0)
4286 _croak_error();
4287
4288 RETVAL = (HV *)sv_2mortal((SV*)newHV());
4289 (void)hv_store (RETVAL, "label", 5, newSVpv(seclabel.label, 0), 0);
4290 (void)hv_store (RETVAL, "enforcing", 9, newSViv(seclabel.enforcing), 0);
4291 OUTPUT:
4292 RETVAL
4293
4294
4295 void
4296 get_security_label_list(dom)
4297 virDomainPtr dom;
4298 PREINIT:
4299 virSecurityLabelPtr seclabels;
4300 int nlabels;
4301 int i;
4302 PPCODE:
4303 if ((nlabels = virDomainGetSecurityLabelList(dom, &seclabels)) < 0)
4304 _croak_error();
4305
4306 EXTEND(SP, nlabels);
4307 for (i = 0 ; i < nlabels ; i++) {
4308 HV *rec = (HV *)sv_2mortal((SV*)newHV());
4309 (void)hv_store (rec, "label", 5, newSVpv(seclabels[i].label, 0), 0);
4310 (void)hv_store (rec, "enforcing", 9, newSViv(seclabels[i].enforcing), 0);
4311 PUSHs(newRV_noinc((SV*)rec));
4312 }
4313 free(seclabels);
4314
4315
4316 void
4317 get_cpu_stats(dom, start_cpu, ncpus, flags=0)
4318 virDomainPtr dom;
4319 int start_cpu;
4320 unsigned int ncpus;
4321 unsigned int flags;
4322 PREINIT:
4323 virTypedParameterPtr params;
4324 unsigned int nparams;
4325 int ret;
4326 int i;
4327 PPCODE:
4328 if ((ret = virDomainGetCPUStats(dom, NULL, 0, 0, 1, 0)) < 0)
4329 _croak_error();
4330 nparams = ret;
4331
4332 if (ncpus == 0) {
4333 if ((ret = virDomainGetCPUStats(dom, NULL, 0, 0, 0, 0)) < 0)
4334 _croak_error();
4335 ncpus = ret;
4336 }
4337
4338 Newx(params, ncpus * nparams, virTypedParameter);
4339 if ((ret = virDomainGetCPUStats(dom, params, nparams, start_cpu, ncpus, flags)) < 0) {
4340 Safefree(params);
4341 _croak_error();
4342 }
4343
4344 EXTEND(SP, ret);
4345 for (i = 0 ; i < ret ; i++) {
4346 HV *rec = vir_typed_param_to_hv(params + (i * nparams), nparams);
4347 PUSHs(newRV_noinc((SV *)rec));
4348 }
4349
4350 Safefree(params);
4351
4352
4353 void
4354 get_vcpu_info(dom, flags=0)
4355 virDomainPtr dom;
4356 unsigned int flags;
4357 PREINIT:
4358 virVcpuInfoPtr info;
4359 unsigned char *cpumaps;
4360 size_t maplen;
4361 virNodeInfo nodeinfo;
4362 virDomainInfo dominfo;
4363 int nvCpus;
4364 int i;
4365 PPCODE:
4366 if (virNodeGetInfo(virDomainGetConnect(dom), &nodeinfo) < 0)
4367 _croak_error();
4368 if (virDomainGetInfo(dom, &dominfo) < 0)
4369 _croak_error();
4370
4371 maplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
4372 Newx(cpumaps, dominfo.nrVirtCpu * maplen, unsigned char);
4373 if (flags && (flags & VIR_DOMAIN_AFFECT_CONFIG)) {
4374 Newx(info, dominfo.nrVirtCpu, virVcpuInfo);
4375 if ((nvCpus = virDomainGetVcpus(dom, info, dominfo.nrVirtCpu, cpumaps, maplen)) < 0) {
4376 Safefree(info);
4377 Safefree(cpumaps);
4378 _croak_error();
4379 }
4380 } else {
4381 info = NULL;
4382 if ((nvCpus = virDomainGetVcpuPinInfo(dom, dominfo.nrVirtCpu, cpumaps, maplen, flags)) < 0) {
4383 Safefree(cpumaps);
4384 _croak_error();
4385 }
4386 }
4387
4388 EXTEND(SP, nvCpus);
4389 for (i = 0 ; i < nvCpus ; i++) {
4390 HV *rec = newHV();
4391 (void)hv_store(rec, "number", 6, newSViv(i), 0);
4392 if (info) {
4393 (void)hv_store(rec, "state", 5, newSViv(info[i].state), 0);
4394 (void)hv_store(rec, "cpuTime", 7, virt_newSVull(info[i].cpuTime), 0);
4395 (void)hv_store(rec, "cpu", 3, newSViv(info[i].cpu), 0);
4396 }
4397 (void)hv_store(rec, "affinity", 8, newSVpvn((char*)cpumaps + (i *maplen), maplen), 0);
4398 PUSHs(newRV_noinc((SV *)rec));
4399 }
4400
4401 if (info)
4402 Safefree(info);
4403 Safefree(cpumaps);
4404
4405
4406 void
4407 pin_vcpu(dom, vcpu, mask, flags=0)
4408 virDomainPtr dom;
4409 unsigned int vcpu;
4410 SV *mask;
4411 unsigned int flags;
4412 PREINIT:
4413 STRLEN masklen;
4414 unsigned char *maps;
4415 PPCODE:
4416 maps = (unsigned char *)SvPV(mask, masklen);
4417 if (flags) {
4418 if (virDomainPinVcpuFlags(dom, vcpu, maps, masklen, flags) < 0)
4419 _croak_error();
4420 } else {
4421 if (virDomainPinVcpu(dom, vcpu, maps, masklen) < 0)
4422 _croak_error();
4423 }
4424
4425
4426 void
4427 pin_emulator(dom, mask, flags=0)
4428 virDomainPtr dom;
4429 SV *mask;
4430 unsigned int flags;
4431 PREINIT:
4432 STRLEN masklen;
4433 unsigned char *maps;
4434 PPCODE:
4435 maps = (unsigned char *)SvPV(mask, masklen);
4436 if (virDomainPinEmulator(dom, maps, masklen, flags) < 0)
4437 _croak_error();
4438
4439
4440 SV *
4441 get_emulator_pin_info(dom, flags=0)
4442 virDomainPtr dom;
4443 unsigned int flags;
4444 PREINIT:
4445 unsigned char *cpumaps;
4446 int maplen;
4447 virNodeInfo nodeinfo;
4448 int nCpus;
4449 CODE:
4450 if (virNodeGetInfo(virDomainGetConnect(dom), &nodeinfo) < 0)
4451 _croak_error();
4452
4453 nCpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
4454 maplen = VIR_CPU_MAPLEN(nCpus);
4455 Newx(cpumaps, maplen, unsigned char);
4456 if ((virDomainGetEmulatorPinInfo(dom, cpumaps, maplen, flags)) < 0) {
4457 Safefree(cpumaps);
4458 _croak_error();
4459 }
4460 RETVAL = newSVpvn((char*)cpumaps, maplen);
4461 Safefree(cpumaps);
4462 OUTPUT:
4463 RETVAL
4464
4465
4466 int
4467 num_of_snapshots(dom, flags=0)
4468 virDomainPtr dom;
4469 unsigned int flags;
4470 CODE:
4471 if ((RETVAL = virDomainSnapshotNum(dom, flags)) < 0)
4472 _croak_error();
4473 OUTPUT:
4474 RETVAL
4475
4476
4477 void
4478 list_snapshot_names(dom, maxnames, flags=0)
4479 virDomainPtr dom;
4480 int maxnames;
4481 unsigned int flags;
4482 PREINIT:
4483 char **names;
4484 int nsnap;
4485 int i;
4486 PPCODE:
4487 Newx(names, maxnames, char *);
4488 if ((nsnap = virDomainSnapshotListNames(dom, names, maxnames, flags)) < 0) {
4489 Safefree(names);
4490 _croak_error();
4491 }
4492 EXTEND(SP, nsnap);
4493 for (i = 0 ; i < nsnap ; i++) {
4494 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
4495 free(names[i]);
4496 }
4497 Safefree(names);
4498
4499
4500 void
4501 list_all_snapshots(dom, flags=0)
4502 virDomainPtr dom;
4503 unsigned int flags;
4504 PREINIT:
4505 virDomainSnapshotPtr *domsss;
4506 int i, ndomss;
4507 SV *domssrv;
4508 PPCODE:
4509 if ((ndomss = virDomainListAllSnapshots(dom, &domsss, flags)) < 0)
4510 _croak_error();
4511
4512 EXTEND(SP, ndomss);
4513 for (i = 0 ; i < ndomss ; i++) {
4514 domssrv = sv_newmortal();
4515 sv_setref_pv(domssrv, "Sys::Virt::DomainSnapshot", domsss[i]);
4516 PUSHs(domssrv);
4517 }
4518 free(domsss);
4519
4520
4521 int
4522 has_current_snapshot(dom, flags=0)
4523 virDomainPtr dom;
4524 unsigned int flags;
4525 CODE:
4526 if ((RETVAL = virDomainHasCurrentSnapshot(dom, flags)) < 0)
4527 _croak_error();
4528 OUTPUT:
4529 RETVAL
4530
4531
4532 virDomainSnapshotPtr
4533 current_snapshot(dom, flags=0)
4534 virDomainPtr dom;
4535 unsigned int flags;
4536 CODE:
4537 if (!(RETVAL = virDomainSnapshotCurrent(dom, flags)))
4538 _croak_error();
4539 OUTPUT:
4540 RETVAL
4541
4542
4543 void
4544 fs_trim(dom, mountPoint, minimumsv, flags=0)
4545 virDomainPtr dom;
4546 const char *mountPoint;
4547 SV *minimumsv;
4548 unsigned int flags;
4549 PREINIT:
4550 unsigned long long minimum;
4551 PPCODE:
4552 minimum = virt_SvIVull(minimumsv);
4553 if (virDomainFSTrim(dom, mountPoint, minimum, flags) < 0)
4554 _croak_error();
4555
4556
4557 void
4558 send_process_signal(dom, pidsv, signum, flags=0)
4559 virDomainPtr dom;
4560 SV *pidsv;
4561 unsigned int signum;
4562 unsigned int flags;
4563 PREINIT:
4564 long long pid;
4565 PPCODE:
4566 pid = virt_SvIVull(pidsv);
4567 if (virDomainSendProcessSignal(dom, pid, signum, flags) < 0)
4568 _croak_error();
4569
4570
4571 void
4572 destroy(dom_rv, flags=0)
4573 SV *dom_rv;
4574 unsigned int flags;
4575 PREINIT:
4576 virDomainPtr dom;
4577 PPCODE:
4578 dom = (virDomainPtr)SvIV((SV*)SvRV(dom_rv));
4579 if (flags) {
4580 if (virDomainDestroyFlags(dom, flags) < 0)
4581 _croak_error();
4582 } else {
4583 if (virDomainDestroy(dom) < 0)
4584 _croak_error();
4585 }
4586
4587
4588 void
4589 DESTROY(dom_rv)
4590 SV *dom_rv;
4591 PREINIT:
4592 virDomainPtr dom;
4593 PPCODE:
4594 dom = (virDomainPtr)SvIV((SV*)SvRV(dom_rv));
4595 if (dom) {
4596 virDomainFree(dom);
4597 sv_setiv((SV*)SvRV(dom_rv), 0);
4598 }
4599
4600
4601 MODULE = Sys::Virt::Network PACKAGE = Sys::Virt::Network
4602
4603
4604 virNetworkPtr
4605 _create_xml(con, xml)
4606 virConnectPtr con;
4607 const char *xml;
4608 CODE:
4609 if (!(RETVAL = virNetworkCreateXML(con, xml)))
4610 _croak_error();
4611 OUTPUT:
4612 RETVAL
4613
4614
4615 virNetworkPtr
4616 _define_xml(con, xml)
4617 virConnectPtr con;
4618 const char *xml;
4619 CODE:
4620 if (!(RETVAL = virNetworkDefineXML(con, xml)))
4621 _croak_error();
4622 OUTPUT:
4623 RETVAL
4624
4625
4626 virNetworkPtr
4627 _lookup_by_name(con, name)
4628 virConnectPtr con;
4629 const char *name;
4630 CODE:
4631 if (!(RETVAL = virNetworkLookupByName(con, name)))
4632 _croak_error();
4633 OUTPUT:
4634 RETVAL
4635
4636
4637 virNetworkPtr
4638 _lookup_by_uuid(con, uuid)
4639 virConnectPtr con;
4640 const unsigned char *uuid;
4641 CODE:
4642 if (!(RETVAL = virNetworkLookupByUUID(con, uuid)))
4643 _croak_error();
4644 OUTPUT:
4645 RETVAL
4646
4647
4648 virNetworkPtr
4649 _lookup_by_uuid_string(con, uuid)
4650 virConnectPtr con;
4651 const char *uuid;
4652 CODE:
4653 if (!(RETVAL = virNetworkLookupByUUIDString(con, uuid)))
4654 _croak_error();
4655
4656 OUTPUT:
4657 RETVAL
4658
4659
4660 SV *
4661 get_uuid(net)
4662 virNetworkPtr net;
4663 PREINIT:
4664 unsigned char rawuuid[VIR_UUID_BUFLEN];
4665 CODE:
4666 if ((virNetworkGetUUID(net, rawuuid)) < 0)
4667 _croak_error();
4668
4669 RETVAL = newSVpv((char*)rawuuid, sizeof(rawuuid));
4670 OUTPUT:
4671 RETVAL
4672
4673
4674 SV *
4675 get_uuid_string(net)
4676 virNetworkPtr net;
4677 PREINIT:
4678 char uuid[VIR_UUID_STRING_BUFLEN];
4679 CODE:
4680 if ((virNetworkGetUUIDString(net, uuid)) < 0)
4681 _croak_error();
4682
4683 RETVAL = newSVpv(uuid, 0);
4684 OUTPUT:
4685 RETVAL
4686
4687
4688 const char *
4689 get_name(net)
4690 virNetworkPtr net;
4691 CODE:
4692 if (!(RETVAL = virNetworkGetName(net)))
4693 _croak_error();
4694 OUTPUT:
4695 RETVAL
4696
4697
4698 int
4699 is_active(net)
4700 virNetworkPtr net;
4701 CODE:
4702 if ((RETVAL = virNetworkIsActive(net)) < 0)
4703 _croak_error();
4704 OUTPUT:
4705 RETVAL
4706
4707
4708 int
4709 is_persistent(net)
4710 virNetworkPtr net;
4711 CODE:
4712 if ((RETVAL = virNetworkIsPersistent(net)) < 0)
4713 _croak_error();
4714 OUTPUT:
4715 RETVAL
4716
4717
4718 SV *
4719 get_bridge_name(net)
4720 virNetworkPtr net;
4721 PREINIT:
4722 char *name;
4723 CODE:
4724 if (!(name = virNetworkGetBridgeName(net)))
4725 _croak_error();
4726
4727 RETVAL = newSVpv(name, 0);
4728 free(name);
4729 OUTPUT:
4730 RETVAL
4731
4732
4733 SV *
4734 get_xml_description(net, flags=0)
4735 virNetworkPtr net;
4736 unsigned int flags;
4737 PREINIT:
4738 char *xml;
4739 CODE:
4740 if (!(xml = virNetworkGetXMLDesc(net, flags)))
4741 _croak_error();
4742
4743 RETVAL = newSVpv(xml, 0);
4744 free(xml);
4745 OUTPUT:
4746 RETVAL
4747
4748
4749 void
4750 undefine(net)
4751 virNetworkPtr net;
4752 PPCODE:
4753 if (virNetworkUndefine(net) < 0)
4754 _croak_error();
4755
4756
4757 void
4758 create(net)
4759 virNetworkPtr net;
4760 PPCODE:
4761 if (virNetworkCreate(net) < 0)
4762 _croak_error();
4763
4764
4765 void
4766 update(net, command, section, parentIndex, xml, flags=0)
4767 virNetworkPtr net;
4768 unsigned int command;
4769 unsigned int section;
4770 int parentIndex;
4771 const char *xml;
4772 unsigned int flags;
4773 PPCODE:
4774 if (virNetworkUpdate(net, command, section, parentIndex, xml, flags) < 0)
4775 _croak_error();
4776
4777 void
4778 set_autostart(net, autostart)
4779 virNetworkPtr net;
4780 int autostart;
4781 PPCODE:
4782 if (virNetworkSetAutostart(net, autostart) < 0)
4783 _croak_error();
4784
4785
4786 int
4787 get_autostart(net)
4788 virNetworkPtr net;
4789 PREINIT:
4790 int autostart;
4791 CODE:
4792 if (virNetworkGetAutostart(net, &autostart) < 0)
4793 _croak_error();
4794
4795 RETVAL = autostart;
4796 OUTPUT:
4797 RETVAL
4798
4799
4800 void
4801 destroy(net_rv)
4802 SV *net_rv;
4803 PREINIT:
4804 virNetworkPtr net;
4805 PPCODE:
4806 net = (virNetworkPtr)SvIV((SV*)SvRV(net_rv));
4807 if (virNetworkDestroy(net) < 0)
4808 _croak_error();
4809
4810
4811 void
4812 DESTROY(net_rv)
4813 SV *net_rv;
4814 PREINIT:
4815 virNetworkPtr net;
4816 PPCODE:
4817 net = (virNetworkPtr)SvIV((SV*)SvRV(net_rv));
4818 if (net) {
4819 virNetworkFree(net);
4820 sv_setiv((SV*)SvRV(net_rv), 0);
4821 }
4822
4823
4824 MODULE = Sys::Virt::StoragePool PACKAGE = Sys::Virt::StoragePool
4825
4826
4827 virStoragePoolPtr
4828 _create_xml(con, xml)
4829 virConnectPtr con;
4830 const char *xml;
4831 CODE:
4832 if (!(RETVAL = virStoragePoolCreateXML(con, xml, 0)))
4833 _croak_error();
4834
4835 OUTPUT:
4836 RETVAL
4837
4838
4839 virStoragePoolPtr
4840 _define_xml(con, xml)
4841 virConnectPtr con;
4842 const char *xml;
4843 CODE:
4844 if (!(RETVAL = virStoragePoolDefineXML(con, xml, 0)))
4845 _croak_error();
4846 OUTPUT:
4847 RETVAL
4848
4849
4850 virStoragePoolPtr
4851 _lookup_by_name(con, name)
4852 virConnectPtr con;
4853 const char *name;
4854 CODE:
4855 if (!(RETVAL = virStoragePoolLookupByName(con, name)))
4856 _croak_error();
4857 OUTPUT:
4858 RETVAL
4859
4860
4861 virStoragePoolPtr
4862 _lookup_by_uuid(con, uuid)
4863 virConnectPtr con;
4864 const unsigned char *uuid;
4865 CODE:
4866 if (!(RETVAL = virStoragePoolLookupByUUID(con, uuid)))
4867 _croak_error();
4868 OUTPUT:
4869 RETVAL
4870
4871
4872 virStoragePoolPtr
4873 _lookup_by_uuid_string(con, uuid)
4874 virConnectPtr con;
4875 const char *uuid;
4876 CODE:
4877 if (!(RETVAL = virStoragePoolLookupByUUIDString(con, uuid)))
4878 _croak_error();
4879 OUTPUT:
4880 RETVAL
4881
4882
4883 virStoragePoolPtr
4884 _lookup_by_volume(vol)
4885 virStorageVolPtr vol;
4886 CODE:
4887 if (!(RETVAL = virStoragePoolLookupByVolume(vol)))
4888 _croak_error();
4889 OUTPUT:
4890 RETVAL
4891
4892
4893 SV *
4894 get_uuid(pool)
4895 virStoragePoolPtr pool;
4896 PREINIT:
4897 unsigned char rawuuid[VIR_UUID_BUFLEN];
4898 CODE:
4899 if ((virStoragePoolGetUUID(pool, rawuuid)) < 0)
4900 _croak_error();
4901
4902 RETVAL = newSVpv((char*)rawuuid, sizeof(rawuuid));
4903 OUTPUT:
4904 RETVAL
4905
4906
4907 SV *
4908 get_uuid_string(pool)
4909 virStoragePoolPtr pool;
4910 PREINIT:
4911 char uuid[VIR_UUID_STRING_BUFLEN];
4912 CODE:
4913 if ((virStoragePoolGetUUIDString(pool, uuid)) < 0)
4914 _croak_error();
4915
4916 RETVAL = newSVpv(uuid, 0);
4917 OUTPUT:
4918 RETVAL
4919
4920
4921 const char *
4922 get_name(pool)
4923 virStoragePoolPtr pool;
4924 CODE:
4925 if (!(RETVAL = virStoragePoolGetName(pool)))
4926 _croak_error();
4927 OUTPUT:
4928 RETVAL
4929
4930
4931 int
4932 is_active(pool)
4933 virStoragePoolPtr pool;
4934 CODE:
4935 if ((RETVAL = virStoragePoolIsActive(pool)) < 0)
4936 _croak_error();
4937 OUTPUT:
4938 RETVAL
4939
4940
4941 int
4942 is_persistent(pool)
4943 virStoragePoolPtr pool;
4944 CODE:
4945 if ((RETVAL = virStoragePoolIsPersistent(pool)) < 0)
4946 _croak_error();
4947 OUTPUT:
4948 RETVAL
4949
4950
4951 SV *
4952 get_xml_description(pool, flags=0)
4953 virStoragePoolPtr pool;
4954 unsigned int flags;
4955 PREINIT:
4956 char *xml;
4957 CODE:
4958 if (!(xml = virStoragePoolGetXMLDesc(pool, flags)))
4959 _croak_error();
4960
4961 RETVAL = newSVpv(xml, 0);
4962 free(xml);
4963 OUTPUT:
4964 RETVAL
4965
4966
4967 void
4968 undefine(pool)
4969 virStoragePoolPtr pool;
4970 PPCODE:
4971 if (virStoragePoolUndefine(pool) < 0)
4972 _croak_error();
4973
4974
4975 void
4976 create(pool)
4977 virStoragePoolPtr pool;
4978 PPCODE:
4979 if (virStoragePoolCreate(pool, 0) < 0)
4980 _croak_error();
4981
4982
4983 void
4984 refresh(pool, flags=0)
4985 virStoragePoolPtr pool;
4986 int flags;
4987 PPCODE:
4988 if (virStoragePoolRefresh(pool, flags) < 0)
4989 _croak_error();
4990
4991
4992 void
4993 build(pool, flags=0)
4994 virStoragePoolPtr pool;
4995 int flags;
4996 PPCODE:
4997 if (virStoragePoolBuild(pool, flags) < 0)
4998 _croak_error();
4999
5000
5001 void
5002 delete(pool, flags=0)
5003 virStoragePoolPtr pool;
5004 int flags;
5005 PPCODE:
5006 if (virStoragePoolDelete(pool, flags) < 0)
5007 _croak_error();
5008
5009
5010 void
5011 set_autostart(pool, autostart)
5012 virStoragePoolPtr pool;
5013 int autostart;
5014 PPCODE:
5015 if (virStoragePoolSetAutostart(pool, autostart) < 0)
5016 _croak_error();
5017
5018
5019 int
5020 get_autostart(pool)
5021 virStoragePoolPtr pool;
5022 PREINIT:
5023 int autostart;
5024 CODE:
5025 if (virStoragePoolGetAutostart(pool, &autostart) < 0)
5026 _croak_error();
5027
5028 RETVAL = autostart;
5029 OUTPUT:
5030 RETVAL
5031
5032
5033 HV *
5034 get_info(pool)
5035 virStoragePoolPtr pool;
5036 PREINIT:
5037 virStoragePoolInfo info;
5038 CODE:
5039 if (virStoragePoolGetInfo(pool, &info) < 0)
5040 _croak_error();
5041
5042 RETVAL = (HV *)sv_2mortal((SV*)newHV());
5043 (void)hv_store (RETVAL, "state", 5, newSViv(info.state), 0);
5044 (void)hv_store (RETVAL, "capacity", 8, virt_newSVull(info.capacity), 0);
5045 (void)hv_store (RETVAL, "allocation", 10, virt_newSVull(info.allocation), 0);
5046 (void)hv_store (RETVAL, "available", 9, virt_newSVull(info.available), 0);
5047 OUTPUT:
5048 RETVAL
5049
5050
5051 void
5052 destroy(pool_rv)
5053 SV *pool_rv;
5054 PREINIT:
5055 virStoragePoolPtr pool;
5056 PPCODE:
5057 pool = (virStoragePoolPtr)SvIV((SV*)SvRV(pool_rv));
5058 if (virStoragePoolDestroy(pool) < 0)
5059 _croak_error();
5060
5061
5062 int
5063 num_of_storage_volumes(pool)
5064 virStoragePoolPtr pool;
5065 CODE:
5066 if ((RETVAL = virStoragePoolNumOfVolumes(pool)) < 0)
5067 _croak_error();
5068 OUTPUT:
5069 RETVAL
5070
5071
5072 void
5073 list_storage_vol_names(pool, maxnames)
5074 virStoragePoolPtr pool;
5075 int maxnames;
5076 PREINIT:
5077 char **names;
5078 int i, nnet;
5079 PPCODE:
5080 Newx(names, maxnames, char *);
5081 if ((nnet = virStoragePoolListVolumes(pool, names, maxnames)) < 0) {
5082 Safefree(names);
5083 _croak_error();
5084 }
5085 EXTEND(SP, nnet);
5086 for (i = 0 ; i < nnet ; i++) {
5087 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
5088 free(names[i]);
5089 }
5090 Safefree(names);
5091
5092
5093 void
5094 list_all_volumes(pool, flags=0)
5095 virStoragePoolPtr pool;
5096 unsigned int flags;
5097 PREINIT:
5098 virStorageVolPtr *vols;
5099 int i, nvolss;
5100 SV *volssrv;
5101 PPCODE:
5102 if ((nvolss = virStoragePoolListAllVolumes(pool, &vols, flags)) < 0)
5103 _croak_error();
5104
5105 EXTEND(SP, nvolss);
5106 for (i = 0 ; i < nvolss ; i++) {
5107 volssrv = sv_newmortal();
5108 sv_setref_pv(volssrv, "Sys::Virt::StorageVol", vols[i]);
5109 PUSHs(volssrv);
5110 }
5111 free(vols);
5112
5113
5114
5115
5116 void
5117 DESTROY(pool_rv)
5118 SV *pool_rv;
5119 PREINIT:
5120 virStoragePoolPtr pool;
5121 PPCODE:
5122 pool = (virStoragePoolPtr)SvIV((SV*)SvRV(pool_rv));
5123 if (pool) {
5124 virStoragePoolFree(pool);
5125 sv_setiv((SV*)SvRV(pool_rv), 0);
5126 }
5127
5128
5129 MODULE = Sys::Virt::StorageVol PACKAGE = Sys::Virt::StorageVol
5130
5131
5132 virStorageVolPtr
5133 _create_xml(pool, xml, flags=0)
5134 virStoragePoolPtr pool;
5135 const char *xml;
5136 int flags;
5137 CODE:
5138 if (!(RETVAL = virStorageVolCreateXML(pool, xml, flags)))
5139 _croak_error();
5140 OUTPUT:
5141 RETVAL
5142
5143
5144 virStorageVolPtr
5145 _create_xml_from(pool, xml, clone, flags=0)
5146 virStoragePoolPtr pool;
5147 const char *xml;
5148 virStorageVolPtr clone;
5149 int flags;
5150 CODE:
5151 if (!(RETVAL = virStorageVolCreateXMLFrom(pool, xml, clone, flags)))
5152 _croak_error();
5153 OUTPUT:
5154 RETVAL
5155
5156
5157 virStorageVolPtr
5158 _lookup_by_name(pool, name)
5159 virStoragePoolPtr pool;
5160 const char *name;
5161 CODE:
5162 if (!(RETVAL = virStorageVolLookupByName(pool, name)))
5163 _croak_error();
5164 OUTPUT:
5165 RETVAL
5166
5167
5168 virStorageVolPtr
5169 _lookup_by_key(con, key)
5170 virConnectPtr con;
5171 const char *key;
5172 CODE:
5173 if (!(RETVAL = virStorageVolLookupByKey(con, key)))
5174 _croak_error();
5175 OUTPUT:
5176 RETVAL
5177
5178
5179 virStorageVolPtr
5180 _lookup_by_path(con, path)
5181 virConnectPtr con;
5182 const char *path;
5183 CODE:
5184 if (!(RETVAL = virStorageVolLookupByPath(con, path)))
5185 _croak_error();
5186 OUTPUT:
5187 RETVAL
5188
5189
5190 const char *
5191 get_name(vol)
5192 virStorageVolPtr vol;
5193 CODE:
5194 if (!(RETVAL = virStorageVolGetName(vol)))
5195 _croak_error();
5196 OUTPUT:
5197 RETVAL
5198
5199
5200 const char *
5201 get_key(vol)
5202 virStorageVolPtr vol;
5203 CODE:
5204 if (!(RETVAL = virStorageVolGetKey(vol)))
5205 _croak_error();
5206 OUTPUT:
5207 RETVAL
5208
5209
5210 const char *
5211 get_path(vol)
5212 virStorageVolPtr vol;
5213 CODE:
5214 if (!(RETVAL = virStorageVolGetPath(vol)))
5215 _croak_error();
5216 OUTPUT:
5217 RETVAL
5218
5219
5220 void
5221 resize(vol, capacity, flags=0)
5222 virStorageVolPtr vol;
5223 SV *capacity;
5224 unsigned int flags;
5225 PPCODE:
5226 if (virStorageVolResize(vol, virt_SvIVull(capacity), flags) < 0)
5227 _croak_error();
5228
5229
5230 SV *
5231 get_xml_description(vol, flags=0)
5232 virStorageVolPtr vol;
5233 unsigned int flags;
5234 PREINIT:
5235 char *xml;
5236 CODE:
5237 if (!(xml = virStorageVolGetXMLDesc(vol, flags)))
5238 _croak_error();
5239
5240 RETVAL = newSVpv(xml, 0);
5241 free(xml);
5242 OUTPUT:
5243 RETVAL
5244
5245
5246 void
5247 delete(vol, flags=0)
5248 virStorageVolPtr vol;
5249 unsigned int flags;
5250 PPCODE:
5251 if (virStorageVolDelete(vol, flags) < 0)
5252 _croak_error();
5253
5254
5255 void
5256 wipe(vol, flags=0)
5257 virStorageVolPtr vol;
5258 unsigned int flags;
5259 PPCODE:
5260 if (virStorageVolWipe(vol, flags) < 0)
5261 _croak_error();
5262
5263
5264 void
5265 wipe_pattern(vol, algorithm, flags=0)
5266 virStorageVolPtr vol;
5267 unsigned int algorithm
5268 unsigned int flags;
5269 PPCODE:
5270 if (virStorageVolWipePattern(vol, algorithm, flags) < 0)
5271 _croak_error();
5272
5273
5274 HV *
5275 get_info(vol)
5276 virStorageVolPtr vol;
5277 PREINIT:
5278 virStorageVolInfo info;
5279 CODE:
5280 if (virStorageVolGetInfo(vol, &info) < 0)
5281 _croak_error();
5282
5283 RETVAL = (HV *)sv_2mortal((SV*)newHV());
5284 (void)hv_store (RETVAL, "type", 4, newSViv(info.type), 0);
5285 (void)hv_store (RETVAL, "capacity", 8, virt_newSVull(info.capacity), 0);
5286 (void)hv_store (RETVAL, "allocation", 10, virt_newSVull(info.allocation), 0);
5287 OUTPUT:
5288 RETVAL
5289
5290
5291 void
5292 download(vol, st, offsetsv, lengthsv, flags=0)
5293 virStorageVolPtr vol;
5294 virStreamPtr st;
5295 SV *offsetsv;
5296 SV *lengthsv;
5297 unsigned int flags;
5298 PREINIT:
5299 unsigned long long offset;
5300 unsigned long long length;
5301 PPCODE:
5302 offset = virt_SvIVull(offsetsv);
5303 length = virt_SvIVull(lengthsv);
5304
5305 if (virStorageVolDownload(vol, st, offset, length, flags) < 0)
5306 _croak_error();
5307
5308
5309 void
5310 upload(vol, st, offsetsv, lengthsv, flags=0)
5311 virStorageVolPtr vol;
5312 virStreamPtr st;
5313 SV *offsetsv;
5314 SV *lengthsv;
5315 unsigned int flags;
5316 PREINIT:
5317 unsigned long long offset;
5318 unsigned long long length;
5319 PPCODE:
5320 offset = virt_SvIVull(offsetsv);
5321 length = virt_SvIVull(lengthsv);
5322
5323 if (virStorageVolUpload(vol, st, offset, length, flags) < 0)
5324 _croak_error();
5325
5326
5327 void
5328 DESTROY(vol_rv)
5329 SV *vol_rv;
5330 PREINIT:
5331 virStorageVolPtr vol;
5332 PPCODE:
5333 vol = (virStorageVolPtr)SvIV((SV*)SvRV(vol_rv));
5334 if (vol) {
5335 virStorageVolFree(vol);
5336 sv_setiv((SV*)SvRV(vol_rv), 0);
5337 }
5338
5339
5340 MODULE = Sys::Virt::NodeDevice PACKAGE = Sys::Virt::NodeDevice
5341
5342
5343 virNodeDevicePtr
5344 _create_xml(con, xml, flags=0)
5345 virConnectPtr con;
5346 const char *xml;
5347 unsigned int flags;
5348 CODE:
5349 if (!(RETVAL = virNodeDeviceCreateXML(con, xml, flags)))
5350 _croak_error();
5351 OUTPUT:
5352 RETVAL
5353
5354
5355 virNodeDevicePtr
5356 _lookup_by_name(con, name)
5357 virConnectPtr con;
5358 const char *name;
5359 CODE:
5360 if (!(RETVAL = virNodeDeviceLookupByName(con, name)))
5361 _croak_error();
5362 OUTPUT:
5363 RETVAL
5364
5365
5366 virNodeDevicePtr
5367 _lookup_scsihost_by_wwn(con, wwnn, wwpn, flags=0)
5368 virConnectPtr con;
5369 const char *wwnn;
5370 const char *wwpn;
5371 unsigned int flags;
5372 CODE:
5373 if (!(RETVAL = virNodeDeviceLookupSCSIHostByWWN(con, wwnn, wwpn, flags)))
5374 _croak_error();
5375 OUTPUT:
5376 RETVAL
5377
5378
5379 const char *
5380 get_name(dev)
5381 virNodeDevicePtr dev;
5382 CODE:
5383 if (!(RETVAL = virNodeDeviceGetName(dev)))
5384 _croak_error();
5385 OUTPUT:
5386 RETVAL
5387
5388
5389 const char *
5390 get_parent(dev)
5391 virNodeDevicePtr dev;
5392 CODE:
5393 if (!(RETVAL = virNodeDeviceGetParent(dev)))
5394 _croak_error();
5395 OUTPUT:
5396 RETVAL
5397
5398
5399 SV *
5400 get_xml_description(dev, flags=0)
5401 virNodeDevicePtr dev;
5402 unsigned int flags;
5403 PREINIT:
5404 char *xml;
5405 CODE:
5406 if (!(xml = virNodeDeviceGetXMLDesc(dev, flags)))
5407 _croak_error();
5408
5409 RETVAL = newSVpv(xml, 0);
5410 free(xml);
5411 OUTPUT:
5412 RETVAL
5413
5414
5415 void
5416 dettach(dev, driversv, flags=0)
5417 virNodeDevicePtr dev;
5418 SV *driversv;
5419 unsigned int flags;
5420 PREINIT:
5421 const char *driver = NULL;
5422 STRLEN len;
5423 PPCODE:
5424 if (SvOK(driversv)) {
5425 driver = SvPV(driversv, len);
5426 }
5427
5428 if (flags || driver) {
5429 if (virNodeDeviceDetachFlags(dev, driver, flags) < 0)
5430 _croak_error();
5431 } else {
5432 if (virNodeDeviceDettach(dev) < 0)
5433 _croak_error();
5434 }
5435
5436
5437 void
5438 reattach(dev)
5439 virNodeDevicePtr dev;
5440 PPCODE:
5441 if (virNodeDeviceReAttach(dev) < 0)
5442 _croak_error();
5443
5444
5445 void
5446 reset(dev)
5447 virNodeDevicePtr dev;
5448 PPCODE:
5449 if (virNodeDeviceReset(dev) < 0)
5450 _croak_error();
5451
5452
5453 void
5454 list_capabilities(dev)
5455 virNodeDevicePtr dev;
5456 PREINIT:
5457 int maxnames;
5458 char **names;
5459 int i, nnet;
5460 PPCODE:
5461 if ((maxnames = virNodeDeviceNumOfCaps(dev)) < 0)
5462 _croak_error();
5463
5464 Newx(names, maxnames, char *);
5465 if ((nnet = virNodeDeviceListCaps(dev, names, maxnames)) < 0) {
5466 Safefree(names);
5467 _croak_error();
5468 }
5469 EXTEND(SP, nnet);
5470 for (i = 0 ; i < nnet ; i++) {
5471 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
5472 free(names[i]);
5473 }
5474 Safefree(names);
5475
5476
5477 void
5478 destroy(dev_rv)
5479 SV *dev_rv;
5480 PREINIT:
5481 virNodeDevicePtr dev;
5482 PPCODE:
5483 dev = (virNodeDevicePtr)SvIV((SV*)SvRV(dev_rv));
5484 if (virNodeDeviceDestroy(dev) < 0)
5485 _croak_error();
5486
5487
5488 void
5489 DESTROY(dev_rv)
5490 SV *dev_rv;
5491 PREINIT:
5492 virNodeDevicePtr dev;
5493 PPCODE:
5494 dev = (virNodeDevicePtr)SvIV((SV*)SvRV(dev_rv));
5495 if (dev) {
5496 virNodeDeviceFree(dev);
5497 sv_setiv((SV*)SvRV(dev_rv), 0);
5498 }
5499
5500
5501 MODULE = Sys::Virt::Interface PACKAGE = Sys::Virt::Interface
5502
5503 virInterfacePtr
5504 _define_xml(con, xml, flags = 0)
5505 virConnectPtr con;
5506 const char *xml;
5507 unsigned int flags;
5508 CODE:
5509 if (!(RETVAL = virInterfaceDefineXML(con, xml, flags)))
5510 _croak_error();
5511 OUTPUT:
5512 RETVAL
5513
5514
5515 virInterfacePtr
5516 _lookup_by_name(con, name)
5517 virConnectPtr con;
5518 const char *name;
5519 CODE:
5520 if (!(RETVAL = virInterfaceLookupByName(con, name)))
5521 _croak_error();
5522 OUTPUT:
5523 RETVAL
5524
5525
5526 virInterfacePtr
5527 _lookup_by_mac(con, mac)
5528 virConnectPtr con;
5529 const char *mac;
5530 CODE:
5531 if (!(RETVAL = virInterfaceLookupByMACString(con, mac)))
5532 _croak_error();
5533 OUTPUT:
5534 RETVAL
5535
5536
5537 const char *
5538 get_mac(iface)
5539 virInterfacePtr iface;
5540 CODE:
5541 if (!(RETVAL = virInterfaceGetMACString(iface)))
5542 _croak_error();
5543 OUTPUT:
5544 RETVAL
5545
5546
5547 const char *
5548 get_name(iface)
5549 virInterfacePtr iface;
5550 CODE:
5551 if (!(RETVAL = virInterfaceGetName(iface)))
5552 _croak_error();
5553 OUTPUT:
5554 RETVAL
5555
5556
5557 int
5558 is_active(iface)
5559 virInterfacePtr iface;
5560 CODE:
5561 if ((RETVAL = virInterfaceIsActive(iface)) < 0)
5562 _croak_error();
5563 OUTPUT:
5564 RETVAL
5565
5566
5567 SV *
5568 get_xml_description(iface, flags=0)
5569 virInterfacePtr iface;
5570 unsigned int flags;
5571 PREINIT:
5572 char *xml;
5573 CODE:
5574 if (!(xml = virInterfaceGetXMLDesc(iface, flags)))
5575 _croak_error();
5576 RETVAL = newSVpv(xml, 0);
5577 free(xml);
5578 OUTPUT:
5579 RETVAL
5580
5581
5582 void
5583 undefine(iface)
5584 virInterfacePtr iface;
5585 PPCODE:
5586 if (virInterfaceUndefine(iface) < 0)
5587 _croak_error();
5588
5589
5590 void
5591 create(iface, flags=0)
5592 virInterfacePtr iface;
5593 unsigned int flags;
5594 PPCODE:
5595 if (virInterfaceCreate(iface, flags) < 0)
5596 _croak_error();
5597
5598
5599 void
5600 destroy(iface_rv, flags=0)
5601 SV *iface_rv;
5602 unsigned int flags;
5603 PREINIT:
5604 virInterfacePtr iface;
5605 PPCODE:
5606 iface = (virInterfacePtr)SvIV((SV*)SvRV(iface_rv));
5607 if (virInterfaceDestroy(iface, flags) < 0)
5608 _croak_error();
5609
5610
5611 void
5612 DESTROY(iface_rv)
5613 SV *iface_rv;
5614 PREINIT:
5615 virInterfacePtr iface;
5616 PPCODE:
5617 iface = (virInterfacePtr)SvIV((SV*)SvRV(iface_rv));
5618 if (iface) {
5619 virInterfaceFree(iface);
5620 sv_setiv((SV*)SvRV(iface_rv), 0);
5621 }
5622
5623
5624 MODULE = Sys::Virt::Secret PACKAGE = Sys::Virt::Secret
5625
5626
5627 virSecretPtr
5628 _define_xml(con, xml, flags=0)
5629 virConnectPtr con;
5630 const char *xml;
5631 unsigned int flags;
5632 CODE:
5633 if (!(RETVAL = virSecretDefineXML(con, xml, flags)))
5634 _croak_error();
5635 OUTPUT:
5636 RETVAL
5637
5638
5639 virSecretPtr
_lookup_by_usage(con,usageType,usageID)5640 _lookup_by_usage(con, usageType, usageID)
5641 virConnectPtr con;
5642 int usageType;
5643 const char *usageID;
5644 CODE:
5645 if (!(RETVAL = virSecretLookupByUsage(con, usageType, usageID))) {
5646 _croak_error();
5647 }
5648 OUTPUT:
5649 RETVAL
5650
5651
5652 virSecretPtr
5653 _lookup_by_uuid(con, uuid)
5654 virConnectPtr con;
5655 const unsigned char *uuid;
5656 CODE:
5657 if (!(RETVAL = virSecretLookupByUUID(con, uuid)))
5658 _croak_error();
5659 OUTPUT:
5660 RETVAL
5661
5662
5663 virSecretPtr
5664 _lookup_by_uuid_string(con, uuid)
5665 virConnectPtr con;
5666 const char *uuid;
5667 CODE:
5668 if (!(RETVAL = virSecretLookupByUUIDString(con, uuid)))
5669 _croak_error();
5670 OUTPUT:
5671 RETVAL
5672
5673
5674 SV *
5675 get_uuid(sec)
5676 virSecretPtr sec;
5677 PREINIT:
5678 unsigned char rawuuid[VIR_UUID_BUFLEN];
5679 CODE:
5680 if ((virSecretGetUUID(sec, rawuuid)) < 0)
5681 _croak_error();
5682
5683 RETVAL = newSVpv((char*)rawuuid, sizeof(rawuuid));
5684 OUTPUT:
5685 RETVAL
5686
5687
5688 SV *
5689 get_uuid_string(sec)
5690 virSecretPtr sec;
5691 PREINIT:
5692 char uuid[VIR_UUID_STRING_BUFLEN];
5693 CODE:
5694 if ((virSecretGetUUIDString(sec, uuid)) < 0)
5695 _croak_error();
5696
5697 RETVAL = newSVpv(uuid, 0);
5698 OUTPUT:
5699 RETVAL
5700
5701
5702 const char *
5703 get_usage_id(sec)
5704 virSecretPtr sec;
5705 CODE:
5706 if (!(RETVAL = virSecretGetUsageID(sec)))
5707 _croak_error();
5708 OUTPUT:
5709 RETVAL
5710
5711
5712 int
5713 get_usage_type(sec)
5714 virSecretPtr sec;
5715 CODE:
5716 if (!(RETVAL = virSecretGetUsageType(sec)))
5717 _croak_error();
5718 OUTPUT:
5719 RETVAL
5720
5721
5722 SV *
5723 get_xml_description(sec, flags=0)
5724 virSecretPtr sec;
5725 unsigned int flags;
5726 PREINIT:
5727 char *xml;
5728 CODE:
5729 if (!(xml = virSecretGetXMLDesc(sec, flags)))
5730 _croak_error();
5731 RETVAL = newSVpv(xml, 0);
5732 free(xml);
5733 OUTPUT:
5734 RETVAL
5735
5736
5737 void
5738 undefine(sec)
5739 virSecretPtr sec;
5740 PPCODE:
5741 if (virSecretUndefine(sec) < 0)
5742 _croak_error();
5743
5744
5745 void
5746 set_value(sec, value, flags=0)
5747 virSecretPtr sec;
5748 SV *value;
5749 unsigned int flags;
5750 PREINIT:
5751 unsigned char *bytes;
5752 STRLEN len;
5753 PPCODE:
5754 bytes = (unsigned char *)SvPV(value, len);
5755 if (virSecretSetValue(sec, bytes, len, flags) < 0)
5756 _croak_error();
5757
5758
5759 SV *
5760 get_value(sec, flags=0)
5761 virSecretPtr sec;
5762 unsigned int flags;
5763 PREINIT:
5764 unsigned char *bytes;
5765 size_t len;
5766 CODE:
5767 if ((bytes = virSecretGetValue(sec, &len, flags)) == NULL)
5768 _croak_error();
5769
5770 RETVAL = newSVpv((char*)bytes, len);
5771 OUTPUT:
5772 RETVAL
5773
5774
5775
5776 void
5777 DESTROY(sec_rv)
5778 SV *sec_rv;
5779 PREINIT:
5780 virSecretPtr sec;
5781 PPCODE:
5782 sec = (virSecretPtr)SvIV((SV*)SvRV(sec_rv));
5783 if (sec) {
5784 virSecretFree(sec);
5785 sv_setiv((SV*)SvRV(sec_rv), 0);
5786 }
5787
5788
5789 MODULE = Sys::Virt::NWFilter PACKAGE = Sys::Virt::NWFilter
5790
5791
5792 virNWFilterPtr
5793 _define_xml(con, xml)
5794 virConnectPtr con;
5795 const char *xml;
5796 CODE:
5797 if (!(RETVAL = virNWFilterDefineXML(con, xml)))
5798 _croak_error();
5799 OUTPUT:
5800 RETVAL
5801
5802
5803 virNWFilterPtr
5804 _lookup_by_name(con, name)
5805 virConnectPtr con;
5806 const char *name;
5807 CODE:
5808 if (!(RETVAL = virNWFilterLookupByName(con, name)))
5809 _croak_error();
5810 OUTPUT:
5811 RETVAL
5812
5813
5814 virNWFilterPtr
5815 _lookup_by_uuid(con, uuid)
5816 virConnectPtr con;
5817 const unsigned char *uuid;
5818 CODE:
5819 if (!(RETVAL = virNWFilterLookupByUUID(con, uuid)))
5820 _croak_error();
5821 OUTPUT:
5822 RETVAL
5823
5824
5825 virNWFilterPtr
5826 _lookup_by_uuid_string(con, uuid)
5827 virConnectPtr con;
5828 const char *uuid;
5829 CODE:
5830 if (!(RETVAL = virNWFilterLookupByUUIDString(con, uuid)))
5831 _croak_error();
5832 OUTPUT:
5833 RETVAL
5834
5835
5836 SV *
5837 get_uuid(filter)
5838 virNWFilterPtr filter;
5839 PREINIT:
5840 unsigned char rawuuid[VIR_UUID_BUFLEN];
5841 CODE:
5842 if ((virNWFilterGetUUID(filter, rawuuid)) < 0)
5843 _croak_error();
5844
5845 RETVAL = newSVpv((char*)rawuuid, sizeof(rawuuid));
5846 OUTPUT:
5847 RETVAL
5848
5849
5850 SV *
5851 get_uuid_string(filter)
5852 virNWFilterPtr filter;
5853 PREINIT:
5854 char uuid[VIR_UUID_STRING_BUFLEN];
5855 CODE:
5856 if ((virNWFilterGetUUIDString(filter, uuid)) < 0)
5857 _croak_error();
5858
5859 RETVAL = newSVpv(uuid, 0);
5860 OUTPUT:
5861 RETVAL
5862
5863
5864 const char *
5865 get_name(filter)
5866 virNWFilterPtr filter;
5867 CODE:
5868 if (!(RETVAL = virNWFilterGetName(filter)))
5869 _croak_error();
5870 OUTPUT:
5871 RETVAL
5872
5873
5874 SV *
5875 get_xml_description(filter, flags=0)
5876 virNWFilterPtr filter;
5877 unsigned int flags;
5878 PREINIT:
5879 char *xml;
5880 CODE:
5881 if (!(xml = virNWFilterGetXMLDesc(filter, flags)))
5882 _croak_error();
5883
5884 RETVAL = newSVpv(xml, 0);
5885 free(xml);
5886 OUTPUT:
5887 RETVAL
5888
5889
5890 void
5891 undefine(filter)
5892 virNWFilterPtr filter;
5893 PPCODE:
5894 if (virNWFilterUndefine(filter) < 0)
5895 _croak_error();
5896
5897 void
5898 DESTROY(filter_rv)
5899 SV *filter_rv;
5900 PREINIT:
5901 virNWFilterPtr filter;
5902 PPCODE:
5903 filter = (virNWFilterPtr)SvIV((SV*)SvRV(filter_rv));
5904 if (filter) {
5905 virNWFilterFree(filter);
5906 sv_setiv((SV*)SvRV(filter_rv), 0);
5907 }
5908
5909
5910 MODULE = Sys::Virt::DomainSnapshot PACKAGE = Sys::Virt::DomainSnapshot
5911
5912
5913 virDomainSnapshotPtr
5914 _create_xml(dom, xml, flags=0)
5915 virDomainPtr dom;
5916 const char *xml;
5917 unsigned int flags;
5918 CODE:
5919 if (!(RETVAL = virDomainSnapshotCreateXML(dom, xml, flags)))
5920 _croak_error();
5921 OUTPUT:
5922 RETVAL
5923
5924
5925 virDomainSnapshotPtr
5926 _lookup_by_name(dom, name, flags=0)
5927 virDomainPtr dom;
5928 const char *name;
5929 unsigned int flags;
5930 CODE:
5931 if (!(RETVAL = virDomainSnapshotLookupByName(dom, name, flags)))
5932 _croak_error();
5933 OUTPUT:
5934 RETVAL
5935
5936
5937 const char *
5938 get_name(domss)
5939 virDomainSnapshotPtr domss;
5940 CODE:
5941 if (!(RETVAL = virDomainSnapshotGetName(domss)))
5942 _croak_error();
5943 OUTPUT:
5944 RETVAL
5945
5946
5947 SV *
5948 get_xml_description(domss, flags=0)
5949 virDomainSnapshotPtr domss;
5950 unsigned int flags;
5951 PREINIT:
5952 char *xml;
5953 CODE:
5954 if (!(xml = virDomainSnapshotGetXMLDesc(domss, flags)))
5955 _croak_error();
5956 RETVAL = newSVpv(xml, 0);
5957 free(xml);
5958 OUTPUT:
5959 RETVAL
5960
5961
5962 void
5963 revert_to(domss, flags=0)
5964 virDomainSnapshotPtr domss;
5965 unsigned int flags;
5966 PPCODE:
5967 if (virDomainRevertToSnapshot(domss, flags) < 0)
5968 _croak_error();
5969
5970
5971 void
5972 delete(domss, flags=0)
5973 virDomainSnapshotPtr domss;
5974 unsigned int flags;
5975 PPCODE:
5976 if (virDomainSnapshotDelete(domss, flags) < 0)
5977 _croak_error();
5978
5979
5980 virDomainSnapshotPtr
5981 get_parent(domss, flags=0)
5982 virDomainSnapshotPtr domss;
5983 unsigned int flags;
5984 CODE:
5985 if (!(RETVAL = virDomainSnapshotGetParent(domss, flags)))
5986 _croak_error();
5987 OUTPUT:
5988 RETVAL
5989
5990
5991 int
5992 num_of_child_snapshots(domss, flags=0)
5993 virDomainSnapshotPtr domss;
5994 unsigned int flags;
5995 CODE:
5996 if ((RETVAL = virDomainSnapshotNumChildren(domss, flags)) < 0)
5997 _croak_error();
5998 OUTPUT:
5999 RETVAL
6000
6001
6002 int
6003 is_current(domss, flags=0)
6004 virDomainSnapshotPtr domss;
6005 unsigned int flags;
6006 CODE:
6007 if ((RETVAL = virDomainSnapshotIsCurrent(domss, flags)) < 0)
6008 _croak_error();
6009 OUTPUT:
6010 RETVAL
6011
6012
6013 int
6014 has_metadata(domss, flags=0)
6015 virDomainSnapshotPtr domss;
6016 unsigned int flags;
6017 CODE:
6018 if ((RETVAL = virDomainSnapshotHasMetadata(domss, flags)) < 0)
6019 _croak_error();
6020 OUTPUT:
6021 RETVAL
6022
6023
6024 void
6025 list_child_snapshot_names(domss, maxnames, flags=0)
6026 virDomainSnapshotPtr domss;
6027 int maxnames;
6028 unsigned int flags;
6029 PREINIT:
6030 char **names;
6031 int nsnap;
6032 int i;
6033 PPCODE:
6034 Newx(names, maxnames, char *);
6035 if ((nsnap = virDomainSnapshotListChildrenNames(domss, names, maxnames, flags)) < 0) {
6036 Safefree(names);
6037 _croak_error();
6038 }
6039 EXTEND(SP, nsnap);
6040 for (i = 0 ; i < nsnap ; i++) {
6041 PUSHs(sv_2mortal(newSVpv(names[i], 0)));
6042 free(names[i]);
6043 }
6044 Safefree(names);
6045
6046
6047 void
6048 list_all_children(domss, flags=0)
6049 virDomainSnapshotPtr domss;
6050 unsigned int flags;
6051 PREINIT:
6052 virDomainSnapshotPtr *domsss;
6053 int i, ndomss;
6054 SV *domssrv;
6055 PPCODE:
6056 if ((ndomss = virDomainSnapshotListAllChildren(domss, &domsss, flags)) < 0)
6057 _croak_error();
6058
6059 EXTEND(SP, ndomss);
6060 for (i = 0 ; i < ndomss ; i++) {
6061 domssrv = sv_newmortal();
6062 sv_setref_pv(domssrv, "Sys::Virt::DomainSnapshot", domsss[i]);
6063 PUSHs(domssrv);
6064 }
6065 free(domsss);
6066
6067
6068 void
6069 DESTROY(domss_rv)
6070 SV *domss_rv;
6071 PREINIT:
6072 virDomainSnapshotPtr domss;
6073 PPCODE:
6074 domss = (virDomainSnapshotPtr)SvIV((SV*)SvRV(domss_rv));
6075 if (domss) {
6076 virDomainSnapshotFree(domss);
6077 sv_setiv((SV*)SvRV(domss_rv), 0);
6078 }
6079
6080
6081 MODULE = Sys::Virt::Event PACKAGE = Sys::Virt::Event
6082
6083
6084 PROTOTYPES: ENABLE
6085
6086
6087 void
6088 _register_impl()
6089 PPCODE:
6090 virEventRegisterImpl(_event_add_handle,
6091 _event_update_handle,
6092 _event_remove_handle,
6093 _event_add_timeout,
6094 _event_update_timeout,
6095 _event_remove_timeout);
6096
6097
6098 void
6099 register_default()
6100 PPCODE:
6101 virEventRegisterDefaultImpl();
6102
6103
6104 void
6105 run_default()
6106 PPCODE:
6107 virEventRunDefaultImpl();
6108
6109
6110 int
6111 add_handle(fd, events, coderef)
6112 int fd;
6113 int events;
6114 SV *coderef;
6115 PREINIT:
6116 int watch;
6117 CODE:
6118 SvREFCNT_inc(coderef);
6119
6120 if ((watch = virEventAddHandle(fd, events, _event_handle_helper, coderef, _event_cb_free)) < 0) {
6121 SvREFCNT_dec(coderef);
6122 _croak_error();
6123 }
6124 RETVAL = watch;
6125 OUTPUT:
6126 RETVAL
6127
6128
6129 void
6130 update_handle(watch, events)
6131 int watch;
6132 int events;
6133 PPCODE:
6134 virEventUpdateHandle(watch, events);
6135
6136
6137 void
6138 remove_handle(watch)
6139 int watch;
6140 PPCODE:
6141 if (virEventRemoveHandle(watch) < 0)
6142 _croak_error();
6143
6144
6145 int
6146 add_timeout(frequency, coderef)
6147 int frequency;
6148 SV *coderef;
6149 PREINIT:
6150 int timer;
6151 CODE:
6152 SvREFCNT_inc(coderef);
6153
6154 if ((timer = virEventAddTimeout(frequency, _event_timeout_helper, coderef, _event_cb_free)) < 0) {
6155 SvREFCNT_dec(coderef);
6156 _croak_error();
6157 }
6158 RETVAL = timer;
6159 OUTPUT:
6160 RETVAL
6161
6162
6163 void
6164 update_timeout(timer, frequency)
6165 int timer;
6166 int frequency;
6167 PPCODE:
6168 virEventUpdateTimeout(timer, frequency);
6169
6170
6171 void
6172 remove_timeout(timer)
6173 int timer;
6174 PPCODE:
6175 if (virEventRemoveTimeout(timer) < 0)
6176 _croak_error();
6177
6178
6179 void
6180 _run_handle_callback_helper(watch, fd, event, cbref, opaqueref)
6181 int watch;
6182 int fd;
6183 int event;
6184 SV *cbref;
6185 SV *opaqueref;
6186 PREINIT:
6187 virEventHandleCallback cb;
6188 void *opaque;
6189 PPCODE:
6190 cb = (virEventHandleCallback)SvIV((SV*)SvRV(cbref));
6191 opaque = (void*)SvIV((SV*)SvRV(opaqueref));
6192
6193 cb(watch, fd, event, opaque);
6194
6195
6196 void
6197 _run_timeout_callback_helper(timer, cbref, opaqueref)
6198 int timer;
6199 SV *cbref;
6200 SV *opaqueref;
6201 PREINIT:
6202 virEventTimeoutCallback cb;
6203 void *opaque;
6204 PPCODE:
6205 cb = (virEventTimeoutCallback)SvIV((SV*)SvRV(cbref));
6206 opaque = (void*)SvIV((SV*)SvRV(opaqueref));
6207
6208 cb(timer, opaque);
6209
6210
6211 void
6212 _free_callback_opaque_helper(ffref, opaqueref)
6213 SV *ffref;
6214 SV *opaqueref;
6215 PREINIT:
6216 virFreeCallback ff;
6217 void *opaque;
6218 PPCODE:
6219 opaque = SvOK(opaqueref) ? (void*)SvIV((SV*)SvRV(opaqueref)) : NULL;
6220 ff = SvOK(ffref) ? (virFreeCallback)SvIV((SV*)SvRV(ffref)) : NULL;
6221
6222 if (opaque != NULL && ff != NULL)
6223 ff(opaque);
6224
6225
6226
6227 MODULE = Sys::Virt::Stream PACKAGE = Sys::Virt::Stream
6228
6229 virStreamPtr
6230 _new_obj(con, flags=0)
6231 virConnectPtr con;
6232 unsigned int flags;
6233 CODE:
6234 if (!(RETVAL = virStreamNew(con, flags)))
6235 _croak_error();
6236 OUTPUT:
6237 RETVAL
6238
6239
6240 int
6241 send(st, data, nbytes)
6242 virStreamPtr st;
6243 SV *data;
6244 size_t nbytes;
6245 PREINIT:
6246 const char *rawdata;
6247 STRLEN len;
6248 CODE:
6249 if (SvOK(data)) {
6250 rawdata = SvPV(data, len);
6251 if (nbytes > len)
6252 nbytes = len;
6253 } else {
6254 rawdata = "";
6255 nbytes = 0;
6256 }
6257
6258 if ((RETVAL = virStreamSend(st, rawdata, nbytes)) < 0 &&
6259 RETVAL != -2)
6260 _croak_error();
6261 OUTPUT:
6262 RETVAL
6263
6264
6265 int
6266 recv(st, data, nbytes)
6267 virStreamPtr st;
6268 SV *data;
6269 size_t nbytes;
6270 PREINIT:
6271 char *rawdata;
6272 CODE:
6273 Newx(rawdata, nbytes, char);
6274 if ((RETVAL = virStreamRecv(st, rawdata, nbytes)) < 0 &&
6275 RETVAL != -2) {
6276 Safefree(rawdata);
6277 _croak_error();
6278 }
6279 if (RETVAL > 0) {
6280 sv_setpvn(data, rawdata, RETVAL);
6281 }
6282 Safefree(rawdata);
6283 OUTPUT:
6284 RETVAL
6285
6286
6287 void
6288 send_all(stref, handler)
6289 SV *stref;
6290 SV *handler;
6291 PREINIT:
6292 AV *opaque;
6293 virStreamPtr st;
6294 CODE:
6295 st = (virStreamPtr)SvIV((SV*)SvRV(stref));
6296
6297 opaque = newAV();
6298 SvREFCNT_inc(handler);
6299 SvREFCNT_inc(stref);
6300 av_push(opaque, stref);
6301 av_push(opaque, handler);
6302
6303 if (virStreamSendAll(st, _stream_send_all_source, opaque) < 0)
6304 _croak_error();
6305
6306 SvREFCNT_dec(opaque);
6307
6308
6309 void
6310 recv_all(stref, handler)
6311 SV *stref;
6312 SV *handler;
6313 PREINIT:
6314 AV *opaque;
6315 virStreamPtr st;
6316 CODE:
6317 st = (virStreamPtr)SvIV((SV*)SvRV(stref));
6318
6319 opaque = newAV();
6320 SvREFCNT_inc(handler);
6321 SvREFCNT_inc(stref);
6322 av_push(opaque, stref);
6323 av_push(opaque, handler);
6324
6325 if (virStreamRecvAll(st, _stream_recv_all_sink, opaque) < 0)
6326 _croak_error();
6327
6328 SvREFCNT_dec(opaque);
6329
6330
6331 void
6332 add_callback(stref, events, cb)
6333 SV* stref;
6334 int events;
6335 SV* cb;
6336 PREINIT:
6337 AV *opaque;
6338 virStreamPtr st;
6339 PPCODE:
6340 st = (virStreamPtr)SvIV((SV*)SvRV(stref));
6341
6342 opaque = newAV();
6343 SvREFCNT_inc(cb);
6344 SvREFCNT_inc(stref);
6345 av_push(opaque, stref);
6346 av_push(opaque, cb);
6347 if (virStreamEventAddCallback(st, events, _stream_event_callback, opaque, _stream_event_free) < 0)
6348 _croak_error();
6349
6350
6351 void
6352 update_callback(st, events)
6353 virStreamPtr st;
6354 int events;
6355 PPCODE:
6356 if (virStreamEventUpdateCallback(st, events) < 0)
6357 _croak_error();
6358
6359
6360 void
6361 remove_callback(st)
6362 virStreamPtr st;
6363 PPCODE:
6364 if (virStreamEventRemoveCallback(st) < 0)
6365 _croak_error();
6366
6367
6368 void
6369 finish(st)
6370 virStreamPtr st;
6371 PPCODE:
6372 if (virStreamFinish(st) < 0)
6373 _croak_error();
6374
6375
6376 void
6377 abort(st)
6378 virStreamPtr st;
6379 PPCODE:
6380 if (virStreamAbort(st) < 0)
6381 _croak_error();
6382
6383
6384 void
6385 DESTROY(st_rv)
6386 SV *st_rv;
6387 PREINIT:
6388 virStreamPtr st;
6389 PPCODE:
6390 st = (virStreamPtr)SvIV((SV*)SvRV(st_rv));
6391 if (st) {
6392 virStreamFree(st);
6393 sv_setiv((SV*)SvRV(st_rv), 0);
6394 }
6395
6396
6397 MODULE = Sys::Virt PACKAGE = Sys::Virt
6398
6399
6400 PROTOTYPES: ENABLE
6401
6402
6403 BOOT:
6404 {
6405 HV *stash;
6406
6407 virSetErrorFunc(NULL, ignoreVirErrorFunc);
6408 virInitialize();
6409
6410 stash = gv_stashpv( "Sys::Virt", TRUE );
6411
6412 REGISTER_CONSTANT(VIR_CONNECT_RO, CONNECT_RO);
6413 REGISTER_CONSTANT(VIR_CONNECT_NO_ALIASES, CONNECT_NO_ALIASES);
6414
6415 REGISTER_CONSTANT(VIR_CRED_USERNAME, CRED_USERNAME);
6416 REGISTER_CONSTANT(VIR_CRED_AUTHNAME, CRED_AUTHNAME);
6417 REGISTER_CONSTANT(VIR_CRED_LANGUAGE, CRED_LANGUAGE);
6418 REGISTER_CONSTANT(VIR_CRED_CNONCE, CRED_CNONCE);
6419 REGISTER_CONSTANT(VIR_CRED_PASSPHRASE, CRED_PASSPHRASE);
6420 REGISTER_CONSTANT(VIR_CRED_ECHOPROMPT, CRED_ECHOPROMPT);
6421 REGISTER_CONSTANT(VIR_CRED_NOECHOPROMPT, CRED_NOECHOPROMPT);
6422 REGISTER_CONSTANT(VIR_CRED_REALM, CRED_REALM);
6423 REGISTER_CONSTANT(VIR_CRED_EXTERNAL, CRED_EXTERNAL);
6424
6425
6426 /* Don't bother with VIR_CPU_COMPARE_ERROR since we die in that case */
6427 REGISTER_CONSTANT(VIR_CPU_COMPARE_INCOMPATIBLE, CPU_COMPARE_INCOMPATIBLE);
6428 REGISTER_CONSTANT(VIR_CPU_COMPARE_IDENTICAL, CPU_COMPARE_IDENTICAL);
6429 REGISTER_CONSTANT(VIR_CPU_COMPARE_SUPERSET, CPU_COMPARE_SUPERSET);
6430
6431
6432 REGISTER_CONSTANT(VIR_NODE_SUSPEND_TARGET_MEM, NODE_SUSPEND_TARGET_MEM);
6433 REGISTER_CONSTANT(VIR_NODE_SUSPEND_TARGET_DISK, NODE_SUSPEND_TARGET_DISK);
6434 REGISTER_CONSTANT(VIR_NODE_SUSPEND_TARGET_HYBRID, NODE_SUSPEND_TARGET_HYBRID);
6435
6436
6437 REGISTER_CONSTANT(VIR_NODE_CPU_STATS_ALL_CPUS, NODE_CPU_STATS_ALL_CPUS);
6438 REGISTER_CONSTANT_STR(VIR_NODE_CPU_STATS_IDLE, NODE_CPU_STATS_IDLE);
6439 REGISTER_CONSTANT_STR(VIR_NODE_CPU_STATS_IOWAIT, NODE_CPU_STATS_IOWAIT);
6440 REGISTER_CONSTANT_STR(VIR_NODE_CPU_STATS_KERNEL, NODE_CPU_STATS_KERNEL);
6441 REGISTER_CONSTANT_STR(VIR_NODE_CPU_STATS_USER, NODE_CPU_STATS_USER);
6442 REGISTER_CONSTANT_STR(VIR_NODE_CPU_STATS_UTILIZATION, NODE_CPU_STATS_UTILIZATION);
6443
6444 REGISTER_CONSTANT(VIR_NODE_MEMORY_STATS_ALL_CELLS, NODE_MEMORY_STATS_ALL_CELLS);
6445 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_STATS_BUFFERS, NODE_MEMORY_STATS_BUFFERS);
6446 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_STATS_CACHED, NODE_MEMORY_STATS_CACHED);
6447 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_STATS_FREE, NODE_MEMORY_STATS_FREE);
6448 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_STATS_TOTAL, NODE_MEMORY_STATS_TOTAL);
6449
6450 REGISTER_CONSTANT(VIR_CONNECT_CLOSE_REASON_CLIENT, CLOSE_REASON_CLIENT);
6451 REGISTER_CONSTANT(VIR_CONNECT_CLOSE_REASON_EOF, CLOSE_REASON_EOF);
6452 REGISTER_CONSTANT(VIR_CONNECT_CLOSE_REASON_ERROR, CLOSE_REASON_ERROR);
6453 REGISTER_CONSTANT(VIR_CONNECT_CLOSE_REASON_KEEPALIVE, CLOSE_REASON_KEEPALIVE);
6454
6455 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_SHARED_PAGES_TO_SCAN, NODE_MEMORY_SHARED_PAGES_TO_SCAN);
6456 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_SHARED_SLEEP_MILLISECS, NODE_MEMORY_SHARED_SLEEP_MILLISECS);
6457 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_SHARED_PAGES_SHARED, NODE_MEMORY_SHARED_PAGES_SHARED);
6458 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_SHARED_PAGES_SHARING, NODE_MEMORY_SHARED_PAGES_SHARING);
6459 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_SHARED_PAGES_UNSHARED, NODE_MEMORY_SHARED_PAGES_UNSHARED);
6460 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_SHARED_PAGES_VOLATILE, NODE_MEMORY_SHARED_PAGES_VOLATILE);
6461 REGISTER_CONSTANT_STR(VIR_NODE_MEMORY_SHARED_FULL_SCANS, NODE_MEMORY_SHARED_FULL_SCANS);
6462
6463
6464 stash = gv_stashpv( "Sys::Virt::Event", TRUE );
6465
6466 REGISTER_CONSTANT(VIR_EVENT_HANDLE_READABLE, HANDLE_READABLE);
6467 REGISTER_CONSTANT(VIR_EVENT_HANDLE_WRITABLE, HANDLE_WRITABLE);
6468 REGISTER_CONSTANT(VIR_EVENT_HANDLE_ERROR, HANDLE_ERROR);
6469 REGISTER_CONSTANT(VIR_EVENT_HANDLE_HANGUP, HANDLE_HANGUP);
6470
6471
6472 stash = gv_stashpv( "Sys::Virt::Domain", TRUE );
6473 REGISTER_CONSTANT(VIR_DOMAIN_NOSTATE, STATE_NOSTATE);
6474 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING, STATE_RUNNING);
6475 REGISTER_CONSTANT(VIR_DOMAIN_BLOCKED, STATE_BLOCKED);
6476 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED, STATE_PAUSED);
6477 REGISTER_CONSTANT(VIR_DOMAIN_SHUTDOWN, STATE_SHUTDOWN);
6478 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF, STATE_SHUTOFF);
6479 REGISTER_CONSTANT(VIR_DOMAIN_CRASHED, STATE_CRASHED);
6480 REGISTER_CONSTANT(VIR_DOMAIN_PMSUSPENDED, STATE_PMSUSPENDED);
6481
6482 REGISTER_CONSTANT(VIR_DUMP_CRASH, DUMP_CRASH);
6483 REGISTER_CONSTANT(VIR_DUMP_LIVE, DUMP_LIVE);
6484 REGISTER_CONSTANT(VIR_DUMP_BYPASS_CACHE, DUMP_BYPASS_CACHE);
6485 REGISTER_CONSTANT(VIR_DUMP_RESET, DUMP_RESET);
6486 REGISTER_CONSTANT(VIR_DUMP_MEMORY_ONLY, DUMP_MEMORY_ONLY);
6487
6488 REGISTER_CONSTANT(VIR_DOMAIN_SAVE_BYPASS_CACHE, SAVE_BYPASS_CACHE);
6489 REGISTER_CONSTANT(VIR_DOMAIN_SAVE_RUNNING, SAVE_RUNNING);
6490 REGISTER_CONSTANT(VIR_DOMAIN_SAVE_PAUSED, SAVE_PAUSED);
6491
6492 REGISTER_CONSTANT(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, UNDEFINE_MANAGED_SAVE);
6493 REGISTER_CONSTANT(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, UNDEFINE_SNAPSHOTS_METADATA);
6494
6495 REGISTER_CONSTANT(VIR_DOMAIN_START_PAUSED, START_PAUSED);
6496 REGISTER_CONSTANT(VIR_DOMAIN_START_AUTODESTROY, START_AUTODESTROY);
6497 REGISTER_CONSTANT(VIR_DOMAIN_START_BYPASS_CACHE, START_BYPASS_CACHE);
6498 REGISTER_CONSTANT(VIR_DOMAIN_START_FORCE_BOOT, START_FORCE_BOOT);
6499
6500 REGISTER_CONSTANT(VIR_DOMAIN_NOSTATE_UNKNOWN, STATE_NOSTATE_UNKNOWN);
6501
6502 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_UNKNOWN, STATE_RUNNING_UNKNOWN);
6503 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_BOOTED, STATE_RUNNING_BOOTED);
6504 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_MIGRATED, STATE_RUNNING_MIGRATED);
6505 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_RESTORED, STATE_RUNNING_RESTORED);
6506 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_FROM_SNAPSHOT, STATE_RUNNING_FROM_SNAPSHOT);
6507 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_UNPAUSED, STATE_RUNNING_UNPAUSED);
6508 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_MIGRATION_CANCELED, STATE_RUNNING_MIGRATION_CANCELED);
6509 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_SAVE_CANCELED, STATE_RUNNING_SAVE_CANCELED);
6510 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_WAKEUP, STATE_RUNNING_WAKEUP);
6511 REGISTER_CONSTANT(VIR_DOMAIN_RUNNING_CRASHED, STATE_RUNNING_CRASHED);
6512
6513 REGISTER_CONSTANT(VIR_DOMAIN_BLOCKED_UNKNOWN, STATE_BLOCKED_UNKNOWN);
6514
6515 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_UNKNOWN, STATE_PAUSED_UNKNOWN);
6516 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_USER, STATE_PAUSED_USER);
6517 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_MIGRATION, STATE_PAUSED_MIGRATION);
6518 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_SAVE, STATE_PAUSED_SAVE);
6519 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_DUMP, STATE_PAUSED_DUMP);
6520 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_IOERROR, STATE_PAUSED_IOERROR);
6521 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_WATCHDOG, STATE_PAUSED_WATCHDOG);
6522 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_FROM_SNAPSHOT, STATE_PAUSED_FROM_SNAPSHOT);
6523 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_SHUTTING_DOWN, STATE_PAUSED_SHUTTING_DOWN);
6524 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_SNAPSHOT, STATE_PAUSED_SNAPSHOT);
6525 REGISTER_CONSTANT(VIR_DOMAIN_PAUSED_CRASHED, STATE_PAUSED_CRASHED);
6526
6527 REGISTER_CONSTANT(VIR_DOMAIN_SHUTDOWN_UNKNOWN, STATE_SHUTDOWN_UNKNOWN);
6528 REGISTER_CONSTANT(VIR_DOMAIN_SHUTDOWN_USER, STATE_SHUTDOWN_USER);
6529
6530 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF_UNKNOWN, STATE_SHUTOFF_UNKNOWN);
6531 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF_SHUTDOWN, STATE_SHUTOFF_SHUTDOWN);
6532 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF_DESTROYED, STATE_SHUTOFF_DESTROYED);
6533 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF_CRASHED, STATE_SHUTOFF_CRASHED);
6534 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF_MIGRATED, STATE_SHUTOFF_MIGRATED);
6535 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF_SAVED, STATE_SHUTOFF_SAVED);
6536 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF_FAILED, STATE_SHUTOFF_FAILED);
6537 REGISTER_CONSTANT(VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, STATE_SHUTOFF_FROM_SNAPSHOT);
6538
6539 REGISTER_CONSTANT(VIR_DOMAIN_CRASHED_UNKNOWN, STATE_CRASHED_UNKNOWN);
6540 REGISTER_CONSTANT(VIR_DOMAIN_CRASHED_PANICKED, STATE_CRASHED_PANICKED);
6541
6542 REGISTER_CONSTANT(VIR_DOMAIN_PMSUSPENDED_UNKNOWN, STATE_PMSUSPENDED_UNKNOWN);
6543
6544 REGISTER_CONSTANT(VIR_DOMAIN_PMSUSPENDED_DISK_UNKNOWN, STATE_PMSUSPENDED_DISK_UNKNOWN);
6545
6546 REGISTER_CONSTANT(VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH, OPEN_GRAPHICS_SKIPAUTH);
6547
6548 REGISTER_CONSTANT(VIR_DOMAIN_CONSOLE_FORCE, OPEN_CONSOLE_FORCE);
6549 REGISTER_CONSTANT(VIR_DOMAIN_CONSOLE_SAFE, OPEN_CONSOLE_SAFE);
6550
6551 REGISTER_CONSTANT(VIR_DOMAIN_CHANNEL_FORCE, OPEN_CHANNEL_FORCE);
6552
6553 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD, SCHEDULER_EMULATOR_PERIOD);
6554 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA, SCHEDULER_EMULATOR_QUOTA);
6555
6556 REGISTER_CONSTANT_STR(VIR_DOMAIN_CPU_STATS_CPUTIME, CPU_STATS_CPUTIME);
6557 REGISTER_CONSTANT_STR(VIR_DOMAIN_CPU_STATS_SYSTEMTIME, CPU_STATS_SYSTEMTIME);
6558 REGISTER_CONSTANT_STR(VIR_DOMAIN_CPU_STATS_USERTIME, CPU_STATS_USERTIME);
6559 REGISTER_CONSTANT_STR(VIR_DOMAIN_CPU_STATS_VCPUTIME, CPU_STATS_VCPUTIME);
6560
6561
6562 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_ERRS, BLOCK_STATS_ERRS);
6563 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_FLUSH_REQ, BLOCK_STATS_FLUSH_REQ);
6564 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_FLUSH_TOTAL_TIMES, BLOCK_STATS_FLUSH_TOTAL_TIMES);
6565 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_READ_BYTES, BLOCK_STATS_READ_BYTES);
6566 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_READ_REQ, BLOCK_STATS_READ_REQ);
6567 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_READ_TOTAL_TIMES, BLOCK_STATS_READ_TOTAL_TIMES);
6568 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES, BLOCK_STATS_WRITE_BYTES);
6569 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_WRITE_REQ, BLOCK_STATS_WRITE_REQ);
6570 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_STATS_WRITE_TOTAL_TIMES, BLOCK_STATS_WRITE_TOTAL_TIMES);
6571
6572 REGISTER_CONSTANT(VIR_MIGRATE_LIVE, MIGRATE_LIVE);
6573 REGISTER_CONSTANT(VIR_MIGRATE_PEER2PEER, MIGRATE_PEER2PEER);
6574 REGISTER_CONSTANT(VIR_MIGRATE_TUNNELLED, MIGRATE_TUNNELLED);
6575 REGISTER_CONSTANT(VIR_MIGRATE_PERSIST_DEST, MIGRATE_PERSIST_DEST);
6576 REGISTER_CONSTANT(VIR_MIGRATE_UNDEFINE_SOURCE, MIGRATE_UNDEFINE_SOURCE);
6577 REGISTER_CONSTANT(VIR_MIGRATE_PAUSED, MIGRATE_PAUSED);
6578 REGISTER_CONSTANT(VIR_MIGRATE_NON_SHARED_DISK, MIGRATE_NON_SHARED_DISK);
6579 REGISTER_CONSTANT(VIR_MIGRATE_NON_SHARED_INC, MIGRATE_NON_SHARED_INC);
6580 REGISTER_CONSTANT(VIR_MIGRATE_CHANGE_PROTECTION, MIGRATE_CHANGE_PROTECTION);
6581 REGISTER_CONSTANT(VIR_MIGRATE_UNSAFE, MIGRATE_UNSAFE);
6582 REGISTER_CONSTANT(VIR_MIGRATE_OFFLINE, MIGRATE_OFFLINE);
6583 REGISTER_CONSTANT(VIR_MIGRATE_COMPRESSED, MIGRATE_COMPRESSED);
6584 REGISTER_CONSTANT(VIR_MIGRATE_ABORT_ON_ERROR, MIGRATE_ABORT_ON_ERROR);
6585
6586 REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_BANDWIDTH, MIGRATE_PARAM_BANDWIDTH);
6587 REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_DEST_NAME, MIGRATE_PARAM_DEST_NAME);
6588 REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_DEST_XML, MIGRATE_PARAM_DEST_XML);
6589 REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_GRAPHICS_URI, MIGRATE_PARAM_GRAPHICS_URI);
6590 REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_URI, MIGRATE_PARAM_URI);
6591
6592 REGISTER_CONSTANT(VIR_DOMAIN_XML_SECURE, XML_SECURE);
6593 REGISTER_CONSTANT(VIR_DOMAIN_XML_INACTIVE, XML_INACTIVE);
6594 REGISTER_CONSTANT(VIR_DOMAIN_XML_UPDATE_CPU, XML_UPDATE_CPU);
6595 REGISTER_CONSTANT(VIR_DOMAIN_XML_MIGRATABLE, XML_MIGRATABLE);
6596
6597
6598 REGISTER_CONSTANT(VIR_MEMORY_VIRTUAL, MEMORY_VIRTUAL);
6599 REGISTER_CONSTANT(VIR_MEMORY_PHYSICAL, MEMORY_PHYSICAL);
6600
6601
6602 REGISTER_CONSTANT(VIR_VCPU_OFFLINE, VCPU_OFFLINE);
6603 REGISTER_CONSTANT(VIR_VCPU_RUNNING, VCPU_RUNNING);
6604 REGISTER_CONSTANT(VIR_VCPU_BLOCKED, VCPU_BLOCKED);
6605
6606
6607 REGISTER_CONSTANT(VIR_KEYCODE_SET_LINUX, KEYCODE_SET_LINUX);
6608 REGISTER_CONSTANT(VIR_KEYCODE_SET_XT, KEYCODE_SET_XT);
6609 REGISTER_CONSTANT(VIR_KEYCODE_SET_ATSET1, KEYCODE_SET_ATSET1);
6610 REGISTER_CONSTANT(VIR_KEYCODE_SET_ATSET2, KEYCODE_SET_ATSET2);
6611 REGISTER_CONSTANT(VIR_KEYCODE_SET_ATSET3, KEYCODE_SET_ATSET3);
6612 REGISTER_CONSTANT(VIR_KEYCODE_SET_OSX, KEYCODE_SET_OSX);
6613 REGISTER_CONSTANT(VIR_KEYCODE_SET_XT_KBD, KEYCODE_SET_XT_KBD);
6614 REGISTER_CONSTANT(VIR_KEYCODE_SET_USB, KEYCODE_SET_USB);
6615 REGISTER_CONSTANT(VIR_KEYCODE_SET_WIN32, KEYCODE_SET_WIN32);
6616 REGISTER_CONSTANT(VIR_KEYCODE_SET_RFB, KEYCODE_SET_RFB);
6617
6618
6619 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_DEFINED, EVENT_DEFINED);
6620 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_UNDEFINED, EVENT_UNDEFINED);
6621 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STARTED, EVENT_STARTED);
6622 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SUSPENDED, EVENT_SUSPENDED);
6623 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_RESUMED, EVENT_RESUMED);
6624 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STOPPED, EVENT_STOPPED);
6625 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SHUTDOWN, EVENT_SHUTDOWN);
6626 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_PMSUSPENDED, EVENT_PMSUSPENDED);
6627 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_PMSUSPENDED_DISK, EVENT_PMSUSPENDED_DISK);
6628 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_CRASHED, EVENT_CRASHED);
6629
6630 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_DEFINED_ADDED, EVENT_DEFINED_ADDED);
6631 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_DEFINED_UPDATED, EVENT_DEFINED_UPDATED);
6632
6633 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_UNDEFINED_REMOVED, EVENT_UNDEFINED_REMOVED);
6634
6635 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STARTED_BOOTED, EVENT_STARTED_BOOTED);
6636 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STARTED_MIGRATED, EVENT_STARTED_MIGRATED);
6637 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STARTED_RESTORED, EVENT_STARTED_RESTORED);
6638 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT, EVENT_STARTED_FROM_SNAPSHOT);
6639 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STARTED_WAKEUP, EVENT_STARTED_WAKEUP);
6640
6641 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_CRASHED_PANICKED, EVENT_CRASHED_PANICKED);
6642
6643 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SUSPENDED_PAUSED, EVENT_SUSPENDED_PAUSED);
6644 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED, EVENT_SUSPENDED_MIGRATED);
6645 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SUSPENDED_IOERROR, EVENT_SUSPENDED_IOERROR);
6646 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SUSPENDED_WATCHDOG, EVENT_SUSPENDED_WATCHDOG);
6647 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SUSPENDED_RESTORED, EVENT_SUSPENDED_RESTORED);
6648 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT, EVENT_SUSPENDED_FROM_SNAPSHOT);
6649 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR, EVENT_SUSPENDED_API_ERROR);
6650
6651 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_RESUMED_UNPAUSED, EVENT_RESUMED_UNPAUSED);
6652 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_RESUMED_MIGRATED, EVENT_RESUMED_MIGRATED);
6653 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT, EVENT_RESUMED_FROM_SNAPSHOT);
6654
6655 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN, EVENT_STOPPED_SHUTDOWN);
6656 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STOPPED_DESTROYED, EVENT_STOPPED_DESTROYED);
6657 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STOPPED_CRASHED, EVENT_STOPPED_CRASHED);
6658 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STOPPED_MIGRATED, EVENT_STOPPED_MIGRATED);
6659 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STOPPED_SAVED, EVENT_STOPPED_SAVED);
6660 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STOPPED_FAILED, EVENT_STOPPED_FAILED);
6661 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT, EVENT_STOPPED_FROM_SNAPSHOT);
6662
6663 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED, EVENT_SHUTDOWN_FINISHED);
6664
6665 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY, EVENT_PMSUSPENDED_MEMORY);
6666
6667
6668 REGISTER_CONSTANT(VIR_DOMAIN_CONTROL_OK, CONTROL_OK);
6669 REGISTER_CONSTANT(VIR_DOMAIN_CONTROL_JOB, CONTROL_JOB);
6670 REGISTER_CONSTANT(VIR_DOMAIN_CONTROL_OCCUPIED, CONTROL_OCCUPIED);
6671 REGISTER_CONSTANT(VIR_DOMAIN_CONTROL_ERROR, CONTROL_ERROR);
6672
6673
6674 REGISTER_CONSTANT(VIR_DOMAIN_DEVICE_MODIFY_CURRENT, DEVICE_MODIFY_CURRENT);
6675 REGISTER_CONSTANT(VIR_DOMAIN_DEVICE_MODIFY_LIVE, DEVICE_MODIFY_LIVE);
6676 REGISTER_CONSTANT(VIR_DOMAIN_DEVICE_MODIFY_CONFIG, DEVICE_MODIFY_CONFIG);
6677 REGISTER_CONSTANT(VIR_DOMAIN_DEVICE_MODIFY_FORCE, DEVICE_MODIFY_FORCE);
6678
6679
6680 REGISTER_CONSTANT(VIR_DOMAIN_MEM_CURRENT, MEM_CURRENT);
6681 REGISTER_CONSTANT(VIR_DOMAIN_MEM_LIVE, MEM_LIVE);
6682 REGISTER_CONSTANT(VIR_DOMAIN_MEM_CONFIG, MEM_CONFIG);
6683 REGISTER_CONSTANT(VIR_DOMAIN_MEM_MAXIMUM, MEM_MAXIMUM);
6684
6685
6686 REGISTER_CONSTANT(VIR_DOMAIN_AFFECT_CURRENT, AFFECT_CURRENT);
6687 REGISTER_CONSTANT(VIR_DOMAIN_AFFECT_LIVE, AFFECT_LIVE);
6688 REGISTER_CONSTANT(VIR_DOMAIN_AFFECT_CONFIG, AFFECT_CONFIG);
6689
6690
6691 REGISTER_CONSTANT(VIR_DOMAIN_JOB_NONE, JOB_NONE);
6692 REGISTER_CONSTANT(VIR_DOMAIN_JOB_BOUNDED, JOB_BOUNDED);
6693 REGISTER_CONSTANT(VIR_DOMAIN_JOB_UNBOUNDED, JOB_UNBOUNDED);
6694 REGISTER_CONSTANT(VIR_DOMAIN_JOB_COMPLETED, JOB_COMPLETED);
6695 REGISTER_CONSTANT(VIR_DOMAIN_JOB_FAILED, JOB_FAILED);
6696 REGISTER_CONSTANT(VIR_DOMAIN_JOB_CANCELLED, JOB_CANCELLED);
6697
6698 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_COMPRESSION_BYTES, JOB_COMPRESSION_BYTES);
6699 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_COMPRESSION_CACHE, JOB_COMPRESSION_CACHE);
6700 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_COMPRESSION_CACHE_MISSES, JOB_COMPRESSION_CACHE_MISSES);
6701 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_COMPRESSION_OVERFLOW, JOB_COMPRESSION_OVERFLOW);
6702 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_COMPRESSION_PAGES, JOB_COMPRESSION_PAGES);
6703 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_DATA_PROCESSED, JOB_DATA_PROCESSED);
6704 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_DATA_REMAINING, JOB_DATA_REMAINING);
6705 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_DATA_TOTAL, JOB_DATA_TOTAL);
6706 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_DISK_PROCESSED, JOB_DISK_PROCESSED);
6707 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_DISK_REMAINING, JOB_DISK_REMAINING);
6708 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_DISK_TOTAL, JOB_DISK_TOTAL);
6709 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_DOWNTIME, JOB_DOWNTIME);
6710 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_MEMORY_CONSTANT, JOB_MEMORY_CONSTANT);
6711 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_MEMORY_NORMAL, JOB_MEMORY_NORMAL);
6712 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_MEMORY_NORMAL_BYTES, JOB_MEMORY_NORMAL_BYTES);
6713 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_MEMORY_PROCESSED, JOB_MEMORY_PROCESSED);
6714 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_MEMORY_REMAINING, JOB_MEMORY_REMAINING);
6715 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_MEMORY_TOTAL, JOB_MEMORY_TOTAL);
6716 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_TIME_ELAPSED, JOB_TIME_ELAPSED);
6717 REGISTER_CONSTANT_STR(VIR_DOMAIN_JOB_TIME_REMAINING, JOB_TIME_REMAINING);
6718
6719 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN, BLOCK_JOB_TYPE_UNKNOWN);
6720 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_TYPE_PULL, BLOCK_JOB_TYPE_PULL);
6721 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_TYPE_COPY, BLOCK_JOB_TYPE_COPY);
6722 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT, BLOCK_JOB_TYPE_COMMIT);
6723
6724 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_COMPLETED, BLOCK_JOB_COMPLETED);
6725 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_FAILED, BLOCK_JOB_FAILED);
6726 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_CANCELED, BLOCK_JOB_CANCELED);
6727 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_READY, BLOCK_JOB_READY);
6728
6729 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_COMMIT_DELETE, BLOCK_COMMIT_DELETE);
6730 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW, BLOCK_COMMIT_SHALLOW);
6731
6732 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_LIFECYCLE, EVENT_ID_LIFECYCLE);
6733 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_REBOOT, EVENT_ID_REBOOT);
6734 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_RTC_CHANGE, EVENT_ID_RTC_CHANGE);
6735 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_WATCHDOG, EVENT_ID_WATCHDOG);
6736 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_IO_ERROR, EVENT_ID_IO_ERROR);
6737 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_GRAPHICS, EVENT_ID_GRAPHICS);
6738 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON, EVENT_ID_IO_ERROR_REASON);
6739 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_CONTROL_ERROR, EVENT_ID_CONTROL_ERROR);
6740 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_BLOCK_JOB, EVENT_ID_BLOCK_JOB);
6741 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_DISK_CHANGE, EVENT_ID_DISK_CHANGE);
6742 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_PMSUSPEND, EVENT_ID_PMSUSPEND);
6743 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK, EVENT_ID_PMSUSPEND_DISK);
6744 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_PMWAKEUP, EVENT_ID_PMWAKEUP);
6745 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_TRAY_CHANGE, EVENT_ID_TRAY_CHANGE);
6746 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE, EVENT_ID_BALLOON_CHANGE);
6747 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, EVENT_ID_DEVICE_REMOVED);
6748
6749 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_NONE, EVENT_WATCHDOG_NONE);
6750 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_PAUSE, EVENT_WATCHDOG_PAUSE);
6751 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_RESET, EVENT_WATCHDOG_RESET);
6752 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF, EVENT_WATCHDOG_POWEROFF);
6753 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN, EVENT_WATCHDOG_SHUTDOWN);
6754 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_DEBUG, EVENT_WATCHDOG_DEBUG);
6755
6756 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_IO_ERROR_NONE, EVENT_IO_ERROR_NONE);
6757 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_IO_ERROR_PAUSE, EVENT_IO_ERROR_PAUSE);
6758 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_IO_ERROR_REPORT, EVENT_IO_ERROR_REPORT);
6759
6760 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_GRAPHICS_CONNECT, EVENT_GRAPHICS_CONNECT);
6761 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE, EVENT_GRAPHICS_INITIALIZE);
6762 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT, EVENT_GRAPHICS_DISCONNECT);
6763
6764 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4, EVENT_GRAPHICS_ADDRESS_IPV4);
6765 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6, EVENT_GRAPHICS_ADDRESS_IPV6);
6766 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_UNIX, EVENT_GRAPHICS_ADDRESS_UNIX);
6767
6768 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START, EVENT_DISK_CHANGE_MISSING_ON_START);
6769
6770 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN, EVENT_TRAY_CHANGE_OPEN);
6771 REGISTER_CONSTANT(VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE, EVENT_TRAY_CHANGE_CLOSE);
6772
6773 REGISTER_CONSTANT_STR(VIR_DOMAIN_MEMORY_HARD_LIMIT, MEMORY_HARD_LIMIT);
6774 REGISTER_CONSTANT_STR(VIR_DOMAIN_MEMORY_SOFT_LIMIT, MEMORY_SOFT_LIMIT);
6775 REGISTER_CONSTANT_STR(VIR_DOMAIN_MEMORY_MIN_GUARANTEE, MEMORY_MIN_GUARANTEE);
6776 REGISTER_CONSTANT_STR(VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT, MEMORY_SWAP_HARD_LIMIT);
6777 REGISTER_CONSTANT_ULL(VIR_DOMAIN_MEMORY_PARAM_UNLIMITED, MEMORY_PARAM_UNLIMITED);
6778
6779 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLKIO_WEIGHT, BLKIO_WEIGHT);
6780 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLKIO_DEVICE_WEIGHT, BLKIO_DEVICE_WEIGHT);
6781
6782 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_CPU_SHARES, SCHEDULER_CPU_SHARES);
6783 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_VCPU_PERIOD, SCHEDULER_VCPU_PERIOD);
6784 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_VCPU_QUOTA, SCHEDULER_VCPU_QUOTA);
6785 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_WEIGHT, SCHEDULER_WEIGHT);
6786 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_CAP, SCHEDULER_CAP);
6787 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_LIMIT, SCHEDULER_LIMIT);
6788 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_RESERVATION, SCHEDULER_RESERVATION);
6789 REGISTER_CONSTANT_STR(VIR_DOMAIN_SCHEDULER_SHARES, SCHEDULER_SHARES);
6790
6791
6792 REGISTER_CONSTANT(VIR_DOMAIN_MEMORY_STAT_SWAP_IN, MEMORY_STAT_SWAP_IN);
6793 REGISTER_CONSTANT(VIR_DOMAIN_MEMORY_STAT_SWAP_OUT, MEMORY_STAT_SWAP_OUT);
6794 REGISTER_CONSTANT(VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT, MEMORY_STAT_MAJOR_FAULT);
6795 REGISTER_CONSTANT(VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT, MEMORY_STAT_MINOR_FAULT);
6796 REGISTER_CONSTANT(VIR_DOMAIN_MEMORY_STAT_UNUSED, MEMORY_STAT_UNUSED);
6797 REGISTER_CONSTANT(VIR_DOMAIN_MEMORY_STAT_AVAILABLE, MEMORY_STAT_AVAILABLE);
6798 REGISTER_CONSTANT(VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, MEMORY_STAT_ACTUAL_BALLOON);
6799 REGISTER_CONSTANT(VIR_DOMAIN_MEMORY_STAT_RSS, MEMORY_STAT_RSS);
6800
6801
6802 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC, BLOCK_IOTUNE_TOTAL_BYTES_SEC);
6803 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC, BLOCK_IOTUNE_READ_BYTES_SEC);
6804 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC, BLOCK_IOTUNE_WRITE_BYTES_SEC);
6805 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC, BLOCK_IOTUNE_TOTAL_IOPS_SEC);
6806 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC, BLOCK_IOTUNE_READ_IOPS_SEC);
6807 REGISTER_CONSTANT_STR(VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC, BLOCK_IOTUNE_WRITE_IOPS_SEC);
6808
6809
6810 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_RESIZE_BYTES, BLOCK_RESIZE_BYTES);
6811
6812
6813 REGISTER_CONSTANT_STR(VIR_DOMAIN_NUMA_NODESET, NUMA_NODESET);
6814 REGISTER_CONSTANT_STR(VIR_DOMAIN_NUMA_MODE, NUMA_MODE);
6815
6816 REGISTER_CONSTANT(VIR_DOMAIN_NUMATUNE_MEM_STRICT, NUMATUNE_MEM_STRICT);
6817 REGISTER_CONSTANT(VIR_DOMAIN_NUMATUNE_MEM_PREFERRED, NUMATUNE_MEM_PREFERRED);
6818 REGISTER_CONSTANT(VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE, NUMATUNE_MEM_INTERLEAVE);
6819
6820
6821 REGISTER_CONSTANT_STR(VIR_DOMAIN_BANDWIDTH_IN_AVERAGE, BANDWIDTH_IN_AVERAGE);
6822 REGISTER_CONSTANT_STR(VIR_DOMAIN_BANDWIDTH_IN_PEAK, BANDWIDTH_IN_PEAK);
6823 REGISTER_CONSTANT_STR(VIR_DOMAIN_BANDWIDTH_IN_BURST, BANDWIDTH_IN_BURST);
6824 REGISTER_CONSTANT_STR(VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE, BANDWIDTH_OUT_AVERAGE);
6825 REGISTER_CONSTANT_STR(VIR_DOMAIN_BANDWIDTH_OUT_PEAK, BANDWIDTH_OUT_PEAK);
6826 REGISTER_CONSTANT_STR(VIR_DOMAIN_BANDWIDTH_OUT_BURST, BANDWIDTH_OUT_BURST);
6827
6828
6829 REGISTER_CONSTANT(VIR_DOMAIN_VCPU_CURRENT, VCPU_CURRENT);
6830 REGISTER_CONSTANT(VIR_DOMAIN_VCPU_LIVE, VCPU_LIVE);
6831 REGISTER_CONSTANT(VIR_DOMAIN_VCPU_CONFIG, VCPU_CONFIG);
6832 REGISTER_CONSTANT(VIR_DOMAIN_VCPU_MAXIMUM, VCPU_MAXIMUM);
6833 REGISTER_CONSTANT(VIR_DOMAIN_VCPU_GUEST, VCPU_GUEST);
6834
6835
6836 REGISTER_CONSTANT(VIR_DOMAIN_SHUTDOWN_DEFAULT, SHUTDOWN_DEFAULT);
6837 REGISTER_CONSTANT(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN, SHUTDOWN_ACPI_POWER_BTN);
6838 REGISTER_CONSTANT(VIR_DOMAIN_SHUTDOWN_GUEST_AGENT, SHUTDOWN_GUEST_AGENT);
6839 REGISTER_CONSTANT(VIR_DOMAIN_SHUTDOWN_INITCTL, SHUTDOWN_INITCTL);
6840 REGISTER_CONSTANT(VIR_DOMAIN_SHUTDOWN_SIGNAL, SHUTDOWN_SIGNAL);
6841
6842
6843 REGISTER_CONSTANT(VIR_DOMAIN_REBOOT_DEFAULT, REBOOT_DEFAULT);
6844 REGISTER_CONSTANT(VIR_DOMAIN_REBOOT_ACPI_POWER_BTN, REBOOT_ACPI_POWER_BTN);
6845 REGISTER_CONSTANT(VIR_DOMAIN_REBOOT_GUEST_AGENT, REBOOT_GUEST_AGENT);
6846 REGISTER_CONSTANT(VIR_DOMAIN_REBOOT_INITCTL, REBOOT_INITCTL);
6847 REGISTER_CONSTANT(VIR_DOMAIN_REBOOT_SIGNAL, REBOOT_SIGNAL);
6848
6849 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_NOP, PROCESS_SIGNAL_NOP);
6850 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_HUP, PROCESS_SIGNAL_HUP);
6851 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_INT, PROCESS_SIGNAL_INT);
6852 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_QUIT, PROCESS_SIGNAL_QUIT);
6853 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_ILL, PROCESS_SIGNAL_ILL);
6854 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_TRAP, PROCESS_SIGNAL_TRAP);
6855 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_ABRT, PROCESS_SIGNAL_ABRT);
6856 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_BUS, PROCESS_SIGNAL_BUS);
6857 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_FPE, PROCESS_SIGNAL_FPE);
6858 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_KILL, PROCESS_SIGNAL_KILL);
6859
6860 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_USR1, PROCESS_SIGNAL_USR1);
6861 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_SEGV, PROCESS_SIGNAL_SEGV);
6862 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_USR2, PROCESS_SIGNAL_USR2);
6863 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_PIPE, PROCESS_SIGNAL_PIPE);
6864 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_ALRM, PROCESS_SIGNAL_ALRM);
6865 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_TERM, PROCESS_SIGNAL_TERM);
6866 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_STKFLT, PROCESS_SIGNAL_STKFLT);
6867 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_CHLD, PROCESS_SIGNAL_CHLD);
6868 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_CONT, PROCESS_SIGNAL_CONT);
6869 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_STOP, PROCESS_SIGNAL_STOP);
6870
6871 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_TSTP, PROCESS_SIGNAL_TSTP);
6872 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_TTIN, PROCESS_SIGNAL_TTIN);
6873 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_TTOU, PROCESS_SIGNAL_TTOU);
6874 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_URG, PROCESS_SIGNAL_URG);
6875 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_XCPU, PROCESS_SIGNAL_XCPU);
6876 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_XFSZ, PROCESS_SIGNAL_XFSZ);
6877 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_VTALRM, PROCESS_SIGNAL_VTALRM);
6878 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_PROF, PROCESS_SIGNAL_PROF);
6879 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_WINCH, PROCESS_SIGNAL_WINCH);
6880 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_POLL, PROCESS_SIGNAL_POLL);
6881
6882 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_PWR, PROCESS_SIGNAL_PWR);
6883 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_SYS, PROCESS_SIGNAL_SYS);
6884 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT0, PROCESS_SIGNAL_RT0);
6885 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT1, PROCESS_SIGNAL_RT1);
6886 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT2, PROCESS_SIGNAL_RT2);
6887 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT3, PROCESS_SIGNAL_RT3);
6888 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT4, PROCESS_SIGNAL_RT4);
6889 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT5, PROCESS_SIGNAL_RT5);
6890 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT6, PROCESS_SIGNAL_RT6);
6891 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT7, PROCESS_SIGNAL_RT7);
6892
6893 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT8, PROCESS_SIGNAL_RT8);
6894 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT9, PROCESS_SIGNAL_RT9);
6895 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT10, PROCESS_SIGNAL_RT10);
6896 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT11, PROCESS_SIGNAL_RT11);
6897 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT12, PROCESS_SIGNAL_RT12);
6898 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT13, PROCESS_SIGNAL_RT13);
6899 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT14, PROCESS_SIGNAL_RT14);
6900 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT15, PROCESS_SIGNAL_RT15);
6901 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT16, PROCESS_SIGNAL_RT16);
6902 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT17, PROCESS_SIGNAL_RT17);
6903
6904 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT18, PROCESS_SIGNAL_RT18);
6905 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT19, PROCESS_SIGNAL_RT19);
6906 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT20, PROCESS_SIGNAL_RT20);
6907 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT21, PROCESS_SIGNAL_RT21);
6908 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT22, PROCESS_SIGNAL_RT22);
6909 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT23, PROCESS_SIGNAL_RT23);
6910 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT24, PROCESS_SIGNAL_RT24);
6911 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT25, PROCESS_SIGNAL_RT25);
6912 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT26, PROCESS_SIGNAL_RT26);
6913 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT27, PROCESS_SIGNAL_RT27);
6914
6915 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT28, PROCESS_SIGNAL_RT28);
6916 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT29, PROCESS_SIGNAL_RT29);
6917 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT30, PROCESS_SIGNAL_RT30);
6918 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT31, PROCESS_SIGNAL_RT31);
6919 REGISTER_CONSTANT(VIR_DOMAIN_PROCESS_SIGNAL_RT32, PROCESS_SIGNAL_RT32);
6920
6921 REGISTER_CONSTANT(VIR_DOMAIN_DESTROY_DEFAULT, DESTROY_DEFAULT);
6922 REGISTER_CONSTANT(VIR_DOMAIN_DESTROY_GRACEFUL, DESTROY_GRACEFUL);
6923
6924
6925 REGISTER_CONSTANT(VIR_DOMAIN_METADATA_DESCRIPTION, METADATA_DESCRIPTION);
6926 REGISTER_CONSTANT(VIR_DOMAIN_METADATA_TITLE, METADATA_TITLE);
6927 REGISTER_CONSTANT(VIR_DOMAIN_METADATA_ELEMENT, METADATA_ELEMENT);
6928
6929 REGISTER_CONSTANT(VIR_DOMAIN_DISK_ERROR_NONE, DISK_ERROR_NONE);
6930 REGISTER_CONSTANT(VIR_DOMAIN_DISK_ERROR_NO_SPACE, DISK_ERROR_NO_SPACE);
6931 REGISTER_CONSTANT(VIR_DOMAIN_DISK_ERROR_UNSPEC, DISK_ERROR_UNSPEC);
6932
6933
6934 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC, BLOCK_JOB_ABORT_ASYNC);
6935 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT, BLOCK_JOB_ABORT_PIVOT);
6936
6937 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_REBASE_SHALLOW, BLOCK_REBASE_SHALLOW);
6938 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT, BLOCK_REBASE_REUSE_EXT);
6939 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_REBASE_COPY_RAW, BLOCK_REBASE_COPY_RAW);
6940 REGISTER_CONSTANT(VIR_DOMAIN_BLOCK_REBASE_COPY, BLOCK_REBASE_COPY);
6941
6942 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_ACTIVE, LIST_ACTIVE);
6943 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_AUTOSTART, LIST_AUTOSTART);
6944 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT, LIST_HAS_SNAPSHOT);
6945 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_INACTIVE, LIST_INACTIVE);
6946 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE, LIST_MANAGEDSAVE);
6947 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART, LIST_NO_AUTOSTART);
6948 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE, LIST_NO_MANAGEDSAVE);
6949 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT, LIST_NO_SNAPSHOT);
6950 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_OTHER, LIST_OTHER);
6951 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_PAUSED, LIST_PAUSED);
6952 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_PERSISTENT, LIST_PERSISTENT);
6953 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_RUNNING, LIST_RUNNING);
6954 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_SHUTOFF, LIST_SHUTOFF);
6955 REGISTER_CONSTANT(VIR_CONNECT_LIST_DOMAINS_TRANSIENT, LIST_TRANSIENT);
6956
6957 REGISTER_CONSTANT(VIR_DOMAIN_SEND_KEY_MAX_KEYS, SEND_KEY_MAX_KEYS);
6958
6959
6960 stash = gv_stashpv( "Sys::Virt::DomainSnapshot", TRUE );
6961 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, DELETE_CHILDREN);
6962 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, DELETE_METADATA_ONLY);
6963 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, DELETE_CHILDREN_ONLY);
6964
6965 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE, CREATE_REDEFINE);
6966 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT, CREATE_CURRENT);
6967 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, CREATE_NO_METADATA);
6968 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_HALT, CREATE_HALT);
6969 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY, CREATE_DISK_ONLY);
6970 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT, CREATE_REUSE_EXT);
6971 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE, CREATE_QUIESCE);
6972 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC, CREATE_ATOMIC);
6973 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_CREATE_LIVE, CREATE_LIVE);
6974
6975 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS, LIST_ROOTS);
6976 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS, LIST_DESCENDANTS);
6977 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_METADATA, LIST_METADATA);
6978 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, LIST_LEAVES);
6979 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES, LIST_NO_LEAVES);
6980 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA, LIST_NO_METADATA);
6981 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE, LIST_ACTIVE);
6982 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE, LIST_INACTIVE);
6983 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL, LIST_EXTERNAL);
6984 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL, LIST_INTERNAL);
6985 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY, LIST_DISK_ONLY);
6986
6987
6988 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING, REVERT_RUNNING);
6989 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED, REVERT_PAUSED);
6990 REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_REVERT_FORCE, REVERT_FORCE);
6991
6992 stash = gv_stashpv( "Sys::Virt::StoragePool", TRUE );
6993 REGISTER_CONSTANT(VIR_STORAGE_POOL_INACTIVE, STATE_INACTIVE);
6994 REGISTER_CONSTANT(VIR_STORAGE_POOL_BUILDING, STATE_BUILDING);
6995 REGISTER_CONSTANT(VIR_STORAGE_POOL_RUNNING, STATE_RUNNING);
6996 REGISTER_CONSTANT(VIR_STORAGE_POOL_DEGRADED, STATE_DEGRADED);
6997 REGISTER_CONSTANT(VIR_STORAGE_POOL_INACCESSIBLE, STATE_INACCESSIBLE);
6998
6999 REGISTER_CONSTANT(VIR_STORAGE_POOL_BUILD_NEW, BUILD_NEW);
7000 REGISTER_CONSTANT(VIR_STORAGE_POOL_BUILD_REPAIR, BUILD_REPAIR);
7001 REGISTER_CONSTANT(VIR_STORAGE_POOL_BUILD_RESIZE, BUILD_RESIZE);
7002 REGISTER_CONSTANT(VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, BUILD_NO_OVERWRITE);
7003 REGISTER_CONSTANT(VIR_STORAGE_POOL_BUILD_OVERWRITE, BUILD_OVERWRITE);
7004
7005 REGISTER_CONSTANT(VIR_STORAGE_POOL_DELETE_NORMAL, DELETE_NORMAL);
7006 REGISTER_CONSTANT(VIR_STORAGE_POOL_DELETE_ZEROED, DELETE_ZEROED);
7007
7008 REGISTER_CONSTANT(VIR_STORAGE_XML_INACTIVE, XML_INACTIVE);
7009
7010
7011 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE, LIST_INACTIVE);
7012 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE, LIST_ACTIVE);
7013 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT, LIST_PERSISTENT);
7014 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT, LIST_TRANSIENT);
7015 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART, LIST_AUTOSTART);
7016 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_NO_AUTOSTART, LIST_NO_AUTOSTART);
7017
7018 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_DIR, LIST_DIR);
7019 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_FS, LIST_FS);
7020 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_NETFS, LIST_NETFS);
7021 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_LOGICAL, LIST_LOGICAL);
7022 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_DISK, LIST_DISK);
7023 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI, LIST_ISCSI);
7024 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_SCSI, LIST_SCSI);
7025 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_MPATH, LIST_MPATH);
7026 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_RBD, LIST_RBD);
7027 REGISTER_CONSTANT(VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG, LIST_SHEEPDOG);
7028
7029 stash = gv_stashpv( "Sys::Virt::Network", TRUE );
7030 REGISTER_CONSTANT(VIR_NETWORK_XML_INACTIVE, XML_INACTIVE);
7031
7032 REGISTER_CONSTANT(VIR_NETWORK_UPDATE_COMMAND_NONE, UPDATE_COMMAND_NONE);
7033 REGISTER_CONSTANT(VIR_NETWORK_UPDATE_COMMAND_MODIFY, UPDATE_COMMAND_MODIFY);
7034 REGISTER_CONSTANT(VIR_NETWORK_UPDATE_COMMAND_DELETE, UPDATE_COMMAND_DELETE);
7035 REGISTER_CONSTANT(VIR_NETWORK_UPDATE_COMMAND_ADD_LAST, UPDATE_COMMAND_ADD_LAST);
7036 REGISTER_CONSTANT(VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST, UPDATE_COMMAND_ADD_FIRST);
7037
7038 REGISTER_CONSTANT(VIR_NETWORK_SECTION_NONE, SECTION_NONE);
7039 REGISTER_CONSTANT(VIR_NETWORK_SECTION_BRIDGE, SECTION_BRIDGE);
7040 REGISTER_CONSTANT(VIR_NETWORK_SECTION_DOMAIN, SECTION_DOMAIN);
7041 REGISTER_CONSTANT(VIR_NETWORK_SECTION_IP, SECTION_IP);
7042 REGISTER_CONSTANT(VIR_NETWORK_SECTION_IP_DHCP_HOST, SECTION_IP_DHCP_HOST);
7043 REGISTER_CONSTANT(VIR_NETWORK_SECTION_IP_DHCP_RANGE, SECTION_IP_DHCP_RANGE);
7044 REGISTER_CONSTANT(VIR_NETWORK_SECTION_FORWARD, SECTION_FORWARD);
7045 REGISTER_CONSTANT(VIR_NETWORK_SECTION_FORWARD_INTERFACE, SECTION_FORWARD_INTERFACE);
7046 REGISTER_CONSTANT(VIR_NETWORK_SECTION_FORWARD_PF, SECTION_FORWARD_PF);
7047 REGISTER_CONSTANT(VIR_NETWORK_SECTION_PORTGROUP, SECTION_PORTGROUP);
7048 REGISTER_CONSTANT(VIR_NETWORK_SECTION_DNS_HOST, SECTION_DNS_HOST);
7049 REGISTER_CONSTANT(VIR_NETWORK_SECTION_DNS_TXT, SECTION_DNS_TXT);
7050 REGISTER_CONSTANT(VIR_NETWORK_SECTION_DNS_SRV, SECTION_DNS_SRV);
7051
7052 REGISTER_CONSTANT(VIR_NETWORK_UPDATE_AFFECT_CURRENT, UPDATE_AFFECT_CURRENT);
7053 REGISTER_CONSTANT(VIR_NETWORK_UPDATE_AFFECT_LIVE, UPDATE_AFFECT_LIVE);
7054 REGISTER_CONSTANT(VIR_NETWORK_UPDATE_AFFECT_CONFIG, UPDATE_AFFECT_CONFIG);
7055
7056 REGISTER_CONSTANT(VIR_CONNECT_LIST_NETWORKS_ACTIVE, LIST_ACTIVE);
7057 REGISTER_CONSTANT(VIR_CONNECT_LIST_NETWORKS_INACTIVE, LIST_INACTIVE);
7058 REGISTER_CONSTANT(VIR_CONNECT_LIST_NETWORKS_AUTOSTART, LIST_AUTOSTART);
7059 REGISTER_CONSTANT(VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART, LIST_NO_AUTOSTART);
7060 REGISTER_CONSTANT(VIR_CONNECT_LIST_NETWORKS_PERSISTENT, LIST_PERSISTENT);
7061 REGISTER_CONSTANT(VIR_CONNECT_LIST_NETWORKS_TRANSIENT, LIST_TRANSIENT);
7062
7063 stash = gv_stashpv( "Sys::Virt::Interface", TRUE );
7064 REGISTER_CONSTANT(VIR_INTERFACE_XML_INACTIVE, XML_INACTIVE);
7065
7066 REGISTER_CONSTANT(VIR_CONNECT_LIST_INTERFACES_ACTIVE, LIST_ACTIVE);
7067 REGISTER_CONSTANT(VIR_CONNECT_LIST_INTERFACES_INACTIVE, LIST_INACTIVE);
7068
7069
7070 stash = gv_stashpv( "Sys::Virt::NodeDevice", TRUE );
7071
7072 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM, LIST_CAP_SYSTEM);
7073 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV, LIST_CAP_PCI_DEV);
7074 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV, LIST_CAP_USB_DEV);
7075 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE, LIST_CAP_USB_INTERFACE);
7076 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET, LIST_CAP_NET);
7077 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST, LIST_CAP_SCSI_HOST);
7078 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET, LIST_CAP_SCSI_TARGET);
7079 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI, LIST_CAP_SCSI);
7080 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE, LIST_CAP_STORAGE);
7081 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST, LIST_CAP_FC_HOST);
7082 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS, LIST_CAP_VPORTS);
7083 REGISTER_CONSTANT(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC, LIST_CAP_SCSI_GENERIC);
7084
7085
7086 stash = gv_stashpv( "Sys::Virt::StorageVol", TRUE );
7087 REGISTER_CONSTANT(VIR_STORAGE_VOL_FILE, TYPE_FILE);
7088 REGISTER_CONSTANT(VIR_STORAGE_VOL_BLOCK, TYPE_BLOCK);
7089 REGISTER_CONSTANT(VIR_STORAGE_VOL_DIR, TYPE_DIR);
7090 REGISTER_CONSTANT(VIR_STORAGE_VOL_NETWORK, TYPE_NETWORK);
7091
7092 REGISTER_CONSTANT(VIR_STORAGE_VOL_DELETE_NORMAL, DELETE_NORMAL);
7093 REGISTER_CONSTANT(VIR_STORAGE_VOL_DELETE_ZEROED, DELETE_ZEROED);
7094
7095
7096 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_ZERO, WIPE_ALG_ZERO);
7097 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_NNSA, WIPE_ALG_NNSA);
7098 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_DOD, WIPE_ALG_DOD);
7099 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_BSI, WIPE_ALG_BSI);
7100 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_GUTMANN, WIPE_ALG_GUTMANN);
7101 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_SCHNEIER, WIPE_ALG_SCHNEIER);
7102 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_PFITZNER7, WIPE_ALG_PFITZNER7);
7103 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_PFITZNER33, WIPE_ALG_PFITZNER33);
7104 REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_RANDOM, WIPE_ALG_RANDOM);
7105
7106 REGISTER_CONSTANT(VIR_STORAGE_VOL_RESIZE_ALLOCATE, RESIZE_ALLOCATE);
7107 REGISTER_CONSTANT(VIR_STORAGE_VOL_RESIZE_DELTA, RESIZE_DELTA);
7108 REGISTER_CONSTANT(VIR_STORAGE_VOL_RESIZE_SHRINK, RESIZE_SHRINK);
7109
7110 REGISTER_CONSTANT(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, CREATE_PREALLOC_METADATA);
7111
7112
7113 stash = gv_stashpv( "Sys::Virt::Secret", TRUE );
7114 REGISTER_CONSTANT(VIR_SECRET_USAGE_TYPE_NONE, USAGE_TYPE_NONE);
7115 REGISTER_CONSTANT(VIR_SECRET_USAGE_TYPE_VOLUME, USAGE_TYPE_VOLUME);
7116 REGISTER_CONSTANT(VIR_SECRET_USAGE_TYPE_CEPH, USAGE_TYPE_CEPH);
7117 REGISTER_CONSTANT(VIR_SECRET_USAGE_TYPE_ISCSI, USAGE_TYPE_ISCSI);
7118
7119
7120 REGISTER_CONSTANT(VIR_CONNECT_LIST_SECRETS_EPHEMERAL, LIST_EPHEMERAL);
7121 REGISTER_CONSTANT(VIR_CONNECT_LIST_SECRETS_NO_EPHEMERAL, LIST_NO_EPHEMERAL);
7122 REGISTER_CONSTANT(VIR_CONNECT_LIST_SECRETS_PRIVATE, LIST_PRIVATE);
7123 REGISTER_CONSTANT(VIR_CONNECT_LIST_SECRETS_NO_PRIVATE, LIST_NO_PRIVATE);
7124
7125
7126 stash = gv_stashpv( "Sys::Virt::Stream", TRUE );
7127 REGISTER_CONSTANT(VIR_STREAM_NONBLOCK, NONBLOCK);
7128
7129 REGISTER_CONSTANT(VIR_STREAM_EVENT_READABLE, EVENT_READABLE);
7130 REGISTER_CONSTANT(VIR_STREAM_EVENT_WRITABLE, EVENT_WRITABLE);
7131 REGISTER_CONSTANT(VIR_STREAM_EVENT_ERROR, EVENT_ERROR);
7132 REGISTER_CONSTANT(VIR_STREAM_EVENT_HANGUP, EVENT_HANGUP);
7133
7134
7135
7136 stash = gv_stashpv( "Sys::Virt::Error", TRUE );
7137
7138 REGISTER_CONSTANT(VIR_ERR_NONE, LEVEL_NONE);
7139 REGISTER_CONSTANT(VIR_ERR_WARNING, LEVEL_WARNING);
7140 REGISTER_CONSTANT(VIR_ERR_ERROR, LEVEL_ERROR);
7141
7142 REGISTER_CONSTANT(VIR_FROM_NONE, FROM_NONE);
7143 REGISTER_CONSTANT(VIR_FROM_XEN, FROM_XEN);
7144 REGISTER_CONSTANT(VIR_FROM_XEND, FROM_XEND);
7145 REGISTER_CONSTANT(VIR_FROM_XENSTORE, FROM_XENSTORE);
7146 REGISTER_CONSTANT(VIR_FROM_SEXPR, FROM_SEXPR);
7147 REGISTER_CONSTANT(VIR_FROM_XML, FROM_XML);
7148 REGISTER_CONSTANT(VIR_FROM_DOM, FROM_DOM);
7149 REGISTER_CONSTANT(VIR_FROM_RPC, FROM_RPC);
7150 REGISTER_CONSTANT(VIR_FROM_PROXY, FROM_PROXY);
7151 REGISTER_CONSTANT(VIR_FROM_CONF, FROM_CONF);
7152 REGISTER_CONSTANT(VIR_FROM_QEMU, FROM_QEMU);
7153 REGISTER_CONSTANT(VIR_FROM_NET, FROM_NET);
7154 REGISTER_CONSTANT(VIR_FROM_TEST, FROM_TEST);
7155 REGISTER_CONSTANT(VIR_FROM_REMOTE, FROM_REMOTE);
7156 REGISTER_CONSTANT(VIR_FROM_OPENVZ, FROM_OPENVZ);
7157 REGISTER_CONSTANT(VIR_FROM_XENXM, FROM_XENXM);
7158 REGISTER_CONSTANT(VIR_FROM_STATS_LINUX, FROM_STATS_LINUX);
7159 REGISTER_CONSTANT(VIR_FROM_LXC, FROM_LXC);
7160 REGISTER_CONSTANT(VIR_FROM_STORAGE, FROM_STORAGE);
7161 REGISTER_CONSTANT(VIR_FROM_NETWORK, FROM_NETWORK);
7162 REGISTER_CONSTANT(VIR_FROM_DOMAIN, FROM_DOMAIN);
7163 REGISTER_CONSTANT(VIR_FROM_UML, FROM_UML);
7164 REGISTER_CONSTANT(VIR_FROM_NODEDEV, FROM_NODEDEV);
7165 REGISTER_CONSTANT(VIR_FROM_XEN_INOTIFY, FROM_XEN_INOTIFY);
7166 REGISTER_CONSTANT(VIR_FROM_SECURITY, FROM_SECURITY);
7167 REGISTER_CONSTANT(VIR_FROM_VBOX, FROM_VBOX);
7168 REGISTER_CONSTANT(VIR_FROM_INTERFACE, FROM_INTERFACE);
7169 REGISTER_CONSTANT(VIR_FROM_ONE, FROM_ONE);
7170 REGISTER_CONSTANT(VIR_FROM_ESX, FROM_ESX);
7171 REGISTER_CONSTANT(VIR_FROM_PHYP, FROM_PHYP);
7172 REGISTER_CONSTANT(VIR_FROM_SECRET, FROM_SECRET);
7173 REGISTER_CONSTANT(VIR_FROM_CPU, FROM_CPU);
7174 REGISTER_CONSTANT(VIR_FROM_XENAPI, FROM_XENAPI);
7175 REGISTER_CONSTANT(VIR_FROM_NWFILTER, FROM_NWFILTER);
7176 REGISTER_CONSTANT(VIR_FROM_HOOK, FROM_HOOK);
7177 REGISTER_CONSTANT(VIR_FROM_DOMAIN_SNAPSHOT, FROM_DOMAIN_SNAPSHOT);
7178 REGISTER_CONSTANT(VIR_FROM_AUDIT, FROM_AUDIT);
7179 REGISTER_CONSTANT(VIR_FROM_SYSINFO, FROM_SYSINFO);
7180 REGISTER_CONSTANT(VIR_FROM_STREAMS, FROM_STREAMS);
7181 REGISTER_CONSTANT(VIR_FROM_VMWARE, FROM_VMWARE);
7182 REGISTER_CONSTANT(VIR_FROM_EVENT, FROM_EVENT);
7183 REGISTER_CONSTANT(VIR_FROM_LIBXL, FROM_LIBXL);
7184 REGISTER_CONSTANT(VIR_FROM_LOCKING, FROM_LOCKING);
7185 REGISTER_CONSTANT(VIR_FROM_HYPERV, FROM_HYPERV);
7186 REGISTER_CONSTANT(VIR_FROM_CAPABILITIES, FROM_CAPABILITIES);
7187 REGISTER_CONSTANT(VIR_FROM_AUTH, FROM_AUTH);
7188 REGISTER_CONSTANT(VIR_FROM_URI, FROM_URI);
7189 REGISTER_CONSTANT(VIR_FROM_DBUS, FROM_DBUS);
7190 REGISTER_CONSTANT(VIR_FROM_DEVICE, FROM_DEVICE);
7191 REGISTER_CONSTANT(VIR_FROM_PARALLELS, FROM_PARALLELS);
7192 REGISTER_CONSTANT(VIR_FROM_SSH, FROM_SSH);
7193 REGISTER_CONSTANT(VIR_FROM_LOCKSPACE, FROM_LOCKSPACE);
7194 REGISTER_CONSTANT(VIR_FROM_INITCTL, FROM_INITCTL);
7195 REGISTER_CONSTANT(VIR_FROM_CGROUP, FROM_CGROUP);
7196 REGISTER_CONSTANT(VIR_FROM_IDENTITY, FROM_IDENTITY);
7197 REGISTER_CONSTANT(VIR_FROM_ACCESS, FROM_ACCESS);
7198 REGISTER_CONSTANT(VIR_FROM_SYSTEMD, FROM_SYSTEMD);
7199
7200
7201 REGISTER_CONSTANT(VIR_ERR_OK, ERR_OK);
7202 REGISTER_CONSTANT(VIR_ERR_INTERNAL_ERROR, ERR_INTERNAL_ERROR);
7203 REGISTER_CONSTANT(VIR_ERR_NO_MEMORY, ERR_NO_MEMORY);
7204 REGISTER_CONSTANT(VIR_ERR_NO_SUPPORT, ERR_NO_SUPPORT);
7205 REGISTER_CONSTANT(VIR_ERR_UNKNOWN_HOST, ERR_UNKNOWN_HOST);
7206 REGISTER_CONSTANT(VIR_ERR_NO_CONNECT, ERR_NO_CONNECT);
7207 REGISTER_CONSTANT(VIR_ERR_INVALID_CONN, ERR_INVALID_CONN);
7208 REGISTER_CONSTANT(VIR_ERR_INVALID_DOMAIN, ERR_INVALID_DOMAIN);
7209 REGISTER_CONSTANT(VIR_ERR_INVALID_ARG, ERR_INVALID_ARG);
7210 REGISTER_CONSTANT(VIR_ERR_OPERATION_FAILED, ERR_OPERATION_FAILED);
7211 REGISTER_CONSTANT(VIR_ERR_GET_FAILED, ERR_GET_FAILED);
7212 REGISTER_CONSTANT(VIR_ERR_POST_FAILED, ERR_POST_FAILED);
7213 REGISTER_CONSTANT(VIR_ERR_HTTP_ERROR, ERR_HTTP_ERROR);
7214 REGISTER_CONSTANT(VIR_ERR_SEXPR_SERIAL, ERR_SEXPR_SERIAL);
7215 REGISTER_CONSTANT(VIR_ERR_NO_XEN, ERR_NO_XEN);
7216 REGISTER_CONSTANT(VIR_ERR_XEN_CALL, ERR_XEN_CALL);
7217 REGISTER_CONSTANT(VIR_ERR_OS_TYPE, ERR_OS_TYPE);
7218 REGISTER_CONSTANT(VIR_ERR_NO_KERNEL, ERR_NO_KERNEL);
7219 REGISTER_CONSTANT(VIR_ERR_NO_ROOT, ERR_NO_ROOT);
7220 REGISTER_CONSTANT(VIR_ERR_NO_SOURCE, ERR_NO_SOURCE);
7221 REGISTER_CONSTANT(VIR_ERR_NO_TARGET, ERR_NO_TARGET);
7222 REGISTER_CONSTANT(VIR_ERR_NO_NAME, ERR_NO_NAME);
7223 REGISTER_CONSTANT(VIR_ERR_NO_OS, ERR_NO_OS);
7224 REGISTER_CONSTANT(VIR_ERR_NO_DEVICE, ERR_NO_DEVICE);
7225 REGISTER_CONSTANT(VIR_ERR_NO_XENSTORE, ERR_NO_XENSTORE);
7226 REGISTER_CONSTANT(VIR_ERR_DRIVER_FULL, ERR_DRIVER_FULL);
7227 REGISTER_CONSTANT(VIR_ERR_CALL_FAILED, ERR_CALL_FAILED);
7228 REGISTER_CONSTANT(VIR_ERR_XML_ERROR, ERR_XML_ERROR);
7229 REGISTER_CONSTANT(VIR_ERR_DOM_EXIST, ERR_DOM_EXIST);
7230 REGISTER_CONSTANT(VIR_ERR_OPERATION_DENIED, ERR_OPERATIONED_DENIED);
7231 REGISTER_CONSTANT(VIR_ERR_OPEN_FAILED, ERR_OPEN_FAILED);
7232 REGISTER_CONSTANT(VIR_ERR_READ_FAILED, ERR_READ_FAILED);
7233 REGISTER_CONSTANT(VIR_ERR_PARSE_FAILED, ERR_PARSE_FAILED);
7234 REGISTER_CONSTANT(VIR_ERR_CONF_SYNTAX, ERR_CONF_SYNTAX);
7235 REGISTER_CONSTANT(VIR_ERR_WRITE_FAILED, ERR_WRITE_FAILED);
7236 REGISTER_CONSTANT(VIR_ERR_XML_DETAIL, ERR_XML_DETAIL);
7237 REGISTER_CONSTANT(VIR_ERR_INVALID_NETWORK, ERR_INVALID_NETWORK);
7238 REGISTER_CONSTANT(VIR_ERR_NETWORK_EXIST, ERR_NETWORK_EXIST);
7239 REGISTER_CONSTANT(VIR_ERR_SYSTEM_ERROR, ERR_SYSTEM_ERROR);
7240 REGISTER_CONSTANT(VIR_ERR_RPC, ERR_RPC);
7241 REGISTER_CONSTANT(VIR_ERR_GNUTLS_ERROR, ERR_GNUTLS_ERROR);
7242 REGISTER_CONSTANT(VIR_WAR_NO_NETWORK, WAR_NO_NETWORK);
7243 REGISTER_CONSTANT(VIR_ERR_NO_DOMAIN, ERR_NO_DOMAIN);
7244 REGISTER_CONSTANT(VIR_ERR_NO_NETWORK, ERR_NO_NETWORK);
7245 REGISTER_CONSTANT(VIR_ERR_INVALID_MAC, ERR_INVALID_MAC);
7246 REGISTER_CONSTANT(VIR_ERR_AUTH_FAILED, ERR_AUTH_FAILED);
7247 REGISTER_CONSTANT(VIR_ERR_INVALID_STORAGE_POOL, ERR_INVALID_STORAGE_POOL);
7248 REGISTER_CONSTANT(VIR_ERR_INVALID_STORAGE_VOL, ERR_INVALID_STORAGE_VOL);
7249 REGISTER_CONSTANT(VIR_WAR_NO_STORAGE, WAR_NO_STORAGE);
7250 REGISTER_CONSTANT(VIR_ERR_NO_STORAGE_POOL, ERR_NO_STORAGE_POOL);
7251 REGISTER_CONSTANT(VIR_ERR_NO_STORAGE_VOL, ERR_NO_STORAGE_VOL);
7252 REGISTER_CONSTANT(VIR_WAR_NO_NODE, WAR_NO_NODE);
7253 REGISTER_CONSTANT(VIR_ERR_INVALID_NODE_DEVICE, ERR_INVALID_NODE_DEVICE);
7254 REGISTER_CONSTANT(VIR_ERR_NO_NODE_DEVICE, ERR_NO_NODE_DEVICE);
7255 REGISTER_CONSTANT(VIR_ERR_NO_SECURITY_MODEL, ERR_NO_SECURITY_MODEL);
7256 REGISTER_CONSTANT(VIR_ERR_OPERATION_INVALID, ERR_OPERATION_INVALID);
7257 REGISTER_CONSTANT(VIR_WAR_NO_INTERFACE, WAR_NO_INTERFACE);
7258 REGISTER_CONSTANT(VIR_ERR_NO_INTERFACE, ERR_NO_INTERFACE);
7259 REGISTER_CONSTANT(VIR_ERR_INVALID_INTERFACE, ERR_INVALID_INTERFACE);
7260 REGISTER_CONSTANT(VIR_ERR_MULTIPLE_INTERFACES, ERR_MULTIPLE_INTERFACES);
7261 REGISTER_CONSTANT(VIR_WAR_NO_NWFILTER, WAR_NO_NWFILTER);
7262 REGISTER_CONSTANT(VIR_ERR_INVALID_NWFILTER, ERR_INVALID_NWFILTER);
7263 REGISTER_CONSTANT(VIR_ERR_NO_NWFILTER, ERR_NO_NWFILTER);
7264 REGISTER_CONSTANT(VIR_ERR_BUILD_FIREWALL, ERR_BUILD_FIREWALL);
7265 REGISTER_CONSTANT(VIR_WAR_NO_SECRET, WAR_NO_SECRET);
7266 REGISTER_CONSTANT(VIR_ERR_INVALID_SECRET, ERR_INVALID_SECRET);
7267 REGISTER_CONSTANT(VIR_ERR_NO_SECRET, ERR_NO_SECRET);
7268 REGISTER_CONSTANT(VIR_ERR_CONFIG_UNSUPPORTED, ERR_CONFIG_UNSUPPORTED);
7269 REGISTER_CONSTANT(VIR_ERR_OPERATION_TIMEOUT, ERR_OPERATION_TIMEOUT);
7270 REGISTER_CONSTANT(VIR_ERR_MIGRATE_PERSIST_FAILED, ERR_MIGRATE_PERSIST_FAILED);
7271 REGISTER_CONSTANT(VIR_ERR_HOOK_SCRIPT_FAILED, ERR_HOOK_SCRIPT_FAILED);
7272 REGISTER_CONSTANT(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, ERR_INVALID_DOMAIN_SNAPSHOT);
7273 REGISTER_CONSTANT(VIR_ERR_NO_DOMAIN_SNAPSHOT, ERR_NO_DOMAIN_SNAPSHOT);
7274 REGISTER_CONSTANT(VIR_ERR_INVALID_STREAM, ERR_INVALID_STREAM);
7275 REGISTER_CONSTANT(VIR_ERR_ARGUMENT_UNSUPPORTED, ERR_ARGUMENT_UNSUPPORTED);
7276 REGISTER_CONSTANT(VIR_ERR_STORAGE_PROBE_FAILED, ERR_STORAGE_PROBE_FAILED);
7277 REGISTER_CONSTANT(VIR_ERR_STORAGE_POOL_BUILT, ERR_STORAGE_POOL_BUILT);
7278 REGISTER_CONSTANT(VIR_ERR_SNAPSHOT_REVERT_RISKY, ERR_SNAPSHOT_REVERT_RISKY);
7279 REGISTER_CONSTANT(VIR_ERR_OPERATION_ABORTED, ERR_OPERATION_ABORTED);
7280 REGISTER_CONSTANT(VIR_ERR_AUTH_CANCELLED, ERR_AUTH_CANCELLED);
7281 REGISTER_CONSTANT(VIR_ERR_NO_DOMAIN_METADATA, ERR_NO_DOMAIN_METADATA);
7282 REGISTER_CONSTANT(VIR_ERR_MIGRATE_UNSAFE, ERR_MIGRATE_UNSAFE);
7283 REGISTER_CONSTANT(VIR_ERR_OVERFLOW, ERR_OVERFLOW);
7284 REGISTER_CONSTANT(VIR_ERR_BLOCK_COPY_ACTIVE, ERR_BLOCK_COPY_ACTIVE);
7285 REGISTER_CONSTANT(VIR_ERR_AGENT_UNRESPONSIVE, ERR_AGENT_UNRESPONSIVE);
7286 REGISTER_CONSTANT(VIR_ERR_OPERATION_UNSUPPORTED, ERR_OPERATION_UNSUPPORTED);
7287 REGISTER_CONSTANT(VIR_ERR_SSH, ERR_SSH);
7288 REGISTER_CONSTANT(VIR_ERR_RESOURCE_BUSY, ERR_RESOURCE_BUSY);
7289 REGISTER_CONSTANT(VIR_ERR_ACCESS_DENIED, ERR_ACCESS_DENIED);
7290 REGISTER_CONSTANT(VIR_ERR_DBUS_SERVICE, ERR_DBUS_SERVICE);
7291 }
7292