[libvirt] [PATCH v3 01/36] network: restrict usage of port management APIs

Laine Stump laine at laine.org
Fri Mar 22 18:33:32 UTC 2019


On 3/19/19 8:46 AM, Daniel P. Berrangé wrote:
> The port allocation APIs are currently called unconditionally for all
> types of NIC, but (mostly) only do anything for NICs with type=network.
>
> The exception is the port allocate API which does some validation even
> for NICs with type!=network. Relying on this validation is flawed,
> however, since the network driver may not even be installed. IOW virt
> drivers must not delegate validation to the network driver for NICs
> with type != network.
>
> This change allows us to report errors when the virtual network driver
> is not registered.
>
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>   src/conf/domain_conf.c      | 26 ++++++++------
>   src/libxl/libxl_domain.c    |  6 ++--
>   src/libxl/libxl_driver.c    |  9 +++--
>   src/lxc/lxc_driver.c        |  6 ++--
>   src/lxc/lxc_process.c       |  9 +++--
>   src/network/bridge_driver.c | 72 +++++++++++++++++++------------------
>   src/qemu/qemu_driver.c      |  6 ++--
>   src/qemu/qemu_hotplug.c     | 17 +++++----
>   src/qemu/qemu_process.c     |  9 +++--
>   9 files changed, 94 insertions(+), 66 deletions(-)

[...]


> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 4d4ab0f375..cf37a16c64 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -4371,8 +4371,11 @@ networkAllocateActualDevice(virDomainDefPtr dom,
>       size_t i;
>       int ret = -1;
>   
> -    if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK)
> -        goto validate;
> +    if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Expected a interface for a virtual network"));


Oops. Missed this the first time through - should be "an interface", not 
"a interface". There's a second occurence of this in 
networkReleaseActualDevice().





More information about the libvir-list mailing list