* [Qemu-devel] [PATCH] monitor: convert do_device_del() to QObject, QError
@ 2010-03-17 16:46 Markus Armbruster
2010-03-18 21:27 ` [Qemu-devel] " Luiz Capitulino
0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2010-03-17 16:46 UTC (permalink / raw)
To: qemu-devel; +Cc: lcapitulino
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/qdev.c | 7 ++++---
hw/qdev.h | 2 +-
qemu-monitor.hx | 3 ++-
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 17a46a7..35460eb 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -800,15 +800,16 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
return 0;
}
-void do_device_del(Monitor *mon, const QDict *qdict)
+int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
DeviceState *dev;
dev = qdev_find_recursive(main_system_bus, id);
if (NULL == dev) {
- error_report("Device '%s' not found", id);
- return;
+ qerror_report(QERR_DEVICE_NOT_FOUND, id);
+ return -1;
}
qdev_unplug(dev);
+ return 0;
}
diff --git a/hw/qdev.h b/hw/qdev.h
index 9475705..40373c8 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -176,7 +176,7 @@ void qbus_free(BusState *bus);
void do_info_qtree(Monitor *mon);
void do_info_qdm(Monitor *mon);
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
-void do_device_del(Monitor *mon, const QDict *qdict);
+int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
/*** qdev-properties.c ***/
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 5308f36..d290b4b 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -589,7 +589,8 @@ ETEXI
.args_type = "id:s",
.params = "device",
.help = "remove device",
- .mhandler.cmd = do_device_del,
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_device_del,
},
STEXI
--
1.6.6.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH] monitor: convert do_device_del() to QObject, QError
2010-03-17 16:46 [Qemu-devel] [PATCH] monitor: convert do_device_del() to QObject, QError Markus Armbruster
@ 2010-03-18 21:27 ` Luiz Capitulino
2010-03-19 21:35 ` Markus Armbruster
0 siblings, 1 reply; 3+ messages in thread
From: Luiz Capitulino @ 2010-03-18 21:27 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
On Wed, 17 Mar 2010 17:46:07 +0100
Markus Armbruster <armbru@redhat.com> wrote:
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> hw/qdev.c | 7 ++++---
> hw/qdev.h | 2 +-
> qemu-monitor.hx | 3 ++-
> 3 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 17a46a7..35460eb 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -800,15 +800,16 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
> return 0;
> }
>
> -void do_device_del(Monitor *mon, const QDict *qdict)
> +int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
> {
> const char *id = qdict_get_str(qdict, "id");
> DeviceState *dev;
>
> dev = qdev_find_recursive(main_system_bus, id);
> if (NULL == dev) {
> - error_report("Device '%s' not found", id);
> - return;
> + qerror_report(QERR_DEVICE_NOT_FOUND, id);
> + return -1;
> }
> qdev_unplug(dev);
This function can fail, otherwise looks good.
> + return 0;
> }
> diff --git a/hw/qdev.h b/hw/qdev.h
> index 9475705..40373c8 100644
> --- a/hw/qdev.h
> +++ b/hw/qdev.h
> @@ -176,7 +176,7 @@ void qbus_free(BusState *bus);
> void do_info_qtree(Monitor *mon);
> void do_info_qdm(Monitor *mon);
> int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
> -void do_device_del(Monitor *mon, const QDict *qdict);
> +int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
>
> /*** qdev-properties.c ***/
>
> diff --git a/qemu-monitor.hx b/qemu-monitor.hx
> index 5308f36..d290b4b 100644
> --- a/qemu-monitor.hx
> +++ b/qemu-monitor.hx
> @@ -589,7 +589,8 @@ ETEXI
> .args_type = "id:s",
> .params = "device",
> .help = "remove device",
> - .mhandler.cmd = do_device_del,
> + .user_print = monitor_user_noop,
> + .mhandler.cmd_new = do_device_del,
> },
>
> STEXI
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH] monitor: convert do_device_del() to QObject, QError
2010-03-18 21:27 ` [Qemu-devel] " Luiz Capitulino
@ 2010-03-19 21:35 ` Markus Armbruster
0 siblings, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2010-03-19 21:35 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel
Luiz Capitulino <lcapitulino@redhat.com> writes:
> On Wed, 17 Mar 2010 17:46:07 +0100
> Markus Armbruster <armbru@redhat.com> wrote:
>
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>> hw/qdev.c | 7 ++++---
>> hw/qdev.h | 2 +-
>> qemu-monitor.hx | 3 ++-
>> 3 files changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/qdev.c b/hw/qdev.c
>> index 17a46a7..35460eb 100644
>> --- a/hw/qdev.c
>> +++ b/hw/qdev.c
>> @@ -800,15 +800,16 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
>> return 0;
>> }
>>
>> -void do_device_del(Monitor *mon, const QDict *qdict)
>> +int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
>> {
>> const char *id = qdict_get_str(qdict, "id");
>> DeviceState *dev;
>>
>> dev = qdev_find_recursive(main_system_bus, id);
>> if (NULL == dev) {
>> - error_report("Device '%s' not found", id);
>> - return;
>> + qerror_report(QERR_DEVICE_NOT_FOUND, id);
>> + return -1;
>> }
>> qdev_unplug(dev);
>
> This function can fail, otherwise looks good.
Thanks, will fix.
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-19 21:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-17 16:46 [Qemu-devel] [PATCH] monitor: convert do_device_del() to QObject, QError Markus Armbruster
2010-03-18 21:27 ` [Qemu-devel] " Luiz Capitulino
2010-03-19 21:35 ` Markus Armbruster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).