From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 2/4] qemu: Rebase patch for UNIX domain socket support to latest upstream Date: Fri, 28 Jan 2022 19:34:07 +0100 Message-ID: <20220128183409.3407795-3-sbrivio@redhat.com> In-Reply-To: <20220128183409.3407795-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1244534665043686467==" --===============1244534665043686467== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Signed-off-by: Stefano Brivio --- ...NIX-domain-sockets-to-be-used-as-net.patch | 63 ++++++------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/qemu/0001-net-Allow-also-UNIX-domain-sockets-to-be-used-as-net.p= atch b/qemu/0001-net-Allow-also-UNIX-domain-sockets-to-be-used-as-net.patch index 23cda71..9e71f88 100644 --- a/qemu/0001-net-Allow-also-UNIX-domain-sockets-to-be-used-as-net.patch +++ b/qemu/0001-net-Allow-also-UNIX-domain-sockets-to-be-used-as-net.patch @@ -1,7 +1,6 @@ -From ba51349d353f11e05c6341a7e065f2ade3874c68 Mon Sep 17 00:00:00 2001 -Message-Id: +From 83c3f76b8fe6b4a6bb45dcf5cfad65ec6f98a10e Mon Sep 17 00:00:00 2001 From: Stefano Brivio -Date: Wed, 21 Apr 2021 18:51:18 +0200 +Date: Wed, 26 Jan 2022 16:45:15 +0100 Subject: [PATCH 1/2] net: Allow also UNIX domain sockets to be used as -netd= ev socket =20 @@ -10,18 +9,17 @@ and the adaptation is trivial. =20 Signed-off-by: Stefano Brivio --- -SPDX-FileCopyrightText: 2020-2021 Red Hat GmbH +SPDX-FileCopyrightText: 2020-2022 Red Hat GmbH SPDX-License-Identifier: AGPL-3.0-or-later =20 - net/socket.c | 106 ++++++++++++++++++++++++++++++++++++++++-------- - qemu-options.hx | 12 +++--- - 2 files changed, 94 insertions(+), 24 deletions(-) + net/socket.c | 106 ++++++++++++++++++++++++++++++++++++++++++--------- + 1 file changed, 87 insertions(+), 19 deletions(-) =20 diff --git a/net/socket.c b/net/socket.c -index 15b410e8d825..aadd11dae2b3 100644 +index 2e5f3ac923..b901e22836 100644 --- a/net/socket.c +++ b/net/socket.c -@@ -511,26 +511,60 @@ static int net_socket_listen_init(NetClientState *peer, +@@ -511,26 +511,59 @@ static int net_socket_listen_init(NetClientState *peer, { NetClientState *nc; NetSocketState *s; @@ -41,6 +39,7 @@ index 15b410e8d825..aadd11dae2b3 100644 =20 - if (parse_host_port(&saddr, host_str, errp) < 0) { - return -1; +- } + pf =3D PF_INET; + saddr_size =3D sizeof(*saddr_in); +#ifndef WIN32 @@ -56,16 +55,15 @@ index 15b410e8d825..aadd11dae2b3 100644 + error_setg_errno(errp, errno, "path provided is not a socket"); + return -1; + } -+ +=20 +- fd =3D qemu_socket(PF_INET, SOCK_STREAM, 0); + saddr_un->sun_family =3D PF_UNIX; + strncpy(saddr_un->sun_path, host_str, sizeof(saddr_un->sun_path)); + + pf =3D PF_UNIX; + saddr_size =3D sizeof(*saddr_un); - } ++ } +#endif /* !WIN32 */ -=20 -- fd =3D qemu_socket(PF_INET, SOCK_STREAM, 0); + fd =3D qemu_socket(pf, SOCK_STREAM, 0); if (fd < 0) { error_setg_errno(errp, errno, "can't create stream socket"); @@ -91,7 +89,7 @@ index 15b410e8d825..aadd11dae2b3 100644 closesocket(fd); return -1; } -@@ -559,14 +593,44 @@ static int net_socket_connect_init(NetClientState *pee= r, +@@ -559,14 +592,43 @@ static int net_socket_connect_init(NetClientState *pee= r, Error **errp) { NetSocketState *s; @@ -103,15 +101,14 @@ index 15b410e8d825..aadd11dae2b3 100644 + struct sockaddr_in *saddr_in =3D (struct sockaddr_in *)&saddr; +#ifndef WIN32 + struct sockaddr_un *saddr_un =3D (struct sockaddr_un *)&saddr; -=20 -- if (parse_host_port(&saddr, host_str, errp) < 0) { -- return -1; + + if (strchr(host_str, ':')) { +#endif + if (parse_host_port(saddr_in, host_str, errp) < 0) + return -1; -+ +=20 +- if (parse_host_port(&saddr, host_str, errp) < 0) { +- return -1; + pf =3D PF_INET; + saddr_size =3D sizeof(*saddr_in); +#ifndef WIN32 @@ -141,7 +138,7 @@ index 15b410e8d825..aadd11dae2b3 100644 if (fd < 0) { error_setg_errno(errp, errno, "can't create stream socket"); return -1; -@@ -575,7 +639,7 @@ static int net_socket_connect_init(NetClientState *peer, +@@ -575,7 +637,7 @@ static int net_socket_connect_init(NetClientState *peer, =20 connected =3D 0; for(;;) { @@ -150,7 +147,7 @@ index 15b410e8d825..aadd11dae2b3 100644 if (ret < 0) { if (errno =3D=3D EINTR || errno =3D=3D EWOULDBLOCK) { /* continue */ -@@ -598,9 +662,15 @@ static int net_socket_connect_init(NetClientState *peer, +@@ -597,9 +659,15 @@ static int net_socket_connect_init(NetClientState *peer, return -1; } =20 @@ -169,30 +166,6 @@ index 15b410e8d825..aadd11dae2b3 100644 return 0; } =20 -diff --git a/qemu-options.hx b/qemu-options.hx -index fd21002bd61d..625a31dcdbc8 100644 ---- a/qemu-options.hx -+++ b/qemu-options.hx -@@ -2847,13 +2847,13 @@ SRST - #connect a TAP device to bridge qemubr0 - |qemu_system| linux.img -netdev bridge,br=3Dqemubr0,id=3Dn1 -device= virtio-net,netdev=3Dn1 -=20 --``-netdev socket,id=3Did[,fd=3Dh][,listen=3D[host]:port][,connect=3Dhost:po= rt]`` -+``-netdev socket,id=3Did[,fd=3Dh][,listen=3D[host]:port|path][,connect=3Dho= st:port|path]`` - This host network backend can be used to connect the guest's network -- to another QEMU virtual machine using a TCP socket connection. If -- ``listen`` is specified, QEMU waits for incoming connections on port -- (host is optional). ``connect`` is used to connect to another QEMU -- instance using the ``listen`` option. ``fd``\ =3Dh specifies an -- already opened TCP socket. -+ to another QEMU virtual machine using a TCP or a UNIX domain socket -+ connection. If ``listen`` is specified, QEMU waits for incoming -+ connections on port (host is optional), or on path. ``connect`` is used -+ to connect to another QEMU instance using the ``listen`` option. -+ ``fd``\ =3Dh specifies an already opened TCP or UNIX domain socket. -=20 - Example: -=20 --=20 -2.29.2 +2.28.0 =20 --=20 2.33.0 --===============1244534665043686467==--