From nobody Mon Feb 9 02:51:01 2026 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