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);
|
|
|
|
|
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)
|
|
|
|
ATTRIBUTE_RETURN_CHECK;
|
|
|
|
|
|
|
|
int virNetDevMacVLanDelete(const char *ifname)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
|
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,
|
2016-05-04 17:18:16 +00:00
|
|
|
virNetDevVlanPtr vlan,
|
2011-11-02 17:19:48 +00:00
|
|
|
const unsigned char *vmuuid,
|
|
|
|
virNetDevVPortProfilePtr virtPortProfile,
|
|
|
|
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)
|
|
|
|
ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) ATTRIBUTE_RETURN_CHECK;
|
2010-02-15 15:58:13 +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,
|
|
|
|
virNetDevVPortProfilePtr virtPortProfile,
|
|
|
|
char *stateDir)
|
2017-03-22 12:07:44 +00:00
|
|
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
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
|
|
|
ATTRIBUTE_NONNULL(6) ATTRIBUTE_RETURN_CHECK;
|
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,
|
|
|
|
virNetDevVPortProfilePtr virtPortProfile,
|
|
|
|
virNetDevVPortProfileOp vmOp)
|
2012-03-27 12:38:33 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
util: fix crash when starting macvtap interfaces
This patch resolves https://bugzilla.redhat.com/show_bug.cgi?id=815270
The function virNetDevMacVLanVPortProfileRegisterCallback() takes an
arg "virtPortProfile", and was checking it for non-NULL before using
it. However, the prototype for
virNetDevMacVLanPortProfileRegisterCallback had marked that arg with
ATTRIBUTE_NONNULL(). Contrary to what one may think,
ATTRIBUTE_NONNULL() does not provide any guarantee that an arg marked
as such really is always non-null; the only effect to the code
generated by gcc, is that gcc *assumes* it is non-NULL; this results
in, for example, the check for a non-NULL value being optimized out.
(Unfortunately, this code removal only occurs when optimization is
enabled, and I am in the habit of doing local builds with optimization
off to ease debugging, so the bug didn't show up in my earlier local
testing).
In general, virPortProfile might always be NULL, so it shouldn't be
marked as ATTRIBUTE_NONNULL. One other function prototype made this
same error, so this patch fixes it as well.
2012-04-25 19:49:44 +00:00
|
|
|
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
|
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,
|
|
|
|
virNetDevVPortProfilePtr virtPortProfile,
|
|
|
|
virNetDevVPortProfileOp vmOp)
|
2012-03-29 11:15:00 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
util: fix crash when starting macvtap interfaces
This patch resolves https://bugzilla.redhat.com/show_bug.cgi?id=815270
The function virNetDevMacVLanVPortProfileRegisterCallback() takes an
arg "virtPortProfile", and was checking it for non-NULL before using
it. However, the prototype for
virNetDevMacVLanPortProfileRegisterCallback had marked that arg with
ATTRIBUTE_NONNULL(). Contrary to what one may think,
ATTRIBUTE_NONNULL() does not provide any guarantee that an arg marked
as such really is always non-null; the only effect to the code
generated by gcc, is that gcc *assumes* it is non-NULL; this results
in, for example, the check for a non-NULL value being optimized out.
(Unfortunately, this code removal only occurs when optimization is
enabled, and I am in the habit of doing local builds with optimization
off to ease debugging, so the bug didn't show up in my earlier local
testing).
In general, virPortProfile might always be NULL, so it shouldn't be
marked as ATTRIBUTE_NONNULL. One other function prototype made this
same error, so this patch fixes it as well.
2012-04-25 19:49:44 +00:00
|
|
|
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
|