* Call qemu_socketpair() instead of socketpair() when possible
@ 2023-01-16 4:56 Guoyi Tu
2023-01-16 7:33 ` Thomas Huth
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Guoyi Tu @ 2023-01-16 4:56 UTC (permalink / raw)
To: Stefan Berger, Marc-André Lureau, Thomas Huth,
Laurent Vivier, Paolo Bonzini, Juan Quintela,
Dr. David Alan Gilbert, Daniel P. Berrangé, marcandre.lureau
Cc: qemu-devel
As qemu_socketpair() was introduced in commit 3c63b4e9
("oslib-posix: Introduce qemu_socketpair()"), it's time
to replace the other existing socketpair() calls with
qemu_socketpair() if possible
Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
---
backends/tpm/tpm_emulator.c | 2 +-
tests/qtest/dbus-display-test.c | 5 +++--
tests/qtest/migration-test.c | 2 +-
tests/unit/test-crypto-tlssession.c | 4 ++--
tests/unit/test-io-channel-tls.c | 2 +-
5 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
index 49cc3d749d..67e7b212e3 100644
--- a/backends/tpm/tpm_emulator.c
+++ b/backends/tpm/tpm_emulator.c
@@ -553,7 +553,7 @@ static int tpm_emulator_prepare_data_fd(TPMEmulator
*tpm_emu)
Error *err = NULL;
int fds[2] = { -1, -1 };
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
+ if (qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
error_report("tpm-emulator: Failed to create socketpair");
return -1;
}
diff --git a/tests/qtest/dbus-display-test.c
b/tests/qtest/dbus-display-test.c
index cb1b62d1d1..fef025ac6f 100644
--- a/tests/qtest/dbus-display-test.c
+++ b/tests/qtest/dbus-display-test.c
@@ -1,5 +1,6 @@
#include "qemu/osdep.h"
#include "qemu/dbus.h"
+#include "qemu/sockets.h"
#include <gio/gio.h>
#include <gio/gunixfdlist.h>
#include "libqtest.h"
@@ -36,7 +37,7 @@ test_setup(QTestState **qts, GDBusConnection **conn)
*qts = qtest_init("-display dbus,p2p=yes -name dbus-test");
- g_assert_cmpint(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
+ g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
qtest_qmp_add_client(*qts, "@dbus-display", pair[1]);
@@ -152,7 +153,7 @@ test_dbus_display_console(void)
test_setup(&qts, &conn);
- g_assert_cmpint(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
+ g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
fd_list = g_unix_fd_list_new();
idx = g_unix_fd_list_append(fd_list, pair[1], NULL);
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index dbde726adf..1dd32c9506 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -1661,7 +1661,7 @@ static void *test_migrate_fd_start_hook(QTestState
*from,
int pair[2];
/* Create two connected sockets for migration */
- ret = socketpair(PF_LOCAL, SOCK_STREAM, 0, pair);
+ ret = qemu_socketpair(PF_LOCAL, SOCK_STREAM, 0, pair);
g_assert_cmpint(ret, ==, 0);
/* Send the 1st socket to the target */
diff --git a/tests/unit/test-crypto-tlssession.c
b/tests/unit/test-crypto-tlssession.c
index 615a1344b4..b12e7b6879 100644
--- a/tests/unit/test-crypto-tlssession.c
+++ b/tests/unit/test-crypto-tlssession.c
@@ -82,7 +82,7 @@ static void test_crypto_tls_session_psk(void)
int ret;
/* We'll use this for our fake client-server connection */
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
+ ret = qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
g_assert(ret == 0);
/*
@@ -236,7 +236,7 @@ static void test_crypto_tls_session_x509(const void
*opaque)
int ret;
/* We'll use this for our fake client-server connection */
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
+ ret = qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
g_assert(ret == 0);
/*
diff --git a/tests/unit/test-io-channel-tls.c
b/tests/unit/test-io-channel-tls.c
index cc39247556..e036ac5df4 100644
--- a/tests/unit/test-io-channel-tls.c
+++ b/tests/unit/test-io-channel-tls.c
@@ -121,7 +121,7 @@ static void test_io_channel_tls(const void *opaque)
GMainContext *mainloop;
/* We'll use this for our fake client-server connection */
- g_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
+ g_assert(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
#define CLIENT_CERT_DIR "tests/test-io-channel-tls-client/"
#define SERVER_CERT_DIR "tests/test-io-channel-tls-server/"
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: Call qemu_socketpair() instead of socketpair() when possible
2023-01-16 4:56 Call qemu_socketpair() instead of socketpair() when possible Guoyi Tu
@ 2023-01-16 7:33 ` Thomas Huth
2023-01-16 8:31 ` Philippe Mathieu-Daudé
2023-01-16 16:43 ` Laurent Vivier
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2023-01-16 7:33 UTC (permalink / raw)
To: Guoyi Tu, Stefan Berger, Marc-André Lureau, Laurent Vivier,
Paolo Bonzini, Juan Quintela, Dr. David Alan Gilbert,
Daniel P. Berrangé, marcandre.lureau
Cc: qemu-devel, QEMU Trivial
On 16/01/2023 05.56, Guoyi Tu wrote:
> As qemu_socketpair() was introduced in commit 3c63b4e9
> ("oslib-posix: Introduce qemu_socketpair()"), it's time
> to replace the other existing socketpair() calls with
> qemu_socketpair() if possible
>
> Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
> ---
> backends/tpm/tpm_emulator.c | 2 +-
> tests/qtest/dbus-display-test.c | 5 +++--
> tests/qtest/migration-test.c | 2 +-
> tests/unit/test-crypto-tlssession.c | 4 ++--
> tests/unit/test-io-channel-tls.c | 2 +-
> 5 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
> index 49cc3d749d..67e7b212e3 100644
> --- a/backends/tpm/tpm_emulator.c
> +++ b/backends/tpm/tpm_emulator.c
> @@ -553,7 +553,7 @@ static int tpm_emulator_prepare_data_fd(TPMEmulator
> *tpm_emu)
> Error *err = NULL;
> int fds[2] = { -1, -1 };
>
> - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
> + if (qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
> error_report("tpm-emulator: Failed to create socketpair");
> return -1;
> }
> diff --git a/tests/qtest/dbus-display-test.c b/tests/qtest/dbus-display-test.c
> index cb1b62d1d1..fef025ac6f 100644
> --- a/tests/qtest/dbus-display-test.c
> +++ b/tests/qtest/dbus-display-test.c
> @@ -1,5 +1,6 @@
> #include "qemu/osdep.h"
> #include "qemu/dbus.h"
> +#include "qemu/sockets.h"
> #include <gio/gio.h>
> #include <gio/gunixfdlist.h>
> #include "libqtest.h"
> @@ -36,7 +37,7 @@ test_setup(QTestState **qts, GDBusConnection **conn)
>
> *qts = qtest_init("-display dbus,p2p=yes -name dbus-test");
>
> - g_assert_cmpint(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
> + g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
>
> qtest_qmp_add_client(*qts, "@dbus-display", pair[1]);
>
> @@ -152,7 +153,7 @@ test_dbus_display_console(void)
>
> test_setup(&qts, &conn);
>
> - g_assert_cmpint(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
> + g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
> fd_list = g_unix_fd_list_new();
> idx = g_unix_fd_list_append(fd_list, pair[1], NULL);
>
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index dbde726adf..1dd32c9506 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -1661,7 +1661,7 @@ static void *test_migrate_fd_start_hook(QTestState *from,
> int pair[2];
>
> /* Create two connected sockets for migration */
> - ret = socketpair(PF_LOCAL, SOCK_STREAM, 0, pair);
> + ret = qemu_socketpair(PF_LOCAL, SOCK_STREAM, 0, pair);
> g_assert_cmpint(ret, ==, 0);
>
> /* Send the 1st socket to the target */
> diff --git a/tests/unit/test-crypto-tlssession.c
> b/tests/unit/test-crypto-tlssession.c
> index 615a1344b4..b12e7b6879 100644
> --- a/tests/unit/test-crypto-tlssession.c
> +++ b/tests/unit/test-crypto-tlssession.c
> @@ -82,7 +82,7 @@ static void test_crypto_tls_session_psk(void)
> int ret;
>
> /* We'll use this for our fake client-server connection */
> - ret = socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
> + ret = qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
> g_assert(ret == 0);
>
> /*
> @@ -236,7 +236,7 @@ static void test_crypto_tls_session_x509(const void
> *opaque)
> int ret;
>
> /* We'll use this for our fake client-server connection */
> - ret = socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
> + ret = qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
> g_assert(ret == 0);
>
> /*
> diff --git a/tests/unit/test-io-channel-tls.c
> b/tests/unit/test-io-channel-tls.c
> index cc39247556..e036ac5df4 100644
> --- a/tests/unit/test-io-channel-tls.c
> +++ b/tests/unit/test-io-channel-tls.c
> @@ -121,7 +121,7 @@ static void test_io_channel_tls(const void *opaque)
> GMainContext *mainloop;
>
> /* We'll use this for our fake client-server connection */
> - g_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
> + g_assert(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
>
> #define CLIENT_CERT_DIR "tests/test-io-channel-tls-client/"
> #define SERVER_CERT_DIR "tests/test-io-channel-tls-server/"
Acked-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Call qemu_socketpair() instead of socketpair() when possible
2023-01-16 4:56 Call qemu_socketpair() instead of socketpair() when possible Guoyi Tu
2023-01-16 7:33 ` Thomas Huth
@ 2023-01-16 8:31 ` Philippe Mathieu-Daudé
2023-01-16 16:43 ` Laurent Vivier
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-16 8:31 UTC (permalink / raw)
To: Guoyi Tu, Stefan Berger, Marc-André Lureau, Thomas Huth,
Laurent Vivier, Paolo Bonzini, Juan Quintela,
Dr. David Alan Gilbert, Daniel P. Berrangé, marcandre.lureau
Cc: qemu-devel
On 16/1/23 05:56, Guoyi Tu wrote:
> As qemu_socketpair() was introduced in commit 3c63b4e9
> ("oslib-posix: Introduce qemu_socketpair()"), it's time
> to replace the other existing socketpair() calls with
> qemu_socketpair() if possible
>
> Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
> ---
> backends/tpm/tpm_emulator.c | 2 +-
> tests/qtest/dbus-display-test.c | 5 +++--
> tests/qtest/migration-test.c | 2 +-
> tests/unit/test-crypto-tlssession.c | 4 ++--
> tests/unit/test-io-channel-tls.c | 2 +-
> 5 files changed, 8 insertions(+), 7 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Call qemu_socketpair() instead of socketpair() when possible
2023-01-16 4:56 Call qemu_socketpair() instead of socketpair() when possible Guoyi Tu
2023-01-16 7:33 ` Thomas Huth
2023-01-16 8:31 ` Philippe Mathieu-Daudé
@ 2023-01-16 16:43 ` Laurent Vivier
2 siblings, 0 replies; 4+ messages in thread
From: Laurent Vivier @ 2023-01-16 16:43 UTC (permalink / raw)
To: Guoyi Tu, Stefan Berger, Marc-André Lureau, Thomas Huth,
Laurent Vivier, Paolo Bonzini, Juan Quintela,
Dr. David Alan Gilbert, Daniel P. Berrangé, marcandre.lureau
Cc: qemu-devel, qemu-trivial@nongnu.org
Le 16/01/2023 à 05:56, Guoyi Tu a écrit :
> As qemu_socketpair() was introduced in commit 3c63b4e9
> ("oslib-posix: Introduce qemu_socketpair()"), it's time
> to replace the other existing socketpair() calls with
> qemu_socketpair() if possible
>
> Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
> ---
> backends/tpm/tpm_emulator.c | 2 +-
> tests/qtest/dbus-display-test.c | 5 +++--
> tests/qtest/migration-test.c | 2 +-
> tests/unit/test-crypto-tlssession.c | 4 ++--
> tests/unit/test-io-channel-tls.c | 2 +-
> 5 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
> index 49cc3d749d..67e7b212e3 100644
> --- a/backends/tpm/tpm_emulator.c
> +++ b/backends/tpm/tpm_emulator.c
> @@ -553,7 +553,7 @@ static int tpm_emulator_prepare_data_fd(TPMEmulator *tpm_emu)
> Error *err = NULL;
> int fds[2] = { -1, -1 };
>
> - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
> + if (qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
> error_report("tpm-emulator: Failed to create socketpair");
> return -1;
> }
> diff --git a/tests/qtest/dbus-display-test.c b/tests/qtest/dbus-display-test.c
> index cb1b62d1d1..fef025ac6f 100644
> --- a/tests/qtest/dbus-display-test.c
> +++ b/tests/qtest/dbus-display-test.c
> @@ -1,5 +1,6 @@
> #include "qemu/osdep.h"
> #include "qemu/dbus.h"
> +#include "qemu/sockets.h"
> #include <gio/gio.h>
> #include <gio/gunixfdlist.h>
> #include "libqtest.h"
> @@ -36,7 +37,7 @@ test_setup(QTestState **qts, GDBusConnection **conn)
>
> *qts = qtest_init("-display dbus,p2p=yes -name dbus-test");
>
> - g_assert_cmpint(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
> + g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
>
> qtest_qmp_add_client(*qts, "@dbus-display", pair[1]);
>
> @@ -152,7 +153,7 @@ test_dbus_display_console(void)
>
> test_setup(&qts, &conn);
>
> - g_assert_cmpint(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
> + g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
> fd_list = g_unix_fd_list_new();
> idx = g_unix_fd_list_append(fd_list, pair[1], NULL);
>
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index dbde726adf..1dd32c9506 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -1661,7 +1661,7 @@ static void *test_migrate_fd_start_hook(QTestState *from,
> int pair[2];
>
> /* Create two connected sockets for migration */
> - ret = socketpair(PF_LOCAL, SOCK_STREAM, 0, pair);
> + ret = qemu_socketpair(PF_LOCAL, SOCK_STREAM, 0, pair);
> g_assert_cmpint(ret, ==, 0);
>
> /* Send the 1st socket to the target */
> diff --git a/tests/unit/test-crypto-tlssession.c b/tests/unit/test-crypto-tlssession.c
> index 615a1344b4..b12e7b6879 100644
> --- a/tests/unit/test-crypto-tlssession.c
> +++ b/tests/unit/test-crypto-tlssession.c
> @@ -82,7 +82,7 @@ static void test_crypto_tls_session_psk(void)
> int ret;
>
> /* We'll use this for our fake client-server connection */
> - ret = socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
> + ret = qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
> g_assert(ret == 0);
>
> /*
> @@ -236,7 +236,7 @@ static void test_crypto_tls_session_x509(const void *opaque)
> int ret;
>
> /* We'll use this for our fake client-server connection */
> - ret = socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
> + ret = qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
> g_assert(ret == 0);
>
> /*
> diff --git a/tests/unit/test-io-channel-tls.c b/tests/unit/test-io-channel-tls.c
> index cc39247556..e036ac5df4 100644
> --- a/tests/unit/test-io-channel-tls.c
> +++ b/tests/unit/test-io-channel-tls.c
> @@ -121,7 +121,7 @@ static void test_io_channel_tls(const void *opaque)
> GMainContext *mainloop;
>
> /* We'll use this for our fake client-server connection */
> - g_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
> + g_assert(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
>
> #define CLIENT_CERT_DIR "tests/test-io-channel-tls-client/"
> #define SERVER_CERT_DIR "tests/test-io-channel-tls-server/"
Applied to my trivial-patches branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-16 16:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-16 4:56 Call qemu_socketpair() instead of socketpair() when possible Guoyi Tu
2023-01-16 7:33 ` Thomas Huth
2023-01-16 8:31 ` Philippe Mathieu-Daudé
2023-01-16 16:43 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).