Skip to content

Commit 3a246c5

Browse files
praveen-pkbryteise
authored andcommitted
ch: pass TAP device name to CLH instead of fds
If TAP fds are passed, during reboot CLH closes all FDs and that causes kernel to remove the tap device. This eventually causes guest reboot failures.
1 parent ba77e12 commit 3a246c5

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/ch/ch_domain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct _virCHDomainObjPrivate {
7777

7878
size_t tapfdSize;
7979
int *tapfd;
80+
char *tapName;
8081

8182
virThread vmThreadWatcher;
8283
int vmThreadWatcherStop;

src/ch/ch_monitor.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ virCHMonitorBuildNetJson(virDomainObjPtr vm, virJSONValuePtr nets, virDomainNetD
315315
char macaddr[VIR_MAC_STRING_BUFLEN];
316316
virCHDomainObjPrivatePtr priv = vm->privateData;
317317
virJSONValuePtr net;
318-
virJSONValuePtr clh_tapfds = NULL;
319-
int i = 0;
320318
net = virJSONValueNewObject();
321319

322320
switch (netType) {
@@ -387,18 +385,12 @@ virCHMonitorBuildNetJson(virDomainObjPtr vm, virJSONValuePtr nets, virDomainNetD
387385
goto cleanup;
388386
}
389387

390-
clh_tapfds = virJSONValueNewArray();
391-
for (i=0; i< priv->tapfdSize; i++) {
392-
virJSONValueArrayAppend(clh_tapfds, virJSONValueNewNumberUint(priv->tapfd[i]));
393-
}
394-
395-
if (virJSONValueObjectAppend(net, "fds", clh_tapfds) < 0)
388+
if (virJSONValueObjectAppendString(net, "tap", priv->tapName) < 0)
396389
goto cleanup;
397390

398391
if (virJSONValueObjectAppendString(net, "mac", virMacAddrFormat(&netdef->mac, macaddr)) < 0)
399392
goto cleanup;
400393

401-
402394
if (netdef->virtio != NULL) {
403395
if (netdef->virtio->iommu == VIR_TRISTATE_SWITCH_ON) {
404396
if (virJSONValueObjectAppendBoolean(net, "iommu", true) < 0)
@@ -616,7 +608,6 @@ chMonitorBuildSocketCmd(virDomainObjPtr vm, const char *socket_path)
616608
cmd = virCommandNew(CH_CMD);
617609

618610
virCommandAddArgList(cmd, "--api-socket", socket_path, NULL);
619-
620611
return cmd;
621612
}
622613

src/ch/ch_process.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "virjson.h"
3939
#include "virlog.h"
4040
#include "virpidfile.h"
41+
#include "virstring.h"
4142

4243
#define VIR_FROM_THIS VIR_FROM_CH
4344

@@ -608,14 +609,20 @@ chProcessNetworkPrepareDevices(virCHDriverPtr driver, virDomainObjPtr vm)
608609
// This info will be used while generating Network Json
609610
priv->tapfd = g_steal_pointer(&tapfd);
610611
priv->tapfdSize = tapfdSize;
612+
priv->tapName = g_new(char, IFNAMSIZ);
613+
if (virStrcpy(priv->tapName, net->ifname, IFNAMSIZ) < 0) {
614+
virReportError(VIR_ERR_INTERNAL_ERROR,
615+
_("net->ifname %s too big for destination"), net->ifname);
616+
goto cleanup;
617+
}
611618
}
612619
}
613620

614621
return 0;
615622

616623
cleanup:
617624
g_free(tapfd);
618-
return 0;
625+
return -1;
619626
}
620627

621628

0 commit comments

Comments
 (0)