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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
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: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
# BEWARE: It will be overwritten automatically
if [ ! -e "%(disk_path)s" ]
# Echo client program
then "%(qemu_img_path)s" create -f qcow2 "%(disk_path)s" %(disk_size)sG
import os
fi
import socket
import subprocess
# TODO: -net nic,model=virtio, but OS installer has to provide the virtio_net
def getSocketStatus(host, port):
# module
s = None
exec %(qemu_path)s \
for res in socket.getaddrinfo(host, port,
-net nic,macaddr=%(mac_address)s \
socket.AF_UNSPEC, socket.SOCK_STREAM):
-net tap,ifname=%(tap_interface)s,script=no,downscript=no \
af, socktype, proto, canonname, sa = res
-smp %(smp_count)s \
try:
-m %(ram_size)s \
s = socket.socket(af, socktype, proto)
-cdrom nbd:[%(nbd_ip)s]:%(nbd_port)s \
except socket.error, msg:
-drive file=%(disk_path)s,if=virtio,boot=on \
s = None
-vnc %(vnc_ip)s:1,ipv4,password \
continue
-boot menu=on \
try:
-qmp unix:%(socket_path)s,server \
s.connect(sa)
-pidfile %(pid_file_path)s \
except socket.error, msg:
-no-kvm
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