[PATCH v1 15/23] lock_driver_lockd: Implement remember and recall APIs

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/locking/lock_driver_lockd.c | 87 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index c974d60..70ed45d 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -775,6 +775,90 @@ static int virLockManagerLockDaemonInquire(virLockManagerPtr lock ATTRIBUTE_UNUS
     return 0;
 }
 
+static int
+virLockManagerLockDaemonRemember(virLockManagerPtr lock,
+                                 const char *path,
+                                 const char *model,
+                                 const char *label)
+{
+    virNetClientPtr client = NULL;
+    virNetClientProgramPtr program = NULL;
+    virLockSpaceProtocolRememberSeclabelArgs args;
+    int counter = 0;
+    int rv = -1;
+
+    memset(&args, 0, sizeof(args));
+
+    if (!(client = virLockManagerLockDaemonConnect(lock, &program, &counter)))
+        goto cleanup;
+
+    args.path = (char *)path;
+    args.model = (char *)model;
+    args.label = (char *)label;
+
+    if (virNetClientProgramCall(program,
+                                client,
+                                counter++,
+                                VIR_LOCK_SPACE_PROTOCOL_PROC_REMEMBER_SECLABEL,
+                                0, NULL, NULL, NULL,
+                                (xdrproc_t)xdr_virLockSpaceProtocolRememberSeclabelArgs, &args,
+                                (xdrproc_t)xdr_void, NULL) < 0)
+        goto cleanup;
+    rv = 0;
+
+ cleanup:
+    virNetClientClose(client);
+    virObjectUnref(client);
+    virObjectUnref(program);
+
+    return rv;
+}
+
+static int
+virLockManagerLockDaemonRecall(virLockManagerPtr lock,
+                               const char *path,
+                               const char *model,
+                               char **label)
+{
+    virNetClientPtr client = NULL;
+    virNetClientProgramPtr program = NULL;
+    virLockSpaceProtocolRecallSeclabelArgs args;
+    virLockSpaceProtocolRecallSeclabelRet ret;
+    int counter = 0;
+    int rv = -1;
+
+    memset(&args, 0, sizeof(args));
+    memset(&ret, 0, sizeof(ret));
+
+    if (!(client = virLockManagerLockDaemonConnect(lock, &program, &counter)))
+        goto cleanup;
+
+    args.path = (char *)path;
+    args.model = (char *)model;
+
+    if (virNetClientProgramCall(program,
+                                client,
+                                counter++,
+                                VIR_LOCK_SPACE_PROTOCOL_PROC_RECALL_SECLABEL,
+                                0, NULL, NULL, NULL,
+                                (xdrproc_t)xdr_virLockSpaceProtocolRecallSeclabelArgs, &args,
+                                (xdrproc_t)xdr_virLockSpaceProtocolRecallSeclabelRet, &ret) < 0)
+        goto cleanup;
+
+    if (ret.ret == 0 && label)
+        *label = *ret.label;
+
+    rv = ret.ret;
+
+ cleanup:
+    VIR_FREE(ret.label);
+    virNetClientClose(client);
+    virObjectUnref(client);
+    virObjectUnref(program);
+
+    return rv;
+}
+
 virLockDriver virLockDriverImpl =
 {
     .version = VIR_LOCK_MANAGER_VERSION,
@@ -792,4 +876,7 @@ virLockDriver virLockDriverImpl =
     .drvRelease = virLockManagerLockDaemonRelease,
 
     .drvInquire = virLockManagerLockDaemonInquire,
+
+    .drvRemember = virLockManagerLockDaemonRemember,
+    .drvRecall = virLockManagerLockDaemonRecall,
 };
-- 
2.4.9

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