From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=Ce9vbM4v; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 05ED35A004E for ; Mon, 14 Oct 2024 07:02:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1728882164; bh=m3lGG/5Srs479XO+5gFz7YWox4XEIkQxks/nzt0R4OY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ce9vbM4vGu+DtkF9oBqlNsdK1dUdehrSuxlaFyawpblgYHcWbXTNuT/UduMJGBqyY Up44wkAgMJGBTCieAhzkYMu/4HmCC+jVx1iSMZDHp/hsECDD8jtVNd47ApWkKfpB6T a1Wo1Zg+JJQz/Wc4lMUlIgt/F7kygLOHbIuEpb6eNpBe8GzmjI2npyBP1SWhrPzYIu 5g95wcnojWFXVnmN8en99xYvPhUEK6kk4qq/8YdlpIHx1qkRH9/CIBljt9w/A/XUcl zKIe2kbl+pR/wWR8Tbc9z5q7xJd/6h9ujihuvp3iUTgKK/HVKuVT4BkQFdEjcdNCHz N7sq9RFt4PoWg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XRlTw2ppRz4xFt; Mon, 14 Oct 2024 16:02:44 +1100 (AEDT) Date: Mon, 14 Oct 2024 15:30:53 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v8 6/8] passt: rename tap_sock_init() to tap_backend_init() Message-ID: References: <20241010122903.1188992-1-lvivier@redhat.com> <20241010122903.1188992-7-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LxzJbeWJSnDAIqUA" Content-Disposition: inline In-Reply-To: <20241010122903.1188992-7-lvivier@redhat.com> Message-ID-Hash: CIQQHP3733RM4KIKD7FESUPL4B3QB27Q X-Message-ID-Hash: CIQQHP3733RM4KIKD7FESUPL4B3QB27Q X-MailFrom: dgibson@gandalf.ozlabs.org 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: --LxzJbeWJSnDAIqUA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 10, 2024 at 02:29:00PM +0200, Laurent Vivier wrote: > Extract pool storage initialization loop to tap_sock_update_pool(), > extract QEMU hints to tap_backend_show_hints(). >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > passt.c | 2 +- > tap.c | 56 +++++++++++++++++++++++++++++++++++++++++--------------- > tap.h | 2 +- > 3 files changed, 43 insertions(+), 17 deletions(-) >=20 > diff --git a/passt.c b/passt.c > index ad6f0bc32df6..79093ee02d62 100644 > --- a/passt.c > +++ b/passt.c > @@ -261,7 +261,7 @@ int main(int argc, char **argv) > =20 > pasta_netns_quit_init(&c); > =20 > - tap_sock_init(&c); > + tap_backend_init(&c); > =20 > secret_init(&c); > =20 > diff --git a/tap.c b/tap.c > index c53a39b79e62..4b826fdf7adc 100644 > --- a/tap.c > +++ b/tap.c > @@ -1188,11 +1188,31 @@ int tap_sock_unix_open(char *sock_path) > return fd; > } > =20 > +/** > + * tap_backend_show_hints() - Give help information to start QEMU > + * @c: Execution context > + */ > +static void tap_backend_show_hints(struct ctx *c) > +{ > + switch(c->mode) { > + case MODE_PASTA: > + /* No hints */ > + break; > + case MODE_PASST: > + info("\nYou can now start qemu (>=3D 7.2, with commit 13c6be96618c):"); > + info(" kvm ... -device virtio-net-pci,netdev=3Ds -netdev stream,id= =3Ds,server=3Doff,addr.type=3Dunix,addr.path=3D%s", > + c->sock_path); > + info("or qrap, for earlier qemu versions:"); > + info(" ./qrap 5 kvm ... -net socket,fd=3D5 -net nic,model=3Dvirtio"= ); > + break; > + } > +} > + > /** > * tap_sock_unix_init() - Start listening for connections on AF_UNIX soc= ket > * @c: Execution context > */ > -static void tap_sock_unix_init(struct ctx *c) > +static void tap_sock_unix_init(const struct ctx *c) > { > union epoll_ref ref =3D { .type =3D EPOLL_TYPE_TAP_LISTEN }; > struct epoll_event ev =3D { 0 }; > @@ -1203,12 +1223,6 @@ static void tap_sock_unix_init(struct ctx *c) > ev.events =3D EPOLLIN | EPOLLET; > ev.data.u64 =3D ref.u64; > epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap_listen, &ev); > - > - info("\nYou can now start qemu (>=3D 7.2, with commit 13c6be96618c):"); > - info(" kvm ... -device virtio-net-pci,netdev=3Ds -netdev stream,id= =3Ds,server=3Doff,addr.type=3Dunix,addr.path=3D%s", > - c->sock_path); > - info("or qrap, for earlier qemu versions:"); > - info(" ./qrap 5 kvm ... -net socket,fd=3D5 -net nic,model=3Dvirtio"); > } > =20 > /** > @@ -1321,21 +1335,31 @@ static void tap_sock_tun_init(struct ctx *c) > } > =20 > /** > - * tap_sock_init() - Create and set up AF_UNIX socket or tuntap file des= criptor > - * @c: Execution context > + * tap_sock_update_pool() - Set the buffer base and size for the pool of= packets > + * @base: Buffer base > + * @size Buffer size > */ > -void tap_sock_init(struct ctx *c) > +static void tap_sock_update_pool(void *base, size_t size) > { > - size_t sz =3D sizeof(pkt_buf); > int i; > =20 > - pool_tap4_storage =3D PACKET_INIT(pool_tap4, TAP_MSGS, pkt_buf, sz); > - pool_tap6_storage =3D PACKET_INIT(pool_tap6, TAP_MSGS, pkt_buf, sz); > + pool_tap4_storage =3D PACKET_INIT(pool_tap4, TAP_MSGS, base, size); > + pool_tap6_storage =3D PACKET_INIT(pool_tap6, TAP_MSGS, base, size); > =20 > for (i =3D 0; i < TAP_SEQS; i++) { > - tap4_l4[i].p =3D PACKET_INIT(pool_l4, UIO_MAXIOV, pkt_buf, sz); > - tap6_l4[i].p =3D PACKET_INIT(pool_l4, UIO_MAXIOV, pkt_buf, sz); > + tap4_l4[i].p =3D PACKET_INIT(pool_l4, UIO_MAXIOV, base, size); > + tap6_l4[i].p =3D PACKET_INIT(pool_l4, UIO_MAXIOV, base, size); > } > +} > + > +/** > + * tap_backend_init() - Create and set up AF_UNIX socket or > + * tuntap file descriptor > + * @c: Execution context > + */ > +void tap_backend_init(struct ctx *c) > +{ > + tap_sock_update_pool(pkt_buf, sizeof(pkt_buf)); > =20 > if (c->fd_tap !=3D -1) { /* Passed as --fd */ > struct epoll_event ev =3D { 0 }; > @@ -1365,4 +1389,6 @@ void tap_sock_init(struct ctx *c) > */ > memset(&c->guest_mac, 0xff, sizeof(c->guest_mac)); > } > + > + tap_backend_show_hints(c); > } > diff --git a/tap.h b/tap.h > index 85f1e8473711..8728cc5c09c3 100644 > --- a/tap.h > +++ b/tap.h > @@ -68,7 +68,7 @@ void tap_handler_pasta(struct ctx *c, uint32_t events, > void tap_handler_passt(struct ctx *c, uint32_t events, > const struct timespec *now); > int tap_sock_unix_open(char *sock_path); > -void tap_sock_init(struct ctx *c); > +void tap_backend_init(struct ctx *c); > void tap_flush_pools(void); > void tap_handler(struct ctx *c, const struct timespec *now); > void tap_add_packet(struct ctx *c, ssize_t l2len, char *p); --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --LxzJbeWJSnDAIqUA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmcMnn0ACgkQzQJF27ox 2GedDw/+PP1YX679Ov7IHGZXxCFOnHrNHwE+FLloTCNSgVvVv3WTmfns1DxPKMvY Hlhm8AEkU8MY3fDv1+CVAVRldNm3Az/rkpXXXX8EswhAmejsJW6rO+O705eNUU+/ Ta4Iqy1InXe22UfTz0LPcj2nat8L4VuNdQkwOWvk3CI/Ku6P2HRiv9KT/BHfDHE+ fNWt/0BH3JF3TMGzNR5V/6p88orhhmBeYfMfADNhr5i76xEIawFeX6CtApyGG4+O avLTE+BzPlPEKO3qZVLuUnmu76Ip0/KQzUnMtjLkqA++fNB1Sd77KgfKxHUj0TvA zLZpNUT+JlJ7zTRuuc4esJ+mxx9fQWkuKSvczzgsnlf71lBOgF423gM6ZeLASgg6 EbyVSZ5yu190768ZCPeNACxrRc/X0pP8JReQ6n0ikivzc8mlJcO/b13p/ebahbhu NNzpnTGLj3q530LRFOF3ag6w6O1zQsQys4Q3K/0o4aYpkV+suTAEE2csZhNKd4qZ 06RBvod4KNy0xpERXY6mpDsmm/JH3ZMGQ/2C9s0lKqYHAAfEiCfGNTXPfCa3vTrE LryUZ1ORjvQ5rToK6hDDB5pAPHkjLet7L79O38GNCZDDt3dVOrB7S97NvKY4LUKO nMuey2tTaXP0VSWbvd0e1ak43NssGHEcNAzUttJKvF+2UrBIGXY= =amZ9 -----END PGP SIGNATURE----- --LxzJbeWJSnDAIqUA--