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-devel

[Xen-devel] [PATCH 5 of 5] libxl: specific explicit disk image format to

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 5 of 5] libxl: specific explicit disk image format to new qemu
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 04 Apr 2011 14:21:08 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Mon, 04 Apr 2011 06:27:10 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1301923263@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1301923263@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1301923242 -3600
# Node ID 5735c9124b586f95ad05b1a710c90664bb82e472
# Parent  4243987a85117cb2fe417e5290a0e894f035f85d
libxl: specific explicit disk image format to new qemu

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 4243987a8511 -r 5735c9124b58 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Mon Apr 04 14:19:29 2011 +0100
+++ b/tools/libxl/libxl_dm.c    Mon Apr 04 14:20:42 2011 +0100
@@ -170,6 +170,18 @@ static char ** libxl__build_device_model
     return (char **) flexarray_contents(dm_args);
 }
 
+static const char *qemu_disk_format_string(libxl_disk_format format)
+{
+    switch (format) {
+    case DISK_FORMAT_QCOW: return "qcow";
+    case DISK_FORMAT_QCOW2: return "qcow2";
+    case DISK_FORMAT_VHD: return "vpc";
+    case DISK_FORMAT_RAW: return "raw";
+    case DISK_FORMAT_EMPTY: return NULL;
+    default: return NULL;
+    }
+}
+
 static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                                                   libxl_device_model_info 
*info,
                                                   libxl_device_disk *disks, 
int num_disks,
@@ -315,6 +327,7 @@ static char ** libxl__build_device_model
         for (i; i < num_disks; i++) {
             int disk, part;
             int dev_number = libxl__device_disk_dev_number(disks[i].vdev, 
&disk, &part);
+            const char *format = qemu_disk_format_string(disks[i].format);
             char *drive;
 
             if (dev_number == -1) {
@@ -326,11 +339,18 @@ static char ** libxl__build_device_model
                 if (disks[i].format == DISK_FORMAT_EMPTY)
                     drive = libxl__sprintf(gc, "if=ide,index=%d,media=cdrom", 
disk);
                 else
-                    drive = libxl__sprintf(gc, 
"file=%s,if=ide,index=%d,media=cdrom",
-                                           disks[i].pdev_path, disk);
+                    drive = libxl__sprintf(gc, 
"file=%s,if=ide,index=%d,media=cdrom,format=%s",
+                                           disks[i].pdev_path, disk, format);
             } else {
-                if (disks[i].format == DISK_FORMAT_EMPTY)
+                if (disks[i].format == DISK_FORMAT_EMPTY) {
+                    LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot support empty 
disk format for %s", disks[i].vdev);
                     continue;
+                }
+
+                if (format == NULL) {
+                    LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "unable to determine 
disk image format %s", disks[i].vdev);
+                    continue;
+                }
 
                 /*
                  * Explicit sd disks are passed through as is.
@@ -339,11 +359,11 @@ static char ** libxl__build_device_model
                  * hd[a-d] and ignore the rest.
                  */
                 if (strncmp(disks[i].vdev, "sd", 2) == 0)
-                    drive = libxl__sprintf(gc, "file=%s,if=scsi,bus=0,unit=%d",
-                                           disks[i].pdev_path, disk);
+                    drive = libxl__sprintf(gc, 
"file=%s,if=scsi,bus=0,unit=%d,format=%s",
+                                           disks[i].pdev_path, disk, format);
                 else if (disk < 4)
-                    drive = libxl__sprintf(gc, 
"file=%s,if=ide,index=%d,media=disk",
-                                           disks[i].pdev_path, disk);
+                    drive = libxl__sprintf(gc, 
"file=%s,if=ide,index=%d,media=disk,format=%s",
+                                           disks[i].pdev_path, disk, format);
                 else
                     continue; /* Do not emulate this disk */
             }

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