[PATCH 21/24] qemu: Use qemuBuildChrChardevCommand for virtiofs backend chardev

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

 



Now that the API for qemuBuildChrChardevCommand is sane enough, we can
use it to centralize formatting of '-chardev' generally.

The 'virDomainFSDef' doesn't use 'virDomainChrSourceDef' internally so
we create it for this occasion manually.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0bfe76c29c..3a5796fed8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2741,22 +2741,6 @@ qemuBuildDisksCommandLine(virCommand *cmd,
 }


-static char *
-qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs,
-                               const char *chardev_alias,
-                               qemuDomainObjPrivate *priv)
-{
-    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    g_autofree char *socket_path = qemuDomainGetVHostUserFSSocketPath(priv, fs);
-
-    virBufferAddLit(&buf, "socket");
-    virBufferAsprintf(&buf, ",id=%s", chardev_alias);
-    virBufferAddLit(&buf, ",path=");
-    virQEMUBuildBufferEscapeComma(&buf, socket_path);
-    return virBufferContentAndReset(&buf);
-}
-
-
 virJSONValue *
 qemuBuildVHostUserFsDevProps(virDomainFSDef *fs,
                              const virDomainDef *def,
@@ -2790,15 +2774,18 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd,
                                 const virDomainDef *def,
                                 qemuDomainObjPrivate *priv)
 {
-    g_autofree char *chardev_alias = NULL;
-    g_autofree char *chrdevstr = NULL;
+    g_autofree char *chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias);
     g_autoptr(virJSONValue) devprops = NULL;
+    g_autoptr(virDomainChrSourceDef) chrsrc = virDomainChrSourceDefNew(priv->driver->xmlopt);

-    chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias);
-    chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias, priv);
+    if (!chrsrc)
+        return -1;
+
+    chrsrc->type = VIR_DOMAIN_CHR_TYPE_UNIX;
+    chrsrc->data.nix.path = qemuDomainGetVHostUserFSSocketPath(priv, fs);

-    virCommandAddArg(cmd, "-chardev");
-    virCommandAddArg(cmd, chrdevstr);
+    if (qemuBuildChardevCommand(cmd, chrsrc, chardev_alias, priv->qemuCaps) < 0)
+        return -1;

     if (qemuCommandAddExtDevice(cmd, &fs->info, priv->qemuCaps) < 0)
         return -1;
-- 
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