Skip to contentSkip to conversation

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

PATCH Masaki Kanno 1 participant 1 message Mar 25, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

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

Best regards,
Kan

tools/python/xen/xm/xenapi_create.py +8 -7
diff -r 0477f9061c8a tools/python/xen/xm/xenapi_create.py
@@ -218,8 +218,8 @@ class xenapi_create:
             "SR":               self.DEFAULT_STORAGE_REPOSITORY,  
             "virtual_size":     vdi.attributes["size"].value,
             "type":             vdi.attributes["type"].value,
-            "sharable":         bool(vdi.attributes["sharable"].value),
-            "read_only":        bool(vdi.attributes["read_only"].value),
+            "sharable":         vdi.attributes["sharable"].value == "True",
+            "read_only":        vdi.attributes["read_only"].value == "True",
             "other_config":     {"location":
                 vdi.attributes["src"].value}
             }
@@ -804,6 +804,7 @@ class sxp2xml:
 
     def extract_vbd(self, vbd_sxp, document):
         src = get_child_by_name(vbd_sxp, "uname")
+        mode = get_child_by_name(vbd_sxp, "mode")
         name = str(src.__hash__())
 
         vbd = document.createElement("vbd")
@@ -811,8 +812,7 @@ class sxp2xml:
         vbd.attributes["name"] = "vdb" + name
         vbd.attributes["vdi"] = "vdi" + name
         vbd.attributes["mode"] \
-            = get_child_by_name(vbd_sxp, "mode") != "w" \
-              and "RO" or "RW"
+            = re.search("^w!{0,1}$", mode) and "RW" or "RO"
         vbd.attributes["device"] \
             = re.sub(":cdrom$", "", get_child_by_name(vbd_sxp, "dev"))
         vbd.attributes["bootable"] = "1"
@@ -825,17 +825,18 @@ class sxp2xml:
 
     def extract_vdi(self, vbd_sxp, document):
         src = get_child_by_name(vbd_sxp, "uname")
+        mode = get_child_by_name(vbd_sxp, "mode")
         name = "vdi" + str(src.__hash__())
 
         vdi = document.createElement("vdi")
 
         vdi.attributes["src"] = src
         vdi.attributes["read_only"] \
-            = (get_child_by_name(vbd_sxp, "mode") != "w") \
-               and "True" or "False"
+            = re.search("^w!{0,1}$", mode) and "False" or "True"
         vdi.attributes["size"] = '-1'
         vdi.attributes["type"] = "system"
-        vdi.attributes["sharable"] = "False"
+        vdi.attributes["sharable"] \
+            = re.search("^w!$", mode) and "True" or "False"
         vdi.attributes["name"] = name
 
         vdi.appendChild(self.make_name_tag(name, document))

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel