[PATCH 04/10] conf: use virDomainChrSourceDef to save the path

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

 



As the backend of shmem server is a unix type chr device,
save it in virDomainChrSourceDef can reuse the exist
code for chr device.

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 src/conf/domain_conf.c  |  8 +++++---
 src/conf/domain_conf.h  |  2 +-
 src/qemu/qemu_command.c | 16 +++-------------
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 60d4d07..306b718 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1945,7 +1945,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);
 }
@@ -11042,8 +11042,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);
     }
 
@@ -19997,7 +19999,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");
     }
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ba17a8d..a4b1bf3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1599,7 +1599,7 @@ struct _virDomainShmemDef {
     unsigned long long size;
     struct {
         bool enabled;
-        char *path;
+        virDomainChrSourceDef chr;
     } server;
     struct {
         bool enabled;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0414f77..5d55794 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8500,24 +8500,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;
 }
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]