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

Chris Venteicher cventeic at redhat.com
Fri Jun 22 04:42:07 UTC 2018


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




More information about the libvir-list mailing list