mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
sanlock: fix locking for readonly devices
Add ignore param for readonly and shared disk in sanlock
This commit is contained in:
parent
891a7f9e23
commit
b8012ce931
1
AUTHORS
1
AUTHORS
@ -237,6 +237,7 @@ Patches have also been contributed by:
|
|||||||
Eugen Feller <eugen.feller@inria.fr>
|
Eugen Feller <eugen.feller@inria.fr>
|
||||||
Dmitry Guryanov <dguryanov@parallels.com>
|
Dmitry Guryanov <dguryanov@parallels.com>
|
||||||
William Jon McCann <william.jon.mccann@gmail.com>
|
William Jon McCann <william.jon.mccann@gmail.com>
|
||||||
|
David Weber <wb@munzinger.de>
|
||||||
|
|
||||||
[....send patches to get your name here....]
|
[....send patches to get your name here....]
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ module Libvirt_sanlock =
|
|||||||
| bool_entry "auto_disk_leases"
|
| bool_entry "auto_disk_leases"
|
||||||
| int_entry "host_id"
|
| int_entry "host_id"
|
||||||
| bool_entry "require_lease_for_disks"
|
| bool_entry "require_lease_for_disks"
|
||||||
|
| bool_entry "ignore_readonly_and_shared_disks"
|
||||||
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
|
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
|
||||||
let empty = [ label "#empty" . eol ]
|
let empty = [ label "#empty" . eol ]
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* lock_driver_sanlock.c: A lock driver for Sanlock
|
* lock_driver_sanlock.c: A lock driver for Sanlock
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2011 Red Hat, Inc.
|
* Copyright (C) 2010-2012 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -65,6 +65,7 @@ struct _virLockManagerSanlockDriver {
|
|||||||
bool requireLeaseForDisks;
|
bool requireLeaseForDisks;
|
||||||
int hostID;
|
int hostID;
|
||||||
bool autoDiskLease;
|
bool autoDiskLease;
|
||||||
|
bool ignoreReadonlyShared;
|
||||||
char *autoDiskLeasePath;
|
char *autoDiskLeasePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,6 +115,10 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
|
|||||||
CHECK_TYPE("auto_disk_leases", VIR_CONF_LONG);
|
CHECK_TYPE("auto_disk_leases", VIR_CONF_LONG);
|
||||||
if (p) driver->autoDiskLease = p->l;
|
if (p) driver->autoDiskLease = p->l;
|
||||||
|
|
||||||
|
p = virConfGetValue(conf, "ignore_readonly_and_shared_disks");
|
||||||
|
CHECK_TYPE("ignore_readonly_and_shared_disks", VIR_CONF_LONG);
|
||||||
|
if (p) driver->ignoreReadonlyShared = p->l;
|
||||||
|
|
||||||
p = virConfGetValue(conf, "disk_lease_dir");
|
p = virConfGetValue(conf, "disk_lease_dir");
|
||||||
CHECK_TYPE("disk_lease_dir", VIR_CONF_STRING);
|
CHECK_TYPE("disk_lease_dir", VIR_CONF_STRING);
|
||||||
if (p && p->str) {
|
if (p && p->str) {
|
||||||
@ -625,6 +630,12 @@ static int virLockManagerSanlockAddResource(virLockManagerPtr lock,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((flags & (VIR_LOCK_MANAGER_RESOURCE_READONLY |
|
||||||
|
VIR_LOCK_MANAGER_RESOURCE_SHARED)) &&
|
||||||
|
driver->ignoreReadonlyShared) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & VIR_LOCK_MANAGER_RESOURCE_READONLY) {
|
if (flags & VIR_LOCK_MANAGER_RESOURCE_READONLY) {
|
||||||
virLockError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virLockError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Readonly leases are not supported"));
|
_("Readonly leases are not supported"));
|
||||||
|
@ -52,3 +52,10 @@
|
|||||||
# to enabled, otherwise it defaults to disabled.
|
# to enabled, otherwise it defaults to disabled.
|
||||||
#
|
#
|
||||||
#require_lease_for_disks = 1
|
#require_lease_for_disks = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# Enable this flag to have sanlock ignore readonly and shared disks.
|
||||||
|
# If disabled, then this rejects attempts to share resources until
|
||||||
|
# sanlock gains support for shared locks.
|
||||||
|
#
|
||||||
|
#ignore_readonly_and_shared_disks = 1
|
||||||
|
@ -4,6 +4,7 @@ module Test_libvirt_sanlock =
|
|||||||
disk_lease_dir = \"/var/lib/libvirt/sanlock\"
|
disk_lease_dir = \"/var/lib/libvirt/sanlock\"
|
||||||
host_id = 1
|
host_id = 1
|
||||||
require_lease_for_disks = 1
|
require_lease_for_disks = 1
|
||||||
|
ignore_readonly_and_shared_disks = 1
|
||||||
"
|
"
|
||||||
|
|
||||||
test Libvirt_sanlock.lns get conf =
|
test Libvirt_sanlock.lns get conf =
|
||||||
@ -11,3 +12,4 @@ require_lease_for_disks = 1
|
|||||||
{ "disk_lease_dir" = "/var/lib/libvirt/sanlock" }
|
{ "disk_lease_dir" = "/var/lib/libvirt/sanlock" }
|
||||||
{ "host_id" = "1" }
|
{ "host_id" = "1" }
|
||||||
{ "require_lease_for_disks" = "1" }
|
{ "require_lease_for_disks" = "1" }
|
||||||
|
{ "ignore_readonly_and_shared_disks" = "1" }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user