File Coverage

blib/lib/Protocol/Sys/Virt/UNIXSocket.pm
Criterion Covered Total %
statement 25 25 100.0
branch 4 4 100.0
condition 10 13 76.9
subroutine 6 6 100.0
pod 1 1 100.0
total 46 49 93.8


line stmt bran cond sub pod time code
1             ####################################################################
2             #
3             # This file was generated using XDR::Parse version v1.0.1,
4             # XDR::Gen version 1.1.2 and LibVirt version v12.1.0
5             #
6             # Don't edit this file, use the source template instead
7             #
8             # ANY CHANGES HERE WILL BE LOST !
9             #
10             ####################################################################
11              
12              
13 1     1   260253 use v5.14;
  1         5  
14 1     1   8 use warnings;
  1         2  
  1         130  
15              
16             package Protocol::Sys::Virt::UNIXSocket v12.1.0;
17              
18 1     1   527 use parent qw(Exporter);
  1         335  
  1         8  
19              
20 1     1   110 use Carp qw(croak);
  1         3  
  1         54  
21 1     1   498 use Log::Any qw($log);
  1         10545  
  1         6  
22              
23             our @EXPORT = qw( socket_path );
24              
25             sub socket_path {
26 14     14 1 258248 my %args = @_;
27 14   100     82 my $path = $args{prefix} // '';
28 14         37 $path .= '/run/libvirt';
29              
30 14         25 my $driver;
31 14   100     48 my $mode = $args{mode} // 'legacy';
32 14 100 66     69 if ($mode eq 'direct' and ($args{hypervisor} // $args{driver})) {
      66        
33 6   66     28 $path .= '/virt' . ($args{hypervisor} // $args{driver}) . 'd-sock';
34             }
35             else {
36 8         39 $path .= '/libvirt-sock';
37             }
38 14 100       40 if ($args{readonly}) {
39 6         12 $path .= '-ro';
40             }
41              
42 14         96 return $path;
43             }
44              
45             1;
46              
47              
48             __END__