Attempt to boot kvm even when NBD is not available

parent 6f4f3803
#!%(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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment