Skip to contentSkip to conversation

: libxl: function libxl_device_disk_add returns error when detecting the vbd does not exist

PATCH New Jun Zhu (Intern) 1 participant 1 message Sep 21, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : libxl: function libxl_device_disk_add returns error when detecting the vbd does not exist

This patch returns error to the invoker when the phy:/* vbd does not exist.
I think it can be improved to better. libxl_device_disk_add is called in libxl/xl_cmdimpl.c, libxl/libxl.c, and ocaml/libs/xl/xl_stubs.c. If the error log is outputed in libxl_device_disk_add, it is better. But it has to modify these invokers.

What's your option?

tools/libxl/libxl.c +4 -1
diff -r 6d272b3f900b tools/libxl/libxl.c
@@ -1814,7 +1814,10 @@ int libxl_device_disk_add(libxl_ctx *ctx
     switch (disk->phystype) {
         case PHYSTYPE_PHY: {
 
-            libxl__device_physdisk_major_minor(disk->physpath, &major, &minor);
+            if (libxl__device_physdisk_major_minor(disk->physpath, &major, &minor) < 0) {
+                rc = ERROR_INVAL;
+                goto out_free;
+            }
             flexarray_set(back, boffset++, "physical-device");
             flexarray_set(back, boffset++, libxl__sprintf(&gc, "%x:%x", major, minor));
 

Jun Zhu
Citrix Systems UK