/[pxelator]/lib/PXElator/kvm.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /lib/PXElator/kvm.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54 - (hide annotations)
Thu Jul 30 12:28:49 2009 UTC (11 years, 7 months ago) by dpavlin
File size: 776 byte(s)
start kvm with vde2

1 dpavlin 54 package kvm;
2    
3     use warnings;
4     use strict;
5     use autodie;
6    
7     use File::Slurp;
8    
9     use server;
10    
11     my $interfaces = read_file '/etc/network/interfaces';
12    
13     if ( $interfaces !~ m{tap0.*$server::ip}s ) {
14    
15     system "sudo apt-get install vde2";
16    
17     $interfaces .= qq{
18    
19     iface tap0 inet static
20     address $server::ip
21     netmask $server::netmask
22     vde2-switch -
23    
24     };
25    
26     write_file '/etc/network/interfaces', $interfaces;
27    
28     }
29    
30     if ( grep /tap0/, read_file '/proc/net/dev' ) {
31     warn "tap0 started";
32     } else {
33     system "sudo ifup tap0";
34     }
35    
36     our $memory_size = 512;
37     our $mac = '52:54:00:00:00:01';
38    
39     sub start {
40    
41     my $kvm = qq|
42     vdeq kvm -m $memory_size -net nic,vlan=1,macaddr=$mac
43     -net vde,vlan=1,sock=/var/run/vde2/tap0.ctl
44     -boot n
45     |;
46     $kvm =~ s{\s+}{ }gs;
47     warn $kvm;
48     system $kvm;
49    
50     }
51    
52     warn 'loaded';
53    
54     1;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26