| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Linux::Virt::Plugin::Xen; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Linux::Virt::Plugin::Xen::VERSION = '0.15'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
BEGIN { |
|
6
|
1
|
|
|
1
|
|
2639
|
$Linux::Virt::Plugin::Xen::AUTHORITY = 'cpan:TEX'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
|
|
|
|
|
|
# ABSTRACT: Xen plugin for Linux::Virt |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
36
|
use 5.010_000; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
43
|
|
|
11
|
1
|
|
|
1
|
|
7
|
use mro 'c3'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
12
|
1
|
|
|
1
|
|
51
|
use feature ':5.10'; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
122
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
15
|
1
|
|
|
1
|
|
12374
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
12
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# use IO::Handle; |
|
18
|
|
|
|
|
|
|
# use autodie; |
|
19
|
|
|
|
|
|
|
# use MooseX::Params::Validate; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
extends 'Linux::Virt::Plugin::Libvirt'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
0
|
|
|
sub _init_priority { return 10; } |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _init_type { |
|
26
|
0
|
|
|
0
|
|
|
return 'xen'; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub is_host { # dom0 |
|
30
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
31
|
0
|
|
|
|
|
|
my $xen_caps = "/proc/xen/capabilities"; |
|
32
|
0
|
0
|
|
|
|
|
if ( -f $xen_caps ) { |
|
33
|
0
|
0
|
|
|
|
|
if ( open( my $FH, "<", $xen_caps ) ) { |
|
34
|
0
|
|
|
|
|
|
while ( my $line = <$FH> ) { |
|
35
|
0
|
0
|
|
|
|
|
if ( $line =~ m/control_d/i ) { |
|
36
|
0
|
|
|
|
|
|
close($FH); |
|
37
|
0
|
|
|
|
|
|
return 1; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} ## end while ( my $line = <$FH> ) |
|
40
|
0
|
|
|
|
|
|
close($FH); |
|
41
|
|
|
|
|
|
|
} ## end if ( open( my $FH, "<"...)) |
|
42
|
|
|
|
|
|
|
} ## end if ( -f $xen_caps ) |
|
43
|
0
|
|
|
|
|
|
return; |
|
44
|
|
|
|
|
|
|
} ## end sub is_host |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub is_vm { # domu |
|
47
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
48
|
0
|
|
|
|
|
|
my $xen_caps = "/proc/xen/capabilities"; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# xen_caps must be present and NOT contain control_d |
|
51
|
0
|
0
|
|
|
|
|
if ( -f $xen_caps ) { |
|
52
|
0
|
0
|
|
|
|
|
if ( open( my $FH, "<", $xen_caps ) ) { |
|
53
|
0
|
|
|
|
|
|
while ( my $line = <$FH> ) { |
|
54
|
0
|
0
|
|
|
|
|
if ( $line =~ m/control_d/i ) { |
|
55
|
0
|
|
|
|
|
|
close($FH); |
|
56
|
0
|
|
|
|
|
|
return; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
} ## end while ( my $line = <$FH> ) |
|
59
|
0
|
|
|
|
|
|
close($FH); |
|
60
|
|
|
|
|
|
|
} ## end if ( open( my $FH, "<"...)) |
|
61
|
0
|
|
|
|
|
|
return 1; |
|
62
|
|
|
|
|
|
|
} ## end if ( -f $xen_caps ) |
|
63
|
0
|
|
|
|
|
|
return; |
|
64
|
|
|
|
|
|
|
} ## end sub is_vm |
|
65
|
|
|
|
|
|
|
|
|
66
|
1
|
|
|
1
|
|
1307
|
no Moose; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
7
|
|
|
67
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=pod |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=encoding utf-8 |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Linux::Virt::Plugin::Xen - Xen plugin for Linux::Virt |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 is_host |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This method will return a true value if invoked in an xen (capeable) host (dom0). |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 is_vm |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This method will return a true value if invoked in a xen vm (domU) |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Linux::Virt::Xen - Xen plugin for Linux::Virt |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Dominik Schulz <dominik.schulz@gauner.org> |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Dominik Schulz. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
104
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |