On 02/15/2014 08:29 PM, Paulo Ricardo Paz Vital wrote:
Hello Aline,
On Fri, 2014-02-14 at 16:47 -0200, Aline Manera wrote:
> 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(a)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.
>
>
I completely agree with you about that, and my first implementation and
tests was pretty close to your suggestion, but I have some important
points to explain:
1) Power systems don't have sound supporyt, so the usage of
<sound model='%(sound_model)s' />
directly in XML will not work. If you look better to the diff in
template_specs on osinfo.py, you can see that only the dictionaries for
x86_64 have the sound_model set up as parameter.
2) During my tests on x86_64, the usage of keyboard (kbd) line didn't
work on guests - the keyboard didn't work. I did all test on Fedora 19
and RHEL6.5 as hosts, creating Fedora 20 and Debian 7 guests (via VNC
and Spice). However, Power systems need this line to enable keyboard in
the guests.
So, in the end of this story, for Power systems we need in XML:
<input type='mouse' bus='usb'/>
<input type='kbd' bus='usb'> </input>
, and for x86_64:
<sound model='ich6' />
<input type='mouse' bus='ps2'/>
Once the set of parameters expected are different between Power and
x86_64, the best solution I found was create a method to check the
template.info() parameters and fill only that necessary to each
architecture.
I still maintain my implementation suggestion as fix to solve the
template differences between these architectures.
Got it.
Thanks for the explanation.
Reviewed-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
>> <memballoon model='virtio' />
>> </devices>
>> </domain>
Best regards,
Paulo Vital.