[Kimchi-devel] [PATCH 1/6 - V2] [Memory HotPlug] Feature test to check support to memory devices

Aline Manera alinefm at linux.vnet.ibm.com
Mon Jun 1 12:20:24 UTC 2015


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

On 28/05/2015 10:59, Rodrigo Trujillo wrote:
> This patch adds a new feature test to check if the host libvirt
> version supports memory devices attachment. This support is provided
> since libvirt 1.2.14 and is the base to make memory hotplug work.
> When libvirt does not support memory devices, it is going to fail when
> we try to attach it, raising the libvirt.libvirtError:
> "unsupported configuration: unknown device type 'memory'"
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/config.py       |  3 +++
>   src/kimchi/model/featuretests.py | 43 ++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 46 insertions(+)
>
> diff --git a/src/kimchi/model/config.py b/src/kimchi/model/config.py
> index 687531b..8735beb 100644
> --- a/src/kimchi/model/config.py
> +++ b/src/kimchi/model/config.py
> @@ -55,6 +55,7 @@ class CapabilitiesModel(object):
>           self.fc_host_support = False
>           self.metadata_support = False
>           self.kernel_vfio = False
> +        self.mem_hotplug_support = False
>
>           # Subscribe function to set host capabilities to be run when cherrypy
>           # server is up
> @@ -91,6 +92,7 @@ class CapabilitiesModel(object):
>           self.fc_host_support = FeatureTests.libvirt_support_fc_host(conn)
>           self.metadata_support = FeatureTests.has_metadata_support(conn)
>           self.kernel_vfio = FeatureTests.kernel_support_vfio()
> +        self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn)
>
>           self.libvirt_stream_protocols = []
>           for p in ['http', 'https', 'ftp', 'ftps', 'tftp']:
> @@ -139,6 +141,7 @@ class CapabilitiesModel(object):
>                   'auth': kconfig.get("authentication", "method"),
>                   'kernel_vfio': self.kernel_vfio,
>                   'nm_running': FeatureTests.is_nm_running(),
> +                'mem_hotplug_support': self.mem_hotplug_support
>                   }
>
>
> diff --git a/src/kimchi/model/featuretests.py b/src/kimchi/model/featuretests.py
> index 9400151..86e918a 100644
> --- a/src/kimchi/model/featuretests.py
> +++ b/src/kimchi/model/featuretests.py
> @@ -63,6 +63,25 @@ SIMPLE_VM_XML = """
>     </os>
>   </domain>"""
>
> +MAXMEM_VM_XML = """
> +<domain type='%(domain)s'>
> +  <name>%(name)s</name>
> +  <maxMemory slots='1' unit='KiB'>20480</maxMemory>
> +  <memory unit='KiB'>10240</memory>
> +  <os>
> +    <type arch='%(arch)s'>hvm</type>
> +    <boot dev='hd'/>
> +  </os>
> +</domain>"""
> +
> +DEV_MEM_XML = """
> +<memory model='dimm'>
> +  <target>
> +    <size unit='KiB'>10240</size>
> +    <node>0</node>
> +  </target>
> +</memory>"""
> +
>   SCSI_FC_XML = """
>   <pool type='scsi'>
>     <name>%(name)s</name>
> @@ -207,3 +226,27 @@ class FeatureTests(object):
>               return False
>
>           return True
> +
> +    @staticmethod
> +    def has_mem_hotplug_support(conn):
> +        '''
> +        A memory device can be hot-plugged or hot-unplugged since libvirt
> +        version 1.2.14.
> +        '''
> +        with RollbackContext() as rollback:
> +            FeatureTests.disable_libvirt_error_logging()
> +            rollback.prependDefer(FeatureTests.enable_libvirt_error_logging)
> +            conn_type = conn.getType().lower()
> +            domain_type = 'test' if conn_type == 'test' else 'kvm'
> +            arch = 'i686' if conn_type == 'test' else platform.machine()
> +            arch = 'ppc64' if arch == 'ppc64le' else arch
> +            dom = conn.defineXML(MAXMEM_VM_XML % {'name': FEATURETEST_VM_NAME,
> +                                                  'domain': domain_type,
> +                                                  'arch': arch})
> +            rollback.prependDefer(dom.undefine)
> +            try:
> +                dom.attachDeviceFlags(DEV_MEM_XML,
> +                                      libvirt.VIR_DOMAIN_MEM_CONFIG)
> +                return True
> +            except libvirt.libvirtError:
> +                return False




More information about the Kimchi-devel mailing list