From nobody Wed Feb 11 01:00:13 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=1675016740; cv=none; d=zohomail.com; s=zohoarc; b=E7spOVOVTVbN3JTrmKBbLcgSghYH+r1hxCDQW/7+gcI1S7uen7w9F7IOVuXDv0lvl9LP86rnIqukE+C92tG6sMQfmcXEzpmAOJevh1XH5edahn0H3kvEPCp6Gyn9MMPMDIZz0ThqdXK5vIznfFGPWfjoOJL24oNTeCgvX8FaJXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675016740; 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=NYYGbU4+VCQyccn3EjyMVYJtukXx7ENFQ5jJFpqb+ZY=; b=bHGcUH5AEL+piBm5mgrBK6xT91e8aSCo77Z9ATKtiJGr1zzQhdFV93rBS6xrbNg+SI7B1VckSYJ0HBIpdiK1e1h/MFbHsQQ73O541TwFdNvS17odG8emdLS3MCk1KfJ8/jd/TGk+hfyWhKYcFzr5Wunk3gxbY+I/n7LdwHdWaeU= 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 1675016740045507.8714467306469; Sun, 29 Jan 2023 10:25:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMCMo-0005AW-71; Sun, 29 Jan 2023 13:25:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMCMW-0004pR-5W for qemu-devel@nongnu.org; Sun, 29 Jan 2023 13:25:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMCMU-0006CZ-8u for qemu-devel@nongnu.org; Sun, 29 Jan 2023 13:25:07 -0500 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-584-Rn38cSv8ONmrvR2cDRuZ7A-1; Sun, 29 Jan 2023 13:25:01 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BF4D3C02B70; Sun, 29 Jan 2023 18:25:00 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B3C714171BB; Sun, 29 Jan 2023 18:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675016705; 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=NYYGbU4+VCQyccn3EjyMVYJtukXx7ENFQ5jJFpqb+ZY=; b=cYo2pjfFEULK23HZly3wYc5/d+pIOpxOsI16tJzr3J+GEhvwGfWVo6AqmhXOBJ9754EPks UlaI2c6ziJQ6dHXESYVhaiSPt3wMj8b3nG6BWhTty+RFKICndZ2PsHq9+MilcVpX5fW+on 2UvVzZXaIKFBAUIKbnms9XRAVnFk7ro= X-MC-Unique: Rn38cSv8ONmrvR2cDRuZ7A-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Stefan Weil , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eric Blake , Gerd Hoffmann , Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Beraldo Leal , Wainer dos Santos Moschetta , "Dr. David Alan Gilbert" , Michael Roth , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 8/9] libqtest: make qtest_qmp_add_client work on win32 Date: Sun, 29 Jan 2023 22:24:13 +0400 Message-Id: <20230129182414.583349-9-marcandre.lureau@redhat.com> In-Reply-To: <20230129182414.583349-1-marcandre.lureau@redhat.com> References: <20230129182414.583349-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 3.1 on 10.11.54.7 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675016741869100011 From: Marc-Andr=C3=A9 Lureau Duplicate a socket to QEMU, and add it via 'getfd' on win32. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Thomas Huth --- tests/qtest/libqtest.h | 2 -- tests/qtest/libqtest.c | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index fcf1c3c3b3..36186cd946 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -758,7 +758,6 @@ void qtest_qmp_device_add_qdict(QTestState *qts, const = char *drv, void qtest_qmp_device_add(QTestState *qts, const char *driver, const char = *id, const char *fmt, ...) G_GNUC_PRINTF(4, 5); =20 -#ifndef _WIN32 /** * qtest_qmp_add_client: * @qts: QTestState instance to operate on @@ -768,7 +767,6 @@ void qtest_qmp_device_add(QTestState *qts, const char *= driver, const char *id, * Call QMP ``getfd`` followed by ``add_client`` with the given @fd. */ void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd); -#endif /* _WIN32 */ =20 /** * qtest_qmp_device_del_send: diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 6b2216cb20..7542c169da 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1456,13 +1456,26 @@ void qtest_qmp_device_add(QTestState *qts, const ch= ar *driver, const char *id, qobject_unref(args); } =20 -#ifndef _WIN32 void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd) { QDict *resp; =20 +#ifdef WIN32 + WSAPROTOCOL_INFOW info; + g_autofree char *info64 =3D NULL; + + assert(fd_is_socket(fd)); + if (WSADuplicateSocketW(fd, GetProcessId((HANDLE)qts->qemu_pid), &info= ) =3D=3D SOCKET_ERROR) { + g_autofree char *emsg =3D g_win32_error_message(WSAGetLastError()); + g_error("WSADuplicateSocketW failed: %s", emsg); + } + info64 =3D g_base64_encode((guchar *)&info, sizeof(info)); + resp =3D qtest_qmp(qts, "{'execute': 'getfd'," + "'arguments': {'fdname': 'fdname', 'wsa-info': %s}}",= info64); +#else resp =3D qtest_qmp_fds(qts, &fd, 1, "{'execute': 'getfd'," "'arguments': {'fdname': 'fdname'}}"); +#endif g_assert(resp); g_assert(!qdict_haskey(resp, "event")); /* We don't expect any events = */ g_assert(!qdict_haskey(resp, "error")); @@ -1476,7 +1489,6 @@ void qtest_qmp_add_client(QTestState *qts, const char= *protocol, int fd) g_assert(!qdict_haskey(resp, "error")); qobject_unref(resp); } -#endif =20 /* * Generic hot-unplugging test via the device_del QMP command. --=20 2.39.1