[PATCH 08/27] qemu: domain: Add helper for generating 'fdset' ids for VM startup

Ján Tomko jtomko at redhat.com
Thu Feb 10 17:53:43 UTC 2022


On a Wednesday in 2022, Peter Krempa wrote:
>When starting a VM we must assign unique IDs for fdsets we add via
>'-add-fd'. For now it was done by using the index of the filedescriptor
>passed to the virCommand. That approach is not very flexible, because
>you need to have already passed the 'fd' to virCommand before generating
>the fdset path, and also won't nicely work with fdsets containing two or
>more fds.
>
>This patch introduces a counter into the private data of a qemu domain
>so that we can allocate unique ids without relying on virCommand.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/qemu/qemu_domain.c | 29 +++++++++++++++++++++++++++++
> src/qemu/qemu_domain.h |  4 ++++
> 2 files changed, 33 insertions(+)
>
>diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
>index 64be39d49f..d0abf76e4a 100644
>--- a/src/qemu/qemu_domain.c
>+++ b/src/qemu/qemu_domain.c
>@@ -683,6 +683,33 @@ qemuDomainStorageIdReset(qemuDomainObjPrivate *priv)
> }
>
>
>+/**
>+ * qemuDomainFDSetIdNew:
>+ * @priv: qemu VM private data object.
>+ *
>+ * Generate a new unique id for a fdset. Note that this is necessary only for
>+ * startup. When running qemu auto-assigns id for added fdset.
>+ */
>+unsigned int
>+qemuDomainFDSetIdNew(qemuDomainObjPrivate *priv)

The spelling of 'ID' would look nicer.

>+{
>+    return ++priv->fdsetindex;

Is there a reason why we shouldn't allow '0' as a valid fdset index?

It would reduce test churn.

Jano

>+}
>+
>+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220210/4748838a/attachment-0001.sig>


More information about the libvir-list mailing list