Skip to contentSkip to conversation

xl: remove all local "ctx" variables

PATCH In review Ian Campbell 2 participants 4 messages May 17, 2012 – May 29, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xl: remove all local "ctx" variables

# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1337262494 -3600
# Node ID bb377172ef57bed114ad688d8019fef98a08267f # Parent 5bc483bc723e8b9563ba3763fe926cc6ebe6a980
xl: remove all local "ctx" variables.

xl has a global "ctx" variable, so there should be no need to pass a ctx to any function.

---
v2: remove autoconnect_console change to ctx_ignored -- IanJ already handled that in "libxl, xl: fix bootloader immediate console attach"

tools/libxl/xl.c +1 -1
diff -r 5bc483bc723e -r bb377172ef57 tools/libxl/xl.c
@@ -108,7 +108,7 @@ void postfork(void)
     }
 }
 
-pid_t xl_fork(libxl_ctx *ctx) {
+pid_t xl_fork(void) {
     pid_t pid;
 
     pid = fork();
tools/libxl/xl.h +1 -1
diff -r 5bc483bc723e -r bb377172ef57 tools/libxl/xl.h
@@ -107,7 +107,7 @@ struct cmd_spec *cmdtable_lookup(const c
 
 extern libxl_ctx *ctx;
 extern xentoollog_logger_stdiostream *logger;
-pid_t xl_fork(libxl_ctx *ctx); /* like fork, but prints and dies if it fails */
+pid_t xl_fork(void); /* like fork, but prints and dies if it fails */
 void postfork(void);
 
 /* global options */
tools/libxl/xl_cmdimpl.c +9 -9
diff -r 5bc483bc723e -r bb377172ef57 tools/libxl/xl_cmdimpl.c
@@ -1298,7 +1298,7 @@ skip_vfb:
     xlu_cfg_destroy(config);
 }
 
-static void reload_domain_config(libxl_ctx *ctx, uint32_t domid,
+static void reload_domain_config(uint32_t domid,
                                  uint8_t **config_data, int *config_len)
 {
     uint8_t *t_data;
@@ -1318,7 +1318,7 @@ static void reload_domain_config(libxl_c
 
 /* Returns 1 if domain should be restarted,
  * 2 if domain should be renamed then restarted, or 0 */
-static int handle_domain_death(libxl_ctx *ctx, uint32_t domid,
+static int handle_domain_death(uint32_t domid,
                                libxl_event *event,
                                uint8_t **config_data, int *config_len,
                                libxl_domain_config *d_config)
@@ -1377,12 +1377,12 @@ static int handle_domain_death(libxl_ctx
         break;
 
     case LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME:
-        reload_domain_config(ctx, domid, config_data, config_len);
+        reload_domain_config(domid, config_data, config_len);
         restart = 2;
         break;
 
     case LIBXL_ACTION_ON_SHUTDOWN_RESTART:
-        reload_domain_config(ctx, domid, config_data, config_len);
+        reload_domain_config(domid, config_data, config_len);
 
         restart = 1;
         /* fall-through */
@@ -1418,7 +1418,7 @@ static void replace_string(char **str, c
 }
 
 
-static int preserve_domain(libxl_ctx *ctx, uint32_t domid, libxl_event *event,
+static int preserve_domain(uint32_t domid, libxl_event *event,
                            libxl_domain_config *d_config)
 {
     time_t now;
@@ -1813,7 +1813,7 @@ start:
         pid_t child1, got_child;
         int nullfd;
 
-        child1 = xl_fork(ctx);
+        child1 = xl_fork();
         if (child1) {
             printf("Daemon running with PID %d\n", child1);
 
@@ -1891,11 +1891,11 @@ start:
             LOG("Domain %d has shut down, reason code %d 0x%x", domid,
                 event->u.domain_shutdown.shutdown_reason,
                 event->u.domain_shutdown.shutdown_reason);
-            switch (handle_domain_death(ctx, domid, event,
+            switch (handle_domain_death(domid, event,
                                         (uint8_t **)&config_data, &config_len,
                                         &d_config)) {
             case 2:
-                if (!preserve_domain(ctx, domid, event, &d_config)) {
+                if (!preserve_domain(domid, event, &d_config)) {
                     /* If we fail then exit leaving the old domain in place. */
                     ret = -1;
                     goto out;
@@ -2931,7 +2931,7 @@ static void migrate_domain(const char *d
     MUST( libxl_pipe(ctx, sendpipe) );
     MUST( libxl_pipe(ctx, recvpipe) );
 
-    child = xl_fork(ctx);
+    child = xl_fork();
 
     if (!child) {
         dup2(sendpipe[0], 0);
Acked-by on v1 1/1
#1 lore raw

Ian Campbell writes ("[PATCH] xl: remove all local "ctx" variables"):

Quoted 4 lines

xl: remove all local "ctx" variables.

xl has a global "ctx" variable, so there should be no need to pass a ctx to any function.

Although I would prefer it if you'd leave xl_fork alone because my xl child process fix patch is going to change its prototype anyway.

Ian.

#2 lore raw
Quoted 10 lines · Ian Jackson

Ian Campbell writes ("[PATCH] xl: remove all local "ctx" variables"):

Quoted 4 lines

xl: remove all local "ctx" variables.

xl has a global "ctx" variable, so there should be no need to pass a ctx to any function.

Although I would prefer it if you'd leave xl_fork alone because my xl child process fix patch is going to change its prototype anyway.

I'm happy to refresh this patch after your xl child patch goes in, and drop the xl_fork stuff as appropriate.

Ian.

#3 lore raw
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Ian Jackson

Ian Campbell writes ("[PATCH] xl: remove all local "ctx" variables"):

Quoted 4 lines

xl: remove all local "ctx" variables.

xl has a global "ctx" variable, so there should be no need to pass a ctx to any function.

Quoted 7 lines
Quoted 4 lines

Although I would prefer it if you'd leave xl_fork alone because my xl child process fix patch is going to change its prototype anyway.

I'm happy to refresh this patch after your xl child patch goes in, and drop the xl_fork stuff as appropriate.

I dropped the xl_fork hunks and committed.

Ian.