[libvirt] [PATCH 09/23] Add support for disks with LXC

Gao feng gaofeng at cn.fujitsu.com
Fri Dec 14 07:15:16 UTC 2012


On 2012/12/01 04:26, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Currently LXC guests can be given arbitrary pre-mounted
> filesystems, however, for some usecases it is more appropriate
> to provide block devices which the container can mount itself.
> This first impl only allows for <disk type='block'>, in other
> words exposing a host disk device to a container. Since LXC
> does not have device namespace virtualization, we are cheating
> a little bit. If the XML specifies /dev/sdc4 to be given to
> the container as /dev/sda1, when we do the mknod /dev/sda1
> in the container's /dev, we actually use the major:minor
> number of /dev/sdc4, not /dev/sda1.
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  src/lxc/lxc_cgroup.c    |  18 +++++++++
>  src/lxc/lxc_container.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 122 insertions(+)
> 
> diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
> index 767ef26..0636869 100644
> --- a/src/lxc/lxc_cgroup.c
> +++ b/src/lxc/lxc_cgroup.c
> @@ -332,6 +332,24 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def,
>          }
>      }
>  
> +    for (i = 0 ; i < def->ndisks ; i++) {
> +        if (def->disks[i]->type != VIR_DOMAIN_DISK_TYPE_BLOCK)
> +            continue;

You return error when type != VIR_DOMAIN_DISK_TYPE_BLOCK in lxcContainerSetupDisk,
So I think you can return error immediately here too.

Just this little advice.

ACK.




More information about the libvir-list mailing list