Debian Codegraph @

lib/Sys/Virt/Error.pm

raw
1 # -*- perl -*-
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 =pod
21
22 =head1 NAME
23
24 Sys::Virt::Error - Error object for libvirt APIs
25
26 =head1 DESCRIPTION
27
28 The C<Sys::Virt::Error> class provides an encoding of the
29 libvirt errors. Instances of this object can be thrown by
30 pretty much any of the Sys::Virt APIs.
31
32 =head1 METHODS
33
34 =over 4
35
36 =cut
37
38 package Sys::Virt::Error;
39
40 use strict;
41 use warnings;
42 use overload ('""' => 'stringify');
43
44 =item $err->stringify
45
46 Convert the object into string format suitable for printing on a
47 console to inform a user of the error.
48
49 =cut
50
51 sub stringify {
52 my $self = shift;
53
54 return "libvirt error code: " . $self->{code} . ", message: " . $self->{message} . ($self->{message} =~ /\n$/ ? "" : "\n");
55 }
56
57 =item my $level = $err->level
58
59 Return the raw error level represented by this error. One of the
60 ERROR LEVEL CONSTANTS
61
62 =cut
63
64 sub level {
65 my $self = shift;
66 return $self->{code}
67 }
68
69 =item my $code = $err->code
70
71 Return the raw error code represented by this error. One of the
72 ERROR CODE CONSTANTS
73
74 =cut
75
76 sub code {
77 my $self = shift;
78 return $self->{code}
79 }
80
81 =item my $from = $err->domain
82
83 Return the error domain raising this error. One of the ERROR
84 DOMAIN CONSTANTS
85
86 =cut
87
88 sub domain {
89 my $self = shift;
90 return $self->{domain}
91 }
92
93 =item my $msg = $err->message
94
95 Return an informative message describing the error condition.
96
97 =cut
98
99 sub message {
100 my $self = shift;
101 return $self->{message}
102 }
103
104
105 1;
106
107 =back
108
109 =head1 CONSTANTS
110
111 =head2 ERROR LEVEL CONSTANTS
112
113 =over 4
114
115 =item Sys::Virt::Error::LEVEL_NONE
116
117 Undefined error level
118
119 =item Sys::Virt::Error::LEVEL_WARNING
120
121 Warning error level
122
123 =item Sys::Virt::Error::LEVEL_ERROR
124
125 Fatal error level
126
127 =back
128
129 =head2 ERROR DOMAIN CONSTANTS
130
131 The error domain indicates which internal part of libvirt the error
132 report was raised from.
133
134 =over 4
135
136 =item Sys::Virt::Error::FROM_CONF
137
138 Configuration file handling
139
140 =item Sys::Virt::Error::FROM_DOM
141
142 Error while operating on a domain
143
144 =item Sys::Virt::Error::FROM_DOMAIN
145
146 Domain configuration handling
147
148 =item Sys::Virt::Error::FROM_LXC
149
150 LXC virtualization driver
151
152 =item Sys::Virt::Error::FROM_NET
153
154 Error while operating on a network
155
156 =item Sys::Virt::Error::FROM_NETWORK
157
158 Network configuration handling
159
160 =item Sys::Virt::Error::FROM_NODEDEV
161
162 Node device configuration handling
163
164 =item Sys::Virt::Error::FROM_NONE
165
166 No specific error domain.
167
168 =item Sys::Virt::Error::FROM_OPENVZ
169
170 OpenVZ virtualization driver
171
172 =item Sys::Virt::Error::FROM_PROXY
173
174 Xen proxy virtualization driver
175
176 =item Sys::Virt::Error::FROM_QEMU
177
178 QEMU virtualization driver
179
180 =item Sys::Virt::Error::FROM_REMOTE
181
182 Remote client virtualization driver
183
184 =item Sys::Virt::Error::FROM_RPC
185
186 XML-RPC handling code
187
188 =item Sys::Virt::Error::FROM_SECURITY
189
190 Security services driver
191
192 =item Sys::Virt::Error::FROM_SEXPR
193
194 SEXPR parsing code
195
196 =item Sys::Virt::Error::FROM_STATS_LINUX
197
198 Device statistics code
199
200 =item Sys::Virt::Error::FROM_STORAGE
201
202 Storage configuration handling
203
204 =item Sys::Virt::Error::FROM_TEST
205
206 Test virtualization driver
207
208 =item Sys::Virt::Error::FROM_UML
209
210 UML virtualization driver
211
212 =item Sys::Virt::Error::FROM_XEN
213
214 Xen hypervisor driver
215
216 =item Sys::Virt::Error::FROM_XEND
217
218 XenD daemon driver
219
220 =item Sys::Virt::Error::FROM_XENSTORE
221
222 XenStore driver
223
224 =item Sys::Virt::Error::FROM_XENXM
225
226 Xen XM configuration file driver
227
228 =item Sys::Virt::Error::FROM_XEN_INOTIFY
229
230 Xen Inotify events driver
231
232 =item Sys::Virt::Error::FROM_XML
233
234 Low level XML parser
235
236 =item Sys::Virt::Error::FROM_ESX
237
238 The VMWare ESX driver
239
240 =item Sys::Virt::Error::FROM_INTERFACE
241
242 The host network interface driver
243
244 =item Sys::Virt::Error::FROM_ONE
245
246 The Open Nebula driver. This constant is no longer
247 used and retained only for backwards compatibility
248
249 =item Sys::Virt::Error::FROM_PHYP
250
251 The IBM Power Hypervisor driver
252
253 =item Sys::Virt::Error::FROM_SECRET
254
255 The secret management driver
256
257 =item Sys::Virt::Error::FROM_VBOX
258
259 The VirtualBox driver
260
261 =item Sys::Virt::Error::FROM_AUDIT
262
263 The audit driver
264
265 =item Sys::Virt::Error::FROM_CPU
266
267 The CPU information driver
268
269 =item Sys::Virt::Error::FROM_DOMAIN_SNAPSHOT
270
271 The domain snapshot driver
272
273 =item Sys::Virt::Error::FROM_HOOK
274
275 The daemon hook driver
276
277 =item Sys::Virt::Error::FROM_NWFILTER
278
279 The network filter driver
280
281 =item Sys::Virt::Error::FROM_STREAMS
282
283 The data streams driver
284
285 =item Sys::Virt::Error::FROM_SYSINFO
286
287 The system information driver
288
289 =item Sys::Virt::Error::FROM_VMWARE
290
291 The VMWare driver
292
293 =item Sys::Virt::Error::FROM_XENAPI
294
295 The XenAPI driver
296
297 =item Sys::Virt::Error::FROM_EVENT
298
299 The event driver
300
301 =item Sys::Virt::Error::FROM_LIBXL
302
303 The libxl Xen driver
304
305 =item Sys::Virt::Error::FROM_LOCKING
306
307 The lock manager drivers
308
309 =item Sys::Virt::Error::FROM_HYPERV
310
311 The Hyper-V driver
312
313 =item Sys::Virt::Error::FROM_CAPABILITIES
314
315 The capabilities driver
316
317 =item Sys::Virt::Error::FROM_AUTH
318
319 The authentication handling code
320
321 =item Sys::Virt::Error::FROM_URI
322
323 The URI handling code
324
325 =item Sys::Virt::Error::FROM_DBUS
326
327 The DBus handling code
328
329 =item Sys::Virt::Error::FROM_DEVICE
330
331 The device handling code
332
333 =item Sys::Virt::Error::FROM_SSH
334
335 The libSSH2 socket client
336
337 =item Sys::Virt::Error::FROM_PARALLELS
338
339 The Parallels virtualization driver
340
341 =item Sys::Virt::Error::FROM_LOCKSPACE
342
343 The lockspace handling code
344
345 =item Sys::Virt::Error::FROM_INITCTL
346
347 The initctl client code
348
349 =item Sys::Virt::Error::FROM_CGROUP
350
351 The cgroups code
352
353 =item Sys::Virt::Error::FROM_IDENTITY
354
355 The identity management code
356
357 =item Sys::Virt::Error::FROM_ACCESS
358
359 The access control code
360
361 =item Sys::Virt::Error::FROM_SYSTEMD
362
363 The systemd init service
364
365 =item Sys::Virt::Error::FROM_BHYVE
366
367 The FreeBSD BHyve driver
368
369 =item Sys::Virt::Error::FROM_CRYPTO
370
371 The cryptographic helper APIs.
372
373 =item Sys::Virt::Error::FROM_FIREWALL
374
375 The firewall helper APIs.
376
377 =item Sys::Virt::Error::FROM_POLKIT
378
379 The polkit authentication / authorization APIs
380
381 =item Sys::Virt::Error::FROM_THREAD
382
383 The thread helper utils
384
385 =item Sys::Virt::Error::FROM_ADMIN
386
387 The administrative service
388
389 =item Sys::Virt::Error::FROM_LOGGING
390
391 The logging service
392
393 =item Sys::Virt::Error::FROM_XENXL
394
395 The Xen XL driver
396
397 =item Sys::Virt::Error::FROM_PERF
398
399 The performance events subsystem
400
401 =item Sys::Virt::Error::FROM_LIBSSH
402
403 The libSSH socket client
404
405 =item Sys::Virt::Error::FROM_RESCTRL
406
407 The resource control subsystem
408
409 =item Sys::Virt::Error::FROM_FIREWALLD
410
411 The firewalld service
412
413 =item Sys::Virt::Error::FROM_DOMAIN_CHECKPOINT
414
415 The domain checkpoint
416
417 =item Sys::Virt::Error::FROM_TPM
418
419 The TPM subsystem
420
421 =item Sys::Virt::Error::FROM_BPF
422
423 The BPF subsystem
424
425 =item Sys::Virt::Error::FROM_CH
426
427 The Cloud Hypervisor driver
428
429 =back
430
431 =head2 ERROR CODE CONSTANTS
432
433 The error codes allow for specific problems to be identified and
434 handled separately from generic error handling.
435
436 =over 4
437
438 =item Sys::Virt::Error::ERR_AUTH_FAILED
439
440 Authentication failure when connecting to a driver
441
442 =item Sys::Virt::Error::ERR_CALL_FAILED
443
444 Operation not supported by driver (DEPRECATED & unused)
445
446 =item Sys::Virt::Error::ERR_CONF_SYNTAX
447
448 Configuration file syntax error
449
450 =item Sys::Virt::Error::ERR_DOM_EXIST
451
452 The domain already exists
453
454 =item Sys::Virt::Error::ERR_DRIVER_FULL
455
456 Too many hypervisor drivers have been registered
457
458 =item Sys::Virt::Error::ERR_GET_FAILED
459
460 HTTP GET command failed talking to XenD
461
462 =item Sys::Virt::Error::ERR_GNUTLS_ERROR
463
464 GNUTLS encryption error in RPC driver
465
466 =item Sys::Virt::Error::ERR_HTTP_ERROR
467
468 Unexpected HTTP error code from XenD
469
470 =item Sys::Virt::Error::ERR_INTERNAL_ERROR
471
472 Generic internal error
473
474 =item Sys::Virt::Error::ERR_INVALID_ARG
475
476 Invalid argument supplied to function
477
478 =item Sys::Virt::Error::ERR_INVALID_CONN
479
480 Invalid connection object
481
482 =item Sys::Virt::Error::ERR_INVALID_DOMAIN
483
484 Invalid domain object
485
486 =item Sys::Virt::Error::ERR_INVALID_MAC
487
488 Invalid MAC address string
489
490 =item Sys::Virt::Error::ERR_INVALID_NETWORK
491
492 Invalid network object
493
494 =item Sys::Virt::Error::ERR_INVALID_NODE_DEVICE
495
496 Invalid node device object
497
498 =item Sys::Virt::Error::ERR_INVALID_STORAGE_POOL
499
500 Invalid storage pool object
501
502 =item Sys::Virt::Error::ERR_INVALID_STORAGE_VOL
503
504 Invalid storage vol object
505
506 =item Sys::Virt::Error::ERR_NETWORK_EXIST
507
508 Network with this name/uuid already exists
509
510 =item Sys::Virt::Error::ERR_NO_CONNECT
511
512 Unable to connect to requested hypervisor driver
513
514 =item Sys::Virt::Error::ERR_NO_DEVICE
515
516 Missing device information
517
518 =item Sys::Virt::Error::ERR_NO_DOMAIN
519
520 No such domain with that name/uuid/id
521
522 =item Sys::Virt::Error::ERR_NO_KERNEL
523
524 Missing kernel information in domain configuration
525
526 =item Sys::Virt::Error::ERR_NO_MEMORY
527
528 Missing memory information in domain configuration
529
530 =item Sys::Virt::Error::ERR_NO_NAME
531
532 Missing name in object configuration
533
534 =item Sys::Virt::Error::ERR_NO_NETWORK
535
536 No such network with that name/uuid
537
538 =item Sys::Virt::Error::ERR_NO_NODE_DEVICE
539
540 No such node device with that name
541
542 =item Sys::Virt::Error::ERR_NO_OS
543
544 Missing OS information in domain configuration
545
546 =item Sys::Virt::Error::ERR_NO_ROOT
547
548 Missing root device information in domain configuration
549
550 =item Sys::Virt::Error::ERR_NO_SECURITY_MODEL
551
552 Missing security model information in domain configuration
553
554 =item Sys::Virt::Error::ERR_NO_SOURCE
555
556 Missing source device information in domain configuration
557
558 =item Sys::Virt::Error::ERR_NO_STORAGE_POOL
559
560 No such storage pool with that name/uuid
561
562 =item Sys::Virt::Error::ERR_NO_STORAGE_VOL
563
564 No such storage volume with that name/path/key
565
566 =item Sys::Virt::Error::ERR_NO_SUPPORT
567
568 This operation is not supported by the active driver
569
570 =item Sys::Virt::Error::ERR_NO_TARGET
571
572 Missing target device information in domain configuration
573
574 =item Sys::Virt::Error::ERR_NO_XEN
575
576 Unable to connect to Xen hypervisor
577
578 =item Sys::Virt::Error::ERR_NO_XENSTORE
579
580 Unable to connect to XenStorage daemon
581
582 =item Sys::Virt::Error::ERR_OK
583
584 No error code. This should never be see
585
586 =item Sys::Virt::Error::ERR_OPEN_FAILED
587
588 Unable to open a configuration file
589
590 =item Sys::Virt::Error::ERR_OPERATIONED_DENIED
591
592 The operation is forbidden for the current connection
593
594 =item Sys::Virt::Error::ERR_OPERATION_FAILED
595
596 The operation failed to complete
597
598 =item Sys::Virt::Error::ERR_OS_TYPE
599
600 Missing/incorrect OS type in domain configuration
601
602 =item Sys::Virt::Error::ERR_PARSE_FAILED
603
604 Failed to parse configuration file
605
606 =item Sys::Virt::Error::ERR_POST_FAILED
607
608 HTTP POST failure talking to XenD
609
610 =item Sys::Virt::Error::ERR_READ_FAILED
611
612 Unable to read from configuration file
613
614 =item Sys::Virt::Error::ERR_RPC
615
616 Generic RPC error talking to XenD
617
618 =item Sys::Virt::Error::ERR_SEXPR_SERIAL
619
620 Failed to generic SEXPR for XenD
621
622 =item Sys::Virt::Error::ERR_SYSTEM_ERROR
623
624 Generic operating system error
625
626 =item Sys::Virt::Error::ERR_UNKNOWN_HOST
627
628 Unknown hostname
629
630 =item Sys::Virt::Error::ERR_WRITE_FAILED
631
632 Failed to write to configuration file
633
634 =item Sys::Virt::Error::ERR_XEN_CALL
635
636 Failure while talking to Xen hypervisor
637
638 =item Sys::Virt::Error::ERR_XML_DETAIL
639
640 Detailed XML parsing error
641
642 =item Sys::Virt::Error::ERR_XML_ERROR
643
644 Generic XML parsing error
645
646 =item Sys::Virt::Error::WAR_NO_NETWORK
647
648 Warning that no network driver is activated
649
650 =item Sys::Virt::Error::WAR_NO_NODE
651
652 Warning that no node device driver is activated
653
654 =item Sys::Virt::Error::WAR_NO_STORAGE
655
656 Warning that no storage driver is activated
657
658 =item Sys::Virt::Error::ERR_INVALID_INTERFACE
659
660 Invalid network interface object
661
662 =item Sys::Virt::Error::ERR_NO_INTERFACE
663
664 No interface with the matching name / mac address
665
666 =item Sys::Virt::Error::ERR_OPERATION_INVALID
667
668 The requested operation is not valid for the current object state
669
670 =item Sys::Virt::Error::WAR_NO_INTERFACE
671
672 The network interface driver is not available
673
674 =item Sys::Virt::Error::ERR_MULTIPLE_INTERFACES
675
676 There are multiple interfaces with the requested MAC address
677
678 =item Sys::Virt::Error::ERR_BUILD_FIREWALL
679
680 The firewall could not be constructed
681
682 =item Sys::Virt::Error::WAR_NO_NWFILTER
683
684 The network filter driver could not be activated
685
686 =item Sys::Virt::Error::ERR_NO_NWFILTER
687
688 There is no network filter driver available
689
690 =item Sys::Virt::Error::ERR_INVALID_NWFILTER
691
692 The network filter object was invalid
693
694 =item Sys::Virt::Error::WAR_NO_SECRET
695
696 There secret management driver is not available
697
698 =item Sys::Virt::Error::ERR_NO_SECRET
699
700 No secret with the matching uuid / usage ID
701
702 =item Sys::Virt::Error::ERR_INVALID_SECRET
703
704 Invalid secret object
705
706 =item Sys::Virt::Error::ERR_CONFIG_UNSUPPORTED
707
708 The requested XML configuration is not supported by the hypervisor
709
710 =item Sys::Virt::Error::ERR_OPERATION_TIMEOUT
711
712 The operation could not be completed in a satisfactory time
713
714 =item Sys::Virt::Error::ERR_MIGRATE_PERSIST_FAILED
715
716 Unable to persistent the domain configuration after migration
717 successfully completed
718
719 =item Sys::Virt::Error::ERR_HOOK_SCRIPT_FAILED
720
721 Execution of a daemon hook script failed
722
723 =item Sys::Virt::Error::ERR_INVALID_DOMAIN_SNAPSHOT
724
725 The domain snapshot object pointer was invalid
726
727 =item Sys::Virt::Error::ERR_NO_DOMAIN_SNAPSHOT
728
729 No matching domain snapshot was found
730
731 =item Sys::Virt::Error::ERR_INVALID_STREAM
732
733 The stream object pointer was invalid
734
735 =item Sys::Virt::Error::ERR_ARGUMENT_UNSUPPORTED
736
737 The argument value was not supported by the driver
738
739 =item Sys::Virt::Error::ERR_STORAGE_POOL_BUILT
740
741 The storage pool has already been built
742
743 =item Sys::Virt::Error::ERR_STORAGE_PROBE_FAILED
744
745 Probing the storage pool failed
746
747 =item Sys::Virt::Error::ERR_SNAPSHOT_REVERT_RISKY
748
749 Reverting the snapshot could cause data loss
750
751 =item Sys::Virt::Error::ERR_OPERATION_ABORTED
752
753 The asynchronous operation was aborted at admin request
754
755 =item Sys::Virt::Error::ERR_AUTH_CANCELLED
756
757 The user cancelled the authentication process
758
759 =item Sys::Virt::Error::ERR_NO_DOMAIN_METADATA
760
761 The requested metadata does not exist
762
763 =item Sys::Virt::Error::ERR_MIGRATE_UNSAFE
764
765 The migration operation would be unsafe to perform
766
767 =item Sys::Virt::Error::ERR_OVERFLOW
768
769 The calculation would overflow
770
771 =item Sys::Virt::Error::ERR_BLOCK_COPY_ACTIVE
772
773 Action prevented by block copy job
774
775 =item Sys::Virt::Error::ERR_AGENT_UNRESPONSIVE
776
777 The guest agent is not responding
778
779 =item Sys::Virt::Error::ERR_OPERATION_UNSUPPORTED
780
781 The operation is not supported on this host
782
783 =item Sys::Virt::Error::ERR_SSH
784
785 The SSH operation failed
786
787 =item Sys::Virt::Error::ERR_RESOURCE_BUSY
788
789 The resource requested is already in use
790
791 =item Sys::Virt::Error::ERR_ACCESS_DENIED
792
793 Not authorized to perform the operation
794
795 =item Sys::Virt::Error::ERR_DBUS_SERVICE
796
797 An error from a DBus service API
798
799 =item Sys::Virt::Error::ERR_STORAGE_VOL_EXIST
800
801 The storage volume already exists
802
803 =item Sys::Virt::Error::ERR_CPU_INCOMPATIBLE
804
805 The CPUs are not compatible
806
807 =item Sys::Virt::Error::ERR_INVALID_SCHEMA
808
809 The XML document does not comply with the XML schema
810
811 =item Sys::Virt::Error::ERR_MIGRATE_FINISH_OK
812
813 Migration finished but expected to return NULL domain.
814
815 =item Sys::Virt::Error::ERR_AUTH_UNAVAILABLE
816
817 Authentication services were not available
818
819 =item Sys::Virt::Error::ERR_NO_SERVER
820
821 Libvirt server was not found
822
823 =item Sys::Virt::Error::ERR_NO_CLIENT
824
825 Libvirt client was not found
826
827 =item Sys::Virt::Error::ERR_AGENT_UNSYNCED
828
829 Libvirt guest agent replies with wrong id to guest-sync command
830
831 =item Sys::Virt::Error::ERR_LIBSSH
832
833 The libSSH operation failed
834
835 =item Sys::Virt::Error::ERR_DEVICE_MISSING
836
837 Libvirt fail to find the desired device.
838
839 =item Sys::Virt::Error::ERR_INVALID_NWFILTER_BINDING
840
841 Invalid nwfilter binding
842
843 =item Sys::Virt::Error::ERR_NO_NWFILTER_BINDING
844
845 No nwfilter binding
846
847 =item Sys::Virt::Error::ERR_INVALID_DOMAIN_CHECKPOINT
848
849 Invalid domain checkpoint
850
851 =item Sys::Virt::Error::ERR_NO_DOMAIN_BACKUP
852
853 Domain checkpoint not found
854
855 =item Sys::Virt::Error::ERR_NO_DOMAIN_CHECKPOINT
856
857 Domain backup job id not found
858
859 =item Sys::Virt::Error::ERR_NO_NETWORK_PORT
860
861 No matching network port
862
863 =item Sys::Virt::Error::ERR_INVALID_NETWORK_PORT
864
865 Invalid network port object
866
867 =item Sys::Virt::Error::ERR_NETWORK_PORT_EXIST
868
869 Network port already exists
870
871 =item Sys::Virt::Error::ERR_NO_HOSTNAME
872
873 No domain hostname found
874
875 =item Sys::Virt::Error::ERR_CHECKPOINT_INCONSISTENT
876
877 The checkpoint is inconsistent
878
879 =item Sys::Virt::Error::ERR_MULTIPLE_DOMAINS
880
881 More than one matching domain found
882
883 =item Sys::Virt::Error::ERR_NO_NETWORK_METADATA
884
885 The requested metadata does not exist
886
887 =item Sys::Virt::Error::ERR_AGENT_COMMAND_TIMEOUT
888
889 Guest agent didn't respond to a non-sync command within timeout
890
891 =item Sys::Virt::Error::ERR_AGENT_COMMAND_FAILED
892
893 Guest agent responded with failure to a command
894
895 =item Sys::Virt::Error::ERR_INVALID_ENCR_KEY_SECRET
896
897 Secret encryption key is invalid
898
899 =back
900
901 =head1 AUTHORS
902
903 Daniel P. Berrange <[email protected]>
904
905
906 =head1 COPYRIGHT
907
908 Copyright (C) 2006 Red Hat
909 Copyright (C) 2006-2007 Daniel P. Berrange
910
911 =head1 LICENSE
912
913 This program is free software; you can redistribute it and/or modify
914 it under the terms of either the GNU General Public License as published
915 by the Free Software Foundation (either version 2 of the License, or at
916 your option any later version), or, the Artistic License, as specified
917 in the Perl README file.
918
919 =head1 SEE ALSO
920
921 L<Sys::Virt::Domain>, L<Sys::Virt>, C<http://libvirt.org>
922
923 =cut