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 25 of 32] tools: libxl: remove libxl_domain_build_sta

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 25 of 32] tools: libxl: remove libxl_domain_build_state from the IDL
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 18 Apr 2011 14:53:47 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 18 Apr 2011 07:27:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1303134802@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.1303134802@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1303134373 -3600
# Node ID fcf62b8dc42e85ee8a6365ec43d7e196efb94d6f
# Parent  d537fe77010c7dc5dd4b6a1766b8d53660bde7e3
tools: libxl: remove libxl_domain_build_state from the IDL

This datastructure is internal to the library.

Remove the reference from libxl_device_console. This could never have
been used from outside libxl and is only used internally to add the
primary PV console to a guest. Make an internal variant of
libxl_device_console_add which takes the build state as a paramter
instead.

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

diff -r d537fe77010c -r fcf62b8dc42e tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/libxl/libxl.c       Mon Apr 18 14:46:13 2011 +0100
@@ -1389,14 +1389,20 @@ err:
 }
 
 
/******************************************************************************/
-int libxl_device_console_add(libxl_ctx *ctx, uint32_t domid, 
libxl_device_console *console)
+int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
+                              libxl_device_console *console,
+                              libxl__domain_build_state *state)
 {
-    libxl__gc gc = LIBXL_INIT_GC(ctx);
     flexarray_t *front;
     flexarray_t *back;
     libxl__device device;
     int rc;
 
+    if (console->devid && state) {
+        rc = ERROR_INVAL;
+        goto out;
+    }
+
     front = flexarray_make(16, 1);
     if (!front) {
         rc = ERROR_NOMEM;
@@ -1416,20 +1422,20 @@ int libxl_device_console_add(libxl_ctx *
     device.kind = DEVICE_CONSOLE;
 
     flexarray_append(back, "frontend-id");
-    flexarray_append(back, libxl__sprintf(&gc, "%d", domid));
+    flexarray_append(back, libxl__sprintf(gc, "%d", domid));
     flexarray_append(back, "online");
     flexarray_append(back, "1");
     flexarray_append(back, "state");
-    flexarray_append(back, libxl__sprintf(&gc, "%d", 1));
+    flexarray_append(back, libxl__sprintf(gc, "%d", 1));
     flexarray_append(back, "domain");
-    flexarray_append(back, libxl__domid_to_name(&gc, domid));
+    flexarray_append(back, libxl__domid_to_name(gc, domid));
     flexarray_append(back, "protocol");
     flexarray_append(back, LIBXL_XENCONSOLE_PROTOCOL);
 
     flexarray_append(front, "backend-id");
-    flexarray_append(front, libxl__sprintf(&gc, "%d", console->backend_domid));
+    flexarray_append(front, libxl__sprintf(gc, "%d", console->backend_domid));
     flexarray_append(front, "limit");
-    flexarray_append(front, libxl__sprintf(&gc, "%d", LIBXL_XENCONSOLE_LIMIT));
+    flexarray_append(front, libxl__sprintf(gc, "%d", LIBXL_XENCONSOLE_LIMIT));
     flexarray_append(front, "type");
     if (console->consback == LIBXL_CONSOLE_BACKEND_XENCONSOLED)
         flexarray_append(front, "xenconsoled");
@@ -1438,30 +1444,37 @@ int libxl_device_console_add(libxl_ctx *
     flexarray_append(front, "output");
     flexarray_append(front, console->output);
 
-    if (device.devid == 0) {
-        if (console->build_state == NULL) {
-            rc = ERROR_INVAL;
-            goto out_free;
-        }
+    if (state) {
         flexarray_append(front, "port");
-        flexarray_append(front, libxl__sprintf(&gc, "%"PRIu32, 
console->build_state->console_port));
+        flexarray_append(front, libxl__sprintf(gc, "%"PRIu32, 
state->console_port));
         flexarray_append(front, "ring-ref");
-        flexarray_append(front, libxl__sprintf(&gc, "%lu", 
console->build_state->console_mfn));
+        flexarray_append(front, libxl__sprintf(gc, "%lu", state->console_mfn));
     } else {
         flexarray_append(front, "state");
-        flexarray_append(front, libxl__sprintf(&gc, "%d", 1));
+        flexarray_append(front, libxl__sprintf(gc, "%d", 1));
         flexarray_append(front, "protocol");
         flexarray_append(front, LIBXL_XENCONSOLE_PROTOCOL);
     }
 
-    libxl__device_generic_add(&gc, &device,
-                             libxl__xs_kvs_of_flexarray(&gc, back, 
back->count),
-                             libxl__xs_kvs_of_flexarray(&gc, front, 
front->count));
+    libxl__device_generic_add(gc, &device,
+                             libxl__xs_kvs_of_flexarray(gc, back, back->count),
+                             libxl__xs_kvs_of_flexarray(gc, front, 
front->count));
     rc = 0;
 out_free:
     flexarray_free(back);
     flexarray_free(front);
 out:
+    return rc;
+}
+
+int libxl_device_console_add(libxl_ctx *ctx, uint32_t domid,
+                              libxl_device_console *console)
+{
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    int rc = ERROR_INVAL;
+
+    rc = libxl__device_console_add(&gc, domid, console, NULL);
+
     libxl__free_all(&gc);
     return rc;
 }
diff -r d537fe77010c -r fcf62b8dc42e tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl     Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/libxl/libxl.idl     Mon Apr 18 14:46:13 2011 +0100
@@ -190,13 +190,6 @@ by libxl_domain_build/restore. If either
 then the user is responsible for calling
 libxl_file_reference_unmap.""")
 
-libxl_domain_build_state = Struct("domain_build_state",[
-    ("store_port",   uint32),
-    ("store_mfn",    unsigned_long),
-    ("console_port", uint32),
-    ("console_mfn",  unsigned_long),
-    ], destructor_fn=None)
-
 libxl_device_model_info = Struct("device_model_info",[
     ("domid",            libxl_domid),
     ("uuid",             libxl_uuid,  False, "this is use only with stubdom, 
and must be different from the domain uuid"),
@@ -259,7 +252,6 @@ libxl_device_console = Struct("device_co
     ("backend_domid", libxl_domid),
     ("devid", integer),
     ("consback", libxl_console_backend),
-    ("build_state", Reference(libxl_domain_build_state), True),
     ("output", string),
     ])
 
diff -r d537fe77010c -r fcf62b8dc42e tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/libxl/libxl_create.c        Mon Apr 18 14:46:13 2011 +0100
@@ -133,7 +133,7 @@ void libxl_init_dm_info(libxl_device_mod
     dm_info->xen_platform_pci = 1;
 }
 
-static int init_console_info(libxl_device_console *console, int dev_num, 
libxl_domain_build_state *state)
+static int init_console_info(libxl_device_console *console, int dev_num)
 {
     memset(console, 0x00, sizeof(libxl_device_console));
     console->devid = dev_num;
@@ -141,12 +141,11 @@ static int init_console_info(libxl_devic
     console->output = strdup("pty");
     if ( NULL == console->output )
         return ERROR_NOMEM;
-    if (state)
-        console->build_state = state;
     return 0;
 }
 
-int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, uint32_t 
domid, libxl_domain_build_state *state)
+int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info,
+                        uint32_t domid, libxl__domain_build_state *state)
 {
     char **vments = NULL, **localents = NULL;
     struct timeval start_time;
@@ -198,7 +197,8 @@ out:
 }
 
 static int domain_restore(libxl__gc *gc, libxl_domain_build_info *info,
-                          uint32_t domid, int fd, libxl_domain_build_state 
*state,
+                          uint32_t domid, int fd,
+                          libxl__domain_build_state *state,
                           libxl_device_model_info *dm_info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -403,7 +403,7 @@ static int do_domain_create(libxl__gc *g
     libxl_ctx *ctx = libxl__gc_owner(gc);
     libxl__device_model_starting *dm_starting = 0;
     libxl_device_model_info *dm_info = &d_config->dm_info;
-    libxl_domain_build_state state;
+    libxl__domain_build_state state;
     uint32_t domid;
     int i, ret;
 
@@ -464,10 +464,10 @@ static int do_domain_create(libxl__gc *g
     if (d_config->c_info.hvm) {
         libxl_device_console console;
 
-        ret = init_console_info(&console, 0, &state);
+        ret = init_console_info(&console, 0);
         if ( ret )
             goto error_out;
-        libxl_device_console_add(ctx, domid, &console);
+        libxl__device_console_add(gc, domid, &console, &state);
         libxl_device_console_destroy(&console);
 
         dm_info->domid = domid;
@@ -489,7 +489,7 @@ static int do_domain_create(libxl__gc *g
             libxl_device_vkb_add(ctx, domid, &d_config->vkbs[i]);
         }
 
-        ret = init_console_info(&console, 0, &state);
+        ret = init_console_info(&console, 0);
         if ( ret )
             goto error_out;
 
@@ -500,7 +500,7 @@ static int do_domain_create(libxl__gc *g
         if (need_qemu)
              console.consback = LIBXL_CONSOLE_BACKEND_IOEMU;
 
-        libxl_device_console_add(ctx, domid, &console);
+        libxl__device_console_add(gc, domid, &console, &state);
         libxl_device_console_destroy(&console);
 
         if (need_qemu)
diff -r d537fe77010c -r fcf62b8dc42e tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/libxl/libxl_dm.c    Mon Apr 18 14:46:13 2011 +0100
@@ -569,7 +569,7 @@ static int libxl__create_stubdom(libxl__
     libxl_device_console *console;
     libxl_domain_create_info c_info;
     libxl_domain_build_info b_info;
-    libxl_domain_build_state state;
+    libxl__domain_build_state state;
     uint32_t domid;
     char **args;
     struct xs_permissions perm[2];
@@ -684,7 +684,6 @@ retry_transaction:
                 name = libxl__sprintf(gc, "qemu-dm-%s", 
libxl_domid_to_name(ctx, info->domid));
                 libxl_create_logfile(ctx, name, &filename);
                 console[i].output = libxl__sprintf(gc, "file:%s", filename);
-                console[i].build_state = &state;
                 free(filename);
                 break;
             case STUBDOM_CONSOLE_SAVE:
@@ -698,7 +697,8 @@ retry_transaction:
                 console[i].output = "pty";
                 break;
         }
-        ret = libxl_device_console_add(ctx, domid, &console[i]);
+        ret = libxl__device_console_add(gc, domid, &console[i],
+                                    i == STUBDOM_CONSOLE_LOGGING ? &state : 
NULL);
         if (ret)
             goto out_free;
     }
diff -r d537fe77010c -r fcf62b8dc42e tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/libxl/libxl_dom.c   Mon Apr 18 14:46:13 2011 +0100
@@ -67,7 +67,7 @@ int libxl__domain_shutdown_reason(libxl_
 }
 
 int libxl__build_pre(libxl__gc *gc, uint32_t domid,
-              libxl_domain_build_info *info, libxl_domain_build_state *state)
+              libxl_domain_build_info *info, libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
@@ -91,8 +91,9 @@ int libxl__build_pre(libxl__gc *gc, uint
 }
 
 int libxl__build_post(libxl__gc *gc, uint32_t domid,
-               libxl_domain_build_info *info, libxl_domain_build_state *state,
-               char **vms_ents, char **local_ents)
+                      libxl_domain_build_info *info,
+                      libxl__domain_build_state *state,
+                      char **vms_ents, char **local_ents)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     char *dom_path, *vm_path;
@@ -145,7 +146,7 @@ retry_transaction:
 }
 
 int libxl__build_pv(libxl__gc *gc, uint32_t domid,
-             libxl_domain_build_info *info, libxl_domain_build_state *state)
+             libxl_domain_build_info *info, libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     struct xc_dom_image *dom;
@@ -277,7 +278,7 @@ static const char *libxl__domain_hvmload
 }
 
 int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
-              libxl_domain_build_info *info, libxl_domain_build_state *state)
+              libxl_domain_build_info *info, libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int ret, rc = ERROR_INVAL;
@@ -305,8 +306,9 @@ out:
 }
 
 int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid,
-                   libxl_domain_build_info *info, libxl_domain_build_state 
*state,
-                   int fd)
+                                 libxl_domain_build_info *info,
+                                 libxl__domain_build_state *state,
+                                 int fd)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     /* read signature */
diff -r d537fe77010c -r fcf62b8dc42e tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/libxl/libxl_internal.h      Mon Apr 18 14:46:13 2011 +0100
@@ -169,23 +169,33 @@ _hidden char **libxl__xs_directory(libxl
 _hidden int libxl__domain_is_hvm(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
 
+typedef struct {
+    uint32_t store_port;
+    unsigned long store_mfn;
+
+    uint32_t console_port;
+    unsigned long console_mfn;
+} libxl__domain_build_state;
+
 _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
-              libxl_domain_build_info *info, libxl_domain_build_state *state);
+              libxl_domain_build_info *info, libxl__domain_build_state *state);
 _hidden int libxl__build_post(libxl__gc *gc, uint32_t domid,
-               libxl_domain_build_info *info, libxl_domain_build_state *state,
+               libxl_domain_build_info *info, libxl__domain_build_state *state,
                char **vms_ents, char **local_ents);
 
 _hidden int libxl__build_pv(libxl__gc *gc, uint32_t domid,
-             libxl_domain_build_info *info, libxl_domain_build_state *state);
+             libxl_domain_build_info *info, libxl__domain_build_state *state);
 _hidden int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
-              libxl_domain_build_info *info, libxl_domain_build_state *state);
+              libxl_domain_build_info *info, libxl__domain_build_state *state);
 
 _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
                                  const char *old_name, const char *new_name,
                                  xs_transaction_t trans);
 
 _hidden int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid,
-                   libxl_domain_build_info *info, libxl_domain_build_state 
*state, int fd);
+                                         libxl_domain_build_info *info,
+                                         libxl__domain_build_state *state,
+                                         int fd);
 _hidden int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int 
fd, int hvm, int live, int debug);
 _hidden int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int 
fd);
 _hidden void libxl__userdata_destroyall(libxl__gc *gc, uint32_t domid);
@@ -198,6 +208,10 @@ _hidden int libxl__device_physdisk_major
 _hidden int libxl__device_disk_dev_number(char *virtpath,
                                           int *pdisk, int *ppartition);
 
+_hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
+                                      libxl_device_console *console,
+                                      libxl__domain_build_state *state);
+
 _hidden int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
                              char **bents, char **fents);
 _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device);
@@ -230,7 +244,9 @@ typedef struct {
 
 /* from xl_create */
 _hidden int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, 
uint32_t *domid);
-_hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, 
uint32_t domid, /* out */ libxl_domain_build_state *state);
+_hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info,
+                                uint32_t domid,
+                                libxl__domain_build_state *state);
 
 /* for device model creation */
 _hidden const char *libxl__domain_device_model(libxl__gc *gc,
diff -r d537fe77010c -r fcf62b8dc42e tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Mon Apr 18 14:46:13 2011 +0100
@@ -70,16 +70,6 @@ module Domain_build_info = struct
        }
 end
 
-module Domain_build_state = struct
-       type t =
-       {
-               store_port : int;
-               store_mfn : int64;
-               console_port : int;
-               console_mfn : int64;
-       }
-end
-
 type domid = int
 
 type disk_phystype =
@@ -139,7 +129,7 @@ module Device_console = struct
                consoletype : console_type;
        }
 
-       external add : t -> Domain_build_state.t -> domid -> unit = 
"stub_xl_device_console_add"
+       external add : t -> domid -> unit = "stub_xl_device_console_add"
 end
 
 module Device_vkb = struct
diff -r d537fe77010c -r fcf62b8dc42e tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli        Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli        Mon Apr 18 14:46:13 2011 +0100
@@ -70,16 +70,6 @@ module Domain_build_info : sig
        }
 end
 
-module Domain_build_state : sig
-       type t =
-       {
-               store_port : int;
-               store_mfn : int64;
-               console_port : int;
-               console_mfn : int64;
-       }
-end
-
 type domid = int
 
 type disk_phystype =
@@ -139,7 +129,7 @@ module Device_console : sig
                consoletype : console_type;
        }
 
-       external add : t -> Domain_build_state.t -> domid -> unit = 
"stub_xl_device_console_add"
+       external add : t -> domid -> unit = "stub_xl_device_console_add"
 end
 
 module Device_vkb : sig
diff -r d537fe77010c -r fcf62b8dc42e tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c    Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c    Mon Apr 18 14:46:13 2011 +0100
@@ -294,18 +294,6 @@ static int sched_credit_val(caml_gc *gc,
        CAMLreturn(0);
 }
 
-static int domain_build_state_val(caml_gc *gc, libxl_domain_build_state 
*c_val, value v)
-{
-       CAMLparam1(v);
-
-       c_val->store_port = Int_val(Field(v, 0));
-       c_val->store_mfn = Int64_val(Field(v, 1));
-       c_val->console_port = Int_val(Field(v, 2));
-       c_val->console_mfn = Int64_val(Field(v, 3));
-       
-       CAMLreturn(0);
-}
-
 static value Val_sched_credit(libxl_sched_credit *c_val)
 {
        CAMLparam0();
@@ -436,17 +424,14 @@ value stub_xl_device_nic_del(value info,
        CAMLreturn(Val_unit);
 }
 
-value stub_xl_device_console_add(value info, value state, value domid)
+value stub_xl_device_console_add(value info, value domid)
 {
-       CAMLparam3(info, state, domid);
+       CAMLparam2(info, domid);
        libxl_device_console c_info;
-       libxl_domain_build_state c_state;
        int ret;
        INIT_STRUCT();
 
        device_console_val(&gc, &c_info, info);
-       domain_build_state_val(&gc, &c_state, state);
-       c_info.build_state = &c_state;
 
        INIT_CTX();
        ret = libxl_device_console_add(ctx, Int_val(domid), &c_info);
diff -r d537fe77010c -r fcf62b8dc42e tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Mon Apr 18 14:45:49 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Mon Apr 18 14:46:13 2011 +0100
@@ -232,12 +232,6 @@ int attrib__libxl_cpuarray_set(PyObject 
     return -1;
 }
 
-int attrib__libxl_domain_build_state_ptr_set(PyObject *v, 
libxl_domain_build_state **pptr)
-{
-    PyErr_SetString(PyExc_NotImplementedError, "Setting 
domain_build_state_ptr");
-    return -1;
-}
-
 int attrib__libxl_file_reference_set(PyObject *v, libxl_file_reference *pptr)
 {
     return genwrap__string_set(v, &pptr->path);
@@ -329,12 +323,6 @@ PyObject *attrib__libxl_cpuarray_get(lib
     return list;
 }
 
-PyObject *attrib__libxl_domain_build_state_ptr_get(libxl_domain_build_state 
**pptr)
-{
-    PyErr_SetString(PyExc_NotImplementedError, "Getting 
domain_build_state_ptr");
-    return NULL;
-}
-
 PyObject *attrib__libxl_file_reference_get(libxl_file_reference *pptr)
 {
     return genwrap__string_get(&pptr->path);

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

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