On 4/8/26 8:16 AM, Michal Privoznik via Devel wrote:
From: Michal Privoznik <[email protected]>
Now that after previous commit the wait for udev to settle down
is done right after device creation, there's no need to have
additional wait in virNetDevMacVLanTapOpen(). It's effectively a
dead code. Remove it.
I looked all the way back to when this retry loop was put in - it went
in with the original macvtap support in 2010 (commit
315baab94432f52a039b1364588948e2f1365567) and had a comment that said
"number of retires in case udev for example may need to be waited for to
create the tap chardev". So anyway we can say that the reason for the
retry loop is "waiting for udev to settle", so definitely once we add
the virWaitForDevices() after the create (only in the case that has the
CREATE_WITH_TAP flag!), this code can safely be removed (assuming
there's not some other *unknown* reason that retrying was useful, of
course :-))
Reviewed-by: Laine Stump <[email protected]>
(contingent on modified Patch 1 being pushed first)
Signed-off-by: Michal Privoznik <[email protected]>
---
src/util/virnetdevmacvlan.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 347148542d..bbc943cc7d 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -158,7 +158,6 @@ virNetDevMacVLanTapOpen(const char *ifname,
int *tapfd,
size_t tapfdSize)
{
- int retries = 10;
int ret = -1;
int ifindex;
size_t i = 0;
@@ -172,20 +171,13 @@ virNetDevMacVLanTapOpen(const char *ifname,
for (i = 0; i < tapfdSize; i++) {
int fd = -1;
- while (fd < 0) {
- if ((fd = open(tapname, O_RDWR)) >= 0) {
- tapfd[i] = fd;
- } else if (retries-- > 0) {
- /* may need to wait for udev to be done */
- g_usleep(20000);
- } else {
- /* However, if haven't succeeded, quit. */
- virReportSystemError(errno,
- _("cannot open macvtap tap device %1$s"),
- tapname);
- goto cleanup;
- }
+ if ((fd = open(tapname, O_RDWR)) < 0) {
+ virReportSystemError(errno,
+ _("cannot open macvtap tap device %1$s"),
+ tapname);
+ goto cleanup;
}
+ tapfd[i] = fd;
}
ret = 0;