From nobody Sun Feb 8 20:13:33 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; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1607094567; cv=none; d=zohomail.com; s=zohoarc; b=oAKgnROh4m/kfJBcPxWeFBZIFJSr9c7N5Rc5z/tDqZqPDZitusYRsJoejOhk6O2lz9n9v7QFQ9cDtwjySLdP+eOwauWGaAGd4li/hRyukajAz84H9WPeJjgx8HmkJ2rws7gIEP9bZAvneG+KXV9K9iEgSJuSmip0E0ATGS4zFEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607094567; 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=VbiNYvX2IoRtLA8g0W3ERVZHgLU8JlYCgEspZSevQG0=; b=AaebqCcdydn9zJS77Lkw1Co3jzf1PYGus0m9WQNyGSprsoMgc8YSN+cHRlFlxCYi7C7LyvI8CwNdlseDGfEECTji0YBMKXE8Jl/QI7VJ6WqE6aAD2k0WX7fTLaq3LeUasjaGoj1nw7f/o27dp1JI6OUggC4dEyFeUMjCT+C1Ibk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 1607094567206162.61661110591137; Fri, 4 Dec 2020 07:09:27 -0800 (PST) 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-468-hh9eA2n2PSysZur2DvkGkg-1; Fri, 04 Dec 2020 10:09:23 -0500 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 49F36180A094; Fri, 4 Dec 2020 15:09:17 +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 19FE327C5E; Fri, 4 Dec 2020 15:09:17 +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 CF6F6180954D; Fri, 4 Dec 2020 15:09:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B4F8EVR031272 for ; Fri, 4 Dec 2020 10:08:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 53E965D9CA; Fri, 4 Dec 2020 15:08:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9913C5D9D7 for ; Fri, 4 Dec 2020 15:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607094565; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VbiNYvX2IoRtLA8g0W3ERVZHgLU8JlYCgEspZSevQG0=; b=LLgTcknBoA9ZC+XHJaEyb30M6YcAiFPuG+kXAhdzk8WGC9RbUNZw8GOzUYObCXDPLPj1tB ++GBCbQKFXAmU25J+aluWJfr2mVDXRYdUPuW77OqTWMg0abLD6wokwrbJy4xGSFwjR43Fs IBc19lxgWhMyymxHU4+4zJ2viFYPfyY= X-MC-Unique: hh9eA2n2PSysZur2DvkGkg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] qemuMonitorBlockJobInfo: Store 'ready' and 'ready_present' separately Date: Fri, 4 Dec 2020 16:07:58 +0100 Message-Id: <570ec93798f82eb551aaab8a4eb11f625e6c62e1.1607094319.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Don't make the logic confusing by representing the 3 options using an integer with negative values. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 9 +++++---- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 8 ++------ src/qemu/qemu_process.c | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4fd70ed300..800f98e474 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14650,17 +14650,18 @@ qemuBlockJobInfoTranslate(qemuMonitorBlockJobInfo= Ptr rawInfo, * and end are zero, in which case qemu hasn't started the * job yet. */ if (!info->cur && !info->end) { - if (rawInfo->ready > 0) { - info->cur =3D info->end =3D 1; - } else if (!rawInfo->ready) { + if (rawInfo->ready_present) { info->end =3D 1; + if (rawInfo->ready) + info->cur =3D 1; } } /* If qemu reports that it's not ready yet don't make the job go to * cur =3D=3D end as some apps wrote code polling this instead of wait= ing for * the ready event */ - if (rawInfo->ready =3D=3D 0 && + if (rawInfo->ready_present && + !rawInfo->ready && info->cur =3D=3D info->end && info->cur > 0) info->cur -=3D 1; diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 49be2d5412..a2f28f9492 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1117,7 +1117,8 @@ struct _qemuMonitorBlockJobInfo { unsigned long long bandwidth; /* in bytes/s */ virDomainBlockJobCursor cur; virDomainBlockJobCursor end; - int ready; /* -1 if unknown, 0 if not ready, 1 if ready */ + bool ready_present; + bool ready; }; GHashTable *qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4db00e284a..94e482cc97 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5049,7 +5049,6 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJob= s, qemuMonitorBlockJobInfoPtr info =3D NULL; const char *device; const char *type; - bool ready; if (!(device =3D virJSONValueObjectGetString(entry, "device"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -5067,9 +5066,6 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJob= s, return -1; } - /* assume we don't know the state */ - info->ready =3D -1; - if (!(type =3D virJSONValueObjectGetString(entry, "type"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("entry was missing 'type'")); @@ -5104,8 +5100,8 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJob= s, return -1; } - if (virJSONValueObjectGetBoolean(entry, "ready", &ready) =3D=3D 0) - info->ready =3D ready; + if (virJSONValueObjectGetBoolean(entry, "ready", &info->ready) =3D=3D = 0) + info->ready_present =3D true; return 0; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9d83825190..cbd29d867b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8176,8 +8176,8 @@ qemuProcessRefreshLegacyBlockjob(void *payload, return -1; if (disk->mirror) { - if (info->ready =3D=3D 1 || - (info->ready =3D=3D -1 && info->end =3D=3D info->cur)) { + if ((!info->ready_present && info->end =3D=3D info->cur) || + info->ready) { disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_READY; job->state =3D VIR_DOMAIN_BLOCK_JOB_READY; } --=20 2.28.0