mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Assign managed PR path when preparing storage source
Rather than always checking which path to use pre-assign it when preparing storage source. This reduces the need to pass 'vm' around too much. For later use the path can be retrieved from the status XML. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
e31f490458
commit
b571e7bad0
@ -9717,7 +9717,6 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
|
||||
|
||||
/**
|
||||
* qemuBuildPRManagerInfoProps:
|
||||
* @vm: domain object
|
||||
* @disk: disk definition
|
||||
* @propsret: Returns JSON object containing properties of the pr-manager-helper object
|
||||
* @aliasret: alias of the pr-manager-helper object
|
||||
@ -9728,12 +9727,10 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
|
||||
* -1 on failure (with error message set).
|
||||
*/
|
||||
int
|
||||
qemuBuildPRManagerInfoProps(virDomainObjPtr vm,
|
||||
const virDomainDiskDef *disk,
|
||||
qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk,
|
||||
virJSONValuePtr *propsret,
|
||||
char **aliasret)
|
||||
{
|
||||
char *socketPath = NULL;
|
||||
char *alias = NULL;
|
||||
int ret = -1;
|
||||
|
||||
@ -9743,9 +9740,6 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm,
|
||||
if (!disk->src->pr)
|
||||
return 0;
|
||||
|
||||
if (!(socketPath = qemuDomainGetPRSocketPath(vm, disk->src->pr)))
|
||||
return ret;
|
||||
|
||||
if (virStoragePRDefIsManaged(disk->src->pr)) {
|
||||
if (VIR_STRDUP(alias, qemuDomainGetManagedPRAlias()) < 0)
|
||||
goto cleanup;
|
||||
@ -9755,7 +9749,7 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm,
|
||||
}
|
||||
|
||||
if (virJSONValueObjectCreate(propsret,
|
||||
"s:path", socketPath,
|
||||
"s:path", disk->src->pr->path,
|
||||
NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -9763,14 +9757,12 @@ qemuBuildPRManagerInfoProps(virDomainObjPtr vm,
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(alias);
|
||||
VIR_FREE(socketPath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBuildMasterPRCommandLine(virDomainObjPtr vm,
|
||||
virCommandPtr cmd,
|
||||
qemuBuildMasterPRCommandLine(virCommandPtr cmd,
|
||||
const virDomainDef *def)
|
||||
{
|
||||
size_t i;
|
||||
@ -9790,7 +9782,7 @@ qemuBuildMasterPRCommandLine(virDomainObjPtr vm,
|
||||
managedAdded = true;
|
||||
}
|
||||
|
||||
if (qemuBuildPRManagerInfoProps(vm, disk, &props, &alias) < 0)
|
||||
if (qemuBuildPRManagerInfoProps(disk, &props, &alias) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!props)
|
||||
@ -9984,7 +9976,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
|
||||
if (qemuBuildMasterKeyCommandLine(cmd, priv) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuBuildMasterPRCommandLine(vm, cmd, def) < 0)
|
||||
if (qemuBuildMasterPRCommandLine(cmd, def) < 0)
|
||||
goto error;
|
||||
|
||||
if (enableFips)
|
||||
|
@ -55,8 +55,7 @@ virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver,
|
||||
int **nicindexes);
|
||||
|
||||
/* Generate the object properties for pr-manager */
|
||||
int qemuBuildPRManagerInfoProps(virDomainObjPtr vm,
|
||||
const virDomainDiskDef *disk,
|
||||
int qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk,
|
||||
virJSONValuePtr *propsret,
|
||||
char **alias);
|
||||
|
||||
|
@ -11930,6 +11930,22 @@ qemuDomainPrepareDiskCachemode(virDomainDiskDefPtr disk)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainPrepareStorageSourcePR(virStorageSourcePtr src,
|
||||
qemuDomainObjPrivatePtr priv)
|
||||
{
|
||||
if (!src->pr)
|
||||
return 0;
|
||||
|
||||
if (virStoragePRDefIsManaged(src->pr)) {
|
||||
if (!(src->pr->path = qemuDomainGetManagedPRSocketPath(priv)))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
|
||||
qemuDomainObjPrivatePtr priv,
|
||||
@ -11946,6 +11962,9 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
|
||||
if (qemuDomainPrepareDiskSourceChain(disk, NULL, cfg, priv->qemuCaps) < 0)
|
||||
return -1;
|
||||
|
||||
if (qemuDomainPrepareStorageSourcePR(disk->src, priv) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -12051,22 +12070,12 @@ qemuProcessEventFree(struct qemuProcessEvent *event)
|
||||
|
||||
|
||||
char *
|
||||
qemuDomainGetPRSocketPath(virDomainObjPtr vm,
|
||||
virStoragePRDefPtr pr)
|
||||
qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
const char *defaultAlias = NULL;
|
||||
char *ret = NULL;
|
||||
|
||||
if (!pr)
|
||||
return NULL;
|
||||
|
||||
if (virStoragePRDefIsManaged(pr)) {
|
||||
defaultAlias = qemuDomainGetManagedPRAlias();
|
||||
ignore_value(virAsprintf(&ret, "%s/%s.sock", priv->libDir, defaultAlias));
|
||||
} else {
|
||||
ignore_value(VIR_STRDUP(ret, pr->path));
|
||||
}
|
||||
ignore_value(virAsprintf(&ret, "%s/%s.sock", priv->libDir,
|
||||
qemuDomainGetManagedPRAlias()));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1006,7 +1006,6 @@ qemuDomainDiskCachemodeFlags(int cachemode,
|
||||
bool *direct,
|
||||
bool *noflush);
|
||||
|
||||
char * qemuDomainGetPRSocketPath(virDomainObjPtr vm,
|
||||
virStoragePRDefPtr pr);
|
||||
char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);
|
||||
|
||||
#endif /* __QEMU_DOMAIN_H__ */
|
||||
|
@ -401,7 +401,7 @@ qemuMaybeBuildPRManagerInfoProps(virDomainObjPtr vm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return qemuBuildPRManagerInfoProps(vm, disk, propsret, aliasret);
|
||||
return qemuBuildPRManagerInfoProps(disk, propsret, aliasret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2659,7 +2659,7 @@ qemuProcessStartPRDaemon(virDomainObjPtr vm,
|
||||
if ((pidfd = virPidFileAcquirePath(pidfile, false, -1)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(socketPath = qemuDomainGetPRSocketPath(vm, disk->src->pr)))
|
||||
if (!(socketPath = qemuDomainGetManagedPRSocketPath(priv)))
|
||||
goto cleanup;
|
||||
|
||||
/* Remove stale socket */
|
||||
|
Loading…
x
Reference in New Issue
Block a user