From nobody Mon May 6 07:45:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1603201560; cv=none; d=zohomail.com; s=zohoarc; b=WORr6gQVNdQ6fbqgP6ABhd62fUp6l7z8XFBaqcltlSbmfBa7DHcff/ketO1RhFbd+tBnCHgP5mfyW2bgXoN5xyGB43Lpc4nQ8U+AlNJMOWhFAaYvgMl10zoayIm5WWfKkoekxHn36NXB3cNHEatGcpy4ilY7iRAoycrfm9aZgCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603201560; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=XILC0SK/hhJ9U3slQFuXdzngB0S8R6kZOHZg9rKFP1M=; b=aEdxk7ScCuIueGuyFEHlgLHXU9ZdC5DIIiXAw25bAqZrKg5x34Sf7/91W/jO5W6DEEf9ZxGiPsEgKXl/m0SwaJ4bovG/Re7t7z7DBjIR4X8SDFQkHHVLoYM+vLTaRgpvqWfHvwiE7y5gtWM+VFLSi7jj9LrQKhDZPOKRg/BB6AA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603201560354666.3177153088978; Tue, 20 Oct 2020 06:46:00 -0700 (PDT) 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-250-JTl-SgSYOn2hBjOXGID1-w-1; Tue, 20 Oct 2020 09:45:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0956364145; Tue, 20 Oct 2020 13:45:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD4EA5B4D6; Tue, 20 Oct 2020 13:45:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4838F180B658; Tue, 20 Oct 2020 13:45:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09KDjleU020406 for ; Tue, 20 Oct 2020 09:45:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E5ED1050191; Tue, 20 Oct 2020 13:45:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 887601111C7F for ; Tue, 20 Oct 2020 13:45:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 92741185A78B for ; Tue, 20 Oct 2020 13:45:44 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-74-dtJsdt34M3Of5mfvhKBJNA-1; Tue, 20 Oct 2020 09:45:40 -0400 Received: from [10.28.15.159] (helo=vz7.sw.ru) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kUrxA-005MrG-Qt for libvir-list@redhat.com; Tue, 20 Oct 2020 16:45:28 +0300 X-MC-Unique: JTl-SgSYOn2hBjOXGID1-w-1 X-MC-Unique: dtJsdt34M3Of5mfvhKBJNA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 1/3] qemu: add option to process offloaded legacy blockjob event ealier Date: Tue, 20 Oct 2020 16:44:07 +0300 Message-Id: <1603201449-610752-2-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1603201449-610752-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1603201449-610752-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently in qemuProcessHandleBlockJob we either offload blockjob event processing to the worker thread or notify another thread that waits for blockjob event and that thread processes the event. But sometimes after eve= nt is offloaded to the worker thread we need to process the event in a differe= nt thread. To be able to to do it let's always set newstate/errmsg and then let whatev= er thread is first process it. Signed-off-by: Nikolay Shirokovskiy --- src/qemu/qemu_driver.c | 17 ++++------------- src/qemu/qemu_process.c | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 825bdd9..c06db3a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4118,9 +4118,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver, static void processBlockJobEvent(virQEMUDriverPtr driver, virDomainObjPtr vm, - const char *diskAlias, - int type, - int status) + const char *diskAlias) { virDomainDiskDefPtr disk; g_autoptr(qemuBlockJobData) job =3D NULL; @@ -4139,14 +4137,10 @@ processBlockJobEvent(virQEMUDriverPtr driver, } =20 if (!(job =3D qemuBlockJobDiskGetJob(disk))) { - VIR_DEBUG("creating new block job object for '%s'", diskAlias); - if (!(job =3D qemuBlockJobDiskNew(vm, disk, type, diskAlias))) - goto endjob; - job->state =3D QEMU_BLOCKJOB_STATE_RUNNING; + VIR_DEBUG("disk %s job not found", diskAlias); + goto endjob; } =20 - job->newstate =3D status; - qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); =20 endjob: @@ -4321,10 +4315,7 @@ static void qemuProcessEventHandler(void *data, void= *opaque) processEvent->action); break; case QEMU_PROCESS_EVENT_BLOCK_JOB: - processBlockJobEvent(driver, vm, - processEvent->data, - processEvent->action, - processEvent->status); + processBlockJobEvent(driver, vm, processEvent->data); break; case QEMU_PROCESS_EVENT_JOB_STATUS_CHANGE: processJobStatusChangeEvent(driver, vm, processEvent->data); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6422881..4d63e7d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -953,13 +953,19 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon G_GNUC_U= NUSED, if (!(disk =3D qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NU= LL))) goto cleanup; =20 - job =3D qemuBlockJobDiskGetJob(disk); + if (!(job =3D qemuBlockJobDiskGetJob(disk))) { + VIR_DEBUG("creating new block job object for '%s'", diskAlias); + if (!(job =3D qemuBlockJobDiskNew(vm, disk, type, diskAlias))) + goto cleanup; + job->state =3D QEMU_BLOCKJOB_STATE_RUNNING; + } =20 - if (job && job->synchronous) { - /* We have a SYNC API waiting for this event, dispatch it back */ - job->newstate =3D status; - VIR_FREE(job->errmsg); - job->errmsg =3D g_strdup(error); + job->newstate =3D status; + VIR_FREE(job->errmsg); + job->errmsg =3D g_strdup(error); + + /* We have a SYNC API waiting for this event, dispatch it back */ + if (job->synchronous) { virDomainObjBroadcast(vm); } else { /* there is no waiting SYNC API, dispatch the update to a thread */ @@ -969,8 +975,6 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon G_GNUC_UNU= SED, data =3D g_strdup(diskAlias); processEvent->data =3D data; processEvent->vm =3D virObjectRef(vm); - processEvent->action =3D type; - processEvent->status =3D status; =20 if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0)= { virObjectUnref(vm); --=20 1.8.3.1 From nobody Mon May 6 07:45:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1603201571; cv=none; d=zohomail.com; s=zohoarc; b=PGhlfJDwb/vYp9VzD0FtSOMoJjnjUEdCd0z4jIIeLCIdZKo0uQNipO3g3wGTmzCcyIToK5xhOrlK4DutybStBAlE0Q97tGSGq1E2cLgWkw5xFsIpWmhYal+mdMwBWCAM4j/5Y13V8A/XCACxfyIbmVIjIScV5xwpZKX0jlqEmkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603201571; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=xgis+4EER3B/OyV2+Wnvtl+G88hXBoAaoMtbJ2mgGzY=; b=CQHP4zkG3Ei/4bD6Il8iBPl/Z0ilLZdHN6vy3Kt34o7tgjrcSbpMDJcYsSK4kurrMnZ2e1rcEsK96G7ceTKvuT2mMSGXKQbAhQciLGwfHDllTA2yfMUhttJ6hLIqyN7WqDuHej/wAVIUg5n5k2Dkg03vAscgE9NZ33d8+mVMNYA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603201571737800.5048581936373; Tue, 20 Oct 2020 06:46:11 -0700 (PDT) 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-138--aWgaX5ZO1mz6wU1vj_zng-1; Tue, 20 Oct 2020 09:46: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 58ECF6414B; Tue, 20 Oct 2020 13:46:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29B265C22A; Tue, 20 Oct 2020 13:46:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E4D9D8C7C6; Tue, 20 Oct 2020 13:45:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09KDjlMN020400 for ; Tue, 20 Oct 2020 09:45:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B70F2022780; Tue, 20 Oct 2020 13:45:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51A442022793 for ; Tue, 20 Oct 2020 13:45:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AAEA9811E76 for ; Tue, 20 Oct 2020 13:45:44 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-237-I-SmkpAQOTaCRpEgoGOteQ-1; Tue, 20 Oct 2020 09:45:40 -0400 Received: from [10.28.15.159] (helo=vz7.sw.ru) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kUrxA-005MrG-SB for libvir-list@redhat.com; Tue, 20 Oct 2020 16:45:28 +0300 X-MC-Unique: -aWgaX5ZO1mz6wU1vj_zng-1 X-MC-Unique: I-SmkpAQOTaCRpEgoGOteQ-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 2/3] qemu: update legacy block job sync after offloading changes Date: Tue, 20 Oct 2020 16:44:08 +0300 Message-Id: <1603201449-610752-3-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1603201449-610752-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1603201449-610752-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now block job can be created by qemuProcessHandleBlockJob during reconnect before we start to synchronize block jobs. Also pending event can hold state change we see during sync and in this case we don't need to process the pen= ding event. Signed-off-by: Nikolay Shirokovskiy --- src/qemu/qemu_process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4d63e7d..ff79832 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8022,7 +8022,9 @@ qemuProcessRefreshLegacyBlockjob(void *payload, disk->mirrorJob =3D=3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT) jobtype =3D disk->mirrorJob; =20 - if (!(job =3D qemuBlockJobDiskNew(vm, disk, jobtype, jobname))) + /* Job can be created by block job event handler */ + if (!(job =3D qemuBlockJobDiskGetJob(disk)) && + !(job =3D qemuBlockJobDiskNew(vm, disk, jobtype, jobname))) return -1; =20 if (disk->mirror) { @@ -8030,6 +8032,10 @@ qemuProcessRefreshLegacyBlockjob(void *payload, (info->ready =3D=3D -1 && info->end =3D=3D info->cur)) { disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_READY; job->state =3D VIR_DOMAIN_BLOCK_JOB_READY; + + /* Reset pending event if we already in the state of event */ + if (job->newstate =3D=3D VIR_DOMAIN_BLOCK_JOB_READY) + job->newstate =3D -1; } =20 /* Pre-blockdev block copy labelled the chain of the mirrored devi= ce --=20 1.8.3.1 From nobody Mon May 6 07:45:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1603201565; cv=none; d=zohomail.com; s=zohoarc; b=ix3EfaCs99yFXaBFHADgE4jEKkMdk48dLY5UbYOfaQPwgWYkAh+XW4xeTBw9w9+TJHOuJ7FsoK3DYs4JfxPShzqypKGdwhGRipZ2masCE4WArUV2ahiEJduL6U3w4AyG/yWkWjx/hSG9lXL3UNFVOu418yKD4FVRWtdpWvXmIGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603201565; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=sBt9Faihm2o3W0n7iTfgjkaiD2xzjdKDKndeKD4v3mM=; b=aBtLu7I0hGgiiWJFH18/S/u1WABxfeCYPb3id57RVJf9Pf7DquonmeMm83ADAI2tYoRRw9c7gW5WlTy7HKQZuOzU8Ixvj8hpxeWseoypoRPizREKN4EpMFIauuHX5yDWAqh4dU/ZXt8mh99jgc/Y1ytebVrhbnWtBQoDPVUlhZk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603201564517112.97850891047494; Tue, 20 Oct 2020 06:46:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-387-ZYaEixQnPhy5ZnzQQ9zF4w-1; Tue, 20 Oct 2020 09:45:57 -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 AAF2264143; Tue, 20 Oct 2020 13:45:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 44CFA10842D7; Tue, 20 Oct 2020 13:45:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 61B058C7B9; Tue, 20 Oct 2020 13:45:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09KDjlMs020399 for ; Tue, 20 Oct 2020 09:45:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id E4FAF2166B28; Tue, 20 Oct 2020 13:45:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFE422166B27 for ; Tue, 20 Oct 2020 13:45:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A960F803526 for ; Tue, 20 Oct 2020 13:45:44 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-237-PatmZ21qPkSgODLDdzkA_g-1; Tue, 20 Oct 2020 09:45:40 -0400 Received: from [10.28.15.159] (helo=vz7.sw.ru) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kUrxA-005MrG-TB for libvir-list@redhat.com; Tue, 20 Oct 2020 16:45:28 +0300 X-MC-Unique: ZYaEixQnPhy5ZnzQQ9zF4w-1 X-MC-Unique: PatmZ21qPkSgODLDdzkA_g-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 3/3] qemu: sync backing chain update in virDomainGetBlockJobInfo Date: Tue, 20 Oct 2020 16:44:09 +0300 Message-Id: <1603201449-610752-4-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1603201449-610752-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1603201449-610752-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some mgmt still use polling for block job completion. After job completion = the job failure/success is infered by inspecting domain xml. With legacy block = job processing this does not always work. The issue deals with how libvirt processes events. If no other thread is waiting for blockjob event then event processing if offloaded to worker thr= ead. If now virDomainGetBlockJobInfo API is called then as block job is already dismissed in legacy scheme the API returns 0 but backing chain is not yet updated as processing yet be done in worker thread. Now mgmt checks backing chain right after return from the API call and detects error. This happens quite often under load. I guess because of we have only one wo= rker thread for all the domains. The event delivery is synchronous in qemu and block job completed event is = sent in job finalize step so if block job is absent the event is already deliver= ed and we just need to process it. Signed-off-by: Nikolay Shirokovskiy --- src/qemu/qemu_driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c06db3a..7189a29 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14672,8 +14672,15 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, ret =3D qemuMonitorGetBlockJobInfo(qemuDomainGetMonitor(vm), job->name= , &rawInfo); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -1; - if (ret <=3D 0) + if (ret < 0) + goto endjob; + if (ret =3D=3D 0) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) + qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); goto endjob; + } =20 if (qemuBlockJobInfoTranslate(&rawInfo, info, disk, flags & VIR_DOMAIN_BLOCK_JOB_INFO_BANDWI= DTH_BYTES) < 0) { --=20 1.8.3.1