[PATCH v1 03/10] domain_lock: Introduce seclabel APIs

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libvirt_private.syms        |  2 ++
 src/locking/domain_lock.c       | 65 +++++++++++++++++++++++++++++++++++++++++
 src/locking/domain_lock.h       | 10 +++++++
 src/locking/lock_driver.h       |  2 ++
 src/locking/lock_driver_lockd.c |  4 +++
 5 files changed, 83 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cdc476a..db65aa5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -874,6 +874,8 @@ virDomainLockProcessInquire;
 virDomainLockProcessPause;
 virDomainLockProcessResume;
 virDomainLockProcessStart;
+virDomainLockRecallSeclabel;
+virDomainLockRememberSeclabel;
 
 
 # locking/lock_manager.h
diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c
index d7b681e..7de56b3 100644
--- a/src/locking/domain_lock.c
+++ b/src/locking/domain_lock.c
@@ -164,6 +164,30 @@ static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin,
 }
 
 
+static virLockManagerPtr
+virDomainLockManagerSeclabelNew(virLockManagerPluginPtr plugin)
+{
+    virLockManagerPtr lock;
+    virLockManagerParam params[] = {
+        /* nada */
+    };
+    VIR_DEBUG("plugin=%p", plugin);
+
+    if (!(lock = virLockManagerNew(virLockManagerPluginGetDriver(plugin),
+                                   VIR_LOCK_MANAGER_OBJECT_TYPE_SECLABEL,
+                                   ARRAY_CARDINALITY(params),
+                                   params,
+                                   0)))
+        goto error;
+
+    return lock;
+
+ error:
+    virLockManagerFree(lock);
+    return NULL;
+}
+
+
 int virDomainLockProcessStart(virLockManagerPluginPtr plugin,
                               const char *uri,
                               virDomainObjPtr dom,
@@ -378,3 +402,44 @@ int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin,
 
     return ret;
 }
+
+
+int virDomainLockRememberSeclabel(virLockManagerPluginPtr plugin,
+                                  const char *path,
+                                  const char *model,
+                                  const char *seclabel)
+{
+    virLockManagerPtr lock;
+    int ret = -1;
+
+    VIR_DEBUG("plugin=%p path=%s model=%s seclabel=%s",
+              plugin, path, model, seclabel);
+
+    if (!(lock = virDomainLockManagerSeclabelNew(plugin)))
+        return ret;
+
+    ret = virLockManagerRememberSeclabel(lock, path, model, seclabel);
+
+    virLockManagerFree(lock);
+    return ret;
+}
+
+int virDomainLockRecallSeclabel(virLockManagerPluginPtr plugin,
+                                const char *path,
+                                const char *model,
+                                char **seclabel)
+{
+    virLockManagerPtr lock;
+    int ret = -1;
+
+    VIR_DEBUG("plugin=%p path=%s model=%s seclabel=%p",
+              plugin, path, model, seclabel);
+
+    if (!(lock = virDomainLockManagerSeclabelNew(plugin)))
+        return ret;
+
+    ret = virLockManagerRecallSeclabel(lock, path, model, seclabel);
+
+    virLockManagerFree(lock);
+    return ret;
+}
diff --git a/src/locking/domain_lock.h b/src/locking/domain_lock.h
index fb49102..7a4b119 100644
--- a/src/locking/domain_lock.h
+++ b/src/locking/domain_lock.h
@@ -66,4 +66,14 @@ int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin,
                              virDomainObjPtr dom,
                              virDomainLeaseDefPtr lease);
 
+int virDomainLockRememberSeclabel(virLockManagerPluginPtr plugin,
+                                  const char *path,
+                                  const char *model,
+                                  const char *seclabel);
+
+int virDomainLockRecallSeclabel(virLockManagerPluginPtr plugin,
+                                const char *path,
+                                const char *model,
+                                char **seclabel);
+
 #endif /* __VIR_DOMAIN_LOCK_H__ */
diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h
index a82f240..0dde48c 100644
--- a/src/locking/lock_driver.h
+++ b/src/locking/lock_driver.h
@@ -42,6 +42,8 @@ typedef enum {
 typedef enum {
     /* The managed object is a virtual guest domain */
     VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN = 0,
+    /* The managed object is a seclabel */
+    VIR_LOCK_MANAGER_OBJECT_TYPE_SECLABEL = 1,
 } virLockManagerObjectType;
 
 typedef enum {
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index 0a40e94..4bb5925 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -487,6 +487,10 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock,
         }
         break;
 
+    case VIR_LOCK_MANAGER_OBJECT_TYPE_SECLABEL:
+        /* No parameters yet */
+        break;
+
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unknown lock manager object type %d"),
-- 
1.8.5.5

--
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]