WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] blktapctrl: Select backend by prefix

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] blktapctrl: Select backend by prefix
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Mar 2009 11:55:11 -0700
Delivery-date: Thu, 12 Mar 2009 11:55:18 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1236883351 0
# Node ID d4ad5dd4f411f30d4e67622fde93111225c3526e
# Parent  b4f3a52c359ecfaf0553104be52ed19f615a1e64
blktapctrl: Select backend by prefix

This patch adds support for specifying the backend (tapdisk or ioemu)
to blktapctrl. Images can be specified e.g. as tap:tapdisk:aio,
tap:ioemu:qcow2 or tap:vmdk. When omitting the backend, a default is
chosen based on the image type (currently always tapdisk because ioemu
as a backend is broken until a follow-up patch series against qemu-xen
is applied)

Signed-off-by: Kevin Wolf <kwolf@xxxxxxx>
---
 tools/blktap/drivers/blktapctrl.c                |   35 +++++++++++++++++++----
 tools/blktap/drivers/tapdisk.h                   |   20 +++++--------
 tools/python/xen/xend/server/BlktapController.py |    3 +
 3 files changed, 40 insertions(+), 18 deletions(-)

diff -r b4f3a52c359e -r d4ad5dd4f411 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Thu Mar 12 15:40:52 2009 +0000
+++ b/tools/blktap/drivers/blktapctrl.c Thu Mar 12 18:42:31 2009 +0000
@@ -148,7 +148,8 @@ static int get_tapdisk_pid(blkif_t *blki
  *   return 0 on success, -1 on error.
  */
 
-static int test_path(char *path, char **dev, int *type, blkif_t **blkif)
+static int test_path(char *path, char **dev, int *type, blkif_t **blkif,
+       int* use_ioemu)
 {
        char *ptr, handle[10];
        int i, size, found = 0;
@@ -157,6 +158,17 @@ static int test_path(char *path, char **
        size = sizeof(dtypes)/sizeof(disk_info_t *);
        *type = MAX_DISK_TYPES + 1;
         *blkif = NULL;
+
+       if (!strncmp(path, "tapdisk:", strlen("tapdisk:"))) {
+               *use_ioemu = 0;
+               path += strlen("tapdisk:");
+       } else if (!strncmp(path, "ioemu:", strlen("ioemu:"))) {
+               *use_ioemu = 1;
+               path += strlen("ioemu:");
+       } else {
+               // Use the default for the image type
+               *use_ioemu = -1;
+       }
 
        if ( (ptr = strstr(path, ":"))!=NULL) {
                handle_len = (ptr - path);
@@ -174,6 +186,8 @@ static int test_path(char *path, char **
                         }
 
                        if (found) {
+                               if (*use_ioemu == -1)
+                                       *use_ioemu = dtypes[i]->use_ioemu;
                                *type = dtypes[i]->idnum;
                         
                         if (dtypes[i]->single_handler == 1) {
@@ -185,6 +199,7 @@ static int test_path(char *path, char **
                                         *blkif = active_disks[dtypes[i]
                                                              ->idnum]->blkif;
                         }
+
                         return 0;
                 }
             }
@@ -504,7 +519,8 @@ static int connect_qemu(blkif_t *blkif, 
        static int tapdisk_ioemu_pid = 0;
        static int dom0_readfd = 0;
        static int dom0_writefd = 0;
-       
+       int refresh_pid = 0;
+
        if (asprintf(&rdctldev, BLKTAP_CTRL_DIR "/qemu-read-%d", domid) < 0)
                return -1;
 
@@ -523,15 +539,23 @@ static int connect_qemu(blkif_t *blkif, 
                if (tapdisk_ioemu_pid == 0 || kill(tapdisk_ioemu_pid, 0)) {
                        /* No device model and tapdisk-ioemu doesn't run yet */
                        DPRINTF("Launching tapdisk-ioemu\n");
-                       tapdisk_ioemu_pid = launch_tapdisk_ioemu();
+                       launch_tapdisk_ioemu();
                        
                        dom0_readfd = open_ctrl_socket(wrctldev);
                        dom0_writefd = open_ctrl_socket(rdctldev);
+
+                       refresh_pid = 1;
                }
 
                DPRINTF("Using tapdisk-ioemu connection\n");
                blkif->fds[READ] = dom0_readfd;
                blkif->fds[WRITE] = dom0_writefd;
+
+               if (refresh_pid) {
+                       get_tapdisk_pid(blkif);
+                       tapdisk_ioemu_pid = blkif->tappid;
+               }
+
        } else if (access(rdctldev, R_OK | W_OK) == 0) {
                /* Use existing pipe to the device model */
                DPRINTF("Using qemu-dm connection\n");
@@ -605,13 +629,14 @@ static int blktapctrl_new_blkif(blkif_t 
        image_t *image;
        blkif_t *exist = NULL;
        static uint16_t next_cookie = 0;
+       int use_ioemu;
 
        DPRINTF("Received a poll for a new vbd\n");
        if ( ((blk=blkif->info) != NULL) && (blk->params != NULL) ) {
                if (blktap_interface_create(ctlfd, &major, &minor, blkif) < 0)
                        return -1;
 
-               if (test_path(blk->params, &ptr, &type, &exist) != 0) {
+               if (test_path(blk->params, &ptr, &type, &exist, &use_ioemu) != 
0) {
                         DPRINTF("Error in blktap device string(%s).\n",
                                 blk->params);
                         goto fail;
@@ -620,7 +645,7 @@ static int blktapctrl_new_blkif(blkif_t 
                blkif->cookie = next_cookie++;
 
                if (!exist) {
-                       if (type == DISK_TYPE_IOEMU) {
+                       if (use_ioemu) {
                                if (connect_qemu(blkif, blkif->domid))
                                        goto fail;
                        } else {
diff -r b4f3a52c359e -r d4ad5dd4f411 tools/blktap/drivers/tapdisk.h
--- a/tools/blktap/drivers/tapdisk.h    Thu Mar 12 15:40:52 2009 +0000
+++ b/tools/blktap/drivers/tapdisk.h    Thu Mar 12 18:42:31 2009 +0000
@@ -145,6 +145,8 @@ typedef struct disk_info {
        char handle[10];     /* xend handle, e.g. 'ram' */
        int  single_handler; /* is there a single controller for all */
                             /* instances of disk type? */
+       int  use_ioemu;      /* backend provider: 0 = tapdisk; 1 = ioemu */
+
 #ifdef TAPDISK
        struct tap_disk *drv;   
 #endif
@@ -167,7 +169,6 @@ extern struct tap_disk tapdisk_qcow2;
 #define DISK_TYPE_RAM      3
 #define DISK_TYPE_QCOW     4
 #define DISK_TYPE_QCOW2    5
-#define DISK_TYPE_IOEMU    6
 
 
 /*Define Individual Disk Parameters here */
@@ -176,6 +177,7 @@ static disk_info_t aio_disk = {
        "raw image (aio)",
        "aio",
        0,
+       0,
 #ifdef TAPDISK
        &tapdisk_aio,
 #endif
@@ -185,6 +187,7 @@ static disk_info_t sync_disk = {
        DISK_TYPE_SYNC,
        "raw image (sync)",
        "sync",
+       0,
        0,
 #ifdef TAPDISK
        &tapdisk_sync,
@@ -196,6 +199,7 @@ static disk_info_t vmdk_disk = {
        "vmware image (vmdk)",
        "vmdk",
        1,
+       0,
 #ifdef TAPDISK
        &tapdisk_vmdk,
 #endif
@@ -206,6 +210,7 @@ static disk_info_t ram_disk = {
        "ramdisk image (ram)",
        "ram",
        1,
+       0,
 #ifdef TAPDISK
        &tapdisk_ram,
 #endif
@@ -216,6 +221,7 @@ static disk_info_t qcow_disk = {
        "qcow disk (qcow)",
        "qcow",
        0,
+       0,
 #ifdef TAPDISK
        &tapdisk_qcow,
 #endif
@@ -226,18 +232,9 @@ static disk_info_t qcow2_disk = {
        "qcow2 disk (qcow2)",
        "qcow2",
        0,
+       0,
 #ifdef TAPDISK
        &tapdisk_qcow2,
-#endif
-};
-
-static disk_info_t ioemu_disk = {
-       DISK_TYPE_IOEMU,
-       "ioemu disk",
-       "ioemu",
-       1,
-#ifdef TAPDISK
-       NULL
 #endif
 };
 
@@ -249,7 +246,6 @@ static disk_info_t *dtypes[] = {
        &ram_disk,
        &qcow_disk,
        &qcow2_disk,
-       &ioemu_disk,
 };
 
 typedef struct driver_list_entry {
diff -r b4f3a52c359e -r d4ad5dd4f411 
tools/python/xen/xend/server/BlktapController.py
--- a/tools/python/xen/xend/server/BlktapController.py  Thu Mar 12 15:40:52 
2009 +0000
+++ b/tools/python/xen/xend/server/BlktapController.py  Thu Mar 12 18:42:31 
2009 +0000
@@ -15,7 +15,8 @@ blktap_disk_types = [
     'qcow',
     'qcow2',
 
-    'ioemu'
+    'ioemu',
+    'tapdisk',
     ]
 
 class BlktapController(BlkifController):

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] blktapctrl: Select backend by prefix, Xen patchbot-unstable <=