mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
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: Luyao Huang <lhuang@redhat.com>
This commit is contained in:
parent
ffe96a1593
commit
2c2655744a
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user