From nobody Mon May 6 02:11:59 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561552458; cv=none; d=zoho.com; s=zohoarc; b=Umw1tG+Az/V9w2X/S9iKB1Ki7ayCGe1agMAFrNzWkVoXs6SaGuGnjxI/jV5OV+BxV8d3m3iaFYzDNGaQwUz6bWa1stYCesRmSD8PwFzWp3Tdgtu0VHrbi1CXejlDBGG1Uez6MqLaHARfhSuapTJe1CfRO19bKPCGpKNXPgyaS5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561552458; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=wXu27Giv1kE+1c+EECQV8N6xXLJV2cY20IzP+XKIMBA=; b=JLtmLl29h3+FSh7B6+5V+i1HL1cx2mlriJ1R5MtDJFSbmk6b5JMRCGumkaEIjcq5CRvW+6SlGGBn+w+wbBVD6QteDCcuKg7GxHzdgkNkfqyvy2kYJ5DRJh7WUl5qhLfnKZNa8qh6LsNlNGCm4LY303lcUtzKTzgAwRGqULQ5rhI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561552458525992.012464633699; Wed, 26 Jun 2019 05:34:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31757308FB9D; Wed, 26 Jun 2019 12:34:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD9BA6012E; Wed, 26 Jun 2019 12:33:56 +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 20979E160; Wed, 26 Jun 2019 12:33:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5Q63AsB026604 for ; Wed, 26 Jun 2019 02:03:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA50A60BF3; Wed, 26 Jun 2019 06:03:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C578D60BE5 for ; Wed, 26 Jun 2019 06:03:08 +0000 (UTC) Received: from mxct.zte.com.cn (mx7.zte.com.cn [202.103.147.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DCAC30832EA for ; Wed, 26 Jun 2019 06:02:49 +0000 (UTC) Received: from mse-fl1.zte.com.cn (unknown [10.30.14.238]) by Forcepoint Email with ESMTPS id 50919E9E51BBB2425A7C for ; Wed, 26 Jun 2019 14:02:37 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse-fl1.zte.com.cn with ESMTP id x5Q6201g082518 for ; Wed, 26 Jun 2019 14:02:00 +0800 (GMT-8) (envelope-from liu.dayu@zte.com.cn) Received: from kvm-146.localdomain ([10.74.120.146]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019062614022042-1724433 ; Wed, 26 Jun 2019 14:02:20 +0800 From: Liu Dayu To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 14:05:41 +0800 Message-Id: <1561529141-25261-1-git-send-email-liu.dayu@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-06-26 14:02:20, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-06-26 14:02:04, Serialize complete at 2019-06-26 14:02:04 X-MAIL: mse-fl1.zte.com.cn x5Q6201g082518 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 26 Jun 2019 06:02:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 26 Jun 2019 06:02:58 +0000 (UTC) for IP:'202.103.147.169' DOMAIN:'mx7.zte.com.cn' HELO:'mxct.zte.com.cn' FROM:'liu.dayu@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -2.299 (RCVD_IN_DNSWL_MED, SPF_NONE) 202.103.147.169 mx7.zte.com.cn 202.103.147.169 mx7.zte.com.cn X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 26 Jun 2019 08:32:21 -0400 Cc: wang.yi59@zte.com.cn, wang.yechao255@zte.com.cn, Liu Dayu Subject: [libvirt] [PATCH] libvirt: support block device storage type in virshParseSnapshotDiskspec 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 26 Jun 2019 12:34:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virsh snapshot-create-as supports 'file' storage type in --diskspec by defa= ult. It doesn't support 'block' storage type in the process of virshParseSnapsho= tDiskspec(). So if a snapshot on a block device (e.g. LV) was created, the type of curre= nt running storage source in dumpxml is inconsistent with the actual backend storage s= ource. It will check file-system type mismatch failed and return an error message = of 'Migration without shared storage is unsafe' when VM performs a live migrat= ion after this snapshot. Signed-off-by: Liu Dayu --- tools/virsh-snapshot.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index f6bb38b..f9c55e0 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -255,6 +255,8 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBufferPt= r buf, const char *str) char **array =3D NULL; int narray; size_t i; + struct stat st; + int stor_type =3D VIR_STORAGE_TYPE_NONE; =20 narray =3D vshStringToArray(str, &array); if (narray <=3D 0) @@ -272,16 +274,29 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBuffer= Ptr buf, const char *str) goto cleanup; } =20 + /* possibly update storage type */ + if (file && STRPREFIX(file, "/dev/") && stat(file, &st) =3D=3D 0 && S_= ISBLK(st.st_mode)) + stor_type =3D VIR_STORAGE_TYPE_BLOCK; + else + stor_type =3D VIR_STORAGE_TYPE_FILE; + virBufferEscapeString(buf, "\n"); virBufferAdjustIndent(buf, 2); if (driver) virBufferAsprintf(buf, "\n", driver); - if (file) - virBufferEscapeString(buf, "\n", file); + if (file) { + if (stor_type =3D=3D VIR_STORAGE_TYPE_BLOCK) + virBufferEscapeString(buf, "\n", file); + else + virBufferEscapeString(buf, "\n", file= ); + } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } else { --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list