From nobody Mon Feb 9 04:23:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1701964281853215.99769003112885; Thu, 7 Dec 2023 07:51:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 86B971935; Thu, 7 Dec 2023 10:51:20 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A3569182A; Thu, 7 Dec 2023 10:39:45 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2F15A187B; Thu, 7 Dec 2023 10:38:41 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1ED2E17F5 for ; Thu, 7 Dec 2023 10:38:35 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-140-kpEOlsMDMF28vrT0rnZO1g-1; Thu, 07 Dec 2023 10:38:34 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4769838062C0 for ; Thu, 7 Dec 2023 15:38:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id C005E3C32 for ; Thu, 7 Dec 2023 15:38:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: kpEOlsMDMF28vrT0rnZO1g-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 8/8] qemu: migration: Automatically fix non-shared-storage migration to bigger block devices Date: Thu, 7 Dec 2023 16:38:26 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: T2WU6RKXCKCCRV6ANMBKJBJJXAFVHYGM X-Message-ID-Hash: T2WU6RKXCKCCRV6ANMBKJBJJXAFVHYGM X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1701964284056100001 QEMU's blockdev-mirror job doesn't allow copy into a destination which isn't exactly the same size as source. This is a problem for non-shared-storage migration when migrating into a raw block device, as there it's very hard to ensure that the destination size will match the source size. Rather than failing the migration, we can add a storage slice in such case automatically and thus make the migration pass. To do this we need to probe the size of the block device on the destination and if it differs form the size detected on the source we'll install the 'slice'. An additional handling is required when persisting the VM as we want to propagate the slice even there to ensure that the device sizes won't change. Resolves: https://issues.redhat.com/browse/RHEL-4607 Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_migration.c | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index b8331a32d3..fa566dded6 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -275,6 +275,7 @@ struct _qemuDomainDiskPrivate { bool migrating; /* the disk is being migrated */ virStorageSource *migrSource; /* disk source object used for NBD migra= tion */ + bool migrationslice; /* storage slice was added for migration purposes= */ /* information about the device */ bool tray; /* device has tray */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2d91fc3e8b..a0f131aa61 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -473,6 +473,25 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm, } if (diskSrcPath) { + /* In case the destination of the storage migration is a block + * device it might be possible that for various reasons the si= ze + * will not be identical. Since qemu refuses to do a blockdev-= mirror + * into an image which doesn't have the exact same size we nee= d to + * install a slice on top of the top image */ + if (virStorageSourceIsBlockLocal(disk->src) && + disk->src->format =3D=3D VIR_STORAGE_FILE_RAW && + disk->src->sliceStorage =3D=3D NULL) { + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetCon= fig(priv->driver); + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVA= TE(disk); + + if (qemuDomainStorageUpdatePhysical(cfg, vm, disk->src) = =3D=3D 0 && + disk->src->physical > nbd->disks[i].capacity) { + disk->src->sliceStorage =3D g_new0(virStorageSourceSli= ce, 1); + disk->src->sliceStorage->size =3D nbd->disks[i].capaci= ty; + diskPriv->migrationslice =3D true; + } + } /* don't pre-create existing disks */ if (virFileExists(diskSrcPath)) { @@ -6381,6 +6400,37 @@ qemuMigrationDstPersist(virQEMUDriver *driver, priv->qemuCaps))) goto error; + if (vm->def) { + size_t i; + + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDiskDef *disk =3D vm->def->disks[i]; + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(d= isk); + virDomainDiskDef *persistDisk; + + /* transfer over any slices added for migration */ + if (!disk->src->sliceStorage) + continue; + + if (!diskPriv->migrationslice) + continue; + + diskPriv->migrationslice =3D false; + + if (!(persistDisk =3D virDomainDiskByTarget(vm->newDef, disk->= dst))) + continue; + + if (persistDisk->src->sliceStorage) + continue; + + if (!virStorageSourceIsSameLocation(disk->src, persistDisk->sr= c)) + continue; + + persistDisk->src->sliceStorage =3D g_new0(virStorageSourceSlic= e, 1); + persistDisk->src->sliceStorage->size =3D disk->src->sliceStora= ge->size; + } + } + if (!oldPersist) { eventDetail =3D VIR_DOMAIN_EVENT_DEFINED_ADDED; --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org