Message ID | 1453208789-42479-7-git-send-email-imammedo@redhat.com |
---|---|
State | New |
Headers | show |
On 01/19/2016 06:06 AM, Igor Mammedov wrote: > Add set-vm-generation-id command to set Virtual Machine > Generation ID counter. > > QMP command example: > { "execute": "set-vm-generation-id", > "arguments": { > "uuid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" > } > } > > HMP command example: > set-vm-generation-id 324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87 > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > --- > +++ b/hmp.c > @@ -2384,3 +2384,15 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict) > } > qapi_free_UuidInfo(info); > } > + > +void hmp_set_vm_generation_id(Monitor *mon, const QDict *qdict) > +{ > + Error *errp = NULL; > + const char *uuid = qdict_get_str(qdict, "uuid"); > + > + qmp_set_vm_generation_id(uuid, &errp); > + if (errp != NULL) { I might have written 'if (errp)', but that's cosmetic style. > +++ b/qapi-schema.json > @@ -4090,3 +4090,12 @@ > # Since 2.6 > ## > { 'command': 'query-vm-generation-id', 'returns': 'UuidInfo' } > + > +## > +# @set-vm-generation-id > +# > +# Set Virtual Machine Generation ID > +# Missing documentation of the @uuid argument. > +# Since 2.6 > +## > +{ 'command': 'set-vm-generation-id', 'data': { 'uuid': 'str' } } > diff --git a/qmp-commands.hx b/qmp-commands.hx > index 9408a3d..306082f 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -4814,3 +4814,25 @@ Example: > > -> { "execute": "query-vm-generation-id" } > <- {"return": {"UUID": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87"}} Annoying that the set uses 'uuid' and the query responds with 'UUID'; I prefer the lowercase version in new API, so maybe patch 5/9 should create a new return type with desirable spelling rather than reusing the older type. > +SQMP > +Set Virtual Machine Generation ID counter > +----- > + > +Arguments: > + > +- "UUID": counter ID in UUID string representation (json-string)" wrong case, per the example. > + > +Example: > + > +-> { "execute": "set-vm-generation-id" , > + "arguments": { "uuid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" } } > +<- {"return": {}}
On Wed, 20 Jan 2016 09:48:41 -0700 Eric Blake <eblake@redhat.com> wrote: > On 01/19/2016 06:06 AM, Igor Mammedov wrote: > > Add set-vm-generation-id command to set Virtual Machine > > Generation ID counter. > > > > QMP command example: > > { "execute": "set-vm-generation-id", > > "arguments": { > > "uuid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" > > } > > } > > > > HMP command example: > > set-vm-generation-id 324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87 > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > > --- > > > +++ b/hmp.c > > @@ -2384,3 +2384,15 @@ void hmp_info_vm_generation_id(Monitor *mon, > > const QDict *qdict) } > > qapi_free_UuidInfo(info); > > } > > + > > +void hmp_set_vm_generation_id(Monitor *mon, const QDict *qdict) > > +{ > > + Error *errp = NULL; > > + const char *uuid = qdict_get_str(qdict, "uuid"); > > + > > + qmp_set_vm_generation_id(uuid, &errp); > > + if (errp != NULL) { > > I might have written 'if (errp)', but that's cosmetic style. > > > +++ b/qapi-schema.json > > @@ -4090,3 +4090,12 @@ > > # Since 2.6 > > ## > > { 'command': 'query-vm-generation-id', 'returns': 'UuidInfo' } > > + > > +## > > +# @set-vm-generation-id > > +# > > +# Set Virtual Machine Generation ID > > +# > > Missing documentation of the @uuid argument. > > > +# Since 2.6 > > +## > > +{ 'command': 'set-vm-generation-id', 'data': { 'uuid': 'str' } } > > diff --git a/qmp-commands.hx b/qmp-commands.hx > > index 9408a3d..306082f 100644 > > --- a/qmp-commands.hx > > +++ b/qmp-commands.hx > > @@ -4814,3 +4814,25 @@ Example: > > > > -> { "execute": "query-vm-generation-id" } > > <- {"return": {"UUID": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87"}} > > Annoying that the set uses 'uuid' and the query responds with 'UUID'; > I prefer the lowercase version in new API, so maybe patch 5/9 should > create a new return type with desirable spelling rather than reusing > the older type. ok, I'll add a new type. > > > > +SQMP > > +Set Virtual Machine Generation ID counter > > +----- > > + > > +Arguments: > > + > > +- "UUID": counter ID in UUID string representation (json-string)" > > wrong case, per the example. > > > + > > +Example: > > + > > +-> { "execute": "set-vm-generation-id" , > > + "arguments": { "uuid": > > "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" } } +<- {"return": {}} >
diff --git a/hmp-commands.hx b/hmp-commands.hx index bb52e4d..06800b0 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1756,5 +1756,18 @@ ETEXI }, STEXI +@item set-vm-generation-id @var{uuid} +Set Virtual Machine Generation ID counter to @var{uuid} +ETEXI + + { + .name = "set-vm-generation-id", + .args_type = "uuid:s", + .params = "uuid", + .help = "Set Virtual Machine Generation ID counter", + .mhandler.cmd = hmp_set_vm_generation_id, + }, + +STEXI @end table ETEXI diff --git a/hmp.c b/hmp.c index 63a4457..fad94f1 100644 --- a/hmp.c +++ b/hmp.c @@ -2384,3 +2384,15 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict) } qapi_free_UuidInfo(info); } + +void hmp_set_vm_generation_id(Monitor *mon, const QDict *qdict) +{ + Error *errp = NULL; + const char *uuid = qdict_get_str(qdict, "uuid"); + + qmp_set_vm_generation_id(uuid, &errp); + if (errp != NULL) { + hmp_handle_error(mon, &errp); + return; + } +} diff --git a/hmp.h b/hmp.h index 21c5132..cbf2045 100644 --- a/hmp.h +++ b/hmp.h @@ -132,5 +132,6 @@ void hmp_rocker_ports(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict); void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict); +void hmp_set_vm_generation_id(Monitor *mon, const QDict *qdict); #endif diff --git a/hw/misc/vmgenid.c b/hw/misc/vmgenid.c index 9323b23..bec832f 100644 --- a/hw/misc/vmgenid.c +++ b/hw/misc/vmgenid.c @@ -58,6 +58,17 @@ UuidInfo *qmp_query_vm_generation_id(Error **errp) return info; } +void qmp_set_vm_generation_id(const char *uuid, Error **errp) +{ + Object *obj = find_vmgneid_dev(errp); + + if (!obj) { + return; + } + + object_property_set_str(obj, uuid, VMGENID_UUID, errp); +} + static void vmgenid_update_guest(VmGenIdState *s) { Object *acpi_obj; diff --git a/qapi-schema.json b/qapi-schema.json index a4ff6c1..789b7d7 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4090,3 +4090,12 @@ # Since 2.6 ## { 'command': 'query-vm-generation-id', 'returns': 'UuidInfo' } + +## +# @set-vm-generation-id +# +# Set Virtual Machine Generation ID +# +# Since 2.6 +## +{ 'command': 'set-vm-generation-id', 'data': { 'uuid': 'str' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 9408a3d..306082f 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -4814,3 +4814,25 @@ Example: -> { "execute": "query-vm-generation-id" } <- {"return": {"UUID": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87"}} + +EQMP + + { + .name = "set-vm-generation-id", + .args_type = "uuid:s", + .mhandler.cmd_new = qmp_marshal_set_vm_generation_id, + }, + +SQMP +Set Virtual Machine Generation ID counter +----- + +Arguments: + +- "UUID": counter ID in UUID string representation (json-string)" + +Example: + +-> { "execute": "set-vm-generation-id" , + "arguments": { "uuid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" } } +<- {"return": {}} diff --git a/stubs/vmgenid.c b/stubs/vmgenid.c index 3cf1013..0fffb87 100644 --- a/stubs/vmgenid.c +++ b/stubs/vmgenid.c @@ -5,3 +5,9 @@ UuidInfo *qmp_query_vm_generation_id(Error **errp) error_setg(errp, "this command is not currently supported"); return NULL; } + +void qmp_set_vm_generation_id(const char *uuid, Error **errp) +{ + error_setg(errp, "this command is not currently supported"); + return; +}
Add set-vm-generation-id command to set Virtual Machine Generation ID counter. QMP command example: { "execute": "set-vm-generation-id", "arguments": { "uuid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" } } HMP command example: set-vm-generation-id 324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87 Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- hmp-commands.hx | 13 +++++++++++++ hmp.c | 12 ++++++++++++ hmp.h | 1 + hw/misc/vmgenid.c | 11 +++++++++++ qapi-schema.json | 9 +++++++++ qmp-commands.hx | 22 ++++++++++++++++++++++ stubs/vmgenid.c | 6 ++++++ 7 files changed, 74 insertions(+)