canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.38k stars 931 forks source link

unix-char devices (serial/UART) added to container shown as mounted block devices inside the container #6793

Closed mirko closed 4 years ago

mirko commented 4 years ago

Required information

Issue description

When adding a unix-char device to a container, it's listed as mounted block device. To be more precise: the block device the hypervisor's root file system is on.

Steps to reproduce

$ mount | grep root /dev/mapper/HV-root on / type ext4 [..] $ lxc config device add VM ttyUSB0 unix-char path=/dev/ttyUSB0 $ ssh VM.lxc "df -h | grep ttyUSB" /dev/mapper/HV-root 733G 694G 1.7G 100% /dev/ttyUSB0

brauner commented 4 years ago

That's really not something we can fix since this is how mounts are exposed by the kernel, i.e. if you were to setup any mount across mount namespaces, even if the origin mount is neither accessible nor visible inside your mount namespace, you can still see it as part of the mount you setup:

└─/dev/ttyS0                        /dev/mapper/sda3_crypt[/var/lib/lxd/devices/f1/unix.ddd.dev-ttyS0] ext4        rw,relatime,errors=remount-ro

findmnt has the same behavior. Really nothing we can do about it short of changing how mountinfo works which is a nogo given that it would be a regression.

mirko commented 4 years ago

Ok, thanks for the heads up. All I can say is, that it's really confusing to see the block device your root file system of the physical host is on, incl. all its metadata (df -h shows all the familiar details about it), being mounted to a character device being passed-through.

stgraber commented 4 years ago

Yeah, unfortunately that's really the only way we can make device nodes appear in containers.