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

Martin Kletzander mkletzan at redhat.com
Wed Jul 8 09:39:20 UTC 2015


On Wed, Jun 17, 2015 at 11:56:15AM +0800, Luyao Huang wrote:
>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 at redhat.com>
>---
> 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(-)
>

ACK

>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 at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150708/d1bd516c/attachment-0001.sig>


More information about the libvir-list mailing list