提交 83c896c8 编写于 作者: P Peter Krempa

util: Don't require full disk definition when getting imagelabels

The image labels are stored in the virStorageSource struct. Convert the
virDomainDiskDefGetSecurityLabelDef helper not to use the full disk def
and move it appropriately.
上级 5aadf437
......@@ -19489,20 +19489,6 @@ virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model)
return seclabel;
}
virSecurityDeviceLabelDefPtr
virDomainDiskDefGetSecurityLabelDef(virDomainDiskDefPtr def, const char *model)
{
size_t i;
if (def == NULL)
return NULL;
for (i = 0; i < def->src->nseclabels; i++) {
if (STREQ_NULLABLE(def->src->seclabels[i]->model, model))
return def->src->seclabels[i];
}
return NULL;
}
virSecurityDeviceLabelDefPtr
virDomainChrDefGetSecurityLabelDef(virDomainChrDefPtr def, const char *model)
......
......@@ -2518,9 +2518,6 @@ virDomainObjGetState(virDomainObjPtr obj, int *reason)
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);
virSecurityDeviceLabelDefPtr
virDomainDiskDefGetSecurityLabelDef(virDomainDiskDefPtr def, const char *model);
virSecurityDeviceLabelDefPtr
virDomainChrDefGetSecurityLabelDef(virDomainChrDefPtr def, const char *model);
......
......@@ -210,7 +210,6 @@ virDomainDiskCopyOnReadTypeToString;
virDomainDiskDefAssignAddress;
virDomainDiskDefForeachPath;
virDomainDiskDefFree;
virDomainDiskDefGetSecurityLabelDef;
virDomainDiskDefNew;
virDomainDiskDeviceTypeToString;
virDomainDiskDiscardTypeToString;
......@@ -1900,6 +1899,7 @@ virStorageSourceClear;
virStorageSourceClearBackingStore;
virStorageSourceFree;
virStorageSourceGetActualType;
virStorageSourceGetSecurityLabelDef;
virStorageSourceNewFromBacking;
virStorageSourcePoolDefFree;
virStorageSourcePoolModeTypeFromString;
......
......@@ -2413,7 +2413,7 @@ qemuDomainGetImageIds(virQEMUDriverConfigPtr cfg,
vmlabel->label)
virParseOwnershipIds(vmlabel->label, uid, gid);
if ((disklabel = virDomainDiskDefGetSecurityLabelDef(disk, "dac")) &&
if ((disklabel = virStorageSourceGetSecurityLabelDef(disk->src, "dac")) &&
disklabel->label)
virParseOwnershipIds(disklabel->label, uid, gid);
}
......
......@@ -302,7 +302,7 @@ virSecurityDACSetSecurityFileLabel(virDomainDiskDefPtr disk,
uid_t user;
gid_t group;
disk_seclabel = virDomainDiskDefGetSecurityLabelDef(disk,
disk_seclabel = virStorageSourceGetSecurityLabelDef(disk->src,
SECURITY_DAC_NAME);
if (disk_seclabel && disk_seclabel->norelabel)
......@@ -369,7 +369,7 @@ virSecurityDACRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
if (secdef && secdef->norelabel)
return 0;
disk_seclabel = virDomainDiskDefGetSecurityLabelDef(disk,
disk_seclabel = virStorageSourceGetSecurityLabelDef(disk->src,
SECURITY_DAC_NAME);
if (disk_seclabel && disk_seclabel->norelabel)
......
......@@ -1134,7 +1134,7 @@ virSecuritySELinuxRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
if (seclabel == NULL)
return 0;
disk_seclabel = virDomainDiskDefGetSecurityLabelDef(disk,
disk_seclabel = virStorageSourceGetSecurityLabelDef(disk->src,
SECURITY_SELINUX_NAME);
if (seclabel->norelabel || (disk_seclabel && disk_seclabel->norelabel))
return 0;
......@@ -1202,7 +1202,7 @@ virSecuritySELinuxSetSecurityFileLabel(virDomainDiskDefPtr disk,
virSecurityLabelDefPtr secdef = cbdata->secdef;
virSecuritySELinuxDataPtr data = virSecurityManagerGetPrivateData(cbdata->manager);
disk_seclabel = virDomainDiskDefGetSecurityLabelDef(disk,
disk_seclabel = virStorageSourceGetSecurityLabelDef(disk->src,
SECURITY_SELINUX_NAME);
if (disk_seclabel && disk_seclabel->norelabel)
......
......@@ -1496,6 +1496,21 @@ virStorageNetHostDefCopy(size_t nhosts,
}
virSecurityDeviceLabelDefPtr
virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
const char *model)
{
size_t i;
for (i = 0; i < src->nseclabels; i++) {
if (STREQ_NULLABLE(src->seclabels[i]->model, model))
return src->seclabels[i];
}
return NULL;
}
void
virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def)
{
......
......@@ -312,6 +312,10 @@ int virStorageFileGetLVMKey(const char *path,
int virStorageFileGetSCSIKey(const char *path,
char **key);
virSecurityDeviceLabelDefPtr
virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
const char *model);
void virStorageNetHostDefClear(virStorageNetHostDefPtr def);
void virStorageNetHostDefFree(size_t nhosts, virStorageNetHostDefPtr hosts);
virStorageNetHostDefPtr virStorageNetHostDefCopy(size_t nhosts,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册