From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 332C35A004F for ; Fri, 26 Jul 2024 13:25:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721993148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m/afw6JyuZjduuXBgOTuPfol/uUDbN30KB84Vbzc2xI=; b=TjNiHlrzde+djMCQKZ3VEBKuL6wlpdL9/HeR3E8o5yO137cWikkWJ6GEmAnGu9c8ixyOwx 2cNyvsIgRIVahCspHgT01IrwsE7qC4ZdS0esMIf4Z59dzdHWfq1A0XVXLVFGSB7hAwZz8k EctN8e3qYvUR1lvcoeIpslNxhw9apbo= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-34-3PBTInCYMKWB5PlLzgPy5w-1; Fri, 26 Jul 2024 07:25:46 -0400 X-MC-Unique: 3PBTInCYMKWB5PlLzgPy5w-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6b7917c2b69so7937316d6.1 for ; Fri, 26 Jul 2024 04:25:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721993145; x=1722597945; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=m/afw6JyuZjduuXBgOTuPfol/uUDbN30KB84Vbzc2xI=; b=Vs5iZmlyiQKD3QEE1DnyHo66blu2hypdFs+qtapZFDZ4bVLEVBOtbuuOUN9BUzGV1z XmtkcsKX8yNhNWneXywO41kYg/DcjStPonu91mkCOuniWPdRUPIOP8bpwqfz2uWK1UaQ wKdirEP+LUkAP/Q6U72hZu/Vc5U0qYtdlbC+IJ7JjfcQnOpkeKL0O9vgzO7bvd6NA/7u zRYdhCAjkXD3lo1dtgmomIrTcgc4NTKP4NsnOG0zsqW74A9xIxX0vGwREd8iOsJ8uJ5q mJlx+5kfyOSNsqaWrT/ZQEuWBGWjk3uaGcF57LO2EY04i4/7SmFF3+4sSUp7Jjeexbh6 S6Zw== X-Gm-Message-State: AOJu0YyoAaCjemig0Jn0TinI0dLDBy77zs/+MA+0qhtA4zH03xo7NC56 kEgOD3moCDRBwY0XPz55bt9/qq4v28izor3BszEyiwoAw9wMw8m5uRqG6wG6UYcNCnszKgzyK27 e88KUzPABb3zqPrnRlRKQz63wQ/tKco0yohSiyJ23+cD4ttDPGfLv3aW+YQiU X-Received: by 2002:a05:6214:cc7:b0:6b5:fa20:9b3d with SMTP id 6a1803df08f44-6bb3cac5660mr79210286d6.46.1721993145260; Fri, 26 Jul 2024 04:25:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkKxpgLBv1WpUtz5ZvxchbMJy3v+ii2ljqAoKcaw1zO4gK9MEfcbmBwyKouXKp7VicWrpEpg== X-Received: by 2002:a05:6214:cc7:b0:6b5:fa20:9b3d with SMTP id 6a1803df08f44-6bb3cac5660mr79210086d6.46.1721993144854; Fri, 26 Jul 2024 04:25:44 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f7e419csm15941986d6.0.2024.07.26.04.25.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jul 2024 04:25:44 -0700 (PDT) Date: Fri, 26 Jul 2024 13:25:08 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 1/5] tap: Better report errors receiving from QEMU socket Message-ID: <20240726132508.6a4d1147@elisabeth> In-Reply-To: <20240726072031.3941305-2-david@gibson.dropbear.id.au> References: <20240726072031.3941305-1-david@gibson.dropbear.id.au> <20240726072031.3941305-2-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: XOIGN2AVLW4RD7ZSGZSPANUYQH3WFJ2J X-Message-ID-Hash: XOIGN2AVLW4RD7ZSGZSPANUYQH3WFJ2J X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 26 Jul 2024 17:20:27 +1000 David Gibson wrote: > If we get an error on recv() from the QEMU socket, we currently don't > print any kind of error. Although this can happen in a non-fatal situation > such as a guest restarting, it's unusual enough that we realy should report > something for debugability. > > Add an error message in this case. Also always report when the qemu > connection closes for any reason, not just when it will cause us to exit > (--one-off). > > Signed-off-by: David Gibson > --- > tap.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/tap.c b/tap.c > index 44bd4445..a2ae7c2a 100644 > --- a/tap.c > +++ b/tap.c > @@ -969,10 +969,10 @@ void tap_add_packet(struct ctx *c, ssize_t l2len, char *p) > */ > static void tap_sock_reset(struct ctx *c) > { > - if (c->one_off) { > - info("Client closed connection, exiting"); > + info("Client connection closed%s", c->one_off ? ", exiting" : ""); > + > + if (c->one_off) > exit(EXIT_SUCCESS); > - } > > /* Close the connected socket, wait for a new connection */ > epoll_ctl(c->epollfd, EPOLL_CTL_DEL, c->fd_tap, NULL); > @@ -1005,8 +1005,10 @@ redo: > > n = recv(c->fd_tap, p, TAP_BUF_FILL, MSG_DONTWAIT); > if (n < 0) { > - if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) > + if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) { > + err_perror("Error receiving from QEMU socket"); Nit I'm fixing up on merge: it's not necessarily QEMU, because libkrun and perhaps others also use this path (in fact, the whole problem was reported as part of the libkrun integration). Maybe it's obvious to users anyway, but this might seriously confuse somebody who's using e.g. krun on Asahi Linux (is QEMU running, one might wonder): https://github.com/slp/krun#motivation https://github.com/slp/krun/blob/main/crates/krun/src/net.rs On top of that, now that we have an error message, I guess it would be nice to state we're resetting the connection, because it's not really obvious: the subsequent message from tap_sock_reset() makes it look like the client decided to close the connection on its own. So I'm changing this to: err("Error receiving from guest, resetting connection"); ...if you see an issue with it, I'll send another patch. -- Stefano