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

Re: [libvirt] [PATCH] Ensure root filesystem is mounted if a file/block mount.



On 22.03.2013 15:24, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> 
> For a root filesystem with type=file or type=block, the LXC
> container was forgetting to actually mount it, before doing
> the pivot root step.
> 
> Signed-off-by: Daniel P. Berrange <berrange redhat com>
> ---
>  src/lxc/lxc_container.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index be9bc6c..002dba1 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -105,6 +105,9 @@ struct __lxc_child_argv {
>      int handshakefd;
>  };
>  
> +static int lxcContainerMountFSBlock(virDomainFSDefPtr fs,
> +                                    const char *srcprefix);
> +

1: ^^^

>  
>  /*
>   * reboot(LINUX_REBOOT_CMD_CAD_ON) will return -EINVAL
> @@ -406,6 +409,51 @@ static int lxcContainerChildMountSort(const void *a, const void *b)
>  # define MS_SLAVE                (1<<19)
>  #endif
>  
> +static int lxcContainerPrepareRoot(virDomainDefPtr def,
> +                                   virDomainFSDefPtr root)
> +{
> +    char *dst;
> +    char *tmp;
> +
> +    if (root->type == VIR_DOMAIN_FS_TYPE_MOUNT)
> +        return 0;
> +
> +    if (root->type == VIR_DOMAIN_FS_TYPE_FILE) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Unexpected root filesystem without loop device"));
> +        return -1;
> +    }
> +
> +    if (root->type != VIR_DOMAIN_FS_TYPE_BLOCK) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                       _("Unsupported root filesystem type %s"),
> +                       virDomainFSTypeToString(root->type));
> +        return -1;
> +    }
> +
> +    if (virAsprintf(&dst, "%s/%s.root",
> +                    LXC_STATE_DIR, def->name) < 0) {
> +        virReportOOMError();
> +        return -1;
> +    }
> +
> +    tmp = root->dst;
> +    root->dst = dst;
> +
> +    if (lxcContainerMountFSBlock(root, "") < 0) {
> +        root->dst = tmp;
> +        VIR_FREE(dst);
> +        return -1;
> +    }
> +
> +    root->dst = tmp;
> +    root->type = VIR_DOMAIN_FS_TYPE_MOUNT;
> +    VIR_FREE(root->src);
> +    root->src = dst;
> +
> +    return 0;
> +}
> +

Any chance you can move this after the lxcContainerMountFSBlock() and
hence avoid [1]? Not a show stopper though. ACK.

Michal


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