From nobody Sun Feb 8 12:42:45 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=1658502601; cv=none; d=zohomail.com; s=zohoarc; b=Ue8CAZm5MU6Ot0Ri207jRNItI3BPgRIDdwnfl5NVBbLi9AhEJLfifvHuiFTFBOui+zVySd14u/Zj1T1/qt8DU43HfdKaAzNzHNxCJojc+DF5W95EVRm9O8p08UYqkPt3YryrlA/L5iMxVOcQcxDZFTu0KBFDXXb2FwKJcdh5rUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658502601; 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=aGRB3Bp64yKF9s3a0Y0bfrelLvNs8NrM1EVhwDV8TvU=; b=bpVadsLFzfgkTzIY7tzo8dBiSktboczdUYhPpk/gy0JHZaI+fWMtgAc9WwqZI51ZmggejlmLPrdataQhytBdPZQuX6a5cIjxC5x03FPQqGyl5hnZ72mehkFvyHHd2GOG1ShKvNS0NivP3/vYZOuvpmlWidXi3c1i04LvrxnfiGo= 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 1658502601714734.7050739756497; Fri, 22 Jul 2022 08:10:01 -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-556-r_OXDfMKOpKbdM4i9Zt-kg-1; Fri, 22 Jul 2022 11:09:57 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 51ADC1C06EE5; Fri, 22 Jul 2022 15:09:54 +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 375C5C28100; Fri, 22 Jul 2022 15:09:54 +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 85AC31947BB1; Fri, 22 Jul 2022 15:09:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CABC71947049 for ; Fri, 22 Jul 2022 15:09:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BCD111121319; Fri, 22 Jul 2022 15:09:51 +0000 (UTC) Received: from rein.int.mamuti.net (unknown [10.40.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9DD691121315 for ; Fri, 22 Jul 2022 15:09:51 +0000 (UTC) Received: by rein.int.mamuti.net (Postfix, from userid 500) id 76B2518B30C; Fri, 22 Jul 2022 17:09:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658502600; 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=aGRB3Bp64yKF9s3a0Y0bfrelLvNs8NrM1EVhwDV8TvU=; b=Aq1ORgQzK3nnIMyXCWQ54KIykbMGcuVKjbeOs/ElhmZOzC6vxrbYr6b6FGF2ymN3eV4o9+ Y4MWQSxj0jK/NxSo21oyWCfqxPTfO/QyGRIS9enGuE10SuG9bJHGwDHn9wjFCHnsG5Hofn I3cBfGE6S4FQePM5GxKAm2CzB99lndw= X-MC-Unique: r_OXDfMKOpKbdM4i9Zt-kg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] qemu_migration_params: Refactor qemuMigrationParamsApply Date: Fri, 22 Jul 2022 17:08:59 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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.8 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: 1658502602473100001 Content-Type: text/plain; charset="utf-8" qemuMigrationParamsApply restricts when capabilities can be set, but this is not useful in all cases. Let's create new helpers for setting migration capabilities and parameters which can be reused in more places without the restriction. https://bugzilla.redhat.com/show_bug.cgi?id=3D2107892 Signed-off-by: Jiri Denemark --- src/qemu/qemu_migration_params.c | 55 +++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 1fd0c55905..dcfb30b56f 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -864,6 +864,43 @@ qemuMigrationCapsToJSON(virBitmap *caps, } =20 =20 +static int +qemuMigrationParamsApplyCaps(virDomainObj *vm, + virBitmap *states) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(virJSONValue) json =3D NULL; + + if (!(json =3D qemuMigrationCapsToJSON(priv->migrationCaps, states))) + return -1; + + if (virJSONValueArraySize(json) > 0 && + qemuMonitorSetMigrationCapabilities(priv->mon, &json) < 0) + return -1; + + return 0; +} + + +static int +qemuMigrationParamsApplyValues(virDomainObj *vm, + qemuMigrationParams *params, + bool postcopyResume) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(virJSONValue) json =3D NULL; + + if (!(json =3D qemuMigrationParamsToJSON(params, postcopyResume))) + return -1; + + if (virJSONValueObjectKeysNumber(json) > 0 && + qemuMonitorSetMigrationParams(priv->mon, &json) < 0) + return -1; + + return 0; +} + + /** * qemuMigrationParamsApply * @driver: qemu driver @@ -885,9 +922,6 @@ qemuMigrationParamsApply(virQEMUDriver *driver, qemuMigrationParams *migParams, unsigned long apiFlags) { - qemuDomainObjPrivate *priv =3D vm->privateData; - g_autoptr(virJSONValue) params =3D NULL; - g_autoptr(virJSONValue) caps =3D NULL; bool postcopyResume =3D !!(apiFlags & VIR_MIGRATE_POSTCOPY_RESUME); int ret =3D -1; =20 @@ -905,21 +939,12 @@ qemuMigrationParamsApply(virQEMUDriver *driver, "a migration job")); goto cleanup; } - } else { - if (!(caps =3D qemuMigrationCapsToJSON(priv->migrationCaps, mi= gParams->caps))) - goto cleanup; - - if (virJSONValueArraySize(caps) > 0 && - qemuMonitorSetMigrationCapabilities(priv->mon, &caps) < 0) - goto cleanup; + } else if (qemuMigrationParamsApplyCaps(vm, migParams->caps) < 0) { + goto cleanup; } } =20 - if (!(params =3D qemuMigrationParamsToJSON(migParams, postcopyResume))) - goto cleanup; - - if (virJSONValueObjectKeysNumber(params) > 0 && - qemuMonitorSetMigrationParams(priv->mon, ¶ms) < 0) + if (qemuMigrationParamsApplyValues(vm, migParams, postcopyResume) < 0) goto cleanup; =20 ret =3D 0; --=20 2.35.1