From nobody Mon Feb 9 03:47:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1652196243; cv=none; d=zohomail.com; s=zohoarc; b=Ly8jJ6+a38j9bJTnbG0zAOJXcW6FKtyTBixuZVDCfr+oBqjotKAGAfjs93pvgFLAjiX4kEBUYocqVib9hl1BZMs2oskxnEUdyxPDsPOfScIADZ5V2OKSzScpvIYSWG7CSfbz5yWtqg76wiIs2QdHSXD12gvyhhLj9fMhTxp4Ifg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196243; 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=UHzvkfl53wf1jjohiu1aPb5WnsAUiR62lYW8klE463E=; b=dJTC8ENAt1mC6lqb3KIIxy7nJBwly/1KYhxtdkj2P0zBV6im1PkEzVaOsLa9+PHgcE8EO6aikyiC2sANxqHMfQS5tgTUsp5yZxw49qZLk/Kxh5l1DRIKpU7WsnPLrNQblekUCIcGv046xr6ZefV6FfPpgAZsL/KXKxV4YPBpsUU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1652196243944638.1011167972248; Tue, 10 May 2022 08:24:03 -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-649-v-qOV_awPD6p8pqCxL_hTQ-1; Tue, 10 May 2022 11:23:16 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 210BF2802297; Tue, 10 May 2022 15:22:05 +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 0C48240314F; Tue, 10 May 2022 15:22:05 +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 8B78D1947078; Tue, 10 May 2022 15:21:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 88EDA1947060 for ; Tue, 10 May 2022 15:21:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 545BC463ED0; 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 16CDA40314F for ; Tue, 10 May 2022 15:21:49 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id AB01B244618; 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=1652196242; 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=UHzvkfl53wf1jjohiu1aPb5WnsAUiR62lYW8klE463E=; b=ES0indeC7Z2Cgael3cdAjT+z6mm/kQozCBndvvt57YACYKavkjseVKg0K2HAQ4zUWFYuBP KymLBQZOdKmyiUefgqSdDBHV45V39A/6g3V4+SMcnkG2Hgy9eY5ccrCE2gvohGHuocb2RE ig7cgLWM4J43bXeNsDWHPjxyctZL54g= X-MC-Unique: v-qOV_awPD6p8pqCxL_hTQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 44/80] qemu: Introduce qemuMigrationSrcBeginXML helper Date: Tue, 10 May 2022 17:21:05 +0200 Message-Id: <5414ef051d7621cb0bf2485e554b87a71339523c.1652196064.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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.10 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: 1652196245040100001 Content-Type: text/plain; charset="utf-8" Turn the final part of Begin phase formatting a domain XML for migration into a reusable helper. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_migration.c | 95 ++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 180a760bca..7299bb6a0b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2487,6 +2487,60 @@ qemuMigrationAnyRefreshStatus(virQEMUDriver *driver, } =20 =20 +static char * +qemuMigrationSrcBeginXML(virQEMUDriver *driver, + virDomainObj *vm, + const char *xmlin, + char **cookieout, + int *cookieoutlen, + unsigned int cookieFlags, + const char **migrate_disks, + size_t nmigrate_disks, + unsigned long flags) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(qemuMigrationCookie) mig =3D NULL; + + if (priv->origCPU) + cookieFlags |=3D QEMU_MIGRATION_COOKIE_CPU; + + if (!(flags & VIR_MIGRATE_OFFLINE)) + cookieFlags |=3D QEMU_MIGRATION_COOKIE_CAPS; + + if (!(mig =3D qemuMigrationCookieNew(vm->def, priv->origname))) + return NULL; + + if (cookieFlags & QEMU_MIGRATION_COOKIE_NBD && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BIT= MAP_MAPPING) && + qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(mig, vm, migrate_disks, + nmigrate_disks) < 0) + return NULL; + + if (qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_SOURCE, + cookieout, cookieoutlen, + cookieFlags) < 0) + return NULL; + + if (xmlin) { + g_autoptr(virDomainDef) def =3D NULL; + + if (!(def =3D virDomainDefParseString(xmlin, driver->xmlopt, priv-= >qemuCaps, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) + return NULL; + + if (!qemuDomainCheckABIStability(driver, vm, def)) + return NULL; + + return qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, = false, true); + } + + return qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def, priv->= origCPU, + false, true); +} + + /* The caller is supposed to lock the vm and start a migration job. */ static char * qemuMigrationSrcBeginPhase(virQEMUDriver *driver, @@ -2499,8 +2553,6 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, const char **migrate_disks, unsigned long flags) { - g_autoptr(qemuMigrationCookie) mig =3D NULL; - g_autoptr(virDomainDef) def =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; unsigned int cookieFlags =3D QEMU_MIGRATION_COOKIE_LOCKSTATE; =20 @@ -2621,41 +2673,10 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, vm->newDef && !qemuDomainVcpuHotplugIsInOrder(vm->newDef))) cookieFlags |=3D QEMU_MIGRATION_COOKIE_CPU_HOTPLUG; =20 - if (priv->origCPU) - cookieFlags |=3D QEMU_MIGRATION_COOKIE_CPU; - - if (!(flags & VIR_MIGRATE_OFFLINE)) - cookieFlags |=3D QEMU_MIGRATION_COOKIE_CAPS; - - if (!(mig =3D qemuMigrationCookieNew(vm->def, priv->origname))) - return NULL; - - if (cookieFlags & QEMU_MIGRATION_COOKIE_NBD && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BIT= MAP_MAPPING) && - qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(mig, vm, migrate_disks, - nmigrate_disks) < 0) - return NULL; - - if (qemuMigrationCookieFormat(mig, driver, vm, - QEMU_MIGRATION_SOURCE, - cookieout, cookieoutlen, - cookieFlags) < 0) - return NULL; - - if (xmlin) { - if (!(def =3D virDomainDefParseString(xmlin, driver->xmlopt, priv-= >qemuCaps, - VIR_DOMAIN_DEF_PARSE_INACTIVE | - VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) - return NULL; - - if (!qemuDomainCheckABIStability(driver, vm, def)) - return NULL; - - return qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, = false, true); - } else { - return qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def, pr= iv->origCPU, - false, true); - } + return qemuMigrationSrcBeginXML(driver, vm, xmlin, + cookieout, cookieoutlen, cookieFlags, + migrate_disks, nmigrate_disks, + flags); } =20 char * --=20 2.35.1