From nobody Sat Apr 27 23:02:10 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=1562579023; cv=none; d=zoho.com; s=zohoarc; b=gDPFvnXXN5tbHv/T0tYBepFW6CynSIObIFvwv4fPJMRzrPZ8WkLbreSDNs8mhTUqAGr7naQxKuEkBRWX5g1kl2mXxfLVsRP6kuWr7sUuzFHQ8zcHE4pj2LRYnvlUCLFMzMePlkF3uQ36A7G8Xo/ZD8hXtTZSp8/saeBsb550wDQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562579023; 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=WLHK4mXKd/lYpMenzCkzpfio0malEe70uAR9CHcCuQI=; b=EPQMoO1EhnvtRCaBAd8aagtXfT4tcaqOd1oRUfirzjnJhaqTikI/ZILUWJMPNuDKOTBftnvaSeAB+7QuD1yyD/li6lTobuM3IxGfApwDoNaCMaFJ+FhfsvFi+pIXcsHmffv+KizleZI1j0TTrmnecZhsFOCVjFPynB6hwmRPjPk= 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 1562579022851192.8361697087663; Mon, 8 Jul 2019 02:43:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 192982F8BDB; Mon, 8 Jul 2019 09:43:41 +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 748FB19C79; Mon, 8 Jul 2019 09:43:38 +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 8A8D018184A5; Mon, 8 Jul 2019 09:43:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x689hZjw006416 for ; Mon, 8 Jul 2019 05:43:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2E1518370; Mon, 8 Jul 2019 09:43:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DDAF917D4B for ; Mon, 8 Jul 2019 09:43:33 +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 63F60308210C for ; Mon, 8 Jul 2019 09:43:22 +0000 (UTC) Received: from mse-fl1.zte.com.cn (unknown [10.30.14.238]) by Forcepoint Email with ESMTPS id CF976C3149E4F1E5C483 for ; Mon, 8 Jul 2019 17:43:19 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse-fl1.zte.com.cn with ESMTP id x689gnhx000269 for ; Mon, 8 Jul 2019 17:42:49 +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 2019070817425393-2170557 ; Mon, 8 Jul 2019 17:42:53 +0800 From: Liu Dayu To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 17:46:34 +0800 Message-Id: <1562579194-15765-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-07-08 17:42:54, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-07-08 17:42:50, Serialize complete at 2019-07-08 17:42:50 X-MAIL: mse-fl1.zte.com.cn x689gnhx000269 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.47]); Mon, 08 Jul 2019 09:43:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 08 Jul 2019 09:43:23 +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.3 (RCVD_IN_DNSWL_MED, SPF_HELO_NONE, SPF_PASS) 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.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: wang.yi59@zte.com.cn, wang.yechao255@zte.com.cn, Liu Dayu Subject: [libvirt] [PATCH v2] 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 08 Jul 2019 09:43:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virsh snapshot-create-as supports 'file' storage type in --diskspec by defa= ult. But it doesn't support 'block' storage type in the virshParseSnapshotDisksp= ec(). So if a snapshot on a block device (e.g. LV) was created, the type of current running storage source in dumpxml is inconsistent with the actual backend storage source. 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 migration after this snapshot. Considering virsh has to be able to work remotely that recognizing a block = device by prefix /dev/ or by stat() may be not suitable, so adding a "stype" field for the --diskspec string which will be either "file" or "block". e.g. --diskspec vda,snapshot=3Dexternal,driver=3Dqcow2,stype=3Dblock,file= =3D/dev/xxx. Signed-off-by: Liu Dayu --- Patch v1: https://www.redhat.com/archives/libvir-list/2019-June/msg01248.html Changes in v2: - Adding a "stype" field for the --diskspec string which will indicate a "= file" or "block" storage type. --- tools/virsh-snapshot.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index e9f0ee0..ec965b2 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -251,10 +251,12 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBuffer= Ptr buf, const char *str) const char *name =3D NULL; const char *snapshot =3D NULL; const char *driver =3D NULL; + const char *stype =3D NULL; const char *file =3D NULL; char **array =3D NULL; int narray; size_t i; + bool isFile =3D true; =20 narray =3D vshStringToArray(str, &array); if (narray <=3D 0) @@ -266,6 +268,8 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBufferPt= r buf, const char *str) snapshot =3D array[i] + strlen("snapshot=3D"); else if (!driver && STRPREFIX(array[i], "driver=3D")) driver =3D array[i] + strlen("driver=3D"); + else if (!stype && STRPREFIX(array[i], "stype=3D")) + stype =3D array[i] + strlen("stype=3D"); else if (!file && STRPREFIX(array[i], "file=3D")) file =3D array[i] + strlen("file=3D"); else @@ -275,13 +279,26 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBuffer= Ptr buf, const char *str) virBufferEscapeString(buf, "\n"); virBufferAdjustIndent(buf, 2); if (driver) virBufferAsprintf(buf, "\n", driver); - if (file) - virBufferEscapeString(buf, "\n", file); + if (file) { + if (isFile) + virBufferEscapeString(buf, "\n", file= ); + else + virBufferEscapeString(buf, "\n", file); + } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } else { @@ -351,7 +368,7 @@ static const vshCmdOptDef opts_snapshot_create_as[] =3D= { }, {.name =3D "diskspec", .type =3D VSH_OT_ARGV, - .help =3D N_("disk attributes: disk[,snapshot=3Dtype][,driver=3Dtype]= [,file=3Dname]") + .help =3D N_("disk attributes: disk[,snapshot=3Dtype][,driver=3Dtype]= [,stype=3Dtype][,file=3Dname]") }, {.name =3D NULL} }; --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list