All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxl: basic support for virtio disk
@ 2011-05-27  2:26 Wei Liu
  2011-05-27 12:26 ` Stefano Stabellini
  0 siblings, 1 reply; 13+ messages in thread
From: Wei Liu @ 2011-05-27  2:26 UTC (permalink / raw)
  To: xen-devel; +Cc: Stefano Stabellini

commit 5672b0151ad7904e771e45d934c2f5d8aa8eac73
Author: Wei Liu <liuw@liuw.name>
Date:   Fri May 27 10:22:05 2011 +0800

    libxl: basic virtio disk support.

    Use "vd*" in vm config file to enable virtio disk.

    Virtio disk is not backed by any backend, so a new backend
    type NONE is added. More work is needed to support hotplug
    virtio disk.

    Signed-off-by: Wei Liu <liuw@liuw.name>

diff --git a/docs/misc/vbd-interface.txt b/docs/misc/vbd-interface.txt
index d97c458..83cbe39 100644
--- a/docs/misc/vbd-interface.txt
+++ b/docs/misc/vbd-interface.txt
@@ -8,7 +8,7 @@ emulated IDE or SCSI disks.
 The abstract interface involves specifying, for each block device:

  * Nominal disk type: Xen virtual disk (aka xvd*, the default); SCSI
-   (sd*); IDE (hd*).
+   (sd*); IDE (hd*); Virtio disk (vd*).

    For HVM guests, each whole-disk hd* and and sd* device is made
    available _both_ via emulated IDE resp. SCSI controller, _and_ as a
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index ccf6518..1b973c1 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -975,6 +975,9 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t
domid, libxl_device_disk *dis
                " virtual disk identifier %s", disk->vdev);
         rc = ERROR_INVAL;
         goto out_free;
+    } else if (devid==-2) {
+        LIBXL__LOG(ctx, LIBXL__LOG_INFO, "Using QEMU virtio backend for"
+                   " virtual disk %s", disk->vdev);
     }

     device.backend_devid = devid;
@@ -1028,6 +1031,9 @@ 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));
             device.backend_kind = DEVICE_QDISK;
             break;
+        case LIBXL_DISK_BACKEND_NONE:
+	    /* Nothing to do, not a Xen VBD */
+	    break;
         default:
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk
backend type: %d\n", disk->backend);
             rc = ERROR_INVAL;
diff --git a/tools/libxl/libxl.idl b/tools/libxl/libxl.idl
index a5be66f..6b27eae 100644
--- a/tools/libxl/libxl.idl
+++ b/tools/libxl/libxl.idl
@@ -54,6 +54,7 @@ libxl_disk_backend = Enumeration("disk_backend", [
     (1, "PHY"),
     (2, "TAP"),
     (3, "QDISK"),
+    (4, "NONE"),
     ])

 libxl_nic_type = Enumeration("nic_type", [
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 5d85822..25b783c 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -239,6 +239,13 @@ int libxl__device_disk_dev_number(char *virtpath,
int *pdisk, int *ppartition)
         if (ppartition) *ppartition = partition;
         return (8 << 8) | (disk << 4) | partition;
     }
+    if (device_virtdisk_matches(virtpath, "vd",
+                                &disk, 15,
+                                &partition, 15)) {
+        if (pdisk) *pdisk = disk;
+        if (ppartition) *ppartition = partition;
+        return -2;
+    }
     return -1;
 }

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 76479fe..407e8c5 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -419,6 +419,10 @@ static char **
libxl__build_device_model_args_new(libxl__gc *gc,
                     drive = libxl__sprintf
                         (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s",
                          disks[i].pdev_path, disk, format);
+                else if (strncmp(disks[i].vdev, "vd", 2) == 0)
+                    drive = libxl__sprintf
+                        (gc, "file=%s,if=virtio,index=%d,media=disk,format=%s",
+                         disks[i].pdev_path, disk, format);
                 else if (disk < 4)
                     drive = libxl__sprintf
                         (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
@@ -976,6 +980,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc,

             case LIBXL_DISK_BACKEND_PHY:
             case LIBXL_DISK_BACKEND_UNKNOWN:
+            case LIBXL_DISK_BACKEND_NONE:
                 break;
             }
         }

-- 
Best regards
Wei Liu
Twitter: @iliuw
Site: http://liuw.name

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-06-03  1:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27  2:26 [PATCH] libxl: basic support for virtio disk Wei Liu
2011-05-27 12:26 ` Stefano Stabellini
2011-05-27 13:23   ` Wei Liu
2011-05-27 15:12     ` Stefano Stabellini
2011-05-30  3:10       ` Wei Liu
2011-05-31 11:37         ` Stefano Stabellini
2011-06-01 11:09           ` Wei Liu
2011-06-01 13:59             ` Ian Jackson
2011-06-01 14:51               ` Wei Liu
2011-06-02 15:04                 ` Stefano Stabellini
2011-06-02 16:03                   ` Ian Jackson
2011-06-02 16:10                     ` Stefano Stabellini
2011-06-03  1:22                     ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.