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 3 of 5] libxl: pass list of disks to libxl__build_dev

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 3 of 5] libxl: pass list of disks to libxl__build_device_model_args
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 04 Apr 2011 14:21:06 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Mon, 04 Apr 2011 06:24:49 -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 1301923169 -3600
# Node ID 8abca96d78c1368cee94c3ac5984a92aebbb2711
# Parent  8f5c77edff0b52d90cdf081891b37323df6beef3
libxl: pass list of disks to libxl__build_device_model_args

Given that we have the information available this is preferable to
picking it out of xenstore instead. We already do this for VIFs.

Only the qemu upstream version makes use of it since old qemu-xen
actually parses xenstore itself.

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

diff -r 8f5c77edff0b -r 8abca96d78c1 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:19:29 2011 +0100
@@ -40,8 +40,8 @@ static const char *libxl_tapif_script(li
 
 static char ** libxl__build_device_model_args_old(libxl__gc *gc,
                                                   libxl_device_model_info 
*info,
-                                                  libxl_device_nic *vifs,
-                                                  int num_vifs)
+                                                  libxl_device_disk *disks, 
int num_disks,
+                                                  libxl_device_nic *vifs, int 
num_vifs)
 {
     int i;
     flexarray_t *dm_args;
@@ -172,12 +172,11 @@ static char ** libxl__build_device_model
 
 static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                                                   libxl_device_model_info 
*info,
-                                                  libxl_device_nic *vifs,
-                                                  int num_vifs)
+                                                  libxl_device_disk *disks, 
int num_disks,
+                                                  libxl_device_nic *vifs, int 
num_vifs)
 {
     flexarray_t *dm_args;
-    libxl_device_disk *disks;
-    int nb, i;
+    int i;
 
     dm_args = flexarray_make(16, 1);
     if (!dm_args)
@@ -312,8 +311,7 @@ static char ** libxl__build_device_model
     flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->target_ram));
 
     if (info->type == XENFV) {
-        disks = libxl_device_disk_list(libxl__gc_owner(gc), info->domid, &nb);
-        for (i; i < nb; i++) {
+        for (i; i < num_disks; i++) {
             if (disks[i].is_cdrom) {
                 flexarray_append(dm_args, "-cdrom");
                 flexarray_append(dm_args, libxl__strdup(gc, 
disks[i].pdev_path));
@@ -321,9 +319,7 @@ static char ** libxl__build_device_model
                 flexarray_append(dm_args, libxl__sprintf(gc, "-%s", 
disks[i].vdev));
                 flexarray_append(dm_args, libxl__strdup(gc, 
disks[i].pdev_path));
             }
-            libxl_device_disk_destroy(&disks[i]);
         }
-        free(disks);
     }
     flexarray_append(dm_args, NULL);
     return (char **) flexarray_contents(dm_args);
@@ -331,8 +327,8 @@ static char ** libxl__build_device_model
 
 static char ** libxl__build_device_model_args(libxl__gc *gc,
                                               libxl_device_model_info *info,
-                                              libxl_device_nic *vifs,
-                                              int num_vifs)
+                                              libxl_device_disk *disks, int 
num_disks,
+                                              libxl_device_nic *vifs, int 
num_vifs)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int new_qemu;
@@ -340,9 +336,9 @@ static char ** libxl__build_device_model
     new_qemu = libxl_check_device_model_version(ctx, info->device_model);
 
     if (new_qemu == 1) {
-        return libxl__build_device_model_args_new(gc, info, vifs, num_vifs);
+        return libxl__build_device_model_args_new(gc, info, disks, num_disks, 
vifs, num_vifs);
     } else {
-        return libxl__build_device_model_args_old(gc, info, vifs, num_vifs);
+        return libxl__build_device_model_args_old(gc, info, disks, num_disks, 
vifs, num_vifs);
     }
 }
 
@@ -463,7 +459,7 @@ static int libxl__create_stubdom(libxl__
     xs_transaction_t t;
     libxl__device_model_starting *dm_starting = 0;
 
-    args = libxl__build_device_model_args(gc, info, vifs, num_vifs);
+    args = libxl__build_device_model_args(gc, info, disks, num_disks, vifs, 
num_vifs);
     if (!args) {
         ret = ERROR_FAIL;
         goto out;
@@ -637,7 +633,7 @@ int libxl__create_device_model(libxl__gc
         goto out;
     }
 
-    args = libxl__build_device_model_args(gc, info, vifs, num_vifs);
+    args = libxl__build_device_model_args(gc, info, disks, num_disks, vifs, 
num_vifs);
     if (!args) {
         rc = ERROR_FAIL;
         goto out;

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