From nobody Sun Feb 8 17:47:40 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=1609941859; cv=none; d=zohomail.com; s=zohoarc; b=BwkF56Ue7VcCZf6L8b2VRG6PpLCuDtU+YNJ7Hqt3I6oODimHW65fiHtacB/ZmatNZV55GgORwgBDsFL3J5n/1eGAe9n+DeCMq0IPaMt+iadoTJt3dHdQZTG7pU8QY4qqDFNU6GyTYQMFPmQ62tAFaA9MejY4toF3FaGd2+XO7eQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609941859; 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=ApMD8LAG3yg/texCVQZ7Duwkhr4tG1Xa6icayiV+UAI=; b=bDWg8ZdtGfdGeA4wEGL4SMLYANvo0cS1VSbDEjpgMRt0ASK8UNRMiyxspJ2qnlmVU4E6B4ypFh1uLrAhTmlTXwSRZywTNhKjfPj/ZSC+XhhLV5lT13jcbOzGDFiNhx0qXFRN9cnBYwtCeE2Eufp7YOH54tf56AMeyKnpAXUfpEM= 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 1609941859470572.2705962375278; Wed, 6 Jan 2021 06:04:19 -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-294-trP7UeWbNamlEz29xXSj2Q-1; Wed, 06 Jan 2021 09:04:14 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 520E4DF8A5; Wed, 6 Jan 2021 14:04:08 +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 3149F5D9D2; Wed, 6 Jan 2021 14:04:08 +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 F14A15002F; Wed, 6 Jan 2021 14:04:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106E3oOZ031332 for ; Wed, 6 Jan 2021 09:03:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id E8EA71840B; Wed, 6 Jan 2021 14:03:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39D2A37A0 for ; Wed, 6 Jan 2021 14:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609941857; 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=ApMD8LAG3yg/texCVQZ7Duwkhr4tG1Xa6icayiV+UAI=; b=b5ylU9GBOfOTIaELtdmmOashKeaavPRgMlbT2K1QroHNWmcZQdm62cVoHIUmItvRO/4aoD ZKqg56o0UcLPjOuZk5/b3L18KchpvrozjnZ7WoQuGphoORDB76AIgDm/Oo2WIqZJKsE68H VS4enykHSyAD+l4jOHS+gWC2fh/mxZw= X-MC-Unique: trP7UeWbNamlEz29xXSj2Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/12] qemuMonitorSetMigrationCapabilities: Take double pointer for @caps Date: Wed, 6 Jan 2021 15:03:33 +0100 Message-Id: <183f278bc49ca0bcde00f294d52006efd7ef2c93.1609941694.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.14 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" This allows simplification of the callers. Signed-off-by: Peter Krempa --- src/qemu/qemu_migration_params.c | 13 ++++--------- src/qemu/qemu_monitor.c | 11 +++-------- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 5 ++--- src/qemu/qemu_monitor_json.h | 2 +- tests/qemumonitorjsontest.c | 3 +-- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index d1d59aeb01..8c019bf2ce 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -803,7 +803,6 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver, g_autoptr(virJSONValue) caps =3D NULL; qemuMigrationParam xbzrle =3D QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE; int ret =3D -1; - int rc; if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; @@ -819,12 +818,9 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver, if (!(caps =3D qemuMigrationCapsToJSON(priv->migrationCaps, migPar= ams->caps))) goto cleanup; - if (virJSONValueArraySize(caps) > 0) { - rc =3D qemuMonitorSetMigrationCapabilities(priv->mon, caps); - caps =3D NULL; - if (rc < 0) - goto cleanup; - } + if (virJSONValueArraySize(caps) > 0 && + qemuMonitorSetMigrationCapabilities(priv->mon, &caps) < 0) + goto cleanup; } /* If QEMU is too old to support xbzrle-cache-size migration parameter, @@ -1389,8 +1385,7 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; - rc =3D qemuMonitorSetMigrationCapabilities(priv->mon, json); - json =3D NULL; + rc =3D qemuMonitorSetMigrationCapabilities(priv->mon, &json); if (qemuDomainObjExitMonitor(driver, vm) < 0) return -1; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a81cd5fff5..8b1f90b363 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3877,22 +3877,17 @@ qemuMonitorGetMigrationCapabilities(qemuMonitorPtr = mon, * @mon: Pointer to the monitor object. * @caps: Migration capabilities. * - * The @caps object is consumed and should not be referenced by the caller - * after this function returns. + * The @caps object is consumed cleared. * * Returns 0 on success, -1 on error. */ int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon, - virJSONValuePtr caps) + virJSONValuePtr *caps) { - QEMU_CHECK_MONITOR_GOTO(mon, error); + QEMU_CHECK_MONITOR(mon); return qemuMonitorJSONSetMigrationCapabilities(mon, caps); - - error: - virJSONValueFree(caps); - return -1; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c543515cdc..a07617ec28 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -864,7 +864,7 @@ int qemuMonitorGetMigrationStats(qemuMonitorPtr mon, int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon, char ***capabilities); int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon, - virJSONValuePtr caps); + virJSONValuePtr *caps); int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon, virGICCapability **capabilities); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index ad517a99b8..0660c37e1e 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6972,14 +6972,14 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitor= Ptr mon, int qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon, - virJSONValuePtr caps) + virJSONValuePtr *caps) { int ret =3D -1; virJSONValuePtr cmd =3D NULL; virJSONValuePtr reply =3D NULL; cmd =3D qemuMonitorJSONMakeCommand("migrate-set-capabilities", - "a:capabilities", &caps, + "a:capabilities", caps, NULL); if (!cmd) goto cleanup; @@ -6992,7 +6992,6 @@ qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPt= r mon, ret =3D 0; cleanup: - virJSONValueFree(caps); virJSONValueFree(cmd); virJSONValueFree(reply); return ret; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index f3d7d204d6..4a5292a69c 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -149,7 +149,7 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon, int qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon, char ***capabilities); int qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon, - virJSONValuePtr caps); + virJSONValuePtr *caps); int qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon, virGICCapability **capabilities); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index d0c37967d5..13794c2886 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2092,8 +2092,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabil= ities(const void *opaque) goto cleanup; ret =3D qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMoni= tor(test), - json); - json =3D NULL; + &json); cleanup: virJSONValueFree(json); --=20 2.29.2