[libvirt] [PATCH V2 2/2] libxl: limit support for specifying an interface script

Laine Stump laine at laine.org
Thu Jun 19 08:36:36 UTC 2014


On 06/11/2014 12:25 AM, Jim Fehlig wrote:
> Generally, <interface> ... <script> is only supported for
> type='ethernet'.  Due to the long and pervasive use of
>
>   <interface type='bridge'>
>     ...
>     <script path='foo'/>
>   </interface>
>
> in Xen domain configuration, it was agreed to allow the use
> of <script> with type='bridge' for backwards compatibility.  See
> the following discussion thread
>
> http://www.redhat.com/archives/libvir-list/2013-April/msg00755.html
>
> This patch limits the use of <script> to interface types ethernet
> and bridge, raising an unsupported config error if <script> is
> specified for all other interface types.
>
> While at it, use VIR_ERR_CONFIG_UNSUPPORTED instead of
> VIR_ERR_INTERNAL_ERROR when reporting unsupported interface types.
>
> Signed-off-by: Jim Fehlig <jfehlig at suse.com>
> ---
>  src/libxl/libxl_conf.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 9c453d8..6a025f0 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -881,6 +881,14 @@ libxlMakeNic(virDomainDefPtr def,
>       * x_nics[i].mtu = 1492;
>       */
>  
> +    if (l_nic->script && !(actual_type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
> +                           actual_type == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                       _("specifying a script is only supported with "
> +                         "interface types bridge and ethernet"));
> +        return -1;
> +    }
> +
>      libxl_device_nic_init(x_nic);
>  
>      virMacAddrGetRaw(&l_nic->mac, x_nic->mac);
> @@ -954,8 +962,8 @@ libxlMakeNic(virDomainDefPtr def,
>          case VIR_DOMAIN_NET_TYPE_DIRECT:
>          case VIR_DOMAIN_NET_TYPE_HOSTDEV:
>          case VIR_DOMAIN_NET_TYPE_LAST:
> -            virReportError(VIR_ERR_INTERNAL_ERROR,
> -                    _("libxenlight does not support network device type %s"),
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                    _("unsupported interface type %s"),
>                      virDomainNetTypeToString(l_nic->type));
>              return -1;
>      }

ACK.




More information about the libvir-list mailing list