From nobody Sun Feb 8 15:47:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1652196485; cv=none; d=zohomail.com; s=zohoarc; b=ZLAOfDhGdCUQD/iHG5Ts4/65dtsgNn2Cx6Cdwy/wwBY69Rdo0iGuiVEZ+qFaEXs1m7lAlDXlfiBY0dPDa0wLJxPeTjSZkXGmE3rzh8pR1AQerahc5kkbMSTgLkYgOyxXi28VdmBKoEBaCa0QelhcP5wmNCLfnHt+3NoEUETWRIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196485; 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=7Kt4APOzBJar6Hn4MxIJ1CuE2d/dOYEeWfd7ZesRofI=; b=l3LJo/odDvsx43eka77CNFNJ9xonRjs5UEdMYd42yOKugfqVxuAClQFIgEq1K1y98soBBLPXfAgi49A3Cj1DLki80Q1qxYxG1MWFTxkRCkbBcfeMuHib2F+hokFrwZa3LS5AS49zC4Iq9Ba02K1mHdXGeDk2BinWIgXQ9wX49vM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196485598512.8362980837642; Tue, 10 May 2022 08:28:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-cVYRWnRZPU2sl4LQ1TwElg-1; Tue, 10 May 2022 11:23:23 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1DFC91C161B6; Tue, 10 May 2022 15:22:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0928615088BC; Tue, 10 May 2022 15:22:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 92686194E11A; Tue, 10 May 2022 15:22:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4E9F8194707F for ; Tue, 10 May 2022 15:21:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2D0B0C28100; Tue, 10 May 2022 15:21:49 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5DFFC15D58 for ; Tue, 10 May 2022 15:21:48 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A7225244615; Tue, 10 May 2022 17:21:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196484; 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=7Kt4APOzBJar6Hn4MxIJ1CuE2d/dOYEeWfd7ZesRofI=; b=TBUxbD1BKLBWiRbwcGGeHkJ1Yziz7jRwNTS+Wv3Y+bdBjg0NzjKslLzWj/3AVKvT8uvwfw 34NflyIUxPfZntH9TK9d1jxR8lxuIlazGDMg4dUceD6XMgNicIfLibBwwv7cMr9METQXPM 6flAc7XiWD+oyHGDExPXWxh0cjK/4+M= X-MC-Unique: cVYRWnRZPU2sl4LQ1TwElg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 41/80] qemu: Ignore missing memory statistics in query-migrate Date: Tue, 10 May 2022 17:21:02 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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) X-ZM-MESSAGEID: 1652196486361100001 Content-Type: text/plain; charset="utf-8" We want to use query-migrate QMP command to check the current migration state when reconnecting to active domains, but the reply we get to this command may not contain any statistics at all if called on the destination host. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 88 +++++++++++++++++------------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3a497dceae..df3fdfe4fb 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3249,56 +3249,52 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue = *reply, case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER: case QEMU_MONITOR_MIGRATION_STATUS_DEVICE: ram =3D virJSONValueObjectGetObject(ret, "ram"); - if (!ram) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but no RAM info was se= t")); - return -1; - } + if (ram) { + if (virJSONValueObjectGetNumberUlong(ram, "transferred", + &stats->ram_transferred) = < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'transferr= ed' " + "data was missing")); + return -1; + } + if (virJSONValueObjectGetNumberUlong(ram, "remaining", + &stats->ram_remaining) < = 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'remaining= ' " + "data was missing")); + return -1; + } + if (virJSONValueObjectGetNumberUlong(ram, "total", + &stats->ram_total) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'total' " + "data was missing")); + return -1; + } =20 - if (virJSONValueObjectGetNumberUlong(ram, "transferred", - &stats->ram_transferred) < 0)= { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'transferred' " - "data was missing")); - return -1; - } - if (virJSONValueObjectGetNumberUlong(ram, "remaining", - &stats->ram_remaining) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'remaining' " - "data was missing")); - return -1; - } - if (virJSONValueObjectGetNumberUlong(ram, "total", - &stats->ram_total) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'total' " - "data was missing")); - return -1; - } + if (virJSONValueObjectGetNumberDouble(ram, "mbps", &mbps) =3D= =3D 0 && + mbps > 0) { + /* mpbs from QEMU reports Mbits/s (M as in 10^6 not Mi as = 2^20) */ + stats->ram_bps =3D mbps * (1000 * 1000 / 8); + } =20 - if (virJSONValueObjectGetNumberDouble(ram, "mbps", &mbps) =3D=3D 0= && - mbps > 0) { - /* mpbs from QEMU reports Mbits/s (M as in 10^6 not Mi as 2^20= ) */ - stats->ram_bps =3D mbps * (1000 * 1000 / 8); + if (virJSONValueObjectGetNumberUlong(ram, "duplicate", + &stats->ram_duplicate) = =3D=3D 0) + stats->ram_duplicate_set =3D true; + ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal", + &stats->ram_norm= al)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal-byt= es", + &stats->ram_norm= al_bytes)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-page= s-rate", + &stats->ram_dirt= y_rate)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "page-size", + &stats->ram_page= _size)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-sync= -count", + &stats->ram_iter= ation)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "postcopy-r= equests", + &stats->ram_post= copy_reqs)); } =20 - if (virJSONValueObjectGetNumberUlong(ram, "duplicate", - &stats->ram_duplicate) =3D=3D= 0) - stats->ram_duplicate_set =3D true; - ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal", - &stats->ram_normal)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal-bytes", - &stats->ram_normal_b= ytes)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-pages-ra= te", - &stats->ram_dirty_ra= te)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "page-size", - &stats->ram_page_siz= e)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-sync-cou= nt", - &stats->ram_iteratio= n)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "postcopy-reque= sts", - &stats->ram_postcopy= _reqs)); - disk =3D virJSONValueObjectGetObject(ret, "disk"); if (disk) { rc =3D virJSONValueObjectGetNumberUlong(disk, "transferred", --=20 2.35.1