From nobody Mon May 6 00:14:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617899830; cv=none; d=zohomail.com; s=zohoarc; b=aOvVQzR1Mmwva9tkSdEyzy8zgnTD+w0L6pCe9cY4w3pPlvpKeiUH3PihIqW4j9QBRRIixDMr9jiEBjciRGCCJiQL6uYlZq1dXXnEVJKT7M705+csu0okPf9E+BtuCWEGBL56MG5nEAe3CAA8dh3NV+AQ7fWoA5QLrA4T9WTnye8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617899830; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XPUgI0EWYJX9LLRwnrV0db0/K/q7sIiYNAYue3pPA+k=; b=l7ExR9Nd861Xn60HvvYMeJ3+7Mjmplp+nunsTrUt/fRFQqFkSlTwGogPCrK0W20RDGzcPmDv9oSBoFCjg5fn2bEOtOHiPCMs2H4SDAz6/ozDWwFMYu0LuUgsc9kA8kPCApSAeIWxVAstVnr0Vf2qZE5lkqVbwaRGr3GMGiBzO4k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617899830507734.0527527927512; Thu, 8 Apr 2021 09:37:10 -0700 (PDT) Received: from localhost ([::1]:35082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUXeX-0004FO-EE for importer@patchew.org; Thu, 08 Apr 2021 12:37:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUXWy-0006Eu-8T for qemu-devel@nongnu.org; Thu, 08 Apr 2021 12:29:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUXOs-00029E-T0 for qemu-devel@nongnu.org; Thu, 08 Apr 2021 12:21: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-137-NFJpFezDNwO5jkaqIwUUqg-1; Thu, 08 Apr 2021 12:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7462100A628; Thu, 8 Apr 2021 16:20:52 +0000 (UTC) Received: from localhost (ovpn-114-123.ams2.redhat.com [10.36.114.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74D3662A1B; Thu, 8 Apr 2021 16:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617898858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XPUgI0EWYJX9LLRwnrV0db0/K/q7sIiYNAYue3pPA+k=; b=TqD1xnG9F8Kvf5AFVZ8UmhjedOcHzJW7yv5taXB8p1oHMbc0E5u7QFRPCgNgSQfj84eIjw sqS01QpkYlRmi94lmE+/m8z9kFjHnldNuCDQkSm+8EDi0T3ezntO8Z328uIFtW711VF+yW gtrEzM2JYLUUHb4jPogjfr5M5t1UbeY= X-MC-Unique: NFJpFezDNwO5jkaqIwUUqg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH for-6.0? 1/3] job: Add job_wait_unpaused() for block-job-complete Date: Thu, 8 Apr 2021 18:20:37 +0200 Message-Id: <20210408162039.242670-2-mreitz@redhat.com> In-Reply-To: <20210408162039.242670-1-mreitz@redhat.com> References: <20210408162039.242670-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@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=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" block-job-complete can only be applied when the job is READY, not when it is on STANDBY (ready, but paused). Draining a job technically pauses it (which makes a READY job enter STANDBY), and ending the drained section does not synchronously resume it, but only schedules the job, which will then be resumed. So attempting to complete a job immediately after a drained section may sometimes fail. That is bad at least because users cannot really work nicely around this: A job may be paused and resumed at any time, so waiting for the job to be in the READY state and then issuing a block-job-complete poses a TOCTTOU problem. The only way around it would be to issue block-job-complete until it no longer fails due to the job being in the STANDBY state, but that would not be nice. We can solve the problem by allowing block-job-complete to be invoked on jobs that are on STANDBY, if that status is the result of a drained section (not because the user has paused the job), and that section has ended. That is, if the job is on STANDBY, but scheduled to be resumed. Perhaps we could actually just directly allow this, seeing that mirror is the only user of ready/complete, and that mirror_complete() could probably work under the given circumstances, but there may be many side effects to consider. It is simpler to add a function job_wait_unpaused() that waits for the job to be resumed (under said circumstances), and to make qmp_block_job_complete() use it to delay job_complete() until then. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1945635 Signed-off-by: Max Reitz Acked-by: John Snow Reviewed-by: John Snow --- include/qemu/job.h | 15 +++++++++++++++ blockdev.c | 3 +++ job.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/include/qemu/job.h b/include/qemu/job.h index efc6fa7544..cf3082b6d7 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -563,4 +563,19 @@ void job_dismiss(Job **job, Error **errp); */ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error *= *errp); =20 +/** + * If the job has been paused because of a drained section, and that + * section has ended, wait until the job is resumed. + * + * Return 0 if the job is not paused, or if it has been successfully + * resumed. + * Return an error if the job has been paused in such a way that + * waiting will not resume it, i.e. if it has been paused by the user, + * or if it is still drained. + * + * Callers must be in the home AioContext and hold the AioContext lock + * of job->aio_context. + */ +int job_wait_unpaused(Job *job, Error **errp); + #endif diff --git a/blockdev.c b/blockdev.c index a57590aae4..c0cc2fa364 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3414,6 +3414,9 @@ void qmp_block_job_complete(const char *device, Error= **errp) return; } =20 + if (job_wait_unpaused(&job->job, errp) < 0) { + return; + } trace_qmp_block_job_complete(job); job_complete(&job->job, errp); aio_context_release(aio_context); diff --git a/job.c b/job.c index 289edee143..1ea30fd294 100644 --- a/job.c +++ b/job.c @@ -1023,3 +1023,45 @@ int job_finish_sync(Job *job, void (*finish)(Job *, = Error **errp), Error **errp) job_unref(job); return ret; } + +int job_wait_unpaused(Job *job, Error **errp) +{ + /* + * Only run this function from the main context, because this is + * what we need, and this way we do not have to think about what + * happens if the user concurrently pauses the job from the main + * monitor. + */ + assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); + + /* + * Quick path (e.g. so we do not get an error if pause_count > 0 + * but the job is not even paused) + */ + if (!job->paused) { + return 0; + } + + /* If the user has paused the job, waiting will not help */ + if (job->user_paused) { + error_setg(errp, "Job '%s' has been paused by the user", job->id); + return -EBUSY; + } + + /* Similarly, if the job is still drained, waiting will not help eithe= r */ + if (job->pause_count > 0) { + error_setg(errp, "Job '%s' is blocked and cannot be unpaused", job= ->id); + return -EBUSY; + } + + /* + * This function is specifically for waiting for a job to be + * resumed after a drained section. Ending the drained section + * includes a job_enter(), which schedules the job loop to be run, + * and once it does, job->paused will be cleared. Therefore, we + * do not need to invoke job_enter() here. + */ + AIO_WAIT_WHILE(job->aio_context, job->paused); + + return 0; +} --=20 2.29.2 From nobody Mon May 6 00:14:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617899873; cv=none; d=zohomail.com; s=zohoarc; b=gytrnSHHOkBltiWHV73nPEsh0Myl3FyzDX5tCy+JtPASzGQsTP1SVut9SUz6+AAUM+bvDDgAR5j2A29K8409qDU6RtF9kk3Xciot1XJpO1MSl706eDWZFnwOtJqMAhL8XkXV0zf/ZZCPNLhZoTk2xzk2h8x9doqw4eg4BOgK1b4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617899873; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ozyvUMwTUWB5EMkecsm7lCgbLvNzDma8A7uIYIHcNGo=; b=MY1YieAAwnzz9296ChX+/gZWlAQPV3duoMTSwssRsEgmeI3hXU7Gl/1den7Nzu7RliugaKSBMW9mISR2VSra/skpRQaRShHwbWUEueCi6ojVHWJrJTUsr32V6LVcaD80tSUzb+PqGPx5n4iHySEukrPftA6aU/Gcf40Zns7Lv0k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617899873669830.7688380071818; Thu, 8 Apr 2021 09:37:53 -0700 (PDT) Received: from localhost ([::1]:37976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUXfE-0005VS-RW for importer@patchew.org; Thu, 08 Apr 2021 12:37:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUXWz-0006Eu-2L for qemu-devel@nongnu.org; Thu, 08 Apr 2021 12:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52950) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUXOs-00029B-LO for qemu-devel@nongnu.org; Thu, 08 Apr 2021 12:21: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-515-aIwom1PwMmulzz2iOlFpAg-1; Thu, 08 Apr 2021 12:20:56 -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 29B7EA0CAF; Thu, 8 Apr 2021 16:20:55 +0000 (UTC) Received: from localhost (ovpn-114-123.ams2.redhat.com [10.36.114.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C14695C261; Thu, 8 Apr 2021 16:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617898858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ozyvUMwTUWB5EMkecsm7lCgbLvNzDma8A7uIYIHcNGo=; b=UgT1Vy0zpHOa7eram7kgyi23ZepYaUpXZeCF1y4qywkY+LdyZOK3PpIqf9uKfbEI8Dmya6 lsBhYgZRGsIybYHGugHLLLiRMvAMgjzx5Ktq8vgvA9lZzU3crZk5a+N69naFBoDbs68GQm pnaZ9ravpIUnIOLnxRryR1JvMZpLGmQ= X-MC-Unique: aIwom1PwMmulzz2iOlFpAg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH for-6.0? 2/3] test-blockjob: Test job_wait_unpaused() Date: Thu, 8 Apr 2021 18:20:38 +0200 Message-Id: <20210408162039.242670-3-mreitz@redhat.com> In-Reply-To: <20210408162039.242670-1-mreitz@redhat.com> References: <20210408162039.242670-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@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=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Create a job that remains on STANDBY after a drained section, and see that invoking job_wait_unpaused() will get it unstuck. Signed-off-by: Max Reitz Acked-by: John Snow --- tests/unit/test-blockjob.c | 140 +++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/tests/unit/test-blockjob.c b/tests/unit/test-blockjob.c index 7519847912..b7736e298d 100644 --- a/tests/unit/test-blockjob.c +++ b/tests/unit/test-blockjob.c @@ -16,6 +16,7 @@ #include "block/blockjob_int.h" #include "sysemu/block-backend.h" #include "qapi/qmp/qdict.h" +#include "iothread.h" =20 static const BlockJobDriver test_block_job_driver =3D { .job_driver =3D { @@ -375,6 +376,144 @@ static void test_cancel_concluded(void) cancel_common(s); } =20 +/* (See test_yielding_driver for the job description) */ +typedef struct YieldingJob { + BlockJob common; + bool should_complete; +} YieldingJob; + +static void yielding_job_complete(Job *job, Error **errp) +{ + YieldingJob *s =3D container_of(job, YieldingJob, common.job); + s->should_complete =3D true; + job_enter(job); +} + +static int coroutine_fn yielding_job_run(Job *job, Error **errp) +{ + YieldingJob *s =3D container_of(job, YieldingJob, common.job); + + job_transition_to_ready(job); + + while (!s->should_complete) { + job_yield(job); + } + + return 0; +} + +/* + * This job transitions immediately to the READY state, and then + * yields until it is to complete. + */ +static const BlockJobDriver test_yielding_driver =3D { + .job_driver =3D { + .instance_size =3D sizeof(YieldingJob), + .free =3D block_job_free, + .user_resume =3D block_job_user_resume, + .run =3D yielding_job_run, + .complete =3D yielding_job_complete, + }, +}; + +/* + * Test that job_wait_unpaused() can get jobs from a paused state to + * a running state so that job_complete() can be applied (assuming the + * pause occurred due to a drain that has already been lifted). + * (This is what QMP's block-job-complete does so it can be executed + * even immediately after some other operation instated and lifted a + * drain.) + * + * To do this, run YieldingJob in an IO thread, get it into the READY + * state, then have a drained section. Before ending the section, + * acquire the context so the job will not be entered and will thus + * remain on STANDBY. + * + * Invoking job_complete() then will fail. + * + * However, job_wait_unpaused() should see the job is to be resumed, + * wait for it to be resumed, and then we can invoke job_complete() + * without error. + * + * Note that on the QMP interface, it is impossible to lock an IO + * thread before a drained section ends. In practice, the + * bdrv_drain_all_end() and the aio_context_acquire() will be + * reversed. However, that makes for worse reproducibility here: + * Sometimes, the job would no longer be in STANDBY then but already + * be started. We cannot prevent that, because the IO thread runs + * concurrently. We can only prevent it by taking the lock before + * ending the drained section, so we do that. + * + * (You can reverse the order of operations and most of the time the + * test will pass, but sometimes the assert(status =3D=3D STANDBY) will + * fail.) + */ +static void test_complete_in_standby(void) +{ + BlockBackend *blk; + IOThread *iothread; + AioContext *ctx; + Job *job; + BlockJob *bjob; + Error *local_err =3D NULL; + + /* Create a test drive, move it to an IO thread */ + blk =3D create_blk(NULL); + iothread =3D iothread_new(); + + ctx =3D iothread_get_aio_context(iothread); + blk_set_aio_context(blk, ctx, &error_abort); + + /* Create our test job */ + bjob =3D mk_job(blk, "job", &test_yielding_driver, true, + JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS); + job =3D &bjob->job; + assert(job->status =3D=3D JOB_STATUS_CREATED); + + /* Wait for the job to become READY */ + job_start(job); + aio_context_acquire(ctx); + AIO_WAIT_WHILE(ctx, job->status !=3D JOB_STATUS_READY); + aio_context_release(ctx); + + /* Begin the drained section, pausing the job */ + bdrv_drain_all_begin(); + assert(job->status =3D=3D JOB_STATUS_STANDBY); + /* Lock the IO thread to prevent the job from being run */ + aio_context_acquire(ctx); + /* This will schedule the job to resume it */ + bdrv_drain_all_end(); + + /* But the job cannot run, so it will remain on standby */ + assert(job->status =3D=3D JOB_STATUS_STANDBY); + + /* A job on standby cannot be completed */ + job_complete(job, &local_err); + assert(local_err !=3D NULL); + error_free(local_err); + local_err =3D NULL; + + /* + * But waiting for it and then completing it should work. + * (This is what qmp_block_job_complete() does.) + */ + job_wait_unpaused(job, &error_abort); + job_complete(job, &error_abort); + + /* The test is done now, clean up. */ + job_finish_sync(job, NULL, &error_abort); + assert(job->status =3D=3D JOB_STATUS_PENDING); + + job_finalize(job, &error_abort); + assert(job->status =3D=3D JOB_STATUS_CONCLUDED); + + job_dismiss(&job, &error_abort); + + destroy_blk(blk); + aio_context_release(ctx); + iothread_join(iothread); +} + int main(int argc, char **argv) { qemu_init_main_loop(&error_abort); @@ -389,5 +528,6 @@ int main(int argc, char **argv) g_test_add_func("/blockjob/cancel/standby", test_cancel_standby); g_test_add_func("/blockjob/cancel/pending", test_cancel_pending); g_test_add_func("/blockjob/cancel/concluded", test_cancel_concluded); + g_test_add_func("/blockjob/complete_in_standby", test_complete_in_stan= dby); return g_test_run(); } --=20 2.29.2 From nobody Mon May 6 00:14:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617899579; cv=none; d=zohomail.com; s=zohoarc; b=O/Rd17eN6guRblMPQwA393oxlKgwIbgMXyd9hXCaevSnGb6H40uwKSGxAY8vjrpshI0U8wvczhg77BsktXUkf+2/YxLPH3RpuUIB+tRDi5GElfzdn9tGQcx8Os+YHCKthyaA8ABgzy8Ly2axOfDdJ8BGUMXFw1BnvunZQ1poGvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617899579; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=joSw4jwTLU8DYiFScDGknK1n4nE5TiMPrAyJTZ43A0M=; b=CC5hQqYaW4dNqxfJqhxPO7hxKqfSYKm4TgE/i2vNyymdBVzxTRSxn//kuTsiDU7HpSj+7dZ41xO33Sluu7sqlF7qjJYGhsXs/hHHa3SgUTaIE32FJsYlGCyQlV9mtsmd3igLh5Zqy4u6cvxYZcm9NTr/R5PHxRnINqGYrcf9sbY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617899579891460.83363968293315; Thu, 8 Apr 2021 09:32:59 -0700 (PDT) Received: from localhost ([::1]:55040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUXaV-0000Gc-4j for importer@patchew.org; Thu, 08 Apr 2021 12:32:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUXWw-0006Eu-TG for qemu-devel@nongnu.org; Thu, 08 Apr 2021 12:29:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33042) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUXOv-0002BF-2A for qemu-devel@nongnu.org; Thu, 08 Apr 2021 12:21:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-q_P27Qx3NK6vtYXToEb-vg-1; Thu, 08 Apr 2021 12:20:58 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59337107ACC7; Thu, 8 Apr 2021 16:20:57 +0000 (UTC) Received: from localhost (ovpn-114-123.ams2.redhat.com [10.36.114.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8C4519701; Thu, 8 Apr 2021 16:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617898860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=joSw4jwTLU8DYiFScDGknK1n4nE5TiMPrAyJTZ43A0M=; b=HZwGe5jo3E72nxP9tKg9vFyz/16FZIT44lGh9IQqt75yff+d0YJFCBJbncJ2q5NNNaUQa4 RBbC56b8FM7TkvwsQQervmeIypRmMYBx06bkNAEX/AF4S8OXN3MyfCPFgsSO56b9g+/EHl 77PJR8heLG2EuK7MdN3rBICQqVVlK28= X-MC-Unique: q_P27Qx3NK6vtYXToEb-vg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH for-6.0? 3/3] iotests/041: block-job-complete on user-paused job Date: Thu, 8 Apr 2021 18:20:39 +0200 Message-Id: <20210408162039.242670-4-mreitz@redhat.com> In-Reply-To: <20210408162039.242670-1-mreitz@redhat.com> References: <20210408162039.242670-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@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=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Expand test_pause() to check what happens when issuing block-job-complete on a job that is on STANDBY because it has been paused by the user. (This should be an error, and in particular not hang job_wait_unpaused().) Signed-off-by: Max Reitz Acked-by: John Snow --- tests/qemu-iotests/041 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 5cc02b24fc..d2c9669741 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -120,7 +120,18 @@ class TestSingleDrive(iotests.QMPTestCase): result =3D self.vm.qmp('block-job-resume', device=3D'drive0') self.assert_qmp(result, 'return', {}) =20 - self.complete_and_wait() + self.wait_ready() + + # Check that a job on STANDBY cannot be completed + self.pause_job('drive0') + result =3D self.vm.qmp('block-job-complete', device=3D'drive0') + self.assert_qmp(result, 'error/desc', + "Job 'drive0' has been paused by the user") + + result =3D self.vm.qmp('block-job-resume', device=3D'drive0') + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait(wait_ready=3DFalse) self.vm.shutdown() self.assertTrue(iotests.compare_images(test_img, target_img), 'target image does not match source after mirrorin= g') --=20 2.29.2