----- Original message -----
From: Aline Manera <alinefm@linux.vnet.ibm.com>
Sent by: kimchi-devel-bounces@ovirt.org
To: harshalp@linux.vnet.ibm.com, Kimchi Devel <kimchi-devel@ovirt.org>
Cc:
Subject: Re: [Kimchi-devel] [PATCH] Issue #999: Attach storage to guest on s390x without libvirt
Date: Sat, Sep 17, 2016 1:03 AM
On 09/12/2016 06:55 AM, harshalp@linux.vnet.ibm.com wrote:
> From: Harshal Patil <harshalp@linux.vnet.ibm.com>
>
> This patch enables direct storage attachment to guests running
> on s390x arch without going through libvirt
>
> Signed-off-by: Harshal Patil <harshalp@linux.vnet.ibm.com>
> ---
> docs/API.md | 3 +++
> i18n.py | 3 +++
> model/vmstorages.py | 25 +++++++++++++++++++++++--
> utils.py | 2 +-
> 4 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/docs/API.md b/docs/API.md
> index 6678ac5..c9d5d2a 100644
> --- a/docs/API.md
> +++ b/docs/API.md
> @@ -239,6 +239,9 @@ Represents a snapshot of the Virtual Machine's primary monitor.
> * path: Path of cdrom iso.
> * pool: Storage pool which disk image file locate in.
> * vol: Storage volume name of disk image.
> + * 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
>
> ### Sub-resource: storage
> **URI:** /plugins/kimchi/vms/*:name*/storages/*:dev*
> diff --git a/i18n.py b/i18n.py
> index fc7dbc7..ceb4286 100644
> --- a/i18n.py
> +++ b/i18n.py
> @@ -332,6 +332,9 @@ messages = {
> "KCHVMSTOR0016E": _("Volume already in use by other virtual machine."),
> "KCHVMSTOR0017E": _("Only one of path or pool/volume can be specified to add a new virtual machine disk"),
> "KCHVMSTOR0018E": _("Volume chosen with format %(format)s does not fit in the storage type %(type)s"),
> + "KCHVMSTOR0019E": _("On s390x arch one of pool, path of dir_path must be specified"),
> + "KCHVMSTOR0020E": _("On s390x arch 'format' must be specified while attaching disk to virtual machine"),
> + "KCHVMSTOR0021E": _("Virtual disk already exists on the system: %(disk_path)s"),
>
> "KCHSNAP0001E": _("Virtual machine '%(vm)s' must be stopped before creating a snapshot of it."),
> "KCHSNAP0002E": _("Unable to create snapshot '%(name)s' on virtual machine '%(vm)s'. Details: %(err)s"),
> diff --git a/model/vmstorages.py b/model/vmstorages.py
> index 2e9f783..156a16f 100644
> --- a/model/vmstorages.py
> +++ b/model/vmstorages.py
> @@ -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-1301 USA
>
> +import os
> import string
> from lxml import etree
>
> @@ -30,6 +31,7 @@ from wok.plugins.kimchi.model.storagevolumes import StorageVolumeModel
> from wok.plugins.kimchi.model.utils import get_vm_config_flag
> from wok.plugins.kimchi.model.vms import DOM_STATE_MAP, VMModel
> from wok.plugins.kimchi.osinfo import lookup
> +from wok.plugins.kimchi.utils import create_disk_image, is_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
>
> @@ -82,11 +84,30 @@ class VMStoragesModel(object):
> # Path will never be blank due to API.json verification.
> # There is no need to cover this case here.
> if not ('vol' in params) ^ ('path' in params):
> - raise InvalidParameter("KCHVMSTOR0017E")
> + if not is_s390x():
> + raise InvalidParameter("KCHVMSTOR0017E")
> +
> + if 'dir_path' not in params:
> + raise InvalidParameter("KCHVMSTOR0019E")
>The dir_path is exclusively for s390x. You need to add this verification
>too.