Virt/Plugin/Xen.pm

filter: Statementstmt 50.0% 23 / 46 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.6% 7 / 11 Podpod 100% 2 / 2 totaltotal 42.6% 32 / 75 CC 9 SCAR 28.0
CC
9
Cov
37%
is_host
30.0
is_vm
30.0
_init_priority
2.0
CRAP 16.4
« Virt/Plugin/Openvz.pm ↑ Summary Virt/Plugin/KVM.pm »
1 package Linux::Virt::Plugin::Xen;
2 {
3 2 $Linux::Virt::Plugin::Xen::VERSION = '0.15';
4 }
5 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 $Linux::Virt::Plugin::Xen::AUTHORITY = 'cpan:TEX';
7 }
8 # ABSTRACT: Xen plugin for Linux::Virt
9  
10 2 ▶use 5.010_000;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use feature ':5.10';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 # use IO::Handle;
18 # use autodie;
19 # use MooseX::Params::Validate;
20  
21 2 extends 'Linux::Virt::Plugin::Libvirt';
22  
23 0 ▶sub _init_priority { return 10; }
Subroutine _init_priority: not called CC=1 SCAR=6.9
24  
25 0 ▶sub _init_type {
Subroutine _init_type: not called CC=1 SCAR=6.9
26 0 return 'xen';
27 }
28  
29 0 ▶sub is_host { # dom0
Subroutine is_host: not called CC=5 SCAR=34.0
Pod documented
30 0 my $self = shift;
31 0 my $xen_caps = "/proc/xen/capabilities";
32 0 ▶ if ( -f $xen_caps ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $xen_caps) 0 0 0
33 0 ▶ if ( open( my $FH, "<", $xen_caps ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $FH, "<", $xen_caps) 0 0 0
34 0 ▶ while ( my $line = <$FH> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $FH)) 0 0 0
35 0 ▶ if ( $line =~ m/control_d/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /control_d/i) 0 0 0
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 0 ▶sub is_vm { # domu
Subroutine is_vm: not called CC=5 SCAR=34.0
Pod documented
47 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 ▶ if ( -f $xen_caps ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $xen_caps) 0 0 0
52 0 ▶ if ( open( my $FH, "<", $xen_caps ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $FH, "<", $xen_caps) 0 0 0
53 0 ▶ while ( my $line = <$FH> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $FH)) 0 0 0
54 0 ▶ if ( $line =~ m/control_d/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /control_d/i) 0 0 0
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 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 2 __PACKAGE__->meta->make_immutable;
68  
69 2 1;
70  
71 __END__
« Virt/Plugin/Openvz.pm ↑ Summary Virt/Plugin/KVM.pm »