+ va_list ap_copy;
+ QObject *qobj;
+
+ /* Going through qobject ensures we escape strings properly.
+ * This seemingly unnecessary copy is required in case va_list
+ * is an array type.
+ */
+ va_copy(ap_copy, ap);
+ qobj = qobject_from_jsonv(fmt, &ap_copy);
+ va_end(ap_copy);
+
+ /* No need to send anything for an empty QObject. */
+ if (qobj) {
+ QString *qstr = qobject_to_json(qobj);
+ const char *str = qstring_get_str(qstr);
+ size_t size = qstring_get_length(qstr);
+
+ /* Send QMP request */
+ socket_send(s->qmp_fd, str, size);
+
+ QDECREF(qstr);
+ qobject_decref(qobj);
+ }