提交 565d040f 编写于 作者: D Daniel P. Berrange

Add support for locking based on LVM volume uuid

上级 f14fdae3
......@@ -20,6 +20,7 @@ module Libvirt_lockd =
let entry = bool_entry "auto_disk_leases"
| bool_entry "require_lease_for_disks"
| str_entry "file_lockspace_dir"
| str_entry "lvm_lockspace_dir"
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
let empty = [ label "#empty" . eol ]
......
......@@ -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,26 @@ 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);
if (virStorageFileGetLVMKey(name, &newName) < 0)
goto error;
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;
......@@ -623,6 +658,7 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
no_memory:
virReportOOMError();
error:
VIR_FREE(newLockspace);
VIR_FREE(newName);
return -1;
......
......@@ -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"
......@@ -5,3 +5,4 @@ module Test_libvirt_lockd =
{ "auto_disk_leases" = "0" }
{ "require_lease_for_disks" = "1" }
{ "file_lockspace_dir" = "/var/lib/libvirt/lockd/files" }
{ "lvm_lockspace_dir" = "/var/lib/libvirt/lockd/lvmvolumes" }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册