[PATCH 09/16] conf: Convert 'chr' in virDomainShmemDef to proper pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The main reason is to ensure that the private data are properly
allocated for every instance.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_audit.c |  2 +-
 src/conf/domain_conf.c  | 17 ++++++++++-------
 src/conf/domain_conf.h  |  2 +-
 src/qemu/qemu_command.c |  2 +-
 src/qemu/qemu_domain.c  |  6 +++---
 src/qemu/qemu_hotplug.c |  2 +-
 6 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index b08233fa49..69c5792b07 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -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;

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index da0c64b460..52f513f488 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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");
     }

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ab9a7d66f8..3cb68c5d0a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1997,7 +1997,7 @@ struct _virDomainShmemDef {
     virDomainShmemRole role;
     struct {
         bool enabled;
-        virDomainChrSourceDef chr;
+        virDomainChrSourceDef *chr;
     } server;
     struct {
         bool enabled;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f97cdc70ab..60336947b5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fb203bc830..e69215cee2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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);
 }


diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 3df0a1f17a..0e798dc237 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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)
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux