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