[Kimchi-devel] [PATCH 2/2] Support VM template for Power machine
Mark Wu
wudxw at linux.vnet.ibm.com
Fri Dec 27 11:57:53 UTC 2013
On 12/27/2013 12:01 AM, Aline Manera wrote:
> On 12/24/2013 12:41 AM, Mark Wu wrote:
>> VM on power machine requires different parameters from X86 machine.
>> So kimchi should provide different template according to the
>> architecture.
>> IDE bus is not available on power platform. So change the device
>> bus of cdrom to scsi instead of ide for VM on power. The same
>> problem exists for old nic model, and change it to rtl8139 instead.
>>
>> Signed-off-by: Mark Wu <wudxw at linux.vnet.ibm.com>
>> ---
>> src/kimchi/osinfo.py | 27 +++++++++++++++++++++++----
>> 1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
>> index b141d9e..62c1bbf 100644
>> --- a/src/kimchi/osinfo.py
>> +++ b/src/kimchi/osinfo.py
>> @@ -25,6 +25,9 @@ import os
>> from distutils.version import LooseVersion
>>
>
> It seems this patch wasn't made based on master branch. Or I am
> missing something.
I am not sure if it's valid for current master code. I will try to
rebase it if necessary.
>
>> +SUPPORTED_ARCHS = {'x86': ('i386', 'x86_64'), 'power': ('ppc',
>> 'ppc64')}
>> +
>> +
>> common_spec = {'cpus': 1, 'cpu_cores': 1, 'cpu_threads': 1,
>> 'memory': 1024,
>> 'disks': [{'index': 0, 'size': 10}], 'cdrom_bus':
>> 'ide',
>> 'cdrom_index': 2}
>> @@ -33,7 +36,15 @@ common_spec = {'cpus': 1, 'cpu_cores': 1,
>> 'cpu_threads': 1, 'memory': 1024,
>> modern_spec = dict(common_spec, disk_bus='virtio', nic_model='virtio')
>>
>>
>> -old_spec = dict(common_spec, disk_bus='ide', nic_model='e1000')
>> +template_specs = {'x86': {'old': dict(common_spec, disk_bus='ide',
>> + nic_model='e1000'),
>> + 'modern': dict(common_spec,
>> disk_bus='virtio',
>> + nic_model='virtio')},
>> + 'power': {'old': dict(common_spec, disk_bus='scsi',
>> + nic_model='rtl8139',
>> cdrom_bus='scsi'),
>> + 'modern': dict(common_spec,
>> disk_bus='virtio',
>> + nic_model='virtio',
>> + cdrom_bus='scsi')}}
>>
>>
>> modern_version_bases = {'debian': '6.0', 'ubuntu': '7.10',
>> 'opensuse': '10.3',
>> @@ -61,6 +72,13 @@ defaults = {'network': 'default', 'storagepool':
>> '/storagepools/default',
>> 'domain': 'kvm', 'arch': os.uname()[4]
>> }
>>
>> +
>> +def _get_arch():
>> + for arch, sub_archs in SUPPORTED_ARCHS.iteritems():
>> + if os.uname()[4] in sub_archs:
>> + return arch
>> +
>> +
>
> You can use platform.machine() to get arch info
>
> >>> import platform
> >>> platform.machine()
> 'x86_64'
>
Yes, but platform.machine just use uname. We can avoid an unnecessary
import by using uname.
>
>> def lookup(distro, version):
>> """
>> Lookup all parameters needed to run a VM of a known or unknown
>> operating
>> @@ -72,18 +90,19 @@ def lookup(distro, version):
>> params['os_distro'] = distro
>> params['os_version'] = version
>> params['cdrom'] = isolinks.get(distro, {}).get(version, '')
>> + arch = _get_arch()
>>
>> for name, base_version in modern_version_bases.iteritems():
>> if name == distro:
>> params['icon'] = 'images/icon-%s.png' % distro
>> if LooseVersion(version) >= LooseVersion(base_version):
>> - params.update(modern_spec)
>> + params.update(template_specs[arch]['modern'])
>> else:
>> - params.update(old_spec)
>> + params.update(template_specs[arch]['old'])
>> break
>> else:
>> params['icon'] = 'images/icon-vm.png'
>> params['os_distro'] = params['os_version'] = "unknown"
>> - params.update(old_spec)
>> + params.update(template_specs[arch]['old'])
>>
>> return params
>
More information about the Kimchi-devel
mailing list