From nobody Sun Apr 28 23:56:51 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=1617278242; cv=none; d=zohomail.com; s=zohoarc; b=KCV0u1MpckNGbBCq499yzPidiNVG4Ihi41fi4qKi+UtFdlN45Ga3RU5LrGi8JZWpzsZimiV4Z2PClFA56rs0myRgemj1s+BVrrTyWZ9Bp4Htf1l42vWWtkWaQwJXS7M4x5SN9CH2iWIV1Wxgf6zQkqWxtAhNO6vH6Ocex8OYv3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278242; 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=MI7RMcqT4+pUAOeGKJAUr/kj0vfNR4JFnq1Xa4b1yxRNn69nxG/ZJEt/abA+B/EmvSLyw/EnJ2TITsKxxky2Bkhwo27Vg/Njcsg/6SfX7cUVq00GHmOeY6BbUgd0pAbK+YkNg7tgvW1V1NDwPecPYZ/svBnBU+nGFjGMi67jDSE= 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 1617278242816963.869671727382; Thu, 1 Apr 2021 04:57:22 -0700 (PDT) Received: from localhost ([::1]:47268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRvwv-00061F-OJ for importer@patchew.org; Thu, 01 Apr 2021 07:57:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvY-0004SO-Rn for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:55:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvW-00020V-Vu for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:55:56 -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-126-M6PwA7adP1eFSaPYoBTaEA-1; Thu, 01 Apr 2021 07:55:51 -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 90F83801814; Thu, 1 Apr 2021 11:55:50 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47BB21ACBA; Thu, 1 Apr 2021 11:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278153; 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=X4lBrp+bhYUvOQ4ZxNV/YSVvHPs9qWohHq0my3IpWV+ggiMq3sOe644UeJ44/JJSWsaChn N19G70CgEFA2u4xtmkWj4QeFN50Fmw863WTCnOMuNN4U053SSLmI4m29JgEAdZH1q7WCnz yjTdR/XdVL3hmGd4wBEvXgdZiEdraLE= X-MC-Unique: M6PwA7adP1eFSaPYoBTaEA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 1/9] util: fix use-after-free in module_load_one Date: Thu, 1 Apr 2021 15:55:24 +0400 Message-Id: <20210401115532.430961-2-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-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=170.10.133.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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 Sun Apr 28 23:56:51 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=1617278249; cv=none; d=zohomail.com; s=zohoarc; b=ZNVCeSQtHPGvno5JkdRhh4afPOMKVOSynRm0vGBarLUesJTmi4GHysOca87WGfFYi7VweY4UUUlBrWQA18OA0dtPXI4PMO/ZSRFfv57bhtSd88H9ew8eMmonHXlrvDXYIurmJlabCArmX/heUXk+xwzUR3xp6zewAeDr5c9r4Bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278249; 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=afoq7XMnlTFG0Dcsxs7Yf7PI2/uP8MAMP9zm+w3hcV3Au3lt0f24BufPeEfAUTdtTiBjfHkwF18T2dko4GzNbC+QUmAVBeloYTuva8XM5P8SdBV6TTDSyH/PIjeWnOBZtiwR3vZZxBKsXHnqAYgFh0pfK1CXo+SHBinEqKOr5Dw= 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 1617278249351745.5626227978704; Thu, 1 Apr 2021 04:57:29 -0700 (PDT) Received: from localhost ([::1]:47826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRvx1-0006ES-4i for importer@patchew.org; Thu, 01 Apr 2021 07:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvl-0004Y4-I2 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvh-00029K-I6 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:09 -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-266-TJeeYN0YO223YdbYHEbXpQ-1; Thu, 01 Apr 2021 07:55:56 -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 DAE158030A1; Thu, 1 Apr 2021 11:55:55 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id A431960CCD; Thu, 1 Apr 2021 11:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278164; 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=Y7ptTN2+J2HPRdrfkw8BaT70nL06wXdS5edJKPqsZaO949c59GAyQP83YCvZmoyDXPj4LJ mKnFmrMEMoCoVxECMbjqAqSCvhm7jMXR2wAKmvpXyO4xpud8dc0YgAcyJGtRV4Rj8ZnZTT XiiQzBKFIg5wAxE96jdPgn0066o4mmU= X-MC-Unique: TJeeYN0YO223YdbYHEbXpQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 2/9] dbus-vmstate: Increase the size of input stream buffer used during load Date: Thu, 1 Apr 2021 15:55:25 +0400 Message-Id: <20210401115532.430961-3-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-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=170.10.133.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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Sun Apr 28 23:56:51 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=1617278249; cv=none; d=zohomail.com; s=zohoarc; b=BY/mXhvuGxFEz7B/ay1V//OJE3rixdZ3bTthKUrEhQVaVxlM2czGOiyTqmN3rGYOh/p3jXTIbTjMBYHtD1CDZlNgNllYlKj9TV4HBFGcngXgaEnIut7uLErjpBkKfANx/RSpEULEhykqNoFEiVl46xpjy4hfzUGi/Ool8wSKohA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278249; 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=QscEFl50esVC5/FR1Z9f+bcTBUpbt/KM1vHgxzSymVGkaseJ4aoHvjJLSUPwoIJ+riHO4bmKoGXXnxzC9PyXKDCBCBKOGpY5P5ZsZiU5Psds+Tw+hjfNjYwmMA1B9qOUxYfNFdc+7/BagKJzxIcHR1/f0QjyeSS8RQ/fSDtQiik= 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 1617278249685165.33709117568503; Thu, 1 Apr 2021 04:57:29 -0700 (PDT) Received: from localhost ([::1]:47882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRvx1-0006Fu-KQ for importer@patchew.org; Thu, 01 Apr 2021 07:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvm-0004Zi-HL for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvk-0002DD-M1 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56: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-473-Wl_0vfBGMnW-uAiK4-BbCw-1; Thu, 01 Apr 2021 07:56:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2593108BD07; Thu, 1 Apr 2021 11:56:04 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4089F5C1BB; Thu, 1 Apr 2021 11:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278167; 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=QCat26IbQwUHxHnU0hYLfRqarDi5MCiUoo9iHEV/qpxaeieoyoTa/n+KxpWIXAMTwbJzKx MW+syeLxWUMBH1a90vkfpNvdEzZbPVUK8F1/6fYaXh8XOaGgk+YmLvF92hJaR/D/LA74I1 Xz5a5NcPiEIkcBRp0QHfXvI4iIW1NIg= X-MC-Unique: Wl_0vfBGMnW-uAiK4-BbCw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 3/9] docs: simplify each section title Date: Thu, 1 Apr 2021 15:55:26 +0400 Message-Id: <20210401115532.430961-4-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Sun Apr 28 23:56:51 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=1617278362; cv=none; d=zohomail.com; s=zohoarc; b=aeZtjHlRrHgQLVMxKeobMSpV7InQBRN8DeWgYgjvrvIkYbAjWqSjHpgOJoDDmMvJBbQ04eO3kAFekWV5xhbIwtSdiOD18cNUwU9JYfublQveErRr9S2dIK5bJuAj6wO2Wo5YpWDJLy7vvP9ANauqHlMkQGREKvkw+t7VtOSin0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278362; 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=auGRD61R/ohTlFsyk3nI41talSGTckLsYpHvhaFxzTkOYPCEd3Xmw7khcKBUy/Ms0s9EcbpWlunK2WhHl5Tbn7dTN1c/KLtNSJFrvjQMj+Wz0RwAIA+pfCCqxYFQg+tIt7wtyQLA3KcDInnrzekGwn6tdLhq6SobLqOWQuMcTzc= 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 1617278362547264.6972819036422; Thu, 1 Apr 2021 04:59:22 -0700 (PDT) Received: from localhost ([::1]:56440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRvyr-0001MP-E8 for importer@patchew.org; Thu, 01 Apr 2021 07:59:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvs-0004pY-Ru for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvq-0002ID-Fv for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:16 -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-136-qYeCR77OP5-Oe65Xs9hZKw-1; Thu, 01 Apr 2021 07:56:12 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0FC96101962B; Thu, 1 Apr 2021 11:56:11 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id B476319C44; Thu, 1 Apr 2021 11:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278173; 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=fqnjWfoUbjuzX1BmH3ssbzDrjQW+TTNXTa/NdbdJ/NQXo3F5+5dJaShl6BGaoAQ7VAxWqP 3Qk+qDH2xav3fjLRRn8PWZIersfWBrHAq3Vf3ueWatneU/Q66S/DNj0+pexD4a2jw2WosI a/7SUf6q8VRcbGYFJ9o3c0j6S8/2ptk= X-MC-Unique: qYeCR77OP5-Oe65Xs9hZKw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 4/9] yank: Remove dependency on qiochannel Date: Thu, 1 Apr 2021 15:55:27 +0400 Message-Id: <20210401115532.430961-5-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=170.10.133.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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Sun Apr 28 23:56:51 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=1617278360; cv=none; d=zohomail.com; s=zohoarc; b=TJyMYHNsyUY9nKJgigHRgkzkpkWhOf0+J3VBtvQb3qtSsgf+ZOmgVas4zS2OBaTMxaI1Zs9viLJOcR8d1pEf70iY3F4ItB2winaOXzNXzuAl1fQGz/Yr4rNlPpbiUKZ8uTt96ptgab23Vm9nSBfmX2FWk7I0ImhppIlaonxedZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278360; 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=cJTX47xDa/1Hy5D+HwEtvY7CmaaHAEOLAR/Osz9QVVuEiDJTzMEtt9Ty79iEdALV5dJrSY2LQhhpKKNtHMFrouEewIQx3MZammbtLm8kOKgfbQWFqVWGbXI2JUkpdZJDwHMbokTRbUMLigtye5zEnVha/zNTTr8wzxPr91LkEis= 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 1617278360616419.52696102734797; Thu, 1 Apr 2021 04:59:20 -0700 (PDT) Received: from localhost ([::1]:56340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRvyp-0001Jz-IR for importer@patchew.org; Thu, 01 Apr 2021 07:59:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvz-00055F-4b for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvvx-0002NC-Dl for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:22 -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-477-HoFXnfx_PWy6pneYvOqUuQ-1; Thu, 01 Apr 2021 07:56:16 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEC72108BD06; Thu, 1 Apr 2021 11:56:15 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id CED1F19C44; Thu, 1 Apr 2021 11:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278180; 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=D+16IobT+4kJwfOgTPBCbVVF8X01Y3zc+ye7NFDP9tokfwW6LizwkrDJN3ne7e5b8XrpAD SGFWFqsMukZUcRcZjcYid5CK0blMFu4zHHffZl0PcUciwfD1OCwXcuU99DZv6UyIjc7438 VxuIJVUCMkX3esoaiKcqJSMnTYYY308= X-MC-Unique: HoFXnfx_PWy6pneYvOqUuQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 5/9] yank: Always link full yank code Date: Thu, 1 Apr 2021 15:55:28 +0400 Message-Id: <20210401115532.430961-6-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Sun Apr 28 23:56:51 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=1617278519; cv=none; d=zohomail.com; s=zohoarc; b=DZjTeEEq84Np3WdYpfmvny+TA/D5DDTp4E6z4Bn5jYASGwKOSiwWRfMttXxynG9HCzQiBB97uNv91RK8Lqxoej6w4QZ2XkImUrbqnfL6iHbfOD5CMUWiXG6M1ZxIRVY8U+Hew6vJSH9lLURYeOZepyAD+6R0I78foL0QoFbPZJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278519; 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=IdHMm3QbJd3MAySeBn092KAn+e3GFVk6ESm00Gw2ms8=; b=e1IUYzE4gl+zRqsn7faqaeWfi+kCoA8f3gqm4yF43pWDoisvQodGFSF5djQ1sYnYnCFkobCr0nlu3PI9XkpYUkbEk2g1YIMRoiq6ot8zPGHAGvAw3u5ROEZfRcynECNSwyKJmAsVDH4Y3VAf7nq+szC0F+MFn4lkCZQxKY3lsWk= 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 1617278519012383.7166074771486; Thu, 1 Apr 2021 05:01:59 -0700 (PDT) Received: from localhost ([::1]:34662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRw1M-0004Fa-P1 for importer@patchew.org; Thu, 01 Apr 2021 08:01:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvw6-0005F4-0F for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvw1-0002QL-K5 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:29 -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-455-llkpIjmwPeConPQH3z5v5w-1; Thu, 01 Apr 2021 07:56:22 -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 78DA91853026; Thu, 1 Apr 2021 11:56:21 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38C9B608DB; Thu, 1 Apr 2021 11:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278185; 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=IdHMm3QbJd3MAySeBn092KAn+e3GFVk6ESm00Gw2ms8=; b=Nrl638U52DkW/PxHCh6hWdX9bLdjO5174y2NONLIe+mzuEhq92Sgy1/6tLifGv+s3WmIkL 0D1kNwR27lLqdU1TXrPMd0DjD8UOHMzESPopSKpa1r7np8qQYPNQXF4osWxiW1V6hVK30i Rm/J4ZaEHR3ARDvTklVPup1fEhgHxD8= X-MC-Unique: llkpIjmwPeConPQH3z5v5w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 6/9] chardev/char.c: Move object_property_try_add_child out of chardev_new Date: Thu, 1 Apr 2021 15:55:29 +0400 Message-Id: <20210401115532.430961-7-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Sun Apr 28 23:56:51 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=1617278521; cv=none; d=zohomail.com; s=zohoarc; b=dEowL/Z8hJg84bSdYi5AgtYELkNor2uKCkUeBD3CUuC8AHzNkEUHwfVLt833NS8Mx20jidwEBve0vce4LM8LbHPzdeTcKA3oOrE87Rt8Ft3NyrFIRpwCYbXX+WLfnz0vKumB2VYAtNjSFMHFcx5YphAjhHPqr49BOEmcrjF+Mh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278521; 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=QpBwc4N9AO7sZNRqHpJv8uCgZkugyse87WKBzp3WcA4=; b=dC+gT73XyVFop1uwoq+dzHWIvzkvHbeXeMop6oAlPGn3Rm+09Q4ptdONHKeQp84FR7lxpui+DIDJtCl72LVc/HP3m8lM+japyjB87Veqv5mwN5hBor0A/+3QS+Czig9NIB81BcfcMHgE46gWswLI5y9TDzcutAfTMnIvCTO0bIY= 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 1617278520720574.4843491134478; Thu, 1 Apr 2021 05:02:00 -0700 (PDT) Received: from localhost ([::1]:34770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRw1O-0004IB-4S for importer@patchew.org; Thu, 01 Apr 2021 08:01:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvw8-0005Gz-6b for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvw5-0002Qi-W3 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:31 -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-289-MF53vEInPeCEVdS2IhEdiA-1; Thu, 01 Apr 2021 07:56:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48AAB7FE80; Thu, 1 Apr 2021 11:56:26 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40C7E5C238; Thu, 1 Apr 2021 11:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278189; 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=QpBwc4N9AO7sZNRqHpJv8uCgZkugyse87WKBzp3WcA4=; b=CIDiuDg3afas026HLY8YrjhcC9ZaFzP6uk2GotSK4UsBYVqVWQgePFY/aEeQyhFumfLVeu BA/gRgOdN5K8qzmQ3+I9Krqfl/2kn3ogBCd3szxgCQoGOneXsb2xTE/QQB11Z/+qQP9j1m Sss3kRuC2RsLzz1fz2GhUGGa7kUCyMA= X-MC-Unique: MF53vEInPeCEVdS2IhEdiA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 7/9] chardev/char.c: Always pass id to chardev_new Date: Thu, 1 Apr 2021 15:55:30 +0400 Message-Id: <20210401115532.430961-8-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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.1617127849.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 Sun Apr 28 23:56:51 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=1617278355; cv=none; d=zohomail.com; s=zohoarc; b=HB2776l886vYMPWriSwJ/TEmWTjvdJUL8cZuGc+nrX216n48v2IctmXokLqTJpECZGYbY/ZjM3GytgTT9pog0RrMfCbNYhzccLaCVeCpN7rk/dOr0UyzTxRs1U32tTKqgHsn5k67SU1x0ZP3iC07GPl1Tt6JzABgHnUlrG2t8g4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278355; 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=oMva8pidwhrff2eP7M4aCTOHQrwFVRDH+Y9qYHtBtrg=; b=VI5jMRgOLOVxQDZQE9vK/G40Jq0fukpu0EQCY7bqL5sFnBvdQh8qCvUiYfL7+3A03yuWR2Ijd5ywBN58wJU5jwaX2DsKvl5htQ4jPAptYUTVPRSxWWOqKHPDM3DAIO4gWebytHCTaYkiCPB+VXHPfJprSh9bdNNpuVQnrTvtUow= 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 16172783553471005.7365689293052; Thu, 1 Apr 2021 04:59:15 -0700 (PDT) Received: from localhost ([::1]:55744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRvyk-00015P-Ae for importer@patchew.org; Thu, 01 Apr 2021 07:59:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvwK-0005OY-57 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37147) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvwH-0002WY-P2 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:43 -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-pzM_-SxAP4yDi2g4qlhJoA-1; Thu, 01 Apr 2021 07:56:33 -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 E82E21853021; Thu, 1 Apr 2021 11:56:32 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7545451C3F; Thu, 1 Apr 2021 11:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278200; 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=oMva8pidwhrff2eP7M4aCTOHQrwFVRDH+Y9qYHtBtrg=; b=gTgkT2uC/NGme0+z8zQPzAJMVmJj06pAwFi6XELWVp67TfVAx7l6ZkwKjT0+9keFd3TUA3 /aZ4Em5FPXA2CpTgwyk0egHJscVLDcf7LDWq9JhTsMagDXg9yaV81lpz8pFkcZD5qew+Bj JPaByLyswg0+r36CDlnBWbwI/fCSDAM= X-MC-Unique: pzM_-SxAP4yDi2g4qlhJoA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 8/9] chardev: Fix yank with the chardev-change case Date: Thu, 1 Apr 2021 15:55:31 +0400 Message-Id: <20210401115532.430961-9-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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.1617127849.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 Sun Apr 28 23:56:51 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=1617278357; cv=none; d=zohomail.com; s=zohoarc; b=ELxX4NflGd3LKzcoe4mXUdBKN53XzMeLZuEQghVoneXQoagS3CbSauBNuN8Fzb0tmP7HYB4DNM5sAX9gQcAMQbhBlLtI4JFmgBaqiQTh5ubOkmr9SWaNvViE7lPzAlgEqXUKWP/kcxmKysV/igTN7sXpqFB+f7VhDfpeOZY9FWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617278357; 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=uhfSmRhns+ivA4uVzbLsfC95kF/YsbwJNKXaDqCxNxk=; b=OJR8S39EzEmIOCfuwNKphTtUpzEh1xg6KUMObA8+pcJdxz5N3uhYh7w694R5ohEgFNN/Qq1409I8puSY9QU5H7nU3q0H5ZFF90+M3m5obADHzKC1TDXYK29879KcHP9yqnj31+aOSlTuvnCrvchYROiMdP2mxj2+TxA4trisw7s= 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 1617278357707220.9722568802656; Thu, 1 Apr 2021 04:59:17 -0700 (PDT) Received: from localhost ([::1]:55962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRvym-0001Ad-K0 for importer@patchew.org; Thu, 01 Apr 2021 07:59:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvwM-0005UF-7E for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRvwK-0002Xv-13 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 07:56:45 -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-202-VQ06xojbP7iXK00yn6aIAw-1; Thu, 01 Apr 2021 07:56:39 -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 92564801597; Thu, 1 Apr 2021 11:56:38 +0000 (UTC) Received: from localhost (unknown [10.36.110.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id F33605D72F; Thu, 1 Apr 2021 11:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617278203; 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=uhfSmRhns+ivA4uVzbLsfC95kF/YsbwJNKXaDqCxNxk=; b=X6gN3tObm0C7Y3y7lDKyPjmdSB6BGZwauS1Qsh1tk4k59O80JaFpM/WxYfQLt9+kLWSEvL mqoQhr0a+BCxMTV/QPq7Nc7AAld33tYAjw0Q5rprrlAkR/9pnpN4HDgVWsi1Mgce/f7HJy KDcopSWE9n6Du97qymhBMtq6hsTZIlk= X-MC-Unique: VQ06xojbP7iXK00yn6aIAw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 9/9] tests: Add tests for yank with the chardev-change case Date: Thu, 1 Apr 2021 15:55:32 +0400 Message-Id: <20210401115532.430961-10-marcandre.lureau@redhat.com> In-Reply-To: <20210401115532.430961-1-marcandre.lureau@redhat.com> References: <20210401115532.430961-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=170.10.133.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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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: <697ce111503a8bab011d21519ae0b6b07041ec9a.1617127849.git.lukass= traub2@web.de> --- tests/unit/test-yank.c | 249 +++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + tests/unit/meson.build | 3 +- 3 files changed, 252 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..2383d2908c --- /dev/null +++ b/tests/unit/test-yank.c @@ -0,0 +1,249 @@ +/* + * 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 gpointer accept_thread(gpointer data) +{ + QIOChannelSocket *ioc =3D data; + QIOChannelSocket *cioc; + + cioc =3D qio_channel_socket_accept(ioc, &error_abort); + object_unref(OBJECT(cioc)); + + return NULL; +} + +static void char_change_test(gconstpointer opaque) +{ + CharChangeTestConfig *conf =3D (gpointer) opaque; + SocketAddress *addr; + Chardev *chr; + CharBackend be; + ChardevReturn *ret; + QIOChannelSocket *ioc; + QemuThread thread; + + /* + * 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()); + + if (conf->old_yank) { + qemu_thread_create(&thread, "accept", accept_thread, + ioc, QEMU_THREAD_JOINABLE); + } + + 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); + if (conf->old_yank) { + qemu_thread_join(&thread); + } + + 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 { + if (conf->new_yank) { + qemu_thread_create(&thread, "accept", accept_thread, + ioc, QEMU_THREAD_JOINABLE); + } + ret =3D qmp_chardev_change("chardev", &backend[conf->new_yank], + &error_abort); + if (conf->new_yank) { + qemu_thread_join(&thread); + } + 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); + + g_test_add_data_func("/yank/char_change/success/to_yank", + &(CharChangeTestConfig) { .addr =3D &tcpaddr, + .old_yank =3D false, + .new_yank =3D true, + .fail =3D false }, + char_change_test); + g_test_add_data_func("/yank/char_change/fail/to_yank", + &(CharChangeTestConfig) { .addr =3D &tcpaddr, + .old_yank =3D false, + .new_yank =3D true, + .fail =3D true }, + char_change_test); + + g_test_add_data_func("/yank/char_change/success/yank_to_yank", + &(CharChangeTestConfig) { .addr =3D &tcpaddr, + .old_yank =3D true, + .new_yank =3D true, + .fail =3D false }, + char_change_test); + g_test_add_data_func("/yank/char_change/fail/yank_to_yank", + &(CharChangeTestConfig) { .addr =3D &tcpaddr, + .old_yank =3D true, + .new_yank =3D true, + .fail =3D true }, + char_change_test); + + g_test_add_data_func("/yank/char_change/success/from_yank", + &(CharChangeTestConfig) { .addr =3D &tcpaddr, + .old_yank =3D true, + .new_yank =3D false, + .fail =3D false }, + char_change_test); + g_test_add_data_func("/yank/char_change/fail/from_yank", + &(CharChangeTestConfig) { .addr =3D &tcpaddr, + .old_yank =3D true, + .new_yank =3D false, + .fail =3D true }, + char_change_test); + +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