diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index fc3f70fcde..b522882c78 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -2767,95 +2767,3 @@ virDomainDefPtr qemuParseCommandLineString(virFileCachePtr capsCache, return def; } - - -static int qemuParseProcFileStrings(int pid_value, - const char *name, - char ***list) -{ - char *path = NULL; - int ret = -1; - char *data = NULL; - ssize_t len; - char *tmp; - size_t nstr = 0; - char **str = NULL; - - if (virAsprintf(&path, "/proc/%d/%s", pid_value, name) < 0) - goto cleanup; - - if ((len = virFileReadAll(path, 1024*128, &data)) < 0) - goto cleanup; - - tmp = data; - while (tmp < (data + len)) { - if (VIR_EXPAND_N(str, nstr, 1) < 0) - goto cleanup; - - if (VIR_STRDUP(str[nstr-1], tmp) < 0) - goto cleanup; - /* Skip arg */ - tmp += strlen(tmp); - /* Skip \0 separator */ - tmp++; - } - - if (VIR_EXPAND_N(str, nstr, 1) < 0) - goto cleanup; - - str[nstr-1] = NULL; - - ret = nstr-1; - *list = str; - - cleanup: - if (ret < 0) - virStringListFree(str); - VIR_FREE(data); - VIR_FREE(path); - return ret; -} - -virDomainDefPtr qemuParseCommandLinePid(virFileCachePtr capsCache, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - pid_t pid, - char **pidfile, - virDomainChrSourceDefPtr *monConfig, - bool *monJSON) -{ - virDomainDefPtr def = NULL; - char **progargv = NULL; - char **progenv = NULL; - char *exepath = NULL; - char *emulator; - - /* The parser requires /proc/pid, which only exists on platforms - * like Linux where pid_t fits in int. */ - if ((int)pid != pid || - qemuParseProcFileStrings(pid, "cmdline", &progargv) < 0 || - qemuParseProcFileStrings(pid, "environ", &progenv) < 0) - goto cleanup; - - if (!(def = qemuParseCommandLine(capsCache, caps, xmlopt, progenv, progargv, - pidfile, monConfig, monJSON))) - goto cleanup; - - if (virAsprintf(&exepath, "/proc/%d/exe", (int)pid) < 0) - goto cleanup; - - if (virFileResolveLink(exepath, &emulator) < 0) { - virReportSystemError(errno, - _("Unable to resolve %s for pid %u"), - exepath, (int)pid); - goto cleanup; - } - VIR_FREE(def->emulator); - def->emulator = emulator; - - cleanup: - VIR_FREE(exepath); - virStringListFree(progargv); - virStringListFree(progenv); - return def; -} diff --git a/src/qemu/qemu_parse_command.h b/src/qemu/qemu_parse_command.h index 3fe8206896..0d74766064 100644 --- a/src/qemu/qemu_parse_command.h +++ b/src/qemu/qemu_parse_command.h @@ -36,13 +36,6 @@ virDomainDefPtr qemuParseCommandLineString(virFileCachePtr capsCache, char **pidfile, virDomainChrSourceDefPtr *monConfig, bool *monJSON); -virDomainDefPtr qemuParseCommandLinePid(virFileCachePtr capsCache, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - pid_t pid, - char **pidfile, - virDomainChrSourceDefPtr *monConfig, - bool *monJSON); void qemuParseKeywordsFree(int nkeywords,