[PATCHv1 08/12] qemu_capabilities: QMPCommandPtr without shadow qmperr

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

 



Previously QMPCommandPtr (handle for issuing QMP commands) required an
external char * qmperr to persist over the lifespan of QMPCommand to
expose a QMP error string outside of QMPCommand.

Specifically the external char *qmperr was required between calls to
virQEMUCapsInitQMPCommandNew and virQEMUCapsInitQMPCommandAbort.

This change allows the qmperr pointer to be maintained within the
QMPCommand it's self avoiding the need to track the qmperr variable
across a multi-function call lifespan of a QMPCommand.

Q) Should we eliminate external qmperr completely as there seems to be
no current use of qmperr outside the lifespan of QMPCommand in which an
internal qmperr char pointer can persist and be used by anywhere we have
access to the QMPCommandPtr?

conversion functions removed
'57d6df39bd'.
---
 src/qemu/qemu_capabilities.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 89a313b55d..f2202b652d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4242,6 +4242,7 @@ struct _virQEMUCapsInitQMPCommand {
     uid_t runUid;
     gid_t runGid;
     char **qmperr;
+    char *qmperr_internal;
     char *monarg;
     char *monpath;
     char *pidfile;
@@ -4319,7 +4320,11 @@ virQEMUCapsInitQMPCommandNew(char *binary,
 
     cmd->runUid = runUid;
     cmd->runGid = runGid;
-    cmd->qmperr = qmperr;
+
+    if (qmperr)
+        cmd->qmperr = qmperr; /* external storage */
+    else
+        cmd->qmperr = &cmd->qmperr_internal; /* cmd internal storage */
 
     /* the ".sock" sufix is important to avoid a possible clash with a qemu
      * domain called "capabilities"
-- 
2.17.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]

  Powered by Linux