20.20. Security Label
<seclabel>element allows control over the operation of the security drivers. There are three basic modes of operation,
'dynamic'where libvirt automatically generates a unique security label,
'static'where the application/administrator chooses the labels, or
'none'where confinement is disabled. With dynamic label generation, libvirt will always automatically relabel any resources associated with the virtual machine. With static label assignment, by default, the administrator or application must ensure labels are set correctly on any resources. However, automatic relabeling can be enabled if desired.
modelValid input XML configurations for the top-level security label are:
<seclabel type='dynamic' model='selinux'/> <seclabel type='dynamic' model='selinux'> <baselabel>system_u:system_r:my_svirt_t:s0</baselabel> </seclabel> <seclabel type='static' model='selinux' relabel='no'> <label>system_u:system_r:svirt_t:s0:c392,c662</label> </seclabel> <seclabel type='static' model='selinux' relabel='yes'> <label>system_u:system_r:svirt_t:s0:c392,c662</label> </seclabel> <seclabel type='none'/>
Figure 20.69. Security label
'type'attribute is provided in the input XML, then the security driver default setting will be used, which may be either
'dynamic'. If a
<baselabel>is set but no
'type'is set, then the type is presumed to be
'dynamic'. When viewing the XML for a running guest virtual machine with automatic resource relabeling active, an additional XML element,
imagelabel, will be included. This is an output-only element, so will be ignored in user supplied XML documents.
noneto determine whether libvirt automatically generates a unique security label or not.
model- A valid security model name, matching the currently activated security model
no. This must always be
yesif dynamic label assignment is used. With static label assignment it will default to
<label>- If static labelling is used, this must specify the full security label to assign to the virtual domain. The format of the content depends on the security driver in use:
SELinux: a SELinux context.
AppArmor: an AppArmor profile.
DAC: owner and group separated by colon. They can be defined both as user/group names or uid/gid. The driver will first try to parse these values as names, but a leading plus sign can used to force the driver to parse them as uid or gid.
<baselabel>- If dynamic labelling is used, this can optionally be used to specify the base security label. The format of the content depends on the security driver in use.
<imagelabel>- This is an output only element, which shows the security label used on resources associated with the virtual domain. The format of the content depends on the security driver in use When relabeling is in effect, it is also possible to fine-tune the labeling done for specific source file names, by either disabling the labeling (useful if the file lives on NFS or other file system that lacks security labeling) or requesting an alternate label (useful when a management application creates a special label to allow sharing of some, but not all, resources between domains). When a seclabel element is attached to a specific path rather than the top-level domain assignment, only the attribute relabel or the sub-element label are supported.