libxl: Drop internal DEVICE_TAP backend type
authorIan Campbell <ian.campbell@citrix.com>
Fri, 8 Apr 2011 15:40:58 +0000 (16:40 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 8 Apr 2011 15:40:58 +0000 (16:40 +0100)
There is no such thing with blktap2, the backend in that case is PHY.

libxl_device_disk_del was just plain wrong in this regard, fix it to
select the appropriate backend_kind.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_device.c
tools/libxl/libxl_internal.h

index a69643f7acffc6aa7feba43a633c8a164b6ffa23..b7c0bb5999ce664f9109083895f1538b357a9883 100644 (file)
@@ -950,7 +950,6 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
     flexarray_t *front;
     flexarray_t *back;
     char *dev;
-    char *backend_type;
     int devid;
     libxl__device device;
     int major, minor, rc;
@@ -970,7 +969,6 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
         goto out_free;
     }
 
-    backend_type = libxl__device_disk_string_of_backend(disk->backend);
     devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
     if (devid==-1) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Invalid or unsupported"
@@ -1021,8 +1019,6 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
                 libxl__device_disk_string_of_format(disk->format),
                 disk->pdev_path));
 
-            backend_type = "phy";
-
             /* now create a phy device to export the device to the guest */
             goto do_backend_phy;
 
@@ -1051,7 +1047,7 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
     flexarray_append(back, "dev");
     flexarray_append(back, disk->vdev);
     flexarray_append(back, "type");
-    flexarray_append(back, backend_type);
+    flexarray_append(back, libxl__device_disk_string_of_backend(disk->backend));
     flexarray_append(back, "mode");
     flexarray_append(back, disk->readwrite ? "w" : "r");
 
@@ -1093,14 +1089,30 @@ int libxl_device_disk_del(libxl_ctx *ctx, uint32_t domid,
     devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
     device.backend_domid    = disk->backend_domid;
     device.backend_devid    = devid;
-    device.backend_kind     =
-        (disk->backend == DISK_BACKEND_PHY) ? DEVICE_VBD : DEVICE_TAP;
+
+    switch (disk->backend) {
+        case DISK_BACKEND_PHY:
+            device.backend_kind = DEVICE_VBD;
+            break;
+        case DISK_BACKEND_TAP:
+            device.backend_kind = DEVICE_VBD;
+            break;
+        case DISK_BACKEND_QDISK:
+            device.backend_kind = DEVICE_QDISK;
+            break;
+        default:
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend type: %d\n",
+                       disk->backend);
+            rc = ERROR_INVAL;
+            goto out_free;
+    }
     device.domid            = domid;
     device.devid            = devid;
     device.kind             = DEVICE_VBD;
     rc = libxl__device_del(&gc, &device, wait);
     xs_rm(ctx->xsh, XBT_NULL, libxl__device_backend_path(&gc, &device));
     xs_rm(ctx->xsh, XBT_NULL, libxl__device_frontend_path(&gc, &device));
+out_free:
     libxl__free_all(&gc);
     return rc;
 }
index 3408b9b1425640c1aa7cd25c09108d7e8e725ca8..adf6292a25c87948ef4ef1881fb9b5e2749a4ffb 100644 (file)
@@ -31,7 +31,6 @@
 static const char *string_of_kinds[] = {
     [DEVICE_VIF] = "vif",
     [DEVICE_VBD] = "vbd",
-    [DEVICE_TAP] = "tap",
     [DEVICE_QDISK] = "qdisk",
     [DEVICE_PCI] = "pci",
     [DEVICE_VFB] = "vfb",
@@ -135,7 +134,7 @@ char *libxl__device_disk_string_of_backend(libxl_disk_backend backend)
 {
     switch (backend) {
         case DISK_BACKEND_QDISK: return "qdisk";
-        case DISK_BACKEND_TAP: return "tap";
+        case DISK_BACKEND_TAP: return "phy";
         case DISK_BACKEND_PHY: return "phy";
         default: return NULL;
     }
index 9fd0f58e08e727e6a5da4a73362e7f7072ba266c..256a98e831649b8b86fe809e84b67a8764358d85 100644 (file)
@@ -97,7 +97,6 @@ struct libxl__ctx {
 typedef enum {
     DEVICE_VIF = 1,
     DEVICE_VBD,
-    DEVICE_TAP,
     DEVICE_QDISK,
     DEVICE_PCI,
     DEVICE_VFB,