Commit e9641b86 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Léo-Paul Géneau

software/kvm: Allow many CD-ROMs to boot from

By using virtio-scsi-pci it's possible to attach many CD-ROMs to be boot from.
parent ce643de5
...@@ -55,7 +55,7 @@ md5sum = b7e87479a289f472b634a046b44b5257 ...@@ -55,7 +55,7 @@ md5sum = b7e87479a289f472b634a046b44b5257
[template-kvm-run] [template-kvm-run]
filename = template/template-kvm-run.in filename = template/template-kvm-run.in
md5sum = 84e40e43a74559f3b31677c2b2052360 md5sum = 4a6f149177a453a13436f320f6841518
[template-kvm-controller] [template-kvm-controller]
filename = template/kvm-controller-run.in filename = template/kvm-controller-run.in
......
...@@ -371,6 +371,7 @@ for nbd_ip, nbd_port in nbd_list: ...@@ -371,6 +371,7 @@ for nbd_ip, nbd_port in nbd_list:
'-drive', '-drive',
'file=nbd:[%s]:%s,media=cdrom' % (nbd_ip, nbd_port)]) 'file=nbd:[%s]:%s,media=cdrom' % (nbd_ip, nbd_port)])
else: else:
index = 0
if boot_image_url_select_json_config: if boot_image_url_select_json_config:
# Support boot-image-url-select # Support boot-image-url-select
with open(boot_image_url_select_json_config) as fh: with open(boot_image_url_select_json_config) as fh:
...@@ -380,9 +381,11 @@ else: ...@@ -380,9 +381,11 @@ else:
link = os.path.join(image_config['destination-directory'], image['link']) link = os.path.join(image_config['destination-directory'], image['link'])
if os.path.exists(link) and os.path.islink(link): if os.path.exists(link) and os.path.islink(link):
kvm_argument_list.extend([ kvm_argument_list.extend([
'-drive', '-drive', 'file=%s,media=cdrom,if=none,id=cdrom%s' % (link, index),
'file=%s,media=cdrom' % (link,) '-device', 'virtio-scsi-pci,id=scsi%s' % (index,),
'-device', 'scsi-cd,bus=scsi%s.0,drive=cdrom%s' % (index, index)
]) ])
index += 1
if boot_image_url_list_json_config: if boot_image_url_list_json_config:
# Support boot-image-url-list # Support boot-image-url-list
with open(boot_image_url_list_json_config) as fh: with open(boot_image_url_list_json_config) as fh:
...@@ -392,12 +395,16 @@ else: ...@@ -392,12 +395,16 @@ else:
link = os.path.join(image_config['destination-directory'], image['link']) link = os.path.join(image_config['destination-directory'], image['link'])
if os.path.exists(link) and os.path.islink(link): if os.path.exists(link) and os.path.islink(link):
kvm_argument_list.extend([ kvm_argument_list.extend([
'-drive', '-drive', 'file=%s,media=cdrom,if=none,id=cdrom%s' % (link, index),
'file=%s,media=cdrom' % (link,) '-device', 'virtio-scsi-pci,id=scsi%s' % (index,),
'-device', 'scsi-cd,bus=scsi%s.0,drive=cdrom%s' % (index, index)
]) ])
index += 1
# Always add by default the default image # Always add by default the default image
kvm_argument_list.extend([ kvm_argument_list.extend([
'-drive', 'file=%s,media=cdrom' % default_cdrom_iso '-drive', 'file=%s,media=cdrom,if=none,id=cdrom%s' % (default_cdrom_iso, index),
'-device', 'virtio-scsi-pci,id=scsi%s' % (index,),
'-device', 'scsi-cd,bus=scsi%s.0,drive=cdrom%s' % (index, index)
]) ])
......
...@@ -604,7 +604,7 @@ class TestBootImageUrlList(InstanceTestCase): ...@@ -604,7 +604,7 @@ class TestBootImageUrlList(InstanceTestCase):
# check that the image is NOT YET available in kvm # check that the image is NOT YET available in kvm
self.assertEqual( self.assertEqual(
['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' ['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
'media=cdrom'], 'media=cdrom,if=none,id=cdrom0'],
getRunningImageList() getRunningImageList()
) )
...@@ -618,10 +618,12 @@ class TestBootImageUrlList(InstanceTestCase): ...@@ -618,10 +618,12 @@ class TestBootImageUrlList(InstanceTestCase):
# now the image is available in the kvm, and its above default image # now the image is available in the kvm, and its above default image
self.assertEqual( self.assertEqual(
[ [
'file=/srv/%s/image_001,media=cdrom' % (self.image_directory,), 'file=/srv/%s/image_001,media=cdrom,if=none,id=cdrom0' % (
'file=/srv/%s/image_002,media=cdrom' % (self.image_directory,), self.image_directory,),
'file=/srv/%s/image_002,media=cdrom,if=none,id=cdrom1' % (
self.image_directory,),
'file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' 'file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
'media=cdrom' 'media=cdrom,if=none,id=cdrom2'
], ],
getRunningImageList() getRunningImageList()
) )
...@@ -645,7 +647,7 @@ class TestBootImageUrlList(InstanceTestCase): ...@@ -645,7 +647,7 @@ class TestBootImageUrlList(InstanceTestCase):
# again only default image is available in the running process # again only default image is available in the running process
self.assertEqual( self.assertEqual(
['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' ['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
'media=cdrom'], 'media=cdrom,if=none,id=cdrom0'],
getRunningImageList() getRunningImageList()
) )
...@@ -784,7 +786,7 @@ class TestBootImageUrlSelect(TestBootImageUrlList): ...@@ -784,7 +786,7 @@ class TestBootImageUrlSelect(TestBootImageUrlList):
# check that the image is NOT YET available in kvm # check that the image is NOT YET available in kvm
self.assertEqual( self.assertEqual(
['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' ['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
'media=cdrom'], 'media=cdrom,if=none,id=cdrom0'],
getRunningImageList() getRunningImageList()
) )
...@@ -798,10 +800,12 @@ class TestBootImageUrlSelect(TestBootImageUrlList): ...@@ -798,10 +800,12 @@ class TestBootImageUrlSelect(TestBootImageUrlList):
# now the image is available in the kvm, and its above default image # now the image is available in the kvm, and its above default image
self.assertEqual( self.assertEqual(
[ [
'file=/srv/boot-image-url-select-repository/image_001,media=cdrom', 'file=/srv/boot-image-url-select-repository/image_001,media=cdrom,'
'file=/srv/boot-image-url-list-repository/image_001,media=cdrom', 'if=none,id=cdrom0',
'file=/srv/boot-image-url-list-repository/image_001,media=cdrom,'
'if=none,id=cdrom1',
'file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' 'file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
'media=cdrom' 'media=cdrom,if=none,id=cdrom2'
], ],
getRunningImageList() getRunningImageList()
) )
...@@ -830,7 +834,7 @@ class TestBootImageUrlSelect(TestBootImageUrlList): ...@@ -830,7 +834,7 @@ class TestBootImageUrlSelect(TestBootImageUrlList):
# again only default image is available in the running process # again only default image is available in the running process
self.assertEqual( self.assertEqual(
['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' ['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
'media=cdrom'], 'media=cdrom,if=none,id=cdrom0'],
getRunningImageList() getRunningImageList()
) )
......
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