mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
virNetDevMacVLanCreateWithVPortProfile: Rework to support multiple FDs
For the multiqueue on macvtaps we are going to need to open the device multiple times. Currently, this is not supported. Rework the function, so that upper layers can be reworked too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1e90c744d5
commit
08da97bfb9
@ -349,6 +349,7 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
|
|||||||
&res_ifname,
|
&res_ifname,
|
||||||
VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
|
VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
|
||||||
cfg->stateDir,
|
cfg->stateDir,
|
||||||
|
NULL, 0,
|
||||||
macvlan_create_flags) < 0)
|
macvlan_create_flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -230,15 +230,18 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
|
|||||||
if (net->model && STREQ(net->model, "virtio"))
|
if (net->model && STREQ(net->model, "virtio"))
|
||||||
macvlan_create_flags |= VIR_NETDEV_MACVLAN_VNET_HDR;
|
macvlan_create_flags |= VIR_NETDEV_MACVLAN_VNET_HDR;
|
||||||
|
|
||||||
rc = virNetDevMacVLanCreateWithVPortProfile(
|
if (virNetDevMacVLanCreateWithVPortProfile(net->ifname,
|
||||||
net->ifname, &net->mac,
|
&net->mac,
|
||||||
virDomainNetGetActualDirectDev(net),
|
virDomainNetGetActualDirectDev(net),
|
||||||
virDomainNetGetActualDirectMode(net),
|
virDomainNetGetActualDirectMode(net),
|
||||||
def->uuid,
|
def->uuid,
|
||||||
virDomainNetGetActualVirtPortProfile(net),
|
virDomainNetGetActualVirtPortProfile(net),
|
||||||
&res_ifname,
|
&res_ifname,
|
||||||
vmop, cfg->stateDir,
|
vmop, cfg->stateDir,
|
||||||
macvlan_create_flags);
|
&rc, 1,
|
||||||
|
macvlan_create_flags) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
virDomainAuditNetDevice(def, net, res_ifname, true);
|
virDomainAuditNetDevice(def, net, res_ifname, true);
|
||||||
VIR_FREE(net->ifname);
|
VIR_FREE(net->ifname);
|
||||||
|
@ -727,11 +727,15 @@ virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
|
|||||||
* @res_ifname: Pointer to a string pointer where the actual name of the
|
* @res_ifname: Pointer to a string pointer where the actual name of the
|
||||||
* interface will be stored into if everything succeeded. It is up
|
* interface will be stored into if everything succeeded. It is up
|
||||||
* to the caller to free the string.
|
* to the caller to free the string.
|
||||||
|
* @tapfd: array of file descriptor return value for the new tap device
|
||||||
|
* @tapfdSize: number of file descriptors in @tapfd
|
||||||
* @flags: OR of virNetDevMacVLanCreateFlags.
|
* @flags: OR of virNetDevMacVLanCreateFlags.
|
||||||
*
|
*
|
||||||
* Returns file descriptor of the tap device in case of success with
|
* Creates a macvlan device. Optionally, if flags &
|
||||||
* @flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP, otherwise returns 0; returns
|
* VIR_NETDEV_MACVLAN_CREATE_WITH_TAP is set, @tapfd is populated with FDs of
|
||||||
* -1 on error.
|
* tap devices up to @tapfdSize.
|
||||||
|
*
|
||||||
|
* Return 0 on success, -1 on error.
|
||||||
*/
|
*/
|
||||||
int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
|
int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
|
||||||
const virMacAddr *macaddress,
|
const virMacAddr *macaddress,
|
||||||
@ -742,6 +746,8 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
|
|||||||
char **res_ifname,
|
char **res_ifname,
|
||||||
virNetDevVPortProfileOp vmOp,
|
virNetDevVPortProfileOp vmOp,
|
||||||
char *stateDir,
|
char *stateDir,
|
||||||
|
int *tapfd,
|
||||||
|
size_t tapfdSize,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
const char *type = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
|
const char *type = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
|
||||||
@ -853,10 +859,10 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) {
|
if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) {
|
||||||
if (virNetDevMacVLanTapOpen(cr_ifname, &rc, 1, 10) < 0)
|
if (virNetDevMacVLanTapOpen(cr_ifname, tapfd, tapfdSize, 10) < 0)
|
||||||
goto disassociate_exit;
|
goto disassociate_exit;
|
||||||
|
|
||||||
if (virNetDevMacVLanTapSetup(&rc, 1, vnet_hdr, false) < 0) {
|
if (virNetDevMacVLanTapSetup(tapfd, tapfdSize, vnet_hdr, tapfdSize > 0) < 0) {
|
||||||
VIR_FORCE_CLOSE(rc); /* sets rc to -1 */
|
VIR_FORCE_CLOSE(rc); /* sets rc to -1 */
|
||||||
goto disassociate_exit;
|
goto disassociate_exit;
|
||||||
}
|
}
|
||||||
@ -892,6 +898,8 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
|
|||||||
linkdev,
|
linkdev,
|
||||||
vf,
|
vf,
|
||||||
vmOp));
|
vmOp));
|
||||||
|
while (tapfdSize--)
|
||||||
|
VIR_FORCE_CLOSE(tapfd[tapfdSize]);
|
||||||
|
|
||||||
link_del_exit:
|
link_del_exit:
|
||||||
ignore_value(virNetDevMacVLanDelete(cr_ifname));
|
ignore_value(virNetDevMacVLanDelete(cr_ifname));
|
||||||
@ -1016,6 +1024,8 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname ATTRIBUTE_UNUSED,
|
|||||||
char **res_ifname ATTRIBUTE_UNUSED,
|
char **res_ifname ATTRIBUTE_UNUSED,
|
||||||
virNetDevVPortProfileOp vmop ATTRIBUTE_UNUSED,
|
virNetDevVPortProfileOp vmop ATTRIBUTE_UNUSED,
|
||||||
char *stateDir ATTRIBUTE_UNUSED,
|
char *stateDir ATTRIBUTE_UNUSED,
|
||||||
|
int *tapfd ATTRIBUTE_UNUSED,
|
||||||
|
size_t tapfdSize ATTRIBUTE_UNUSED,
|
||||||
unsigned int unused_flags ATTRIBUTE_UNUSED)
|
unsigned int unused_flags ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virReportSystemError(ENOSYS, "%s",
|
virReportSystemError(ENOSYS, "%s",
|
||||||
|
@ -71,9 +71,11 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
|
|||||||
char **res_ifname,
|
char **res_ifname,
|
||||||
virNetDevVPortProfileOp vmop,
|
virNetDevVPortProfileOp vmop,
|
||||||
char *stateDir,
|
char *stateDir,
|
||||||
|
int *tapfd,
|
||||||
|
size_t tapfdSize,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
|
||||||
ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(12) ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
|
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
|
||||||
const virMacAddr *macaddress,
|
const virMacAddr *macaddress,
|
||||||
|
Loading…
Reference in New Issue
Block a user