提交 2c265574 编写于 作者: L Luyao Huang 提交者: Martin Kletzander

conf: use virDomainChrSourceDef to save server path

As the backend of shmem server is a unix type chr device, save it in
virDomainChrSourceDef, so we can reuse the existing code for chr device.
Signed-off-by: NLuyao Huang <lhuang@redhat.com>
上级 ffe96a15
...@@ -1948,7 +1948,7 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def) ...@@ -1948,7 +1948,7 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def)
return; return;
virDomainDeviceInfoClear(&def->info); virDomainDeviceInfoClear(&def->info);
VIR_FREE(def->server.path); virDomainChrSourceDefClear(&def->server.chr);
VIR_FREE(def->name); VIR_FREE(def->name);
VIR_FREE(def); VIR_FREE(def);
} }
...@@ -11158,8 +11158,10 @@ virDomainShmemDefParseXML(xmlNodePtr node, ...@@ -11158,8 +11158,10 @@ virDomainShmemDefParseXML(xmlNodePtr node,
if ((server = virXPathNode("./server[1]", ctxt))) { if ((server = virXPathNode("./server[1]", ctxt))) {
def->server.enabled = true; def->server.enabled = true;
def->server.chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
def->server.chr.data.nix.listen = false;
if ((tmp = virXMLPropString(server, "path"))) if ((tmp = virXMLPropString(server, "path")))
def->server.path = virFileSanitizePath(tmp); def->server.chr.data.nix.path = virFileSanitizePath(tmp);
VIR_FREE(tmp); VIR_FREE(tmp);
} }
...@@ -20195,7 +20197,7 @@ virDomainShmemDefFormat(virBufferPtr buf, ...@@ -20195,7 +20197,7 @@ virDomainShmemDefFormat(virBufferPtr buf,
if (def->server.enabled) { if (def->server.enabled) {
virBufferAddLit(buf, "<server"); virBufferAddLit(buf, "<server");
virBufferEscapeString(buf, " path='%s'", def->server.path); virBufferEscapeString(buf, " path='%s'", def->server.chr.data.nix.path);
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
} }
......
...@@ -1601,7 +1601,7 @@ struct _virDomainShmemDef { ...@@ -1601,7 +1601,7 @@ struct _virDomainShmemDef {
unsigned long long size; unsigned long long size;
struct { struct {
bool enabled; bool enabled;
char *path; virDomainChrSourceDef chr;
} server; } server;
struct { struct {
bool enabled; bool enabled;
......
...@@ -8593,24 +8593,14 @@ qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem, ...@@ -8593,24 +8593,14 @@ qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
char *devstr = NULL; char *devstr = NULL;
virDomainChrSourceDef source = {
.type = VIR_DOMAIN_CHR_TYPE_UNIX,
.data.nix = {
.path = shmem->server.path,
.listen = false,
}
};
if (!shmem->server.path && if (!shmem->server.chr.data.nix.path &&
virAsprintf(&source.data.nix.path, virAsprintf(&shmem->server.chr.data.nix.path,
"/var/lib/libvirt/shmem-%s-sock", "/var/lib/libvirt/shmem-%s-sock",
shmem->name) < 0) shmem->name) < 0)
return NULL; return NULL;
devstr = qemuBuildChrChardevStr(&source, shmem->info.alias, qemuCaps); devstr = qemuBuildChrChardevStr(&shmem->server.chr, shmem->info.alias, qemuCaps);
if (!shmem->server.path)
VIR_FREE(source.data.nix.path);
return devstr; return devstr;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册