virnetdevmacvlan.h 5.0 KB
Newer Older
1
/*
2
 * Copyright (C) 2011, 2013, 2016 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13 14 15
 * Copyright (C) 2010 IBM Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library.  If not, see
O
Osier Yang 已提交
17
 * <http://www.gnu.org/licenses/>.
18 19
 */

20
#pragma once
21

22 23 24 25 26 27 28
#include "internal.h"
#include "virmacaddr.h"
#include "virsocketaddr.h"
#include "virnetdevbandwidth.h"
#include "virnetdevvportprofile.h"
#include "virnetdevvlan.h"
#include "virenum.h"
29

30
/* the mode type for macvtap devices */
31
typedef enum {
32 33 34 35
    VIR_NETDEV_MACVLAN_MODE_VEPA,
    VIR_NETDEV_MACVLAN_MODE_PRIVATE,
    VIR_NETDEV_MACVLAN_MODE_BRIDGE,
    VIR_NETDEV_MACVLAN_MODE_PASSTHRU,
36

37
    VIR_NETDEV_MACVLAN_MODE_LAST,
38
} virNetDevMacVLanMode;
39
VIR_ENUM_DECL(virNetDevMacVLanMode);
40

41 42 43 44
typedef enum {
   VIR_NETDEV_MACVLAN_CREATE_NONE     = 0,
   /* Create with a tap device */
   VIR_NETDEV_MACVLAN_CREATE_WITH_TAP = 1 << 0,
45 46
   /* Bring the interface up */
   VIR_NETDEV_MACVLAN_CREATE_IFUP     = 1 << 1,
47 48
   /* Enable VNET_HDR */
   VIR_NETDEV_MACVLAN_VNET_HDR          = 1 << 2,
49 50
} virNetDevMacVLanCreateFlags;

51 52 53
/* libvirt will start macvtap/macvlan interface names with one of
 * these prefixes when it auto-generates the name
 */
54 55
#define VIR_NET_GENERATED_MACVTAP_PREFIX "macvtap"
#define VIR_NET_GENERATED_MACVLAN_PREFIX "macvlan"
56

57 58 59
int virNetDevMacVLanReserveName(const char *name, bool quietfail);
int virNetDevMacVLanReleaseName(const char *name);

60 61 62
bool virNetDevMacVLanIsMacvtap(const char *ifname)
   ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NOINLINE;

63 64
int virNetDevMacVLanCreate(const char *ifname,
                           const char *type,
65
                           const virMacAddr *macaddress,
66 67 68 69 70 71 72 73 74
                           const char *srcdev,
                           uint32_t macvlan_mode,
                           int *retry)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
    ATTRIBUTE_RETURN_CHECK;

int virNetDevMacVLanDelete(const char *ifname)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;

75
int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
76
                                           const virMacAddr *macaddress,
77
                                           const char *linkdev,
78
                                           virNetDevMacVLanMode mode,
79
                                           virNetDevVlanPtr vlan,
80 81 82
                                           const unsigned char *vmuuid,
                                           virNetDevVPortProfilePtr virtPortProfile,
                                           char **res_ifname,
83
                                           virNetDevVPortProfileOp vmop,
84
                                           char *stateDir,
85 86
                                           int *tapfd,
                                           size_t tapfdSize,
87
                                           unsigned int flags)
88 89
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
    ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) ATTRIBUTE_RETURN_CHECK;
90

91
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
92
                                           const virMacAddr *macaddress,
93 94 95 96
                                           const char *linkdev,
                                           int mode,
                                           virNetDevVPortProfilePtr virtPortProfile,
                                           char *stateDir)
97
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
98
    ATTRIBUTE_NONNULL(6) ATTRIBUTE_RETURN_CHECK;
99

100
int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname,
101 102 103 104 105
                                            const virMacAddr *macaddress,
                                            const char *linkdev,
                                            const unsigned char *vmuuid,
                                            virNetDevVPortProfilePtr virtPortProfile,
                                            virNetDevVPortProfileOp vmOp)
106
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
107
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
108

109
int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
110 111 112 113 114
                                                 const virMacAddr *macaddress,
                                                 const char *linkdev,
                                                 const unsigned char *vmuuid,
                                                 virNetDevVPortProfilePtr virtPortProfile,
                                                 virNetDevVPortProfileOp vmOp)
115
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
116
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;