render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
acda74
From f7d193539a8a7194ee3506642b68e0e52619cdf9 Mon Sep 17 00:00:00 2001
acda74
Message-Id: <f7d193539a8a7194ee3506642b68e0e52619cdf9@dist-git>
acda74
From: Peter Krempa <pkrempa@redhat.com>
acda74
Date: Tue, 31 Jan 2023 15:25:57 +0100
acda74
Subject: [PATCH] qemu: fd: Add helpers allowing storing FD set data in status
acda74
 XML
acda74
acda74
Rollback of FD sets passed to qemu is also needed after possible restart
acda74
of libvirtd when we need to serialize the data into status XML. For this
acda74
purpose we need to access the fdset ID once it was passed to qemu and
acda74
potentially re-create a 'qemuFDPass' struct in passed state.
acda74
acda74
Introduce 'qemuFDPassNewPassed' and 'qemuFDPassIsPassed'.
acda74
acda74
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
acda74
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
acda74
(cherry picked from commit 5598c10c6464887a99928de48fb2fc3e4f1696dc)
acda74
acda74
https://bugzilla.redhat.com/show_bug.cgi?id=2040272
acda74
---
acda74
 src/qemu/qemu_fd.c | 41 +++++++++++++++++++++++++++++++++++++++++
acda74
 src/qemu/qemu_fd.h |  7 +++++++
acda74
 2 files changed, 48 insertions(+)
acda74
acda74
diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c
acda74
index ebeeb65505..f5eedb88ec 100644
acda74
--- a/src/qemu/qemu_fd.c
acda74
+++ b/src/qemu/qemu_fd.c
acda74
@@ -96,6 +96,47 @@ qemuFDPassNew(const char *prefix,
acda74
 }
acda74
 
acda74
 
acda74
+/**
acda74
+ * qemuFDPassNewPassed:
acda74
+ * @fdSetID: ID of an FDset which was allready passed to qemu
acda74
+ *
acda74
+ * Create qemuFDPass pointing to an already passed FD. Useful to usw with
acda74
+ * qemuFDPassTransferMonitorRollback, when restoring after restart.
acda74
+ */
acda74
+qemuFDPass *
acda74
+qemuFDPassNewPassed(unsigned int fdSetID)
acda74
+{
acda74
+    qemuFDPass *fdpass = g_new0(qemuFDPass, 1);
acda74
+
acda74
+    fdpass->fdSetID = fdSetID;
acda74
+    fdpass->passed = true;
acda74
+
acda74
+    return fdpass;
acda74
+}
acda74
+
acda74
+
acda74
+/**
acda74
+ * qemuFDPassIsPassed:
acda74
+ * @fdpass: The fd passing helper struct
acda74
+ * @id: when non-NULL filled with the fdset ID
acda74
+ *
acda74
+ * Returns true if @fdpass was passed to qemu. In such case @id is also filled
acda74
+ * with the ID of the fdset if non-NULL.
acda74
+ */
acda74
+bool
acda74
+qemuFDPassIsPassed(qemuFDPass *fdpass,
acda74
+                   unsigned *id)
acda74
+{
acda74
+    if (!fdpass || !fdpass->passed)
acda74
+        return false;
acda74
+
acda74
+    if (id)
acda74
+        *id = fdpass->fdSetID;
acda74
+
acda74
+    return true;
acda74
+}
acda74
+
acda74
+
acda74
 /**
acda74
  * qemuFDPassAddFD:
acda74
  * @fdpass: The fd passing helper struct
acda74
diff --git a/src/qemu/qemu_fd.h b/src/qemu/qemu_fd.h
acda74
index 032b9442ee..cd0ff2c690 100644
acda74
--- a/src/qemu/qemu_fd.h
acda74
+++ b/src/qemu/qemu_fd.h
acda74
@@ -31,6 +31,13 @@ qemuFDPass *
acda74
 qemuFDPassNew(const char *prefix,
acda74
               void *dompriv);
acda74
 
acda74
+qemuFDPass *
acda74
+qemuFDPassNewPassed(unsigned int fdSetID);
acda74
+
acda74
+bool
acda74
+qemuFDPassIsPassed(qemuFDPass *fdpass,
acda74
+                   unsigned *id);
acda74
+
acda74
 void
acda74
 qemuFDPassAddFD(qemuFDPass *fdpass,
acda74
                 int *fd,
acda74
-- 
acda74
2.39.1
acda74