mirror of https://gitee.com/openkylin/libvirt.git
conf: Avoid formatting auto-generated DAC labels
To avoid backward compatibility issues, this patch suppresses auto-generated DAC labels from XML. This change affects commands such as dumpxml and save. Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
This commit is contained in:
parent
86e205a24f
commit
990e46c454
|
@ -11244,10 +11244,16 @@ virSecurityLabelDefFormat(virBufferPtr buf, virSecurityLabelDefPtr def)
|
||||||
if (def->type == VIR_DOMAIN_SECLABEL_DEFAULT)
|
if (def->type == VIR_DOMAIN_SECLABEL_DEFAULT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* To avoid backward compatibility issues, suppress DAC labels that are
|
||||||
|
* automatically generated.
|
||||||
|
*/
|
||||||
|
if (STREQ_NULLABLE(def->model, "dac") && def->implicit)
|
||||||
|
return;
|
||||||
|
|
||||||
virBufferAsprintf(buf, "<seclabel type='%s'",
|
virBufferAsprintf(buf, "<seclabel type='%s'",
|
||||||
sectype);
|
sectype);
|
||||||
|
|
||||||
if (def->model)
|
if (def->model && STRNEQ(def->model, "none"))
|
||||||
virBufferEscapeString(buf, " model='%s'", def->model);
|
virBufferEscapeString(buf, " model='%s'", def->model);
|
||||||
|
|
||||||
if (def->type == VIR_DOMAIN_SECLABEL_NONE) {
|
if (def->type == VIR_DOMAIN_SECLABEL_NONE) {
|
||||||
|
@ -14995,6 +15001,7 @@ virSecurityLabelDefPtr
|
||||||
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model)
|
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
virSecurityLabelDefPtr seclabel = NULL;
|
||||||
|
|
||||||
if (def == NULL || model == NULL)
|
if (def == NULL || model == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -15006,7 +15013,11 @@ virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model)
|
||||||
return def->seclabels[i];
|
return def->seclabels[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return virDomainDefAddSecurityLabelDef(def, model);
|
seclabel = virDomainDefAddSecurityLabelDef(def, model);
|
||||||
|
if (seclabel)
|
||||||
|
seclabel->implicit = true;
|
||||||
|
|
||||||
|
return seclabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
virSecurityDeviceLabelDefPtr
|
virSecurityDeviceLabelDefPtr
|
||||||
|
|
|
@ -295,6 +295,7 @@ struct _virSecurityLabelDef {
|
||||||
char *baselabel; /* base name of label string */
|
char *baselabel; /* base name of label string */
|
||||||
int type; /* virDomainSeclabelType */
|
int type; /* virDomainSeclabelType */
|
||||||
bool norelabel;
|
bool norelabel;
|
||||||
|
bool implicit; /* true if seclabel is auto-added */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue