From: "David Lehman" <dlehman(a)redhat.com>
To: anaconda-patches(a)lists.fedorahosted.org
Sent: Thursday, March 20, 2014 1:14:12 PM
Subject: [PATCH 8/9] Add some checking to MDRaidArrayDevice._setSpares.
---
blivet/devices.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/blivet/devices.py b/blivet/devices.py
index 9b4620e..c0136ff 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -3309,7 +3309,15 @@ class MDRaidArrayDevice(ContainerDevice):
return spares
def _setSpares(self, spares):
- # FIXME: this is too simple to be right
+ if self.level.name == "raid0":
+ raise DeviceError("cannot specify spares for raid0")
+
+ max_spares = self.level.get_max_spares(len(self.parents))
+ if spares > max_spares:
+ log.debug("failed to set new spares value %d (max is %d)",
+ spares, max_spares)
+ raise DeviceError("new spares value is too large")
+
if self.totalDevices > spares:
self.memberDevices = self.totalDevices - spares
--
1.8.5.3
_______________________________________________
anaconda-patches mailing list
anaconda-patches(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
Probably it would be better to get RAID0._get_max_spares() to throw an exception
than to do an explicit check in _setSpares().
- mulhern