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 10 of 27 v3] libxl: reimplement devid->nic in terms o

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 10 of 27 v3] libxl: reimplement devid->nic in terms of from_xs_be function
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Tue, 18 Oct 2011 13:55:05 +0100
Cc: ian.jackson@xxxxxxxxxx
Delivery-date: Tue, 18 Oct 2011 06:17:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1318942495@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.1318942495@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1318941402 -3600
# Node ID 88488c1c2d316b0ab025c40eeec22c4c3e8e2c3b
# Parent  7799bad1a323ea5299f61cd1361833631e018fac
libxl: reimplement devid->nic in terms of from_xs_be function.

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

diff -r 7799bad1a323 -r 88488c1c2d31 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Tue Oct 18 13:36:42 2011 +0100
+++ b/tools/libxl/libxl.c       Tue Oct 18 13:36:42 2011 +0100
@@ -1315,7 +1315,7 @@ static void libxl__device_nic_from_xs_be
                   libxl__sprintf(gc, "%s/mac", be_path), &len);
     rc = libxl__parse_mac(tmp, nic->mac);
     if (rc)
-            memset(nic->mac, 0, sizeof(nic->mac));
+        memset(nic->mac, 0, sizeof(nic->mac));
 
     nic->ip = xs_read(ctx->xsh, XBT_NULL,
                       libxl__sprintf(gc, "%s/ip", be_path), &len);
@@ -1332,6 +1332,32 @@ static void libxl__device_nic_from_xs_be
     nic->ifname = NULL; /* XXX Only for TYPE_IOEMU */
 }
 
+int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t domid,
+                              const char *devid, libxl_device_nic *nic)
+{
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    char *dompath, *path;
+    int rc = ERROR_FAIL;
+
+    memset(nic, 0, sizeof (libxl_device_nic));
+    dompath = libxl__xs_get_dompath(&gc, domid);
+    if (!dompath)
+        goto out;
+
+    path = libxl__xs_read(&gc, XBT_NULL,
+                          libxl__sprintf(&gc, "%s/device/vif/%s/backend",
+                                         dompath, devid));
+    if (!path)
+        goto out;
+
+    libxl__device_nic_from_xs_be(&gc, path, nic);
+
+    rc = 0;
+out:
+    libxl__free_all(&gc);
+    return rc;
+}
+
 static int libxl__append_nic_list_of_type(libxl__gc *gc,
                                            uint32_t domid,
                                            const char *type,
diff -r 7799bad1a323 -r 88488c1c2d31 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Tue Oct 18 13:36:42 2011 +0100
+++ b/tools/libxl/libxl_utils.c Tue Oct 18 13:36:42 2011 +0100
@@ -483,41 +483,6 @@ int libxl_mac_to_device_nic(libxl_ctx *c
     return rc;
 }
 
-int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t domid,
-                              const char *devid, libxl_device_nic *nic)
-{
-    libxl__gc gc = LIBXL_INIT_GC(ctx);
-    char *val;
-    char *dompath, *nic_path_fe, *nic_path_be;
-    int rc = ERROR_FAIL;
-
-    memset(nic, 0, sizeof (libxl_device_nic));
-    dompath = libxl__xs_get_dompath(&gc, domid);
-    if (!dompath) {
-        goto out;
-    }
-    nic_path_fe = libxl__sprintf(&gc, "%s/device/vif/%s", dompath, devid);
-    nic_path_be = libxl__xs_read(&gc, XBT_NULL,
-                                libxl__sprintf(&gc, "%s/backend", 
nic_path_fe));
-    val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend-id", 
nic_path_fe));
-    if ( NULL == val ) {
-        goto out;
-    }
-    nic->backend_domid = strtoul(val, NULL, 10);
-    nic->devid = strtoul(devid, NULL, 10);
-
-    val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/mac", 
nic_path_fe));
-    rc = libxl__parse_mac(val, nic->mac);
-    if (rc)
-        goto out;
-
-    nic->script = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "%s/script", 
nic_path_be), NULL);
-    rc = 0;
-out:
-    libxl__free_all(&gc);
-    return rc;
-}
-
 int libxl_devid_to_device_disk(libxl_ctx *ctx, uint32_t domid,
                                const char *devid, libxl_device_disk *disk)
 {

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

<Prev in Thread] Current Thread [Next in Thread>