/[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 56 - (show annotations)
Thu Jul 30 14:16:13 2009 UTC (12 years, 1 month ago) by dpavlin
File size: 836 byte(s)
start kvm with exec in xterm to see monitor output

1 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 -monitor stdio
46 |;
47
48
49 $kvm = "xterm -e $kvm" if $ENV{DISPLAY};
50
51 $kvm =~ s{\s+}{ }gs;
52 warn $kvm;
53 exec $kvm;
54
55 }
56
57 warn 'loaded';
58
59 1;

  ViewVC Help
Powered by ViewVC 1.1.26