monitor: add object-del (QMP) and object_del (HMP) command
These two commands invoke the "unparent" method of Object. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
b0ed5e9fea
commit
ab2d0531b2
@ -1241,6 +1241,20 @@ STEXI
|
|||||||
@item netdev_del
|
@item netdev_del
|
||||||
@findex netdev_del
|
@findex netdev_del
|
||||||
Remove host network device.
|
Remove host network device.
|
||||||
|
ETEXI
|
||||||
|
|
||||||
|
{
|
||||||
|
.name = "object_del",
|
||||||
|
.args_type = "id:s",
|
||||||
|
.params = "id",
|
||||||
|
.help = "destroy QOM object",
|
||||||
|
.mhandler.cmd = hmp_object_del,
|
||||||
|
},
|
||||||
|
|
||||||
|
STEXI
|
||||||
|
@item object_del
|
||||||
|
@findex object_del
|
||||||
|
Destroy QOM object.
|
||||||
ETEXI
|
ETEXI
|
||||||
|
|
||||||
#ifdef CONFIG_SLIRP
|
#ifdef CONFIG_SLIRP
|
||||||
|
9
hmp.c
9
hmp.c
@ -1574,3 +1574,12 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
|
|||||||
|
|
||||||
hmp_handle_error(mon, &err);
|
hmp_handle_error(mon, &err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hmp_object_del(Monitor *mon, const QDict *qdict)
|
||||||
|
{
|
||||||
|
const char *id = qdict_get_str(qdict, "id");
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
|
qmp_object_del(id, &err);
|
||||||
|
hmp_handle_error(mon, &err);
|
||||||
|
}
|
||||||
|
1
hmp.h
1
hmp.h
@ -90,5 +90,6 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict);
|
|||||||
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
|
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
|
||||||
void hmp_qemu_io(Monitor *mon, const QDict *qdict);
|
void hmp_qemu_io(Monitor *mon, const QDict *qdict);
|
||||||
void hmp_cpu_add(Monitor *mon, const QDict *qdict);
|
void hmp_cpu_add(Monitor *mon, const QDict *qdict);
|
||||||
|
void hmp_object_del(Monitor *mon, const QDict *qdict);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2758,6 +2758,20 @@
|
|||||||
##
|
##
|
||||||
{ 'command': 'netdev_del', 'data': {'id': 'str'} }
|
{ 'command': 'netdev_del', 'data': {'id': 'str'} }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @object-del:
|
||||||
|
#
|
||||||
|
# Remove a QOM object.
|
||||||
|
#
|
||||||
|
# @id: the name of the QOM object to remove
|
||||||
|
#
|
||||||
|
# Returns: Nothing on success
|
||||||
|
# Error if @id is not a valid id for a QOM object
|
||||||
|
#
|
||||||
|
# Since: 2.0
|
||||||
|
##
|
||||||
|
{ 'command': 'object-del', 'data': {'id': 'str'} }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @NetdevNoneOptions
|
# @NetdevNoneOptions
|
||||||
#
|
#
|
||||||
|
@ -878,6 +878,31 @@ Example:
|
|||||||
|
|
||||||
EQMP
|
EQMP
|
||||||
|
|
||||||
|
{
|
||||||
|
.name = "object-del",
|
||||||
|
.args_type = "id:s",
|
||||||
|
.mhandler.cmd_new = qmp_marshal_input_object_del,
|
||||||
|
},
|
||||||
|
|
||||||
|
SQMP
|
||||||
|
object-del
|
||||||
|
----------
|
||||||
|
|
||||||
|
Remove QOM object.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
- "id": the object's ID (json-string)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
-> { "execute": "object-del", "arguments": { "id": "rng1" } }
|
||||||
|
<- { "return": {} }
|
||||||
|
|
||||||
|
|
||||||
|
EQMP
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
.name = "block_resize",
|
.name = "block_resize",
|
||||||
.args_type = "device:B,size:o",
|
.args_type = "device:B,size:o",
|
||||||
|
14
qmp.c
14
qmp.c
@ -529,3 +529,17 @@ void qmp_add_client(const char *protocol, const char *fdname,
|
|||||||
error_setg(errp, "protocol '%s' is invalid", protocol);
|
error_setg(errp, "protocol '%s' is invalid", protocol);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qmp_object_del(const char *id, Error **errp)
|
||||||
|
{
|
||||||
|
Object *container;
|
||||||
|
Object *obj;
|
||||||
|
|
||||||
|
container = container_get(object_get_root(), "/objects");
|
||||||
|
obj = object_resolve_path_component(container, id);
|
||||||
|
if (!obj) {
|
||||||
|
error_setg(errp, "object id not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
object_unparent(obj);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user