On 9/18/24 15:42, Martin Kletzander wrote:
> This function sets the memoryBackingDir in qemuDomainObjPrivate struct
> so that it is remembered for the whole lifetime of a domain.
>
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
> ---
> src/qemu/qemu_domain.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index d5c0c4b56834..577c53050651 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -1735,6 +1735,27 @@ qemuDomainSecretPrepare(virQEMUDriver *driver,
> }
>
>
> +static void
> +qemuDomainSetPrivateMemPath(qemuDomainObjPrivate *priv,
> + virQEMUDriverConfig *cfg,
> + const char *embedded_root,
> + const char *short_name)
> +{
> + if (priv->memoryBackingDir)
> + return;
> +
> + if (embedded_root && !STRPREFIX(cfg->memoryBackingDir, embedded_root)) {
> + g_autofree char *hash = virDomainDriverGenerateRootHash("qemu",
> + embedded_root);
> + priv->memoryBackingDir = g_strdup_printf("%s/%s-%s",
> + cfg->memoryBackingDir,
> + hash, short_name);
> + } else {
> + priv->memoryBackingDir = g_strdup_printf("%s/%s", cfg->memoryBackingDir, short_name);
Long line.
> + }
> +}
> +
You can't just introduce a static function and not use it - gcc
complains about unused function.
Also, this looks like an almost verbatim copy of
qemuGetMemoryBackingDomainPath() - so maybe just rename it or something?
Alternatively, turn this into a thin wrapper over
qemuGetMemoryBackingDomainPath() for the time being and dissolve it in
the very last patch:
static void
qemuDomainSetPrivateMemPath()
{
qemuGetMemoryBackingDomainPath(priv, cfg,
embedded_root,
&priv->memoryBackingDir)
}
> +
> /* This is the old way of setting up per-domain directories */
> static void
> qemuDomainSetPrivatePathsOld(virQEMUDriver *driver,
Michal