From nobody Fri Mar 29 11:08:56 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 14883088503211.9349014878247317; Tue, 28 Feb 2017 11:07:30 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 472138205AB; Tue, 28 Feb 2017 19:07:24 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id C9266820304 for ; Tue, 28 Feb 2017 19:06:57 +0000 (UTC) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1SIwq0f031775 for ; Tue, 28 Feb 2017 14:06:57 -0500 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0a-001b2d01.pphosted.com with ESMTP id 28webma4bs-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 28 Feb 2017 14:06:56 -0500 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 28 Feb 2017 16:06:55 -0300 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 28 Feb 2017 16:06:52 -0300 Received: from d24relay04.br.ibm.com (d24relay04.br.ibm.com [9.18.232.146]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 6B007352005F for ; Tue, 28 Feb 2017 14:06:17 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1SJ6p1e34013392 for ; Tue, 28 Feb 2017 16:06:51 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v1SJ6oBD016377 for ; Tue, 28 Feb 2017 16:06:50 -0300 Received: from jarvis.ibmmodules.com ([9.80.226.252]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v1SJ6lcX016347 for ; Tue, 28 Feb 2017 16:06:50 -0300 X-Original-To: kimchi-devel@ovirt.org From: Ramon Medeiros To: Kimchi Devel Date: Tue, 28 Feb 2017 16:06:46 -0300 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170228190647.15004-1-ramonn@linux.vnet.ibm.com> References: <20170228190647.15004-1-ramonn@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022819-0028-0000-0000-0000019B120C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022819-0029-0000-0000-000014991287 Message-Id: <20170228190647.15004-2-ramonn@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-28_15:, , 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-1612050000 definitions=main-1702280166 Subject: [Kimchi-devel] [PATCH] [Kimchi 1/2] 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 is a part of Bug fix #1092 solution Signed-off-by: Ramon Medeiros --- API.json | 11 ++++++++++- docs/API.md | 3 +++ i18n.py | 1 - model/vmstorages.py | 57 +++++++++++++++++++++++++++++++++----------------= ---- xmlutils/disk.py | 12 ++++++++++- 5 files changed, 60 insertions(+), 24 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..0414aed 100644 --- a/docs/API.md +++ b/docs/API.md @@ -253,6 +253,9 @@ Represents a snapshot of the Virtual Machine's primary = monitor. * 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. + * threads: Threads settings for disks. Values accepted: none, writethr= ough, + 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..143225c 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) - if dev_info['type'] !=3D 'cdrom': - raise InvalidOperation("KCHVMSTOR0006E") - - 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) - - dev_info.update(params) - dev, xml =3D get_disk_xml(dev_info) =20 - try: - dom.updateDeviceFlags(xml, get_vm_config_flag(dom, 'all')) - except Exception as e: - raise OperationFailed("KCHVMSTOR0009E", {'error': e.message}) + # only change path to cdrom devices + if dev_info['type'] =3D=3D 'cdrom': + + 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}) + else: + old_dev, old_xml =3D get_disk_xml(dev_info) + dev_info.update(params) + dev, xml =3D get_disk_xml(dev_info) + + # remove + self.delete(vm_name, dev_name) + + try: + dom.attachDeviceFlags(xml) + except Exception as e: + dom.attachDeviceFlags(old_xml) + 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 8edb991..9a9987a 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 @@ -50,6 +50,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']) if params['type'] !=3D 'cdrom': driver.set('cache', 'none') @@ -57,6 +59,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 Fri Mar 29 11:08:56 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 1488308857468611.6763121744094; Tue, 28 Feb 2017 11:07:37 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 722C682052A; Tue, 28 Feb 2017 19:07:36 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 734C3820304 for ; Tue, 28 Feb 2017 19:06:58 +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 v1SIwqt8073565 for ; Tue, 28 Feb 2017 14:06:58 -0500 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0a-001b2d01.pphosted.com with ESMTP id 28wexngjdv-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 28 Feb 2017 14:06:57 -0500 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 28 Feb 2017 16:06:55 -0300 Received: from d24dlp02.br.ibm.com (9.18.248.206) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 28 Feb 2017 16:06:53 -0300 Received: from d24relay02.br.ibm.com (d24relay02.br.ibm.com [9.18.232.42]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id 2ABCC1DC0054 for ; Tue, 28 Feb 2017 14:06:54 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1SJ6qvc39649484 for ; Tue, 28 Feb 2017 16:06:52 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v1SJ6q2G016387 for ; Tue, 28 Feb 2017 16:06:52 -0300 Received: from jarvis.ibmmodules.com ([9.80.226.252]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v1SJ6lcY016347 for ; Tue, 28 Feb 2017 16:06:51 -0300 X-Original-To: kimchi-devel@ovirt.org From: Ramon Medeiros To: Kimchi Devel Date: Tue, 28 Feb 2017 16:06:47 -0300 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170228190647.15004-1-ramonn@linux.vnet.ibm.com> References: <20170228190647.15004-1-ramonn@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022819-0028-0000-0000-0000019B120D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022819-0029-0000-0000-000014991288 Message-Id: <20170228190647.15004-3-ramonn@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-28_15:, , 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-1612050000 definitions=main-1702280166 Subject: [Kimchi-devel] [PATCH] [Kimchi 2/2] 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: , 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 --- tests/test_model.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_model.py b/tests/test_model.py index 95c9e08..e49e556 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -198,6 +198,13 @@ class ModelTests(unittest.TestCase): task =3D inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) =20 + # add io and cache to disk + inst.vmstorage_update("kimchi-vm", "vda", {"io": "threads"}) + inst.vmstorage_update("kimchi-vm", "vda", {"cache": "unsafe"}) + vda =3D inst.vmstorage_lookup("kimchi-vm", "vda") + self.assertEquals("unsafe", vda["cache"]) + self.assertEquals("threads", vda["io"]) + vms =3D inst.vms_get_list() self.assertTrue('kimchi-vm' in vms) =20 --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel