[Kimchi-devel] [PATCH] [Kimchi 1/4] Move unix socket files from /tmp to /run/wok

Aline Manera alinefm at linux.vnet.ibm.com
Thu Mar 10 18:16:52 UTC 2016



On 03/09/2016 04:04 PM, Jose Ricardo Ziviani wrote:
>   - /run is a temporary fs (tmpfs) more adequate to store this kind of
>     file.
>
> Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
> ---
>   i18n.py          |  1 +
>   model/vms.py     | 11 ++++++++++-
>   serialconsole.py |  5 +++--
>   3 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/i18n.py b/i18n.py
> index 707b74b..e219857 100644
> --- a/i18n.py
> +++ b/i18n.py
> @@ -135,6 +135,7 @@ messages = {
>       "KCHVM0078E": _("Memory or Maximum Memory value is higher than amount supported by the host: %(memHost)sMiB."),
>       "KCHVM0079E": _("Memory or Maximum Memory value is higher than maximum amount recommended: %(value)sTiB"),
>       "KCHVM0080E": _("Cannot update Maximum Memory when guest is running."),

> +    "KCHVM0081E": _("Impossible to create /run/wok directory."),

If you created it on run time, when uninstalling Kimchi it will remain 
in the system.

>       "KCHVMHDEV0001E": _("VM %(vmid)s does not contain directly assigned host device %(dev_name)s."),
>       "KCHVMHDEV0002E": _("The host device %(dev_name)s is not allowed to directly assign to VM."),
> diff --git a/model/vms.py b/model/vms.py
> index 195c879..cd77575 100644
> --- a/model/vms.py
> +++ b/model/vms.py
> @@ -1467,8 +1467,17 @@ class VMModel(object):
>           if not self._vm_check_serial(name):
>               raise OperationFailed("KCHVM0076E", {'name': name})
>
> +        if not os.path.isdir(serialconsole.BASE_DIRECTORY):
> +            try:
> +                os.mkdir(serialconsole.BASE_DIRECTORY)
> +
> +            except OSError as e:

> +                wok_log.error(e.message)
> +                raise OperationFailed("KCHVM0081E")

Every exception raised is always logged into the log file so you don't 
need to do that.

> +
>           websocket.add_proxy_token(name.encode('utf-8')+'-console',
> -                                  '/tmp/%s' % name.encode('utf-8'), True)
> +                                  os.path.join(serialconsole.BASE_DIRECTORY,
> +                                               name.encode('utf-8')), True)
>
>           try:
>               self._serial_procs.append(
> diff --git a/serialconsole.py b/serialconsole.py
> index 1eb48b1..47f4c2d 100644
> --- a/serialconsole.py
> +++ b/serialconsole.py
> @@ -35,6 +35,7 @@ from wok.plugins.kimchi import model
>   SOCKET_QUEUE_BACKLOG = 0
>   DEFAULT_TIMEOUT = 120  # seconds
>   CTRL_Q = '\x11'
> +BASE_DIRECTORY = '/run/wok'
>
>
>   class SocketServer(Process):
> @@ -61,13 +62,13 @@ class SocketServer(Process):
>       def __init__(self, guest_name, URI):
>           """Constructs a unix socket server.
>
> -        Listens to connections on /tmp/<guest name>.
> +        Listens to connections on /run/wok/<guest name>.
>           """
>           Process.__init__(self)
>
>           self._guest_name = guest_name
>           self._uri = URI
> -        self._server_addr = '/tmp/%s' % guest_name
> +        self._server_addr = os.path.join(BASE_DIRECTORY, guest_name)
>           if os.path.exists(self._server_addr):
>               wok_log.error('Cannot connect to %s due to an existing '
>                             'connection', guest_name)




More information about the Kimchi-devel mailing list