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

Re: [libvirt] [PATCH 7/8] Perform a handshake during QEMU startup to sync with relabelling



On 11/22/2010 11:09 AM, Daniel P. Berrange wrote:
> Perform a handshake during QEMU startup to allow file relabelling
> to be performed after QEMU has been forked, but before it has
> been exec'd. This is to allow the lock manager to acquire locks
> against the QEMU pid, before relabelling takes place
> 
> * src/qemu/qemu_driver.c: Handshake during QEMU startup
> ---
>  src/qemu/qemu_driver.c |   23 ++++++++++++++---------
>  1 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 0b0b6fe..bf6cd0e 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3683,9 +3683,6 @@ static int qemudSecurityHook(void *data) {
>      if (virSecurityManagerSetProcessLabel(h->driver->securityManager, h->vm) < 0)
>          goto cleanup;
>  
> -    /* XXX temp hack to let disk labelling complete */
> -    sleep(10);
> -
>      ret = 0;
>  
>  cleanup:
> @@ -4097,28 +4094,36 @@ static int qemudStartVMDaemon(virConnectPtr conn,
>      virCommandSetErrorFD(cmd, &logfile);
>      virCommandSetPidFile(cmd, pidfile);
>      virCommandDaemonize(cmd);
> +    virCommandRequireHandshake(cmd);
>  
>      ret = virCommandRun(cmd, NULL);

Oh, I see - you want to daemonize, require handshake, AND do a blocking
virCommandRun.  I see now - __virExec does two forks when daemonize is
requested, and only runs the callback hook in the second (daemon) child,
rather than in the (short-lived) intermediary.  That answers some of my
questions in the previous patch.

> -    VIR_WARN("Executing done %s", vm->def->emulator);
>      VIR_FREE(pidfile);
>  
> -    /* XXX this is bollocks. Need a sync point */
> -    sleep(5);
> +    VIR_WARN0("Waiting for handshake from child");
> +    if (virCommandHandshakeWait(cmd) < 0) {

But it still probably requires virCommand to do some sanity checking
that HandshakeWait is called after the child has been spawned.

>  
> +    VIR_WARN0("Labelling done, completing hanshake to child");

s/hanshake/handshake/

Definitely an improvement.

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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