[libvirt] [PATCH v2] automatic create tap device with network type ethernet

Michal Privoznik mprivozn at redhat.com
Fri Dec 5 11:09:25 UTC 2014


On 28.11.2014 14:40, Vasiliy Tolstov wrote:
> If user not specify script in network type ethernet, assume that user
> needs simple tap device created with libvirt.
> This patch does not need to run external script to create tap device or
> add root to qemu process.
>
> Signed-off-by: Vasiliy Tolstov <v.tolstov at selfip.ru>
> ---
>   src/qemu/qemu_command.c | 86 ++++++++++++++++++++++++++++++++-----------------
>   src/qemu/qemu_hotplug.c | 10 ++----
>   src/qemu/qemu_process.c |  4 +++
>   3 files changed, 62 insertions(+), 38 deletions(-)
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 4ed6506..0911c32 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -319,7 +319,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
>       } else if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
>           if (VIR_STRDUP(brname, virDomainNetGetActualBridgeName(net)) < 0)
>               return ret;
> -    } else {
> +    } else if (actualType != VIR_DOMAIN_NET_TYPE_ETHERNET) {
>           virReportError(VIR_ERR_INTERNAL_ERROR,
>                          _("Network type %d is not supported"),
>                          virDomainNetGetActualType(net));
> @@ -341,30 +341,40 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
>           tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
>       }
>
> -    if (cfg->privileged) {
> -        if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
> -                                           def->uuid, tunpath, tapfd, *tapfdSize,
> -                                           virDomainNetGetActualVirtPortProfile(net),
> -                                           virDomainNetGetActualVlan(net),
> -                                           tap_create_flags) < 0) {
> +    if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) {
> +        if (virNetDevTapCreate(&net->ifname, tunpath, tapfd, *tapfdSize,
> +                               tap_create_flags) < 0) {

Fortunately, when I was introducing multiqueue support, I've made it 
general enough so that even TYPE_ETHERNET can use multiqueue now.
This patch however fails make check. A few more modifications are 
needed. So let me respin the patch with fixed problems.

Michal




More information about the libvir-list mailing list