From nobody Wed May 15 19:32:22 2024 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 1701964101009558.7643585896362; Thu, 7 Dec 2023 07:48:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id AF7BF1862; Thu, 7 Dec 2023 10:48:19 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 34E5B18B7; Thu, 7 Dec 2023 10:39:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 39286180D; Thu, 7 Dec 2023 10:38:36 -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 43EDF17F5 for ; Thu, 7 Dec 2023 10:38:34 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-Y18DNguLOKSCr3nyTsDIcA-1; Thu, 07 Dec 2023 10:38:28 -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 985AA84AEA1 for ; Thu, 7 Dec 2023 15:38:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B0623C2E for ; Thu, 7 Dec 2023 15:38:27 +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: Y18DNguLOKSCr3nyTsDIcA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 1/8] qemuMigrationDstPrecreateStorage: Improve error messages Date: Thu, 7 Dec 2023 16:38:19 +0100 Message-ID: <09588b9e068f921a0a92f5958450c05abee74089.1701962949.git.pkrempa@redhat.com> 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: CSOJ5NEY7AVD5R2KVGTSRAFT5LITTVGW X-Message-ID-Hash: CSOJ5NEY7AVD5R2KVGTSRAFT5LITTVGW 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: 1701964102033100001 Change the error messages so that they can be used to identify the problematic disk or image. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f9c34b72e8..83d986f6e6 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -457,7 +457,7 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm, if (!(disk =3D virDomainDiskByTarget(vm->def, nbd->disks[i].target= ))) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to find disk by target: %1$s"), + _("unable to find disk target '%1$s' for non-sh= ared-storage migration"), nbd->disks[i].target); goto cleanup; } @@ -476,8 +476,9 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm, } if (incremental) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("pre-creation of storage targets for incremen= tal storage migration is not supported")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("pre-creation of storage target '%1$s' for in= cremental storage migration of disk '%2$s' is not supported"), + NULLSTR(diskSrcPath), nbd->disks[i].target); goto cleanup; } --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Wed May 15 19:32:22 2024 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 1701963691582457.35909862401127; Thu, 7 Dec 2023 07:41:31 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 608DC1894; Thu, 7 Dec 2023 10:41:30 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 136EE18A3; Thu, 7 Dec 2023 10:38:45 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 215AF1783; Thu, 7 Dec 2023 10:38:32 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 A34C417E1 for ; Thu, 7 Dec 2023 10:38:31 -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-663-079shTVWP6eq2lYL3t4cRw-1; Thu, 07 Dec 2023 10:38:29 -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 691152806040 for ; Thu, 7 Dec 2023 15:38:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id E43873C2E for ; Thu, 7 Dec 2023 15:38:28 +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_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 079shTVWP6eq2lYL3t4cRw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 2/8] qemuMigrationDstPrecreateStorage: Refactor cleanup Date: Thu, 7 Dec 2023 16:38:20 +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: OHIO5BYQU377FTRZVHQEURWG66FWP4JB X-Message-ID-Hash: OHIO5BYQU377FTRZVHQEURWG66FWP4JB 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: 1701963693551100001 Use automatic pointer freeing for 'conn' and remove the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 83d986f6e6..15032512e2 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -440,9 +440,8 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm, const char **migrate_disks, bool incremental) { - int ret =3D -1; + g_autoptr(virConnect) conn =3D NULL; size_t i =3D 0; - virConnectPtr conn =3D NULL; if (!nbd || !nbd->ndisks) return 0; @@ -459,7 +458,7 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm, virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to find disk target '%1$s' for non-sh= ared-storage migration"), nbd->disks[i].target); - goto cleanup; + return -1; } if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NVME) { @@ -479,20 +478,16 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm, virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("pre-creation of storage target '%1$s' for in= cremental storage migration of disk '%2$s' is not supported"), NULLSTR(diskSrcPath), nbd->disks[i].target); - goto cleanup; + return -1; } VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath)); - if (qemuMigrationDstPrecreateDisk(&conn, - disk, nbd->disks[i].capacity) < = 0) - goto cleanup; + if (qemuMigrationDstPrecreateDisk(&conn, disk, nbd->disks[i].capac= ity) < 0) + return -1; } - ret =3D 0; - cleanup: - virObjectUnref(conn); - return ret; + return 0; } --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Wed May 15 19:32:22 2024 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 1701963776997917.1871745779569; Thu, 7 Dec 2023 07:42:56 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BADF918AD; Thu, 7 Dec 2023 10:42:55 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CB195186F; Thu, 7 Dec 2023 10:38:56 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 60BED17F6; Thu, 7 Dec 2023 10:38:33 -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 2FBD71783 for ; Thu, 7 Dec 2023 10:38:32 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-M67H3pgtOwOtDkpnsC-OMw-1; Thu, 07 Dec 2023 10:38:30 -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 39C4285A596 for ; Thu, 7 Dec 2023 15:38:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2F5A3C2E for ; Thu, 7 Dec 2023 15:38:29 +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: M67H3pgtOwOtDkpnsC-OMw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 3/8] qemuMigrationDstPrecreateStorage: Fix and clarify logic Date: Thu, 7 Dec 2023 16:38:21 +0100 Message-ID: <2e03d349947ef6c32efdd1e474c6803712bee8ee.1701962949.git.pkrempa@redhat.com> 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: VFMTYJ3PNMF5S7W4WWBAY7MSS4DOTJTI X-Message-ID-Hash: VFMTYJ3PNMF5S7W4WWBAY7MSS4DOTJTI 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: 1701963779071100001 While it's intended that qemuMigrationDstPrecreateDisk is called with any kind of the disk, the logic in qemuMigrationDstPrecreateStorage which checks the existence of the image wouldn't properly handle e.g. network backed disks, where it would attempt to use virFileExists() on the disk's 'src->path'. Fix the logic by first skipping disks not meant for migration, then do the existence check only when 'disk->src' is local storage. Since qemuMigrationDstPrecreateDisk has a debug statement there's no need to have an extra one right before calling into it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 15032512e2..a6cfede49f 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -448,7 +448,7 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm, for (i =3D 0; i < nbd->ndisks; i++) { virDomainDiskDef *disk; - const char *diskSrcPath; + const char *diskSrcPath =3D NULL; g_autofree char *nvmePath =3D NULL; VIR_DEBUG("Looking up disk target '%s' (capacity=3D%llu)", @@ -461,19 +461,28 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm, return -1; } + /* Skip disks we don't want to migrate. */ + if (!qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks)) + continue; + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NVME) { virPCIDeviceAddressGetSysfsFile(&disk->src->nvme->pciAddr, &nv= mePath); diskSrcPath =3D nvmePath; - } else { + } else if (virStorageSourceIsLocalStorage(disk->src)) { diskSrcPath =3D virDomainDiskGetSource(disk); } - /* Skip disks we don't want to migrate and already existing disks.= */ - if (!qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks)= || - (diskSrcPath && virFileExists(diskSrcPath))) { - continue; + if (diskSrcPath) { + + /* don't pre-create existing disks */ + if (virFileExists(diskSrcPath)) { + VIR_DEBUG("Skipping pre-create of existing source for disk= '%s'", disk->dst); + continue; + } } + /* create the storage - if supported */ + if (incremental) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("pre-creation of storage target '%1$s' for in= cremental storage migration of disk '%2$s' is not supported"), @@ -481,8 +490,6 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm, return -1; } - VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath)); - if (qemuMigrationDstPrecreateDisk(&conn, disk, nbd->disks[i].capac= ity) < 0) return -1; } --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Wed May 15 19:32:22 2024 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 1701963894931983.4789780049693; Thu, 7 Dec 2023 07:44:54 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id C943C186D; Thu, 7 Dec 2023 10:44:53 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9A1011852; Thu, 7 Dec 2023 10:39:05 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7DE3C1808; Thu, 7 Dec 2023 10:38:34 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 A67A617F3 for ; Thu, 7 Dec 2023 10:38:32 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-AN4NJBXdNXuOyXTC1MhAug-1; Thu, 07 Dec 2023 10:38:31 -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 0353284AEA2 for ; Thu, 7 Dec 2023 15:38:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77B183C2E for ; Thu, 7 Dec 2023 15:38:30 +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_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: AN4NJBXdNXuOyXTC1MhAug-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 4/8] qemu: migration: Improve handling of VIR_MIGRATE_PARAM_DEST_XML with VIR_MIGRATE_PERSIST_DEST Date: Thu, 7 Dec 2023 16:38:22 +0100 Message-ID: <4e4ea88391a687d7f99f8e21a2bad80bd875b6f2.1701962949.git.pkrempa@redhat.com> 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: SFJDPEO53NOUGV23OTQNAH6CCIEU4HCY X-Message-ID-Hash: SFJDPEO53NOUGV23OTQNAH6CCIEU4HCY 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: 1701963895501100001 When a user provides a migration XML via the VIR_MIGRATE_PARAM_DEST_XML it's expected that they want to change ABI-compatible aspects of the XML such as the disk paths or similar. If the user requests persisting of the VM but does not provide an explicit persistent XML libvirt would take the persistent XML from the source of the migration as the persistent config. This usually involves the old paths to images. Doing this would result into failure to start the VM. It makes more sense to take the XML used for migration and use that as the base for persisting the config. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a6cfede49f..0ae88eec03 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4706,6 +4706,7 @@ qemuMigrationSrcCancel(virDomainObj *vm, static int qemuMigrationSrcRun(virQEMUDriver *driver, virDomainObj *vm, + const char *xmlin, const char *persist_xml, const char *cookiein, int cookieinlen, @@ -4779,6 +4780,15 @@ qemuMigrationSrcRun(virQEMUDriver *driver, persist_xml, NULL, NULL))) goto error; + } else if (xmlin) { + /* if input XML is provided, use that one as template for the + * persistent XML. Otherwise user's changes will be thrown awa= y. + */ + if (!(persistDef =3D qemuMigrationAnyPrepareDef(driver, + priv->qemuCaps, + xmlin, + NULL, NULL))) + goto error; } else { virDomainDef *def =3D vm->newDef ? vm->newDef : vm->def; if (!(persistDef =3D qemuDomainDefCopy(driver, priv->qemuCaps,= def, @@ -5117,6 +5127,7 @@ qemuMigrationSrcResume(virDomainObj *vm, static int qemuMigrationSrcPerformNative(virQEMUDriver *driver, virDomainObj *vm, + const char *xmlin, const char *persist_xml, const char *uri, const char *cookiein, @@ -5202,7 +5213,7 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, ret =3D qemuMigrationSrcResume(vm, migParams, cookiein, cookieinle= n, cookieout, cookieoutlen, &spec, flags= ); } else { - ret =3D qemuMigrationSrcRun(driver, vm, persist_xml, cookiein, coo= kieinlen, + ret =3D qemuMigrationSrcRun(driver, vm, xmlin, persist_xml, cookie= in, cookieinlen, cookieout, cookieoutlen, flags, resource, &spec, dconn, graphicsuri, nmigrate_disks, migrate_disks, @@ -5220,6 +5231,7 @@ static int qemuMigrationSrcPerformTunnel(virQEMUDriver *driver, virDomainObj *vm, virStreamPtr st, + const char *xmlin, const char *persist_xml, const char *cookiein, int cookieinlen, @@ -5266,7 +5278,7 @@ qemuMigrationSrcPerformTunnel(virQEMUDriver *driver, goto cleanup; } - ret =3D qemuMigrationSrcRun(driver, vm, persist_xml, cookiein, cookiei= nlen, + ret =3D qemuMigrationSrcRun(driver, vm, xmlin, persist_xml, cookiein, = cookieinlen, cookieout, cookieoutlen, flags, resource, &s= pec, dconn, graphicsuri, nmigrate_disks, migrate_= disks, migParams, NULL); @@ -5305,7 +5317,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver, virCloseCallbacksDomainRemove(vm, NULL, qemuMigrationAnyConnectionClos= ed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); - ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, uri, + ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, NULL, uri, cookiein, cookieinlen, cookieout, cookieoutlen, flags, 0, NULL, NULL, 0, NULL, migParams,= NULL); @@ -5407,12 +5419,12 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriver *dr= iver, VIR_DEBUG("Perform %p", sconn); ignore_value(qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFO= RM2)); if (flags & VIR_MIGRATE_TUNNELLED) - ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, NULL, + ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, NULL, NULL, NULL, 0, NULL, NULL, flags, resource, dconn, NULL, 0, NULL, migParams); else - ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, uri_out, + ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, NULL, uri_= out, cookie, cookielen, NULL, NULL, /* No out cookie w= ith v2 migration */ flags, resource, dconn, NULL, = 0, NULL, @@ -5668,14 +5680,14 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dr= iver, } else { ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PER= FORM3)); if (flags & VIR_MIGRATE_TUNNELLED) { - ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, persist_= xml, + ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, xmlin, p= ersist_xml, cookiein, cookieinlen, &cookieout, &cookieoutlen, flags, bandwidth, dconn, g= raphicsuri, nmigrate_disks, migrate_di= sks, migParams); } else { - ret =3D qemuMigrationSrcPerformNative(driver, vm, persist_xml,= uri, + ret =3D qemuMigrationSrcPerformNative(driver, vm, xmlin, persi= st_xml, uri, cookiein, cookieinlen, &cookieout, &cookieoutlen, flags, bandwidth, dconn, g= raphicsuri, @@ -6075,7 +6087,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFORM2) = < 0) goto endjob; - ret =3D qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri= , cookiein, cookieinlen, + ret =3D qemuMigrationSrcPerformNative(driver, vm, xmlin, persist_x= ml, uri, cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, NULL, NULL, 0= , NULL, migParams, nbdURI); @@ -6140,6 +6152,7 @@ static int qemuMigrationSrcPerformPhase(virQEMUDriver *driver, virConnectPtr conn, virDomainObj *vm, + const char *xmlin, const char *persist_xml, const char *uri, const char *graphicsuri, @@ -6177,7 +6190,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, virCloseCallbacksDomainRemove(vm, NULL, qemuMigrationAnyConnectionClos= ed); - if (qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookie= in, cookieinlen, + if (qemuMigrationSrcPerformNative(driver, vm, xmlin, persist_xml, uri,= cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, NULL, graphicsuri, nmigrate_disks, migrate_disks, migPa= rams, nbdURI) < 0) @@ -6276,7 +6289,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, } if (v3proto) { - return qemuMigrationSrcPerformPhase(driver, conn, vm, persist_xml,= uri, + return qemuMigrationSrcPerformPhase(driver, conn, vm, xmlin, persi= st_xml, uri, graphicsuri, nmigrate_disks, migrate_disks, migParams, --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Wed May 15 19:32:22 2024 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 1701964029348807.0090210277621; Thu, 7 Dec 2023 07:47:09 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 37E321922; Thu, 7 Dec 2023 10:47:08 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0411517E1; Thu, 7 Dec 2023 10:39:16 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id CC2991811; Thu, 7 Dec 2023 10:38:35 -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 AA1AC17E1 for ; Thu, 7 Dec 2023 10:38:33 -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-464-agJIa2w0Ob2nxeVQR5REvw-1; Thu, 07 Dec 2023 10:38:32 -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 C3E531C0BB5A for ; Thu, 7 Dec 2023 15:38:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C6323C2E for ; Thu, 7 Dec 2023 15:38:31 +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: agJIa2w0Ob2nxeVQR5REvw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 5/8] qemuDomainStorageOpenStat: Remove unused 'driver' argument and untangle callers Date: Thu, 7 Dec 2023 16:38:23 +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: 37KQ5VNHYMDKXFJLRIJEMIKQYGUB5QH2 X-Message-ID-Hash: 37KQ5VNHYMDKXFJLRIJEMIKQYGUB5QH2 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: 1701964030278100001 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 64afae6450..f4c2fbfb45 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10217,7 +10217,6 @@ qemuDomainMemoryPeek(virDomainPtr dom, /** - * @driver: qemu driver data * @cfg: driver configuration data * @vm: domain object * @src: storage source data @@ -10236,8 +10235,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, * reported) or -1 otherwise (errors are reported). */ static int -qemuDomainStorageOpenStat(virQEMUDriver *driver G_GNUC_UNUSED, - virQEMUDriverConfig *cfg, +qemuDomainStorageOpenStat(virQEMUDriverConfig *cfg, virDomainObj *vm, virStorageSource *src, int *ret_fd, @@ -10296,7 +10294,6 @@ qemuDomainStorageCloseStat(virStorageSource *src, /** * qemuDomainStorageUpdatePhysical: - * @driver: qemu driver * @cfg: qemu driver configuration object * @vm: domain object * @src: storage source to update @@ -10308,8 +10305,7 @@ qemuDomainStorageCloseStat(virStorageSource *src, * reported but are reset (thus only logged)). */ static int -qemuDomainStorageUpdatePhysical(virQEMUDriver *driver, - virQEMUDriverConfig *cfg, +qemuDomainStorageUpdatePhysical(virQEMUDriverConfig *cfg, virDomainObj *vm, virStorageSource *src) { @@ -10320,7 +10316,7 @@ qemuDomainStorageUpdatePhysical(virQEMUDriver *driv= er, if (virStorageSourceIsEmpty(src)) return 0; - if ((ret =3D qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb,= true)) <=3D 0) { + if ((ret =3D qemuDomainStorageOpenStat(cfg, vm, src, &fd, &sb, true)) = <=3D 0) { if (ret < 0) virResetLastError(); return -1; @@ -10335,7 +10331,6 @@ qemuDomainStorageUpdatePhysical(virQEMUDriver *driv= er, /** - * @driver: qemu driver data * @cfg: driver configuration data * @vm: domain object * @src: storage source data @@ -10366,8 +10361,7 @@ qemuDomainStorageUpdatePhysical(virQEMUDriver *driv= er, * are reported). */ static int -qemuStorageLimitsRefresh(virQEMUDriver *driver, - virQEMUDriverConfig *cfg, +qemuStorageLimitsRefresh(virQEMUDriverConfig *cfg, virDomainObj *vm, virStorageSource *src, bool skipInaccessible) @@ -10379,7 +10373,7 @@ qemuStorageLimitsRefresh(virQEMUDriver *driver, g_autofree char *buf =3D NULL; ssize_t len; - if ((rc =3D qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, + if ((rc =3D qemuDomainStorageOpenStat(cfg, vm, src, &fd, &sb, skipInaccessible)) <=3D 0) return rc; @@ -10470,7 +10464,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, /* for inactive domains we have to peek into the files */ if (!virDomainObjIsActive(vm)) { - if ((qemuStorageLimitsRefresh(driver, cfg, vm, disk->src, false)) = < 0) + if ((qemuStorageLimitsRefresh(cfg, vm, disk->src, false)) < 0) goto endjob; info->capacity =3D disk->src->capacity; @@ -10510,7 +10504,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, if (info->allocation =3D=3D 0) info->allocation =3D entry->physical; - if (qemuDomainStorageUpdatePhysical(driver, cfg, vm, disk->src) = =3D=3D 0) { + if (qemuDomainStorageUpdatePhysical(cfg, vm, disk->src) =3D=3D 0) { info->physical =3D disk->src->physical; } else { info->physical =3D entry->physical; @@ -17220,8 +17214,7 @@ qemuDomainGetStatsInterface(virQEMUDriver *driver G= _GNUC_UNUSED, /* refresh information by opening images on the disk */ static int -qemuDomainGetStatsOneBlockFallback(virQEMUDriver *driver, - virQEMUDriverConfig *cfg, +qemuDomainGetStatsOneBlockFallback(virQEMUDriverConfig *cfg, virDomainObj *dom, virTypedParamList *params, virStorageSource *src, @@ -17233,7 +17226,7 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriver *d= river, if (virStorageSourceIsFD(src)) return 0; - if (qemuStorageLimitsRefresh(driver, cfg, dom, src, true) <=3D 0) { + if (qemuStorageLimitsRefresh(cfg, dom, src, true) <=3D 0) { virResetLastError(); return 0; } @@ -17252,8 +17245,7 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriver *d= river, static int -qemuDomainGetStatsOneBlock(virQEMUDriver *driver, - virQEMUDriverConfig *cfg, +qemuDomainGetStatsOneBlock(virQEMUDriverConfig *cfg, virDomainObj *dom, virTypedParamList *params, const char *entryname, @@ -17266,7 +17258,7 @@ qemuDomainGetStatsOneBlock(virQEMUDriver *driver, /* the VM is offline so we have to go and load the stast from the disk= by * ourselves */ if (!virDomainObjIsActive(dom)) { - return qemuDomainGetStatsOneBlockFallback(driver, cfg, dom, params, + return qemuDomainGetStatsOneBlockFallback(cfg, dom, params, src, block_idx); } @@ -17284,7 +17276,7 @@ qemuDomainGetStatsOneBlock(virQEMUDriver *driver, if (entry->physical) { virTypedParamListAddULLong(params, entry->physical, "block.%zu.phy= sical", block_idx); } else { - if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) =3D=3D = 0) { + if (qemuDomainStorageUpdatePhysical(cfg, dom, src) =3D=3D 0) { virTypedParamListAddULLong(params, src->physical, "block.%zu.p= hysical", block_idx); } } @@ -17362,7 +17354,6 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDef = *disk, virTypedParamList *params, size_t *recordnr, bool visitBacking, - virQEMUDriver *driver, virQEMUDriverConfig *cfg, virDomainObj *dom) @@ -17435,7 +17426,7 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDef = *disk, return -1; } - if (qemuDomainGetStatsOneBlock(driver, cfg, dom, params, + if (qemuDomainGetStatsOneBlock(cfg, dom, params, backendalias, n, *recordnr, stats) < 0) return -1; @@ -17462,7 +17453,7 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDef = *disk, if (qemuDomainGetStatsBlockExportHeader(disk, disk->mirror, *r= ecordnr, params) < 0) return -1; - if (qemuDomainGetStatsOneBlock(driver, cfg, dom, params, + if (qemuDomainGetStatsOneBlock(cfg, dom, params, qemuBlockStorageSourceGetEffect= iveNodename(disk->mirror), disk->mirror, *recordnr, @@ -17491,7 +17482,7 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDef = *disk, *recordnr, par= ams) < 0) return -1; - if (qemuDomainGetStatsOneBlock(driver, cfg, dom, param= s, + if (qemuDomainGetStatsOneBlock(cfg, dom, params, qemuBlockStorageSourceG= etEffectiveNodename(backupdisk->store), backupdisk->store, *recordnr, @@ -17548,7 +17539,7 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, for (i =3D 0; i < dom->def->ndisks; i++) { if (qemuDomainGetStatsBlockExportDisk(dom->def->disks[i], stats, blockparams, &visited, - visitBacking, driver, cfg, d= om) < 0) + visitBacking, cfg, dom) < 0) return -1; } --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Wed May 15 19:32:22 2024 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 1701964172293298.17086170254083; Thu, 7 Dec 2023 07:49:32 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3A76618FC; Thu, 7 Dec 2023 10:49:31 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BEDB018D6; Thu, 7 Dec 2023 10:39:35 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 163031813; Thu, 7 Dec 2023 10:38:37 -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 9D90C17F6 for ; Thu, 7 Dec 2023 10:38:34 -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-20-7MHI5UD_P4mPElLubYAG0g-1; Thu, 07 Dec 2023 10:38:32 -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 9E1471C0BB56 for ; Thu, 7 Dec 2023 15:38:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 193653C2E for ; Thu, 7 Dec 2023 15:38:31 +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: 7MHI5UD_P4mPElLubYAG0g-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 6/8] qemu: migration: Rename qemuMigrationDstPrecreateStorage to qemuMigrationDstPrepareStorage Date: Thu, 7 Dec 2023 16:38:24 +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: SG23J5GAE3YMI5SG7VSOPBND4WPSHVI5 X-Message-ID-Hash: SG23J5GAE3YMI5SG7VSOPBND4WPSHVI5 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: 1701964173466100001 The function will be used to setup storage for non-shared-storage migration, not just precreate images. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 0ae88eec03..2d91fc3e8b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -434,11 +434,11 @@ qemuMigrationHasAnyStorageMigrationDisks(virDomainDef= *def, static int -qemuMigrationDstPrecreateStorage(virDomainObj *vm, - qemuMigrationCookieNBD *nbd, - size_t nmigrate_disks, - const char **migrate_disks, - bool incremental) +qemuMigrationDstPrepareStorage(virDomainObj *vm, + qemuMigrationCookieNBD *nbd, + size_t nmigrate_disks, + const char **migrate_disks, + bool incremental) { g_autoptr(virConnect) conn =3D NULL; size_t i =3D 0; @@ -3097,9 +3097,9 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, goto error; } - if (qemuMigrationDstPrecreateStorage(vm, mig->nbd, - nmigrate_disks, migrate_disks, - !!(flags & VIR_MIGRATE_NON_SHARED= _INC)) < 0) + if (qemuMigrationDstPrepareStorage(vm, mig->nbd, + nmigrate_disks, migrate_disks, + !!(flags & VIR_MIGRATE_NON_SHARED_I= NC)) < 0) goto error; if (tunnel && --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Wed May 15 19:32:22 2024 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 1701964387418723.129425918785; Thu, 7 Dec 2023 07:53:07 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5E4AF180D; Thu, 7 Dec 2023 10:53:06 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7950D1876; Thu, 7 Dec 2023 10:39:54 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 931B7188D; Thu, 7 Dec 2023 10:38:42 -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 41227180A for ; Thu, 7 Dec 2023 10:38:35 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-KYKADA1BPSWWg7rcCM9H0A-1; Thu, 07 Dec 2023 10:38:33 -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 6941910334A9 for ; Thu, 7 Dec 2023 15:38:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id E78963C2E for ; Thu, 7 Dec 2023 15:38:32 +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: KYKADA1BPSWWg7rcCM9H0A-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 7/8] qemu: Move and export qemuDomainStorageUpdatePhysical and dependencies Date: Thu, 7 Dec 2023 16:38:25 +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: Y2H26UDJBB2AZC5S5IMBVFA7LYDNHCAB X-Message-ID-Hash: Y2H26UDJBB2AZC5S5IMBVFA7LYDNHCAB 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: 1701964388216100001 Move qemuDomainStorageUpdatePhysical, qemuDomainStorageOpenStat, qemuDomainStorageCloseStat to qemu_domain.c and export them. They'll be reused in the migration code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 114 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 15 ++++++ src/qemu/qemu_driver.c | 114 ----------------------------------------- 3 files changed, 129 insertions(+), 114 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 953808fcfe..734d63f8a4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12675,3 +12675,117 @@ qemuDomainNumatuneMaybeFormatNodesetUnion(virDoma= inObj *vm, if (nodeset) *nodeset =3D g_steal_pointer(&unionMask); } + + +/** + * @cfg: driver configuration data + * @vm: domain object + * @src: storage source data + * @ret_fd: pointer to return open'd file descriptor + * @ret_sb: pointer to return stat buffer (local or remote) + * @skipInaccessible: Don't report error if files are not accessible + * + * For local storage, open the file using qemuDomainOpenFile and then use + * fstat() to grab the stat struct data for the caller. + * + * For remote storage, attempt to access the file and grab the stat + * struct data if the remote connection supports it. + * + * Returns 1 if @src was successfully opened (@ret_fd and @ret_sb is popul= ated), + * 0 if @src can't be opened and @skipInaccessible is true (no errors are + * reported) or -1 otherwise (errors are reported). + */ +int +qemuDomainStorageOpenStat(virQEMUDriverConfig *cfg, + virDomainObj *vm, + virStorageSource *src, + int *ret_fd, + struct stat *ret_sb, + bool skipInaccessible) +{ + if (virStorageSourceIsLocalStorage(src)) { + if (skipInaccessible && !virFileExists(src->path)) + return 0; + + if ((*ret_fd =3D qemuDomainOpenFile(cfg, vm->def, src->path, O_RDO= NLY, + NULL)) < 0) + return -1; + + if (fstat(*ret_fd, ret_sb) < 0) { + virReportSystemError(errno, _("cannot stat file '%1$s'"), src-= >path); + VIR_FORCE_CLOSE(*ret_fd); + return -1; + } + } else { + if (skipInaccessible && virStorageSourceSupportsBackingChainTraver= sal(src) <=3D 0) + return 0; + + if (virStorageSourceInitAs(src, cfg->user, cfg->group) < 0) + return -1; + + if (virStorageSourceStat(src, ret_sb) < 0) { + virStorageSourceDeinit(src); + virReportSystemError(errno, _("failed to stat remote file '%1$= s'"), + NULLSTR(src->path)); + return -1; + } + } + + return 1; +} + + +/** + * @src: storage source data + * @fd: file descriptor to close for local + * + * If local, then just close the file descriptor. + * else remote, then tear down the storage driver backend connection. + */ +void +qemuDomainStorageCloseStat(virStorageSource *src, + int *fd) +{ + if (virStorageSourceIsLocalStorage(src)) + VIR_FORCE_CLOSE(*fd); + else + virStorageSourceDeinit(src); +} + + +/** + * qemuDomainStorageUpdatePhysical: + * @cfg: qemu driver configuration object + * @vm: domain object + * @src: storage source to update + * + * Update the physical size of the disk by reading the actual size of the = image + * on disk. + * + * Returns 0 on successful update and -1 otherwise (some uncommon errors m= ay be + * reported but are reset (thus only logged)). + */ +int +qemuDomainStorageUpdatePhysical(virQEMUDriverConfig *cfg, + virDomainObj *vm, + virStorageSource *src) +{ + int ret; + int fd =3D -1; + struct stat sb; + + if (virStorageSourceIsEmpty(src)) + return 0; + + if ((ret =3D qemuDomainStorageOpenStat(cfg, vm, src, &fd, &sb, true)) = <=3D 0) { + if (ret < 0) + virResetLastError(); + return -1; + } + + ret =3D virStorageSourceUpdatePhysicalSize(src, fd, &sb); + + qemuDomainStorageCloseStat(src, &fd); + + return ret; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 1e56e50672..b8331a32d3 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1129,3 +1129,18 @@ void qemuDomainNumatuneMaybeFormatNodesetUnion(virDomainObj *vm, virBitmap **nodeset, char **nodesetStr); + +int +qemuDomainStorageOpenStat(virQEMUDriverConfig *cfg, + virDomainObj *vm, + virStorageSource *src, + int *ret_fd, + struct stat *ret_sb, + bool skipInaccessible); +void +qemuDomainStorageCloseStat(virStorageSource *src, + int *fd); +int +qemuDomainStorageUpdatePhysical(virQEMUDriverConfig *cfg, + virDomainObj *vm, + virStorageSource *src); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f4c2fbfb45..9331369d4d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10216,120 +10216,6 @@ qemuDomainMemoryPeek(virDomainPtr dom, } -/** - * @cfg: driver configuration data - * @vm: domain object - * @src: storage source data - * @ret_fd: pointer to return open'd file descriptor - * @ret_sb: pointer to return stat buffer (local or remote) - * @skipInaccessible: Don't report error if files are not accessible - * - * For local storage, open the file using qemuDomainOpenFile and then use - * fstat() to grab the stat struct data for the caller. - * - * For remote storage, attempt to access the file and grab the stat - * struct data if the remote connection supports it. - * - * Returns 1 if @src was successfully opened (@ret_fd and @ret_sb is popul= ated), - * 0 if @src can't be opened and @skipInaccessible is true (no errors are - * reported) or -1 otherwise (errors are reported). - */ -static int -qemuDomainStorageOpenStat(virQEMUDriverConfig *cfg, - virDomainObj *vm, - virStorageSource *src, - int *ret_fd, - struct stat *ret_sb, - bool skipInaccessible) -{ - if (virStorageSourceIsLocalStorage(src)) { - if (skipInaccessible && !virFileExists(src->path)) - return 0; - - if ((*ret_fd =3D qemuDomainOpenFile(cfg, vm->def, src->path, O_RDO= NLY, - NULL)) < 0) - return -1; - - if (fstat(*ret_fd, ret_sb) < 0) { - virReportSystemError(errno, _("cannot stat file '%1$s'"), src-= >path); - VIR_FORCE_CLOSE(*ret_fd); - return -1; - } - } else { - if (skipInaccessible && virStorageSourceSupportsBackingChainTraver= sal(src) <=3D 0) - return 0; - - if (virStorageSourceInitAs(src, cfg->user, cfg->group) < 0) - return -1; - - if (virStorageSourceStat(src, ret_sb) < 0) { - virStorageSourceDeinit(src); - virReportSystemError(errno, _("failed to stat remote file '%1$= s'"), - NULLSTR(src->path)); - return -1; - } - } - - return 1; -} - - -/** - * @src: storage source data - * @fd: file descriptor to close for local - * - * If local, then just close the file descriptor. - * else remote, then tear down the storage driver backend connection. - */ -static void -qemuDomainStorageCloseStat(virStorageSource *src, - int *fd) -{ - if (virStorageSourceIsLocalStorage(src)) - VIR_FORCE_CLOSE(*fd); - else - virStorageSourceDeinit(src); -} - - -/** - * qemuDomainStorageUpdatePhysical: - * @cfg: qemu driver configuration object - * @vm: domain object - * @src: storage source to update - * - * Update the physical size of the disk by reading the actual size of the = image - * on disk. - * - * Returns 0 on successful update and -1 otherwise (some uncommon errors m= ay be - * reported but are reset (thus only logged)). - */ -static int -qemuDomainStorageUpdatePhysical(virQEMUDriverConfig *cfg, - virDomainObj *vm, - virStorageSource *src) -{ - int ret; - int fd =3D -1; - struct stat sb; - - if (virStorageSourceIsEmpty(src)) - return 0; - - if ((ret =3D qemuDomainStorageOpenStat(cfg, vm, src, &fd, &sb, true)) = <=3D 0) { - if (ret < 0) - virResetLastError(); - return -1; - } - - ret =3D virStorageSourceUpdatePhysicalSize(src, fd, &sb); - - qemuDomainStorageCloseStat(src, &fd); - - return ret; -} - - /** * @cfg: driver configuration data * @vm: domain object --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Wed May 15 19:32:22 2024 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 Reviewed-by: J=C3=A1n Tomko --- 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