[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC 8/9] libxl: introduce specific error codes in libxl_device_cdrom_insert



Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
---
 tools/libxl/libxl.c         | 12 ++++++------
 tools/libxl/libxl_device.c  |  6 +++---
 tools/libxl/libxl_qmp.c     |  4 +++-
 tools/libxl/libxl_types.idl | 22 +++++++++++++++++++++-
 4 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 2f56c6e..f41f291 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2848,25 +2848,25 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
 
     libxl_domain_type type = libxl__domain_type(gc, domid);
     if (type == LIBXL_DOMAIN_TYPE_INVALID) {
-        rc = ERROR_FAIL;
+        rc = ERROR_INVAL_DOMAIN_TYPE;
         goto out;
     }
     if (type != LIBXL_DOMAIN_TYPE_HVM) {
         LOG(ERROR, "cdrom-insert requires an HVM domain");
-        rc = ERROR_INVAL;
+        rc = ERROR_NOHVM;
         goto out;
     }
 
     if (libxl_get_stubdom_id(ctx, domid) != 0) {
         LOG(ERROR, "cdrom-insert doesn't work for stub domains");
-        rc = ERROR_INVAL;
+        rc = ERROR_STUBDOM;
         goto out;
     }
 
     dm_ver = libxl__device_model_version_running(gc, domid);
     if (dm_ver == -1) {
         LOG(ERROR, "cannot determine device model version");
-        rc = ERROR_FAIL;
+        rc = ERROR_DM_VERSION_UNDETERMINED;
         goto out;
     }
 
@@ -2881,7 +2881,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
     }
     if (i == num) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual device not found");
-        rc = ERROR_FAIL;
+        rc = ERROR_DISK_VDEV_NOT_FOUND;
         goto out;
     }
 
@@ -2941,7 +2941,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
         {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Internal error: %s does not 
exist",
                        libxl__sprintf(gc, "%s/frontend", path));
-            rc = ERROR_FAIL;
+            rc = ERROR_INTERNAL;
             goto out;
         }
 
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 56c6e2e..1c5f659 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -271,7 +271,7 @@ int libxl__device_disk_set_backend(libxl__gc *gc, 
libxl_device_disk *disk) {
     if (disk->format == LIBXL_DISK_FORMAT_EMPTY) {
         if (!disk->is_cdrom) {
             LOG(ERROR, "Disk vdev=%s is empty but not cdrom", disk->vdev);
-            return ERROR_INVAL;
+            return ERROR_INVAL_DISK_FORMAT;
         }
         memset(&a.stab, 0, sizeof(a.stab));
     } else if ((disk->backend == LIBXL_DISK_BACKEND_UNKNOWN ||
@@ -281,7 +281,7 @@ int libxl__device_disk_set_backend(libxl__gc *gc, 
libxl_device_disk *disk) {
         if (stat(disk->pdev_path, &a.stab)) {
             LOGE(ERROR, "Disk vdev=%s failed to stat: %s",
                         disk->vdev, disk->pdev_path);
-            return ERROR_INVAL;
+            return ERROR_DISK_PDEV_NOT_FOUND;
         }
     }
 
@@ -299,7 +299,7 @@ int libxl__device_disk_set_backend(libxl__gc *gc, 
libxl_device_disk *disk) {
     }
     if (!ok) {
         LOG(ERROR, "no suitable backend for disk %s", disk->vdev);
-        return ERROR_INVAL;
+        return ERROR_DISK_BACKEND_UNDETERMINED;
     }
     disk->backend = ok;
     return 0;
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index 9aa7e2e..c687e86 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -817,9 +817,11 @@ static int qmp_run_command(libxl__gc *gc, int domid,
 
     qmp = libxl__qmp_initialize(gc, domid);
     if (!qmp)
-        return ERROR_FAIL;
+        return ERROR_QMP_INIT;
 
     rc = qmp_synchronous_send(qmp, cmd, args, callback, opaque, qmp->timeout);
+    if (rc < 0)
+        rc = ERROR_QMP_SEND;
 
     libxl__qmp_close(qmp);
     return rc;
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 15e4af2..88262ca 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -107,6 +107,10 @@ libxl_error = Enumeration("error", [
     # Requested domain was not found
     (-21, "DOMAIN_NOTFOUND"),
     
+    # Internal error; not actionable by the caller other than by doing 
something like
+    # a retry/reboot (perhaps a libxl bug)
+    (ENUM_PREV, "INTERNAL"),
+    
     # Xenstore errors
     (ENUM_PREV, "XS_CONNECT"),
     (ENUM_PREV, "XS_READ"),
@@ -132,12 +136,28 @@ libxl_error = Enumeration("error", [
     # Disk parameters invalid
     (ENUM_PREV, "INVAL_DISK_VDEV"),
     (ENUM_PREV, "INVAL_DISK_BACKEND"),
+    (ENUM_PREV, "INVAL_DISK_FORMAT"),
     
     # Disk parameters could not be determined
     (ENUM_PREV, "DISK_VDEV_UNDETERMINED"),
+    (ENUM_PREV, "DISK_BACKEND_UNDETERMINED"),
     
-    # Physical disk device could not be found
+    # Physical/virtual disk device could not be found
     (ENUM_PREV, "DISK_PDEV_NOT_FOUND"),
+    (ENUM_PREV, "DISK_VDEV_NOT_FOUND"),
+    
+    # Operation requires an HVM domain
+    (ENUM_PREV, "NOHVM"),
+
+    # Operation is not compatible with a stub domain
+    (ENUM_PREV, "STUBDOM"),
+    
+    # Device model version could not be determined
+    (ENUM_PREV, "DM_VERSION_UNDETERMINED"),
+    
+    # QMP errors
+    (ENUM_PREV, "QMP_INIT"),
+    (ENUM_PREV, "QMP_SEND"),
     ], value_namespace = "")
 
 libxl_domain_type = Enumeration("domain_type", [
-- 
2.4.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.