From nobody Sun May 12 00:19:47 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=1623250004; cv=none; d=zohomail.com; s=zohoarc; b=bTwU7T4f9m0oOIKc5bo8Oy0LDKd0TsvpNbToxobvLHfH2x/uZk49nsixyrwOvgD/3vLW4hEhjyIDvXgTy1uW1AGU2iqr36rZRNa82OenzPh2DbykNd5xMZ/lrM/v4W9WU0+bzVLYvO7Q/mZ3XUeR+bNp9UtjpDLQaRkGCKQgA6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250004; h=Content-Type:Content-Transfer-Encoding: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=GBBCSK8y8QtfvSD6xrMc++kvbEt6Aq2ZPVwo5jkWIXg=; b=i7F19d32GMHpwH7xRGGiakgZjIEFPEjJC5sYzZEUMzA3NAyiN7CuB0MJ27KqYAMW/Hydi6msBg+1TXsm5cQ6GE/pZYk/sc7PsuPdw588L8UorbVOmidsONxyON9PrFOjbu1UyPpWsiR3t7qgSHqJonOIzBL9I2BVtjc7LKd4vWE= 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 1623250004402786.4311819657445; Wed, 9 Jun 2021 07:46:44 -0700 (PDT) Received: from localhost ([::1]:39634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzTf-0004dj-85 for importer@patchew.org; Wed, 09 Jun 2021 10:46:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSV-0002NE-AR for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSS-0005CL-Tm for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:30 -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-404-Y4rd5NbZMvy-nhLVGIlqEw-1; Wed, 09 Jun 2021 10:45:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F7EC100C665; Wed, 9 Jun 2021 14:45:23 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F09010016F4; Wed, 9 Jun 2021 14:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GBBCSK8y8QtfvSD6xrMc++kvbEt6Aq2ZPVwo5jkWIXg=; b=QS0oSVANgrFFO16sqOWVhSaNBMbknXGfqrb1qwXROnol0BLhU+E9dLAUcTb5KTF5Tlpwha 6B1AObbpBTSQef3qo8g4Rt8wPckt7S7SPZNrY1MaqEc8lzBZLaSCX8c3GmWeb6jFtwdYwE jFEmS49dO4BaaMM4YRFRNOingAb/ygs= X-MC-Unique: Y4rd5NbZMvy-nhLVGIlqEw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 1/9] yank: Unregister function when using TLS migration Date: Wed, 9 Jun 2021 15:45:04 +0100 Message-Id: <20210609144512.211746-2-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Leonardo Bras After yank feature was introduced in migration, whenever migration is started using TLS, the following error happens in both source and destination hosts: (qemu) qemu-kvm: ../util/yank.c:107: yank_unregister_instance: Assertion `QLIST_EMPTY(&entry->yankfns)' failed. This happens because of a missing yank_unregister_function() when using qio-channel-tls. Fix this by also allowing TYPE_QIO_CHANNEL_TLS object type to perform yank_unregister_function() in channel_close() and multifd_load_cleanup(). Also, inside migration_channel_connect() and migration_channel_process_incoming() move yank_register_function() so it only runs once on a TLS migration. Fixes: b5eea99ec2f ("migration: Add yank feature", 2021-01-13) Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1964326 Signed-off-by: Leonardo Bras Reviewed-by: Lukas Straub Reviewed-by: Peter Xu -- Changes since v2: - Dropped all references to ioc->master - yank_register_function() and yank_unregister_function() now only run once in a TLS migration. Changes since v1: - Cast p->c to QIOChannelTLS into multifd_load_cleanup() Message-Id: <20210601054030.1153249-1-leobras.c@gmail.com> Signed-off-by: Dr. David Alan Gilbert --- migration/channel.c | 26 ++++++++++++++------------ migration/multifd.c | 3 ++- migration/qemu-file-channel.c | 4 +++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/migration/channel.c b/migration/channel.c index c9ee902021..01275a9162 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -38,18 +38,19 @@ void migration_channel_process_incoming(QIOChannel *ioc) trace_migration_set_incoming_channel( ioc, object_get_typename(OBJECT(ioc))); =20 - if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { - yank_register_function(MIGRATION_YANK_INSTANCE, - migration_yank_iochannel, - QIO_CHANNEL(ioc)); - } - if (s->parameters.tls_creds && *s->parameters.tls_creds && !object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)) { migration_tls_channel_process_incoming(s, ioc, &local_err); } else { + if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) || + object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)) { + yank_register_function(MIGRATION_YANK_INSTANCE, + migration_yank_iochannel, + QIO_CHANNEL(ioc)); + } + migration_ioc_process_incoming(ioc, &local_err); } =20 @@ -76,12 +77,6 @@ void migration_channel_connect(MigrationState *s, ioc, object_get_typename(OBJECT(ioc)), hostname, error); =20 if (!error) { - if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { - yank_register_function(MIGRATION_YANK_INSTANCE, - migration_yank_iochannel, - QIO_CHANNEL(ioc)); - } - if (s->parameters.tls_creds && *s->parameters.tls_creds && !object_dynamic_cast(OBJECT(ioc), @@ -99,6 +94,13 @@ void migration_channel_connect(MigrationState *s, } else { QEMUFile *f =3D qemu_fopen_channel_output(ioc); =20 + if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) = || + object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)) { + yank_register_function(MIGRATION_YANK_INSTANCE, + migration_yank_iochannel, + QIO_CHANNEL(ioc)); + } + qemu_mutex_lock(&s->qemu_file_lock); s->to_dst_file =3D f; qemu_mutex_unlock(&s->qemu_file_lock); diff --git a/migration/multifd.c b/migration/multifd.c index 0a4803cfcc..2e8f001bc0 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -987,7 +987,8 @@ int multifd_load_cleanup(Error **errp) for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 - if (object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_SOCKET) + if ((object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_SOCKET) || + object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_TLS)) && OBJECT(p->c)->ref =3D=3D 1) { yank_unregister_function(MIGRATION_YANK_INSTANCE, migration_yank_iochannel, diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 876d05a540..fad340ea7a 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -26,6 +26,7 @@ #include "qemu-file-channel.h" #include "qemu-file.h" #include "io/channel-socket.h" +#include "io/channel-tls.h" #include "qemu/iov.h" #include "qemu/yank.h" #include "yank_functions.h" @@ -106,7 +107,8 @@ static int channel_close(void *opaque, Error **errp) int ret; QIOChannel *ioc =3D QIO_CHANNEL(opaque); ret =3D qio_channel_close(ioc, errp); - if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) + if ((object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) || + object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)) && OBJECT(ioc)->ref =3D=3D 1) { yank_unregister_function(MIGRATION_YANK_INSTANCE, migration_yank_iochannel, --=20 2.31.1 From nobody Sun May 12 00:19:47 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=1623250122; cv=none; d=zohomail.com; s=zohoarc; b=dVa3BAJPTWqCuDJ7tFLHcP5T2FyoyMXitEV8uTHnThHdkskNcQ0cwZ9DJXqrs+mzNVFkkF+6SSdVgtxSVqXJ5aJ7RVV7eoB2splCs0I7S+KfFU5gXmwHWo6JjMB+J7UgCEbTUalTwCYMtQWRiBdCr6m3pdgMYAp1bL76eBKAtw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250122; h=Content-Type:Content-Transfer-Encoding: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=coLvn8Gbts70VrCUBaKn8Pa+hvQ3LAyQfn51EoDvrq0=; b=bhNOOSkNipoYFHnbcmZOOSIIu0sQ7w79NwRj+jQBCmhEuF2lPYrIA2ZpwT7RfF67/0jvx9Hs0a4CaEq+C4ezp7u7khqTGxDsyHM+QumpZE49q4A06GB4hexxMWyqLAGOxZi8bweKRzup2sjYNNRsyPBIgUBezvR0vsoR9bhl6ZU= 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 1623250122432166.85970022737786; Wed, 9 Jun 2021 07:48:42 -0700 (PDT) Received: from localhost ([::1]:47914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzVZ-0001hX-9q for importer@patchew.org; Wed, 09 Jun 2021 10:48:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSW-0002Nk-0q for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSU-0005Cg-GS for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45: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-146-uetAHbjaO7akrH7ztaXp2w-1; Wed, 09 Jun 2021 10:45:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34A9E1934108; Wed, 9 Jun 2021 14:45:25 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id D994610023B5; Wed, 9 Jun 2021 14:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=coLvn8Gbts70VrCUBaKn8Pa+hvQ3LAyQfn51EoDvrq0=; b=HoaArIrLorAqf7VNNcHh4/fI4wph3My42DMkf2LZ/7StMlOezXM76VyqW42eO8R6jnO70N tVzt0lYKjJJm+Dsnqq2A9rxrpSCJK0dY6qfcJWni10+6XWcUOuK5bquK/NgK6lsNr8fnTt ICVQSC5Vvm/uzvNaRQdqjMCBQ6zSGxU= X-MC-Unique: uetAHbjaO7akrH7ztaXp2w-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 2/9] migration/rdma: Fix cm event use after free Date: Wed, 9 Jun 2021 15:45:05 +0100 Message-Id: <20210609144512.211746-3-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Li Zhijian Signed-off-by: Li Zhijian Message-Id: <20210602023506.3821293-1-lizhijian@cn.fujitsu.com> Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Dr. David Alan Gilbert --- migration/rdma.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 1cdb4561f3..d90b29a4b5 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1539,16 +1539,20 @@ static int qemu_rdma_wait_comp_channel(RDMAContext = *rdma) =20 if (pfds[1].revents) { ret =3D rdma_get_cm_event(rdma->channel, &cm_event); - if (!ret) { - rdma_ack_cm_event(cm_event); + if (ret) { + error_report("failed to get cm event while wait " + "completion channel"); + return -EPIPE; } =20 error_report("receive cm event while wait comp channel= ," "cm event is %d", cm_event->event); if (cm_event->event =3D=3D RDMA_CM_EVENT_DISCONNECTED = || cm_event->event =3D=3D RDMA_CM_EVENT_DEVICE_REMOVA= L) { + rdma_ack_cm_event(cm_event); return -EPIPE; } + rdma_ack_cm_event(cm_event); } break; =20 @@ -3285,7 +3289,6 @@ static void rdma_cm_poll_handler(void *opaque) error_report("get_cm_event failed %d", errno); return; } - rdma_ack_cm_event(cm_event); =20 if (cm_event->event =3D=3D RDMA_CM_EVENT_DISCONNECTED || cm_event->event =3D=3D RDMA_CM_EVENT_DEVICE_REMOVAL) { @@ -3298,12 +3301,14 @@ static void rdma_cm_poll_handler(void *opaque) rdma->return_path->error_state =3D -EPIPE; } } + rdma_ack_cm_event(cm_event); =20 if (mis->migration_incoming_co) { qemu_coroutine_enter(mis->migration_incoming_co); } return; } + rdma_ack_cm_event(cm_event); } =20 static int qemu_rdma_accept(RDMAContext *rdma) --=20 2.31.1 From nobody Sun May 12 00:19:47 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=1623250134; cv=none; d=zohomail.com; s=zohoarc; b=H3BMDTaKCHBcLVYpbcgGw0aYsHDObwIqsWWHzyTPsSaadYexEtd9BDuhjA6qTURXdFhFroFW4OGI680YuNiMT9vrqZNr0EPZ/7jf+3ylrfUsyjJUBX21IxvsrnIUH58xhxQqc6kw57y+729lFZUQaNQbCQ/IhrsYR0nFd8Yd3rA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250134; h=Content-Type:Content-Transfer-Encoding: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=EAdWutYFecSrmFMdsO/OYCch+zESWDMKrKbxcYyedNg=; b=luOWmkoOHdXsQy7jqNQLtRcD2yxWJIoFMUrROqNZUBDzsM6Yyi0rYTGtjqV2d/TQahspwn9557fCYMB17fxT7zamHm3BhNEwYAmdeU0/MPYf+q7zE1ZVcKOg10+5HRiielta1t3+7eWavF/n+TWav7xp9ucfGV3wHQh9Z7RRFN8= 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 1623250134515547.1292535004467; Wed, 9 Jun 2021 07:48:54 -0700 (PDT) Received: from localhost ([::1]:48418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzVk-00021k-9P for importer@patchew.org; Wed, 09 Jun 2021 10:48:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSb-0002bY-Hv for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30064) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSY-0005H9-PW for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:37 -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-429-7YCbl7G_OHqEbjNQqj42uw-1; Wed, 09 Jun 2021 10:45:30 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A9C5C7403; Wed, 9 Jun 2021 14:45:29 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F17910023B5; Wed, 9 Jun 2021 14:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EAdWutYFecSrmFMdsO/OYCch+zESWDMKrKbxcYyedNg=; b=Z0hmwF0nmBo/h13AeD7PsUdrN8K5t4qiVz2mnbsw+3bGWY1lrJqyaE5oV7BJm9VQo8hA7u fO4XHadrTHlZOl3Cu0FNLYgYoMuU6FNK3k5NCR/Be8OVI3B4s1OIxBUP55uW2MMj2j4TxL j9sBOOFSvukMJjGQh++rpTAqkRmKNyE= X-MC-Unique: 7YCbl7G_OHqEbjNQqj42uw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 3/9] channel-socket: Only set CLOEXEC if we have space for fds Date: Wed, 9 Jun 2021 15:45:06 +0100 Message-Id: <20210609144512.211746-4-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: "Dr. David Alan Gilbert" MSG_CMSG_CLOEXEC cleans up received fd's; it's really only for Unix sockets, but currently we enable it for everything; some socket types (IP_MPTCP) don't like this. Only enable it when we're giving the recvmsg room to receive fd's anyway. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210421112834.107651-2-dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- io/channel-socket.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/io/channel-socket.c b/io/channel-socket.c index de259f7eed..606ec97cf7 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -487,15 +487,15 @@ static ssize_t qio_channel_socket_readv(QIOChannel *i= oc, =20 memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); =20 -#ifdef MSG_CMSG_CLOEXEC - sflags |=3D MSG_CMSG_CLOEXEC; -#endif - msg.msg_iov =3D (struct iovec *)iov; msg.msg_iovlen =3D niov; if (fds && nfds) { msg.msg_control =3D control; msg.msg_controllen =3D sizeof(control); +#ifdef MSG_CMSG_CLOEXEC + sflags |=3D MSG_CMSG_CLOEXEC; +#endif + } =20 retry: --=20 2.31.1 From nobody Sun May 12 00:19:47 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=1623250009; cv=none; d=zohomail.com; s=zohoarc; b=Jb7C3krgBZh1LSFThF+TI7lXbStEmUV7dp7YoGBMnzG1DBaIjDoRBi0MteKiG4qledi0+QEtoZMa6UioICqweOXvZzUtsX4LmS8QTNrOzo8d2cy40ew5WwgbJ3LhJW72aG8CIAxJWRFGbao0giAT95m+Le6abAc/xkfGz4XispA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250009; h=Content-Type:Content-Transfer-Encoding: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=8Yf3psi08pzq+0OCT0UglBlxErIHmD76X4oAw1SryyQ=; b=IwTY3gKJtkWlgcF86s+A/cQAubBmbym0pEevTnjeIxWwL7z5ozsSZMgNCIQU2xtypNPM2o/UT89FPQo91OcTR3y+ASIFpeX7JWnLuGUYGU28kKvaHnztg/699njfkZPClP6L7hbeR/NT+13fpHorubncAzsczJolP9ingMRdBjA= 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 1623250009672310.4518931563862; Wed, 9 Jun 2021 07:46:49 -0700 (PDT) Received: from localhost ([::1]:40280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzTk-00053y-LZ for importer@patchew.org; Wed, 09 Jun 2021 10:46:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSa-0002Z3-JS for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSY-0005H7-Qo for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:36 -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-223-Jnn8V8TsNjmh1NxSiPE_SA-1; Wed, 09 Jun 2021 10:45:32 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 252C1100CFBB; Wed, 9 Jun 2021 14:45:31 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5D53100EB3E; Wed, 9 Jun 2021 14:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Yf3psi08pzq+0OCT0UglBlxErIHmD76X4oAw1SryyQ=; b=M/S5rZycEYgejvFyTlXxDXeWSgy39pwPsNfOoPb/x2GZRStJduQZ02BaysNJblbQldwpwE 0olAV8Skcmi5yKuZJ9QeYZIgm6cKpZQ55c6aOXmcv67muqzEaHYLUEXrjWj9AFpezoGewB S1Q3VaW+6IVezyM5Y2tifSP30z3SXcM= X-MC-Unique: Jnn8V8TsNjmh1NxSiPE_SA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 4/9] io/net-listener: Call the notifier during finalize Date: Wed, 9 Jun 2021 15:45:07 +0100 Message-Id: <20210609144512.211746-5-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: "Dr. David Alan Gilbert" Call the notifier during finalize; it's currently only called if we change it, which is not the intent. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210421112834.107651-3-dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- io/net-listener.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/io/net-listener.c b/io/net-listener.c index 46c2643d00..1c984d69c6 100644 --- a/io/net-listener.c +++ b/io/net-listener.c @@ -292,6 +292,9 @@ static void qio_net_listener_finalize(Object *obj) QIONetListener *listener =3D QIO_NET_LISTENER(obj); size_t i; =20 + if (listener->io_notify) { + listener->io_notify(listener->io_data); + } qio_net_listener_disconnect(listener); =20 for (i =3D 0; i < listener->nsioc; i++) { --=20 2.31.1 From nobody Sun May 12 00:19:47 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=1623250259; cv=none; d=zohomail.com; s=zohoarc; b=mE1n5xymZ6cW37IVZX1JJmwbigpKOo3EK5hPQ7maaJFtA+Y/yjA/PK3B2yEhb5vSjtYM4QY5xu5d5QFxiXozpMX4UFwEgYFcJq/YKmemI2JwMLE1IwvCuGN6V7c3vMTmcR6QM7eYnz49YYNz6w+I0sS8KDVr/TwYVcWFRIbiGQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250259; h=Content-Type:Content-Transfer-Encoding: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=Zk6RO95o0Bz79WNxf9vbWMlU8vKD+fo/Q6+9NzX9c7E=; b=U8WE0re5C7Ubf/qIjgM57AjpkPmGdrtJ4SC4aLCJVz48NQrQl6PZEZK8liD5ssHWFA9Z20iQzKRbha27slLt4v8jdu1pPemJWnFFXKLh1gkPJEAuojmkocpR2XnrLWlG0zpt5DC5y19DkX+IxepBX0AbDYYimB5bPwcjU6HyqE4= 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 1623250259962175.81109733876986; Wed, 9 Jun 2021 07:50:59 -0700 (PDT) Received: from localhost ([::1]:54358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzXm-00064s-VB for importer@patchew.org; Wed, 09 Jun 2021 10:50:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSp-0003MV-He for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSn-0005TF-CO for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:51 -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-306-H9ezTp5mPr2dkJTTPurOvg-1; Wed, 09 Jun 2021 10:45:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE510803622; Wed, 9 Jun 2021 14:45:35 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F33F101E5AF; Wed, 9 Jun 2021 14:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zk6RO95o0Bz79WNxf9vbWMlU8vKD+fo/Q6+9NzX9c7E=; b=Jw3QlM5DsUmfyJQEbIdmvF9skkaTjiprMWDPk7CMudKYUlNaJNvca1lgBI/kOISvKFIVYz E95Ok9ZfMPTe8K7sTmELUXS8V/v8nUqvyQuabR6JyYgfMOrXbNXh1HZkDmhyS8Sw64qEvh +muXs64zebwg19h76CZCvOvq1u2ee4o= X-MC-Unique: H9ezTp5mPr2dkJTTPurOvg-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 5/9] migration: Add cleanup hook for inwards migration Date: Wed, 9 Jun 2021 15:45:08 +0100 Message-Id: <20210609144512.211746-6-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: "Dr. David Alan Gilbert" Add a cleanup hook for incoming migration that gets called at the end as a way for a transport to allow cleanup. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210421112834.107651-4-dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 3 +++ migration/migration.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 1885860d7b..393299e150 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -280,6 +280,9 @@ void migration_incoming_state_destroy(void) g_array_free(mis->postcopy_remote_fds, TRUE); mis->postcopy_remote_fds =3D NULL; } + if (mis->transport_cleanup) { + mis->transport_cleanup(mis->transport_data); + } =20 qemu_event_reset(&mis->main_thread_load_event); =20 diff --git a/migration/migration.h b/migration/migration.h index b88bd8fe07..2ebb740dfa 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -49,6 +49,10 @@ struct PostcopyBlocktimeContext; struct MigrationIncomingState { QEMUFile *from_src_file; =20 + /* A hook to allow cleanup at the end of incoming migration */ + void *transport_data; + void (*transport_cleanup)(void *data); + /* * Free at the start of the main state load, set as the main thread fi= nishes * loading state. --=20 2.31.1 From nobody Sun May 12 00:19:47 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=1623250269; cv=none; d=zohomail.com; s=zohoarc; b=DDQxcH6mZU71qd0S1iC2rMJ7uAskTA+KkRXka/nvH8FAUj7jIHuceIenM/FN4+u0RSyzSx+zclZa2nOlngE+kVlScg4ehzo4JLR1B8/3t7hdu45eePJ+T1FlNejAUpqJLhG3P/VdIYJG5dLc4+uvYgtR9EVxnOY7N+WIcWgcDIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250269; h=Content-Type:Content-Transfer-Encoding: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=vghlMDGG5TpIGy/P4pElI/Q9CxDqkT3r/xWcpPz2mW0=; b=PtX5xiLvKts+oM/ffkPdD19VjgXvV2ngVidJ6FZQi8KJ34WBmqbdeBsGeXNsJrJSyGEC4QVFtWlkBrUBAhUKY00EEY+oKad/7Hh8Clm4rE2nqJL9b6StHMG6KxjyUDd1+HDl6c3U2ju9zvHMzSLp9xytplbDqh/G/67omcAyLcc= 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 1623250269912439.96999537023714; Wed, 9 Jun 2021 07:51:09 -0700 (PDT) Received: from localhost ([::1]:54798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzXw-0006Mt-QB for importer@patchew.org; Wed, 09 Jun 2021 10:51:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSl-00034p-1f for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSh-0005Nb-Q6 for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:46 -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-329-YLlcsxRyMpyVXCW3-uzWAA-1; Wed, 09 Jun 2021 10:45:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 96DC31934100; Wed, 9 Jun 2021 14:45:40 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0345410016F4; Wed, 9 Jun 2021 14:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249943; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vghlMDGG5TpIGy/P4pElI/Q9CxDqkT3r/xWcpPz2mW0=; b=ZUctg8DUdPoLIEytwRazrSKucHpMKfhx6sodk4jSk/llUgKMWka1c6gdw+9v87Bt8LTQWy NZMzfzRT5zxxaxBgzLEPoCYddVbLkAnTyylvhLM4uJfQumN4Gy9lEEufkyn5dH4odIPacv Za5Cc7wPGr0c/ybWZB84FTg8+yF+UbY= X-MC-Unique: YLlcsxRyMpyVXCW3-uzWAA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 6/9] migration/socket: Close the listener at the end Date: Wed, 9 Jun 2021 15:45:09 +0100 Message-Id: <20210609144512.211746-7-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: "Dr. David Alan Gilbert" Delay closing the listener until the cleanup hook at the end; mptcp needs the listener to stay open while the other paths come in. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210421112834.107651-5-dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/multifd.c | 5 +++++ migration/socket.c | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 2e8f001bc0..ab41590e71 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1166,6 +1166,11 @@ bool multifd_recv_all_channels_created(void) return true; } =20 + if (!multifd_recv_state) { + /* Called before any connections created */ + return false; + } + return thread_count =3D=3D qatomic_read(&multifd_recv_state->count); } =20 diff --git a/migration/socket.c b/migration/socket.c index 6016642e04..05705a32d8 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -126,22 +126,31 @@ static void socket_accept_incoming_migration(QIONetLi= stener *listener, { trace_migration_socket_incoming_accepted(); =20 - qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming"); - migration_channel_process_incoming(QIO_CHANNEL(cioc)); - if (migration_has_all_channels()) { - /* Close listening socket as its no longer needed */ - qio_net_listener_disconnect(listener); - object_unref(OBJECT(listener)); + error_report("%s: Extra incoming migration connection; ignoring", + __func__); + return; } + + qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming"); + migration_channel_process_incoming(QIO_CHANNEL(cioc)); } =20 +static void +socket_incoming_migration_end(void *opaque) +{ + QIONetListener *listener =3D opaque; + + qio_net_listener_disconnect(listener); + object_unref(OBJECT(listener)); +} =20 static void socket_start_incoming_migration_internal(SocketAddress *saddr, Error **errp) { QIONetListener *listener =3D qio_net_listener_new(); + MigrationIncomingState *mis =3D migration_incoming_get_current(); size_t i; int num =3D 1; =20 @@ -156,6 +165,9 @@ socket_start_incoming_migration_internal(SocketAddress = *saddr, return; } =20 + mis->transport_data =3D listener; + mis->transport_cleanup =3D socket_incoming_migration_end; + qio_net_listener_set_client_func_full(listener, socket_accept_incoming_migration, NULL, NULL, --=20 2.31.1 From nobody Sun May 12 00:19:47 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=1623250122; cv=none; d=zohomail.com; s=zohoarc; b=hOO2d2pDoyv9AhqLEIzaYn5F28ROASTxISwGK39h/8D8Bk4LRFO87kdfzDcobQi3pJF8nTTT+eSYh6AdFEyc72rLr6t3SvCp7NGKZKsVZScVIZIA9c6msuyQjlZaVcrY0s2EeydwqMK0NfZQVBHYBVoAe024UixyO2DrGXMX6S8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250122; h=Content-Type:Content-Transfer-Encoding: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=0HyOa6ltjbaqEp6S+XfeNEi/Q5ntfEuMy7rznJ97OGI=; b=mg5cxPFfpUwL7dB8J1T8j+ZkfDLQus6AbG3O1C0FNfWEVaCNuOhDTqtZIpkCCeiUOn/DMR6fl58aEUq3MHlGlzXpZXl9DSDx0eqOuqjee49GphKFxCxW2ENanZCnhnEQ3oGPI9vM9JsAaZLuCKDzXHNCyR7feG208+6VgPJ8EOI= 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 162325012270511.633809606477826; Wed, 9 Jun 2021 07:48:42 -0700 (PDT) Received: from localhost ([::1]:47962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzVZ-0001jH-Lk for importer@patchew.org; Wed, 09 Jun 2021 10:48:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSo-0003HT-Ee for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24797) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSm-0005Sz-Hb for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:50 -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-212-ckR107n2PJeinN99C32T4A-1; Wed, 09 Jun 2021 10:45:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60C8E1934104; Wed, 9 Jun 2021 14:45:45 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id E35B11002EF0; Wed, 9 Jun 2021 14:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0HyOa6ltjbaqEp6S+XfeNEi/Q5ntfEuMy7rznJ97OGI=; b=Dj19fdnAuDAG5Vjf5jioqV8KsyfK1igwnRCXpeW3kDoUvdiNPL0QkCdHqIM5lP94BtOsxd 3utpBRt15aNlCje0MZO/jtNlxcLat4NiAMfBpxGCjkByjWiCSoQRAWtHdnZ2HeSe6IMnMM v6URvYcmzfR/wQ9nUBMD/O71tyWrpYE= X-MC-Unique: ckR107n2PJeinN99C32T4A-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 7/9] sockets: Support multipath TCP Date: Wed, 9 Jun 2021 15:45:10 +0100 Message-Id: <20210609144512.211746-8-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: "Dr. David Alan Gilbert" Multipath TCP allows combining multiple interfaces/routes into a single socket, with very little work for the user/admin. It's enabled by 'mptcp' on most socket addresses: ./qemu-system-x86_64 -nographic -incoming tcp:0:4444,mptcp Signed-off-by: Dr. David Alan Gilbert Message-Id: <20210421112834.107651-6-dgilbert@redhat.com> Acked-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Dr. David Alan Gilbert --- io/dns-resolver.c | 4 ++++ qapi/sockets.json | 5 ++++- util/qemu-sockets.c | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/io/dns-resolver.c b/io/dns-resolver.c index 743a0efc87..a5946a93bf 100644 --- a/io/dns-resolver.c +++ b/io/dns-resolver.c @@ -122,6 +122,10 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSRes= olver *resolver, .ipv4 =3D iaddr->ipv4, .has_ipv6 =3D iaddr->has_ipv6, .ipv6 =3D iaddr->ipv6, +#ifdef IPPROTO_MPTCP + .has_mptcp =3D iaddr->has_mptcp, + .mptcp =3D iaddr->mptcp, +#endif }; =20 (*addrs)[i] =3D newaddr; diff --git a/qapi/sockets.json b/qapi/sockets.json index 2e83452797..735eb4abb5 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -57,6 +57,8 @@ # @keep-alive: enable keep-alive when connecting to this socket. Not suppo= rted # for passive sockets. (Since 4.2) # +# @mptcp: enable multi-path TCP. (Since 6.1) +# # Since: 1.3 ## { 'struct': 'InetSocketAddress', @@ -66,7 +68,8 @@ '*to': 'uint16', '*ipv4': 'bool', '*ipv6': 'bool', - '*keep-alive': 'bool' } } + '*keep-alive': 'bool', + '*mptcp': { 'type': 'bool', 'if': 'defined(IPPROTO_MPTCP)' } } } =20 ## # @UnixSocketAddress: diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 2463c49773..c415c342c1 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -278,6 +278,11 @@ static int inet_listen_saddr(InetSocketAddress *saddr, =20 /* create socket + bind/listen */ for (e =3D res; e !=3D NULL; e =3D e->ai_next) { +#ifdef IPPROTO_MPTCP + if (saddr->has_mptcp && saddr->mptcp) { + e->ai_protocol =3D IPPROTO_MPTCP; + } +#endif getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen, uaddr,INET6_ADDRSTRLEN,uport,32, NI_NUMERICHOST | NI_NUMERICSERV); @@ -456,6 +461,13 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error= **errp) for (e =3D res; e !=3D NULL; e =3D e->ai_next) { error_free(local_err); local_err =3D NULL; + +#ifdef IPPROTO_MPTCP + if (saddr->has_mptcp && saddr->mptcp) { + e->ai_protocol =3D IPPROTO_MPTCP; + } +#endif + sock =3D inet_connect_addr(saddr, e, &local_err); if (sock >=3D 0) { break; @@ -687,6 +699,17 @@ int inet_parse(InetSocketAddress *addr, const char *st= r, Error **errp) } addr->has_keep_alive =3D true; } +#ifdef IPPROTO_MPTCP + begin =3D strstr(optstr, ",mptcp"); + if (begin) { + if (inet_parse_flag("mptcp", begin + strlen(",mptcp"), + &addr->mptcp, errp) < 0) + { + return -1; + } + addr->has_mptcp =3D true; + } +#endif return 0; } =20 --=20 2.31.1 From nobody Sun May 12 00:19:47 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=1623250264; cv=none; d=zohomail.com; s=zohoarc; b=ZjsuChUCv715fyC7l45gDR3ds5Z8gWXAZCjW4CABGbk2qPdPSdLYFDHWZyUjaWGYhm3UqiYRWNLUKccqRMk8FB4uA4nli8iSYKMmhjp/ksrlmDz8Muzc5xm/sAwVWnNiFd5iDMKGEKsFnRSlzdrQ9li3GbLy6TccK4LyB46lMy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250264; h=Content-Type:Content-Transfer-Encoding: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=5BEx2+s+dEa5eKj92PIDgwGF7hnX67z4SFsPH9sRzU8=; b=Dpzk3ymSUz/4tNLWaXSAos+FRxlI++natTcAyfg7qVAmaAb8iuLvkS36qnT/UnxwZQFb5i7QbVfe8lD5NgiSH1c/29FSR9drjLDNoaQwv2eZ3ZckLXlTal+M6bvnaS9Bi/12QVkgjJThy1GWqu6Bnprn7NdAtAba9RSawyvqlBI= 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 1623250264843510.8270523680526; Wed, 9 Jun 2021 07:51:04 -0700 (PDT) Received: from localhost ([::1]:54428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzXr-00067u-Qk for importer@patchew.org; Wed, 09 Jun 2021 10:51:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzT0-0003p0-4n for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:46:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSw-0005Zw-Qf for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:46:00 -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-451-Jlc9W2g5NvuKcYJ-jGlQeA-1; Wed, 09 Jun 2021 10:45:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 50482100C66F; Wed, 9 Jun 2021 14:45:50 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABA8710016FE; Wed, 9 Jun 2021 14:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5BEx2+s+dEa5eKj92PIDgwGF7hnX67z4SFsPH9sRzU8=; b=hlAszijwqunPQ3YJGRGlbg00LbsUGfBDHLmR0NHs1Mvz34iBtJcqYMKQjfeGDsxC0EhMci A15QdPAe48vMF1nenenWlN8xpbjX7/LC8v6AAYuLsDLQnJGQdzhyritg98FZuMohvHrh7A vMA30wRjLdvFfzvV6nSfrXBLORWZ6Jk= X-MC-Unique: Jlc9W2g5NvuKcYJ-jGlQeA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 8/9] migration/dirtyrate: make sample page count configurable Date: Wed, 9 Jun 2021 15:45:11 +0100 Message-Id: <20210609144512.211746-9-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Hyman Huang(=E9=BB=84=E5=8B=87) introduce optional sample-pages argument in calc-dirty-rate, making sample page count per GB configurable so that more accurate dirtyrate can be calculated. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) Message-Id: <3103453a3b2796f929269c99a6ad81a9a7f1f405.1623027729.git.huangy= 81@chinatelecom.cn> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert Wrapped a couple of long lines --- migration/dirtyrate.c | 31 +++++++++++++++++++++++++++---- migration/dirtyrate.h | 8 +++++++- qapi/migration.json | 15 ++++++++++++--- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index ccb98147e8..2ee3890721 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -48,6 +48,12 @@ static bool is_sample_period_valid(int64_t sec) return true; } =20 +static bool is_sample_pages_valid(int64_t pages) +{ + return pages >=3D MIN_SAMPLE_PAGE_COUNT && + pages <=3D MAX_SAMPLE_PAGE_COUNT; +} + static int dirtyrate_set_state(int *state, int old_state, int new_state) { assert(new_state < DIRTY_RATE_STATUS__MAX); @@ -72,13 +78,15 @@ static struct DirtyRateInfo *query_dirty_rate_info(void) info->status =3D CalculatingState; info->start_time =3D DirtyStat.start_time; info->calc_time =3D DirtyStat.calc_time; + info->sample_pages =3D DirtyStat.sample_pages; =20 trace_query_dirty_rate_info(DirtyRateStatus_str(CalculatingState)); =20 return info; } =20 -static void init_dirtyrate_stat(int64_t start_time, int64_t calc_time) +static void init_dirtyrate_stat(int64_t start_time, int64_t calc_time, + uint64_t sample_pages) { DirtyStat.total_dirty_samples =3D 0; DirtyStat.total_sample_count =3D 0; @@ -86,6 +94,7 @@ static void init_dirtyrate_stat(int64_t start_time, int64= _t calc_time) DirtyStat.dirty_rate =3D -1; DirtyStat.start_time =3D start_time; DirtyStat.calc_time =3D calc_time; + DirtyStat.sample_pages =3D sample_pages; } =20 static void update_dirtyrate_stat(struct RamblockDirtyInfo *info) @@ -361,6 +370,7 @@ void *get_dirtyrate_thread(void *arg) int ret; int64_t start_time; int64_t calc_time; + uint64_t sample_pages; =20 ret =3D dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_UNSTA= RTED, DIRTY_RATE_STATUS_MEASURING); @@ -371,7 +381,8 @@ void *get_dirtyrate_thread(void *arg) =20 start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) / 1000; calc_time =3D config.sample_period_seconds; - init_dirtyrate_stat(start_time, calc_time); + sample_pages =3D config.sample_pages_per_gigabytes; + init_dirtyrate_stat(start_time, calc_time, sample_pages); =20 calculate_dirtyrate(config); =20 @@ -383,7 +394,8 @@ void *get_dirtyrate_thread(void *arg) return NULL; } =20 -void qmp_calc_dirty_rate(int64_t calc_time, Error **errp) +void qmp_calc_dirty_rate(int64_t calc_time, bool has_sample_pages, + int64_t sample_pages, Error **errp) { static struct DirtyRateConfig config; QemuThread thread; @@ -404,6 +416,17 @@ void qmp_calc_dirty_rate(int64_t calc_time, Error **er= rp) return; } =20 + if (has_sample_pages) { + if (!is_sample_pages_valid(sample_pages)) { + error_setg(errp, "sample-pages is out of range[%d, %d].", + MIN_SAMPLE_PAGE_COUNT, + MAX_SAMPLE_PAGE_COUNT); + return; + } + } else { + sample_pages =3D DIRTYRATE_DEFAULT_SAMPLE_PAGES; + } + /* * Init calculation state as unstarted. */ @@ -415,7 +438,7 @@ void qmp_calc_dirty_rate(int64_t calc_time, Error **err= p) } =20 config.sample_period_seconds =3D calc_time; - config.sample_pages_per_gigabytes =3D DIRTYRATE_DEFAULT_SAMPLE_PAGES; + config.sample_pages_per_gigabytes =3D sample_pages; qemu_thread_create(&thread, "get_dirtyrate", get_dirtyrate_thread, (void *)&config, QEMU_THREAD_DETACHED); } diff --git a/migration/dirtyrate.h b/migration/dirtyrate.h index 6ec429534d..e1fd29089e 100644 --- a/migration/dirtyrate.h +++ b/migration/dirtyrate.h @@ -15,7 +15,6 @@ =20 /* * Sample 512 pages per GB as default. - * TODO: Make it configurable. */ #define DIRTYRATE_DEFAULT_SAMPLE_PAGES 512 =20 @@ -35,6 +34,12 @@ #define MIN_FETCH_DIRTYRATE_TIME_SEC 1 #define MAX_FETCH_DIRTYRATE_TIME_SEC 60 =20 +/* + * Take 1/16 pages in 1G as the maxmum sample page count + */ +#define MIN_SAMPLE_PAGE_COUNT 128 +#define MAX_SAMPLE_PAGE_COUNT 16384 + struct DirtyRateConfig { uint64_t sample_pages_per_gigabytes; /* sample pages per GB */ int64_t sample_period_seconds; /* time duration between two sampling */ @@ -63,6 +68,7 @@ struct DirtyRateStat { int64_t dirty_rate; /* dirty rate in MB/s */ int64_t start_time; /* calculation start time in units of second */ int64_t calc_time; /* time duration of two sampling in units of second= */ + uint64_t sample_pages; /* sample pages per GB */ }; =20 void *get_dirtyrate_thread(void *arg); diff --git a/qapi/migration.json b/qapi/migration.json index 7a5bdf9a0d..1124a2dda8 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1740,6 +1740,9 @@ # # @calc-time: time in units of second for sample dirty pages # +# @sample-pages: page count per GB for sample dirty pages +# the default value is 512 (since 6.1) +# # Since: 5.2 # ## @@ -1747,7 +1750,8 @@ 'data': {'*dirty-rate': 'int64', 'status': 'DirtyRateStatus', 'start-time': 'int64', - 'calc-time': 'int64'} } + 'calc-time': 'int64', + 'sample-pages': 'uint64'} } =20 ## # @calc-dirty-rate: @@ -1756,13 +1760,18 @@ # # @calc-time: time in units of second for sample dirty pages # +# @sample-pages: page count per GB for sample dirty pages +# the default value is 512 (since 6.1) +# # Since: 5.2 # # Example: -# {"command": "calc-dirty-rate", "data": {"calc-time": 1} } +# {"command": "calc-dirty-rate", "data": {"calc-time": 1, +# 'sample-pages': 512} } # ## -{ 'command': 'calc-dirty-rate', 'data': {'calc-time': 'int64'} } +{ 'command': 'calc-dirty-rate', 'data': {'calc-time': 'int64', + '*sample-pages': 'int'} } =20 ## # @query-dirty-rate: --=20 2.31.1 From nobody Sun May 12 00:19:47 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=1623250038; cv=none; d=zohomail.com; s=zohoarc; b=nIXZ3Mr4OgwL5F7EjtnO3h2nBKPpQvMcUm7X6KV4Tactyuz09bTSk7O3j+eryycIph9DJY+RDbvwng1lDn3/+Utdl8nQJhIgPwetDf4VE4lH2PQkShmAfIs6eL5+QihG8l/hO2MWI41t6ob2Kf/Y579B0uYZ5BpJffJJLAS3umc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623250038; h=Content-Type:Content-Transfer-Encoding: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=pHlziamaUebz1rQ20fc/pINanMO3eYs762iYIZ+86L4=; b=Hl0GhT7Vt/VYD3wnOkBgEa03HMlirVu/Tem97/LQAaxNYqvGHwUXlJqd1B0M1uyIk1CDpNSDKGZGR6tihJVyO3e5iCgv1LC89ezo5cDEFHJwyXBoGxty7zfSC4Y6CT12uOkPVd4mp1sM5wA1J1BRTsm9Ht8My0MUteaA6oKx7IA= 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 16232500381421021.5859083130733; Wed, 9 Jun 2021 07:47:18 -0700 (PDT) Received: from localhost ([::1]:42332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqzUA-0006Qp-Nr for importer@patchew.org; Wed, 09 Jun 2021 10:47:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSw-0003hE-4a for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54045) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqzSt-0005Y2-9h for qemu-devel@nongnu.org; Wed, 09 Jun 2021 10:45: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-604-q_szMJLYNGyZTwSYI0qFFA-1; Wed, 09 Jun 2021 10:45:52 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2FE3C7403; Wed, 9 Jun 2021 14:45:51 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-113-168.ams2.redhat.com [10.36.113.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 978D41002EF0; Wed, 9 Jun 2021 14:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pHlziamaUebz1rQ20fc/pINanMO3eYs762iYIZ+86L4=; b=dgjBsSs4OwKPvO/90Yc3LjgK8dc3e1tIq1uRB7O/Yqs5aG0vwNsV+t9JjUYoGAsLVjIisd 9ZoybA6fNZmaWrLJOS5t2AmEitKkf0+OmUsyPlUDx7acJhrJkaiYykDf6K8sOnR7lS7mki J8vxs966sqL5HRSKfWvU50UGTVlUH1Q= X-MC-Unique: q_szMJLYNGyZTwSYI0qFFA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, huangy81@chinatelecom.cn, peterx@redhat.com, lizhijian@cn.fujitsu.com, leobras.c@gmail.com, pabeni@redhat.com Subject: [PULL 9/9] hmp: Add "calc_dirty_rate" and "info dirty_rate" cmds Date: Wed, 9 Jun 2021 15:45:12 +0100 Message-Id: <20210609144512.211746-10-dgilbert@redhat.com> In-Reply-To: <20210609144512.211746-1-dgilbert@redhat.com> References: <20210609144512.211746-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Peter Xu These two commands are missing when adding the QMP sister commands. Add them, so developers can play with them easier. Signed-off-by: Peter Xu Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) Message-Id: <4cc0039fc3ad6145136770cf3b0f056c09a2910b.1623027729.git.huangy= 81@chinatelecom.cn> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert --- hmp-commands-info.hx | 13 ++++++++++++ hmp-commands.hx | 14 +++++++++++++ include/monitor/hmp.h | 2 ++ migration/dirtyrate.c | 47 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index b2347a6aea..fb59c27200 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -867,3 +867,16 @@ SRST ``info replay`` Display the record/replay information: mode and the current icount. ERST + + { + .name =3D "dirty_rate", + .args_type =3D "", + .params =3D "", + .help =3D "show dirty rate information", + .cmd =3D hmp_info_dirty_rate, + }, + +SRST + ``info dirty_rate`` + Display the vcpu dirty rate information. +ERST diff --git a/hmp-commands.hx b/hmp-commands.hx index 2d21fe5ad4..84dcc3aae6 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1727,3 +1727,17 @@ ERST .flags =3D "p", }, =20 +SRST +``calc_dirty_rate`` *second* + Start a round of dirty rate measurement with the period specified in *se= cond*. + The result of the dirty rate measurement may be observed with ``info + dirty_rate`` command. +ERST + + { + .name =3D "calc_dirty_rate", + .args_type =3D "second:l,sample_pages_per_GB:l?", + .params =3D "second [sample_pages_per_GB]", + .help =3D "start a round of guest dirty rate measurement", + .cmd =3D hmp_calc_dirty_rate, + }, diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 605d57287a..3baa1058e2 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -129,5 +129,7 @@ void hmp_info_replay(Monitor *mon, const QDict *qdict); void hmp_replay_break(Monitor *mon, const QDict *qdict); void hmp_replay_delete_break(Monitor *mon, const QDict *qdict); void hmp_replay_seek(Monitor *mon, const QDict *qdict); +void hmp_info_dirty_rate(Monitor *mon, const QDict *qdict); +void hmp_calc_dirty_rate(Monitor *mon, const QDict *qdict); =20 #endif diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index 2ee3890721..320c56ba2c 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -20,6 +20,9 @@ #include "ram.h" #include "trace.h" #include "dirtyrate.h" +#include "monitor/hmp.h" +#include "monitor/monitor.h" +#include "qapi/qmp/qdict.h" =20 static int CalculatingState =3D DIRTY_RATE_STATUS_UNSTARTED; static struct DirtyRateStat DirtyStat; @@ -447,3 +450,47 @@ struct DirtyRateInfo *qmp_query_dirty_rate(Error **err= p) { return query_dirty_rate_info(); } + +void hmp_info_dirty_rate(Monitor *mon, const QDict *qdict) +{ + DirtyRateInfo *info =3D query_dirty_rate_info(); + + monitor_printf(mon, "Status: %s\n", + DirtyRateStatus_str(info->status)); + monitor_printf(mon, "Start Time: %"PRIi64" (ms)\n", + info->start_time); + monitor_printf(mon, "Sample Pages: %"PRIu64" (per GB)\n", + info->sample_pages); + monitor_printf(mon, "Period: %"PRIi64" (sec)\n", + info->calc_time); + monitor_printf(mon, "Dirty rate: "); + if (info->has_dirty_rate) { + monitor_printf(mon, "%"PRIi64" (MB/s)\n", info->dirty_rate); + } else { + monitor_printf(mon, "(not ready)\n"); + } + g_free(info); +} + +void hmp_calc_dirty_rate(Monitor *mon, const QDict *qdict) +{ + int64_t sec =3D qdict_get_try_int(qdict, "second", 0); + int64_t sample_pages =3D qdict_get_try_int(qdict, "sample_pages_per_GB= ", -1); + bool has_sample_pages =3D (sample_pages !=3D -1); + Error *err =3D NULL; + + if (!sec) { + monitor_printf(mon, "Incorrect period length specified!\n"); + return; + } + + qmp_calc_dirty_rate(sec, has_sample_pages, sample_pages, &err); + if (err) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "Starting dirty rate measurement with period %"PRI= i64 + " seconds\n", sec); + monitor_printf(mon, "[Please use 'info dirty_rate' to check results]\n= "); +} --=20 2.31.1