Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alain Takoudjou
slapos
Commits
9e10a93c
Commit
9e10a93c
authored
Feb 24, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to boot kvm even when NBD is not available
parent
6f4f3803
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
18 deletions
+52
-18
slapos/recipe/kvm/template/kvm_run.in
slapos/recipe/kvm/template/kvm_run.in
+52
-18
No files found.
slapos/recipe/kvm/template/kvm_run.in
View file @
9e10a93c
#!%(
shell
_path)s
#!%(
python
_path)s
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
if [ ! -e "%(disk_path)s" ]
then "%(qemu_img_path)s" create -f qcow2 "%(disk_path)s" %(disk_size)sG
fi
# Echo client program
import os
import socket
import subprocess
# TODO: -net nic,model=virtio, but OS installer has to provide the virtio_net
# module
exec %(qemu_path)s \
-net nic,macaddr=%(mac_address)s \
-net tap,ifname=%(tap_interface)s,script=no,downscript=no \
-smp %(smp_count)s \
-m %(ram_size)s \
-cdrom nbd:[%(nbd_ip)s]:%(nbd_port)s \
-drive file=%(disk_path)s,if=virtio,boot=on \
-vnc %(vnc_ip)s:1,ipv4,password \
-boot menu=on \
-qmp unix:%(socket_path)s,server \
-pidfile %(pid_file_path)s \
-no-kvm
def getSocketStatus(host, port):
s = None
for res in socket.getaddrinfo(host, port,
socket.AF_UNSPEC, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
except socket.error, msg:
s = None
continue
try:
s.connect(sa)
except socket.error, msg:
s.close()
s = None
continue
break
return s
# create disk if doesn't exist
disk_path = '%(disk_path)s'
if not os.path.exists(disk_path):
subprocess.Popen(['%(qemu_img_path)s', 'create' ,'-f', 'qcow2',
'%(disk_path)s', '%(disk_size)sG'])
kvm_argument_list = ['%(qemu_path)s',
'-net' 'nic,macaddr=%(mac_address)s',
'-net' 'tap,ifname=%(tap_interface)s,script=no,downscript=no',
'-smp' '%(smp_count)s',
'-m' '%(ram_size)s',
'-drive' 'file=%(disk_path)s,if=virtio,boot=on',
'-vnc' '%(vnc_ip)s:1,ipv4,password',
'-boot' 'menu=on',
'-qmp' 'unix:%(socket_path)s,server',
'-pidfile' '%(pid_file_path)s',
'-no-kvm']
# Try to connect to NBD server
s = getSocketStatus('%(nbd_ip)s', %(nbd_port)s)
if s is None:
# NBD is not available : launch kvm without it
print 'Warning : Nbd is not available.'
os.execv(kvm_argument_list)
else:
# NBD is available
kvm_argument_list.extend(['-cdrom' 'nbd:[%(nbd_ip)s]:%(nbd_port)s'])
os.execv(kvm_argument_list)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment