[Kimchi-devel] [PATCH] Setup VM's input and output template for Power systems.

Aline Manera alinefm at linux.vnet.ibm.com
Fri Feb 14 18:47:56 UTC 2014


On 02/14/2014 02:05 PM, Paulo Vital wrote:
> Setup the bus for keyboard and mouse to 'usb' by default and prevent the
> sound configuration to be added for new Power guests.
>
> Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
> ---
>   src/kimchi/osinfo.py     | 13 ++++++++-----
>   src/kimchi/vmtemplate.py | 23 ++++++++++++++++++++++-
>   2 files changed, 30 insertions(+), 6 deletions(-)
>
> diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
> index f92db3d..eff8070 100644
> --- a/src/kimchi/osinfo.py
> +++ b/src/kimchi/osinfo.py
> @@ -32,21 +32,24 @@ 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}
> +               'cdrom_index': 2, 'mouse_bus': 'ps2'}
>
>
>   modern_spec = dict(common_spec, disk_bus='virtio', nic_model='virtio')
>
>
>   template_specs = {'x86': {'old': dict(common_spec, disk_bus='ide',
> -                                      nic_model='e1000'),
> +                                      nic_model='e1000', sound_model= 'ich6'),
>                             'modern': dict(common_spec, disk_bus='virtio',
> -                                         nic_model='virtio')},
> +                                         nic_model='virtio',
> +                                         sound_model= 'ich6')},
>                     'power': {'old': dict(common_spec, disk_bus='scsi',
> -                                        nic_model='rtl8139', cdrom_bus='scsi'),
> +                                        nic_model='rtl8139', cdrom_bus='scsi',
> +                                        kbd_bus='usb', mouse_bus='usb'),
>                               'modern': dict(common_spec, disk_bus='virtio',
>                                              nic_model='virtio',
> -                                           cdrom_bus='scsi')}}
> +                                           cdrom_bus='scsi', kbd_bus='usb',
> +                                           mouse_bus='usb')}}
>
>
>   modern_version_bases = {'debian': '6.0', 'ubuntu': '7.10', 'opensuse': '10.3',
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index 999473c..de52f40 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -241,11 +241,32 @@ class VMTemplate(object):
>               networks += network % net_info
>           return networks
>
> +    def _get_input_output_xml(self):
> +        sound = """
> +            <sound model='%(sound_model)s' />
> +        """
> +        mouse = """
> +            <input type='mouse' bus='%(mouse_bus)s'/>
> +        """
> +        keyboard = """
> +            <input type='kbd' bus='%(kbd_bus)s'> </input>
> +        """
> +

> +        input_output = ""
> +        if 'mouse_bus' in self.info.keys():
> +            input_output += mouse % self.info
> +        if 'kbd_bus' in self.info.keys():
> +            input_output += keyboard % self.info
> +        if 'sound_model' in self.info.keys():
> +            input_output += sound % self.info
> +        return input_output
> +

As you add the default values in osinfo.py all templates will have those 
information
So you don't need this function. You can add it directly on vm xml. Look 
below


>       def to_vm_xml(self, vm_name, vm_uuid, **kwargs):
>           params = dict(self.info)
>           params['name'] = vm_name
>           params['uuid'] = vm_uuid
>           params['networks'] = self._get_networks_xml()
> +        params['input_output'] = self._get_input_output_xml()
>           params['qemu-namespace'] = ''
>           params['cdroms'] = ''
>           params['qemu-stream-cmdline'] = ''
> @@ -294,7 +315,7 @@ class VMTemplate(object):
>               %(cdroms)s
>               %(networks)s
>               %(graphics)s
> -            <sound model='ich6' />
> +            %(input_output)s

Instead of it, add:


     <sound model='%(sound_model)s' />
     <input type='mouse' bus='%(mouse_bus)s'/>
     <input type='kbd' bus='%(kbd_bus)s'> </input>

This xml is already fill up with template.info() data.


>               <memballoon model='virtio' />
>             </devices>
>           </domain>




More information about the Kimchi-devel mailing list