From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> --- src/locking/lock_driver_lockd.c | 35 ++++++++++++++++++++++++++++++++++- src/locking/lockd.conf | 14 ++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c index aa0f94a..abae52d 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -73,6 +73,7 @@ struct _virLockManagerLockDaemonDriver { bool requireLeaseForDisks; char *fileLockSpaceDir; + char *lvmLockSpaceDir; }; static virLockManagerLockDaemonDriverPtr driver = NULL; @@ -134,6 +135,17 @@ static int virLockManagerLockDaemonLoadConfig(const char *configFile) } } + p = virConfGetValue(conf, "lvm_lockspace_dir"); + CHECK_TYPE("lvm_lockspace_dir", VIR_CONF_STRING); + if (p && p->str) { + VIR_FREE(driver->lvmLockSpaceDir); + if (!(driver->lvmLockSpaceDir = strdup(p->str))) { + virReportOOMError(); + virConfFree(conf); + return -1; + } + } + p = virConfGetValue(conf, "require_lease_for_disks"); CHECK_TYPE("require_lease_for_disks", VIR_CONF_LONG); if (p) @@ -371,8 +383,11 @@ static int virLockManagerLockDaemonInit(unsigned int version, if (driver->fileLockSpaceDir && virLockManagerLockDaemonSetupLockspace(driver->fileLockSpaceDir) < 0) goto error; - } + if (driver->lvmLockSpaceDir && + virLockManagerLockDaemonSetupLockspace(driver->lvmLockSpaceDir) < 0) + goto error; + } return 0; @@ -546,6 +561,24 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock, return 0; } + /* XXX we should somehow pass in TYPE=BLOCK info + * from the domain_lock code, instead of assuming /dev + */ + if (STRPREFIX(name, "/dev") && + driver->lvmLockSpaceDir) { + VIR_DEBUG("Trying to find an LVM UUID for %s", name); + newName = virStorageFileGetLVMKey(name); + if (newName) { + VIR_DEBUG("Got an LVM UUID %s for %s", newName, name); + if (!(newLockspace = strdup(driver->lvmLockSpaceDir))) + goto no_memory; + autoCreate = true; + break; + } + virResetLastError(); + /* Fallback to generic non-block code */ + } + if (driver->fileLockSpaceDir) { if (!(newLockspace = strdup(driver->fileLockSpaceDir))) goto no_memory; diff --git a/src/locking/lockd.conf b/src/locking/lockd.conf index 7545fd9..00f9b49 100644 --- a/src/locking/lockd.conf +++ b/src/locking/lockd.conf @@ -38,3 +38,17 @@ # storage. # #file_lockspace_dir = "/var/lib/libvirt/lockd/files" + + +# +# When using LVM volumes that can be visible across +# multiple, it is desirable to do locking based on +# the unique UUID associated with each volume, instead +# of their paths. Setting this path causes libvirt to +# do UUID based locking for LVM. +# +# Typically this directory would be located on a shared +# filesystem visible to all hosts accessing the same +# storage. +# +#lvm_lockspace_dir = "/var/lib/libvirt/lockd/lvmvolumes" -- 1.7.11.7 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list