~ubuntu-core-dev/eucalyptus/ubuntu-karmic

« back to all changes in this revision

Viewing changes to tools/gen_kvm_libvirt_xml

  • Committer: Dmitrii Zagorodnov
  • Date: 2009-01-27 21:53:41 UTC
  • mfrom: (25.1.112 eucalyptus-main)
  • Revision ID: dmitrii@cs.ucsb.edu-20090127215341-i0f0v6cmbpljmg02
merged with current main

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env perl
 
2
#
 
3
# this generates an XML template for libvirt domain specification,
 
4
# which is tailored to an instance by the node controller
 
5
 
 
6
use diagnostics;
 
7
use warnings; 
 
8
use sigtrap;
 
9
use strict;
 
10
use English; # for descriptive predefined var names
 
11
use Data::Dumper; # for debugging: print Dumper($var)
 
12
use Getopt::Long;
 
13
use FindBin;
 
14
$OUTPUT_AUTOFLUSH = 1; # no output buffering
 
15
 
 
16
our $use_ramdisk = 0;
 
17
our $use_ephemeral = 0;
 
18
 
 
19
# deal with command-line parameters
 
20
GetOptions('ramdisk'        => sub { $use_ramdisk = 1; },
 
21
           'ephemeral'      => sub { $use_ephemeral = 1; }
 
22
                   ) or exit (1);
 
23
 
 
24
print <<EOF;
 
25
<domain type='kvm'>
 
26
    <name>NAME</name>
 
27
    <os>
 
28
    <type>hvm</type>
 
29
        <kernel>BASEPATH/kernel</kernel>
 
30
EOF
 
31
 
 
32
if ( $use_ramdisk ) {
 
33
    print "        <initrd>BASEPATH/ramdisk</initrd>\n";
 
34
}
 
35
 
 
36
print <<EOF;
 
37
        <cmdline>root=/dev/sda1 console=ttyS0</cmdline>
 
38
    </os>
 
39
    <features>
 
40
        <acpi/>
 
41
    </features>
 
42
    <memory>MEMORY</memory>
 
43
    <vcpu>VCPUS</vcpu>
 
44
    <devices>
 
45
        <emulator>/usr/bin/kvm</emulator>
 
46
        <disk type='file'>
 
47
            <source file='BASEPATH/root'/>
 
48
            <target dev='sda'/>
 
49
        </disk>
 
50
EOF
 
51
 
 
52
if ( $use_ephemeral ) {
 
53
    print <<EOF;
 
54
        <disk type='file'>
 
55
            <source file='BASEPATH/ephemeral'/>
 
56
            <target dev='sda2'/>
 
57
        </disk>
 
58
EOF
 
59
}
 
60
 
 
61
print <<EOF;
 
62
        <interface type='bridge'>
 
63
            <source bridge='BRIDGEDEV'/>
 
64
            <mac address='PRIVMACADDR'/>
 
65
        </interface>
 
66
        <serial type="file">
 
67
            <source path='BASEPATH/console.log'/>
 
68
            <target port='1'/>
 
69
        </serial>
 
70
    </devices>
 
71
</domain>
 
72
EOF