In qemuMonitorJSONCommandWithFd() given command (represented by
virJSONValue struct) is translated to string (represented by
virBuffer). The ownership of the string is then transferred to
the message which is then sent. The downside of this approach is
we have to have an explicit call to free the string from the
message. But if the message just "borrowed" the string (which it
can safely do because it is just reading from the string) then
automatic free of the buffer takes care of freeing the string.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
qemuMonitorIOWrite(qemuMonitor *mon)
{
int done;
- char *buf;
+ const char *buf;
size_t len;
/* If no active message, or fully transmitted, the no-op */
struct _qemuMonitorMessage {
int txFD;
- char *txBuffer;
+ const char *txBuffer;
int txOffset;
int txLength;
virBufferAddLit(&cmdbuf, "\r\n");
msg.txLength = virBufferUse(&cmdbuf);
- msg.txBuffer = virBufferContentAndReset(&cmdbuf);
+ msg.txBuffer = virBufferCurrentContent(&cmdbuf);
msg.txFD = scm_fd;
ret = qemuMonitorSend(mon, &msg);
}
cleanup:
- VIR_FREE(msg.txBuffer);
-
return ret;
}