mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
conf: domain: Add helper to check whether a domain def requires use of PR
Extract the lookup code so that it can be reused later. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
b4f113ee44
commit
26c72a76dc
@ -29579,3 +29579,24 @@ virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
|
||||
|
||||
return detect_zeroes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainDefHasManagedPR:
|
||||
* @def: domain definition
|
||||
*
|
||||
* Returns true if any of the domain disks requires the use of the managed
|
||||
* persistent reservations infrastructure.
|
||||
*/
|
||||
bool
|
||||
virDomainDefHasManagedPR(const virDomainDef *def)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
if (virStoragePRDefIsManaged(def->disks[i]->src->pr))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -3544,4 +3544,7 @@ int
|
||||
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
|
||||
virDomainDiskDetectZeroes detect_zeroes);
|
||||
|
||||
bool
|
||||
virDomainDefHasManagedPR(const virDomainDef *def);
|
||||
|
||||
#endif /* __DOMAIN_CONF_H */
|
||||
|
@ -275,6 +275,7 @@ virDomainDefGetVcpus;
|
||||
virDomainDefGetVcpusMax;
|
||||
virDomainDefGetVcpusTopology;
|
||||
virDomainDefHasDeviceAddress;
|
||||
virDomainDefHasManagedPR;
|
||||
virDomainDefHasMemballoon;
|
||||
virDomainDefHasMemoryHotplug;
|
||||
virDomainDefHasUSB;
|
||||
|
@ -2748,26 +2748,6 @@ qemuProcessStartManagedPRDaemon(virDomainObjPtr vm)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuProcessMaybeStartManagedPRDaemon(virDomainObjPtr vm)
|
||||
{
|
||||
bool hasManaged = false;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < vm->def->ndisks; i++) {
|
||||
if (virStoragePRDefIsManaged(vm->def->disks[i]->src->pr)) {
|
||||
hasManaged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasManaged)
|
||||
return 0;
|
||||
|
||||
return qemuProcessStartManagedPRDaemon(vm);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuProcessInitPasswords(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
@ -6285,7 +6265,8 @@ qemuProcessLaunch(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
|
||||
VIR_DEBUG("Setting up managed PR daemon");
|
||||
if (qemuProcessMaybeStartManagedPRDaemon(vm) < 0)
|
||||
if (virDomainDefHasManagedPR(vm->def) &&
|
||||
qemuProcessStartManagedPRDaemon(vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
VIR_DEBUG("Setting domain security labels");
|
||||
|
Loading…
Reference in New Issue
Block a user