[PATCH v2 1/4] virnetmessage: Introduce virNetMessageClearFDs

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

 



The helper splits out the clearing of the FDs transacted inside a
virNetMessage.

APIs transacting FDs both from and to the client at the same time will
need to clear the FDs stored in virNetMessage as the structure is
re-used for the reply and without clearing the list of FDs we'd return
the FDs sent by the client in addition to the new FDs sent by the API.t

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/libvirt_remote.syms | 1 +
 src/rpc/virnetmessage.c | 9 ++++++++-
 src/rpc/virnetmessage.h | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 2fa46e5e0c..f0f90815cf 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -102,6 +102,7 @@ virNetDaemonUpdateServices;
 # rpc/virnetmessage.h
 virNetMessageAddFD;
 virNetMessageClear;
+virNetMessageClearFDs;
 virNetMessageClearPayload;
 virNetMessageDecodeHeader;
 virNetMessageDecodeLength;
diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index ca11f1688e..221da7c59b 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -48,7 +48,7 @@ virNetMessage *virNetMessageNew(bool tracked)


 void
-virNetMessageClearPayload(virNetMessage *msg)
+virNetMessageClearFDs(virNetMessage *msg)
 {
     size_t i;

@@ -58,6 +58,13 @@ virNetMessageClearPayload(virNetMessage *msg)
     msg->donefds = 0;
     msg->nfds = 0;
     VIR_FREE(msg->fds);
+}
+
+
+void
+virNetMessageClearPayload(virNetMessage *msg)
+{
+    virNetMessageClearFDs(msg);

     msg->bufferOffset = 0;
     msg->bufferLength = 0;
diff --git a/src/rpc/virnetmessage.h b/src/rpc/virnetmessage.h
index aadf1b69b0..8f878962f8 100644
--- a/src/rpc/virnetmessage.h
+++ b/src/rpc/virnetmessage.h
@@ -49,6 +49,7 @@ struct _virNetMessage {

 virNetMessage *virNetMessageNew(bool tracked);

+void virNetMessageClearFDs(virNetMessage *msg);
 void virNetMessageClearPayload(virNetMessage *msg);

 void virNetMessageClear(virNetMessage *);
-- 
2.35.1




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

  Powered by Linux