[Kimchi-devel] [PATCH v2 3/4] Define the USB xhci controller in the template for Power Systems

Aline Manera alinefm at linux.vnet.ibm.com
Wed Aug 5 12:23:54 UTC 2015



On 10/07/2015 15:32, Jose Ricardo Ziviani wrote:
>   - When creating VMs using Kimchi in a Power System, the USB xhci
>     controller is defined by default to have PCI hotplug support.
>
> Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
> ---
>   src/kimchi/vmtemplate.py | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
>
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index 79e04ed..3e42971 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -22,6 +22,7 @@ import stat
>   import time
>   import urlparse
>   import uuid
> +import platform
>
>   from lxml import etree
>   from lxml.builder import E
> @@ -287,6 +288,19 @@ class VMTemplate(object):
>                              self.info.get('memory') << 10,
>                              cpu_topo)
>
> +    def _get_usb_controller(self):
> +        # powerkvm systems must include xhci controller model
> +        distro, _, _ = platform.linux_distribution()
> +        if distro != "IBM_PowerKVM":
> +            return ''
> +
> +        return """
> +        <controller type='usb' index='0' model='nec-xhci'>
> +            <address type='pci' domain='0x0000'
> +            bus='0x00' slot='0x0f' function='0x0'/>
> +        </controller>
> +        """
> +

We are in a process to remove all the XML strings from Kimchi code and 
build them using lxml.builder
So, please, do it for the controller XML. We have a module named 
xmlutils which handle all the XML manipulation.

>       def to_vm_xml(self, vm_name, vm_uuid, **kwargs):
>           params = dict(self.info)
>           params['name'] = vm_name
> @@ -323,6 +337,8 @@ class VMTemplate(object):
>           elif params['slots'] == 0:
>               params['slots'] = 1
>
> +        params['usb_controller'] = self._get_usb_controller()
> +
>           xml = """
>           <domain type='%(domain)s'>
>             %(qemu-stream-cmdline)s
> @@ -352,6 +368,7 @@ class VMTemplate(object):
>               %(networks)s
>               %(graphics)s
>               %(input_output)s
> +            %(usb_controller)s
>               <memballoon model='virtio' />
>             </devices>
>           </domain>




More information about the Kimchi-devel mailing list