2010-02-15 15:58:13 +00:00
|
|
|
/*
|
2016-01-19 19:20:54 +00:00
|
|
|
* Copyright (C) 2011, 2013, 2016 Red Hat, Inc.
|
2010-02-15 15:58:13 +00:00
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-02-15 15:58:13 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:48 +00:00
|
|
|
#pragma once
|
2010-02-15 15:58:13 +00:00
|
|
|
|
2019-06-18 16:12:48 +00:00
|
|
|
#include "internal.h"
|
|
|
|
#include "virmacaddr.h"
|
|
|
|
#include "virsocketaddr.h"
|
|
|
|
#include "virnetdevbandwidth.h"
|
|
|
|
#include "virnetdevvportprofile.h"
|
|
|
|
#include "virnetdevvlan.h"
|
|
|
|
#include "virenum.h"
|
2010-02-15 15:58:13 +00:00
|
|
|
|
2011-06-20 16:08:41 +00:00
|
|
|
/* the mode type for macvtap devices */
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
Rename Macvtap management APIs
In preparation for code re-organization, rename the Macvtap
management APIs to have the following patterns
virNetDevMacVLanXXXXX - macvlan/macvtap interface management
virNetDevVPortProfileXXXX - virtual port profile management
* src/util/macvtap.c, src/util/macvtap.h: Rename APIs
* src/conf/domain_conf.c, src/network/bridge_driver.c,
src/qemu/qemu_command.c, src/qemu/qemu_command.h,
src/qemu/qemu_driver.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/qemu/qemu_process.c,
src/qemu/qemu_process.h: Update for renamed APIs
2011-11-02 16:51:01 +00:00
|
|
|
VIR_NETDEV_MACVLAN_MODE_VEPA,
|
|
|
|
VIR_NETDEV_MACVLAN_MODE_PRIVATE,
|
|
|
|
VIR_NETDEV_MACVLAN_MODE_BRIDGE,
|
|
|
|
VIR_NETDEV_MACVLAN_MODE_PASSTHRU,
|
2011-06-20 16:08:41 +00:00
|
|
|
|
Rename Macvtap management APIs
In preparation for code re-organization, rename the Macvtap
management APIs to have the following patterns
virNetDevMacVLanXXXXX - macvlan/macvtap interface management
virNetDevVPortProfileXXXX - virtual port profile management
* src/util/macvtap.c, src/util/macvtap.h: Rename APIs
* src/conf/domain_conf.c, src/network/bridge_driver.c,
src/qemu/qemu_command.c, src/qemu/qemu_command.h,
src/qemu/qemu_driver.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/qemu/qemu_process.c,
src/qemu/qemu_process.h: Update for renamed APIs
2011-11-02 16:51:01 +00:00
|
|
|
VIR_NETDEV_MACVLAN_MODE_LAST,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virNetDevMacVLanMode;
|
2019-01-20 16:04:56 +00:00
|
|
|
VIR_ENUM_DECL(virNetDevMacVLanMode);
|
2010-12-01 14:43:40 +00:00
|
|
|
|
2014-08-27 14:34:13 +00:00
|
|
|
typedef enum {
|
|
|
|
VIR_NETDEV_MACVLAN_CREATE_NONE = 0,
|
|
|
|
/* Create with a tap device */
|
|
|
|
VIR_NETDEV_MACVLAN_CREATE_WITH_TAP = 1 << 0,
|
2014-09-16 20:50:53 +00:00
|
|
|
/* Bring the interface up */
|
|
|
|
VIR_NETDEV_MACVLAN_CREATE_IFUP = 1 << 1,
|
2015-12-03 10:33:55 +00:00
|
|
|
/* Enable VNET_HDR */
|
|
|
|
VIR_NETDEV_MACVLAN_VNET_HDR = 1 << 2,
|
2014-08-27 14:34:13 +00:00
|
|
|
} virNetDevMacVLanCreateFlags;
|
|
|
|
|
2017-04-25 18:09:45 +00:00
|
|
|
/* libvirt will start macvtap/macvlan interface names with one of
|
|
|
|
* these prefixes when it auto-generates the name
|
|
|
|
*/
|
2019-06-18 16:12:48 +00:00
|
|
|
#define VIR_NET_GENERATED_MACVTAP_PREFIX "macvtap"
|
|
|
|
#define VIR_NET_GENERATED_MACVLAN_PREFIX "macvlan"
|
2017-04-25 18:09:45 +00:00
|
|
|
|
2016-01-19 19:20:54 +00:00
|
|
|
int virNetDevMacVLanReserveName(const char *name, bool quietfail);
|
|
|
|
int virNetDevMacVLanReleaseName(const char *name);
|
|
|
|
|
2019-08-26 05:24:08 +00:00
|
|
|
bool virNetDevMacVLanIsMacvtap(const char *ifname)
|
2019-10-15 11:24:34 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
|
2019-08-26 05:24:08 +00:00
|
|
|
|
2011-11-02 17:34:41 +00:00
|
|
|
int virNetDevMacVLanCreate(const char *ifname,
|
|
|
|
const char *type,
|
2013-10-05 19:41:44 +00:00
|
|
|
const virMacAddr *macaddress,
|
2011-11-02 17:34:41 +00:00
|
|
|
const char *srcdev,
|
|
|
|
uint32_t macvlan_mode,
|
|
|
|
int *retry)
|
|
|
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2011-11-02 17:34:41 +00:00
|
|
|
|
|
|
|
int virNetDevMacVLanDelete(const char *ifname)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
|
2011-11-02 17:34:41 +00:00
|
|
|
|
2011-11-02 17:19:48 +00:00
|
|
|
int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
|
2013-10-05 19:41:44 +00:00
|
|
|
const virMacAddr *macaddress,
|
2011-11-02 17:19:48 +00:00
|
|
|
const char *linkdev,
|
2014-04-27 00:15:22 +00:00
|
|
|
virNetDevMacVLanMode mode,
|
2019-10-01 16:25:47 +00:00
|
|
|
const virNetDevVlan *vlan,
|
2011-11-02 17:19:48 +00:00
|
|
|
const unsigned char *vmuuid,
|
2019-10-01 17:56:35 +00:00
|
|
|
const virNetDevVPortProfile *virtPortProfile,
|
2011-11-02 17:19:48 +00:00
|
|
|
char **res_ifname,
|
2014-04-27 00:15:22 +00:00
|
|
|
virNetDevVPortProfileOp vmop,
|
2011-11-02 17:19:48 +00:00
|
|
|
char *stateDir,
|
2015-12-04 10:31:17 +00:00
|
|
|
int *tapfd,
|
|
|
|
size_t tapfdSize,
|
2014-08-27 14:34:13 +00:00
|
|
|
unsigned int flags)
|
2016-05-04 17:18:16 +00:00
|
|
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) G_GNUC_WARN_UNUSED_RESULT;
|
2010-02-15 15:58:13 +00:00
|
|
|
|
2019-08-26 05:51:40 +00:00
|
|
|
int virNetDevMacVLanTapOpen(const char *ifname,
|
|
|
|
int *tapfd,
|
|
|
|
size_t tapfdSize)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2019-08-26 05:51:40 +00:00
|
|
|
|
|
|
|
int virNetDevMacVLanTapSetup(int *tapfd, size_t tapfdSize, bool vnet_hdr)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
|
2019-08-26 05:51:40 +00:00
|
|
|
|
2011-11-02 17:19:48 +00:00
|
|
|
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
|
2013-10-05 19:41:44 +00:00
|
|
|
const virMacAddr *macaddress,
|
2011-11-02 17:19:48 +00:00
|
|
|
const char *linkdev,
|
|
|
|
int mode,
|
2019-10-01 17:56:35 +00:00
|
|
|
const virNetDevVPortProfile *virtPortProfile,
|
2011-11-02 17:19:48 +00:00
|
|
|
char *stateDir)
|
2017-03-22 12:07:44 +00:00
|
|
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(6) G_GNUC_WARN_UNUSED_RESULT;
|
2010-02-15 15:58:13 +00:00
|
|
|
|
2012-03-27 12:38:33 +00:00
|
|
|
int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname,
|
2017-02-10 14:35:23 +00:00
|
|
|
const virMacAddr *macaddress,
|
|
|
|
const char *linkdev,
|
|
|
|
const unsigned char *vmuuid,
|
2019-10-01 17:56:35 +00:00
|
|
|
const virNetDevVPortProfile *virtPortProfile,
|
2017-02-10 14:35:23 +00:00
|
|
|
virNetDevVPortProfileOp vmOp)
|
2012-03-27 12:38:33 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT;
|
2012-03-27 12:38:33 +00:00
|
|
|
|
2012-03-29 11:15:00 +00:00
|
|
|
int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
|
2017-02-10 14:35:23 +00:00
|
|
|
const virMacAddr *macaddress,
|
|
|
|
const char *linkdev,
|
|
|
|
const unsigned char *vmuuid,
|
2019-10-01 17:56:35 +00:00
|
|
|
const virNetDevVPortProfile *virtPortProfile,
|
2017-02-10 14:35:23 +00:00
|
|
|
virNetDevVPortProfileOp vmOp)
|
2012-03-29 11:15:00 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT;
|