[Kimchi-devel] [PATCH 2/2] Support VM template for Power machine

Aline Manera alinefm at linux.vnet.ibm.com
Fri Dec 27 13:47:19 UTC 2013


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 12/23/2013 10:54 PM, 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
>
>
> +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
> +
> +
>   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