[PATCH v2 02/19] virseclabel: Introduce virSecurityDeviceLabelDefNewLabel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]