ia64/xen-unstable

changeset 19451:ef56cfbdd390

xenapi: Fix VDI:read_only, VDI:sharable and VBD:mode of XenAPI

I started a VM by using xm create, then I checked values of VDI
records and values of VBD records. When I gave the following disk
modes to a disk parameter, I got the following values from the records.

"r" "w" "w!"
VDI:read_only True True True <-- Always True!
VDI:sharable True True True <-- Always True!
VBD:mode RO RW RO
^^ <-- It should be RW.

This patch fixes the values of the records as follows.

"r" "w" "w!"
VDI:read_only True False False
VDI:sharable False False True
VBD:mode RO RW RW

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:31:08 2009 +0100 (2009-03-31)
parents b183684130fd
children 192bc11d7506
files tools/python/xen/xm/xenapi_create.py
line diff
     1.1 --- a/tools/python/xen/xm/xenapi_create.py	Tue Mar 31 11:29:53 2009 +0100
     1.2 +++ b/tools/python/xen/xm/xenapi_create.py	Tue Mar 31 11:31:08 2009 +0100
     1.3 @@ -218,8 +218,8 @@ class xenapi_create:
     1.4              "SR":               self.DEFAULT_STORAGE_REPOSITORY,  
     1.5              "virtual_size":     vdi.attributes["size"].value,
     1.6              "type":             vdi.attributes["type"].value,
     1.7 -            "sharable":         bool(vdi.attributes["sharable"].value),
     1.8 -            "read_only":        bool(vdi.attributes["read_only"].value),
     1.9 +            "sharable":         vdi.attributes["sharable"].value == "True",
    1.10 +            "read_only":        vdi.attributes["read_only"].value == "True",
    1.11              "other_config":     {"location":
    1.12                  vdi.attributes["src"].value}
    1.13              }
    1.14 @@ -804,6 +804,7 @@ class sxp2xml:
    1.15  
    1.16      def extract_vbd(self, vbd_sxp, document):
    1.17          src = get_child_by_name(vbd_sxp, "uname")
    1.18 +        mode = get_child_by_name(vbd_sxp, "mode")
    1.19          name = str(src.__hash__())
    1.20  
    1.21          vbd = document.createElement("vbd")
    1.22 @@ -811,8 +812,7 @@ class sxp2xml:
    1.23          vbd.attributes["name"] = "vdb" + name
    1.24          vbd.attributes["vdi"] = "vdi" + name
    1.25          vbd.attributes["mode"] \
    1.26 -            = get_child_by_name(vbd_sxp, "mode") != "w" \
    1.27 -              and "RO" or "RW"
    1.28 +            = re.search("^w!{0,1}$", mode) and "RW" or "RO"
    1.29          vbd.attributes["device"] \
    1.30              = re.sub(":cdrom$", "", get_child_by_name(vbd_sxp, "dev"))
    1.31          vbd.attributes["bootable"] = "1"
    1.32 @@ -825,17 +825,18 @@ class sxp2xml:
    1.33  
    1.34      def extract_vdi(self, vbd_sxp, document):
    1.35          src = get_child_by_name(vbd_sxp, "uname")
    1.36 +        mode = get_child_by_name(vbd_sxp, "mode")
    1.37          name = "vdi" + str(src.__hash__())
    1.38  
    1.39          vdi = document.createElement("vdi")
    1.40  
    1.41          vdi.attributes["src"] = src
    1.42          vdi.attributes["read_only"] \
    1.43 -            = (get_child_by_name(vbd_sxp, "mode") != "w") \
    1.44 -               and "True" or "False"
    1.45 +            = re.search("^w!{0,1}$", mode) and "False" or "True"
    1.46          vdi.attributes["size"] = '-1'
    1.47          vdi.attributes["type"] = "system"
    1.48 -        vdi.attributes["sharable"] = "False"
    1.49 +        vdi.attributes["sharable"] \
    1.50 +            = re.search("^w!$", mode) and "True" or "False"
    1.51          vdi.attributes["name"] = name
    1.52  
    1.53          vdi.appendChild(self.make_name_tag(name, document))