From nobody Sat Dec 21 14:20:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1488827981282491.4074533480492; Mon, 6 Mar 2017 11:19:41 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id A172382051E; Mon, 6 Mar 2017 19:19:38 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 3DEC182051A for ; Mon, 6 Mar 2017 19:19:25 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v26JJIrO039025 for ; Mon, 6 Mar 2017 14:19:24 -0500 Received: from e24smtp01.br.ibm.com (e24smtp01.br.ibm.com [32.104.18.85]) by mx0a-001b2d01.pphosted.com with ESMTP id 291814t01f-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 06 Mar 2017 14:19:24 -0500 Received: from localhost by e24smtp01.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Mar 2017 16:19:21 -0300 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp01.br.ibm.com (10.172.0.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 6 Mar 2017 16:19:20 -0300 Received: from d24relay02.br.ibm.com (d24relay02.br.ibm.com [9.18.232.42]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 89C1C352006E for ; Mon, 6 Mar 2017 14:18:45 -0500 (EST) Received: from d24av03.br.ibm.com (d24av03.br.ibm.com [9.8.31.95]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v26JJJhL38469632 for ; Mon, 6 Mar 2017 16:19:19 -0300 Received: from d24av03.br.ibm.com (localhost [127.0.0.1]) by d24av03.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v26JJJBL027581 for ; Mon, 6 Mar 2017 16:19:19 -0300 Received: from alinefm-TP440.ibmmodules.com ([9.85.144.220]) by d24av03.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v26JJGBX027544 for ; Mon, 6 Mar 2017 16:19:19 -0300 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Mon, 6 Mar 2017 16:19:09 -0300 X-Mailer: git-send-email 2.9.3 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17030619-1523-0000-0000-000002871EA9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030619-1524-0000-0000-00002A1D2D0F Message-Id: <20170306191909.1880-1-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-06_18:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703060155 Subject: [Kimchi-devel] [PATCH] [Kimchi] Bug fix #1107: Only set cache=none to disks that support direct IO X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" ZFS volumes and GlusterFS does not support direct IO and setting cache=3Dnone will not allow the guest to start. So only set cache=3Dnone when direct IO is supported to avoid problems. Signed-off-by: Aline Manera Reviewed-by: Daniel Barboza --- xmlutils/disk.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/xmlutils/disk.py b/xmlutils/disk.py index 02d6811..97298c5 100644 --- a/xmlutils/disk.py +++ b/xmlutils/disk.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -17,6 +17,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import errno import lxml.etree as ET import os import socket @@ -28,7 +29,7 @@ from lxml.builder import E =20 from wok.exception import InvalidParameter, NotFoundError from wok.plugins.kimchi.utils import check_url_path - +from wok.utils import wok_log =20 BUS_TO_DEV_MAP =3D {'ide': 'hd', 'virtio': 'vd', 'scsi': 'sd'} DEV_TYPE_SRC_ATTR_MAP =3D {'file': 'file', 'block': 'dev'} @@ -51,11 +52,22 @@ def get_disk_xml(params): disk_type =3D _get_disk_type(path) if len(path) > 0 else 'file' disk =3D E.disk(type=3Ddisk_type, device=3Dparams['type']) driver =3D E.driver(name=3D'qemu', type=3Dparams['format']) - if params['type'] !=3D 'cdrom': - driver.set('cache', 'none') + try: + fd =3D os.open(path, os.O_RDONLY | os.O_DIRECT) + os.close(fd) + wok_log.debug("Disk '%s' supports direct I/O. Setting cache=3Dnone" + "to enable live migration" % path) + except OSError, e: + if e.errno =3D=3D errno.EINVAL: + wok_log.debug("Disk '%s' does not support direct I/O: " + "'%s'. Let libvirt sets the default cache mode."= % + (path, e.message)) + else: + if params['type'] !=3D 'cdrom': + driver.set('cache', 'none') =20 - if params.get('pool_type') =3D=3D "netfs": - driver.set("io", "native") + if params.get('pool_type') =3D=3D "netfs": + driver.set("io", "native") =20 disk.append(driver) =20 --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel