[libvirt] [PATCH 1/2] conf: reject duplicate paths in device weights

Hu Tao hutao at cn.fujitsu.com
Wed Nov 30 01:30:58 UTC 2011


On Tue, Nov 29, 2011 at 02:11:43PM -0700, Eric Blake wrote:
> The next patch will make it possible to have virDomainSetBlkioParameters
> leave device weights unchanged if they are not mentioned in the incoming
> string, but this only works if the list of block weights does not allow
> duplicate paths.  Technically, a user can still confuse libvirt by
> passing alternate spellings that resolve to the same device, but it
> is not worth worrying about working around that kind of abuse.
> 
> * src/conf/domain_conf.c (virDomainDefParseXML): Require unique
> paths.
> ---
>  src/conf/domain_conf.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index d50a5c7..8221c28 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -6908,10 +6908,20 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
>          goto no_memory;
> 
>      for (i = 0; i < n; i++) {
> +        int j;
>          if (virDomainBlkioDeviceWeightParseXML(nodes[i],
>                                                 &def->blkio.devices[i]) < 0)
>              goto error;
>          def->blkio.ndevices++;
> +        for (j = 0; j < i; j++) {
> +            if (STREQ(def->blkio.devices[j].path,
> +                      def->blkio.devices[i].path)) {
> +                virDomainReportError(VIR_ERR_XML_ERROR,
> +                                     _("duplicate device weight path '%s'"),
> +                                     def->blkio.devices[i].path);
> +                goto error;
> +            }
> +        }
>      }
>      VIR_FREE(nodes);
> 
> -- 
> 1.7.7.3

ACK.

-- 
Thanks,
Hu Tao




More information about the libvir-list mailing list