qemu: fd: Add helpers allowing storing FD set data in status XML

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>
This commit is contained in:
Peter Krempa 2023-01-31 15:25:57 +01:00
parent 3b7b201b95
commit 5598c10c64
2 changed files with 48 additions and 0 deletions

View 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

View 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,