So far, this function is not needed with the current code. But it
is going to do so in subsequent commits. We already have
virSecurityDeviceLabelDefNew() which sets just model for new
seclabel, this new API sets both model and label.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/virseclabel.c | 14 ++++++++++++++
src/util/virseclabel.h | 4 ++++
3 files changed, 19 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 74dd527..bd1462b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2307,6 +2307,7 @@ virSCSIDeviceSetUsedBy;
# util/virseclabel.h
virSecurityDeviceLabelDefFree;
virSecurityDeviceLabelDefNew;
+virSecurityDeviceLabelDefNewLabel;
virSecurityLabelDefFree;
virSecurityLabelDefNew;
diff --git a/src/util/virseclabel.c b/src/util/virseclabel.c
index 02a8342..d762a15 100644
--- a/src/util/virseclabel.c
+++ b/src/util/virseclabel.c
@@ -83,6 +83,20 @@ virSecurityDeviceLabelDefNew(const char *model)
return seclabel;
}
+virSecurityDeviceLabelDefPtr
+virSecurityDeviceLabelDefNewLabel(const char *model,
+ const char *label)
+{
+ virSecurityDeviceLabelDefPtr seclabel;
+
+ if (!(seclabel = virSecurityDeviceLabelDefNew(model)) ||
+ VIR_STRDUP(seclabel->label, label) < 0) {
+ virSecurityDeviceLabelDefFree(seclabel);
+ seclabel = NULL;
+ }
+
+ return seclabel;
+}
virSecurityDeviceLabelDefPtr
virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabelDef *src)
diff --git a/src/util/virseclabel.h b/src/util/virseclabel.h
index 558d4eb..a0af1fd 100644
--- a/src/util/virseclabel.h
+++ b/src/util/virseclabel.h
@@ -64,6 +64,10 @@ virSecurityDeviceLabelDefPtr
virSecurityDeviceLabelDefNew(const char *model);
virSecurityDeviceLabelDefPtr
+virSecurityDeviceLabelDefNewLabel(const char *model,
+ const char *label);
+
+virSecurityDeviceLabelDefPtr
virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabelDef *src)
ATTRIBUTE_NONNULL(1);
--
2.8.4