From nobody Tue Feb 10 09:54:54 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651739460; cv=none; d=zohomail.com; s=zohoarc; b=D8FYdEmLKLonJYQVdgttgp9rAuZqXKYK0Uyftv8S8OAKI++A27NDRScQDGUFHAVHJRdaqOvZu9A6cRNDaT7gXvCtL/rRiay/zZ7zS9qPQ+eRBHV4y20wDqy57W9ovQEOL+Xd8qzry8wawfvlW8mjYJ2eaZOYEoG1ZnqoYeI4nS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651739460; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z8V4PowSbp6KiN32NnxVUfW1RJVoP7G0Taw4agHMlqM=; b=ke/OPE8dz7ZOW3FA96QJ5Nq4IkP5nHNqX79bT7WXeKuNoiDDegAMhOfblEWDbWKut6Q/E4h0uRCsiyI6vBa8iaBpgoBIDZBAoaLcpKfOlqpqTlKWYKMd6ehWM5V9MoOr9T73Sc8kNrQ+7dNkkMUCw2G/h2vMczx0DqSBEIf/D4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651739460278833.0990481161805; Thu, 5 May 2022 01:31:00 -0700 (PDT) Received: from localhost ([::1]:50576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWt1-0005tk-9I for importer@patchew.org; Thu, 05 May 2022 04:30:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWe6-0006dR-TN for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:35 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:28279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWe5-0007qM-AE for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-270-fck9EHBaOkGnpv9lOYGR-w-1; Thu, 05 May 2022 04:15:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C3F2299E745; Thu, 5 May 2022 08:15:29 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31749C27E90; Thu, 5 May 2022 08:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738532; 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=Z8V4PowSbp6KiN32NnxVUfW1RJVoP7G0Taw4agHMlqM=; b=GyL83e/Xaw2zYuqT39O4Chczo0Pg63eEnEPXpLUT+1/0Uj33uUCJKzjkJ0Hg3ImtlsX28j 7ZvgEDgbtyn7KyGd+ayQcbq9zLFw4UkSQZF5A60wUgtRcQjdCjUjbhYzbfsBG5ACT8CFQ2 NtUrSXUc0//nKyL/pWJqxF4XKAyT2n4= X-MC-Unique: fck9EHBaOkGnpv9lOYGR-w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 03/15] tests: make libqmp buildable for win32 Date: Thu, 5 May 2022 12:14:19 +0400 Message-Id: <20220505081431.934739-4-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651739462276100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth --- tests/qtest/libqmp.h | 2 ++ tests/qtest/libqmp.c | 35 +++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqmp.h b/tests/qtest/libqmp.h index 94aa97328a17..772f18b73ba3 100644 --- a/tests/qtest/libqmp.h +++ b/tests/qtest/libqmp.h @@ -20,8 +20,10 @@ #include "qapi/qmp/qdict.h" =20 QDict *qmp_fd_receive(int fd); +#ifndef G_OS_WIN32 void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, const char *fmt, va_list ap) G_GNUC_PRINTF(4, 0); +#endif void qmp_fd_vsend(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0); void qmp_fd_send(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3); void qmp_fd_send_raw(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3); diff --git a/tests/qtest/libqmp.c b/tests/qtest/libqmp.c index 0358b8313dc4..93c9b31cd4ca 100644 --- a/tests/qtest/libqmp.c +++ b/tests/qtest/libqmp.c @@ -15,9 +15,13 @@ */ =20 #include "qemu/osdep.h" - #include "libqmp.h" =20 +#ifndef G_OS_WIN32 +#include +#endif + +#include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/qjson.h" @@ -87,6 +91,7 @@ QDict *qmp_fd_receive(int fd) return qmp.response; } =20 +#ifndef G_OS_WIN32 /* Sends a message and file descriptors to the socket. * It's needed for qmp-commands like getfd/add-fd */ static void socket_send_fds(int socket_fd, int *fds, size_t fds_num, @@ -120,17 +125,23 @@ static void socket_send_fds(int socket_fd, int *fds, = size_t fds_num, } while (ret < 0 && errno =3D=3D EINTR); g_assert_cmpint(ret, >, 0); } +#endif =20 /** * Allow users to send a message without waiting for the reply, * in the case that they choose to discard all replies up until * a particular EVENT is received. */ -void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, - const char *fmt, va_list ap) +static void +_qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, + const char *fmt, va_list ap) { QObject *qobj; =20 +#ifdef G_OS_WIN32 + assert(fds_num =3D=3D 0); +#endif + /* Going through qobject ensures we escape strings properly */ qobj =3D qobject_from_vjsonf_nofail(fmt, ap); =20 @@ -148,10 +159,14 @@ void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_nu= m, if (log) { fprintf(stderr, "%s", str->str); } + +#ifndef G_OS_WIN32 /* Send QMP request */ if (fds && fds_num > 0) { socket_send_fds(fd, fds, fds_num, str->str, str->len); - } else { + } else +#endif + { socket_send(fd, str->str, str->len); } =20 @@ -160,15 +175,23 @@ void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_nu= m, } } =20 +#ifndef G_OS_WIN32 +void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, + const char *fmt, va_list ap) +{ + _qmp_fd_vsend_fds(fd, fds, fds_num, fmt, ap); +} +#endif + void qmp_fd_vsend(int fd, const char *fmt, va_list ap) { - qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); + _qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); } =20 =20 QDict *qmp_fdv(int fd, const char *fmt, va_list ap) { - qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); + _qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); =20 return qmp_fd_receive(fd); } --=20 2.36.0.44.g0f828332d5ac