On 1/28/21 12:08 PM, longguang.yue wrote:
Michal, thanks.
i have another question which is related to kata-container.
when there is only one virtiofs-device , how does it do that in guest there are 4
times of virtiofs-mounts that have same src and different targets.
# in guest
[root@kvm kata-containers]# docker exec efda32ca6a93 mount | grep kataShared
kataShared on / type virtiofs (rw,relatime)
kataShared on /etc/resolv.conf type virtiofs (rw,relatime)
kataShared on /etc/hostname type virtiofs (rw,relatime)
kataShared on /etc/hosts type virtiofs (rw,relatime)
I'm not sure how this is related to libvirt, but I'll try to answer
anyway. I believe these mount points are set up by the initrd in the
guest. And this confusion you are seeing is not related to virtiofs at
all. It's non-intuitive way of how 'mount' shows bind mounts. One can
bind mount a file. For instance:
# touch /tmp/a /tmp/b
# mount --bind /tmp/a /tmp/b
# mount | grep /tmp/b
tmpfs on /tmp/b type tmpfs
(rw,nosuid,nodev,seclabel,nr_inodes=409600,inode64)
As you can see, mount doesn't show /tmp/a as the source of the mount
point but the FS associated. And I believe this is what's happening.
kataShared is mount as root, but then those three files from /etc are
bind mounted and thus mount shows kataShared as their source. I agree
it's misleading (and I remember running into this same problem when
developing private namespaces for QEMU VMs - but that's another story).
Michal