]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: fd: Add helpers allowing storing FD set data in status XML
authorPeter Krempa <pkrempa@redhat.com>
Tue, 31 Jan 2023 14:25:57 +0000 (15:25 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 1 Feb 2023 08:17:41 +0000 (09:17 +0100)
Rollback of FD sets passed to qemu is also needed after possible restart
of libvirtd when we need to serialize the data into status XML. For this
purpose we need to access the fdset ID once it was passed to qemu and
potentially re-create a 'qemuFDPass' struct in passed state.

Introduce 'qemuFDPassNewPassed' and 'qemuFDPassIsPassed'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_fd.c
src/qemu/qemu_fd.h

index ebeeb65505e79424d88c463526b90b16a7074d76..f5eedb88ec54e6c12427a8bae9666de602ee5d88 100644 (file)
@@ -96,6 +96,47 @@ qemuFDPassNew(const char *prefix,
 }
 
 
+/**
+ * qemuFDPassNewPassed:
+ * @fdSetID: ID of an FDset which was allready passed to qemu
+ *
+ * Create qemuFDPass pointing to an already passed FD. Useful to usw with
+ * qemuFDPassTransferMonitorRollback, when restoring after restart.
+ */
+qemuFDPass *
+qemuFDPassNewPassed(unsigned int fdSetID)
+{
+    qemuFDPass *fdpass = g_new0(qemuFDPass, 1);
+
+    fdpass->fdSetID = fdSetID;
+    fdpass->passed = true;
+
+    return fdpass;
+}
+
+
+/**
+ * qemuFDPassIsPassed:
+ * @fdpass: The fd passing helper struct
+ * @id: when non-NULL filled with the fdset ID
+ *
+ * Returns true if @fdpass was passed to qemu. In such case @id is also filled
+ * with the ID of the fdset if non-NULL.
+ */
+bool
+qemuFDPassIsPassed(qemuFDPass *fdpass,
+                   unsigned *id)
+{
+    if (!fdpass || !fdpass->passed)
+        return false;
+
+    if (id)
+        *id = fdpass->fdSetID;
+
+    return true;
+}
+
+
 /**
  * qemuFDPassAddFD:
  * @fdpass: The fd passing helper struct
index 032b9442ee1c85c4a5c2d7189b60c20b70ebd189..cd0ff2c690c0eb4844c4ad448a2397f045e538fd 100644 (file)
@@ -31,6 +31,13 @@ qemuFDPass *
 qemuFDPassNew(const char *prefix,
               void *dompriv);
 
+qemuFDPass *
+qemuFDPassNewPassed(unsigned int fdSetID);
+
+bool
+qemuFDPassIsPassed(qemuFDPass *fdpass,
+                   unsigned *id);
+
 void
 qemuFDPassAddFD(qemuFDPass *fdpass,
                 int *fd,