util: seclabel: Add deep copy function for device labels

This commit is contained in:
Peter Krempa 2014-06-12 16:03:06 +02:00
parent 756b46ddd2
commit 89939e1301
2 changed files with 28 additions and 1 deletions

View File

@ -80,3 +80,26 @@ virSecurityDeviceLabelDefNew(const char *model)
return seclabel;
}
virSecurityDeviceLabelDefPtr
virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabelDef *src)
{
virSecurityDeviceLabelDefPtr ret;
if (VIR_ALLOC(ret) < 0)
return NULL;
ret->norelabel = src->norelabel;
ret->labelskip = src->labelskip;
if (VIR_STRDUP(ret->model, src->model) < 0 ||
VIR_STRDUP(ret->label, src->label) < 0)
goto error;
return ret;
error:
virSecurityDeviceLabelDefFree(ret);
return NULL;
}

View File

@ -45,7 +45,7 @@ struct _virSecurityLabelDef {
};
/* Security configuration for domain */
/* Security configuration for device */
typedef struct _virSecurityDeviceLabelDef virSecurityDeviceLabelDef;
typedef virSecurityDeviceLabelDef *virSecurityDeviceLabelDefPtr;
struct _virSecurityDeviceLabelDef {
@ -61,6 +61,10 @@ virSecurityLabelDefNew(const char *model);
virSecurityDeviceLabelDefPtr
virSecurityDeviceLabelDefNew(const char *model);
virSecurityDeviceLabelDefPtr
virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabelDef *src)
ATTRIBUTE_NONNULL(1);
void virSecurityLabelDefFree(virSecurityLabelDefPtr def);
void virSecurityDeviceLabelDefFree(virSecurityDeviceLabelDefPtr def);