[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v5 21/36] qemu_process: Use unique directories for QMP processes



On Sun, Dec 02, 2018 at 23:10:15 -0600, Chris Venteicher wrote:
> Multiple QEMU processes for QMP commands can operate concurrently.
> 
> Use a unique directory under libDir for each QEMU processes
> to avoid pidfile and unix socket collision between processes.
> 
> The pid file name is changed from "capabilities.pidfile" to "qmp.pid"
> because we no longer need to avoid a possible clash with a qemu domain
> called "capabilities" now that the processes artifacts are stored in
> their own unique temporary directories.
> 
> "Capabilities" was changed to "qmp" in the pid file name because these
> processes are no longer specific to the capabilities usecase and are
> more generic in terms of being used for any general purpose QMP message
> exchanges with a QEMU process that is not associated with a domain.
> 
> Signed-off-by: Chris Venteicher <cventeic redhat com>
> ---
>  src/qemu/qemu_process.c | 24 ++++++++++++++----------
>  src/qemu/qemu_process.h |  1 +
>  2 files changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index 80b938cc0b..26ba59143d 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -8119,6 +8119,7 @@ qemuProcessQmpFree(qemuProcessQmpPtr proc)
>  
>      VIR_FREE(proc->binary);
>      VIR_FREE(proc->libDir);
> +    VIR_FREE(proc->uniqDir);
>      VIR_FREE(proc->monpath);
>      VIR_FREE(proc->monarg);
>      VIR_FREE(proc->pidfile);
> @@ -8181,33 +8182,33 @@ qemuProcessQmpNew(const char *binary,
>  static int
>  qemuProcessQmpInit(qemuProcessQmpPtr proc)
>  {
> +    char *template = NULL;
>      int ret = -1;
>  
>      VIR_DEBUG("Beginning VM startup process"
>                " proc=%p, emulator=%s",
>                proc, proc->binary);
>  
> -    /* the ".sock" sufix is important to avoid a possible clash with a qemu
> -     * domain called "capabilities"
> -     */
> -    if (virAsprintf(&proc->monpath, "%s/%s", proc->libDir,
> -                    "capabilities.monitor.sock") < 0)
> +    if (virAsprintf(&template, "%s/qemu.XXXXXX", proc->libDir) < 0)

Directories for domains are called "domain-%s" so maybe we could call
directories for QMP processes as "qmp-%s" rather than "qemu.%s".

> +        goto cleanup;
> +
> +    proc->uniqDir = mkdtemp(template);

mkdtemp returns NULL on error and you need to handle it here.

> +
> +    if (virAsprintf(&proc->monpath, "%s/%s", proc->uniqDir,
> +                    "qmp.monitor") < 0)
>          goto cleanup;
...

Jirka


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]