Skip to content

Commit

Permalink
qapi: Drop qapi_event_send_FOO()'s Error ** argument
Browse files Browse the repository at this point in the history
The generated qapi_event_send_FOO() take an Error ** argument.  They
can't actually fail, because all they do with the argument is passing it
to functions that can't fail: the QObject output visitor, and the
@qmp_emit callback, which is either monitor_qapi_event_queue() or
event_test_emit().

Drop the argument, and pass &error_abort to the QObject output visitor
and @qmp_emit instead.

Suggested-by: Eric Blake <[email protected]>
Suggested-by: Markus Armbruster <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
[Commit message rewritten, update to qapi-code-gen.txt corrected]
Signed-off-by: Markus Armbruster <[email protected]>
  • Loading branch information
xzpeter authored and Markus Armbruster committed Aug 28, 2018
1 parent bdd2d42 commit 3ab7238
Show file tree
Hide file tree
Showing 29 changed files with 70 additions and 104 deletions.
8 changes: 3 additions & 5 deletions block/block-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,7 @@ void blk_dev_change_media_cb(BlockBackend *blk, bool load, Error **errp)

if (tray_was_open != tray_is_open) {
char *id = blk_get_attached_dev_id(blk);
qapi_event_send_device_tray_moved(blk_name(blk), id, tray_is_open,
&error_abort);
qapi_event_send_device_tray_moved(blk_name(blk), id, tray_is_open);
g_free(id);
}
}
Expand Down Expand Up @@ -1665,8 +1664,7 @@ static void send_qmp_error_event(BlockBackend *blk,
qapi_event_send_block_io_error(blk_name(blk), !!bs,
bs ? bdrv_get_node_name(bs) : NULL, optype,
action, blk_iostatus_is_enabled(blk),
error == ENOSPC, strerror(error),
&error_abort);
error == ENOSPC, strerror(error));
}

/* This is done by device models because, while the block layer knows
Expand Down Expand Up @@ -1782,7 +1780,7 @@ void blk_eject(BlockBackend *blk, bool eject_flag)
* the frontend experienced a tray event. */
id = blk_get_attached_dev_id(blk);
qapi_event_send_device_tray_moved(blk_name(blk), id,
eject_flag, &error_abort);
eject_flag);
g_free(id);
}

Expand Down
2 changes: 1 addition & 1 deletion block/qcow2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4659,7 +4659,7 @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,
*node_name != '\0', node_name,
message, offset >= 0, offset,
size >= 0, size,
fatal, &error_abort);
fatal);
g_free(message);

if (fatal) {
Expand Down
4 changes: 2 additions & 2 deletions block/quorum.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static void quorum_report_bad(QuorumOpType type, uint64_t offset,
}

qapi_event_send_quorum_report_bad(type, !!msg, msg, node_name, start_sector,
end_sector - start_sector, &error_abort);
end_sector - start_sector);
}

static void quorum_report_failure(QuorumAIOCB *acb)
Expand All @@ -210,7 +210,7 @@ static void quorum_report_failure(QuorumAIOCB *acb)
BDRV_SECTOR_SIZE);

qapi_event_send_quorum_failure(reference, start_sector,
end_sector - start_sector, &error_abort);
end_sector - start_sector);
}

static int quorum_vote_error(QuorumAIOCB *acb);
Expand Down
3 changes: 1 addition & 2 deletions block/write-threshold.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ static int coroutine_fn before_write_notify(NotifierWithReturn *notifier,
qapi_event_send_block_write_threshold(
bs->node_name,
amount,
bs->write_threshold_offset,
&error_abort);
bs->write_threshold_offset);

/* autodisable to avoid flooding the monitor */
write_threshold_disable(bs);
Expand Down
13 changes: 5 additions & 8 deletions blockjob.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ static void block_job_event_cancelled(Notifier *n, void *opaque)
job->job.id,
job->job.progress_total,
job->job.progress_current,
job->speed,
&error_abort);
job->speed);
}

static void block_job_event_completed(Notifier *n, void *opaque)
Expand All @@ -338,8 +337,7 @@ static void block_job_event_completed(Notifier *n, void *opaque)
job->job.progress_current,
job->speed,
!!msg,
msg,
&error_abort);
msg);
}

static void block_job_event_pending(Notifier *n, void *opaque)
Expand All @@ -351,8 +349,7 @@ static void block_job_event_pending(Notifier *n, void *opaque)
}

qapi_event_send_block_job_pending(job_type(&job->job),
job->job.id,
&error_abort);
job->job.id);
}

static void block_job_event_ready(Notifier *n, void *opaque)
Expand All @@ -367,7 +364,7 @@ static void block_job_event_ready(Notifier *n, void *opaque)
job->job.id,
job->job.progress_total,
job->job.progress_current,
job->speed, &error_abort);
job->speed);
}


Expand Down Expand Up @@ -494,7 +491,7 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockdevOnError on_err,
qapi_event_send_block_job_error(job->job.id,
is_read ? IO_OPERATION_TYPE_READ :
IO_OPERATION_TYPE_WRITE,
action, &error_abort);
action);
}
if (action == BLOCK_ERROR_ACTION_STOP) {
job_pause(&job->job);
Expand Down
8 changes: 4 additions & 4 deletions cpus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ static int do_vm_stop(RunState state, bool send_stop)
runstate_set(state);
vm_state_notify(0, state);
if (send_stop) {
qapi_event_send_stop(&error_abort);
qapi_event_send_stop();
}
}

Expand Down Expand Up @@ -2107,13 +2107,13 @@ int vm_prepare_start(void)
* the STOP event.
*/
if (runstate_is_running()) {
qapi_event_send_stop(&error_abort);
qapi_event_send_resume(&error_abort);
qapi_event_send_stop();
qapi_event_send_resume();
return -1;
}

/* We are sending this now, but the CPUs will be resumed shortly later */
qapi_event_send_resume(&error_abort);
qapi_event_send_resume();

replay_enable_events();
cpu_enable_ticks();
Expand Down
8 changes: 3 additions & 5 deletions docs/devel/qapi-code-gen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ Example:
#include "example-qapi-types.h"


void qapi_event_send_my_event(Error **errp);
void qapi_event_send_my_event(void);

typedef enum example_QAPIEvent {
EXAMPLE_QAPI_EVENT_MY_EVENT = 0,
Expand All @@ -1356,10 +1356,9 @@ Example:
$ cat qapi-generated/example-qapi-events.c
[Uninteresting stuff omitted...]

void qapi_event_send_my_event(Error **errp)
void qapi_event_send_my_event(void)
{
QDict *qmp;
Error *err = NULL;
QMPEventFuncEmit emit;

emit = qmp_event_get_func_emit();
Expand All @@ -1369,9 +1368,8 @@ Example:

qmp = qmp_event_build_dict("MY_EVENT");

emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp, &err);
emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp);

error_propagate(errp, err);
qobject_unref(qmp);
}

Expand Down
3 changes: 1 addition & 2 deletions dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1890,8 +1890,7 @@ static void dump_process(DumpState *s, Error **errp)
/* should never fail */
assert(result);
qapi_event_send_dump_completed(result, !!local_err, (local_err ? \
error_get_pretty(local_err) : NULL),
&error_abort);
error_get_pretty(local_err) : NULL));
qapi_free_DumpQueryResult(result);

error_propagate(errp, local_err);
Expand Down
2 changes: 1 addition & 1 deletion hw/acpi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
break;
default:
if (sus_typ == ar->pm1.cnt.s4_val) { /* S4 request */
qapi_event_send_suspend_disk(&error_abort);
qapi_event_send_suspend_disk();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion hw/acpi/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data,
cdev = &cpu_st->devs[cpu_st->selector];
cdev->ost_status = data;
info = acpi_cpu_device_status(cpu_st->selector, cdev);
qapi_event_send_acpi_device_ost(info, &error_abort);
qapi_event_send_acpi_device_ost(info);
qapi_free_ACPIOSTInfo(info);
trace_cpuhp_acpi_write_ost_status(cpu_st->selector,
cdev->ost_status);
Expand Down
5 changes: 2 additions & 3 deletions hw/acpi/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
/* TODO: implement memory removal on guest signal */

info = acpi_memory_device_status(mem_st->selector, mdev);
qapi_event_send_acpi_device_ost(info, &error_abort);
qapi_event_send_acpi_device_ost(info);
qapi_free_ACPIOSTInfo(info);
break;
case 0x14: /* set is_* fields */
Expand All @@ -185,8 +185,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
if (local_err) {
trace_mhp_acpi_pc_dimm_delete_failed(mem_st->selector);
qapi_event_send_mem_unplug_error(dev->id,
error_get_pretty(local_err),
&error_abort);
error_get_pretty(local_err));
error_free(local_err);
break;
}
Expand Down
3 changes: 1 addition & 2 deletions hw/char/virtio-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ static void set_guest_connected(VirtIOSerialPort *port, int guest_connected)
}

if (dev->id) {
qapi_event_send_vserport_change(dev->id, guest_connected,
&error_abort);
qapi_event_send_vserport_change(dev->id, guest_connected);
}
}

Expand Down
3 changes: 1 addition & 2 deletions hw/core/qdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,7 @@ static void device_finalize(Object *obj)
if (dev->pending_deleted_event) {
g_assert(dev->canonical_path);

qapi_event_send_device_deleted(!!dev->id, dev->id, dev->canonical_path,
&error_abort);
qapi_event_send_device_deleted(!!dev->id, dev->id, dev->canonical_path);
g_free(dev->canonical_path);
dev->canonical_path = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion hw/net/virtio-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static void rxfilter_notify(NetClientState *nc)
if (nc->rxfilter_notify_enabled) {
gchar *path = object_get_canonical_path(OBJECT(n->qdev));
qapi_event_send_nic_rx_filter_changed(!!n->netclient_name,
n->netclient_name, path, &error_abort);
n->netclient_name, path);
g_free(path);

/* disable event notification to avoid events flooding */
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/spapr_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, sPAPRMachineState *spapr,
}

/* Generate a monitor event for the change */
qapi_event_send_rtc_change(qemu_timedate_diff(&tm), &error_abort);
qapi_event_send_rtc_change(qemu_timedate_diff(&tm));

host_ns = qemu_clock_get_ns(rtc_clock);

Expand Down
2 changes: 1 addition & 1 deletion hw/timer/mc146818rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ static void rtc_set_time(RTCState *s)
s->base_rtc = mktimegm(&tm);
s->last_update = qemu_clock_get_ns(rtc_clock);

qapi_event_send_rtc_change(qemu_timedate_diff(&tm), &error_abort);
qapi_event_send_rtc_change(qemu_timedate_diff(&tm));
}

static void rtc_set_cmos(RTCState *s, const struct tm *tm)
Expand Down
3 changes: 1 addition & 2 deletions hw/virtio/virtio-balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,
dev->actual = le32_to_cpu(config.actual);
if (dev->actual != oldactual) {
qapi_event_send_balloon_change(vm_ram_size -
((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT),
&error_abort);
((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT));
}
trace_virtio_balloon_set_config(dev->actual, oldactual);
}
Expand Down
15 changes: 7 additions & 8 deletions hw/watchdog/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,40 +102,39 @@ void watchdog_perform_action(void)
{
switch (watchdog_action) {
case WATCHDOG_ACTION_RESET: /* same as 'system_reset' in monitor */
qapi_event_send_watchdog(WATCHDOG_ACTION_RESET, &error_abort);
qapi_event_send_watchdog(WATCHDOG_ACTION_RESET);
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
break;

case WATCHDOG_ACTION_SHUTDOWN: /* same as 'system_powerdown' in monitor */
qapi_event_send_watchdog(WATCHDOG_ACTION_SHUTDOWN, &error_abort);
qapi_event_send_watchdog(WATCHDOG_ACTION_SHUTDOWN);
qemu_system_powerdown_request();
break;

case WATCHDOG_ACTION_POWEROFF: /* same as 'quit' command in monitor */
qapi_event_send_watchdog(WATCHDOG_ACTION_POWEROFF, &error_abort);
qapi_event_send_watchdog(WATCHDOG_ACTION_POWEROFF);
exit(0);

case WATCHDOG_ACTION_PAUSE: /* same as 'stop' command in monitor */
/* In a timer callback, when vm_stop calls qemu_clock_enable
* you would get a deadlock. Bypass the problem.
*/
qemu_system_vmstop_request_prepare();
qapi_event_send_watchdog(WATCHDOG_ACTION_PAUSE, &error_abort);
qapi_event_send_watchdog(WATCHDOG_ACTION_PAUSE);
qemu_system_vmstop_request(RUN_STATE_WATCHDOG);
break;

case WATCHDOG_ACTION_DEBUG:
qapi_event_send_watchdog(WATCHDOG_ACTION_DEBUG, &error_abort);
qapi_event_send_watchdog(WATCHDOG_ACTION_DEBUG);
fprintf(stderr, "watchdog: timer fired\n");
break;

case WATCHDOG_ACTION_NONE:
qapi_event_send_watchdog(WATCHDOG_ACTION_NONE, &error_abort);
qapi_event_send_watchdog(WATCHDOG_ACTION_NONE);
break;

case WATCHDOG_ACTION_INJECT_NMI:
qapi_event_send_watchdog(WATCHDOG_ACTION_INJECT_NMI,
&error_abort);
qapi_event_send_watchdog(WATCHDOG_ACTION_INJECT_NMI);
nmi_monitor_handle(0, NULL);
break;

Expand Down
3 changes: 1 addition & 2 deletions include/qapi/qmp-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#ifndef QMP_EVENT_H
#define QMP_EVENT_H


typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict, Error **errp);
typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict);

void qmp_event_set_func_emit(QMPEventFuncEmit emit);

Expand Down
2 changes: 1 addition & 1 deletion job.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void job_state_transition(Job *job, JobStatus s1)
job->status = s1;

if (!job_is_internal(job) && s1 != s0) {
qapi_event_send_job_status_change(job->id, job->status, &error_abort);
qapi_event_send_job_status_change(job->id, job->status);
}
}

Expand Down
4 changes: 2 additions & 2 deletions migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void migration_incoming_state_destroy(void)
static void migrate_generate_event(int new_state)
{
if (migrate_use_events()) {
qapi_event_send_migration(new_state, &error_abort);
qapi_event_send_migration(new_state);
}
}

Expand Down Expand Up @@ -302,7 +302,7 @@ void qemu_start_incoming_migration(const char *uri, Error **errp)
{
const char *p;

qapi_event_send_migration(MIGRATION_STATUS_SETUP, &error_abort);
qapi_event_send_migration(MIGRATION_STATUS_SETUP);
if (!strcmp(uri, "defer")) {
deferred_incoming_migration(errp);
} else if (strstart(uri, "tcp:", &p)) {
Expand Down
2 changes: 1 addition & 1 deletion migration/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ static void migration_bitmap_sync(RAMState *rs)
rs->bytes_xfer_prev = bytes_xfer_now;
}
if (migrate_use_events()) {
qapi_event_send_migration_pass(ram_counters.dirty_sync_count, NULL);
qapi_event_send_migration_pass(ram_counters.dirty_sync_count);
}
}

Expand Down
5 changes: 2 additions & 3 deletions monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ monitor_qapi_event_queue_no_reenter(QAPIEvent event, QDict *qdict)
}

static void
monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
monitor_qapi_event_queue(QAPIEvent event, QDict *qdict)
{
/*
* monitor_qapi_event_queue_no_reenter() is not reentrant: it
Expand Down Expand Up @@ -4316,8 +4316,7 @@ static void handle_qmp_command(void *opaque, QObject *req, Error *err)
* that command was dropped.
*/
qapi_event_send_command_dropped(id,
COMMAND_DROP_REASON_QUEUE_FULL,
&error_abort);
COMMAND_DROP_REASON_QUEUE_FULL);
qmp_request_free(req_obj);
return;
}
Expand Down
Loading

0 comments on commit 3ab7238

Please sign in to comment.