mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 11:01:19 +00:00
qemu: domain: Add helper for generating 'fdset' ids for VM startup
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9b07991c19
commit
56d16e6145
@ -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)
|
||||||
|
{
|
||||||
|
return priv->fdsetindex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qemuDomainFDSetIDReset:
|
||||||
|
* @priv: qemu VM private data object.
|
||||||
|
*
|
||||||
|
* Resets the data for the fdset ID generator.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
qemuDomainFDSetIDReset(qemuDomainObjPrivate *priv)
|
||||||
|
{
|
||||||
|
priv->fdsetindex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qemuDomainSecretInfoClear(qemuDomainSecretInfo *secinfo,
|
qemuDomainSecretInfoClear(qemuDomainSecretInfo *secinfo,
|
||||||
bool keepAlias)
|
bool keepAlias)
|
||||||
@ -1683,6 +1710,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *priv)
|
|||||||
/* reset node name allocator */
|
/* reset node name allocator */
|
||||||
qemuDomainStorageIDReset(priv);
|
qemuDomainStorageIDReset(priv);
|
||||||
|
|
||||||
|
qemuDomainFDSetIDReset(priv);
|
||||||
|
|
||||||
priv->dbusDaemonRunning = false;
|
priv->dbusDaemonRunning = false;
|
||||||
|
|
||||||
if (priv->dbusVMStateIds)
|
if (priv->dbusVMStateIds)
|
||||||
|
@ -207,6 +207,9 @@ struct _qemuDomainObjPrivate {
|
|||||||
/* counter for generating node names for qemu disks */
|
/* counter for generating node names for qemu disks */
|
||||||
unsigned long long nodenameindex;
|
unsigned long long nodenameindex;
|
||||||
|
|
||||||
|
/* counter for generating IDs of fdsets - only relevant during startup */
|
||||||
|
unsigned int fdsetindex;
|
||||||
|
|
||||||
/* qemuProcessStartCPUs stores the reason for starting vCPUs here for the
|
/* qemuProcessStartCPUs stores the reason for starting vCPUs here for the
|
||||||
* RESUME event handler to use it */
|
* RESUME event handler to use it */
|
||||||
virDomainRunningReason runningReason;
|
virDomainRunningReason runningReason;
|
||||||
@ -969,6 +972,8 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivate *priv);
|
|||||||
|
|
||||||
bool qemuDomainDefHasManagedPR(virDomainObj *vm);
|
bool qemuDomainDefHasManagedPR(virDomainObj *vm);
|
||||||
|
|
||||||
|
unsigned int qemuDomainFDSetIDNew(qemuDomainObjPrivate *priv);
|
||||||
|
|
||||||
virDomainEventResumedDetailType
|
virDomainEventResumedDetailType
|
||||||
qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);
|
qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user