[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 13 of 26 V3] libxl: vfb/vkb: use _init/_setdefault



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1330000277 0
# Node ID ee62ab4c3c9d511b201a097e42e6f3f643d2ba5f
# Parent  001f5db5cdb8097051a1fb7b6f5c21a63cfd7872
libxl: vfb/vkb: use _init/_setdefault

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

diff -r 001f5db5cdb8 -r ee62ab4c3c9d tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Feb 23 12:31:16 2012 +0000
+++ b/tools/libxl/libxl.c       Thu Feb 23 12:31:17 2012 +0000
@@ -2101,9 +2101,13 @@ out:
 }
 
 
/******************************************************************************/
-int libxl_device_vkb_init(libxl_ctx *ctx, libxl_device_vkb *vkb)
+void libxl_device_vkb_init(libxl_device_vkb *vkb)
 {
     memset(vkb, 0x00, sizeof(libxl_device_vkb));
+}
+
+int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb)
+{
     return 0;
 }
 
@@ -2129,6 +2133,9 @@ int libxl_device_vkb_add(libxl_ctx *ctx,
     libxl__device device;
     int rc;
 
+    rc = libxl__device_vkb_setdefault(gc, vkb);
+    if (rc) goto out;
+
     front = flexarray_make(16, 1);
     if (!front) {
         rc = ERROR_NOMEM;
@@ -2206,12 +2213,11 @@ out:
 }
 
 
/******************************************************************************/
-int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb)
+void libxl_device_vfb_init(libxl_device_vfb *vfb)
 {
     memset(vfb, 0x00, sizeof(libxl_device_vfb));
     vfb->vnc.enable = 1;
     vfb->vnc.passwd = NULL;
-    vfb->vnc.listen = strdup("127.0.0.1");
     vfb->vnc.display = 0;
     vfb->vnc.findunused = 1;
     vfb->keymap = NULL;
@@ -2219,6 +2225,15 @@ int libxl_device_vfb_init(libxl_ctx *ctx
     vfb->sdl.opengl = 0;
     vfb->sdl.display = NULL;
     vfb->sdl.xauthority = NULL;
+}
+
+int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb)
+{
+    if (!vfb->vnc.listen) {
+        vfb->vnc.listen = strdup("127.0.0.1");
+        if (!vfb->vnc.listen) return ERROR_NOMEM;
+    }
+
     return 0;
 }
 
@@ -2243,6 +2258,9 @@ int libxl_device_vfb_add(libxl_ctx *ctx,
     libxl__device device;
     int rc;
 
+    rc = libxl__device_vfb_setdefault(gc, vfb);
+    if (rc) goto out;
+
     front = flexarray_make(16, 1);
     if (!front) {
         rc = ERROR_NOMEM;
diff -r 001f5db5cdb8 -r ee62ab4c3c9d tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Feb 23 12:31:16 2012 +0000
+++ b/tools/libxl/libxl.h       Thu Feb 23 12:31:17 2012 +0000
@@ -536,7 +536,7 @@ int libxl_device_nic_getinfo(libxl_ctx *
                               libxl_device_nic *nic, libxl_nicinfo *nicinfo);
 
 /* Keyboard */
-int libxl_device_vkb_init(libxl_ctx *ctx, libxl_device_vkb *vkb);
+void libxl_device_vkb_init(libxl_device_vkb *vkb);
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb 
*vkb);
 int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
                             libxl_device_vkb *vkb,
@@ -544,7 +544,7 @@ int libxl_device_vkb_remove(libxl_ctx *c
 int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb 
*vkb);
 
 /* Framebuffer */
-int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb);
+void libxl_device_vfb_init(libxl_device_vfb *vfb);
 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb 
*vfb);
 int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
                             libxl_device_vfb *vfb,
diff -r 001f5db5cdb8 -r ee62ab4c3c9d tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Thu Feb 23 12:31:16 2012 +0000
+++ b/tools/libxl/libxl_create.c        Thu Feb 23 12:31:17 2012 +0000
@@ -594,9 +594,7 @@ static int do_domain_create(libxl__gc *g
         libxl__device_console_add(gc, domid, &console, &state);
         libxl_device_console_dispose(&console);
 
-        ret = libxl_device_vkb_init(ctx, &vkb);
-        if ( ret )
-            goto error_out;
+        libxl_device_vkb_init(&vkb);
         libxl_device_vkb_add(ctx, domid, &vkb);
         libxl_device_vkb_dispose(&vkb);
 
diff -r 001f5db5cdb8 -r ee62ab4c3c9d tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Thu Feb 23 12:31:16 2012 +0000
+++ b/tools/libxl/libxl_dm.c    Thu Feb 23 12:31:17 2012 +0000
@@ -614,8 +614,8 @@ static int libxl__vfb_and_vkb_from_hvm_g
     if (b_info->type != LIBXL_DOMAIN_TYPE_HVM)
         return ERROR_INVAL;
 
-    memset(vfb, 0x00, sizeof(libxl_device_vfb));
-    memset(vkb, 0x00, sizeof(libxl_device_vkb));
+    libxl_device_vfb_init(vfb);
+    libxl_device_vkb_init(vkb);
 
     vfb->backend_domid = 0;
     vfb->devid = 0;
diff -r 001f5db5cdb8 -r ee62ab4c3c9d tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Thu Feb 23 12:31:16 2012 +0000
+++ b/tools/libxl/libxl_internal.h      Thu Feb 23 12:31:17 2012 +0000
@@ -194,6 +194,8 @@ _hidden int libxl__domain_build_info_set
 _hidden int libxl__device_disk_setdefault(libxl__gc *gc,
                                           libxl_device_disk *disk);
 _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic);
+_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb);
+_hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb);
 
 struct libxl__evgen_domain_death {
     uint32_t domid;
diff -r 001f5db5cdb8 -r ee62ab4c3c9d tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Feb 23 12:31:16 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Thu Feb 23 12:31:17 2012 +0000
@@ -935,12 +935,12 @@ skip:
 
             d_config->vfbs = (libxl_device_vfb *) realloc(d_config->vfbs, 
sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));
             vfb = d_config->vfbs + d_config->num_vfbs;
-            libxl_device_vfb_init(ctx, vfb);
+            libxl_device_vfb_init(vfb);
             vfb->devid = d_config->num_vfbs;
 
             d_config->vkbs = (libxl_device_vkb *) realloc(d_config->vkbs, 
sizeof(libxl_device_vkb) * (d_config->num_vkbs + 1));
             vkb = d_config->vkbs + d_config->num_vkbs;
-            libxl_device_vkb_init(ctx, vkb);
+            libxl_device_vkb_init(vkb);
             vkb->devid = d_config->num_vkbs;
 
             p = strtok(buf2, ",");

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.