On 08.07.2013 21:20, John Ferlan wrote: > Add a new qemuMonitorJSONSetObjectProperty() method to support invocation > of the 'qom-set' JSON monitor command with a provided path, property, and > expected data type to set. > > The test code uses the same "/machine/i440fx" property as the get test and > attempts to set the "realized" property to "true" (which it should be set > at anyway). > --- > src/qemu/qemu_monitor_json.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ > src/qemu/qemu_monitor_json.h | 6 +++++ > tests/qemumonitorjsontest.c | 59 +++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 127 insertions(+) > > diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c > index db107f1..9487955 100644 > --- a/src/qemu/qemu_monitor_json.c > +++ b/src/qemu/qemu_monitor_json.c > @@ -4728,6 +4728,68 @@ cleanup: > } > > > +#define MAKE_SET_CMD(STRING, VALUE) \ > + cmd = qemuMonitorJSONMakeCommand("qom-set", \ > + "s:path", path, \ > + "s:property", property, \ > + STRING, VALUE, \ > + NULL) > +int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr mon, > + const char *path, > + const char *property, > + qemuMonitorJSONObjectPropertyPtr prop) > +{ > + int ret = -1; > + virJSONValuePtr cmd = NULL; > + virJSONValuePtr reply = NULL; > + > + switch (prop->type) { Again, this should be: switch ((qemuMonitorJSONObjectPropertyType) prop->type) { > + /* Simple cases of boolean, int, long, uint, ulong, double, and string > + * will receive return value as part of {"return": xxx} statement > + */ > + case QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN: > + MAKE_SET_CMD("b:value", prop->val.b); > + break; > + case QEMU_MONITOR_OBJECT_PROPERTY_INT: > + MAKE_SET_CMD("i:value", prop->val.i); > + break; > + case QEMU_MONITOR_OBJECT_PROPERTY_LONG: > + MAKE_SET_CMD("I:value", prop->val.l); > + break; > + case QEMU_MONITOR_OBJECT_PROPERTY_UINT: > + MAKE_SET_CMD("u:value", prop->val.ui); > + break; > + case QEMU_MONITOR_OBJECT_PROPERTY_ULONG: > + MAKE_SET_CMD("U:value", prop->val.ul); > + break; > + case QEMU_MONITOR_OBJECT_PROPERTY_DOUBLE: > + MAKE_SET_CMD("d:value", prop->val.d); > + break; > + case QEMU_MONITOR_OBJECT_PROPERTY_STRING: > + MAKE_SET_CMD("s:value", prop->val.str); > + break; > + case QEMU_MONITOR_OBJECT_PROPERTY_LAST: > + default: With these removed. > + virReportError(VIR_ERR_INTERNAL_ERROR, > + _("qom-set invalid object property type %d"), > + prop->type); > + goto cleanup; > + > + } > + if (!cmd) > + return -1; > + > + if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) == 0) > + ret = qemuMonitorJSONCheckError(cmd, reply); > + > +cleanup: > + virJSONValueFree(cmd); > + virJSONValueFree(reply); > + > + return ret; > +} > + > + > int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon, > const char *type, > char ***props) Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list