virnetdevvportprofile.h 4.4 KB
Newer Older
1
/*
2
 * Copyright (C) 2009-2013 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13 14
 *
 * 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
15
 * License along with this library.  If not, see
O
Osier Yang 已提交
16
 * <http://www.gnu.org/licenses/>.
17 18
 */

19
#pragma once
20

21 22 23 24
#include "internal.h"
#include "viruuid.h"
#include "virmacaddr.h"
#include "virenum.h"
25

26
#define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
27

28
typedef enum virNetDevVPortProfile {
29 30 31
    VIR_NETDEV_VPORT_PROFILE_NONE,
    VIR_NETDEV_VPORT_PROFILE_8021QBG,
    VIR_NETDEV_VPORT_PROFILE_8021QBH,
A
Ansis Atteka 已提交
32
    VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH,
33
    VIR_NETDEV_VPORT_PROFILE_MIDONET,
34 35

    VIR_NETDEV_VPORT_PROFILE_LAST,
36
} virNetDevVPortProfileType;
37
VIR_ENUM_DECL(virNetDevVPort);
38

39
typedef enum {
40 41 42 43 44 45 46 47 48 49
    VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
    VIR_NETDEV_VPORT_PROFILE_OP_SAVE,
    VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
    VIR_NETDEV_VPORT_PROFILE_OP_DESTROY,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_OUT,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH,
    VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,

    VIR_NETDEV_VPORT_PROFILE_OP_LAST
50
} virNetDevVPortProfileOp;
51
VIR_ENUM_DECL(virNetDevVPortProfileOp);
52

A
Ansis Atteka 已提交
53
/* profile data for macvtap (VEPA) and openvswitch */
54 55 56
typedef struct _virNetDevVPortProfile virNetDevVPortProfile;
typedef virNetDevVPortProfile *virNetDevVPortProfilePtr;
struct _virNetDevVPortProfile {
57
    int           virtPortType; /* enum virNetDevVPortProfile */
58 59
    /* these members are used when virtPortType == 802.1Qbg */
    uint8_t       managerID;
60
    bool          managerID_specified;
61
    uint32_t      typeID; /* 24 bit valid */
62
    bool          typeID_specified;
63
    uint8_t       typeIDVersion;
64
    bool          typeIDVersion_specified;
65
    unsigned char instanceID[VIR_UUID_BUFLEN];
66
    bool          instanceID_specified;
67 68

    /* this member is used when virtPortType == 802.1Qbh|openvswitch */
69
    /* this is a null-terminated character string */
70 71
    char          profileID[LIBVIRT_IFLA_VF_PORT_PROFILE_MAX];

72
    /* this member is used when virtPortType == openvswitch|midonet */
73
    unsigned char interfaceID[VIR_UUID_BUFLEN];
74
    bool          interfaceID_specified;
75
    /* NB - if virtPortType == NONE, any/all of the items could be used */
76 77 78
};


79 80
bool virNetDevVPortProfileEqual(const virNetDevVPortProfile *a,
                                const virNetDevVPortProfile *b);
81 82
int virNetDevVPortProfileCopy(virNetDevVPortProfilePtr *dst,
                              const virNetDevVPortProfile *src);
83

84 85
int virNetDevVPortProfileCheckComplete(virNetDevVPortProfilePtr virtport,
                                       bool generateMissing);
86
int virNetDevVPortProfileCheckNoExtras(const virNetDevVPortProfile *virtport);
87 88

int virNetDevVPortProfileMerge3(virNetDevVPortProfilePtr *result,
89 90 91
                                const virNetDevVPortProfile *fromInterface,
                                const virNetDevVPortProfile *fromNetwork,
                                const virNetDevVPortProfile *fromPortgroup);
92

93
int virNetDevVPortProfileAssociate(const char *ifname,
94
                                   const virNetDevVPortProfile *virtPort,
95
                                   const virMacAddr *macvtap_macaddr,
96
                                   const char *linkdev,
97
                                   int vf,
98
                                   const unsigned char *vmuuid,
99
                                   virNetDevVPortProfileOp vmOp,
100
                                   bool setlink_only)
101
    ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT;
102 103

int virNetDevVPortProfileDisassociate(const char *ifname,
104
                                      const virNetDevVPortProfile *virtPort,
105
                                      const virMacAddr *macvtap_macaddr,
106
                                      const char *linkdev,
107
                                      int vf,
108
                                      virNetDevVPortProfileOp vmOp)
109
    ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT;