mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
conf: Convert 'chr' in virDomainShmemDef to proper pointer
The main reason is to ensure that the private data are properly allocated for every instance. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
876f19c19e
commit
3c558f56f8
@ -898,7 +898,7 @@ virDomainAuditShmem(virDomainObj *vm,
|
||||
{
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
char *vmname = virAuditEncode("vm", vm->def->name);
|
||||
const char *srcpath = virDomainChrSourceDefGetPath(&def->server.chr);
|
||||
const char *srcpath = virDomainChrSourceDefGetPath(def->server.chr);
|
||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||
char *shmpath = NULL;
|
||||
|
||||
|
@ -3069,7 +3069,7 @@ void virDomainShmemDefFree(virDomainShmemDef *def)
|
||||
return;
|
||||
|
||||
virDomainDeviceInfoClear(&def->info);
|
||||
virDomainChrSourceDefClear(&def->server.chr);
|
||||
virObjectUnref(def->server.chr);
|
||||
g_free(def->name);
|
||||
g_free(def);
|
||||
}
|
||||
@ -13665,11 +13665,14 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlopt,
|
||||
if ((server = virXPathNode("./server[1]", ctxt))) {
|
||||
g_autofree char *tmp = NULL;
|
||||
|
||||
if (!(def->server.chr = virDomainChrSourceDefNew(xmlopt)))
|
||||
return NULL;
|
||||
|
||||
def->server.enabled = true;
|
||||
def->server.chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||
def->server.chr.data.nix.listen = false;
|
||||
def->server.chr->type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||
def->server.chr->data.nix.listen = false;
|
||||
if ((tmp = virXMLPropString(server, "path")))
|
||||
def->server.chr.data.nix.path = virFileSanitizePath(tmp);
|
||||
def->server.chr->data.nix.path = virFileSanitizePath(tmp);
|
||||
}
|
||||
|
||||
if ((msi = virXPathNode("./msi[1]", ctxt))) {
|
||||
@ -16814,8 +16817,8 @@ virDomainShmemDefEquals(virDomainShmemDef *src,
|
||||
return false;
|
||||
|
||||
if (src->server.enabled) {
|
||||
if (STRNEQ_NULLABLE(src->server.chr.data.nix.path,
|
||||
dst->server.chr.data.nix.path))
|
||||
if (STRNEQ_NULLABLE(src->server.chr->data.nix.path,
|
||||
dst->server.chr->data.nix.path))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -25868,7 +25871,7 @@ virDomainShmemDefFormat(virBuffer *buf,
|
||||
|
||||
if (def->server.enabled) {
|
||||
virBufferAddLit(buf, "<server");
|
||||
virBufferEscapeString(buf, " path='%s'", def->server.chr.data.nix.path);
|
||||
virBufferEscapeString(buf, " path='%s'", def->server.chr->data.nix.path);
|
||||
virBufferAddLit(buf, "/>\n");
|
||||
}
|
||||
|
||||
|
@ -1997,7 +1997,7 @@ struct _virDomainShmemDef {
|
||||
virDomainShmemRole role;
|
||||
struct {
|
||||
bool enabled;
|
||||
virDomainChrSourceDef chr;
|
||||
virDomainChrSourceDef *chr;
|
||||
} server;
|
||||
struct {
|
||||
bool enabled;
|
||||
|
@ -9368,7 +9368,7 @@ qemuBuildShmemCommandLine(virLogManager *logManager,
|
||||
if (shmem->server.enabled) {
|
||||
chardev = qemuBuildChrChardevStr(logManager, secManager,
|
||||
cmd, cfg, def,
|
||||
&shmem->server.chr,
|
||||
shmem->server.chr,
|
||||
shmem->info.alias, qemuCaps,
|
||||
cdevflags);
|
||||
if (!chardev)
|
||||
|
@ -9964,11 +9964,11 @@ void
|
||||
qemuDomainPrepareShmemChardev(virDomainShmemDef *shmem)
|
||||
{
|
||||
if (!shmem->server.enabled ||
|
||||
shmem->server.chr.data.nix.path)
|
||||
shmem->server.chr->data.nix.path)
|
||||
return;
|
||||
|
||||
shmem->server.chr.data.nix.path = g_strdup_printf("/var/lib/libvirt/shmem-%s-sock",
|
||||
shmem->name);
|
||||
shmem->server.chr->data.nix.path = g_strdup_printf("/var/lib/libvirt/shmem-%s-sock",
|
||||
shmem->name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3064,7 +3064,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver,
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
|
||||
if (shmem->server.enabled) {
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, &shmem->server.chr) < 0)
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, shmem->server.chr) < 0)
|
||||
goto exit_monitor;
|
||||
} else {
|
||||
if (qemuMonitorAddObject(priv->mon, &props, &memAlias) < 0)
|
||||
|
@ -1172,8 +1172,8 @@ get_files(vahControl * ctl)
|
||||
* When the server path is enabled, use it - otherwise fallback to
|
||||
* model dependent defaults. */
|
||||
if (shmem->server.enabled &&
|
||||
shmem->server.chr.data.nix.path) {
|
||||
if (vah_add_file(&buf, shmem->server.chr.data.nix.path,
|
||||
shmem->server.chr->data.nix.path) {
|
||||
if (vah_add_file(&buf, shmem->server.chr->data.nix.path,
|
||||
"rw") != 0)
|
||||
goto cleanup;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user