提交 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)
return;
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def->server.path);
virDomainChrSourceDefClear(&def->server.chr);
VIR_FREE(def->name);
VIR_FREE(def);
}
......@@ -11158,8 +11158,10 @@ virDomainShmemDefParseXML(xmlNodePtr node,
if ((server = virXPathNode("./server[1]", ctxt))) {
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")))
def->server.path = virFileSanitizePath(tmp);
def->server.chr.data.nix.path = virFileSanitizePath(tmp);
VIR_FREE(tmp);
}
......@@ -20195,7 +20197,7 @@ virDomainShmemDefFormat(virBufferPtr buf,
if (def->server.enabled) {
virBufferAddLit(buf, "<server");
virBufferEscapeString(buf, " path='%s'", def->server.path);
virBufferEscapeString(buf, " path='%s'", def->server.chr.data.nix.path);
virBufferAddLit(buf, "/>\n");
}
......
......@@ -1601,7 +1601,7 @@ struct _virDomainShmemDef {
unsigned long long size;
struct {
bool enabled;
char *path;
virDomainChrSourceDef chr;
} server;
struct {
bool enabled;
......
......@@ -8593,24 +8593,14 @@ qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem,
virQEMUCapsPtr qemuCaps)
{
char *devstr = NULL;
virDomainChrSourceDef source = {
.type = VIR_DOMAIN_CHR_TYPE_UNIX,
.data.nix = {
.path = shmem->server.path,
.listen = false,
}
};
if (!shmem->server.path &&
virAsprintf(&source.data.nix.path,
if (!shmem->server.chr.data.nix.path &&
virAsprintf(&shmem->server.chr.data.nix.path,
"/var/lib/libvirt/shmem-%s-sock",
shmem->name) < 0)
return NULL;
devstr = qemuBuildChrChardevStr(&source, shmem->info.alias, qemuCaps);
if (!shmem->server.path)
VIR_FREE(source.data.nix.path);
devstr = qemuBuildChrChardevStr(&shmem->server.chr, shmem->info.alias, qemuCaps);
return devstr;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册