From nobody Wed May 14 20:36:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519639606561314.9960082894838; Mon, 26 Feb 2018 02:06:46 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDDC980B2A; Mon, 26 Feb 2018 10:06:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63B6F60C8D; Mon, 26 Feb 2018 10:06:40 +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 EC99C18033F0; Mon, 26 Feb 2018 10:06:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1QA60aB024952 for ; Mon, 26 Feb 2018 05:06:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id A90992024CA2; Mon, 26 Feb 2018 10:06:00 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-22.brq.redhat.com [10.40.204.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7FA3202699C; Mon, 26 Feb 2018 10:05:59 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 26 Feb 2018 11:05:49 +0100 Message-Id: <4487b16a8be518696e23386614e5bbf94ce208b1.1519639473.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: jdenemar@redhat.com Subject: [libvirt] [PATCH 1/3] qemuMigrationSrcIsSafe: Check local storage more thoroughly 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 26 Feb 2018 10:06:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1494454 If a domain disk is stored on local filesystem (e.g. ext4) but is not being migrated it is very likely that domain is not able to run on destination. Regardless of share/cache mode. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_migration.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index b22a327b5..e98b1e4ce 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1215,25 +1215,26 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def, virDomainDiskDefPtr disk =3D def->disks[i]; const char *src =3D virDomainDiskGetSource(disk); =20 - /* Our code elsewhere guarantees shared disks are either readonly = (in - * which case cache mode doesn't matter) or used with cache=3Dnone= or used with cache=3Ddirectsync */ + /* Disks without any source (i.e. floppies and CD-ROMs) + * OR readonly are safe. */ if (virStorageSourceIsEmpty(disk->src) || - disk->src->readonly || - disk->src->shared || - disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DISABLE || - disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC) + disk->src->readonly) continue; =20 - /* disks which are migrated by qemu are safe too */ + /* Disks which are migrated by qemu are safe too. */ if (storagemigration && qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks)) continue; =20 + /* However, disks on local FS (e.g. ext4) are not safe. */ if (virDomainDiskGetType(disk) =3D=3D VIR_STORAGE_TYPE_FILE) { - if ((rc =3D virFileIsSharedFS(src)) < 0) + if ((rc =3D virFileIsSharedFS(src)) < 0) { return false; - else if (rc =3D=3D 0) - continue; + } else if (rc =3D=3D 0) { + virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", + _("Migration without shared storage is unsa= fe")); + return false; + } if ((rc =3D virStorageFileIsClusterFS(src)) < 0) return false; else if (rc =3D=3D 1) @@ -1243,6 +1244,13 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def, continue; } =20 + /* Our code elsewhere guarantees shared disks are either readonly = (in + * which case cache mode doesn't matter) or used with cache=3Dnone= or used with cache=3Ddirectsync */ + if (disk->src->shared || + disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DISABLE || + disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC) + continue; + virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", _("Migration may lead to data corruption if disks" " use cache !=3D none or cache !=3D directsync")); --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list