[PATCH 0/2] qemu: domain: Move and rename qemuDomainStorageIdNew/Reset

In a review adding similar APIs I was asked to use 'ID' instead of 'Id'. Rename the existing helpers. Patch 1 is a second version as 'qemuDomainStorageIdNew' can be unexported too. Peter Krempa (2): qemu: domain: Move and unexport 'qemuDomainStorageIdNew/Reset' qemu: domain: Change 'Id' to 'ID' in qemuDomainStorageIdNew/Reset src/qemu/qemu_domain.c | 62 +++++++++++++++++++++--------------------- src/qemu/qemu_domain.h | 3 -- 2 files changed, 31 insertions(+), 34 deletions(-) -- 2.34.1

They're used only inside qemu_domain.c. Move it before their usage, and unexport them. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- v2: Unexport qemuDomainStorageIdNew too. src/qemu/qemu_domain.c | 54 +++++++++++++++++++++--------------------- src/qemu/qemu_domain.h | 3 --- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c764f6296c..d44244f9b8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -656,6 +656,33 @@ qemuDomainMasterKeyCreate(virDomainObj *vm) } +/** + * qemuDomainStorageIdNew: + * @priv: qemu VM private data object. + * + * Generate a new unique id for a storage object. Useful for node name generation. + */ +static unsigned int +qemuDomainStorageIdNew(qemuDomainObjPrivate *priv) +{ + return ++priv->nodenameindex; +} + + +/** + * qemuDomainStorageIdReset: + * @priv: qemu VM private data object. + * + * Resets the data for the node name generator. The node names need to be unique + * for a single instance, so can be reset on VM shutdown. + */ +static void +qemuDomainStorageIdReset(qemuDomainObjPrivate *priv) +{ + priv->nodenameindex = 0; +} + + static void qemuDomainSecretInfoClear(qemuDomainSecretInfo *secinfo, bool keepAlias) @@ -10889,33 +10916,6 @@ qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivate *priv) } -/** - * qemuDomainStorageIdNew: - * @priv: qemu VM private data object. - * - * Generate a new unique id for a storage object. Useful for node name generation. - */ -unsigned int -qemuDomainStorageIdNew(qemuDomainObjPrivate *priv) -{ - return ++priv->nodenameindex; -} - - -/** - * qemuDomainStorageIdReset: - * @priv: qemu VM private data object. - * - * Resets the data for the node name generator. The node names need to be unique - * for a single instance, so can be reset on VM shutdown. - */ -void -qemuDomainStorageIdReset(qemuDomainObjPrivate *priv) -{ - priv->nodenameindex = 0; -} - - virDomainEventResumedDetailType qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 8bf1c91049..0a9d312b65 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -969,9 +969,6 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivate *priv); bool qemuDomainDefHasManagedPR(virDomainObj *vm); -unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivate *priv); -void qemuDomainStorageIdReset(qemuDomainObjPrivate *priv); - virDomainEventResumedDetailType qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason); -- 2.34.1

In a patch adding similarly named APIs I was asked to use 'ID' instead of 'Id'. Since the code is being put together fix qemuDomainStorageIdNew/Reset first. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_domain.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d44244f9b8..ee1cf6f9bb 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -657,27 +657,27 @@ qemuDomainMasterKeyCreate(virDomainObj *vm) /** - * qemuDomainStorageIdNew: + * qemuDomainStorageIDNew: * @priv: qemu VM private data object. * * Generate a new unique id for a storage object. Useful for node name generation. */ static unsigned int -qemuDomainStorageIdNew(qemuDomainObjPrivate *priv) +qemuDomainStorageIDNew(qemuDomainObjPrivate *priv) { return ++priv->nodenameindex; } /** - * qemuDomainStorageIdReset: + * qemuDomainStorageIDReset: * @priv: qemu VM private data object. * * Resets the data for the node name generator. The node names need to be unique * for a single instance, so can be reset on VM shutdown. */ static void -qemuDomainStorageIdReset(qemuDomainObjPrivate *priv) +qemuDomainStorageIDReset(qemuDomainObjPrivate *priv) { priv->nodenameindex = 0; } @@ -1681,7 +1681,7 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *priv) g_clear_pointer(&priv->backup, virDomainBackupDefFree); /* reset node name allocator */ - qemuDomainStorageIdReset(priv); + qemuDomainStorageIDReset(priv); priv->dbusDaemonRunning = false; @@ -3090,7 +3090,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, if (qemuDomainObjPrivateXMLParseBackups(priv, ctxt) < 0) goto error; - qemuDomainStorageIdReset(priv); + qemuDomainStorageIDReset(priv); if (virXPathULongLong("string(./nodename/@index)", ctxt, &priv->nodenameindex) == -2) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -10646,7 +10646,7 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDef *disk, qemuDomainObjPrivate *priv, virQEMUDriverConfig *cfg) { - src->id = qemuDomainStorageIdNew(priv); + src->id = qemuDomainStorageIDNew(priv); src->nodestorage = g_strdup_printf("libvirt-%u-storage", src->id); src->nodeformat = g_strdup_printf("libvirt-%u-format", src->id); @@ -10773,7 +10773,7 @@ qemuDomainPrepareHostdev(virDomainHostdevDef *hostdev, src->readonly = hostdev->readonly; if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI)) { - src->id = qemuDomainStorageIdNew(priv); + src->id = qemuDomainStorageIDNew(priv); src->nodestorage = g_strdup_printf("libvirt-%d-backend", src->id); backendalias = src->nodestorage; } -- 2.34.1

On a Monday in 2022, Peter Krempa wrote:
In a review adding similar APIs I was asked to use 'ID' instead of 'Id'.
Rename the existing helpers.
Patch 1 is a second version as 'qemuDomainStorageIdNew' can be unexported too.
Peter Krempa (2): qemu: domain: Move and unexport 'qemuDomainStorageIdNew/Reset' qemu: domain: Change 'Id' to 'ID' in qemuDomainStorageIdNew/Reset
src/qemu/qemu_domain.c | 62 +++++++++++++++++++++--------------------- src/qemu/qemu_domain.h | 3 -- 2 files changed, 31 insertions(+), 34 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa