From nobody Sat Apr 27 09:29:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616957302; cv=none; d=zohomail.com; s=zohoarc; b=eHTuk8oUMzr+z3Hea+TxdhZxxuy4GDSQcZ+KuchSbNt3PLVDGUzjn0OA3LwZYrMyQwAopnG7Vir4jB97ok3mijln020OI4msFiadt6U9f+SLCFmvorjU4HznJ60tJdisGtDynLMts9vx+M7qda5NbE9eX0Djsg63dUC6Dsm5B+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957302; 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=iaOD3xQ5pjlLKR8kXRNgRq1GkuHPhgVh1iuHqIAgMCA=; b=Fs7wEuK9JTOdRGYoODb5FPV7EhYuTZhAddxrraKOce2EWctr21bznXGkyysoyf6/UZiukYTbusRSSYJ8EYeFjim1wOSyqq7bHMKyimsevrDJstH7gvalIq+E1I/o18eVWj/DFepUQQvmCCOGr20qob3ypgG2q/YsQMZHn9vm0Yg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616957302622685.1211401327944; Sun, 28 Mar 2021 11:48:22 -0700 (PDT) Received: from localhost ([::1]:54884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaST-00040S-KS for importer@patchew.org; Sun, 28 Mar 2021 14:48:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQ7-0002CX-3z for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:45:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQ5-00017e-Ir for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:45:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-Cy4qw1I8Pb-SSpcj6rstAw-1; Sun, 28 Mar 2021 14:45:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 739CA8749BC; Sun, 28 Mar 2021 18:45:49 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99FD45D6A1; Sun, 28 Mar 2021 18:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957153; 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=iaOD3xQ5pjlLKR8kXRNgRq1GkuHPhgVh1iuHqIAgMCA=; b=AcbamThuKHrWFLYrXB+yN0KNM5NJHSaVuf0YXBZUzORR2CK/8+f5fYTcW7ft81Td6wQv0E KyPd4eSy7kylfOBiZfWULsbLklTJGDYyK23B1fIDrOaJVpRTgw4GWL/XS6Yc5WLFZuzi4j NKO+E1wo1nzz966LIZAiMxcVFLJ36BQ= X-MC-Unique: Cy4qw1I8Pb-SSpcj6rstAw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 01/10] util: fix use-after-free in module_load_one Date: Sun, 28 Mar 2021 22:45:24 +0400 Message-Id: <20210328184533.752840-2-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-stable@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau g_hash_table_add always retains ownership of the pointer passed in as the key. Its return status merely indicates whether the added entry was new, or replaced an existing entry. Thus key must never be freed after this method returns. Spotted by ASAN: =3D=3D2407186=3D=3DERROR: AddressSanitizer: heap-use-after-free on address = 0x6020003ac4f0 at pc 0x7ffff766659c bp 0x7fffffffd1d0 sp 0x7fffffffc980 READ of size 1 at 0x6020003ac4f0 thread T0 #0 0x7ffff766659b (/lib64/libasan.so.6+0x8a59b) #1 0x7ffff6bfa843 in g_str_equal ../glib/ghash.c:2303 #2 0x7ffff6bf8167 in g_hash_table_lookup_node ../glib/ghash.c:493 #3 0x7ffff6bf9b78 in g_hash_table_insert_internal ../glib/ghash.c:1598 #4 0x7ffff6bf9c32 in g_hash_table_add ../glib/ghash.c:1689 #5 0x5555596caad4 in module_load_one ../util/module.c:233 #6 0x5555596ca949 in module_load_one ../util/module.c:225 #7 0x5555596ca949 in module_load_one ../util/module.c:225 #8 0x5555596cbdf4 in module_load_qom_all ../util/module.c:349 Typical C bug... Fixes: 90629122d2e ("module: use g_hash_table_add()") Cc: qemu-stable@nongnu.org Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210316134456.3243102-1-marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- util/module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/module.c b/util/module.c index cbe89fede6..7661d0f623 100644 --- a/util/module.c +++ b/util/module.c @@ -230,10 +230,11 @@ bool module_load_one(const char *prefix, const char *= lib_name, bool mayfail) } } =20 - if (!g_hash_table_add(loaded_modules, module_name)) { + if (g_hash_table_contains(loaded_modules, module_name)) { g_free(module_name); return true; } + g_hash_table_add(loaded_modules, module_name); =20 search_dir =3D getenv("QEMU_MODULE_DIR"); if (search_dir !=3D NULL) { --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957492; cv=none; d=zohomail.com; s=zohoarc; b=OMmDP5ERfj0jfQa1y8GA8Bm35K3dUehhsxkY5WiaK2mpoOOagIJ9C+DsF5R4ujn4jK98rxNN56lTTgECj+GAd3prE4V09wnUepOjsmGthJfn5ESsea7JrLThDyJsbJqlov6ANIlBZyX4CUVaw9as1Eaa/8Up4fpYRUxUzP/MeYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957492; 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=EsNbzokXUBnh9Fz6v2IEB30C4nOjOr8tWj6XpAo9scA=; b=W3/nyAZ9VspfuwNcaotrwf8fweoMS1eDkyZzlk64h6Wy0ELpSS7UPJQIHW+ENR3Zl73CZs7r471In6Sv42iU4qW4fyMRNnTA8m0Cfs6jT3wILf4jZboTxN+gNe0ckjnZ51QRypqEgYqAC9LfmZTEj/I/PgAmkRgpX2BCZwz+JOk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161695749237578.87647388671144; Sun, 28 Mar 2021 11:51:32 -0700 (PDT) Received: from localhost ([::1]:35154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaVX-0007iD-9H for importer@patchew.org; Sun, 28 Mar 2021 14:51:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQG-0002OQ-N1 for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQE-0001B9-R6 for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-r2o--SxFM2-Zp5SorsvGcA-1; Sun, 28 Mar 2021 14:45:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 396941853020; Sun, 28 Mar 2021 18:45:55 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E09C5D6A1; Sun, 28 Mar 2021 18:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957160; 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=EsNbzokXUBnh9Fz6v2IEB30C4nOjOr8tWj6XpAo9scA=; b=B60LMAdYsD2aj3PWfqn24YiTHIjB/BHzJwjJEKi8arsmasd0gPqU7jqrYB8o/l5WQp1i7f pokHrtk4J+VWVFV7t4QRro+xj2fmPGQQuUQzQh68+q1OVTAsp2/3KUqaN8XswVi9g/OVW7 uZzbK2yIswylUXLUHceCzPXNHMV2sFw= X-MC-Unique: r2o--SxFM2-Zp5SorsvGcA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 02/10] dbus-vmstate: Increase the size of input stream buffer used during load Date: Sun, 28 Mar 2021 22:45:25 +0400 Message-Id: <20210328184533.752840-3-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Priyankar Jain Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Priyankar Jain This commit fixes an issue where migration is failing in the load phase because of a false alarm about data unavailability. Following is the error received when the amount of data to be transferred exceeds the default buffer size setup by G_BUFFERED_INPUT_STREAM(4KiB), even when the maximum data size supported by this backend is 1MiB (DBUS_VMSTATE_SIZE_LIMIT): dbus_vmstate_post_load: Invalid vmstate size: 4364 qemu-kvm: error while loading state for instance 0x0 of device 'dbus-vmst= ate/dbus-vmstate' This commit sets the size of the input stream buffer used during load to DBUS_VMSTATE_SIZE_LIMIT which is the maximum amount of data a helper can send during save phase. Secondly, this commit makes sure that the input stream buffer is loaded bef= ore checking the size of the data available in it, rectifying the false alarm a= bout data unavailability. Fixes: 5010cec2bc87 ("Add dbus-vmstate object") Signed-off-by: Priyankar Jain Message-Id: [ Modified printf format for gsize ] Reviewed-by: Marc-Andr=C3=A9 Lureau --- backends/dbus-vmstate.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c index 2a0d2e4a31..9cfd758c42 100644 --- a/backends/dbus-vmstate.c +++ b/backends/dbus-vmstate.c @@ -204,6 +204,8 @@ static int dbus_vmstate_post_load(void *opaque, int ver= sion_id) m =3D g_memory_input_stream_new_from_data(self->data, self->data_size,= NULL); s =3D g_data_input_stream_new(m); g_data_input_stream_set_byte_order(s, G_DATA_STREAM_BYTE_ORDER_BIG_END= IAN); + g_buffered_input_stream_set_buffer_size(G_BUFFERED_INPUT_STREAM(s), + DBUS_VMSTATE_SIZE_LIMIT); =20 nelem =3D g_data_input_stream_read_uint32(s, NULL, &err); if (err) { @@ -244,11 +246,23 @@ static int dbus_vmstate_post_load(void *opaque, int v= ersion_id) } =20 len =3D g_data_input_stream_read_uint32(s, NULL, &err); + if (len > DBUS_VMSTATE_SIZE_LIMIT) { + error_report("%s: Invalid vmstate size: %u", __func__, len); + return -1; + } + + g_buffered_input_stream_fill(G_BUFFERED_INPUT_STREAM(s), len, NULL, + &err); + if (err) { + goto error; + } + avail =3D g_buffered_input_stream_get_available( G_BUFFERED_INPUT_STREAM(s)); - - if (len > DBUS_VMSTATE_SIZE_LIMIT || len > avail) { - error_report("%s: Invalid vmstate size: %u", __func__, len); + if (len > avail) { + error_report("%s: Not enough data available to load for Id: '%= s'. " + "Available data size: %zu, Actual vmstate size: %u", + __func__, id, avail, len); return -1; } =20 --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957375; cv=none; d=zohomail.com; s=zohoarc; b=kOG96X5aTKpKA8B5COOl4rGHmYjibdtmQzQbuBcGTd0WVDPOc4SjF9z+Wv1zTfSLnxdVgHYmI3T9cxawgKzkw20D8VzV3+ItDRaF6VCfMZJYxLAwhTdVZTm+gL1gCidmgz4ORV15rXO2/9fEEgw0f31CXbJgIAQ42aJTXx+9v44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957375; 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=FSf2L7Kex+5v95xy77YavkOede0IoVeiNpcK0UiCXj8=; b=Sk8JsTREm03HCnfXbzdjOnPsyJ0YLAZ3J6Y6PFbTgo3pQWItPRhCnk2S/XCCP8cDJr77WKJykZTdKltGbklka4cXBa/641+C15CMwN3Pl8PBrpjcKdwJrw1RUYh0Bd3fWeCjSKxhIgjWukXsx/OREsfLkT8juEwPpSWhAPKYziA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161695737505945.74150810596359; Sun, 28 Mar 2021 11:49:35 -0700 (PDT) Received: from localhost ([::1]:57820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaTd-0005FH-Sp for importer@patchew.org; Sun, 28 Mar 2021 14:49:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQV-0002av-Pf for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37333) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQO-0001EN-OL for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-526-LS8XAj5pNemjb0I7vGN3gw-1; Sun, 28 Mar 2021 14:46:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B702287A826; Sun, 28 Mar 2021 18:46:05 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D24C503EE; Sun, 28 Mar 2021 18:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957170; 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=FSf2L7Kex+5v95xy77YavkOede0IoVeiNpcK0UiCXj8=; b=cUtW82jd9pSQKZn1rKJ0Pyszr/Ikx1A39GQs6HMJi6qPH5HcSqDFzQ4gBLI7BgRX0IbOEC BL19YQB9EVhC//+oFvUnXyd5FBIJXQaGorgAvkqXRuLC9HtfoNa60pQEfSLew6v5FG2b4k K59NL+rUNx/khhuyKydrZucvt7REld0= X-MC-Unique: LS8XAj5pNemjb0I7vGN3gw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 03/10] sphinx: adopt kernel readthedoc theme Date: Sun, 28 Mar 2021 22:45:26 +0400 Message-Id: <20210328184533.752840-4-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Marc-Andr=C3=A9 Lureau The default "alabaster" sphinx theme has a couple shortcomings: - the navbar moves along the page - the search bar is not always at the same place - it lacks some contrast and colours The "rtd" theme from readthedocs.org is a popular third party theme used notably by the kernel, with a custom style sheet. I like it better, perhaps others do too. It also simplifies the "Edit on Gitlab" links. Tweak a bit the custom theme to match qemu.org style, use the QEMU logo, and favicon etc. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Bin Meng Message-Id: <20210323115328.4146052-1-marcandre.lureau@redhat.com> Reviewed-by: John Snow --- docs/_templates/editpage.html | 5 - docs/conf.py | 51 ++++--- docs/devel/_templates/editpage.html | 5 - docs/interop/_templates/editpage.html | 5 - docs/meson.build | 5 +- docs/specs/_templates/editpage.html | 5 - docs/sphinx-static/theme_overrides.css | 161 +++++++++++++++++++++ docs/system/_templates/editpage.html | 5 - docs/tools/_templates/editpage.html | 5 - docs/user/_templates/editpage.html | 5 - tests/docker/dockerfiles/alpine.docker | 1 + tests/docker/dockerfiles/debian10.docker | 1 + tests/docker/dockerfiles/fedora.docker | 1 + tests/docker/dockerfiles/ubuntu.docker | 1 + tests/docker/dockerfiles/ubuntu1804.docker | 1 + tests/docker/dockerfiles/ubuntu2004.docker | 1 + 16 files changed, 199 insertions(+), 59 deletions(-) delete mode 100644 docs/_templates/editpage.html delete mode 100644 docs/devel/_templates/editpage.html delete mode 100644 docs/interop/_templates/editpage.html delete mode 100644 docs/specs/_templates/editpage.html create mode 100644 docs/sphinx-static/theme_overrides.css delete mode 100644 docs/system/_templates/editpage.html delete mode 100644 docs/tools/_templates/editpage.html delete mode 100644 docs/user/_templates/editpage.html diff --git a/docs/_templates/editpage.html b/docs/_templates/editpage.html deleted file mode 100644 index 4319b0f5ac..0000000000 --- a/docs/_templates/editpage.html +++ /dev/null @@ -1,5 +0,0 @@ -
- -
diff --git a/docs/conf.py b/docs/conf.py index 2ee6111872..3802b70d62 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -150,38 +150,47 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme =3D 'alabaster' +try: + import sphinx_rtd_theme +except ImportError: + raise ConfigError( + 'The Sphinx \'sphinx_rtd_theme\' HTML theme was not found.\n' + ) + +html_theme =3D 'sphinx_rtd_theme' =20 # Theme options are theme-specific and customize the look and feel of a th= eme # further. For a list of options available for each theme, see the # documentation. -# We initialize this to empty here, so the per-manual conf.py can just -# add individual key/value entries. -html_theme_options =3D { -} +if html_theme =3D=3D 'sphinx_rtd_theme': + html_theme_options =3D { + "style_nav_header_background": "#802400", + } + +html_logo =3D os.path.join(qemu_docdir, "../ui/icons/qemu_128x128.png") + +html_favicon =3D os.path.join(qemu_docdir, "../ui/icons/qemu_32x32.png") =20 # Add any paths that contain custom static files (such as style sheets) he= re, # relative to this directory. They are copied after the builtin static fil= es, # so a file named "default.css" will overwrite the builtin "default.css". -# QEMU doesn't yet have any static files, so comment this out so we don't -# get a warning about a missing directory. -# If we do ever add this then it would probably be better to call the -# subdirectory sphinx_static, as the Linux kernel does. -# html_static_path =3D ['_static'] +html_static_path =3D [os.path.join(qemu_docdir, "sphinx-static")] + +html_css_files =3D [ + 'theme_overrides.css', +] + +html_context =3D { + "display_gitlab": True, + "gitlab_user": "qemu-project", + "gitlab_repo": "qemu", + "gitlab_version": "master", + "conf_py_path": "/docs/", # Path in the checkout to the docs root +} =20 # Custom sidebar templates, must be a dictionary that maps document names # to template names. -# -# This is required for the alabaster theme -# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sideba= rs -html_sidebars =3D { - '**': [ - 'about.html', - 'editpage.html', - 'navigation.html', - 'searchbox.html', - ] -} +#html_sidebars =3D {} =20 # Don't copy the rST source files to the HTML output directory, # and don't put links to the sources into the output HTML. diff --git a/docs/devel/_templates/editpage.html b/docs/devel/_templates/ed= itpage.html deleted file mode 100644 index a86d22bca8..0000000000 --- a/docs/devel/_templates/editpage.html +++ /dev/null @@ -1,5 +0,0 @@ -
- -
diff --git a/docs/interop/_templates/editpage.html b/docs/interop/_template= s/editpage.html deleted file mode 100644 index 215e562681..0000000000 --- a/docs/interop/_templates/editpage.html +++ /dev/null @@ -1,5 +0,0 @@ -
- -
diff --git a/docs/meson.build b/docs/meson.build index f84306ba7e..855e3916e9 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -27,10 +27,9 @@ if sphinx_build.found() build_docs =3D (sphinx_build_test_out.returncode() =3D=3D 0) =20 if not build_docs - warning('@0@ is either too old or uses too old a Python version' - .format(sphinx_build.full_path())) + warning('@0@: @1@'.format(sphinx_build.full_path(), sphinx_build_test_= out.stderr())) if get_option('docs').enabled() - error('Install a Python 3 version of python-sphinx') + error('Install a Python 3 version of python-sphinx and the readthedo= c theme') endif endif endif diff --git a/docs/specs/_templates/editpage.html b/docs/specs/_templates/ed= itpage.html deleted file mode 100644 index aaa468aa98..0000000000 --- a/docs/specs/_templates/editpage.html +++ /dev/null @@ -1,5 +0,0 @@ -
- -
diff --git a/docs/sphinx-static/theme_overrides.css b/docs/sphinx-static/th= eme_overrides.css new file mode 100644 index 0000000000..c70ef95128 --- /dev/null +++ b/docs/sphinx-static/theme_overrides.css @@ -0,0 +1,161 @@ +/* -*- coding: utf-8; mode: css -*- + * + * Sphinx HTML theme customization: read the doc + * Based on Linux Documentation/sphinx-static/theme_overrides.css + */ + +/* Improve contrast and increase size for easier reading. */ + +body { + font-family: serif; + color: black; + font-size: 100%; +} + +h1, h2, .rst-content .toctree-wrapper p.caption, h3, h4, h5, h6, legend { + font-family: sans-serif; +} + +.rst-content dl:not(.docutils) dt { + border-top: none; + border-left: solid 3px #ccc; + background-color: #f0f0f0; + color: black; +} + +.wy-nav-top { + background: #802400; +} + +.wy-side-nav-search input[type=3D"text"] { + border-color: #f60; +} + +.wy-menu-vertical p.caption { + color: white; +} + +.wy-menu-vertical li.current a { + color: #505050; +} + +.wy-menu-vertical li.on a, .wy-menu-vertical li.current > a { + color: #303030; +} + +.fa-gitlab { + box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 3px 10px 0 rgba(0,0,0,0.1= 9); + border-radius: 5px; +} + +div[class^=3D"highlight"] pre { + font-family: monospace; + color: black; + font-size: 100%; +} + +.wy-menu-vertical { + font-family: sans-serif; +} + +.c { + font-style: normal; +} + +p { + font-size: 100%; +} + +/* Interim: Code-blocks with line nos - lines and line numbers don't line = up. + * see: https://github.com/rtfd/sphinx_rtd_theme/issues/419 + */ + +div[class^=3D"highlight"] pre { + line-height: normal; +} +.rst-content .highlight > pre { + line-height: normal; +} + +/* Keep fields from being strangely far apart due to inheirited table CSS.= */ +.rst-content table.field-list th.field-name { + padding-top: 1px; + padding-bottom: 1px; +} +.rst-content table.field-list td.field-body { + padding-top: 1px; + padding-bottom: 1px; +} + +@media screen { + + /* content column + * + * RTD theme's default is 800px as max width for the content, but we h= ave + * tables with tons of columns, which need the full width of the view-= port. + */ + + .wy-nav-content{max-width: none; } + + /* table: + * + * - Sequences of whitespace should collapse into a single whitespac= e. + * - make the overflow auto (scrollbar if needed) + * - align caption "left" ("center" is unsuitable on vast tables) + */ + + .wy-table-responsive table td { white-space: normal; } + .wy-table-responsive { overflow: auto; } + .rst-content table.docutils caption { text-align: left; font-size: 100= %; } + + /* captions: + * + * - captions should have 100% (not 85%) font size + * - hide the permalink symbol as long as link is not hovered + */ + + .toc-title { + font-size: 150%; + font-weight: bold; + } + + caption, .wy-table caption, .rst-content table.field-list caption { + font-size: 100%; + } + caption a.headerlink { opacity: 0; } + caption a.headerlink:hover { opacity: 1; } + + /* Menu selection and keystrokes */ + + span.menuselection { + color: blue; + font-family: "Courier New", Courier, monospace + } + + code.kbd, code.kbd span { + color: white; + background-color: darkblue; + font-weight: bold; + font-family: "Courier New", Courier, monospace + } + + /* fix bottom margin of lists items */ + + .rst-content .section ul li:last-child, .rst-content .section ul li p:= last-child { + margin-bottom: 12px; + } + + /* inline literal: drop the borderbox, padding and red color */ + + code, .rst-content tt, .rst-content code { + color: inherit; + border: none; + padding: unset; + background: inherit; + font-size: 85%; + } + + .rst-content tt.literal,.rst-content tt.literal,.rst-content code.lite= ral { + color: inherit; + } +} diff --git a/docs/system/_templates/editpage.html b/docs/system/_templates/= editpage.html deleted file mode 100644 index 6586b2e257..0000000000 --- a/docs/system/_templates/editpage.html +++ /dev/null @@ -1,5 +0,0 @@ -
- -
diff --git a/docs/tools/_templates/editpage.html b/docs/tools/_templates/ed= itpage.html deleted file mode 100644 index 2a9c8fc92b..0000000000 --- a/docs/tools/_templates/editpage.html +++ /dev/null @@ -1,5 +0,0 @@ -
- -
diff --git a/docs/user/_templates/editpage.html b/docs/user/_templates/edit= page.html deleted file mode 100644 index 1f5ee01e60..0000000000 --- a/docs/user/_templates/editpage.html +++ /dev/null @@ -1,5 +0,0 @@ -
- -
diff --git a/tests/docker/dockerfiles/alpine.docker b/tests/docker/dockerfi= les/alpine.docker index d63a269aef..88d3bbe5f2 100644 --- a/tests/docker/dockerfiles/alpine.docker +++ b/tests/docker/dockerfiles/alpine.docker @@ -39,6 +39,7 @@ ENV PACKAGES \ pulseaudio-dev \ python3 \ py3-sphinx \ + py3-sphinx_rtd_theme \ shadow \ snappy-dev \ spice-dev \ diff --git a/tests/docker/dockerfiles/debian10.docker b/tests/docker/docker= files/debian10.docker index d034acbd25..63cf835ec5 100644 --- a/tests/docker/dockerfiles/debian10.docker +++ b/tests/docker/dockerfiles/debian10.docker @@ -32,6 +32,7 @@ RUN apt update && \ psmisc \ python3 \ python3-sphinx \ + python3-sphinx-rtd-theme \ $(apt-get -s build-dep --arch-only qemu | egrep ^Inst | fgrep '[al= l]' | cut -d\ -f2) =20 ENV FEATURES docs diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfi= les/fedora.docker index 915fdc1845..d8fa16372d 100644 --- a/tests/docker/dockerfiles/fedora.docker +++ b/tests/docker/dockerfiles/fedora.docker @@ -92,6 +92,7 @@ ENV PACKAGES \ python3-pillow \ python3-pip \ python3-sphinx \ + python3-sphinx_rtd_theme \ python3-virtualenv \ rdma-core-devel \ SDL2-devel \ diff --git a/tests/docker/dockerfiles/ubuntu.docker b/tests/docker/dockerfi= les/ubuntu.docker index b5ef7a8198..98a527361c 100644 --- a/tests/docker/dockerfiles/ubuntu.docker +++ b/tests/docker/dockerfiles/ubuntu.docker @@ -63,6 +63,7 @@ ENV PACKAGES \ ninja-build \ python3-yaml \ python3-sphinx \ + python3-sphinx-rtd-theme \ sparse \ xfslibs-dev RUN apt-get update && \ diff --git a/tests/docker/dockerfiles/ubuntu1804.docker b/tests/docker/dock= erfiles/ubuntu1804.docker index 9b0a19ba5e..c0d3642507 100644 --- a/tests/docker/dockerfiles/ubuntu1804.docker +++ b/tests/docker/dockerfiles/ubuntu1804.docker @@ -48,6 +48,7 @@ ENV PACKAGES \ make \ python3-yaml \ python3-sphinx \ + python3-sphinx-rtd-theme \ ninja-build \ sparse \ xfslibs-dev diff --git a/tests/docker/dockerfiles/ubuntu2004.docker b/tests/docker/dock= erfiles/ubuntu2004.docker index 9750016e51..f1e0ebad49 100644 --- a/tests/docker/dockerfiles/ubuntu2004.docker +++ b/tests/docker/dockerfiles/ubuntu2004.docker @@ -58,6 +58,7 @@ ENV PACKAGES flex bison \ python3-pil \ python3-pip \ python3-sphinx \ + python3-sphinx-rtd-theme \ python3-venv \ python3-yaml \ rpm2cpio \ --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957485; cv=none; d=zohomail.com; s=zohoarc; b=il7VZJ2itlh8vH6QhvTGWTFizmk8SkbSE+AyyF+Ca31CktonvtXabEhg+/mGPTEBqEu7WCJVxLBkDwyxqdnzVEP1RaLH//vVSyowcZaRygM/Ih7Icwe1XeDa0KP9bQcjD9bBuZLbyGepLUZVp8CIvTASOEvEmb7WjPrwMXkOIAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957485; 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=TDgXfIDCvb0dC3eYEQfAL7PIi0M4c4+FxvnilNeC6b8=; b=arOWwH8GXMpWWhhxT2rQyBx+mJbVe//zz+IuQzOPVYzyxlGr+Xn5TnNLlmqnYTCleTovhDpC2GZ+tb/uqLKGhSFdtH3SgYs/Uvut5Z7hi9nIVlodBe76wwxivG0FR5YmhWlKomaQUzx52nW22EKUBxauDpReroKaXgsH44aQPeM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161695748554194.11045159403534; Sun, 28 Mar 2021 11:51:25 -0700 (PDT) Received: from localhost ([::1]:34490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaVQ-0007Rc-Hu for importer@patchew.org; Sun, 28 Mar 2021 14:51:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQc-0002ea-4E for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQV-0001GW-88 for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-Y1rbeWhONqa8v-CaK_Yrsg-1; Sun, 28 Mar 2021 14:46:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 044801853024; Sun, 28 Mar 2021 18:46:15 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 702661B426; Sun, 28 Mar 2021 18:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957178; 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=TDgXfIDCvb0dC3eYEQfAL7PIi0M4c4+FxvnilNeC6b8=; b=XQ4xLdB+v4VRGF9yEl4+jFCiO8pEGCkSfcg5Bg3FPSvViUe0HtFSg+XR4d6i8d7oBEae56 2k2BfcG9Xpc2Iwuq8HOF8Jsth27pYHlBGAI2yshho5hswT2aZ9WKV75d4mGpq8psljiYLE YF+3yNP9mEHj46yfD6x3q4Yjjtkts6I= X-MC-Unique: Y1rbeWhONqa8v-CaK_Yrsg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 04/10] docs: simplify each section title Date: Sun, 28 Mar 2021 22:45:27 +0400 Message-Id: <20210328184533.752840-5-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Marc-Andr=C3=A9 Lureau Now that we merged into one doc, it makes the nav looks nicer. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210323074704.4078381-1-marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Snow --- docs/devel/index.rst | 4 ++-- docs/interop/index.rst | 4 ++-- docs/specs/index.rst | 4 ++-- docs/system/index.rst | 4 ++-- docs/tools/index.rst | 4 ++-- docs/user/index.rst | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/devel/index.rst b/docs/devel/index.rst index 7c424ea6d7..60039faa68 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -1,8 +1,8 @@ .. This is the top level page for the 'devel' manual. =20 =20 -QEMU Developer's Guide -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Developer Information +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 This manual documents various parts of the internals of QEMU. You only need to read it if you are interested in reading or diff --git a/docs/interop/index.rst b/docs/interop/index.rst index 95d56495f6..219a5e5fc5 100644 --- a/docs/interop/index.rst +++ b/docs/interop/index.rst @@ -1,8 +1,8 @@ .. This is the top level page for the 'interop' manual. =20 =20 -QEMU System Emulation Management and Interoperability Guide -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +System Emulation Management and Interoperability +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 This manual contains documents and specifications that are useful for making QEMU interoperate with other software. diff --git a/docs/specs/index.rst b/docs/specs/index.rst index 1b0eb979d5..7b08314d33 100644 --- a/docs/specs/index.rst +++ b/docs/specs/index.rst @@ -1,8 +1,8 @@ .. This is the top level page for the 'specs' manual =20 =20 -QEMU System Emulation Guest Hardware Specifications -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +System Emulation Guest Hardware Specifications +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 =20 Contents: diff --git a/docs/system/index.rst b/docs/system/index.rst index 6ad9c93806..02d0707181 100644 --- a/docs/system/index.rst +++ b/docs/system/index.rst @@ -1,8 +1,8 @@ .. This is the top level page for the 'system' manual. =20 =20 -QEMU System Emulation User's Guide -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +System Emulation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 This manual is the overall guide for users using QEMU for full system emulation (as opposed to user-mode emulation). diff --git a/docs/tools/index.rst b/docs/tools/index.rst index 3a5829c17a..d923834a73 100644 --- a/docs/tools/index.rst +++ b/docs/tools/index.rst @@ -1,8 +1,8 @@ .. This is the top level page for the 'tools' manual =20 =20 -QEMU Tools Guide -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Tools +=3D=3D=3D=3D=3D =20 =20 Contents: diff --git a/docs/user/index.rst b/docs/user/index.rst index e030dadf65..a5b47459ec 100644 --- a/docs/user/index.rst +++ b/docs/user/index.rst @@ -1,8 +1,8 @@ .. This is the top level page for the 'user' manual. =20 =20 -QEMU User Mode Emulation User's Guide -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +User Mode Emulation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 This manual is the overall guide for users using QEMU for user-mode emulation. In this mode, QEMU can launch --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957629; cv=none; d=zohomail.com; s=zohoarc; b=WYqxIP8Gt97YxwnvxNRiHZAyTQTfNO0bCbrCjjX1ty/3jzLpmZiE7bRlC5LFyJTsLvbwIlfhwYS6NmdVNoosN6nvt7/227eZZi/FizTSqHQPPYCLZ5ZAHI5XzwuFeFdYt7KKIprJY9okiA8A2IXmBzwy1M941XzF3+pXcwgpUo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957629; 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=XEGTyoFwwAC+Bak9zPPVghB4pUU5qnHSMEsHSpO/GZM=; b=id3M5XbFPdp+e9D8nmYKWgdLNINinSwofXl+KxWceEqOqGjTQIegVMPc8IJQtHyWvJ9qtkUvx698vX/WATd16f51Ar+lEgvxd7alwY65dO1XstNP4RuTK/uDhVTfyiZdl1bFkIM4ZncqJirCtctFRqSgSc0nAMLF/HwR7+KpOqw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616957629580347.68217663306837; Sun, 28 Mar 2021 11:53:49 -0700 (PDT) Received: from localhost ([::1]:43778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaXk-0002pN-FD for importer@patchew.org; Sun, 28 Mar 2021 14:53:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQe-0002lq-QJ for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQc-0001Hw-My for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428--UfT2MhrP4qvzAupNj324g-1; Sun, 28 Mar 2021 14:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3734D87A83E; Sun, 28 Mar 2021 18:46:22 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B64B5D6A1; Sun, 28 Mar 2021 18:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957185; 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=XEGTyoFwwAC+Bak9zPPVghB4pUU5qnHSMEsHSpO/GZM=; b=LfRzDVRfM/dgOZ37LBwn+6ZLvo5VIJjJeGB7WLF6GG0JpHFWGVqo+XEdzHy0RfKjG5g2UP fzJw5t8JcSzo8d3qkLAgVlpP+X+WsgTlciaQGRWAAvZTa8oMT0reUSTnIu3rC4YasnAZej REdz/oYKU9h5VdVlnfon3pgtvHo82cU= X-MC-Unique: -UfT2MhrP4qvzAupNj324g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 05/10] yank: Remove dependency on qiochannel Date: Sun, 28 Mar 2021 22:45:28 +0400 Message-Id: <20210328184533.752840-6-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lukas Straub Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Lukas Straub Remove dependency on qiochannel by removing yank_generic_iochannel and letting migration and chardev use their own yank function for iochannel. Signed-off-by: Lukas Straub Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20ff143fc2db23e27cd41d38043e481376c9cec1.1616521341.git.lukass= traub2@web.de> --- include/qemu/yank.h | 10 ---------- migration/yank_functions.h | 17 +++++++++++++++++ chardev/char-socket.c | 21 ++++++++++++++------- migration/channel.c | 6 ++++-- migration/multifd.c | 3 ++- migration/qemu-file-channel.c | 3 ++- migration/yank_functions.c | 20 ++++++++++++++++++++ stubs/yank.c | 6 ------ util/yank.c | 8 -------- MAINTAINERS | 1 + migration/meson.build | 1 + 11 files changed, 61 insertions(+), 35 deletions(-) create mode 100644 migration/yank_functions.h create mode 100644 migration/yank_functions.c diff --git a/include/qemu/yank.h b/include/qemu/yank.h index 5b93c70cbf..5375a1f195 100644 --- a/include/qemu/yank.h +++ b/include/qemu/yank.h @@ -73,16 +73,6 @@ void yank_unregister_function(const YankInstance *instan= ce, YankFn *func, void *opaque); =20 -/** - * yank_generic_iochannel: Generic yank function for iochannel - * - * This is a generic yank function which will call qio_channel_shutdown on= the - * provided QIOChannel. - * - * @opaque: QIOChannel to shutdown - */ -void yank_generic_iochannel(void *opaque); - #define BLOCKDEV_YANK_INSTANCE(the_node_name) (&(YankInstance) { \ .type =3D YANK_INSTANCE_TYPE_BLOCK_NODE, \ .u.block_node.node_name =3D (the_node_name) }) diff --git a/migration/yank_functions.h b/migration/yank_functions.h new file mode 100644 index 0000000000..055ea22523 --- /dev/null +++ b/migration/yank_functions.h @@ -0,0 +1,17 @@ +/* + * migration yank functions + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +/** + * migration_yank_iochannel: yank function for iochannel + * + * This yank function will call qio_channel_shutdown on the provided QIOCh= annel. + * + * @opaque: QIOChannel to shutdown + */ +void migration_yank_iochannel(void *opaque); diff --git a/chardev/char-socket.c b/chardev/char-socket.c index f618bdec28..1d455ecca4 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -402,6 +402,13 @@ static void remove_hup_source(SocketChardev *s) } } =20 +static void char_socket_yank_iochannel(void *opaque) +{ + QIOChannel *ioc =3D QIO_CHANNEL(opaque); + + qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); +} + static void tcp_chr_free_connection(Chardev *chr) { SocketChardev *s =3D SOCKET_CHARDEV(chr); @@ -424,7 +431,7 @@ static void tcp_chr_free_connection(Chardev *chr) (s->state =3D=3D TCP_CHARDEV_STATE_CONNECTING || s->state =3D=3D TCP_CHARDEV_STATE_CONNECTED)) { yank_unregister_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(s->sioc)); } object_unref(OBJECT(s->sioc)); @@ -946,7 +953,7 @@ static int tcp_chr_add_client(Chardev *chr, int fd) tcp_chr_set_client_ioc_name(chr, sioc); if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } ret =3D tcp_chr_new_client(chr, sioc); @@ -965,7 +972,7 @@ static void tcp_chr_accept(QIONetListener *listener, tcp_chr_set_client_ioc_name(chr, cioc); if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(cioc)); } tcp_chr_new_client(chr, cioc); @@ -985,7 +992,7 @@ static int tcp_chr_connect_client_sync(Chardev *chr, Er= ror **errp) } if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } tcp_chr_new_client(chr, sioc); @@ -1005,7 +1012,7 @@ static void tcp_chr_accept_server_sync(Chardev *chr) tcp_chr_set_client_ioc_name(chr, sioc); if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } tcp_chr_new_client(chr, sioc); @@ -1138,7 +1145,7 @@ static void qemu_chr_socket_connected(QIOTask *task, = void *opaque) tcp_chr_change_state(s, TCP_CHARDEV_STATE_DISCONNECTED); if (s->registered_yank) { yank_unregister_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } check_report_connect_error(chr, err); @@ -1176,7 +1183,7 @@ static void tcp_chr_connect_client_async(Chardev *chr) tcp_chr_set_client_ioc_name(chr, sioc); if (s->registered_yank) { yank_register_function(CHARDEV_YANK_INSTANCE(chr->label), - yank_generic_iochannel, + char_socket_yank_iochannel, QIO_CHANNEL(sioc)); } /* diff --git a/migration/channel.c b/migration/channel.c index 35fe234e9c..c9ee902021 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -20,6 +20,7 @@ #include "io/channel-tls.h" #include "io/channel-socket.h" #include "qemu/yank.h" +#include "yank_functions.h" =20 /** * @migration_channel_process_incoming - Create new incoming migration cha= nnel @@ -38,7 +39,8 @@ void migration_channel_process_incoming(QIOChannel *ioc) ioc, object_get_typename(OBJECT(ioc))); =20 if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { - yank_register_function(MIGRATION_YANK_INSTANCE, yank_generic_iocha= nnel, + yank_register_function(MIGRATION_YANK_INSTANCE, + migration_yank_iochannel, QIO_CHANNEL(ioc)); } =20 @@ -76,7 +78,7 @@ void migration_channel_connect(MigrationState *s, if (!error) { if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { yank_register_function(MIGRATION_YANK_INSTANCE, - yank_generic_iochannel, + migration_yank_iochannel, QIO_CHANNEL(ioc)); } =20 diff --git a/migration/multifd.c b/migration/multifd.c index 03527c564c..a6677c45c8 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -27,6 +27,7 @@ =20 #include "qemu/yank.h" #include "io/channel-socket.h" +#include "yank_functions.h" =20 /* Multiple fd's */ =20 @@ -989,7 +990,7 @@ int multifd_load_cleanup(Error **errp) if (object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_SOCKET) && OBJECT(p->c)->ref =3D=3D 1) { yank_unregister_function(MIGRATION_YANK_INSTANCE, - yank_generic_iochannel, + migration_yank_iochannel, QIO_CHANNEL(p->c)); } =20 diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index afc3a7f642..876d05a540 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -28,6 +28,7 @@ #include "io/channel-socket.h" #include "qemu/iov.h" #include "qemu/yank.h" +#include "yank_functions.h" =20 =20 static ssize_t channel_writev_buffer(void *opaque, @@ -108,7 +109,7 @@ static int channel_close(void *opaque, Error **errp) if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) && OBJECT(ioc)->ref =3D=3D 1) { yank_unregister_function(MIGRATION_YANK_INSTANCE, - yank_generic_iochannel, + migration_yank_iochannel, QIO_CHANNEL(ioc)); } object_unref(OBJECT(ioc)); diff --git a/migration/yank_functions.c b/migration/yank_functions.c new file mode 100644 index 0000000000..96c90e17dc --- /dev/null +++ b/migration/yank_functions.c @@ -0,0 +1,20 @@ +/* + * migration yank functions + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "io/channel.h" +#include "yank_functions.h" + +void migration_yank_iochannel(void *opaque) +{ + QIOChannel *ioc =3D QIO_CHANNEL(opaque); + + qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); +} diff --git a/stubs/yank.c b/stubs/yank.c index 6090416065..11b24fc057 100644 --- a/stubs/yank.c +++ b/stubs/yank.c @@ -21,9 +21,3 @@ void yank_unregister_function(const YankInstance *instanc= e, void *opaque) { } - -void yank_generic_iochannel(void *opaque) -{ -} - - diff --git a/util/yank.c b/util/yank.c index fc08f65209..abf47c346d 100644 --- a/util/yank.c +++ b/util/yank.c @@ -15,7 +15,6 @@ #include "qapi/qapi-commands-yank.h" #include "qapi/qapi-visit-yank.h" #include "qapi/clone-visitor.h" -#include "io/channel.h" #include "qemu/yank.h" =20 struct YankFuncAndParam { @@ -151,13 +150,6 @@ void yank_unregister_function(const YankInstance *inst= ance, abort(); } =20 -void yank_generic_iochannel(void *opaque) -{ - QIOChannel *ioc =3D QIO_CHANNEL(opaque); - - qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); -} - void qmp_yank(YankInstanceList *instances, Error **errp) { diff --git a/MAINTAINERS b/MAINTAINERS index 554be84b32..12c28feb35 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2823,6 +2823,7 @@ M: Lukas Straub S: Odd fixes F: util/yank.c F: stubs/yank.c +F: migration/yank_functions* F: include/qemu/yank.h F: qapi/yank.json =20 diff --git a/migration/meson.build b/migration/meson.build index 9645f44005..2cfa8eed72 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -6,6 +6,7 @@ migration_files =3D files( 'vmstate.c', 'qemu-file-channel.c', 'qemu-file.c', + 'yank_functions.c', ) softmmu_ss.add(migration_files) =20 --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957622; cv=none; d=zohomail.com; s=zohoarc; b=l8WdZ2zEd7JJuFmIiGv/6M3/xdfDeuWV60y3GA3RrJ94jiPe7D7Hkig8cD6VGykLJWV+J7FRH1dME1p+Fh3G/eIXs0E09+AGNtilH+kFw0v6nzV5BfD8TdM83s0hO6g5n+mFVAC7xEIUvUOEo/lZEmnyjc8/ljRC32JUtZifQRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957622; 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=0LO8T7bNUW+8r/eMJGeX8GLhh07MCIeqwow4BHT/m7g=; b=aqT09IjiHqSnryuJVItHRVT2RTlPur1ragxJ4dpOMDd1I7WwB+r/uvWCYuOIiHQhYCRyff6M5dCQFF8G02Louvg4nQRaXE32RTEAibIYcr1ZV+NHt+JG3BbpuLezhASU8Ty0lZPZvzhR1L936yscgQAF7TD0DuzTV8Lk6Sm+pCQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616957622127338.51124275762606; Sun, 28 Mar 2021 11:53:42 -0700 (PDT) Received: from localhost ([::1]:43008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaXc-0002W9-Sv for importer@patchew.org; Sun, 28 Mar 2021 14:53:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQr-00031l-5h for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQk-0001Me-O6 for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-GRgR9l47Nra7kJ0Z81Z8Bw-1; Sun, 28 Mar 2021 14:46:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 629C687A83A; Sun, 28 Mar 2021 18:46:30 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26C045D6A1; Sun, 28 Mar 2021 18:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957194; 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=0LO8T7bNUW+8r/eMJGeX8GLhh07MCIeqwow4BHT/m7g=; b=X3ilC2b2AM9ZS3NSt9jNREYln9tLvRK8jKqgTTcPZuoP6TDWDv0/8D7TeAj0XxAGuC9SZt UzkFvQpU1FuD2K4BscZFujEgEpjE9RGdryNlln7GdkR9leSsaUX3CoprTTUqDo7wvuxNWe 5Vrj+SiwyF2WFlJATgws4Hy4It/BdKo= X-MC-Unique: GRgR9l47Nra7kJ0Z81Z8Bw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 06/10] yank: Always link full yank code Date: Sun, 28 Mar 2021 22:45:29 +0400 Message-Id: <20210328184533.752840-7-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lukas Straub Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Lukas Straub Yank now only depends on util and can be always linked in. Also remove the stubs as they are not needed anymore. Signed-off-by: Lukas Straub Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <997aa12a28c555d8a3b7a363b3bda5c3cf1821ba.1616521341.git.lukass= traub2@web.de> --- stubs/yank.c | 23 ----------------------- MAINTAINERS | 1 - stubs/meson.build | 1 - util/meson.build | 2 +- 4 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 stubs/yank.c diff --git a/stubs/yank.c b/stubs/yank.c deleted file mode 100644 index 11b24fc057..0000000000 --- a/stubs/yank.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu/yank.h" - -bool yank_register_instance(const YankInstance *instance, Error **errp) -{ - return true; -} - -void yank_unregister_instance(const YankInstance *instance) -{ -} - -void yank_register_function(const YankInstance *instance, - YankFn *func, - void *opaque) -{ -} - -void yank_unregister_function(const YankInstance *instance, - YankFn *func, - void *opaque) -{ -} diff --git a/MAINTAINERS b/MAINTAINERS index 12c28feb35..dcab656e62 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2822,7 +2822,6 @@ Yank feature M: Lukas Straub S: Odd fixes F: util/yank.c -F: stubs/yank.c F: migration/yank_functions* F: include/qemu/yank.h F: qapi/yank.json diff --git a/stubs/meson.build b/stubs/meson.build index 8a3e804cf0..be6f6d609e 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -46,7 +46,6 @@ stub_ss.add(files('vm-stop.c')) stub_ss.add(files('win32-kbd-hook.c')) stub_ss.add(files('cpu-synchronize-state.c')) if have_block - stub_ss.add(files('yank.c')) stub_ss.add(files('replay-tools.c')) endif if have_system diff --git a/util/meson.build b/util/meson.build index 984fba965f..510765cde4 100644 --- a/util/meson.build +++ b/util/meson.build @@ -43,6 +43,7 @@ util_ss.add(files('stats64.c')) util_ss.add(files('systemd.c')) util_ss.add(when: 'CONFIG_POSIX', if_true: files('drm.c')) util_ss.add(files('guest-random.c')) +util_ss.add(files('yank.c')) =20 if have_user util_ss.add(files('selfmap.c')) @@ -51,7 +52,6 @@ endif if have_system util_ss.add(files('crc-ccitt.c')) util_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus.c'), gio]) - util_ss.add(files('yank.c')) util_ss.add(when: 'CONFIG_LINUX', if_true: files('userfaultfd.c')) endif =20 --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957491; cv=none; d=zohomail.com; s=zohoarc; b=U2Y74wTxuTp0ZWX0QIBiQ6++Kfigp1UhXRATZi96PHFjR0bzU+DPl8s9N7Dwkfp4xhyIASDH0p4N73nMj7XYRiFuU1vnQOD0xypZiK+514j+Aq/QiMywQ6nmcb702dQb3Lvg1Cd0q92QAiS7p6rHJjMfxGQmWqkBGuxT3QgxC4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957491; 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=oXE/Bgm+erBZQtr1pW+rPTAVUh9BEM9OdXQ5YGZt2jA=; b=Cs2pm5MzhFa4L1zHn9NUfPmZa2IomelFwZhRJthh7HIO5g1sDu9CrNSU/lDRYoAArsYMLDkC3pCCIB0Mpq+lqIloaJGVSc0g1h2MuqaZ+6nWZCbRjqHHr1aui+MblPtnrRJ8ULirK2s0BNJKSVoLIit33aIcSriBQOuZc27hrwE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616957491548690.9472961245001; Sun, 28 Mar 2021 11:51:31 -0700 (PDT) Received: from localhost ([::1]:35094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaVW-0007gd-H7 for importer@patchew.org; Sun, 28 Mar 2021 14:51:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQu-0003B2-NY for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:53906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQs-0001OD-UP for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-498-cuJO6Q7kPaC4i5n24zdEiw-1; Sun, 28 Mar 2021 14:46:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6281C80D6B4; Sun, 28 Mar 2021 18:46:38 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53ADF60853; Sun, 28 Mar 2021 18:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957202; 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=oXE/Bgm+erBZQtr1pW+rPTAVUh9BEM9OdXQ5YGZt2jA=; b=KlPXYU5I+ftfd4MwfdpgTMu4s5Fci5kVmja8jac9F4sv47+KMb2xMUEXA6AIZ0vLO/VWdR PQdnIRpDknwMJuHd6Z/hmTx4v1CjreuFiOUeSFavGzUd1oi2fWsQZ7G0EaRBlsT+tOfmbe zD82lNJlUaNvz0i8x9OtvssLuSRi34I= X-MC-Unique: cuJO6Q7kPaC4i5n24zdEiw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 07/10] chardev/char.c: Move object_property_try_add_child out of chardev_new Date: Sun, 28 Mar 2021 22:45:30 +0400 Message-Id: <20210328184533.752840-8-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lukas Straub Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Lukas Straub Move object_property_try_add_child out of chardev_new into it's callers. This is a preparation for the next patches to fix yank with the chardev-change case. Signed-off-by: Lukas Straub Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: Li Zhang Message-Id: --- chardev/char.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 140d6d9d36..48f321b3e1 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -975,7 +975,9 @@ static Chardev *chardev_new(const char *id, const char = *typename, =20 qemu_char_open(chr, backend, &be_opened, &local_err); if (local_err) { - goto end; + error_propagate(errp, local_err); + object_unref(obj); + return NULL; } =20 if (!chr->filename) { @@ -985,22 +987,6 @@ static Chardev *chardev_new(const char *id, const char= *typename, qemu_chr_be_event(chr, CHR_EVENT_OPENED); } =20 - if (id) { - object_property_try_add_child(get_chardevs_root(), id, obj, - &local_err); - if (local_err) { - goto end; - } - object_unref(obj); - } - -end: - if (local_err) { - error_propagate(errp, local_err); - object_unref(obj); - return NULL; - } - return chr; } =20 @@ -1009,6 +995,7 @@ Chardev *qemu_chardev_new(const char *id, const char *= typename, GMainContext *gcontext, Error **errp) { + Chardev *chr; g_autofree char *genid =3D NULL; =20 if (!id) { @@ -1016,7 +1003,19 @@ Chardev *qemu_chardev_new(const char *id, const char= *typename, id =3D genid; } =20 - return chardev_new(id, typename, backend, gcontext, errp); + chr =3D chardev_new(id, typename, backend, gcontext, errp); + if (!chr) { + return NULL; + } + + if (!object_property_try_add_child(get_chardevs_root(), id, OBJECT(chr= ), + errp)) { + object_unref(OBJECT(chr)); + return NULL; + } + object_unref(OBJECT(chr)); + + return chr; } =20 ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, @@ -1037,6 +1036,13 @@ ChardevReturn *qmp_chardev_add(const char *id, Chard= evBackend *backend, return NULL; } =20 + if (!object_property_try_add_child(get_chardevs_root(), id, OBJECT(chr= ), + errp)) { + object_unref(OBJECT(chr)); + return NULL; + } + object_unref(OBJECT(chr)); + ret =3D g_new0(ChardevReturn, 1); if (CHARDEV_IS_PTY(chr)) { ret->pty =3D g_strdup(chr->filename + 4); --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957775; cv=none; d=zohomail.com; s=zohoarc; b=U23b2CWRRJsAENAHZ6Ai9wkdeHcQ0eQhdN24mnDzfyhFd5FivqXgvEyztusRyM9DKR1k2gQdBtTg37DxtaBsnrdWqMhsuEVkR4E1w82x/IZDdorAwHHPVrwrTz7oTIPIytZGPmZfTljCjw4kNE6F0GquxyrJt+wxTx05o0hlh9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957775; 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=epeJ9rthwp9IK9+kqXLc27V5qVbURYQ6Xk+tOUq5q/Y=; b=iTe0VxB4rdJVJk50nJnoc3MITZlWORqxLXMPS5zC5tJtuB1UpbIeyK3JYQe6GBo4SL2bepkoTSN+r85pXSJTJVi7l11Jp02ohi03MV2v13Dnofm0Ht2WrlJO/acL3tKnovrQ3yE2J5UL/PehuAQfMHmMWYUwRuMzL5zCoNQQM8k= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616957775267189.9447723978052; Sun, 28 Mar 2021 11:56:15 -0700 (PDT) Received: from localhost ([::1]:50728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaa6-0005i1-6m for importer@patchew.org; Sun, 28 Mar 2021 14:56:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaR4-0003Kg-KG for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaQz-0001RA-AE for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-387-cAgyI7cJPe64frGxtXR4sQ-1; Sun, 28 Mar 2021 14:46:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0C94107ACCA; Sun, 28 Mar 2021 18:46:44 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 587FC5D6A1; Sun, 28 Mar 2021 18:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957208; 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=epeJ9rthwp9IK9+kqXLc27V5qVbURYQ6Xk+tOUq5q/Y=; b=R+fWS5hlMjwdFvwl0y2pg4HtMlbxFSEwtmSSgoLVPQD1nA1aRWVH+g9vbkrPf1NL4qWgzo NFFBxb3+XXUPE3L848p1gd6cAjb3+/jjS5gxvriODndpcbnq1GRiQ7pjmLgkYAPBOfMl5T DVje0ynsbg/bgv4MJO8enUTWf8qmwh4= X-MC-Unique: cAgyI7cJPe64frGxtXR4sQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 08/10] chardev/char.c: Always pass id to chardev_new Date: Sun, 28 Mar 2021 22:45:31 +0400 Message-Id: <20210328184533.752840-9-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lukas Straub Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Lukas Straub Always pass the id to chardev_new, since it is needed to register the yank instance for the chardev. Also, after checking that nothing calls chardev_new with id=3DNULL, assert() that id!=3DNULL. This fixes a crash when using chardev-change to change a chardev to chardev-socket, which attempts to register a yank instance. This in turn tries to dereference the NULL-pointer. Signed-off-by: Lukas Straub Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: Li Zhang Message-Id: <3e669b6c160aa7278e37c4d95e0445574f96c7b7.1616794852.git.lukass= traub2@web.de> --- chardev/char.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 48f321b3e1..75993f903f 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -967,6 +967,7 @@ static Chardev *chardev_new(const char *id, const char = *typename, bool be_opened =3D true; =20 assert(g_str_has_prefix(typename, "chardev-")); + assert(id); =20 obj =3D object_new(typename); chr =3D CHARDEV(obj); @@ -1095,12 +1096,11 @@ ChardevReturn *qmp_chardev_change(const char *id, C= hardevBackend *backend, return NULL; } =20 - chr_new =3D chardev_new(NULL, object_class_get_name(OBJECT_CLASS(cc)), + chr_new =3D chardev_new(id, object_class_get_name(OBJECT_CLASS(cc)), backend, chr->gcontext, errp); if (!chr_new) { return NULL; } - chr_new->label =3D g_strdup(id); =20 if (chr->be_open && !chr_new->be_open) { qemu_chr_be_event(chr, CHR_EVENT_CLOSED); --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957627; cv=none; d=zohomail.com; s=zohoarc; b=hCkIKJToylIwkOZIhUrRGTFbkSxq/x7Rp1/Ls4TZTAtZs9G0QiVcD3SBZwXtXDEhb/KjYEp9nxg/QqJP895MNPgG7gzu83b2u8LeyKjHHpn3UP27y4W3hOqmIlRn+3pydxqPSJjNBvQripI8WTJjFQVc/MxKBdsIuNJicqSDAKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957627; 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=vOM2iWXHhvRxXFD+s8jzOonzAS/m1yiOhg26YdgeDBQ=; b=O2eBnW3c34E9Wy6eeFCxdbYNTI8PRaw2MzCyY6iK29SxZnHvuQw5FtKmxHmDCZUKxJEcBii96M7FmttQUx3Dylr02XoKIELTvxeoJ4cLypQq/1a+AUsnAa5vx4pQn09+NOtJqHBWN94BprNjEt5+vH1tt0Dyb6fCr4QWEnl4i10= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161695762747954.49270146768208; Sun, 28 Mar 2021 11:53:47 -0700 (PDT) Received: from localhost ([::1]:43626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaXi-0002lW-CA for importer@patchew.org; Sun, 28 Mar 2021 14:53:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaR7-0003OW-Gj for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaR5-0001Tv-Hg for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:46:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-wTVzD79kP9Odrm4rInuOcg-1; Sun, 28 Mar 2021 14:46:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AC70107ACCA; Sun, 28 Mar 2021 18:46:51 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A3905D6A1; Sun, 28 Mar 2021 18:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957214; 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=vOM2iWXHhvRxXFD+s8jzOonzAS/m1yiOhg26YdgeDBQ=; b=fSmSwIDMWopyk4st8TfzwIEDlB5UQa8xrEG5GaTf8XV7uIh6T0b4JX5VEcnNhbY2Ltz+Fn QYvlN/jYHzAoSPKDvygTaesBXinZwjqhAj8t/7V8Gr82T1+6qOWIoVGlDnTOhTOsxmxg/W ux+WRqbtKysCKAgXLvbF+7q9cL3a8gk= X-MC-Unique: wTVzD79kP9Odrm4rInuOcg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 09/10] chardev: Fix yank with the chardev-change case Date: Sun, 28 Mar 2021 22:45:32 +0400 Message-Id: <20210328184533.752840-10-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lukas Straub Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Lukas Straub When changing from chardev-socket (which supports yank) to chardev-socket again, it fails, because the new chardev attempts to register a new yank instance. This in turn fails, as there still is the yank instance from the current chardev. Also, the old chardev shouldn't unregister the yank instance when it is freed. To fix this, now the new chardev only registers a yank instance if the current chardev doesn't support yank and thus hasn't registered one already. Also, when the old chardev is freed, it now only unregisters the yank instance if the new chardev doesn't need it. If the initialization of the new chardev fails, it still has chr->handover_yank_instance set and won't unregister the yank instance when it is freed. s->registered_yank is always true here, as chardev-change only works on user-visible chardevs and those are guraranteed to register a yank instance as they are initialized via chardev_new() qemu_char_open() cc->open() (qmp_chardev_open_socket()). Signed-off-by: Lukas Straub Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: Li Zhang Message-Id: <9637888d7591d2971975188478bb707299a1dc04.1616794852.git.lukass= traub2@web.de> --- include/chardev/char.h | 3 +++ chardev/char-socket.c | 20 +++++++++++++++++--- chardev/char.c | 35 ++++++++++++++++++++++++++++------- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/include/chardev/char.h b/include/chardev/char.h index 4181a2784a..7c0444f90d 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -65,6 +65,8 @@ struct Chardev { char *filename; int logfd; int be_open; + /* used to coordinate the chardev-change special-case: */ + bool handover_yank_instance; GSource *gsource; GMainContext *gcontext; DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST); @@ -251,6 +253,7 @@ struct ChardevClass { ObjectClass parent_class; =20 bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */ + bool supports_yank; void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp); =20 void (*open)(Chardev *chr, ChardevBackend *backend, diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 1d455ecca4..daa89fe5d1 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1126,7 +1126,13 @@ static void char_socket_finalize(Object *obj) } g_free(s->tls_authz); if (s->registered_yank) { - yank_unregister_instance(CHARDEV_YANK_INSTANCE(chr->label)); + /* + * In the chardev-change special-case, we shouldn't unregister the= yank + * instance, as it still may be needed. + */ + if (!chr->handover_yank_instance) { + yank_unregister_instance(CHARDEV_YANK_INSTANCE(chr->label)); + } } =20 qemu_chr_be_event(chr, CHR_EVENT_CLOSED); @@ -1424,8 +1430,14 @@ static void qmp_chardev_open_socket(Chardev *chr, qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS); } =20 - if (!yank_register_instance(CHARDEV_YANK_INSTANCE(chr->label), errp)) { - return; + /* + * In the chardev-change special-case, we shouldn't register a new yank + * instance, as there already may be one. + */ + if (!chr->handover_yank_instance) { + if (!yank_register_instance(CHARDEV_YANK_INSTANCE(chr->label), err= p)) { + return; + } } s->registered_yank =3D true; =20 @@ -1567,6 +1579,8 @@ static void char_socket_class_init(ObjectClass *oc, v= oid *data) { ChardevClass *cc =3D CHARDEV_CLASS(oc); =20 + cc->supports_yank =3D true; + cc->parse =3D qemu_chr_parse_socket; cc->open =3D qmp_chardev_open_socket; cc->chr_wait_connected =3D tcp_chr_wait_connected; diff --git a/chardev/char.c b/chardev/char.c index 75993f903f..398f09df19 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -39,6 +39,7 @@ #include "qemu/option.h" #include "qemu/id.h" #include "qemu/coroutine.h" +#include "qemu/yank.h" =20 #include "chardev-internal.h" =20 @@ -266,6 +267,7 @@ static void char_init(Object *obj) { Chardev *chr =3D CHARDEV(obj); =20 + chr->handover_yank_instance =3D false; chr->logfd =3D -1; qemu_mutex_init(&chr->chr_write_lock); =20 @@ -959,6 +961,7 @@ void qemu_chr_set_feature(Chardev *chr, static Chardev *chardev_new(const char *id, const char *typename, ChardevBackend *backend, GMainContext *gcontext, + bool handover_yank_instance, Error **errp) { Object *obj; @@ -971,6 +974,7 @@ static Chardev *chardev_new(const char *id, const char = *typename, =20 obj =3D object_new(typename); chr =3D CHARDEV(obj); + chr->handover_yank_instance =3D handover_yank_instance; chr->label =3D g_strdup(id); chr->gcontext =3D gcontext; =20 @@ -1004,7 +1008,7 @@ Chardev *qemu_chardev_new(const char *id, const char = *typename, id =3D genid; } =20 - chr =3D chardev_new(id, typename, backend, gcontext, errp); + chr =3D chardev_new(id, typename, backend, gcontext, false, errp); if (!chr) { return NULL; } @@ -1032,7 +1036,7 @@ ChardevReturn *qmp_chardev_add(const char *id, Charde= vBackend *backend, } =20 chr =3D chardev_new(id, object_class_get_name(OBJECT_CLASS(cc)), - backend, NULL, errp); + backend, NULL, false, errp); if (!chr) { return NULL; } @@ -1057,9 +1061,10 @@ ChardevReturn *qmp_chardev_change(const char *id, Ch= ardevBackend *backend, Error **errp) { CharBackend *be; - const ChardevClass *cc; + const ChardevClass *cc, *cc_new; Chardev *chr, *chr_new; bool closed_sent =3D false; + bool handover_yank_instance; ChardevReturn *ret; =20 chr =3D qemu_chr_find(id); @@ -1091,13 +1096,20 @@ ChardevReturn *qmp_chardev_change(const char *id, C= hardevBackend *backend, return NULL; } =20 - cc =3D char_get_class(ChardevBackendKind_str(backend->type), errp); - if (!cc) { + cc =3D CHARDEV_GET_CLASS(chr); + cc_new =3D char_get_class(ChardevBackendKind_str(backend->type), errp); + if (!cc_new) { return NULL; } =20 - chr_new =3D chardev_new(id, object_class_get_name(OBJECT_CLASS(cc)), - backend, chr->gcontext, errp); + /* + * The new chardev should not register a yank instance if the current + * chardev has registered one already. + */ + handover_yank_instance =3D cc->supports_yank && cc_new->supports_yank; + + chr_new =3D chardev_new(id, object_class_get_name(OBJECT_CLASS(cc_new)= ), + backend, chr->gcontext, handover_yank_instance, = errp); if (!chr_new) { return NULL; } @@ -1121,6 +1133,15 @@ ChardevReturn *qmp_chardev_change(const char *id, Ch= ardevBackend *backend, return NULL; } =20 + /* change successfull, clean up */ + chr_new->handover_yank_instance =3D false; + + /* + * When the old chardev is freed, it should not unregister the yank + * instance if the new chardev needs it. + */ + chr->handover_yank_instance =3D handover_yank_instance; + object_unparent(OBJECT(chr)); object_property_add_child(get_chardevs_root(), chr_new->label, OBJECT(chr_new)); --=20 2.29.0 From nobody Sat Apr 27 09:29:30 2024 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=1616957783; cv=none; d=zohomail.com; s=zohoarc; b=FPtMZb7TG78MvslUSQXV2VO0fOrZgpJHhidDWjrhjWdjJXL109FN6GbrLqv12COKP0bVbi81psIX19OXOwPim1UGrTmIVlnOHFElQZYm4fSyNBvncOYU3MEPMWKHQ/wOCmrJSOXQnHuCYQ2JuFtWxUszkJS6T7+/aWxKX6RmznQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616957783; 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=pckDNNN5vJXs1qB1WPSj1cWohtFLfGRTEovAVaeE5rk=; b=RCC+9fMYbNrDCzSt0GATR6kBkEKq9QBbaP7rbuB4QjVXO8pDuQYelWihDxmlDTItn3PVD0thW0oJnhJmxtsURgX0K3s5PBlQPgCFlaRqg5AViDwzV9EmOSsL7vYie5gT7ZUR4tHX7eulhC6gruGozD7UBIjL5DTr9ve8FeGHshw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616957783833614.0246697317517; Sun, 28 Mar 2021 11:56:23 -0700 (PDT) Received: from localhost ([::1]:51362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQaaE-00064v-MN for importer@patchew.org; Sun, 28 Mar 2021 14:56:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaRK-0003Py-Nz for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:47:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQaRG-0001Wx-AQ for qemu-devel@nongnu.org; Sun, 28 Mar 2021 14:47:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-vzCBvVbJOTOFg8w8OiVhBw-1; Sun, 28 Mar 2021 14:46:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27CF3802B5B; Sun, 28 Mar 2021 18:46:58 +0000 (UTC) Received: from localhost (unknown [10.36.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 512A960853; Sun, 28 Mar 2021 18:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616957222; 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=pckDNNN5vJXs1qB1WPSj1cWohtFLfGRTEovAVaeE5rk=; b=cOaDBrHukRWXT0Mj4uF+BIPVHjLzkeCBg917LZ1EYiv4H4ynFgp1rBLZWi5HJFbOM5aVE3 ai34Qs5MYPjrHDEA7msZ6fGhPEXEJDbTE09a4EOYC6G7/eAP+aO5oewAQaBPC3irI4JTAk 4Kvkuy1gVXbGo2ySrJd3TCM5chMZfzk= X-MC-Unique: vzCBvVbJOTOFg8w8OiVhBw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 10/10] tests: Add tests for yank with the chardev-change case Date: Sun, 28 Mar 2021 22:45:33 +0400 Message-Id: <20210328184533.752840-11-marcandre.lureau@redhat.com> In-Reply-To: <20210328184533.752840-1-marcandre.lureau@redhat.com> References: <20210328184533.752840-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lukas Straub Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Lukas Straub Add tests for yank with the chardev-change case. Signed-off-by: Lukas Straub Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: Li Zhang Message-Id: <7c2f1ddcaa1c97462cb0b834d5aa7368283aa67d.1616794852.git.lukass= traub2@web.de> --- tests/unit/test-yank.c | 200 +++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + tests/unit/meson.build | 3 +- 3 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 tests/unit/test-yank.c diff --git a/tests/unit/test-yank.c b/tests/unit/test-yank.c new file mode 100644 index 0000000000..1596a3b98e --- /dev/null +++ b/tests/unit/test-yank.c @@ -0,0 +1,200 @@ +/* + * Tests for QEMU yank feature + * + * Copyright (c) Lukas Straub + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include + +#include "qemu/config-file.h" +#include "qemu/module.h" +#include "qemu/option.h" +#include "chardev/char-fe.h" +#include "sysemu/sysemu.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-char.h" +#include "qapi/qapi-types-char.h" +#include "qapi/qapi-commands-yank.h" +#include "qapi/qapi-types-yank.h" +#include "io/channel-socket.h" +#include "socket-helpers.h" + +typedef struct { + SocketAddress *addr; + bool old_yank; + bool new_yank; + bool fail; +} CharChangeTestConfig; + +static int chardev_change(void *opaque) +{ + return 0; +} + +static bool is_yank_instance_registered(void) +{ + YankInstanceList *list; + bool ret; + + list =3D qmp_query_yank(&error_abort); + + ret =3D !!list; + + qapi_free_YankInstanceList(list); + + return ret; +} + +static void char_change_test(gconstpointer opaque) +{ + CharChangeTestConfig *conf =3D (gpointer) opaque; + SocketAddress *addr; + Chardev *chr; + CharBackend be; + ChardevReturn *ret; + QIOChannelSocket *ioc; + + /* + * Setup a listener socket and determine its address + * so we know the TCP port for the client later + */ + ioc =3D qio_channel_socket_new(); + g_assert_nonnull(ioc); + qio_channel_socket_listen_sync(ioc, conf->addr, 1, &error_abort); + addr =3D qio_channel_socket_get_local_address(ioc, &error_abort); + g_assert_nonnull(addr); + + ChardevBackend backend[2] =3D { + /* doesn't support yank */ + { .type =3D CHARDEV_BACKEND_KIND_NULL }, + /* supports yank */ + { + .type =3D CHARDEV_BACKEND_KIND_SOCKET, + .u.socket.data =3D &(ChardevSocket) { + .addr =3D &(SocketAddressLegacy) { + .type =3D SOCKET_ADDRESS_LEGACY_KIND_INET, + .u.inet.data =3D &addr->u.inet + }, + .has_server =3D true, + .server =3D false + } + } }; + + ChardevBackend fail_backend[2] =3D { + /* doesn't support yank */ + { + .type =3D CHARDEV_BACKEND_KIND_UDP, + .u.udp.data =3D &(ChardevUdp) { + .remote =3D &(SocketAddressLegacy) { + .type =3D SOCKET_ADDRESS_LEGACY_KIND_UNIX, + .u.q_unix.data =3D &(UnixSocketAddress) { + .path =3D (char *)"" + } + } + } + }, + /* supports yank */ + { + .type =3D CHARDEV_BACKEND_KIND_SOCKET, + .u.socket.data =3D &(ChardevSocket) { + .addr =3D &(SocketAddressLegacy) { + .type =3D SOCKET_ADDRESS_LEGACY_KIND_INET, + .u.inet.data =3D &(InetSocketAddress) { + .host =3D (char *)"127.0.0.1", + .port =3D (char *)"0" + } + }, + .has_server =3D true, + .server =3D false + } + } }; + + g_assert(!is_yank_instance_registered()); + + ret =3D qmp_chardev_add("chardev", &backend[conf->old_yank], &error_ab= ort); + qapi_free_ChardevReturn(ret); + chr =3D qemu_chr_find("chardev"); + g_assert_nonnull(chr); + + g_assert(is_yank_instance_registered() =3D=3D conf->old_yank); + + qemu_chr_wait_connected(chr, &error_abort); + qemu_chr_fe_init(&be, chr, &error_abort); + /* allow chardev-change */ + qemu_chr_fe_set_handlers(&be, NULL, NULL, + NULL, chardev_change, NULL, NULL, true); + + if (conf->fail) { + g_setenv("QTEST_SILENT_ERRORS", "1", 1); + ret =3D qmp_chardev_change("chardev", &fail_backend[conf->new_yank= ], + NULL); + g_assert_null(ret); + g_assert(be.chr =3D=3D chr); + g_assert(is_yank_instance_registered() =3D=3D conf->old_yank); + g_unsetenv("QTEST_SILENT_ERRORS"); + } else { + ret =3D qmp_chardev_change("chardev", &backend[conf->new_yank], + &error_abort); + g_assert_nonnull(ret); + g_assert(be.chr !=3D chr); + g_assert(is_yank_instance_registered() =3D=3D conf->new_yank); + } + + object_unparent(OBJECT(be.chr)); + object_unref(OBJECT(ioc)); + qapi_free_ChardevReturn(ret); + qapi_free_SocketAddress(addr); +} + +static SocketAddress tcpaddr =3D { + .type =3D SOCKET_ADDRESS_TYPE_INET, + .u.inet.host =3D (char *)"127.0.0.1", + .u.inet.port =3D (char *)"0", +}; + +int main(int argc, char **argv) +{ + bool has_ipv4, has_ipv6; + + qemu_init_main_loop(&error_abort); + socket_init(); + + g_test_init(&argc, &argv, NULL); + + if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) { + g_printerr("socket_check_protocol_support() failed\n"); + goto end; + } + + if (!has_ipv4) { + goto end; + } + + module_call_init(MODULE_INIT_QOM); + qemu_add_opts(&qemu_chardev_opts); + +#define CHAR_CHANGE_TEST(name, _old_yank, _new_yank) = \ + g_test_add_data_func("/yank/char_change/success/" # name, = \ + &(CharChangeTestConfig) { .addr =3D &tcpaddr,= \ + .old_yank =3D (_old= _yank),\ + .new_yank =3D (_new= _yank),\ + .fail =3D false }, = \ + char_change_test); = \ + g_test_add_data_func("/yank/char_change/fail/" # name, = \ + &(CharChangeTestConfig) { .addr =3D &tcpaddr,= \ + .old_yank =3D (_old= _yank),\ + .new_yank =3D (_new= _yank),\ + .fail =3D true }, = \ + char_change_test); + + CHAR_CHANGE_TEST(to_yank, false, true); + CHAR_CHANGE_TEST(yank_to_yank, true, true); + CHAR_CHANGE_TEST(from_yank, true, false); + +end: + return g_test_run(); +} diff --git a/MAINTAINERS b/MAINTAINERS index dcab656e62..aa894767dc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2823,6 +2823,7 @@ M: Lukas Straub S: Odd fixes F: util/yank.c F: migration/yank_functions* +F: tests/unit/test-yank.c F: include/qemu/yank.h F: qapi/yank.json =20 diff --git a/tests/unit/meson.build b/tests/unit/meson.build index 4bfe4627ba..b3bc2109da 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -123,7 +123,8 @@ if have_system 'test-util-sockets': ['socket-helpers.c'], 'test-base64': [], 'test-bufferiszero': [], - 'test-vmstate': [migration, io] + 'test-vmstate': [migration, io], + 'test-yank': ['socket-helpers.c', qom, io, chardev] } if 'CONFIG_INOTIFY1' in config_host tests +=3D {'test-util-filemonitor': []} --=20 2.29.0