提交 386fe237 编写于 作者: P Peter Krempa

qemu: monitor: Simplify construction of chardev backends

上级 3da50081
...@@ -5929,22 +5929,17 @@ qemuMonitorJSONBuildInetSocketAddress(const char *host, ...@@ -5929,22 +5929,17 @@ qemuMonitorJSONBuildInetSocketAddress(const char *host,
virJSONValuePtr addr = NULL; virJSONValuePtr addr = NULL;
virJSONValuePtr data = NULL; virJSONValuePtr data = NULL;
if (!(data = virJSONValueNewObject()) || if (virJSONValueObjectCreate(&data, "s:host", host,
!(addr = virJSONValueNewObject())) "s:port", port, NULL) < 0)
goto error; return NULL;
/* port is really expected as a string here by qemu */ if (virJSONValueObjectCreate(&addr, "s:type", "inet",
if (virJSONValueObjectAppendString(data, "host", host) < 0 || "a:data", data, NULL) < 0) {
virJSONValueObjectAppendString(data, "port", port) < 0 || virJSONValueFree(data);
virJSONValueObjectAppendString(addr, "type", "inet") < 0 || return NULL;
virJSONValueObjectAppend(addr, "data", data) < 0) }
goto error;
return addr; return addr;
error:
virJSONValueFree(data);
virJSONValueFree(addr);
return NULL;
} }
static virJSONValuePtr static virJSONValuePtr
...@@ -5953,20 +5948,16 @@ qemuMonitorJSONBuildUnixSocketAddress(const char *path) ...@@ -5953,20 +5948,16 @@ qemuMonitorJSONBuildUnixSocketAddress(const char *path)
virJSONValuePtr addr = NULL; virJSONValuePtr addr = NULL;
virJSONValuePtr data = NULL; virJSONValuePtr data = NULL;
if (!(data = virJSONValueNewObject()) || if (virJSONValueObjectCreate(&data, "s:path", path, NULL) < 0)
!(addr = virJSONValueNewObject())) return NULL;
goto error;
if (virJSONValueObjectAppendString(data, "path", path) < 0 || if (virJSONValueObjectCreate(&addr, "s:type", "unix",
virJSONValueObjectAppendString(addr, "type", "unix") < 0 || "a:data", data, NULL) < 0) {
virJSONValueObjectAppend(addr, "data", data) < 0) virJSONValueFree(data);
goto error; return NULL;
}
return addr; return addr;
error:
virJSONValueFree(data);
virJSONValueFree(addr);
return NULL;
} }
int int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册