[Kimchi-devel] [PATCH] Fix iso streaming functions and feature tests

Royce Lv lvroyce at linux.vnet.ibm.com
Thu Mar 20 08:20:37 UTC 2014


Reviewed-by: Royce Lv<lvroyce at linux.vnet.ibm.com>
On 2014年03月20日 05:04, Rodrigo Trujillo wrote:
> The qemu dns test function was using IP instead of full hostname. This
> makes the function always return True. Also, changed the streaming
> protocols checking function supported by libvirt.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   src/kimchi/featuretests.py |  3 ++-
>   src/kimchi/model/vms.py    | 12 ++++--------
>   src/kimchi/vmtemplate.py   | 13 ++++++++-----
>   3 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py
> index 045f72b..a6a28fa 100644
> --- a/src/kimchi/featuretests.py
> +++ b/src/kimchi/featuretests.py
> @@ -21,6 +21,7 @@ import cherrypy
>   import libvirt
>   import lxml.etree as ET
>   import os
> +import socket
>   import subprocess
>   import threading
>
> @@ -140,7 +141,7 @@ class FeatureTests(object):
>
>       @staticmethod
>       def qemu_iso_stream_dns():
> -        host = cherrypy.server.socket_host
> +        host = socket.getfqdn(cherrypy.server.socket_host)
>           port = cherrypy.server.socket_port
>           cmd = ["qemu-io", "-r", "http://%s:%d/images/icon-fedora.png" %
>                  (host, port), "-c", "'read -v 0 512'"]
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index 79b335c..d29b811 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -202,16 +202,12 @@ class VMsModel(object):
>               with self.objstore as session:
>                   session.store('vm', vm_uuid, {'icon': icon})
>
> -        libvirt_stream = False
> -        if len(self.caps.libvirt_stream_protocols) == 0:
> -            libvirt_stream = True
> -
>           graphics = params.get('graphics')
>           xml = t.to_vm_xml(name, vm_uuid,
> -                          libvirt_stream=libvirt_stream,
> -                          qemu_stream_dns=self.caps.qemu_stream_dns,
> -                          graphics=graphics,
> -                          volumes=vol_list)
> +                   libvirt_stream_protocols=self.caps.libvirt_stream_protocols,
> +                   qemu_stream_dns=self.caps.qemu_stream_dns,
> +                   graphics=graphics,
> +                   volumes=vol_list)
>
>           try:
>               conn.defineXML(xml.encode('utf-8'))
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index 003e524..f810df6 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -81,7 +81,7 @@ class VMTemplate(object):
>           except IsoFormatError:
>               raise InvalidParameter("KCHISO0001E", {'filename': iso})
>
> -    def _get_cdrom_xml(self, libvirt_stream, qemu_stream_dns):
> +    def _get_cdrom_xml(self, libvirt_stream_protocols, qemu_stream_dns):
>           bus = self.info['cdrom_bus']
>           dev = "%s%s" % (self._bus_to_dev[bus],
>                           string.lowercase[self.info['cdrom_index']])
> @@ -133,7 +133,7 @@ class VMTemplate(object):
>               hostname = socket.gethostbyname(hostname)
>               url = protocol + "://" + hostname + ":" + str(port) + url_path
>
> -        if not libvirt_stream:
> +        if protocol not in libvirt_stream_protocols:
>               return qemu_stream_cmdline % {'url': url, 'bus': bus}
>
>           params = {'protocol': protocol, 'url_path': url_path,
> @@ -281,9 +281,12 @@ class VMTemplate(object):
>               params['disks'] = self._get_disks_xml(vm_uuid)
>
>           qemu_stream_dns = kwargs.get('qemu_stream_dns', False)
> -        libvirt_stream = kwargs.get('libvirt_stream', False)
> -        cdrom_xml = self._get_cdrom_xml(libvirt_stream, qemu_stream_dns)
> -        if not libvirt_stream and params.get('iso_stream', False):
> +        libvirt_stream_protocols = kwargs.get('libvirt_stream_protocols', [])
> +        cdrom_xml = self._get_cdrom_xml(libvirt_stream_protocols,
> +                                        qemu_stream_dns)
> +
> +        if not urlparse.urlparse(self.info['cdrom']).scheme in \
> +            libvirt_stream_protocols and params.get('iso_stream', False):
>               params['qemu-namespace'] = QEMU_NAMESPACE
>               params['qemu-stream-cmdline'] = cdrom_xml
>           else:




More information about the Kimchi-devel mailing list