9 use Data::Dump qw/dump/;
11 our $memory_size = 512;
13 # AC = private, AD = multicast, AE = local
15 sub nr { $ENV{nr} || 0 };
20 return join( $del, $server::ip, $port );
23 sub fork_if_active { qw/monitor serial/ }
28 x11::xterm( 'monitor ' . nr() => 'nc ' . port(10000,' ') );
32 x11::xterm( 'serial ' . nr() => 'nc ' . port(11000,' ') );
35 sub actions { qw/reset activate/ }
38 my $sock = IO::Socket::INET->new( port(10000,':') );
39 print $sock "system_reset\n";
44 system "xdotool windowactivate `xdotool search --class kvm`"
48 my $nr = $ENV{nr} || 0;
50 my $mac = sprintf('AC:DE:48:00:00:%02x', $nr);
51 my $mon = port(10000,':');
52 my $ser = port(11000,':');
54 my $ifname = 'kvm' . $nr;
56 warn "# kvm start $nr $mac $mon $ser $ifname";
58 # system "ifconfig $ifname down";
59 # system "brctl delif virtual $ifname";
60 # system "tunctl -d $ifname";
62 my $ifconfig = `/sbin/ifconfig $ifname`;
64 # FIXME tunctl -u $server::user
65 system "tunctl -t $ifname"
66 unless $ifconfig =~ m{$ifname};
67 system "ifconfig $ifname up"
68 unless $ifconfig =~ m{UP};
69 system "brctl addif virtual $ifname"
70 unless `brctl show` =~ m{$ifname};
72 my $ip = client::ip_from_mac $mac;
74 my $name = client::conf( $ip, 'hostname' );
77 my $boot = client::conf( $ip, 'kvm.boot' ) || 'n'; # network by default
82 -m $memory_size -net nic,macaddr=$mac
83 -net tap,ifname=$ifname,script=no
85 -monitor tcp:$mon,server,nowait
86 -serial tcp:$ser,server,nowait
89 $kvm .= ' -vnc ' . port(0,':') unless $ENV{DISPLAY};
91 # -runas $server::user
101 $mac =~ s{^.+:([0-9a-f]{2})$}{hex($1)}e;
106 my @kvms = glob "$server::conf/mac/AC:DE:48:00:00:*";
107 my $nr = nr_from_mac( pop @kvms );