[PATCHv2 08/11] qemu_capabilities: QMPCommandPtr without maintaining 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.

Before this change, an external char *qmperr had to be maintained
between calls to virQEMUCapsInitQMPCommandNew and
virQEMUCapsInitQMPCommandAbort.

This change allows the qmperr pointer to be maintained within the
QMPCommand structure avoiding the need to track and maintain the qmperr
across a sometimes 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?
---
 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 d3f2317a1d..f33152ec40 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4272,6 +4272,7 @@ struct _virQEMUCapsInitQMPCommand {
     uid_t runUid;
     gid_t runGid;
     char **qmperr;
+    char *qmperr_internal;
     char *monarg;
     char *monpath;
     char *pidfile;
@@ -4349,7 +4350,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