From nobody Sat Jul 27 06:49:48 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 1490052534499405.8070711288251; Mon, 20 Mar 2017 16:28:54 -0700 (PDT) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id A8CDE820558; Mon, 20 Mar 2017 23:28:53 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 772A2820650 for ; Mon, 20 Mar 2017 23:28:08 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2KNOHe8041979 for ; Mon, 20 Mar 2017 19:28:07 -0400 Received: from e24smtp01.br.ibm.com (e24smtp01.br.ibm.com [32.104.18.85]) by mx0b-001b2d01.pphosted.com with ESMTP id 29af6ewecj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Mar 2017 19:28:07 -0400 Received: from localhost by e24smtp01.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Mar 2017 20:28:05 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp01.br.ibm.com (10.172.0.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Mar 2017 20:28:04 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2KNS3OC31457532 for ; Mon, 20 Mar 2017 20:28:04 -0300 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2KNS3I9025376 for ; Mon, 20 Mar 2017 20:28:03 -0300 Received: from jarvis.ibmmodules.com ([9.85.180.226]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2KNRuZZ025337 for ; Mon, 20 Mar 2017 20:28:02 -0300 X-Original-To: kimchi-devel@ovirt.org From: Ramon Medeiros To: Kimchi Devel Date: Mon, 20 Mar 2017 20:27:49 -0300 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170320232750.31603-1-ramonn@linux.vnet.ibm.com> References: <20170320232750.31603-1-ramonn@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17032023-1523-0000-0000-0000028D2A32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032023-1524-0000-0000-00002A235180 Message-Id: <20170320232750.31603-4-ramonn@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-20_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-1703200198 Subject: [Kimchi-devel] [PATCH] [Kimchi 3/4] Bug fix #1091: Allow to set disk performance options per guest and template 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" Allow templates to set and update io, cache and bus of the disks. Signed-off-by: Ramon Medeiros --- API.json | 15 +++++++++++++++ docs/API.md | 3 +++ model/vmstorages.py | 4 +++- vmtemplate.py | 19 ++++++++++++++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/API.json b/API.json index abe980c..bae9c9c 100644 --- a/API.json +++ b/API.json @@ -658,6 +658,21 @@ "error": "KCHTMPL0015E" } } + }, + "cache": { + "description": "Cache options", + "type": "string", + "pattern": "^(none|writethrough|writeback|= directsync|unsafe|default)$" + }, + "io": { + "description": "I/O options", + "type": "string", + "pattern": "^(native|threads|default)$" + }, + "bus": { + "description": "Bus disk", + "type": "string", + "pattern": "^(scsi|virtio|ide)$" } } }, diff --git a/docs/API.md b/docs/API.md index 1aa7308..2312002 100644 --- a/docs/API.md +++ b/docs/API.md @@ -344,6 +344,9 @@ Represents a snapshot of the Virtual Machine's primary = monitor. * format: Format of the image. Valid formats: qcow, qcow2, qed, ra= w, vmdk, vpc * pool: Storage pool information * name: URI of the storagepool where disk will be created + * io: Set io flag + * cache: Set cache flag + * bus: Set bus flag * graphics *(optional)*: The graphics paramenters of this template * type: The type of graphics. It can be VNC or spice or None. * vnc: Graphical display using the Virtual Network diff --git a/model/vmstorages.py b/model/vmstorages.py index 007e88c..bf55300 100644 --- a/model/vmstorages.py +++ b/model/vmstorages.py @@ -91,7 +91,9 @@ class VMStoragesModel(object): raise InvalidParameter("KCHVMSTOR0019E") =20 dom =3D VMModel.get_vm(vm_name, self.conn) - params['bus'] =3D _get_device_bus(params['type'], dom) + + if params.get('bus') is None: + params['bus'] =3D _get_device_bus(params['type'], dom) =20 if is_s390x() and params['type'] =3D=3D 'disk' and 'dir_path' in p= arams: if 'format' not in params: diff --git a/vmtemplate.py b/vmtemplate.py index 1acd4db..3f37d1a 100644 --- a/vmtemplate.py +++ b/vmtemplate.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 @@ -144,6 +144,12 @@ class VMTemplate(object): =20 keys =3D sorted(disk_info.keys()) =20 + # remove optional parameters + optional =3D ["bus", "io", "cache"] + for opt in optional: + if opt in keys: + keys.remove(opt) + if ((keys !=3D sorted(basic_disk)) and (keys !=3D sorted(ro_disk)) and (keys !=3D sorted(base_disk))): @@ -253,6 +259,7 @@ class VMTemplate(object): return xml =20 def _get_disks_xml(self, vm_uuid): + optional =3D ["io", "cache"] base_disk_params =3D {'type': 'disk', 'disk': 'file', 'bus': self.info['disk_bus']} logical_disk_params =3D {'format': 'raw'} @@ -267,6 +274,16 @@ class VMTemplate(object): params =3D dict(base_disk_params) params['format'] =3D disk['format'] params['index'] =3D index + + # bus passed: overwrite + if disk.get("bus") is not None: + params["bus"] =3D disk.get("bus") + + # add optionals + for opt in optional: + if disk.get(opt) is not None: + params[opt] =3D disk[opt] + if disk.get('pool'): params.update(locals().get('%s_disk_params' % disk['pool']['type'], {})) --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel