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 25
#include "internal.h"
#include "viruuid.h"
#include "virutil.h"
#include "virmacaddr.h"
#include "virenum.h"
26

27
#define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
28

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

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

40
typedef enum {
41 42 43 44 45 46 47 48 49 50
    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
51
} virNetDevVPortProfileOp;
52
VIR_ENUM_DECL(virNetDevVPortProfileOp);
53

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

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

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


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

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

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

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

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