Commit c7860b72 authored by Cédric de Saint Martin's avatar Cédric de Saint Martin Committed by Marco Mariani

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

parent 1f7f0a60
...@@ -33,6 +33,14 @@ class Recipe(GenericBaseRecipe): ...@@ -33,6 +33,14 @@ class Recipe(GenericBaseRecipe):
kvm instance configuration. kvm instance configuration.
""" """
def install(self): 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( config = dict(
tap_interface=self.options['tap'], tap_interface=self.options['tap'],
vnc_ip=self.options['vnc-ip'], vnc_ip=self.options['vnc-ip'],
...@@ -41,6 +49,7 @@ class Recipe(GenericBaseRecipe): ...@@ -41,6 +49,7 @@ class Recipe(GenericBaseRecipe):
nbd_port=self.options['nbd-port'], nbd_port=self.options['nbd-port'],
disk_path=self.options['disk-path'], disk_path=self.options['disk-path'],
disk_size=self.options['disk-size'], disk_size=self.options['disk-size'],
disk_type=self.options['disk-type'],
mac_address=self.options['mac-address'], mac_address=self.options['mac-address'],
smp_count=self.options['smp-count'], smp_count=self.options['smp-count'],
ram_size=self.options['ram-size'], ram_size=self.options['ram-size'],
...@@ -50,7 +59,6 @@ class Recipe(GenericBaseRecipe): ...@@ -50,7 +59,6 @@ class Recipe(GenericBaseRecipe):
shell_path=self.options['shell-path'], shell_path=self.options['shell-path'],
qemu_path=self.options['qemu-path'], qemu_path=self.options['qemu-path'],
qemu_img_path=self.options['qemu-img-path'], qemu_img_path=self.options['qemu-img-path'],
# XXX Weak password
vnc_passwd=self.options['passwd'] vnc_passwd=self.options['passwd']
) )
......
...@@ -36,7 +36,7 @@ kvm_argument_list = ['%(qemu_path)s', '-enable-kvm', '-net', 'nic,macaddr=%(mac_ ...@@ -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', '-net', 'tap,ifname=%(tap_interface)s,script=no,downscript=no',
'-smp', '%(smp_count)s', '-smp', '%(smp_count)s',
'-m', '%(ram_size)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', '-vnc', '%(vnc_ip)s:1,ipv4,password',
'-boot', 'menu=on', '-boot', 'menu=on',
'-qmp', 'unix:%(socket_path)s,server', '-qmp', 'unix:%(socket_path)s,server',
......
...@@ -18,6 +18,21 @@ ...@@ -18,6 +18,21 @@
"minimum": 1, "minimum": 1,
"maximum": 80 "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": { "nbd-ip": {
......
...@@ -50,9 +50,10 @@ nbd-port = $${slap-parameter:nbd-port} ...@@ -50,9 +50,10 @@ nbd-port = $${slap-parameter:nbd-port}
tap = $${slap-network-information:network-interface} tap = $${slap-network-information:network-interface}
disk-path = $${directory:srv}/virtual.qcow2 disk-path = $${directory:srv}/virtual.qcow2
disk-size = $${slap-parameter:disk-size} disk-size = $${slap-parameter:disk-size}
disk-type = $${slap-parameter:disk-type}
socket-path = $${directory:var}/qmp_socket socket-path = $${directory:var}/qmp_socket
pid-path = $${directory:run}/pid_file pid-path = $${directory:run}/pid_file
smp-count = 1 smp-count = $${slap-parameter:cpu-count}
ram-size = $${slap-parameter:ram-size} ram-size = $${slap-parameter:ram-size}
mac-address = $${create-mac:mac-address} mac-address = $${create-mac:mac-address}
runner-path = $${directory:services}/kvm runner-path = $${directory:services}/kvm
...@@ -174,3 +175,6 @@ nbd_ip = $${:nbd-ip} ...@@ -174,3 +175,6 @@ nbd_ip = $${:nbd-ip}
ram-size = 1024 ram-size = 1024
disk-size = 10 disk-size = 10
disk-type = virtio
cpu-count = 1
\ No newline at end of file
...@@ -119,7 +119,7 @@ command = ...@@ -119,7 +119,7 @@ command =
[template-kvm] [template-kvm]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg.in url = ${:_profile_base_location_}/instance-kvm.cfg.in
md5sum = 67c1980ba1e70b376f2811602991ff09 md5sum = aefed0723c79f4d4b9ed977b73e4bac5
output = ${buildout:directory}/template-kvm.cfg output = ${buildout:directory}/template-kvm.cfg
mode = 0644 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