g_free(def->virtio);
g_free(def->coalesce);
g_free(def->sourceDev);
+ g_free(def->tapfdpath);
virNetDevIPInfoClear(&def->guestIP);
virNetDevIPInfoClear(&def->hostIP);
return NULL;
}
+ if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) {
+ def->tapfdpath = virXPathString("string(./tapfd/@path)", ctxt);
+ }
+
if (virNetworkPortOptionsParseXML(ctxt, &def->isolatedPort) < 0)
return NULL;
if (def->mtu)
virBufferAsprintf(buf, "<mtu size='%u'/>\n", def->mtu);
+ if (def->tapfdpath && (flags & VIR_DOMAIN_DEF_FORMAT_STATUS))
+ virBufferEscapeString(buf, "<tapfd path='%s'/>\n", def->tapfdpath);
+
virDomainNetDefCoalesceFormatXML(buf, def->coalesce);
virDomainDeviceInfoFormat(buf, &def->info, flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT
if (virNetDevMacVLanIsMacvtap(net->ifname)) {
auditdev = net->ifname;
- if (virNetDevMacVLanTapOpen(net->ifname, tapfd, tapfdSize) < 0)
+ if (virNetDevMacVLanTapOpen(net->ifname, tapfd, tapfdSize, &net->tapfdpath) < 0)
goto cleanup;
if (virNetDevMacVLanTapSetup(tapfd, tapfdSize,
virDomainInterfaceIsVnetCompatModel(net)) < 0) {
int
virNetDevMacVLanTapOpen(const char *ifname,
int *tapfd,
- size_t tapfdSize)
+ size_t tapfdSize,
+ char **tapname)
{
int ret = -1;
int ifindex;
size_t i = 0;
- g_autofree char *tapname = NULL;
if (virNetDevGetIndex(ifname, &ifindex) < 0)
return -1;
- tapname = g_strdup_printf("/dev/tap%d", ifindex);
+ *tapname = g_strdup_printf("/dev/tap%d", ifindex);
for (i = 0; i < tapfdSize; i++) {
int fd = -1;
- if ((fd = open(tapname, O_RDWR)) < 0) {
+ if ((fd = open(*tapname, O_RDWR)) < 0) {
virReportSystemError(errno,
_("cannot open macvtap tap device %1$s"),
- tapname);
+ *tapname);
goto cleanup;
}
tapfd[i] = fd;
cleanup:
if (ret < 0) {
+ g_clear_pointer(tapname, g_free);
while (i--)
VIR_FORCE_CLOSE(tapfd[i]);
}
char *stateDir,
int *tapfd,
size_t tapfdSize,
+ char **tapfdpath,
unsigned int flags)
{
g_autofree char *ifname = NULL;
}
if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) {
- if (virNetDevMacVLanTapOpen(ifname, tapfd, tapfdSize) < 0)
+ if (virNetDevMacVLanTapOpen(ifname, tapfd, tapfdSize, tapfdpath) < 0)
goto disassociate_exit;
if (virNetDevMacVLanTapSetup(tapfd, tapfdSize, vnet_hdr) < 0)
int
virNetDevMacVLanTapOpen(const char *ifname G_GNUC_UNUSED,
int *tapfd G_GNUC_UNUSED,
- size_t tapfdSize G_GNUC_UNUSED)
+ size_t tapfdSize G_GNUC_UNUSED,
+ char **tapname G_GNUC_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
_("Cannot create macvlan devices on this platform"));
char *stateDir G_GNUC_UNUSED,
int *tapfd G_GNUC_UNUSED,
size_t tapfdSize G_GNUC_UNUSED,
+ char **tapfdpath G_GNUC_UNUSED,
unsigned int unused_flags G_GNUC_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
+ <interface type='direct'>
+ <mac address='52:54:00:36:bd:3c'/>
+ <source dev='eth0' mode='vepa'/>
+ <model type='rtl8139'/>
+ <tapfd path='/dev/tap8'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
+ </interface>
<serial type='pty'>
<source path='/dev/pts/67'/>
<target type='isa-serial' port='0'>