From nobody Thu Dec 26 13:16:49 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 1490052511287759.8009345998863; Mon, 20 Mar 2017 16:28:31 -0700 (PDT) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 4CB12820671; Mon, 20 Mar 2017 23:28:30 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id D6BA3820558 for ; Mon, 20 Mar 2017 23:28:05 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2KNRvmr143649 for ; Mon, 20 Mar 2017 19:28:05 -0400 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0a-001b2d01.pphosted.com with ESMTP id 29aeac0ew4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Mar 2017 19:28:04 -0400 Received: from localhost by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Mar 2017 20:28:03 -0300 Received: from d24relay02.br.ibm.com (9.18.232.42) by e24smtp03.br.ibm.com (10.172.0.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Mar 2017 20:28:01 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2KNS08033423480 for ; Mon, 20 Mar 2017 20:28:01 -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 v2KNS0Wm025357 for ; Mon, 20 Mar 2017 20:28:00 -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 v2KNRuZX025337 for ; Mon, 20 Mar 2017 20:27:59 -0300 X-Original-To: kimchi-devel@ovirt.org From: Ramon Medeiros To: Kimchi Devel Date: Mon, 20 Mar 2017 20:27:47 -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-0024-0000-0000-00000160F6BD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032023-0025-0000-0000-00001628213A Message-Id: <20170320232750.31603-2-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 1/4] Read io and cache option from disks 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" Signed-off-by: Ramon Medeiros --- xmlutils/disk.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xmlutils/disk.py b/xmlutils/disk.py index 97298c5..76700b9 100644 --- a/xmlutils/disk.py +++ b/xmlutils/disk.py @@ -163,7 +163,9 @@ def get_vm_disk_info(dom, dev_name): 'path': path, 'type': disk.attrib['device'], 'format': disk.driver.attrib['type'], - 'bus': disk.target.attrib['bus']} + 'bus': disk.target.attrib['bus'], + 'io': disk.driver.attrib.get('io', 'none'), + 'cache': disk.driver.attrib.get('cache', 'none')} =20 =20 def get_vm_disks(dom): --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 13:16:49 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 1490052523402966.3135640174794; Mon, 20 Mar 2017 16:28:43 -0700 (PDT) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 7AB99820671; Mon, 20 Mar 2017 23:28:42 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 3805B820558 for ; Mon, 20 Mar 2017 23:28:08 +0000 (UTC) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2KNOAWT051851 for ; Mon, 20 Mar 2017 19:28:07 -0400 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0a-001b2d01.pphosted.com with ESMTP id 29ae099cym-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Mar 2017 19:28:07 -0400 Received: from localhost by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Mar 2017 20:28:04 -0300 Received: from d24relay02.br.ibm.com (9.18.232.42) by e24smtp03.br.ibm.com (10.172.0.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Mar 2017 20:28:03 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2KNS2PE39714888 for ; Mon, 20 Mar 2017 20:28:02 -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 v2KNS2gT025363 for ; Mon, 20 Mar 2017 20:28:02 -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 v2KNRuZY025337 for ; Mon, 20 Mar 2017 20:28:01 -0300 X-Original-To: kimchi-devel@ovirt.org From: Ramon Medeiros To: Kimchi Devel Date: Mon, 20 Mar 2017 20:27:48 -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-0024-0000-0000-00000160F6BE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032023-0025-0000-0000-00001628213B Message-Id: <20170320232750.31603-3-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 2/4] Allow disks to update cache and io flags 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" This allows VMs to update disks flags (io and cache). Signed-off-by: Ramon Medeiros --- API.json | 11 ++++++++++- docs/API.md | 9 +++++++++ i18n.py | 1 - model/vmstorages.py | 51 +++++++++++++++++++++++++++++++++----------------= -- xmlutils/disk.py | 10 ++++++++++ 5 files changed, 62 insertions(+), 20 deletions(-) diff --git a/API.json b/API.json index 5729e5d..abe980c 100644 --- a/API.json +++ b/API.json @@ -761,8 +761,17 @@ "description": "Path of iso image file or disk mount p= oint", "type": "string", "pattern": "^(|(/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$", - "required": true, "error": "KCHVMSTOR0003E" + }, + "cache": { + "description": "Cache options", + "type": "string", + "pattern": "^(none|writethrough|writeback|directsync|u= nsafe|default)$" + }, + "io": { + "description": "I/O options", + "type": "string", + "pattern": "^(native|threads|default)$" } }, "additionalProperties": false diff --git a/docs/API.md b/docs/API.md index 3ecc7a0..1aa7308 100644 --- a/docs/API.md +++ b/docs/API.md @@ -243,6 +243,10 @@ Represents a snapshot of the Virtual Machine's primary= monitor. * dir_path: s390x specific attribute to attach direct storage without = libvirt * format: s390x specific attribute specify the format of direct storage * size: s390x specific attribute to specify the size of direct storage + * io: IO settings for disks. Values accepted: native, threads and defa= ult. + * cache: Cache settings for disks. Values accepted: none, writethrough, + writeback, directsync, unsafe and default. + * bus: Bus type of disk. =20 ### Sub-resource: storage **URI:** /plugins/kimchi/vms/*:name*/storages/*:dev* @@ -250,9 +254,14 @@ Represents a snapshot of the Virtual Machine's primary= monitor. * dev: The name of the storage in the vm. * type: The type of the storage (currently support 'cdrom' and 'disk'). * path: Path of cdrom iso or disk image file. + * io: IO settings for disks. + * cache: Cache settings for disks. * bus: Bus type of disk attached. * **PUT**: Update storage information * path: Path of cdrom iso. Can not be blank. Now just support cdrom ty= pe. + * io: IO settings for disks. Values accepted: native, threads and defa= ult. + * cache: Cache settings for disks. Values accepted: none, writethrough, + writeback, directsync, unsafe and default. * **DELETE**: Remove the storage. =20 **Actions (POST):** diff --git a/i18n.py b/i18n.py index 4460ce5..4bb3a4f 100644 --- a/i18n.py +++ b/i18n.py @@ -327,7 +327,6 @@ messages =3D { =20 "KCHVMSTOR0002E": _("Invalid storage type. Types supported: 'cdrom', '= disk'"), "KCHVMSTOR0003E": _("The path '%(value)s' is not a valid local/remote = path for the device"), - "KCHVMSTOR0006E": _("Only CDROM path can be update."), "KCHVMSTOR0007E": _("The storage device %(dev_name)s does not exist in= the virtual machine %(vm_name)s"), "KCHVMSTOR0008E": _("Error while creating new storage device: %(error)= s"), "KCHVMSTOR0009E": _("Error while updating storage device: %(error)s"), diff --git a/model/vmstorages.py b/model/vmstorages.py index db68121..007e88c 100644 --- a/model/vmstorages.py +++ b/model/vmstorages.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 @@ -35,7 +35,6 @@ from wok.plugins.kimchi.utils import create_disk_image, i= s_s390x from wok.plugins.kimchi.xmlutils.disk import get_device_node, get_disk_xml from wok.plugins.kimchi.xmlutils.disk import get_vm_disk_info, get_vm_disks =20 - HOTPLUG_TYPE =3D ['scsi', 'virtio'] =20 =20 @@ -232,26 +231,42 @@ class VMStorageModel(object): dom =3D VMModel.get_vm(vm_name, self.conn) =20 dev_info =3D self.lookup(vm_name, dev_name) + + # only change path to cdrom devices if dev_info['type'] !=3D 'cdrom': - raise InvalidOperation("KCHVMSTOR0006E") + old_dev, old_xml =3D get_disk_xml(dev_info) + dev_info.update(params) + dev, xml =3D get_disk_xml(dev_info) =20 - params['path'] =3D params.get('path', '') - old_disk_path =3D dev_info['path'] - new_disk_path =3D params['path'] - if new_disk_path !=3D old_disk_path: - # An empty path means a CD-ROM was empty or ejected: - if old_disk_path is not '': - old_disk_used_by =3D get_disk_used_by(self.conn, old_disk_= path) - if new_disk_path is not '': - new_disk_used_by =3D get_disk_used_by(self.conn, new_disk_= path) + # remove + self.delete(vm_name, dev_name) =20 - dev_info.update(params) - dev, xml =3D get_disk_xml(dev_info) + try: + dom.attachDeviceFlags(xml) + except Exception as e: + dom.attachDeviceFlags(old_xml) + raise OperationFailed("KCHVMSTOR0009E", {'error': e.messag= e}) =20 - try: - dom.updateDeviceFlags(xml, get_vm_config_flag(dom, 'all')) - except Exception as e: - raise OperationFailed("KCHVMSTOR0009E", {'error': e.message}) + else: + dev_info.update(params) + dev, xml =3D get_disk_xml(dev_info) + + params['path'] =3D params.get('path', '') + old_disk_path =3D dev_info['path'] + new_disk_path =3D params['path'] + if new_disk_path !=3D old_disk_path: + # An empty path means a CD-ROM was empty or ejected: + if old_disk_path is not '': + old_disk_used_by =3D get_disk_used_by(self.conn, + old_disk_path) + if new_disk_path is not '': + new_disk_used_by =3D get_disk_used_by(self.conn, + new_disk_path) + + try: + dom.updateDeviceFlags(xml, get_vm_config_flag(dom, 'all')) + except Exception as e: + raise OperationFailed("KCHVMSTOR0009E", {'error': e.messag= e}) =20 try: if old_disk_used_by is not None and \ diff --git a/xmlutils/disk.py b/xmlutils/disk.py index 76700b9..ff01190 100644 --- a/xmlutils/disk.py +++ b/xmlutils/disk.py @@ -51,6 +51,8 @@ def get_disk_xml(params): if disk_type is None: 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']) try: fd =3D os.open(path, os.O_RDONLY | os.O_DIRECT) @@ -69,6 +71,14 @@ def get_disk_xml(params): if params.get('pool_type') =3D=3D "netfs": driver.set("io", "native") =20 + # set io + if params.get("io") is not None: + driver.set("io", params.get("io")) + + # set cache + if params.get("cache") is not None: + driver.set("cache", params.get("cache")) + disk.append(driver) =20 # Get device name according to bus and index values --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 13:16:49 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 From nobody Thu Dec 26 13:16:49 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 1490052546844211.05497213917636; Mon, 20 Mar 2017 16:29:06 -0700 (PDT) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id E6E4B8204E8; Mon, 20 Mar 2017 23:29:05 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id BA6DA820650 for ; Mon, 20 Mar 2017 23:28:10 +0000 (UTC) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2KNO0hD054488 for ; Mon, 20 Mar 2017 19:28:10 -0400 Received: from e24smtp02.br.ibm.com (e24smtp02.br.ibm.com [32.104.18.86]) by mx0b-001b2d01.pphosted.com with ESMTP id 29amb5tqs8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Mar 2017 19:28:09 -0400 Received: from localhost by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Mar 2017 20:28:07 -0300 Received: from d24relay02.br.ibm.com (9.18.232.42) by e24smtp02.br.ibm.com (10.172.0.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Mar 2017 20:28:06 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2KNS5qR39714892 for ; Mon, 20 Mar 2017 20:28:05 -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 v2KNS5H7025381 for ; Mon, 20 Mar 2017 20:28:05 -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 v2KNRuZa025337 for ; Mon, 20 Mar 2017 20:28:04 -0300 X-Original-To: kimchi-devel@ovirt.org From: Ramon Medeiros To: Kimchi Devel Date: Mon, 20 Mar 2017 20:27:50 -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> MIME-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17032023-0020-0000-0000-00000295FAE4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032023-0021-0000-0000-000030B21F28 Message-Id: <20170320232750.31603-5-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 4/4] Add tests to verify if cache and io of a disk can be changed 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: , Content-Type: text/plain; charset="utf-8" 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 Tests run both on update and template creation Signed-off-by: Ramon Medeiros --- tests/test_rest.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/tests/test_rest.py b/tests/test_rest.py index 852e4bd..96a5216 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -151,10 +151,35 @@ class RestTests(unittest.TestCase): self.assertEquals(200, resp.status) =20 def test_edit_vm(self): + disks =3D [ + {'index': 0, 'size': 10, 'format': 'qcow2', + 'pool': {"name": "/plugins/kimchi/storagepools/default-pool"}= }, + {'index': 1, 'size': 10, 'format': 'qcow2', 'io': 'threads', + 'cache': 'unsafe', 'bus': 'scsi', + 'pool': {"name": "/plugins/kimchi/storagepools/default-pool"}= }] + req =3D json.dumps({'name': 'test', - 'source_media': {'type': 'disk', 'path': fake_is= o}}) + 'source_media': {'type': 'disk', 'path': fake_is= o}, + 'disks': disks}) + resp =3D self.request('/plugins/kimchi/templates', req, 'POST') self.assertEquals(201, resp.status) + resp =3D json.loads(resp.read()) + + # update template storage + req =3D json.dumps({'disks': [ + {'index': 0, 'size': 10, 'format': 'qcow2', + 'pool': {"name": "/plugins/kimchi/storagepools/default-pool"}, + 'io': 'threads', 'cache': 'unsafe', 'bus': 'virtio'}, + {'index': 1, 'size': 10, 'format': 'qcow2', 'io': 'threads', + 'cache': 'unsafe', 'bus': 'scsi', + 'pool': {"name": "/plugins/kimchi/storagepools/default-pool"}= }]}) + resp =3D self.request('/plugins/kimchi/templates/' + str(resp["nam= e"]), + req, 'PUT') + resp =3D json.loads(resp.read()) + self.assertEquals(resp['disks'][0]['bus'], 'virtio') + self.assertEquals(resp['disks'][0]['cache'], 'unsafe') + self.assertEquals(resp['disks'][0]['io'], 'threads') =20 req =3D json.dumps({'name': 'vm-1', 'template': '/plugins/kimchi/templates/test'}) @@ -166,6 +191,23 @@ class RestTests(unittest.TestCase): vm =3D json.loads(self.request('/plugins/kimchi/vms/vm-1').read()) self.assertEquals('vm-1', vm['name']) =20 + # test vm storage + storages =3D json.loads( + self.request('/plugins/kimchi/vms/vm-1/storages').read()) + self.assertEquals(len(storages), 3) + + # test sdb disk + resp =3D self.request('/plugins/kimchi/vms/vm-1/storages/sdb', 'GE= T') + self.assertEquals(resp.status, 200) + scsi_disk =3D json.loads(resp.read()) + self.assertEquals(scsi_disk['cache'], 'unsafe') + self.assertEquals(scsi_disk['io'], 'threads') + + # remove sdb disk + resp =3D self.request('/plugins/kimchi/vms/vm-1/storages/sdb', + '', 'DELETE') + self.assertEquals(resp.status, 204) + req =3D json.dumps({'cpu_info': {'maxvcpus': 5, 'vcpus': 3}}) resp =3D self.request('/plugins/kimchi/vms/vm-1', req, 'PUT') self.assertEquals(200, resp.status) @@ -330,6 +372,34 @@ class RestTests(unittest.TestCase): resp =3D self.request('/plugins/kimchi/vms/=E2=88=A8=D0=BC-=D1=86= =D1=80d=CE=B1t=D0=B5d', req, 'PUT') self.assertEquals(400, resp.status) =20 + # add volume as scsi + mock_base =3D '/tmp/mock.img' + os.system("qemu-img create -f qcow2 %s 100M" % mock_base) + req =3D json.dumps({'type': 'disk', + 'path': mock_base, + 'bus': 'scsi'}) + resp =3D self.request('/plugins/kimchi/vms/=E2=88=A8=D0=BC-=D1=86= =D1=80d=CE=B1t=D0=B5d/storages', + req, 'POST') + self.assertEquals(201, resp.status) + resp =3D json.loads(resp.read()) + self.assertEquals("scsi", resp["bus"]) + dev =3D resp["dev"] + + # change io/cache + req =3D json.dumps({"io": "threads", "cache": "unsafe"}) + resp =3D self.request('/plugins/kimchi/vms/=E2=88=A8=D0=BC-=D1=86= =D1=80d=CE=B1t=D0=B5d/storages/' + + str(dev), req, 'PUT') + self.assertEquals(200, resp.status) + resp =3D json.loads(resp.read()) + self.assertEquals('threads', resp['io']) + self.assertEquals('unsafe', resp['cache']) + + # remove disk + resp =3D self.request('/plugins/kimchi/vms/=E2=88=A8=D0=BC-=D1=86= =D1=80d=CE=B1t=D0=B5d/storages/' + + str(dev), req, 'DELETE') + os.system("rm -rf " + mock_base) + self.assertEquals(204, resp.status) + def test_vm_lifecycle(self): # Create a Template req =3D json.dumps({'name': 'test', --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel