/[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

Contents of /lib/PXElator/kvm.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 67 - (show annotations)
Thu Jul 30 21:31:30 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 908 byte(s)
implemented correct start/stop logic (which now works!)
and pushed debug state into $server::debug and file 
conf/debug for shared state between servers

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

  ViewVC Help
Powered by ViewVC 1.1.26