summaryrefslogtreecommitdiff
path: root/server/samples/kvm_from_git.srv
blob: 27c4f26dc590644ab204e96dba0ae2becc35b45f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
print "XXXX start of control file"
print "XXXX creating RemoteHost object"
remote_host= hosts.create_host("myhost")

print "XXXX installing KVM"
kvm_on_remote_host= kvm.KVM(remote_host)

### kvm git repo vars ###
kvm_repodir = '/var/local/git/kvm'
kvm_giturl  = 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git'
kvm_weburl  = 'http://git.kernel.org/?p=linux/kernel/git/avi/kvm.git'

### kvm-userspace git repo vars ###
kvmuser_repodir = '/var/local/git/kvm-userspace'
kvmuser_giturl = 'git://git.kernel.org/pub/scm/virt/kvm/kvm-userspace.git'
kvmuser_weburl = 'http://git.kernel.org/?p=virt/kvm/kvm-userspace.git'

### common dir on remote to push repos
kvm_build = '/tmp/git'

print "XXXX pulling latest kvm from git repo"
kvm_repo = git.GitRepo(kvm_repodir, kvm_giturl, kvm_weburl)
kvm_repo.get(remote_host)
kvm_repo.install(remote_host, builddir=kvm_build)

print "XXXX pulling latest kvm-userspace from git repo"
kvmuser_repo = git.GitRepo(kvmuser_repodir, kvmuser_giturl, kvmuser_weburl)
kvmuser_repo.get(remote_host)
kvmuser_repo.install(remote_host, builddir=kvm_build)

# copy kvmuserspace into tmp dir
kvm_on_remote_host.get(kvmuser_repodir)

addresses= [{"mac": "02:00:00:00:00:%02x" % (num,), "ip" : "10.0.0.%d" % (num,)} for num in range(1, 16)]

# install and sync latest kvm bits into before building
print "XXXX installing kvm"
kvm_on_remote_host.install(addresses, syncdir=kvm_repodir)

# print out kvm module version
module = kvm_on_remote_host.modules['kvm']
modversion = remote_host.run("modinfo -F version %s" %(module)).stdout.strip()
print "XXXX using kvm version %s" %(modversion)

print "XXXX starting guest with default kernel"
qemu_options= "-m 256 -hda /var/local/vdisk.img -snapshot"

g= hosts.KVMGuest(kvm_on_remote_host, qemu_options)
g.wait_up()

print g.run('uname -a').stdout.strip()


print "XXXX starting guest with custom kernel"
kernel= deb_kernel.DEBKernel()
kernel.get("/home/foo/linux-2.6.21.3-6_2.6.21.3-6_amd64-version2.deb")
kernel_dir= kernel.extract(remote_host)

qemu_options= '-m 256 -hda /var/local/vdisk.img -snapshot -kernel "%s" -append "%s"' % (sh_escape(os.path.join(kernel_dir, kernel.get_image_name()[1:])), sh_escape("root=/dev/hda1 ro console=tty0 console=ttyS0,9600"),)

g= hosts.KVMGuest(kvm_on_remote_host, qemu_options)
g.wait_up()

print g.run('uname -a').stdout.strip()
print "XXXX end of control file"