[PATCH 8/9] Add some checking to MDRaidArrayDevice._setSpares.

Anne Mulhern amulhern at redhat.com
Fri Mar 21 15:31:04 UTC 2014





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at 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 at 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


More information about the anaconda-patches mailing list