diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index a203a8d1bfc4ab945e1010bcec55bc2347c91bad..a99cc7b7f19608ecb9d579ac70dbdb5e69b47241 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -1204,229 +1204,6 @@ no_memory: return -1; } - -int -xend_parse_sexp_desc_char(virBufferPtr buf, - const char *devtype, - int portNum, - const char *value, - const char *tty) -{ - const char *type; - int telnet = 0; - char *bindPort = NULL; - char *bindHost = NULL; - char *connectPort = NULL; - char *connectHost = NULL; - char *path = NULL; - int ret = -1; - - if (value[0] == '/') { - type = "dev"; - } else if (STRPREFIX(value, "null")) { - type = "null"; - value = NULL; - } else if (STRPREFIX(value, "vc")) { - type = "vc"; - value = NULL; - } else if (STRPREFIX(value, "pty")) { - type = "pty"; - value = NULL; - } else if (STRPREFIX(value, "stdio")) { - type = "stdio"; - value = NULL; - } else if (STRPREFIX(value, "file:")) { - type = "file"; - value += sizeof("file:")-1; - } else if (STRPREFIX(value, "pipe:")) { - type = "pipe"; - value += sizeof("pipe:")-1; - } else if (STRPREFIX(value, "tcp:")) { - type = "tcp"; - value += sizeof("tcp:")-1; - } else if (STRPREFIX(value, "telnet:")) { - type = "tcp"; - value += sizeof("telnet:")-1; - telnet = 1; - } else if (STRPREFIX(value, "udp:")) { - type = "udp"; - value += sizeof("udp:")-1; - } else if (STRPREFIX(value, "unix:")) { - type = "unix"; - value += sizeof("unix:")-1; - } else { - virXendError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Unknown char device type")); - return -1; - } - - /* Compat with legacy syntax */ - if (STREQ(devtype, "console") && - STREQ(type, "pty") && - tty != NULL) { - virBufferVSprintf(buf, " <%s type='%s' tty='%s'>\n", - devtype, type, tty); - } else { - virBufferVSprintf(buf, " <%s type='%s'>\n", - devtype, type); - } - - if (STREQ(type, "null") || - STREQ(type, "vc") || - STREQ(type, "stdio")) { - /* no source needed */ - } else if (STREQ(type, "pty")) { - if (tty) - virBufferVSprintf(buf, " \n", - tty); - } else if (STREQ(type, "file") || - STREQ(type, "pipe")) { - virBufferVSprintf(buf, " \n", - value); - } else if (STREQ(type, "tcp")) { - sa_assert (value); - const char *offset = strchr(value, ':'); - const char *offset2; - const char *mode, *protocol; - - if (offset == NULL) { - virXendError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed char device string")); - goto error; - } - - if (offset != value && - (bindHost = strndup(value, offset - value)) == NULL) - goto no_memory; - - offset2 = strchr(offset, ','); - if (offset2 == NULL) - bindPort = strdup(offset+1); - else - bindPort = strndup(offset+1, offset2-(offset+1)); - if (bindPort == NULL) - goto no_memory; - - if (offset2 && strstr(offset2, ",listen")) - mode = "bind"; - else - mode = "connect"; - protocol = telnet ? "telnet":"raw"; - - if (bindHost) { - virBufferVSprintf(buf, - " \n", - mode, bindHost, bindPort); - } else { - virBufferVSprintf(buf, - " \n", - mode, bindPort); - } - virBufferVSprintf(buf, - " \n", - protocol); - } else if (STREQ(type, "udp")) { - sa_assert (value); - const char *offset = strchr(value, ':'); - const char *offset2, *offset3; - - if (offset == NULL) { - virXendError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed char device string")); - goto error; - } - - if (offset != value && - (connectHost = strndup(value, offset - value)) == NULL) - goto no_memory; - - offset2 = strchr(offset, '@'); - if (offset2 != NULL) { - if ((connectPort = strndup(offset + 1, offset2-(offset+1))) == NULL) - goto no_memory; - - offset3 = strchr(offset2, ':'); - if (offset3 == NULL) { - virXendError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed char device string")); - goto error; - } - - if (offset3 > (offset2 + 1) && - (bindHost = strndup(offset2 + 1, offset3 - (offset2+1))) == NULL) - goto no_memory; - - if ((bindPort = strdup(offset3 + 1)) == NULL) - goto no_memory; - } else { - if ((connectPort = strdup(offset + 1)) == NULL) - goto no_memory; - } - - if (connectHost) { - virBufferVSprintf(buf, - " \n", - connectHost, connectPort); - } else { - virBufferVSprintf(buf, - " \n", - connectPort); - } - if (bindPort) { - if (bindHost) { - virBufferVSprintf(buf, - " \n", - bindHost, bindPort); - } else { - virBufferVSprintf(buf, - " \n", - bindPort); - } - } - - } else if (STREQ(type, "unix")) { - sa_assert (value); - const char *offset = strchr(value, ','); - int dolisten = 0; - if (offset) - path = strndup(value, (offset - value)); - else - path = strdup(value); - if (path == NULL) - goto no_memory; - - if (offset != NULL && - strstr(offset, ",listen") != NULL) - dolisten = 1; - - virBufferVSprintf(buf, " \n", - dolisten ? "bind" : "connect", path); - } - - virBufferVSprintf(buf, " \n", - portNum); - - virBufferVSprintf(buf, " \n", - devtype); - - ret = 0; - - if (ret == -1) { -no_memory: - virReportOOMError(); - } - -error: - - VIR_FREE(path); - VIR_FREE(bindHost); - VIR_FREE(bindPort); - VIR_FREE(connectHost); - VIR_FREE(connectPort); - - return ret; -} - virDomainChrDefPtr xenDaemonParseSxprChar(const char *value, const char *tty) diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h index 25a5421aa23c8966d00b3cf52701bb4bb5d2e862..c757716a46d9aafd72a47e9492f8530c94520fb5 100644 --- a/src/xen/xend_internal.h +++ b/src/xen/xend_internal.h @@ -96,12 +96,6 @@ xenDaemonDomainFetch(virConnectPtr xend, const char *name, const char *cpus); -int xend_parse_sexp_desc_char(virBufferPtr buf, - const char *devtype, - int portNum, - const char *value, - const char *tty); - virDomainDefPtr xenDaemonParseSxprString(virConnectPtr conn, const char *sexpr,