From patchwork Tue Jan 18 16:09:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12716677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BC42C433EF for ; Tue, 18 Jan 2022 16:21:17 +0000 (UTC) Received: from localhost ([::1]:57106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9rER-00027L-S6 for qemu-devel@archiver.kernel.org; Tue, 18 Jan 2022 11:21:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9r37-0003WL-Dg for qemu-devel@nongnu.org; Tue, 18 Jan 2022 11:09:33 -0500 Received: from mail-db8eur05on2108.outbound.protection.outlook.com ([40.107.20.108]:18657 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9r34-0000PK-Fl for qemu-devel@nongnu.org; Tue, 18 Jan 2022 11:09:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AVIZ8gE/4+I9pfsHdVxvLIdoEnd32Fa8hFQPRftSzknx82BzECQyiNW39lqPcRK4LShiEQoTkK3BW/d1fMNkh9pbGXrsT8ml4Z3uFfkRm6H3Qt8nUVq92rKFSfB/V9LYF0sDVqNntbAkdIetK+UBZZBxYg/oOzCV1R5YfFyqkZWIc+KpehVF45TT8T1ivFmWAjAnV6sFixqmHTMGFbAYMvgPgua357v7LfZW0jaTHOe0tipBOYqbvVjop1X+A0jfwWUVyofT4TjJnSVvUDCqGF9Ctt34vP89SntjF2AyhOlOfgk3bVNMGhPbAarmAZil8FBQM12ASWsSuGAJ5p01ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7hh2PRLmUmjZ26xsg29vPn8mXmfObsC/LzeFTayHCok=; b=EM3cFcTPAsgyseGSZWCx9UH0F4gE5qlJC5yhUdDpUQA0xoquIUrOmzPA4tT6N49j8da6vLgQx1Jwnf5YAKte+6I0g4/uoF36IUi5t190xnc87r89Z6T59xY1Z5zt2pLSlhXo/Ha7Xc1qqA19/PUxQ7NEsi31wxZgmAIy+kKZ0IZ8AoFT2SfIRfNQhBC6yBL61waFc5Vzo6SWwExw8oax+Ik9mA1LsrSEqgk6KseRQQz5aIFbbvhvsK2hKoPAAwCzsuNSih1AUL6KaknBQcAC/2vJbLo167BwWjQBTpbgHtPy6IBOyNQaV7GRiyM0PRPamEIxXQwqfsAYoHpU6uQppw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7hh2PRLmUmjZ26xsg29vPn8mXmfObsC/LzeFTayHCok=; b=IqXeGe0+raILO8ORUhhnCxR9o2HNpjk5VqLm3kkUHahH7zO8YJ2ySaxH9x863pB9GgyPneefk1OFkZ+eEde+VfFuWRk7X6F7CtaLv1SkE9R0GC9Zv9EFktHSq6EPZ5umJXc1sN5tRe51IGX4lqhGjCb0rswOnRoRhn6ZqTgT86I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3953.eurprd08.prod.outlook.com (2603:10a6:208:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Tue, 18 Jan 2022 16:09:26 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b435:c0de:ef6b:5917]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b435:c0de:ef6b:5917%7]) with mapi id 15.20.4888.014; Tue, 18 Jan 2022 16:09:26 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: bleal@redhat.com, wainersm@redhat.com, f4bug@amsat.org, crosa@redhat.com, eblake@redhat.com, armbru@redhat.com, kraxel@redhat.com, berrange@redhat.com, vsementsov@virtuozzo.com, marcandre.lureau@redhat.com Subject: [PATCH v3 1/3] ui/vnc: refactor arrays of addresses to SocketAddressList Date: Tue, 18 Jan 2022 17:09:07 +0100 Message-Id: <20220118160909.2502374-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220118160909.2502374-1-vsementsov@virtuozzo.com> References: <20220118160909.2502374-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR03CA0006.eurprd03.prod.outlook.com (2603:10a6:20b:130::16) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fee97db-506e-43e7-c3f2-08d9da9ce612 X-MS-TrafficTypeDiagnostic: AM0PR08MB3953:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:454; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 72rzlETaF4shwVKCL+K5cO022b3WoMRcafWo8YQcxwawqoOuSlJptkR1XjtVTSAPYweIjbCiEd4wvhwDL8rptJjLMS6xRr/lZ+sUdh8WUzGPR2jqPnxkpI5eNPIcLE4dfmZg1mO1EVUA5DvTnndlTtLt+iQGTboeILDd0OJNpjfCfBYZcmP/S+0n+p7mp0t31946AwephnjhYb4ZICzUxRmUodYAYbUCGfaZhNG0CxHCcOuI7c1D2Pe16rP6jLhQoQwPjyYY1Dhd2xBNRVT+0qVJluqUM/5xJ5ndR3WtlM8CgHXDt/OYn65yqvyU7Z8H4tikZV/Y5L2uKTuBGlKsX4CMTCLt8Md9ZgqF87aIkeT9psTWAGieRYcLTVSXs5c7R6xps/a6WHk//nVc2JAldIwIjBY4aTS8rymQVffwQv78xTrrJiO37iuHGQUHrCgMCyYk9c8OSve8hITKwfgDxoKUfKhwyHNlCaFSS5jaeqrToyAB6nzCp5iYIDSrSODz+1Wcs/hN8ozzG+3B27EnlH4EhnNXgO9Z4QwOTqHzmFWkvk7ofLkhVCXNl8zVQOUP+cayKmwZbrnauKSvucWHksFkJG7yj0RojAoGpMFZDTtWiuYB9hsW+ST85Am1BT9sy/2F+oiEKPdBlZm9NGIHfUCFWyIme5bsgaZv2sbqsetWni66TqBPqm1cAyI7Pdn6UY5r6otuNYQ0SYIKZfRjKQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(52116002)(2616005)(1076003)(66946007)(8676002)(186003)(6506007)(5660300002)(66556008)(38350700002)(4326008)(66476007)(8936002)(26005)(6486002)(86362001)(316002)(6512007)(6666004)(83380400001)(2906002)(38100700002)(508600001)(6916009)(7416002)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?hFkx7H/m4Sgy4/DJh9lgDzPXTazT?= =?utf-8?q?PwWnwXSKcMlpDB+HTavIQeRLENCKG9sP84MDIrX83W1wUJxl5DMgv6fBldDN/6v6u?= =?utf-8?q?g1qHbALDYBgmDck3m69l90jhVQZQZuNmo/ZxGP87jzM3vKmQiHYQeZcRSThK4PWex?= =?utf-8?q?D2nI0cRq+XClaLJ61zm9MR5xhByUzC/dt7WC93zy7/Bhzp5GtT2dWIJi0WgkK8kkR?= =?utf-8?q?ZSfOaETxUxEm89EeWpSnMro+ZauE7b76oABqvhnXI/sXCaVhb4ftYG69b3Rf8n2jO?= =?utf-8?q?9LsaY7L9yrhdHm79ABS+FujOBZnpvpi+ioGFWmMDi2eDo3p5DS3ctLcE4oPtPi428?= =?utf-8?q?QOmhfdcsy6ouwv/Bhnn6ArhBfOIB8UwKxW/F5Cb+PYEmlG5qSlyF2WKVhPPMqL99P?= =?utf-8?q?qXhlBBlvJcOLDFNdECqAnaX40kmY0UW4LrowZBQnPRaRCZH9n0olp4x3aNhHLLGtq?= =?utf-8?q?BLT2yUdS1MQ2pjr66lZ2lhZPJYsSQ69SypNlGETkA2D5yggf6uccHFBAdYj7PbsHM?= =?utf-8?q?C6OXavaVoebnHmqw7jvfkfE88rnPpQXcj96v07j6ECN3ryhLirx5emelzDY/3P+LE?= =?utf-8?q?B42O1IEe3jz9BR5E94aSYucx/iHB+lzqTSg5oa28i/diAaXqFA/GI2BbEvFa93Dph?= =?utf-8?q?uKlJRM37WtHuuoUUIIZ04fhh+PcfuknQtblfXXtj17H4iGN+3mxy5O3+hj0IbszVe?= =?utf-8?q?h5T3UU0nNg0AXa8xDtSNLFlAKU8PgI3nm6Tr/mzMdlfzuaF11uLITHhZ+fx4dOy6Y?= =?utf-8?q?ZBVQU9MFT7tt5fBk8hDExh2InWTgXl5EnXgiLrGWYifalqXYHD+z9i4V0vgxuHKaQ?= =?utf-8?q?FnTVFHzAR3jLbHV7DFKJBKxkGF/nSILaGD9gbczlwKNVRtva1gSK+jSEQFWituXhO?= =?utf-8?q?XBiFzuNQc6DsyzwtIXk5CL38Yy8IEcdgdN776fR63IGZmmXGeCBWRf1IL0Hgyk/d6?= =?utf-8?q?UhW9NpGG8s7xcDurAzWUCkc7pKCi68O95uCsLFuN6nqXHL9D0Cm4rn3RQjFiw0Qew?= =?utf-8?q?l1sCE0t0O6fIV+FsKBx6ZCt46FGp5cSCfqwNjMmgoWygqoXmTT+z2+bRGhUNNJ645?= =?utf-8?q?fposWiIefN8wQtAWXfrE9eJ1rgNnC/TzVic9N0aRChifaFWqLH96T7P/98Uma67qL?= =?utf-8?q?V6mOY/csgGX5kb5vXG2Df/hg3w0256UoRlqnqeoGA9bwHRMkP+BT3APSvHvfEL5Lf?= =?utf-8?q?gIS3svz2Nty9w850Amdw2HhDEHYm1179Yd4qACibA0Hf8penChojGN29sUeoXhCkP?= =?utf-8?q?PEKjyo7NT9f595vS3EjEoVfNJCHj473lGlagWYI1w5I5Ju+zc+bFCA77heaXjWkPc?= =?utf-8?q?aa/jgFcikeUE6xXkvYQ6XeQPBy6N1zPTpBht/nuAZKX//cFH8TACPUHlDykc0OIOC?= =?utf-8?q?tC7OtBpAxNg4n4FvWMk+5k7iIh557lb7Y+iKHLM31nMfHorzee+i0EETeqNqSpn3W?= =?utf-8?q?zuAb9E5Z0ZrBcwZRPvzmzaa+TtL+dvewJY49fesPhNhOAUjoAGz8YDPtOiHt+Q+dt?= =?utf-8?q?+kSPojgKWsMKrLYm/H5iEI5C/vG5IwPlOMOWXsjvRHJKRYAZJOgrWPlLf+CxqqwQx?= =?utf-8?q?0QQnHFGxgJ6lj33Fy4nYrb8ecNH7II85kr83sHFot7bkBpxOyljRO4=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fee97db-506e-43e7-c3f2-08d9da9ce612 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 16:09:26.4065 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7N8HhptquOFf8AadINjjIAB1V02E3Ro9i59bm20oMTsfff2D1F5XeNa6ZwRMxwcTmwBH6PY3lZIoZdRW8LJq3ZuHksXyJS4wvjzAyx+2DN0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3953 Received-SPF: pass client-ip=40.107.20.108; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.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, 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_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let's use SocketAddressList instead of dynamic arrays. Benefits: - Automatic cleanup: don't need specific freeing function and drop some gotos. - Less indirection: no triple asterix anymore! - Prepare for the following commit, which will reuse new interface of vnc_display_listen(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé --- ui/vnc.c | 129 ++++++++++++++++++++++--------------------------------- 1 file changed, 51 insertions(+), 78 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 3ccd33dedc..fa0fb736d3 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3812,30 +3812,19 @@ static int vnc_display_get_address(const char *addrstr, return ret; } -static void vnc_free_addresses(SocketAddress ***retsaddr, - size_t *retnsaddr) -{ - size_t i; - - for (i = 0; i < *retnsaddr; i++) { - qapi_free_SocketAddress((*retsaddr)[i]); - } - g_free(*retsaddr); - - *retsaddr = NULL; - *retnsaddr = 0; -} - static int vnc_display_get_addresses(QemuOpts *opts, bool reverse, - SocketAddress ***retsaddr, - size_t *retnsaddr, - SocketAddress ***retwsaddr, - size_t *retnwsaddr, + SocketAddressList **saddr_list_ret, + SocketAddressList **wsaddr_list_ret, Error **errp) { SocketAddress *saddr = NULL; SocketAddress *wsaddr = NULL; + g_autoptr(SocketAddressList) saddr_list = NULL; + SocketAddressList **saddr_tail = &saddr_list; + SocketAddress *single_saddr = NULL; + g_autoptr(SocketAddressList) wsaddr_list = NULL; + SocketAddressList **wsaddr_tail = &wsaddr_list; QemuOptsIter addriter; const char *addr; int to = qemu_opt_get_number(opts, "to", 0); @@ -3844,23 +3833,16 @@ static int vnc_display_get_addresses(QemuOpts *opts, bool ipv4 = qemu_opt_get_bool(opts, "ipv4", false); bool ipv6 = qemu_opt_get_bool(opts, "ipv6", false); int displaynum = -1; - int ret = -1; - - *retsaddr = NULL; - *retnsaddr = 0; - *retwsaddr = NULL; - *retnwsaddr = 0; addr = qemu_opt_get(opts, "vnc"); if (addr == NULL || g_str_equal(addr, "none")) { - ret = 0; - goto cleanup; + return 0; } if (qemu_opt_get(opts, "websocket") && !qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA1)) { error_setg(errp, "SHA1 hash support is required for websockets"); - goto cleanup; + return -1; } qemu_opt_iter_init(&addriter, opts, "vnc"); @@ -3871,7 +3853,7 @@ static int vnc_display_get_addresses(QemuOpts *opts, ipv4, ipv6, &saddr, errp); if (rv < 0) { - goto cleanup; + return -1; } /* Historical compat - first listen address can be used * to set the default websocket port @@ -3879,13 +3861,16 @@ static int vnc_display_get_addresses(QemuOpts *opts, if (displaynum == -1) { displaynum = rv; } - *retsaddr = g_renew(SocketAddress *, *retsaddr, *retnsaddr + 1); - (*retsaddr)[(*retnsaddr)++] = saddr; + QAPI_LIST_APPEND(saddr_tail, saddr); } - /* If we had multiple primary displays, we don't do defaults - * for websocket, and require explicit config instead. */ - if (*retnsaddr > 1) { + if (saddr_list && !saddr_list->next) { + single_saddr = saddr_list->value; + } else { + /* + * If we had multiple primary displays, we don't do defaults + * for websocket, and require explicit config instead. + */ displaynum = -1; } @@ -3895,57 +3880,50 @@ static int vnc_display_get_addresses(QemuOpts *opts, has_ipv4, has_ipv6, ipv4, ipv6, &wsaddr, errp) < 0) { - goto cleanup; + return -1; } /* Historical compat - if only a single listen address was * provided, then this is used to set the default listen * address for websocket too */ - if (*retnsaddr == 1 && - (*retsaddr)[0]->type == SOCKET_ADDRESS_TYPE_INET && + if (single_saddr && + single_saddr->type == SOCKET_ADDRESS_TYPE_INET && wsaddr->type == SOCKET_ADDRESS_TYPE_INET && g_str_equal(wsaddr->u.inet.host, "") && - !g_str_equal((*retsaddr)[0]->u.inet.host, "")) { + !g_str_equal(single_saddr->u.inet.host, "")) { g_free(wsaddr->u.inet.host); - wsaddr->u.inet.host = g_strdup((*retsaddr)[0]->u.inet.host); + wsaddr->u.inet.host = g_strdup(single_saddr->u.inet.host); } - *retwsaddr = g_renew(SocketAddress *, *retwsaddr, *retnwsaddr + 1); - (*retwsaddr)[(*retnwsaddr)++] = wsaddr; + QAPI_LIST_APPEND(wsaddr_tail, wsaddr); } - ret = 0; - cleanup: - if (ret < 0) { - vnc_free_addresses(retsaddr, retnsaddr); - vnc_free_addresses(retwsaddr, retnwsaddr); - } - return ret; + *saddr_list_ret = g_steal_pointer(&saddr_list); + *wsaddr_list_ret = g_steal_pointer(&wsaddr_list); + return 0; } static int vnc_display_connect(VncDisplay *vd, - SocketAddress **saddr, - size_t nsaddr, - SocketAddress **wsaddr, - size_t nwsaddr, + SocketAddressList *saddr_list, + SocketAddressList *wsaddr_list, Error **errp) { /* connect to viewer */ QIOChannelSocket *sioc = NULL; - if (nwsaddr != 0) { + if (wsaddr_list) { error_setg(errp, "Cannot use websockets in reverse mode"); return -1; } - if (nsaddr != 1) { + if (!saddr_list || saddr_list->next) { error_setg(errp, "Expected a single address in reverse mode"); return -1; } /* TODO SOCKET_ADDRESS_TYPE_FD when fd has AF_UNIX */ - vd->is_unix = saddr[0]->type == SOCKET_ADDRESS_TYPE_UNIX; + vd->is_unix = saddr_list->value->type == SOCKET_ADDRESS_TYPE_UNIX; sioc = qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse"); - if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) { + if (qio_channel_socket_connect_sync(sioc, saddr_list->value, errp) < 0) { object_unref(OBJECT(sioc)); return -1; } @@ -3956,20 +3934,18 @@ static int vnc_display_connect(VncDisplay *vd, static int vnc_display_listen(VncDisplay *vd, - SocketAddress **saddr, - size_t nsaddr, - SocketAddress **wsaddr, - size_t nwsaddr, + SocketAddressList *saddr_list, + SocketAddressList *wsaddr_list, Error **errp) { - size_t i; + SocketAddressList *el; - if (nsaddr) { + if (saddr_list) { vd->listener = qio_net_listener_new(); qio_net_listener_set_name(vd->listener, "vnc-listen"); - for (i = 0; i < nsaddr; i++) { + for (el = saddr_list; el; el = el->next) { if (qio_net_listener_open_sync(vd->listener, - saddr[i], 1, + el->value, 1, errp) < 0) { return -1; } @@ -3979,12 +3955,12 @@ static int vnc_display_listen(VncDisplay *vd, vnc_listen_io, vd, NULL); } - if (nwsaddr) { + if (wsaddr_list) { vd->wslistener = qio_net_listener_new(); qio_net_listener_set_name(vd->wslistener, "vnc-ws-listen"); - for (i = 0; i < nwsaddr; i++) { + for (el = wsaddr_list; el; el = el->next) { if (qio_net_listener_open_sync(vd->wslistener, - wsaddr[i], 1, + el->value, 1, errp) < 0) { return -1; } @@ -4002,8 +3978,8 @@ void vnc_display_open(const char *id, Error **errp) { VncDisplay *vd = vnc_display_find(id); QemuOpts *opts = qemu_opts_find(&qemu_vnc_opts, id); - SocketAddress **saddr = NULL, **wsaddr = NULL; - size_t nsaddr, nwsaddr; + g_autoptr(SocketAddressList) saddr_list = NULL; + g_autoptr(SocketAddressList) wsaddr_list = NULL; const char *share, *device_id; QemuConsole *con; bool password = false; @@ -4028,8 +4004,8 @@ void vnc_display_open(const char *id, Error **errp) } reverse = qemu_opt_get_bool(opts, "reverse", false); - if (vnc_display_get_addresses(opts, reverse, &saddr, &nsaddr, - &wsaddr, &nwsaddr, errp) < 0) { + if (vnc_display_get_addresses(opts, reverse, &saddr_list, &wsaddr_list, + errp) < 0) { goto fail; } @@ -4211,16 +4187,16 @@ void vnc_display_open(const char *id, Error **errp) } qkbd_state_set_delay(vd->kbd, key_delay_ms); - if (saddr == NULL) { - goto cleanup; + if (saddr_list == NULL) { + return; } if (reverse) { - if (vnc_display_connect(vd, saddr, nsaddr, wsaddr, nwsaddr, errp) < 0) { + if (vnc_display_connect(vd, saddr_list, wsaddr_list, errp) < 0) { goto fail; } } else { - if (vnc_display_listen(vd, saddr, nsaddr, wsaddr, nwsaddr, errp) < 0) { + if (vnc_display_listen(vd, saddr_list, wsaddr_list, errp) < 0) { goto fail; } } @@ -4229,14 +4205,11 @@ void vnc_display_open(const char *id, Error **errp) vnc_display_print_local_addr(vd); } - cleanup: - vnc_free_addresses(&saddr, &nsaddr); - vnc_free_addresses(&wsaddr, &nwsaddr); + /* Success */ return; fail: vnc_display_close(vd); - goto cleanup; } void vnc_display_add_client(const char *id, int csock, bool skipauth) From patchwork Tue Jan 18 16:09:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12716680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64372C433EF for ; Tue, 18 Jan 2022 16:26:27 +0000 (UTC) Received: from localhost ([::1]:37690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9rJS-0008Sl-Iq for qemu-devel@archiver.kernel.org; Tue, 18 Jan 2022 11:26:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9r39-0003aC-EO for qemu-devel@nongnu.org; Tue, 18 Jan 2022 11:09:35 -0500 Received: from mail-db8eur05on2108.outbound.protection.outlook.com ([40.107.20.108]:18657 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9r37-0000PK-C5 for qemu-devel@nongnu.org; Tue, 18 Jan 2022 11:09:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l2A/4iQOA4kSczG1P9KeY5/PCqVFLKlKqa/cTMBzTxRN/whHu3aX029YbQkkY/Ec70BqHqzWisWy7W91gy5mwFzSFl+v3QWoVLul1ZjK2R5xkDOGE3AOBXvh1AvLqu0v8YeudaCA0XG194/w0izu64eVCfD3UM43hQMt3R+SY8m/Fa54grY7FqEa02QXyDSZY08/4HMngFn2qAGa0OMpZ62he1LsXnBOHd1qgUqeSpHROZ2lV3DnmZMUlpzE8biFV5nOSfAnt3vzqFYfsGdPi/wqdeVj0Pt23NcbvAWFY2HBSVqrLelyFKs5ikc8c2RfNaeASFQqCIYtmkezWX0d/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dwmd9IUTp6EA5vP92DJkcOcyWHbwtF5Z9EDZevcIXyw=; b=iYZcH4JQnUFCUroLhQaUrfkN1tKNQ2YSGUi363OY6U+Q0wybu4uRsp9K0+TCj525usEubHXxxj7lXkCDYe7G87U9uJtySVlfrCFycSRknrM4qdAHdczsPAPBa1ymCrzWNpFt2ORErvVc6QZxrdJRE7WMnwiUALT4rxK7iV/7kgo6jRc4XM6rnUWLJajGLEJT5rsB3ngR4rE6nOa0pjjN54Z1aE9LAF7S8kUtHdPPD7/rhf6Qv4TrYdsxMS3L/y+cvcuE/bLamRjHiLzn5jqmTCllYmUbG4qIXpTEkJpOg7x26gwMJXlu60DzE1O4WLm6jg79Jn/Ico4Y3zKXy+UkSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dwmd9IUTp6EA5vP92DJkcOcyWHbwtF5Z9EDZevcIXyw=; b=PA6kLiPOksqbmX3upa1jdld196LeJfGsIZsx++j6UccPiAeYLL2+8P4UErYNzG7//fbhdTUbLp3DrEfXA05LkcizEu/qFfHx3tf5XmsOFzL1/xAyemaGznCEGlkoZkng/PNICwOdOXLUWPUTbNZGr/opb5WzHij86Sh3VthBYuY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3953.eurprd08.prod.outlook.com (2603:10a6:208:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Tue, 18 Jan 2022 16:09:28 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b435:c0de:ef6b:5917]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b435:c0de:ef6b:5917%7]) with mapi id 15.20.4888.014; Tue, 18 Jan 2022 16:09:28 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: bleal@redhat.com, wainersm@redhat.com, f4bug@amsat.org, crosa@redhat.com, eblake@redhat.com, armbru@redhat.com, kraxel@redhat.com, berrange@redhat.com, vsementsov@virtuozzo.com, marcandre.lureau@redhat.com Subject: [PATCH v3 2/3] qapi/ui: display-reload: add possibility to change listen address Date: Tue, 18 Jan 2022 17:09:08 +0100 Message-Id: <20220118160909.2502374-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220118160909.2502374-1-vsementsov@virtuozzo.com> References: <20220118160909.2502374-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR03CA0006.eurprd03.prod.outlook.com (2603:10a6:20b:130::16) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bccd94be-fc56-4386-1106-08d9da9ce696 X-MS-TrafficTypeDiagnostic: AM0PR08MB3953:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O8OLr/mS43AU5+h7Ub2rDx1TsjYSKrCdQ943XpaZ4OfuRtuRtIlbCLv8lMxqC3uYvABD+HoV/Fbr9/qxH+CPqWEgI0ULAFU4Webz7+3c6oxRi1NQHntZdRQ7zla6wjWA9BOlNWnzYCC3l1S0nJV5u7CFVU5Iycu4L179I//9bn3Im4phBraJw3gaOzZRlDb/6uf/wIUEvXESKC51OF/XyV4EoBqfqjDEfjXsP73PK2UsE9kWBIYtpuTe/4CIwzF+2hkdtPgOsf2Gykr8evKALcxu8iJq/Au3/Dk48wuXGGQwEzM8CPz4XiNbGo4IQ35gwzHSioV2sEEvQNJWXZHync6Q5Y8WsLRLUeR+g+bno1u+PDUiJQPh8WPZHCw6vd1UEanU4z3hKIwiGyii+Nl0UgMTk8ls9aASyqhNyfID3HXO0RWC4qO4DZMVQUyk0/a6zYIIxgUiIvsIMMI1vAIuweEn/ZCEAfzIJZ7At2Juy+8ngDTX2tHvARTk7aBx8QZEon1ylkucYKhFv/FabyRBHu/BeYkvEQuON5ZykBKIRPcl+zWFzLXlSb5sc9PiyAY9LPm+cftFN/QtwUAmJko2ii3Z+lL9n64iHRC7gWv60oQD6os79qyep8l3fwJ6oJNLGNe1+Q2YVR4faOR+bDv1XLQA4stf1Px8UwjWtJmX2aYASvVTT4ZUVY9Qo/XiVh6Z5ELZIJD3KRNj8sMENPvtyQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(52116002)(2616005)(1076003)(66946007)(8676002)(186003)(6506007)(5660300002)(66556008)(38350700002)(4326008)(66476007)(8936002)(26005)(6486002)(86362001)(316002)(6512007)(6666004)(83380400001)(2906002)(38100700002)(508600001)(6916009)(7416002)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9maeDuUXddfpFaSfg3HRddaf5meVyBMQtQQA9T1Cy+SOFi4v1y7WpyYGXqPv+8R42AX9JOcFqnUBLy1rK6w1J4RKsQpdfE/fJODKH6lkDx2H6siYAt5Ff6mjuqtcderq4mVbdShJdQMT+oi4kKtALP1xtebyoKfvtjNfOIglWbV91/r9gtFGKiycC2/av/kWLSP+y0oEzfY9FqeSdxrRF9fTngel68OvIyaauN6fjJfqrZGy/ESsNjrblbPeE4Q5aYA8gdCU9AaeiiYijp9zpo5U7JsI9DVUKbbGVt5K2SNZJVlVfWC7crIf+kVyKnxc2UL59D2dqrPKDc6TO7dXnIzfpMCPDlJqX5NgXGdMCXEyxnU169UqG/yRTiAyEGKln98LRjtqXxZhH7n35DEZcZHQt5kzUZdyNmoKxVtSZ3vXJf8sw7qMeifiBsHod63IigqMcxKEi8JXYgeDhPYseqyyFWQosVe1fs05WGVwp/IlM+vgX8BztdWFpkLKv+OW2t4t9wr+oCZHHdVqIkYcrCv15+YVJGG7iYx0N2MwvEFqApRkF2KK8H2Psip/+4qLR532KUN0aVlWB1Gz1icfOHINBatlGBOMrKwF0zHs/M52QvTW4Ic4UCK7ipvjwvC+mJyjUEJfyzC9BU23w+3+pH/pLcH0Fl6b4zK+VkBr8K9RGhm/wlp4ucccoLfrqgdIJQYArxIPNoKZt+BvRUf4chNINBO5VXVadxDKPljzoJDSsahIcDgeksMdUhB0YtJ91nd4M0/Yebp4LrD/9hxlIqVGSi4u1cNRWP1AJ3NQs/UJMBicgM52zCmwOiAjCItncfuI7BI6R/cAPVyf8D2PuG1qCgL7+UemNjV4i/p46GAjNyT8Fw0kTN+MeCKb3n8mBrOql6duwgpOJ6krawjAbc6G9IzROO+DQ9zhoSkJ7TyvMRxz/epBXbwcaTDq4ka5aW97Q0rQdGpGtbhh9dtLw5FEL7Imb372NJYtlnanFN9qc8TFm3Jmm/iEmqISs6SBsX6w5N4Dz1sekXiLUTZqo70XcoWomHEH1qXGkPOZW/oZXlmEYgGtO+mQ5tGnYEj9U8+aNUzeAPgnqWwGaLDQPJAF8F9YRetXQ95ecGGTXuK3y1C5kRG+1ny7snrVxdkFW+8qqFWwKlFs2qMIzKYBDpmV9XEsemhJ5no43Y7WPp7ZK5uN2yvtrGBv9cwXd9NZ1cbG1U/vzUlo23xcKWOQLZGpXHaKM0nr3jLUvzmNJc2zJGi3q6Ab7nayPGI1/OBflADQEFLLqujFbgNYhwCtaohnyQ8xBG0hDJF7t66PIL6Z0UiDywSgL4jchxWHjnamrW/RWNAYimhBwmKgDXbWRvrF4WrUeRX+1rh1OZE2K2QU1EVHz9w/YbImEzkks18/8PsV+nOabHaqI44uvJZtyrqszDKe7UEpClIkuAZHpunBYvkG7N7wTToTawGZDvhqd/nEBTqBgeDaFjDzcB035oedCHjjqhNGCMStSG2kT9wjgTjaBYdzzBHRFfuCJSiq9XoS+bodH1qr7lt2JRe8gj4R88AkLPaywrLOINe2NFZyFSGvMWtFqT55AOpLBYAvHVGCXP5Zk1fyHRLHcfz4ax1dLICtD/OdI4n4q5cLvMQTdclaZHi1PZmYmcLoX5xv+Zu/tQPdKGmfktwr1OdoC4zZz0PwJxZI8Pvqcp4FhBo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bccd94be-fc56-4386-1106-08d9da9ce696 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 16:09:26.9858 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +9uTj2QC60+ti7TIfpvcunYQunrDlbatGLUI7M5SFinX/kaG5t82YzziEqACTsOc5jXY5Po15SyyBt081ZH48a+E51hTFpqyUaesbXlc+kU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3953 Received-SPF: pass client-ip=40.107.20.108; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.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, 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_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add possibility to change addresses where VNC server listens for new connections. Prior to 6.0 this functionality was available through 'change' qmp command which was deleted. Signed-off-by: Vladimir Sementsov-Ogievskiy --- docs/about/removed-features.rst | 3 ++- qapi/ui.json | 6 +++++- include/ui/console.h | 2 +- monitor/qmp-cmds.c | 4 +--- ui/vnc.c | 37 ++++++++++++++++++++++++++------- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst index 4c4da20d0f..b92626a74e 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -355,7 +355,8 @@ documentation of ``query-hotpluggable-cpus`` for additional details. ``change`` (removed in 6.0) ''''''''''''''''''''''''''' -Use ``blockdev-change-medium`` or ``change-vnc-password`` instead. +Use ``blockdev-change-medium`` or ``change-vnc-password`` or +``display-reload`` instead. ``query-events`` (removed in 6.0) ''''''''''''''''''''''''''''''''' diff --git a/qapi/ui.json b/qapi/ui.json index 9354f4c467..4c4448f378 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1293,12 +1293,16 @@ # Specify the VNC reload options. # # @tls-certs: reload tls certs or not. +# @addresses: If specified, change set of addresses +# to listen for connections. Addresses configured +# for websockets are not touched. (since 7.0) # # Since: 6.0 # ## { 'struct': 'DisplayReloadOptionsVNC', - 'data': { '*tls-certs': 'bool' } } + 'data': { '*tls-certs': 'bool', + '*addresses': ['SocketAddress'] } } ## # @DisplayReloadOptions: diff --git a/include/ui/console.h b/include/ui/console.h index f590819880..b052027915 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -512,7 +512,7 @@ int vnc_display_password(const char *id, const char *password); int vnc_display_pw_expire(const char *id, time_t expires); void vnc_parse(const char *str); int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp); -bool vnc_display_reload_certs(const char *id, Error **errp); +bool vnc_display_reload(DisplayReloadOptionsVNC *arg, Error **errp); /* input.c */ int index_from_key(const char *key, size_t key_length); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 14e3beeaaf..ad45baa12b 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -356,9 +356,7 @@ void qmp_display_reload(DisplayReloadOptions *arg, Error **errp) switch (arg->type) { case DISPLAY_RELOAD_TYPE_VNC: #ifdef CONFIG_VNC - if (arg->u.vnc.has_tls_certs && arg->u.vnc.tls_certs) { - vnc_display_reload_certs(NULL, errp); - } + vnc_display_reload(&arg->u.vnc, errp); #else error_setg(errp, "vnc is invalid, missing 'CONFIG_VNC'"); #endif diff --git a/ui/vnc.c b/ui/vnc.c index fa0fb736d3..a86bd6335e 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -587,16 +587,10 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp) return prev; } -bool vnc_display_reload_certs(const char *id, Error **errp) +static bool vnc_display_reload_certs(VncDisplay *vd, Error **errp) { - VncDisplay *vd = vnc_display_find(id); QCryptoTLSCredsClass *creds = NULL; - if (!vd) { - error_setg(errp, "Can not find vnc display"); - return false; - } - if (!vd->tlscreds) { error_setg(errp, "vnc tls is not enabled"); return false; @@ -3973,6 +3967,35 @@ static int vnc_display_listen(VncDisplay *vd, return 0; } +bool vnc_display_reload(DisplayReloadOptionsVNC *arg, Error **errp) +{ + VncDisplay *vd = vnc_display_find(NULL); + + if (!vd) { + error_setg(errp, "Can not find vnc display"); + return false; + } + + if (arg->has_tls_certs && arg->tls_certs) { + if (!vnc_display_reload_certs(vd, errp)) { + return false; + } + } + + if (arg->has_addresses) { + if (vd->listener) { + qio_net_listener_disconnect(vd->listener); + object_unref(OBJECT(vd->listener)); + vd->listener = NULL; + } + + if (vnc_display_listen(vd, arg->addresses, NULL, errp) < 0) { + return false; + } + } + + return true; +} void vnc_display_open(const char *id, Error **errp) { From patchwork Tue Jan 18 16:09:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12716681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E72E9C433F5 for ; Tue, 18 Jan 2022 16:33:04 +0000 (UTC) Received: from localhost ([::1]:48134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9rPr-0007CH-Jq for qemu-devel@archiver.kernel.org; Tue, 18 Jan 2022 11:33:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9r39-0003a4-Da for qemu-devel@nongnu.org; Tue, 18 Jan 2022 11:09:35 -0500 Received: from mail-vi1eur05on2134.outbound.protection.outlook.com ([40.107.21.134]:20257 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9r36-0000R9-QL for qemu-devel@nongnu.org; Tue, 18 Jan 2022 11:09:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c9vxuDS5x1xsqCZivqNzvjdRWNOzfNishKhteipOVOFzbFOm+UvLvrKg3SWuSaLtkLcXaOp4xeZo4rBI0aWre1KP1A64IVxdkybRR2lEeyeJR+yTiCy2tKScjf792LVSjfCw/nmV1MF/x+ePpGF4hIKjsCxRIVfmKVp/jmhkecOdtTwpbMTZc4Fg6ORxE2gKMWPbb1HGd6fOylZns32jRt6IjPjkyQJDJmzgqmtE4WbGy0dundcUBDgE5467Rgri9yJXodkLb7AHH+RR+BBm6gvCnCkIlIlmyOCoVXNXu0ghrEb2sohiCfb9heRR/v1lOGHpzj+yYo5MHJzwHJ3a8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o73IuOANFqReNKaxuOQ+RIejmRgosbACCyK8Qf2V4sE=; b=io9H0Bcl+vGPHMkEg4Irm44506c7jUbRKcZKNoM21YXACZMloclx7fQK2gO0r6Hc7V9JCkMCYn8hrSgH8SpkIXVyYwmHjkZbFXAqAZFAX5eng4ESRsNbXSERS3fpSv+dN1K+gTcCBaFgqSF5R7NPqnfSj5A96LyNj5lFanomdiqWYhx/0aLYN8U/cYnNhfUOH9pRxsDDXXYrBGXxlEImY5XztanhsUWYHUVO0M0Z0u/+OmMuGq9Og4v3CPl1/NcS+nS57Up5WfhfoimseZbvpm3J+6VFCSZVx1GE4z25hZ1soinQ1fLbRGmXWEyVdwBe22op/op+KJb6mOdoPhpVsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o73IuOANFqReNKaxuOQ+RIejmRgosbACCyK8Qf2V4sE=; b=oVMHNkbl227mWRd74VRlXKmXFsJ7hzAh/m4R6PpRuk88TJHHAE9w3XdhyAwq+idGB3n7WTMaRLed+BM4QfG9TcS4TvwyVROpJYfnKPkMk9IzgBn0KBJ7/bhF/tedoXXCoggYpyWQfQfhK2Rzw6INLkwAZA3/h1IK32t621l9jak= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB4964.eurprd08.prod.outlook.com (2603:10a6:208:157::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Tue, 18 Jan 2022 16:09:30 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b435:c0de:ef6b:5917]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b435:c0de:ef6b:5917%7]) with mapi id 15.20.4888.014; Tue, 18 Jan 2022 16:09:30 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: bleal@redhat.com, wainersm@redhat.com, f4bug@amsat.org, crosa@redhat.com, eblake@redhat.com, armbru@redhat.com, kraxel@redhat.com, berrange@redhat.com, vsementsov@virtuozzo.com, marcandre.lureau@redhat.com Subject: [PATCH v3 3/3] avocado/vnc: add test_change_listen Date: Tue, 18 Jan 2022 17:09:09 +0100 Message-Id: <20220118160909.2502374-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220118160909.2502374-1-vsementsov@virtuozzo.com> References: <20220118160909.2502374-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR03CA0006.eurprd03.prod.outlook.com (2603:10a6:20b:130::16) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a023954c-19da-441e-43ec-08d9da9ce6ee X-MS-TrafficTypeDiagnostic: AM0PR08MB4964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AfizWjWQuJJdfeWcCVTUp32un8zd5fGG1hXb3VeuQzgoCSR5UFGP1wqprZstQR1pMh2Rsutc7tSBqUXutm5C/+fLw91jv81GjPizcBOLTvS3KzyyQoXPuoIkWQ+q7+mkD5Hy2U6p3gCt4n8VLsV7U89n6IqR3cSyqo5B50FVrtqX8WK1edPWd2FyT4Gvib8CPp7wxDS0/S2pB8FQzpqC5/qqYh5KDVodJ0NHN4ZtZVehyd8QRJuwRA7FMRKfvEgGxMdjaMWwsVMq6llSJX6E+4e9bb61hYa2F6DXtha0UMr+MBT6aUqh0st1Yim04GV3hLrDdBFpcxy3q9iONzV6XAW0kRa2lossNocwrB3zYOLTvpDllYRwsCvLfIbGl/bPifK9D6CdNrh6WAs/6Y8tFMDxM7GSu4rlQJRO+mYRAaQxsQ1VG/S/eitzRUttU4xf8YeBVAeq8w/fn+rckpGZs2DlqfHIi4W5Rcj2aGbGVgX9LesBQw6wDOQ0tUB0UtNIIO3EYmGkUw2Dq4TkSN12qBJF/yRf/5k94lZaLIQTbZDNJFm72SQJHazkj3G2AB+tlMU7M3QRUAc20WQcBpgNJi/5YAWOrr0SGnK1Mt6UIJbJlHtKd9La5lywtlY91INtaFh3/A3CImhGQHX60pzjx7pRquQI1dCpc8DDYKRAmBBxL3+c7cfcAtCgxmwq3XjUtX2aDLO7hk66oFt0Wy5Z/w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6916009)(6506007)(4744005)(52116002)(38350700002)(5660300002)(86362001)(36756003)(508600001)(316002)(38100700002)(2906002)(26005)(1076003)(6512007)(83380400001)(2616005)(8936002)(186003)(66946007)(66476007)(6486002)(66556008)(4326008)(7416002)(6666004)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P9sfLxefeTJ3b2v3ABblibma++JKiEn9UG29sSk2Npuj9r5EJHvkqzPpuhkEOwpjBwsmpluv5R3O0I/MVjQacp1sUZU1l1XQkBKfXn7n2x7yNPf4a+ICHeDJxIahrL7ulPvxikFH0HwfQ/xZu6UyoT4Kl6TdVM+/r9On6zbsp9EtQphM4PlAFJDrp2/SIcNlEVmc4mQ2WUk+q0VRvmffNfGM3ZhwKYKeSlgW0CGwrdDV8G1lovevAyqJj+XC7zbdVZiG612a7ZrX/KNH0OTfEv24kUgKDAcDHKRNsnEUuZcfuxnG1NFBOG2rGbZWQ1Cdta3hiwJlRuFga8Ukvgmowc5rjHHezmj1R1dPURAhIAthuY9b7VjNwfgyoouv011YmRAb4rFk4x+HdeKQfPMq+hQnYvz2OgS85M82W0bvK1ZglqbmHNulMjQKHZsYBTEROiquh8P665hsbrul5S4uD/pcD6h8xf5oKfR8JHlA/RQuY1k8CqTUC8GnLwfVyUxs4uTydxBhEaRHqpUC/CGHMc/6HtQHeYCwugGdieucDbkFUjnYIOl4/3+AZcOvzMDmsKJnk7M/7zCw7rg8q5IupustOdqJvSJikYaVyqI+vxqkHbT4bGg4n4VhJg23septesXdsHR7oVqqPhNt7e9o/dKBgbu35c91qbrYsluM3UYBG7y/2NXpviu8glfqTDzz0ptTOU4Rxu9WmD1AUux1R6IgelwMyEYbi3NDbWxavX3Zru+mdCgJJrWNiXEKy1pYBrW6qcFgwE0WpJdA7v5qYUYi5TF85OdOjz6eCuAhuR119ll9eAl1p17wN4wiOrETHBE+H3YdOWyv5pFDojchD8HGE21HijrANKDAcRUqYbpxqHPRmjjqWhp9K3xUpOXwZi6qjQA3uaVCtSY4eGrn9dVXUMAtzjLawfid1o9lLtuldt53Dihpt4n4SFkrD4wqZkxkqoKuzsvq7hAdJuEH/k41Eb4z3zdTdYmpyg8ty130jW7GeN/AdoZV8okCTXpyN8lMS5OKbNuJ6egw9U3f9ncxRuR1KA7BXNAnspGUBnUk0PWwy7vj64thHoW2r1hxB7CjEQzCRlH2pWj2vG5RZ6bR/MkyDxEtQZzirOT304DLog0GU+jvsbAwm2LkA3S2uwgjNLVbbBrXZxM3y2omQ2/IaW3D6dLTok6j/SfiG+kdl86xR8YZwHY9f3cT8Xg8nVnZomg+4M+p3bCoUSkocPXjpbt03lB/4YD6BOdcXlGxpGrMw0Ki9C7j9FZRdBdAE0l5B9K9eNQ456Aja3UX0korKH5o9hXr49xGGLwcRhyrh03nw5EJV77bKV5vlCDjPOq4u9mlkG96Yfxi5o5jniEJayagRckuUpAQohQ7pkf/PLrztzf71qUnPKga/aUIiJbdclyjuyRptC45xjCYD3DLlrkYTXLhxsUqURRT56jIQotZgjE3Gt9mmLJwfZw0lFesejDWVniDHYI+5sKgRkScQv6KRBmPj4xKa6cngMZPhxOdA6peWNrQ606lZ+DRNsVc2wwfU0OAbDNHh23V7hnOeS075tYdwVRW5aVOTmfYMtJXb63ZqvIjKm37rsJ6nMRsWuBonk1i3s8fiOuAHUzKdy+/cT7hcIb53YSICHJWsKx6b5KttY84gWj7iCimwSRXOBostW3O3JHUdUuoL0Eq232DFwyDQqTP8ixmOFU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a023954c-19da-441e-43ec-08d9da9ce6ee X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 16:09:28.2980 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ls8aQ5my3DTepl+nK4G0gau+p6sPhrrjwI7G1TndvnYwdy4G1TqEZsXmKgPYay4rLktwAz2l1oHht6O9YuOAaQADH7AfhPwCgwEpcfpuAbs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4964 Received-SPF: pass client-ip=40.107.21.134; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.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, 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_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add simple test-case for new addresses argument of display-reload qmp command. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/avocado/vnc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/avocado/vnc.py b/tests/avocado/vnc.py index 096432988f..936285a50b 100644 --- a/tests/avocado/vnc.py +++ b/tests/avocado/vnc.py @@ -51,3 +51,13 @@ def test_change_password(self): set_password_response = self.vm.qmp('change-vnc-password', password='new_password') self.assertEqual(set_password_response['return'], {}) + + def test_change_listen(self): + self.vm.add_args('-nodefaults', '-S', '-vnc', ':0') + self.vm.launch() + self.assertEqual(self.vm.qmp('query-vnc')['return']['service'], '5900') + res = self.vm.qmp('display-reload', type='vnc', + addresses=[{'type': 'inet', 'host': '0.0.0.0', + 'port': '5901'}]) + self.assertEqual(res['return'], {}) + self.assertEqual(self.vm.qmp('query-vnc')['return']['service'], '5901')