]> git.ozlabs.org Git - petitboot/blobdiff - discover/platform-powerpc.c
discover: Print IPMI bootdev response for debug
[petitboot] / discover / platform-powerpc.c
index 280793425198a483ecea8c1e4217b9844728d842..992123e58a92bb3cc9ba161bcfd1e8356fb48118 100644 (file)
@@ -179,7 +179,7 @@ static int write_nvram(struct platform_powerpc *platform)
        struct process *process;
        struct param *param;
        const char *argv[6];
-       int rc;
+       int rc = 0;
 
        argv[0] = "nvram";
        argv[1] = "--update-config";
@@ -310,7 +310,7 @@ static int parse_one_interface_config(struct config *config,
        } else if (!strcmp(tok, "static")) {
                ifconf->method = CONFIG_METHOD_STATIC;
 
-               /* ip/mask, [optional] gateway */
+               /* ip/mask, [optional] gateway, [optional] url */
                tok = strtok_r(NULL, ",", &saveptr);
                if (!tok)
                        goto out_err;
@@ -323,6 +323,12 @@ static int parse_one_interface_config(struct config *config,
                                talloc_strdup(ifconf, tok);
                }
 
+               tok = strtok_r(NULL, ",", &saveptr);
+               if (tok) {
+                       ifconf->static_config.url =
+                               talloc_strdup(ifconf, tok);
+               }
+
        } else {
                pb_log("Unknown network configuration method %s\n", tok);
                goto out_err;
@@ -438,7 +444,6 @@ static void populate_bootdev_config(struct platform_powerpc *platform,
 {
        struct autoboot_option *opt, *new = NULL;
        char *pos, *end, *old_dev = NULL;
-       const char delim = ' ';
        unsigned int n_new = 0;
        const char *val;
        bool conflict;
@@ -469,11 +474,9 @@ static void populate_bootdev_config(struct platform_powerpc *platform,
 
                if (read_bootdev(config, &pos, opt)) {
                        pb_log("bootdev config is in an unknown format "
-                              "(expected uuid:... or mac:...)");
+                              "(expected uuid:... or mac:...)\n");
                        talloc_free(opt);
-                       if (strchr(pos, delim))
-                               continue;
-                       return;
+                       continue;
                }
 
                new = talloc_realloc(config, new, struct autoboot_option,
@@ -578,10 +581,12 @@ static char *iface_config_str(void *ctx, struct interface_config *config)
                str = talloc_asprintf_append(str, "dhcp");
 
        } else if (config->method == CONFIG_METHOD_STATIC) {
-               str = talloc_asprintf_append(str, "static,%s%s%s",
+               str = talloc_asprintf_append(str, "static,%s%s%s%s%s",
                                config->static_config.address,
                                config->static_config.gateway ? "," : "",
-                               config->static_config.gateway ?: "");
+                               config->static_config.gateway ?: "",
+                               config->static_config.url ? "," : "",
+                               config->static_config.url ?: "");
        }
        return str;
 }
@@ -759,9 +764,8 @@ static int read_bootdev_sysparam(const char *name, uint8_t *val)
        char path[50];
        int fd, rc;
 
-       strcpy(path, sysparams_dir);
-       assert(strlen(name) < sizeof(path) - strlen(path));
-       strcat(path, name);
+       assert(strlen(sysparams_dir) + strlen(name) < sizeof(path));
+       snprintf(path, sizeof(path), "%s%s", sysparams_dir, name);
 
        fd = open(path, O_RDONLY);
        if (fd < 0) {
@@ -795,9 +799,8 @@ static int write_bootdev_sysparam(const char *name, uint8_t val)
        char path[50];
        int fd, rc;
 
-       strcpy(path, sysparams_dir);
-       assert(strlen(name) < sizeof(path) - strlen(path));
-       strcat(path, name);
+       assert(strlen(sysparams_dir) + strlen(name) < sizeof(path));
+       snprintf(path, sizeof(path), "%s%s", sysparams_dir, name);
 
        fd = open(path, O_WRONLY);
        if (fd < 0) {
@@ -920,6 +923,11 @@ static int get_ipmi_bootdev_ipmi(struct platform_powerpc *platform,
                return -1;
        }
 
+       pb_debug("IPMI get_bootdev response:\n");
+       for (int i = 0; i < resp_len; i++)
+               pb_debug("%x ", resp[i]);
+       pb_debug("\n");
+
        if (resp[0] != 0) {
                pb_log("platform: non-zero completion code %d from IPMI req\n",
                                resp[0]);