From: "Daniel P. Berrange" <berrange(a)redhat.com>
---
src/locking/lock_driver_lockd.c | 31 +++++++++++++++++++++++++++++++
src/locking/lockd.conf | 14 ++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index abae52d..8b07875 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -74,6 +74,7 @@ struct _virLockManagerLockDaemonDriver {
char *fileLockSpaceDir;
char *lvmLockSpaceDir;
+ char *scsiLockSpaceDir;
};
static virLockManagerLockDaemonDriverPtr driver = NULL;
@@ -146,6 +147,17 @@ static int virLockManagerLockDaemonLoadConfig(const char
*configFile)
}
}
+ p = virConfGetValue(conf, "scsi_lockspace_dir");
+ CHECK_TYPE("scsi_lockspace_dir", VIR_CONF_STRING);
+ if (p && p->str) {
+ VIR_FREE(driver->scsiLockSpaceDir);
+ if (!(driver->scsiLockSpaceDir = 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)
@@ -387,6 +399,10 @@ static int virLockManagerLockDaemonInit(unsigned int version,
if (driver->lvmLockSpaceDir &&
virLockManagerLockDaemonSetupLockspace(driver->lvmLockSpaceDir) < 0)
goto error;
+
+ if (driver->scsiLockSpaceDir &&
+ virLockManagerLockDaemonSetupLockspace(driver->scsiLockSpaceDir) < 0)
+ goto error;
}
return 0;
@@ -579,6 +595,21 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr
lock,
/* Fallback to generic non-block code */
}
+ if (STRPREFIX(name, "/dev") &&
+ driver->scsiLockSpaceDir) {
+ VIR_DEBUG("Trying to find an SCSI ID for %s", name);
+ newName = virStorageFileGetSCSIKey(name);
+ if (newName) {
+ VIR_DEBUG("Got an SCSI ID %s for %s", newName, name);
+ if (!(newLockspace = strdup(driver->scsiLockSpaceDir)))
+ 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 00f9b49..85edb91 100644
--- a/src/locking/lockd.conf
+++ b/src/locking/lockd.conf
@@ -52,3 +52,17 @@
# storage.
#
#lvm_lockspace_dir = "/var/lib/libvirt/lockd/lvmvolumes"
+
+
+#
+# When using SCSI 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 SCSI.
+#
+# Typically this directory would be located on a shared
+# filesystem visible to all hosts accessing the same
+# storage.
+#
+#scsi_lockspace_dir = "/var/lib/libvirt/lockd/scsivolumes"
--
1.7.11.7