Implement disk-type and cpu-count parameters in KVM.

parent b2c68db1
......@@ -33,6 +33,14 @@ class Recipe(GenericBaseRecipe):
kvm instance configuration.
"""
def install(self):
# Sanitize drive type parameter
self.options.setdefault('disk-type', 'virtio')
if not self.options.get('disk-type') in ['ide', 'scsi', 'sd',
'mtd', 'floppy', 'pflash', 'virtio']:
print 'Warning: "disk-type" parameter is not in allowed values. Using ' \
'"virtio" value.'
self.options['disk-type'] = 'virtio'
config = dict(
tap_interface=self.options['tap'],
vnc_ip=self.options['vnc-ip'],
......@@ -41,6 +49,7 @@ class Recipe(GenericBaseRecipe):
nbd_port=self.options['nbd-port'],
disk_path=self.options['disk-path'],
disk_size=self.options['disk-size'],
disk_type=self.options['disk-type'],
mac_address=self.options['mac-address'],
smp_count=self.options['smp-count'],
ram_size=self.options['ram-size'],
......@@ -50,7 +59,6 @@ class Recipe(GenericBaseRecipe):
shell_path=self.options['shell-path'],
qemu_path=self.options['qemu-path'],
qemu_img_path=self.options['qemu-img-path'],
# XXX Weak password
vnc_passwd=self.options['passwd']
)
......
......@@ -36,7 +36,7 @@ kvm_argument_list = ['%(qemu_path)s', '-enable-kvm', '-net', 'nic,macaddr=%(mac_
'-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',
'-drive', 'file=%(disk_path)s,if=%(disk_type)s,boot=on',
'-vnc', '%(vnc_ip)s:1,ipv4,password',
'-boot', 'menu=on',
'-qmp', 'unix:%(socket_path)s,server',
......
......@@ -18,8 +18,23 @@
"minimum": 1,
"maximum": 80
},
"disk-type": {
"title": "Disk type",
"description": "Type of QEMU disk drive.",
"type": "string",
"default": "virtio",
"enum": ["ide", "scsi", "sd", "mtd", "floppy", "pflash", "virtio"]
},
"cpu-count": {
"title": "CPU count",
"description": "Number of CPU cores.",
"type": "integer",
"minimum": 1,
"maximum": 8
},
"nbd-ip": {
"title": "NBD hostname",
"description": "hostname (or IP) of the NBD server containing the boot image.",
......@@ -35,8 +50,8 @@
"minimum": 1,
"maximum": 65535
},
"frontend-instance-guid": {
"title": "Frontend Instance ID",
"description": "Unique identifier of the frontend instance, like \"SOFTINST-11031\".",
......
......@@ -50,9 +50,10 @@ nbd-port = $${slap-parameter:nbd-port}
tap = $${slap-network-information:network-interface}
disk-path = $${directory:srv}/virtual.qcow2
disk-size = $${slap-parameter:disk-size}
disk-type = $${slap-parameter:disk-type}
socket-path = $${directory:var}/qmp_socket
pid-path = $${directory:run}/pid_file
smp-count = 1
smp-count = $${slap-parameter:cpu-count}
ram-size = $${slap-parameter:ram-size}
mac-address = $${create-mac:mac-address}
runner-path = $${directory:services}/kvm
......@@ -174,3 +175,6 @@ nbd_ip = $${:nbd-ip}
ram-size = 1024
disk-size = 10
disk-type = virtio
cpu-count = 1
\ No newline at end of file
......@@ -119,7 +119,7 @@ command =
[template-kvm]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg.in
md5sum = 67c1980ba1e70b376f2811602991ff09
md5sum = aefed0723c79f4d4b9ed977b73e4bac5
output = ${buildout:directory}/template-kvm.cfg
mode = 0644
......
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