diff options
114 files changed, 1358 insertions, 1063 deletions
diff --git a/arch_init.c b/arch_init.c index 5fc6fc3..691b5e2 100644 --- a/arch_init.c +++ b/arch_init.c @@ -1124,8 +1124,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ret = qemu_ram_resize(block->offset, length, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } } break; @@ -36,7 +36,7 @@ static QEMUBalloonEvent *balloon_event_fn; static QEMUBalloonStatus *balloon_stat_fn; static void *balloon_opaque; -static bool have_ballon(Error **errp) +static bool have_balloon(Error **errp) { if (kvm_enabled() && !kvm_has_sync_mmu()) { error_set(errp, ERROR_CLASS_KVM_MISSING_CAP, @@ -81,7 +81,7 @@ BalloonInfo *qmp_query_balloon(Error **errp) { BalloonInfo *info; - if (!have_ballon(errp)) { + if (!have_balloon(errp)) { return NULL; } @@ -92,7 +92,7 @@ BalloonInfo *qmp_query_balloon(Error **errp) void qmp_balloon(int64_t target, Error **errp) { - if (!have_ballon(errp)) { + if (!have_balloon(errp)) { return; } diff --git a/block/block-backend.c b/block/block-backend.c index aabe569..bfb0418 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -145,7 +145,7 @@ static void blk_delete(BlockBackend *blk) bdrv_unref(blk->bs); blk->bs = NULL; } - /* Avoid double-remove after blk_hide_on_behalf_of_do_drive_del() */ + /* Avoid double-remove after blk_hide_on_behalf_of_hmp_drive_del() */ if (blk->name[0]) { QTAILQ_REMOVE(&blk_backends, blk, link); } @@ -206,7 +206,7 @@ BlockBackend *blk_next(BlockBackend *blk) /* * Return @blk's name, a non-null string. * Wart: the name is empty iff @blk has been hidden with - * blk_hide_on_behalf_of_do_drive_del(). + * blk_hide_on_behalf_of_hmp_drive_del(). */ const char *blk_name(BlockBackend *blk) { @@ -282,7 +282,7 @@ BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo) * Strictly for use by do_drive_del(). * TODO get rid of it! */ -void blk_hide_on_behalf_of_do_drive_del(BlockBackend *blk) +void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk) { QTAILQ_REMOVE(&blk_backends, blk, link); blk->name[0] = 0; diff --git a/block/sheepdog.c b/block/sheepdog.c index b320871..d17ee36 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -726,8 +726,7 @@ static coroutine_fn void reconnect_to_sdog(void *opaque) s->fd = get_sheep_fd(s, &local_err); if (s->fd < 0) { DPRINTF("Wait for connection to be established\n"); - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); co_aio_sleep_ns(bdrv_get_aio_context(s->bs), QEMU_CLOCK_REALTIME, 1000000000ULL); } @@ -1283,8 +1282,7 @@ static int reload_inode(BDRVSheepdogState *s, uint32_t snapid, const char *tag) fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); return -EIO; } @@ -1292,8 +1290,7 @@ static int reload_inode(BDRVSheepdogState *s, uint32_t snapid, const char *tag) ret = find_vdi_name(s, s->name, snapid, tag, &vid, false, &local_err); if (ret) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); goto out; } @@ -1785,8 +1782,7 @@ static void sd_close(BlockDriverState *bs) fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); return; } @@ -1838,8 +1834,7 @@ static int sd_truncate(BlockDriverState *bs, int64_t offset) fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); return fd; } @@ -1912,8 +1907,7 @@ static bool sd_delete(BDRVSheepdogState *s) fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); return false; } @@ -1960,8 +1954,7 @@ static int sd_create_branch(BDRVSheepdogState *s) deleted = sd_delete(s); ret = do_sd_create(s, &vid, !deleted, &local_err); if (ret) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); goto out; } @@ -1969,8 +1962,7 @@ static int sd_create_branch(BDRVSheepdogState *s) fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); ret = fd; goto out; } @@ -2218,8 +2210,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) /* refresh inode. */ fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); ret = fd; goto cleanup; } @@ -2234,8 +2225,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) ret = do_sd_create(s, &new_vid, 1, &local_err); if (ret < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); error_report("failed to create inode for snapshot. %s", strerror(errno)); goto cleanup; @@ -2336,8 +2326,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); ret = fd; goto out; } @@ -2366,8 +2355,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); ret = fd; goto out; } @@ -2429,8 +2417,7 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data, fd = connect_to_sdog(s, &local_err); if (fd < 0) { - error_report("%s", error_get_pretty(local_err));; - error_free(local_err); + error_report_err(local_err); return fd; } @@ -720,8 +720,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); return NULL; } } @@ -759,8 +758,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) &error_abort); qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); goto fail; } @@ -975,8 +973,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) bs_opts = NULL; if (!blk) { if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } goto fail; } else { @@ -1017,7 +1014,7 @@ fail: return dinfo; } -void do_commit(Monitor *mon, const QDict *qdict) +void hmp_commit(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_str(qdict, "device"); BlockDriverState *bs; @@ -1945,7 +1942,7 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, aio_context_release(aio_context); } -int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) +int hmp_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *id = qdict_get_str(qdict, "id"); BlockBackend *blk; @@ -1970,8 +1967,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) aio_context_acquire(aio_context); if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); aio_context_release(aio_context); return -1; } @@ -1987,7 +1983,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) * then we can just get rid of the block driver state right here. */ if (blk_get_attached_dev(blk)) { - blk_hide_on_behalf_of_do_drive_del(blk); + blk_hide_on_behalf_of_hmp_drive_del(blk); /* Further I/O must not pause the guest */ bdrv_set_on_error(bs, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT); diff --git a/device-hotplug.c b/device-hotplug.c index 9e38cc4..833d874 100644 --- a/device-hotplug.c +++ b/device-hotplug.c @@ -50,7 +50,7 @@ DriveInfo *add_init_drive(const char *optstr) return dinfo; } -void drive_hot_add(Monitor *mon, const QDict *qdict) +void hmp_drive_add(Monitor *mon, const QDict *qdict) { DriveInfo *dinfo = NULL; const char *opts = qdict_get_str(qdict, "opts"); diff --git a/hmp-commands.hx b/hmp-commands.hx index e37bc8b..81f276b 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -28,7 +28,7 @@ ETEXI .args_type = "device:B", .params = "device|all", .help = "commit changes to the disk images (if -snapshot is used) or backing files", - .mhandler.cmd = do_commit, + .mhandler.cmd = hmp_commit, }, STEXI @@ -180,7 +180,7 @@ ETEXI .params = "device", .help = "remove host block device", .user_print = monitor_user_noop, - .mhandler.cmd_new = do_drive_del, + .mhandler.cmd_new = hmp_drive_del, }, STEXI @@ -245,7 +245,7 @@ ETEXI .args_type = "filename:F", .params = "filename", .help = "save screen into PPM image 'filename'", - .mhandler.cmd = hmp_screen_dump, + .mhandler.cmd = hmp_screendump, }, STEXI @@ -259,7 +259,7 @@ ETEXI .args_type = "filename:F", .params = "filename", .help = "output logs to 'filename'", - .mhandler.cmd = do_logfile, + .mhandler.cmd = hmp_logfile, }, STEXI @@ -273,7 +273,7 @@ ETEXI .args_type = "name:s,option:b", .params = "name on|off", .help = "changes status of a specific trace event", - .mhandler.cmd = do_trace_event_set_state, + .mhandler.cmd = hmp_trace_event, }, STEXI @@ -288,7 +288,7 @@ ETEXI .args_type = "op:s?,arg:F?", .params = "on|off|flush|set [arg]", .help = "open, close, or flush trace file, or set a new file name", - .mhandler.cmd = do_trace_file, + .mhandler.cmd = hmp_trace_file, }, STEXI @@ -303,7 +303,7 @@ ETEXI .args_type = "items:s", .params = "item1[,...]", .help = "activate logging of the specified items", - .mhandler.cmd = do_log, + .mhandler.cmd = hmp_log, }, STEXI @@ -317,7 +317,7 @@ ETEXI .args_type = "name:s?", .params = "[tag|id]", .help = "save a VM snapshot. If no tag or id are provided, a new snapshot is created", - .mhandler.cmd = do_savevm, + .mhandler.cmd = hmp_savevm, }, STEXI @@ -334,7 +334,7 @@ ETEXI .args_type = "name:s", .params = "tag|id", .help = "restore a VM snapshot from its tag or id", - .mhandler.cmd = do_loadvm, + .mhandler.cmd = hmp_loadvm, .command_completion = loadvm_completion, }, @@ -350,7 +350,7 @@ ETEXI .args_type = "name:s", .params = "tag|id", .help = "delete a VM snapshot from its tag or id", - .mhandler.cmd = do_delvm, + .mhandler.cmd = hmp_delvm, .command_completion = delvm_completion, }, @@ -365,7 +365,7 @@ ETEXI .args_type = "option:s?", .params = "[on|off]", .help = "run emulation in singlestep mode or switch to normal mode", - .mhandler.cmd = do_singlestep, + .mhandler.cmd = hmp_singlestep, }, STEXI @@ -422,7 +422,7 @@ ETEXI .args_type = "device:s?", .params = "[device]", .help = "start gdbserver on given device (default 'tcp::1234'), stop with 'none'", - .mhandler.cmd = do_gdbserver, + .mhandler.cmd = hmp_gdbserver, }, STEXI @@ -436,7 +436,7 @@ ETEXI .args_type = "fmt:/,addr:l", .params = "/fmt addr", .help = "virtual memory dump starting at 'addr'", - .mhandler.cmd = do_memory_dump, + .mhandler.cmd = hmp_memory_dump, }, STEXI @@ -450,7 +450,7 @@ ETEXI .args_type = "fmt:/,addr:l", .params = "/fmt addr", .help = "physical memory dump starting at 'addr'", - .mhandler.cmd = do_physical_memory_dump, + .mhandler.cmd = hmp_physical_memory_dump, }, STEXI @@ -533,7 +533,7 @@ ETEXI .args_type = "fmt:/,addr:i,index:i.", .params = "/fmt addr", .help = "I/O port read", - .mhandler.cmd = do_ioport_read, + .mhandler.cmd = hmp_ioport_read, }, STEXI @@ -545,7 +545,7 @@ ETEXI .args_type = "fmt:/,addr:i,val:i", .params = "/fmt addr value", .help = "I/O port write", - .mhandler.cmd = do_ioport_write, + .mhandler.cmd = hmp_ioport_write, }, STEXI @@ -557,7 +557,7 @@ ETEXI .args_type = "keys:s,hold-time:i?", .params = "keys [hold_ms]", .help = "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)", - .mhandler.cmd = hmp_send_key, + .mhandler.cmd = hmp_sendkey, .command_completion = sendkey_completion, }, @@ -611,7 +611,7 @@ ETEXI .args_type = "start:i,size:i", .params = "addr size", .help = "compute the checksum of a memory region", - .mhandler.cmd = do_sum, + .mhandler.cmd = hmp_sum, }, STEXI @@ -626,7 +626,7 @@ ETEXI .args_type = "devname:s", .params = "device", .help = "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')", - .mhandler.cmd = do_usb_add, + .mhandler.cmd = hmp_usb_add, }, STEXI @@ -642,7 +642,7 @@ ETEXI .args_type = "devname:s", .params = "device", .help = "remove USB device 'bus.addr'", - .mhandler.cmd = do_usb_del, + .mhandler.cmd = hmp_usb_del, }, STEXI @@ -706,7 +706,7 @@ ETEXI .args_type = "dx_str:s,dy_str:s,dz_str:s?", .params = "dx dy [dz]", .help = "send mouse move events", - .mhandler.cmd = do_mouse_move, + .mhandler.cmd = hmp_mouse_move, }, STEXI @@ -721,7 +721,7 @@ ETEXI .args_type = "button_state:i", .params = "state", .help = "change mouse button state (1=L, 2=M, 4=R)", - .mhandler.cmd = do_mouse_button, + .mhandler.cmd = hmp_mouse_button, }, STEXI @@ -735,7 +735,7 @@ ETEXI .args_type = "index:i", .params = "index", .help = "set which mouse device receives events", - .mhandler.cmd = do_mouse_set, + .mhandler.cmd = hmp_mouse_set, }, STEXI @@ -753,7 +753,7 @@ ETEXI .args_type = "path:F,freq:i?,bits:i?,nchannels:i?", .params = "path [frequency [bits [channels]]]", .help = "capture audio to a wave file (default frequency=44100 bits=16 channels=2)", - .mhandler.cmd = do_wav_capture, + .mhandler.cmd = hmp_wavcapture, }, STEXI @item wavcapture @var{filename} [@var{frequency} [@var{bits} [@var{channels}]]] @@ -774,7 +774,7 @@ ETEXI .args_type = "n:i", .params = "capture index", .help = "stop capture", - .mhandler.cmd = do_stop_capture, + .mhandler.cmd = hmp_stopcapture, }, STEXI @item stopcapture @var{index} @@ -818,7 +818,7 @@ ETEXI .args_type = "bootdevice:s", .params = "bootdevice", .help = "define new values for the boot device list", - .mhandler.cmd = do_boot_set, + .mhandler.cmd = hmp_boot_set, }, STEXI @@ -837,7 +837,7 @@ ETEXI .args_type = "", .params = "", .help = "inject an NMI", - .mhandler.cmd = hmp_inject_nmi, + .mhandler.cmd = hmp_nmi, }, STEXI @item nmi @var{cpu} @@ -1140,7 +1140,7 @@ ETEXI "[,snapshot=on|off][,cache=on|off]\n" "[,readonly=on|off][,copy-on-read=on|off]", .help = "add drive to PCI storage controller", - .mhandler.cmd = drive_hot_add, + .mhandler.cmd = hmp_drive_add, }, STEXI @@ -1155,7 +1155,7 @@ ETEXI .args_type = "pci_addr:s,type:s,opts:s?", .params = "auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", .help = "hot-add PCI device", - .mhandler.cmd = pci_device_hot_add, + .mhandler.cmd = hmp_pci_add, }, #endif @@ -1171,7 +1171,7 @@ ETEXI .args_type = "pci_addr:s", .params = "[[<domain>:]<bus>:]<slot>", .help = "hot remove PCI device", - .mhandler.cmd = do_pci_device_hot_remove, + .mhandler.cmd = hmp_pci_del, }, #endif @@ -1197,7 +1197,7 @@ ETEXI "<tlb header> = 32bit x 4\n\t\t\t" "<tlb header prefix> = 32bit x 4", .user_print = pcie_aer_inject_error_print, - .mhandler.cmd_new = do_pcie_aer_inject_error, + .mhandler.cmd_new = hmp_pcie_aer_inject_error, }, STEXI @@ -1211,7 +1211,7 @@ ETEXI .args_type = "device:s,opts:s?", .params = "tap|user|socket|vde|netmap|bridge|vhost-user|dump [options]", .help = "add host VLAN client", - .mhandler.cmd = net_host_device_add, + .mhandler.cmd = hmp_host_net_add, .command_completion = host_net_add_completion, }, @@ -1226,7 +1226,7 @@ ETEXI .args_type = "vlan_id:i,device:s", .params = "vlan_id name", .help = "remove host VLAN client", - .mhandler.cmd = net_host_device_remove, + .mhandler.cmd = hmp_host_net_remove, .command_completion = host_net_remove_completion, }, @@ -1302,7 +1302,7 @@ ETEXI .args_type = "arg1:s,arg2:s?,arg3:s?", .params = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport", .help = "redirect TCP or UDP connections from host to guest (requires -net user)", - .mhandler.cmd = net_slirp_hostfwd_add, + .mhandler.cmd = hmp_hostfwd_add, }, #endif STEXI @@ -1317,7 +1317,7 @@ ETEXI .args_type = "arg1:s,arg2:s?,arg3:s?", .params = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport", .help = "remove host-to-guest TCP or UDP redirection", - .mhandler.cmd = net_slirp_hostfwd_remove, + .mhandler.cmd = hmp_hostfwd_remove, }, #endif @@ -1361,7 +1361,7 @@ ETEXI .args_type = "action:s", .params = "[reset|shutdown|poweroff|pause|debug|none]", .help = "change watchdog action", - .mhandler.cmd = do_watchdog_action, + .mhandler.cmd = hmp_watchdog_action, .command_completion = watchdog_action_completion, }, @@ -1376,7 +1376,7 @@ ETEXI .args_type = "aclname:s", .params = "aclname", .help = "list rules in the access control list", - .mhandler.cmd = do_acl_show, + .mhandler.cmd = hmp_acl_show, }, STEXI @@ -1393,7 +1393,7 @@ ETEXI .args_type = "aclname:s,policy:s", .params = "aclname allow|deny", .help = "set default access control list policy", - .mhandler.cmd = do_acl_policy, + .mhandler.cmd = hmp_acl_policy, }, STEXI @@ -1409,7 +1409,7 @@ ETEXI .args_type = "aclname:s,match:s,policy:s,index:i?", .params = "aclname match allow|deny [index]", .help = "add a match rule to the access control list", - .mhandler.cmd = do_acl_add, + .mhandler.cmd = hmp_acl_add, }, STEXI @@ -1428,7 +1428,7 @@ ETEXI .args_type = "aclname:s,match:s", .params = "aclname match", .help = "remove a match rule from the access control list", - .mhandler.cmd = do_acl_remove, + .mhandler.cmd = hmp_acl_remove, }, STEXI @@ -1442,7 +1442,7 @@ ETEXI .args_type = "aclname:s", .params = "aclname", .help = "reset the access control list", - .mhandler.cmd = do_acl_reset, + .mhandler.cmd = hmp_acl_reset, }, STEXI @@ -1504,7 +1504,7 @@ ETEXI .args_type = "broadcast:-b,cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l", .params = "[-b] cpu bank status mcgstatus addr misc", .help = "inject a MCE on the given CPU [and broadcast to other CPUs with -b option]", - .mhandler.cmd = do_inject_mce, + .mhandler.cmd = hmp_mce, }, #endif @@ -1694,7 +1694,7 @@ ETEXI .args_type = "item:s?", .params = "[subcommand]", .help = "show various information about the system state", - .mhandler.cmd = do_info_help, + .mhandler.cmd = hmp_info_help, .sub_table = info_cmds, }, @@ -412,7 +412,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) /* Print BlockBackend information */ if (!nodes) { - block_list = qmp_query_block(false); + block_list = qmp_query_block(NULL); } else { block_list = NULL; } @@ -924,7 +924,7 @@ void hmp_system_wakeup(Monitor *mon, const QDict *qdict) qmp_system_wakeup(NULL); } -void hmp_inject_nmi(Monitor *mon, const QDict *qdict) +void hmp_nmi(Monitor *mon, const QDict *qdict) { Error *err = NULL; @@ -1533,7 +1533,7 @@ void hmp_closefd(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } -void hmp_send_key(Monitor *mon, const QDict *qdict) +void hmp_sendkey(Monitor *mon, const QDict *qdict) { const char *keys = qdict_get_str(qdict, "keys"); KeyValueList *keylist, *head = NULL, *tmp = NULL; @@ -1602,7 +1602,7 @@ err_out: goto out; } -void hmp_screen_dump(Monitor *mon, const QDict *qdict) +void hmp_screendump(Monitor *mon, const QDict *qdict) { const char *filename = qdict_get_str(qdict, "filename"); Error *err = NULL; @@ -49,7 +49,7 @@ void hmp_ringbuf_write(Monitor *mon, const QDict *qdict); void hmp_ringbuf_read(Monitor *mon, const QDict *qdict); void hmp_cont(Monitor *mon, const QDict *qdict); void hmp_system_wakeup(Monitor *mon, const QDict *qdict); -void hmp_inject_nmi(Monitor *mon, const QDict *qdict); +void hmp_nmi(Monitor *mon, const QDict *qdict); void hmp_set_link(Monitor *mon, const QDict *qdict); void hmp_block_passwd(Monitor *mon, const QDict *qdict); void hmp_balloon(Monitor *mon, const QDict *qdict); @@ -82,8 +82,8 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict); void hmp_netdev_del(Monitor *mon, const QDict *qdict); void hmp_getfd(Monitor *mon, const QDict *qdict); void hmp_closefd(Monitor *mon, const QDict *qdict); -void hmp_send_key(Monitor *mon, const QDict *qdict); -void hmp_screen_dump(Monitor *mon, const QDict *qdict); +void hmp_sendkey(Monitor *mon, const QDict *qdict); +void hmp_screendump(Monitor *mon, const QDict *qdict); void hmp_nbd_server_start(Monitor *mon, const QDict *qdict); void hmp_nbd_server_add(Monitor *mon, const QDict *qdict); void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict); diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 84a55e4..e82d61d 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -83,11 +83,7 @@ static void clipper_init(MachineState *machine) pci_vga_init(pci_bus); /* Serial code setup. */ - for (i = 0; i < MAX_SERIAL_PORTS; ++i) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); /* Network setup. e1000 is good enough, failing Tulip support. */ for (i = 0; i < nb_nics; i++) { diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c index 97dafca..c55fab8 100644 --- a/hw/arm/exynos4210.c +++ b/hw/arm/exynos4210.c @@ -158,7 +158,7 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, if (object_property_find(cpuobj, "has_el3", NULL)) { object_property_set_bool(cpuobj, false, "has_el3", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } @@ -168,7 +168,7 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, "reset-cbar", &error_abort); object_property_set_bool(cpuobj, true, "realized", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index f67570a..a92cdc3 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -248,7 +248,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) if (object_property_find(cpuobj, "has_el3", NULL)) { object_property_set_bool(cpuobj, false, "has_el3", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } @@ -259,7 +259,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) } object_property_set_bool(cpuobj, true, "realized", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ); diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index 8c48b68..949ae1e 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -500,14 +500,14 @@ static void integratorcp_init(MachineState *machine) if (object_property_find(cpuobj, "has_el3", NULL)) { object_property_set_bool(cpuobj, false, "has_el3", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } object_property_set_bool(cpuobj, true, "realized", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 50cb93d..ef2788d 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -108,7 +108,7 @@ static void realview_init(MachineState *machine, if (object_property_find(cpuobj, "has_el3", NULL)) { object_property_set_bool(cpuobj, false, "has_el3", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } @@ -116,14 +116,14 @@ static void realview_init(MachineState *machine, if (is_pb && is_mpcore) { object_property_set_int(cpuobj, periphbase, "reset-cbar", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } object_property_set_bool(cpuobj, true, "realized", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index b1dae77..624fdb0 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -213,14 +213,14 @@ static void versatile_init(MachineState *machine, int board_id) if (object_property_find(cpuobj, "has_el3", NULL)) { object_property_set_bool(cpuobj, false, "has_el3", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } object_property_set_bool(cpuobj, true, "realized", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 84415c8..5933454 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -223,7 +223,7 @@ static void init_cpus(const char *cpu_model, const char *privdev, } object_property_set_bool(cpuobj, true, "realized", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index 06e6e24..5c37521 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -133,25 +133,25 @@ static void zynq_init(MachineState *machine) if (object_property_find(OBJECT(cpu), "has_el3", NULL)) { object_property_set_bool(OBJECT(cpu), false, "has_el3", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } } object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, "midr", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, "reset-cbar", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } object_property_set_bool(OBJECT(cpu), true, "realized", &err); if (err) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); exit(1); } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 1a8a176..cb71772 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -858,8 +858,7 @@ static void virtio_blk_migration_state_changed(Notifier *notifier, void *data) virtio_blk_data_plane_create(VIRTIO_DEVICE(s), &s->conf, &s->dataplane, &err); if (err != NULL) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); } } } diff --git a/hw/char/parallel.c b/hw/char/parallel.c index c2b553f..4079554 100644 --- a/hw/char/parallel.c +++ b/hw/char/parallel.c @@ -641,3 +641,28 @@ static void parallel_register_types(void) } type_init(parallel_register_types) + +static void parallel_init(ISABus *bus, int index, CharDriverState *chr) +{ + DeviceState *dev; + ISADevice *isadev; + + isadev = isa_create(bus, "isa-parallel"); + dev = DEVICE(isadev); + qdev_prop_set_uint32(dev, "index", index); + qdev_prop_set_chr(dev, "chardev", chr); + qdev_init_nofail(dev); +} + +void parallel_hds_isa_init(ISABus *bus, int n) +{ + int i; + + assert(n <= MAX_PARALLEL_PORTS); + + for (i = 0; i < n; i++) { + if (parallel_hds[i]) { + parallel_init(bus, i, parallel_hds[i]); + } + } +} diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index c9fcb27..f3db024 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -119,20 +119,27 @@ static void serial_register_types(void) type_init(serial_register_types) -bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr) +static void serial_isa_init(ISABus *bus, int index, CharDriverState *chr) { DeviceState *dev; ISADevice *isadev; - isadev = isa_try_create(bus, TYPE_ISA_SERIAL); - if (!isadev) { - return false; - } + isadev = isa_create(bus, TYPE_ISA_SERIAL); dev = DEVICE(isadev); qdev_prop_set_uint32(dev, "index", index); qdev_prop_set_chr(dev, "chardev", chr); - if (qdev_init(dev) < 0) { - return false; + qdev_init_nofail(dev); +} + +void serial_hds_isa_init(ISABus *bus, int n) +{ + int i; + + assert(n <= MAX_SERIAL_PORTS); + + for (i = 0; i < n; ++i) { + if (serial_hds[i]) { + serial_isa_init(bus, i, serial_hds[i]); + } } - return true; } diff --git a/hw/char/serial.c b/hw/char/serial.c index 0491897..55011cf 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -906,8 +906,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, s->chr = chr; serial_realize_core(s, &err); if (err != NULL) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); exit(1); } @@ -970,8 +969,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space, serial_realize_core(s, &err); if (err != NULL) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); exit(1); } vmstate_register(NULL, base, &vmstate_serial, s); diff --git a/hw/core/loader.c b/hw/core/loader.c index fcd4705..e45dc0b 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -1062,7 +1062,7 @@ void *rom_ptr(hwaddr addr) return rom->data + (addr - rom->addr); } -void do_info_roms(Monitor *mon, const QDict *qdict) +void hmp_info_roms(Monitor *mon, const QDict *qdict) { Rom *rom; diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 44c6b93..a02a4cb 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -373,10 +373,15 @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, way is somewhat unclean, and best avoided. */ void qdev_init_nofail(DeviceState *dev) { - const char *typename = object_get_typename(OBJECT(dev)); + Error *err = NULL; + + assert(!dev->realized); - if (qdev_init(dev) < 0) { - error_report("Initialization of device %s failed", typename); + object_property_set_bool(OBJECT(dev), true, "realized", &err); + if (err) { + error_report("Initialization of device %s failed: %s", + object_get_typename(OBJECT(dev)), + error_get_pretty(err)); exit(1); } } @@ -995,7 +1000,12 @@ void qdev_alias_all_properties(DeviceState *target, Object *source) static int qdev_add_hotpluggable_device(Object *obj, void *opaque) { GSList **list = opaque; - DeviceState *dev = DEVICE(obj); + DeviceState *dev = (DeviceState *)object_dynamic_cast(OBJECT(obj), + TYPE_DEVICE); + + if (dev == NULL) { + return 0; + } if (dev->realized && object_property_get_bool(obj, "hotpluggable", NULL)) { *list = g_slist_append(*list, dev); diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index bb206da..bd92c69 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -552,9 +552,8 @@ static void get_real_device(AssignedDevice *pci_dev, Error **errp) snprintf(name, sizeof(name), "%sconfig", dir); if (pci_dev->configfd_name && *pci_dev->configfd_name) { - dev->config_fd = monitor_handle_fd_param2(cur_mon, - pci_dev->configfd_name, - &local_err); + dev->config_fd = monitor_fd_param(cur_mon, pci_dev->configfd_name, + &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -953,8 +952,7 @@ static void assigned_dev_update_irq_routing(PCIDevice *dev) r = assign_intx(assigned_dev, &err); if (r < 0) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); err = NULL; qdev_unplug(&dev->qdev, &err); assert(!err); @@ -1010,8 +1008,7 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev) assign_intx(assigned_dev, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } } } @@ -1158,8 +1155,7 @@ static void assigned_dev_update_msix(PCIDevice *pci_dev) assign_intx(assigned_dev, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } } } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2519297..d2e07ca 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -43,6 +43,7 @@ #include "hw/pci/msi.h" #include "hw/sysbus.h" #include "sysemu/sysemu.h" +#include "sysemu/numa.h" #include "sysemu/kvm.h" #include "kvm_i386.h" #include "hw/xen/xen.h" @@ -416,7 +417,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, set_boot_dev(s, boot_device, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } @@ -1075,8 +1076,7 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge) cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i), icc_bridge, &error); if (error) { - error_report("%s", error_get_pretty(error)); - error_free(error); + error_report_err(error); exit(1); } } @@ -1454,17 +1454,8 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, pcspk_init(isa_bus, pit); } - for(i = 0; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } - - for(i = 0; i < MAX_PARALLEL_PORTS; i++) { - if (parallel_hds[i]) { - parallel_init(isa_bus, i, parallel_hds[i]); - } - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); + parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS); a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2); i8042 = isa_create_simple(isa_bus, "i8042"); diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c index 12d2137..f2e9ab6 100644 --- a/hw/i386/smbios.c +++ b/hw/i386/smbios.c @@ -908,7 +908,7 @@ void smbios_entry_add(QemuOpts *opts) qemu_opts_validate(opts, qemu_smbios_file_opts, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } @@ -994,7 +994,7 @@ void smbios_entry_add(QemuOpts *opts) case 0: qemu_opts_validate(opts, qemu_smbios_type0_opts, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } save_opt(&type0.vendor, opts, "vendor"); @@ -1014,7 +1014,7 @@ void smbios_entry_add(QemuOpts *opts) case 1: qemu_opts_validate(opts, qemu_smbios_type1_opts, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } save_opt(&type1.manufacturer, opts, "manufacturer"); @@ -1036,7 +1036,7 @@ void smbios_entry_add(QemuOpts *opts) case 2: qemu_opts_validate(opts, qemu_smbios_type2_opts, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } save_opt(&type2.manufacturer, opts, "manufacturer"); @@ -1049,7 +1049,7 @@ void smbios_entry_add(QemuOpts *opts) case 3: qemu_opts_validate(opts, qemu_smbios_type3_opts, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } save_opt(&type3.manufacturer, opts, "manufacturer"); @@ -1061,7 +1061,7 @@ void smbios_entry_add(QemuOpts *opts) case 4: qemu_opts_validate(opts, qemu_smbios_type4_opts, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } save_opt(&type4.sock_pfx, opts, "sock_pfx"); @@ -1074,7 +1074,7 @@ void smbios_entry_add(QemuOpts *opts) case 17: qemu_opts_validate(opts, qemu_smbios_type17_opts, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } save_opt(&type17.loc_pfx, opts, "loc_pfx"); diff --git a/hw/ide/isa.c b/hw/ide/isa.c index b084162..c0c4e1b 100644 --- a/hw/ide/isa.c +++ b/hw/ide/isa.c @@ -88,9 +88,7 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq, qdev_prop_set_uint32(dev, "iobase", iobase); qdev_prop_set_uint32(dev, "iobase2", iobase2); qdev_prop_set_uint32(dev, "irq", isairq); - if (qdev_init(dev) < 0) { - return NULL; - } + qdev_init_nofail(dev); s = ISA_IDE(dev); if (hd0) { diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 1ebb58d..b4103fa 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -172,8 +172,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) if (kind != IDE_CD) { blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err); if (err) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); return -1; } } diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index c51901b..0f5c025 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -429,7 +429,7 @@ static void pic_realize(DeviceState *dev, Error **errp) pc->parent_realize(dev, errp); } -void pic_info(Monitor *mon, const QDict *qdict) +void hmp_info_pic(Monitor *mon, const QDict *qdict) { int i; PICCommonState *s; @@ -447,7 +447,7 @@ void pic_info(Monitor *mon, const QDict *qdict) } } -void irq_info(Monitor *mon, const QDict *qdict) +void hmp_info_irq(Monitor *mon, const QDict *qdict) { #ifndef DEBUG_IRQ_COUNT monitor_printf(mon, "irq statistic code not compiled.\n"); diff --git a/hw/intc/lm32_pic.c b/hw/intc/lm32_pic.c index 72fc9ef..641ee47 100644 --- a/hw/intc/lm32_pic.c +++ b/hw/intc/lm32_pic.c @@ -43,7 +43,7 @@ struct LM32PicState { typedef struct LM32PicState LM32PicState; static LM32PicState *pic; -void lm32_do_pic_info(Monitor *mon, const QDict *qdict) +void lm32_hmp_info_pic(Monitor *mon, const QDict *qdict) { if (pic == NULL) { return; @@ -53,7 +53,7 @@ void lm32_do_pic_info(Monitor *mon, const QDict *qdict) pic->im, pic->ip, pic->irq_state); } -void lm32_irq_info(Monitor *mon, const QDict *qdict) +void lm32_hmp_info_irq(Monitor *mon, const QDict *qdict) { int i; uint32_t count; diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 18cdc54..f27a087 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -22,6 +22,7 @@ #include "qemu/config-file.h" #include "qapi/visitor.h" #include "qemu/range.h" +#include "sysemu/numa.h" typedef struct pc_dimms_capacity { uint64_t size; diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 6a9ebfa..ea73585 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -277,7 +277,6 @@ static void mips_fulong2e_init(MachineState *machine) PCIBus *pci_bus; ISABus *isa_bus; I2CBus *smbus; - int i; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; MIPSCPU *cpu; CPUMIPSState *env; @@ -384,15 +383,8 @@ static void mips_fulong2e_init(MachineState *machine) rtc_init(isa_bus, 2000, NULL); - for(i = 0; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } - - if (parallel_hds[0]) { - parallel_init(isa_bus, 0, parallel_hds[0]); - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); + parallel_hds_isa_init(isa_bus, 1); /* Sound card */ audio_init(pci_bus); diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 5845158..533b2e6 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -1172,10 +1172,9 @@ void mips_malta_init(MachineState *machine) isa_create_simple(isa_bus, "i8042"); rtc_init(isa_bus, 2000, NULL); - serial_isa_init(isa_bus, 0, serial_hds[0]); - serial_isa_init(isa_bus, 1, serial_hds[1]); - if (parallel_hds[0]) - parallel_init(isa_bus, 0, parallel_hds[0]); + serial_hds_isa_init(isa_bus, 2); + parallel_hds_isa_init(isa_bus, 1); + for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c index 3e90e27..52564be 100644 --- a/hw/mips/mips_r4k.c +++ b/hw/mips/mips_r4k.c @@ -284,11 +284,7 @@ void mips_r4k_init(MachineState *machine) pit = pit_init(isa_bus, 0x40, 0, NULL); - for(i = 0; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); isa_vga_init(isa_bus); diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c index 2fbbc6c..c57365f 100644 --- a/hw/net/fsl_etsec/etsec.c +++ b/hw/net/fsl_etsec/etsec.c @@ -443,10 +443,7 @@ DeviceState *etsec_create(hwaddr base, dev = qdev_create(NULL, "eTSEC"); qdev_set_nic_properties(dev, nd); - - if (qdev_init(dev)) { - return NULL; - } + qdev_init_nofail(dev); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, tx_irq); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 1, rx_irq); diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c index 0c09c72..beea6d2 100644 --- a/hw/pci/pci-hotplug-old.c +++ b/hw/pci/pci-hotplug-old.c @@ -132,8 +132,7 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter, dinfo->unit, false, -1, NULL, &local_err); if (!scsidev) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); return -1; } dinfo->unit = scsidev->id; @@ -267,7 +266,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, return dev; } -void pci_device_hot_add(Monitor *mon, const QDict *qdict) +void hmp_pci_add(Monitor *mon, const QDict *qdict) { PCIDevice *dev = NULL; const char *pci_addr = qdict_get_str(qdict, "pci_addr"); @@ -337,7 +336,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr) return 0; } -void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict) +void hmp_pci_del(Monitor *mon, const QDict *qdict) { pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr")); } diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c index 1dda89b..5e564c3 100644 --- a/hw/pci/pci-stub.c +++ b/hw/pci/pci-stub.c @@ -34,7 +34,7 @@ static void pci_error_message(Monitor *mon) monitor_printf(mon, "PCI devices not supported\n"); } -int do_pcie_aer_inject_error(Monitor *mon, +int hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict, QObject **ret_data) { pci_error_message(mon); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index d508930..31b222d 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2038,8 +2038,7 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, ret = pci_add_capability2(pdev, cap_id, offset, size, &local_err); if (local_err) { assert(ret < 0); - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } else { /* success implies a positive offset in config space */ assert(ret > 0); diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index 1f4be16..5a25c32 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -962,7 +962,7 @@ static int pcie_aer_parse_error_string(const char *error_name, return -EINVAL; } -int do_pcie_aer_inject_error(Monitor *mon, +int hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *id = qdict_get_str(qdict, "id"); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a82a0f9..23cde20 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -25,6 +25,7 @@ * */ #include "sysemu/sysemu.h" +#include "sysemu/numa.h" #include "hw/hw.h" #include "hw/fw-path-provider.h" #include "elf.h" diff --git a/hw/s390x/css.c b/hw/s390x/css.c index d0c5dde..9a13b00 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -584,7 +584,7 @@ static void copy_schib_from_guest(SCHIB *dest, const SCHIB *src) } } -int css_do_msch(SubchDev *sch, SCHIB *orig_schib) +int css_do_msch(SubchDev *sch, const SCHIB *orig_schib) { SCSW *s = &sch->curr_status.scsw; PMCW *p = &sch->curr_status.pmcw; @@ -801,7 +801,8 @@ out: return ret; } -static void copy_irb_to_guest(IRB *dest, const IRB *src, PMCW *pmcw) +static void copy_irb_to_guest(IRB *dest, const IRB *src, PMCW *pmcw, + int *irb_len) { int i; uint16_t stctl = src->scsw.ctrl & SCSW_CTRL_MASK_STCTL; @@ -815,6 +816,8 @@ static void copy_irb_to_guest(IRB *dest, const IRB *src, PMCW *pmcw) for (i = 0; i < ARRAY_SIZE(dest->ecw); i++) { dest->ecw[i] = cpu_to_be32(src->ecw[i]); } + *irb_len = sizeof(*dest) - sizeof(dest->emw); + /* extended measurements enabled? */ if ((src->scsw.flags & SCSW_FLAGS_MASK_ESWF) || !(pmcw->flags & PMCW_FLAGS_MASK_TF) || @@ -832,26 +835,21 @@ static void copy_irb_to_guest(IRB *dest, const IRB *src, PMCW *pmcw) dest->emw[i] = cpu_to_be32(src->emw[i]); } } + *irb_len = sizeof(*dest); } -int css_do_tsch(SubchDev *sch, IRB *target_irb) +int css_do_tsch_get_irb(SubchDev *sch, IRB *target_irb, int *irb_len) { SCSW *s = &sch->curr_status.scsw; PMCW *p = &sch->curr_status.pmcw; uint16_t stctl; - uint16_t fctl; - uint16_t actl; IRB irb; - int ret; if (!(p->flags & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA))) { - ret = 3; - goto out; + return 3; } stctl = s->ctrl & SCSW_CTRL_MASK_STCTL; - fctl = s->ctrl & SCSW_CTRL_MASK_FCTL; - actl = s->ctrl & SCSW_CTRL_MASK_ACTL; /* Prepare the irb for the guest. */ memset(&irb, 0, sizeof(IRB)); @@ -876,7 +874,22 @@ int css_do_tsch(SubchDev *sch, IRB *target_irb) } } /* Store the irb to the guest. */ - copy_irb_to_guest(target_irb, &irb, p); + copy_irb_to_guest(target_irb, &irb, p, irb_len); + + return ((stctl & SCSW_STCTL_STATUS_PEND) == 0); +} + +void css_do_tsch_update_subch(SubchDev *sch) +{ + SCSW *s = &sch->curr_status.scsw; + PMCW *p = &sch->curr_status.pmcw; + uint16_t stctl; + uint16_t fctl; + uint16_t actl; + + stctl = s->ctrl & SCSW_CTRL_MASK_STCTL; + fctl = s->ctrl & SCSW_CTRL_MASK_FCTL; + actl = s->ctrl & SCSW_CTRL_MASK_ACTL; /* Clear conditions on subchannel, if applicable. */ if (stctl & SCSW_STCTL_STATUS_PEND) { @@ -913,11 +926,6 @@ int css_do_tsch(SubchDev *sch, IRB *target_irb) memset(sch->sense_data, 0 , sizeof(sch->sense_data)); } } - - ret = ((stctl & SCSW_STCTL_STATUS_PEND) == 0); - -out: - return ret; } static void copy_crw_to_guest(CRW *dest, const CRW *src) @@ -947,6 +955,26 @@ int css_do_stcrw(CRW *crw) return ret; } +static void copy_crw_from_guest(CRW *dest, const CRW *src) +{ + dest->flags = be16_to_cpu(src->flags); + dest->rsid = be16_to_cpu(src->rsid); +} + +void css_undo_stcrw(CRW *crw) +{ + CrwContainer *crw_cont; + + crw_cont = g_try_malloc0(sizeof(CrwContainer)); + if (!crw_cont) { + channel_subsys->crws_lost = true; + return; + } + copy_crw_from_guest(&crw_cont->crw, crw); + + QTAILQ_INSERT_HEAD(&channel_subsys->pending_crws, crw_cont, sibling); +} + int css_do_tpi(IOIntCode *int_code, int lowcore) { /* No pending interrupts for !KVM. */ diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 4ba8409..b57adbd 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -18,6 +18,7 @@ #include "hw/sysbus.h" #include "hw/s390x/virtio-ccw.h" #include "hw/s390x/css.h" +#include "ipl.h" #define KERN_IMAGE_START 0x010000UL #define KERN_PARM_AREA 0x010480UL @@ -50,14 +51,49 @@ typedef struct S390IPLState { /*< private >*/ SysBusDevice parent_obj; uint64_t start_addr; + uint64_t bios_start_addr; + bool enforce_bios; + IplParameterBlock iplb; + bool iplb_valid; + bool reipl_requested; /*< public >*/ char *kernel; char *initrd; char *cmdline; char *firmware; + uint8_t cssid; + uint8_t ssid; + uint16_t devno; } S390IPLState; +static const VMStateDescription vmstate_iplb = { + .name = "ipl/iplb", + .version_id = 0, + .minimum_version_id = 0, + .fields = (VMStateField[]) { + VMSTATE_UINT8_ARRAY(reserved1, IplParameterBlock, 110), + VMSTATE_UINT16(devno, IplParameterBlock), + VMSTATE_UINT8_ARRAY(reserved2, IplParameterBlock, 88), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_ipl = { + .name = "ipl", + .version_id = 0, + .minimum_version_id = 0, + .fields = (VMStateField[]) { + VMSTATE_UINT64(start_addr, S390IPLState), + VMSTATE_UINT64(bios_start_addr, S390IPLState), + VMSTATE_STRUCT(iplb, S390IPLState, 0, vmstate_iplb, IplParameterBlock), + VMSTATE_BOOL(iplb_valid, S390IPLState), + VMSTATE_UINT8(cssid, S390IPLState), + VMSTATE_UINT8(ssid, S390IPLState), + VMSTATE_UINT16(devno, S390IPLState), + VMSTATE_END_OF_LIST() + } +}; static int s390_ipl_init(SysBusDevice *dev) { @@ -65,11 +101,14 @@ static int s390_ipl_init(SysBusDevice *dev) uint64_t pentry = KERN_IMAGE_START; int kernel_size; - if (!ipl->kernel) { - int bios_size; - char *bios_filename; + int bios_size; + char *bios_filename; - /* Load zipl bootloader */ + /* + * Always load the bios if it was enforced, + * even if an external kernel has been defined. + */ + if (!ipl->kernel || ipl->enforce_bios) { if (bios_name == NULL) { bios_name = ipl->firmware; } @@ -79,12 +118,12 @@ static int s390_ipl_init(SysBusDevice *dev) hw_error("could not find stage1 bootloader\n"); } - bios_size = load_elf(bios_filename, NULL, NULL, &ipl->start_addr, NULL, - NULL, 1, ELF_MACHINE, 0); + bios_size = load_elf(bios_filename, NULL, NULL, &ipl->bios_start_addr, + NULL, NULL, 1, ELF_MACHINE, 0); if (bios_size < 0) { bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START, 4096); - ipl->start_addr = ZIPL_IMAGE_START; + ipl->bios_start_addr = ZIPL_IMAGE_START; if (bios_size > 4096) { hw_error("stage1 bootloader is > 4k\n"); } @@ -94,52 +133,59 @@ static int s390_ipl_init(SysBusDevice *dev) if (bios_size == -1) { hw_error("could not load bootloader '%s'\n", bios_name); } - return 0; - } - kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL, - NULL, 1, ELF_MACHINE, 0); - if (kernel_size < 0) { - kernel_size = load_image_targphys(ipl->kernel, 0, ram_size); - } - if (kernel_size < 0) { - fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel); - return -1; + /* default boot target is the bios */ + ipl->start_addr = ipl->bios_start_addr; } - /* - * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the - * kernel parameters here as well. Note: For old kernels (up to 3.2) - * we can not rely on the ELF entry point - it was 0x800 (the SALIPL - * loader) and it won't work. For this case we force it to 0x10000, too. - */ - if (pentry == KERN_IMAGE_START || pentry == 0x800) { - ipl->start_addr = KERN_IMAGE_START; - /* Overwrite parameters in the kernel image, which are "rom" */ - strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline); - } else { - ipl->start_addr = pentry; - } - - if (ipl->initrd) { - ram_addr_t initrd_offset; - int initrd_size; - initrd_offset = INITRD_START; - while (kernel_size + 0x100000 > initrd_offset) { - initrd_offset += 0x100000; + if (ipl->kernel) { + kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL, + NULL, 1, ELF_MACHINE, 0); + if (kernel_size < 0) { + kernel_size = load_image_targphys(ipl->kernel, 0, ram_size); + } + if (kernel_size < 0) { + fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel); + return -1; } - initrd_size = load_image_targphys(ipl->initrd, initrd_offset, - ram_size - initrd_offset); - if (initrd_size == -1) { - fprintf(stderr, "qemu: could not load initrd '%s'\n", ipl->initrd); - exit(1); + /* + * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the + * kernel parameters here as well. Note: For old kernels (up to 3.2) + * we can not rely on the ELF entry point - it was 0x800 (the SALIPL + * loader) and it won't work. For this case we force it to 0x10000, too. + */ + if (pentry == KERN_IMAGE_START || pentry == 0x800) { + ipl->start_addr = KERN_IMAGE_START; + /* Overwrite parameters in the kernel image, which are "rom" */ + strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline); + } else { + ipl->start_addr = pentry; } - /* we have to overwrite values in the kernel image, which are "rom" */ - stq_p(rom_ptr(INITRD_PARM_START), initrd_offset); - stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size); - } + if (ipl->initrd) { + ram_addr_t initrd_offset; + int initrd_size; + + initrd_offset = INITRD_START; + while (kernel_size + 0x100000 > initrd_offset) { + initrd_offset += 0x100000; + } + initrd_size = load_image_targphys(ipl->initrd, initrd_offset, + ram_size - initrd_offset); + if (initrd_size == -1) { + fprintf(stderr, "qemu: could not load initrd '%s'\n", + ipl->initrd); + exit(1); + } + /* + * we have to overwrite values in the kernel image, + * which are "rom" + */ + stq_p(rom_ptr(INITRD_PARM_START), initrd_offset); + stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size); + } + } return 0; } @@ -148,9 +194,82 @@ static Property s390_ipl_properties[] = { DEFINE_PROP_STRING("initrd", S390IPLState, initrd), DEFINE_PROP_STRING("cmdline", S390IPLState, cmdline), DEFINE_PROP_STRING("firmware", S390IPLState, firmware), + DEFINE_PROP_BOOL("enforce_bios", S390IPLState, enforce_bios, false), DEFINE_PROP_END_OF_LIST(), }; +/* + * In addition to updating the iplstate, this function returns: + * - 0 if system was ipled with external kernel + * - -1 if no valid boot device was found + * - ccw id of the boot device otherwise + */ +static uint64_t s390_update_iplstate(CPUS390XState *env, S390IPLState *ipl) +{ + DeviceState *dev_st; + + if (ipl->iplb_valid) { + ipl->cssid = 0; + ipl->ssid = 0; + ipl->devno = ipl->iplb.devno; + goto out; + } + + if (ipl->kernel) { + return 0; + } + + dev_st = get_boot_device(0); + if (dev_st) { + VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *) object_dynamic_cast( + OBJECT(qdev_get_parent_bus(dev_st)->parent), + TYPE_VIRTIO_CCW_DEVICE); + if (ccw_dev) { + ipl->cssid = ccw_dev->sch->cssid; + ipl->ssid = ccw_dev->sch->ssid; + ipl->devno = ccw_dev->sch->devno; + goto out; + } + } + + return -1; +out: + return ipl->cssid << 24 | ipl->ssid << 16 | ipl->devno; +} + +int s390_ipl_update_diag308(IplParameterBlock *iplb) +{ + S390IPLState *ipl; + + ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL)); + if (ipl) { + ipl->iplb = *iplb; + ipl->iplb_valid = true; + return 0; + } + return -1; +} + +IplParameterBlock *s390_ipl_get_iplb(void) +{ + S390IPLState *ipl; + + ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL)); + if (!ipl || !ipl->iplb_valid) { + return NULL; + } + return &ipl->iplb; +} + +void s390_reipl_request(void) +{ + S390IPLState *ipl; + + ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL)); + ipl->reipl_requested = true; + qemu_system_reset_request(); +} + static void s390_ipl_reset(DeviceState *dev) { S390IPLState *ipl = S390_IPL(dev); @@ -160,21 +279,14 @@ static void s390_ipl_reset(DeviceState *dev) env->psw.addr = ipl->start_addr; env->psw.mask = IPL_PSW_MASK; - if (!ipl->kernel) { - /* Tell firmware, if there is a preferred boot device */ - env->regs[7] = -1; - DeviceState *dev_st = get_boot_device(0); - if (dev_st) { - VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *) object_dynamic_cast( - OBJECT(qdev_get_parent_bus(dev_st)->parent), - TYPE_VIRTIO_CCW_DEVICE); + if (!ipl->reipl_requested) { + ipl->iplb_valid = false; + } + ipl->reipl_requested = false; - if (ccw_dev) { - env->regs[7] = ccw_dev->sch->cssid << 24 | - ccw_dev->sch->ssid << 16 | - ccw_dev->sch->devno; - } - } + if (!ipl->kernel || ipl->iplb_valid) { + env->psw.addr = ipl->bios_start_addr; + env->regs[7] = s390_update_iplstate(env, ipl); } s390_cpu_set_state(CPU_STATE_OPERATING, cpu); @@ -188,6 +300,7 @@ static void s390_ipl_class_init(ObjectClass *klass, void *data) k->init = s390_ipl_init; dc->props = s390_ipl_properties; dc->reset = s390_ipl_reset; + dc->vmsd = &vmstate_ipl; } static const TypeInfo s390_ipl_info = { diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h new file mode 100644 index 0000000..70497bc --- /dev/null +++ b/hw/s390x/ipl.h @@ -0,0 +1,25 @@ +/* + * s390 IPL device + * + * Copyright 2015 IBM Corp. + * Author(s): Zhang Fan <bjfanzh@cn.ibm.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#ifndef HW_S390_IPL_H +#define HW_S390_IPL_H + +typedef struct IplParameterBlock { + uint8_t reserved1[110]; + uint16_t devno; + uint8_t reserved2[88]; +} IplParameterBlock; + +int s390_ipl_update_diag308(IplParameterBlock *iplb); +IplParameterBlock *s390_ipl_get_iplb(void); +void s390_reipl_request(void); + +#endif diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 9e5bc5b..08d8aa6 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -155,7 +155,9 @@ int clp_service_call(S390CPU *cpu, uint8_t r2) return 0; } - cpu_physical_memory_read(env->regs[r2], buffer, sizeof(*reqh)); + if (s390_cpu_virt_mem_read(cpu, env->regs[r2], buffer, sizeof(*reqh))) { + return 0; + } reqh = (ClpReqHdr *)buffer; req_len = lduw_p(&reqh->len); if (req_len < 16 || req_len > 8184 || (req_len % 8 != 0)) { @@ -163,7 +165,10 @@ int clp_service_call(S390CPU *cpu, uint8_t r2) return 0; } - cpu_physical_memory_read(env->regs[r2], buffer, req_len + sizeof(*resh)); + if (s390_cpu_virt_mem_read(cpu, env->regs[r2], buffer, + req_len + sizeof(*resh))) { + return 0; + } resh = (ClpRspHdr *)(buffer + req_len); res_len = lduw_p(&resh->len); if (res_len < 8 || res_len > 8176 || (res_len % 8 != 0)) { @@ -175,7 +180,10 @@ int clp_service_call(S390CPU *cpu, uint8_t r2) return 0; } - cpu_physical_memory_read(env->regs[r2], buffer, req_len + res_len); + if (s390_cpu_virt_mem_read(cpu, env->regs[r2], buffer, + req_len + res_len)) { + return 0; + } if (req_len != 32) { stw_p(&resh->rsp, CLP_RC_LEN); @@ -269,7 +277,10 @@ int clp_service_call(S390CPU *cpu, uint8_t r2) } out: - cpu_physical_memory_write(env->regs[r2], buffer, req_len + res_len); + if (s390_cpu_virt_mem_write(cpu, env->regs[r2], buffer, + req_len + res_len)) { + return 0; + } setcc(cpu, cc); return 0; } @@ -539,10 +550,10 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr) S390PCIBusDevice *pbdev; MemoryRegion *mr; int i; - uint64_t val; uint32_t fh; uint8_t pcias; uint8_t len; + uint8_t buffer[128]; if (env->psw.mask & PSW_MASK_PSTATE) { program_interrupt(env, PGM_PRIVILEGED, 6); @@ -590,9 +601,12 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr) return 0; } + if (s390_cpu_virt_mem_read(cpu, gaddr, buffer, len)) { + return 0; + } + for (i = 0; i < len / 8; i++) { - val = ldq_phys(&address_space_memory, gaddr + i * 8); - io_mem_write(mr, env->regs[r3] + i * 8, val, 8); + io_mem_write(mr, env->regs[r3] + i * 8, ldq_p(buffer + i * 8), 8); } setcc(cpu, ZPCI_PCI_LS_OK); @@ -709,7 +723,9 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba) return 0; } - cpu_physical_memory_read(fiba, (uint8_t *)&fib, sizeof(fib)); + if (s390_cpu_virt_mem_read(cpu, fiba, (uint8_t *)&fib, sizeof(fib))) { + return 0; + } switch (oc) { case ZPCI_MOD_FC_REG_INT: @@ -809,7 +825,10 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba) fib.fc |= 0x10; } - cpu_physical_memory_write(fiba, (uint8_t *)&fib, sizeof(fib)); + if (s390_cpu_virt_mem_write(cpu, fiba, (uint8_t *)&fib, sizeof(fib))) { + return 0; + } + setcc(cpu, cc); return 0; } diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 71bafe0..8f0ae59 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -126,7 +126,7 @@ static void ccw_init(MachineState *machine) css_bus = virtual_css_bus_init(); s390_sclp_init(); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline, - machine->initrd_filename, "s390-ccw.img"); + machine->initrd_filename, "s390-ccw.img", true); s390_flic_init(); dev = qdev_create(NULL, TYPE_S390_PCI_HOST_BRIDGE); diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index c215cd8..412e49b 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -128,7 +128,8 @@ static void s390_virtio_register_hcalls(void) void s390_init_ipl_dev(const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, - const char *firmware) + const char *firmware, + bool enforce_bios) { DeviceState *dev; @@ -141,6 +142,9 @@ void s390_init_ipl_dev(const char *kernel_filename, } qdev_prop_set_string(dev, "cmdline", kernel_cmdline); qdev_prop_set_string(dev, "firmware", firmware); + qdev_prop_set_bit(dev, "enforce_bios", enforce_bios); + object_property_add_child(qdev_get_machine(), "s390-ipl", + OBJECT(dev), NULL); qdev_init_nofail(dev); } @@ -221,7 +225,7 @@ static void s390_init(MachineState *machine) s390_bus = s390_virtio_bus_init(&my_ram_size); s390_sclp_init(); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline, - machine->initrd_filename, ZIPL_FILENAME); + machine->initrd_filename, ZIPL_FILENAME, false); s390_flic_init(); /* register hypercalls */ diff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h index 33847ae..75b67ed 100644 --- a/hw/s390x/s390-virtio.h +++ b/hw/s390x/s390-virtio.h @@ -26,7 +26,8 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys); void s390_init_ipl_dev(const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, - const char *firmware); + const char *firmware, + bool enforce_bios); void s390_create_virtio_net(BusState *bus, const char *name); void s390_nmi(NMIState *n, int cpu_index, Error **errp); #endif diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index e30ff84..618b0af 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -215,9 +215,11 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) } if (vs->conf.vhostfd) { - vhostfd = monitor_handle_fd_param(cur_mon, vs->conf.vhostfd); + vhostfd = monitor_fd_param(cur_mon, vs->conf.vhostfd, &err); if (vhostfd == -1) { - error_setg(errp, "vhost-scsi: unable to parse vhostfd"); + error_setg(errp, "vhost-scsi: unable to parse vhostfd: %s", + error_get_pretty(err)); + error_free(err); return; } } else { diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index ecd9dc1..09afccf 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -176,13 +176,13 @@ static void nvram_init(M48t59State *nvram, uint8_t *macaddr, static DeviceState *slavio_intctl; -void sun4m_pic_info(Monitor *mon, const QDict *qdict) +void sun4m_hmp_info_pic(Monitor *mon, const QDict *qdict) { if (slavio_intctl) slavio_pic_info(mon, slavio_intctl); } -void sun4m_irq_info(Monitor *mon, const QDict *qdict) +void sun4m_hmp_info_irq(Monitor *mon, const QDict *qdict) { if (slavio_intctl) slavio_irq_info(mon, slavio_intctl); diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 4620cc6..b310588 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -850,17 +850,9 @@ static void sun4uv_init(MemoryRegion *address_space_mem, NULL, 115200, serial_hds[i], DEVICE_BIG_ENDIAN); i++; } - for(; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } - for(i = 0; i < MAX_PARALLEL_PORTS; i++) { - if (parallel_hds[i]) { - parallel_init(isa_bus, i, parallel_hds[i]); - } - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); + parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS); for(i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); diff --git a/hw/usb/bus.c b/hw/usb/bus.c index d83a938..91fc3e2 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -637,7 +637,7 @@ static char *usb_get_fw_dev_path(DeviceState *qdev) return fw_path; } -void usb_info(Monitor *mon, const QDict *qdict) +void hmp_info_usb(Monitor *mon, const QDict *qdict) { USBBus *bus; USBDevice *dev; diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 7131abd..b27b1f4 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1399,8 +1399,7 @@ static USBDevice *usb_net_init(USBBus *bus, const char *cmdline) idx = net_client_init(opts, 0, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); return NULL; } diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index cff4f7c..10f4735 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -878,8 +878,7 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev) usb_device_attach(udev, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); goto fail; } @@ -1637,7 +1636,7 @@ static void usb_host_auto_check(void *unused) timer_mod(usb_auto_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 2000); } -void usb_host_info(Monitor *mon, const QDict *qdict) +void hmp_info_usbhost(Monitor *mon, const QDict *qdict) { libusb_device **devs = NULL; struct libusb_device_descriptor ddesc; diff --git a/hw/usb/host-stub.c b/hw/usb/host-stub.c index 28d8032..2eaaa83 100644 --- a/hw/usb/host-stub.c +++ b/hw/usb/host-stub.c @@ -35,7 +35,7 @@ #include "hw/usb.h" #include "monitor/monitor.h" -void usb_host_info(Monitor *mon, const QDict *qdict) +void hmp_info_usbhost(Monitor *mon, const QDict *qdict) { monitor_printf(mon, "USB host devices not supported\n"); } diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 962d3f5..2416de8 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1273,8 +1273,7 @@ static void usbredir_do_attach(void *opaque) usb_device_attach(&dev->dev, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); WARNING("rejecting device due to speed mismatch\n"); usbredir_reject_device(dev); } diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index f431764..15beb6b 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -92,6 +92,6 @@ SerialState *serial_mm_init(MemoryRegion *address_space, /* serial-isa.c */ #define TYPE_ISA_SERIAL "isa-serial" -bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr); +void serial_hds_isa_init(ISABus *bus, int n); #endif diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 69d9cf8..08ab67d 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -107,23 +107,8 @@ struct PcGuestInfo { }; /* parallel.c */ -static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr) -{ - DeviceState *dev; - ISADevice *isadev; - isadev = isa_try_create(bus, "isa-parallel"); - if (!isadev) { - return false; - } - dev = DEVICE(isadev); - qdev_prop_set_uint32(dev, "index", index); - qdev_prop_set_chr(dev, "chardev", chr); - if (qdev_init(dev) < 0) { - return false; - } - return true; -} +void parallel_hds_isa_init(ISABus *bus, int n); bool parallel_mm_init(MemoryRegion *address_space, hwaddr base, int it_shift, qemu_irq irq, @@ -136,8 +121,8 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq); qemu_irq *kvm_i8259_init(ISABus *bus); int pic_read_irq(DeviceState *d); int pic_get_output(DeviceState *d); -void pic_info(Monitor *mon, const QDict *qdict); -void irq_info(Monitor *mon, const QDict *qdict); +void hmp_info_pic(Monitor *mon, const QDict *qdict); +void hmp_info_irq(Monitor *mon, const QDict *qdict); /* Global System Interrupts */ diff --git a/include/hw/lm32/lm32_pic.h b/include/hw/lm32/lm32_pic.h index 5556803..189fa38 100644 --- a/include/hw/lm32/lm32_pic.h +++ b/include/hw/lm32/lm32_pic.h @@ -8,7 +8,7 @@ uint32_t lm32_pic_get_im(DeviceState *d); void lm32_pic_set_ip(DeviceState *d, uint32_t ip); void lm32_pic_set_im(DeviceState *d, uint32_t im); -void lm32_do_pic_info(Monitor *mon, const QDict *qdict); -void lm32_irq_info(Monitor *mon, const QDict *qdict); +void lm32_hmp_info_pic(Monitor *mon, const QDict *qdict); +void lm32_hmp_info_irq(Monitor *mon, const QDict *qdict); #endif /* QEMU_HW_LM32_PIC_H */ diff --git a/include/hw/loader.h b/include/hw/loader.h index 8593045..4f0681b 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -78,7 +78,7 @@ void rom_load_done(void); void rom_set_fw(FWCfgState *f); int rom_copy(uint8_t *dest, hwaddr addr, size_t size); void *rom_ptr(hwaddr addr); -void do_info_roms(Monitor *mon, const QDict *qdict); +void hmp_info_roms(Monitor *mon, const QDict *qdict); #define rom_add_file_fixed(_f, _a, _i) \ rom_add_file(_f, NULL, _a, _i, false) diff --git a/include/hw/sparc/grlib.h b/include/hw/sparc/grlib.h index 470ce72..9a0db7b 100644 --- a/include/hw/sparc/grlib.h +++ b/include/hw/sparc/grlib.h @@ -55,9 +55,7 @@ DeviceState *grlib_irqmp_create(hwaddr base, qdev_prop_set_ptr(dev, "set_pil_in", set_pil_in); qdev_prop_set_ptr(dev, "set_pil_in_opaque", env); - if (qdev_init(dev)) { - return NULL; - } + qdev_init_nofail(dev); env->irq_manager = dev; @@ -87,9 +85,7 @@ DeviceState *grlib_gptimer_create(hwaddr base, qdev_prop_set_uint32(dev, "frequency", freq); qdev_prop_set_uint32(dev, "irq-line", base_irq); - if (qdev_init(dev)) { - return NULL; - } + qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); @@ -112,9 +108,7 @@ DeviceState *grlib_apbuart_create(hwaddr base, dev = qdev_create(NULL, "grlib,apbuart"); qdev_prop_set_chr(dev, "chrdev", serial); - if (qdev_init(dev)) { - return NULL; - } + qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); diff --git a/include/hw/sparc/sun4m.h b/include/hw/sparc/sun4m.h index a587700..9c17425 100644 --- a/include/hw/sparc/sun4m.h +++ b/include/hw/sparc/sun4m.h @@ -29,8 +29,8 @@ void slavio_pic_info(Monitor *mon, DeviceState *dev); void slavio_irq_info(Monitor *mon, DeviceState *dev); /* sun4m.c */ -void sun4m_pic_info(Monitor *mon, const QDict *qdict); -void sun4m_irq_info(Monitor *mon, const QDict *qdict); +void sun4m_hmp_info_pic(Monitor *mon, const QDict *qdict); +void sun4m_hmp_info_irq(Monitor *mon, const QDict *qdict); /* sparc32_dma.c */ #include "hw/sparc/sparc32_dma.h" diff --git a/include/hw/usb.h b/include/hw/usb.h index b20b959..e6dfb87 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -473,7 +473,7 @@ int set_usb_string(uint8_t *buf, const char *str); /* usb-linux.c */ USBDevice *usb_host_device_open(USBBus *bus, const char *devname); -void usb_host_info(Monitor *mon, const QDict *qdict); +void hmp_info_usbhost(Monitor *mon, const QDict *qdict); /* usb ports of the VM */ diff --git a/include/migration/migration.h b/include/migration/migration.h index f37348b..703b7d7 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -71,10 +71,6 @@ void qemu_start_incoming_migration(const char *uri, Error **errp); uint64_t migrate_max_downtime(void); -void do_info_migrate_print(Monitor *mon, const QObject *data); - -void do_info_migrate(Monitor *mon, QObject **ret_data); - void exec_start_incoming_migration(const char *host_port, Error **errp); void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 47606d0..1c06bed 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -34,8 +34,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device, void *opaque); int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); -int monitor_handle_fd_param(Monitor *mon, const char *fdname); -int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp); +int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h index 8d16e11..5eb4a11 100644 --- a/include/monitor/qdev.h +++ b/include/monitor/qdev.h @@ -6,8 +6,8 @@ /*** monitor commands ***/ -void do_info_qtree(Monitor *mon, const QDict *qdict); -void do_info_qdm(Monitor *mon, const QDict *qdict); +void hmp_info_qtree(Monitor *mon, const QDict *qdict); +void hmp_info_qdm(Monitor *mon, const QDict *qdict); int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data); int qdev_device_help(QemuOpts *opts); DeviceState *qdev_device_add(QemuOpts *opts); diff --git a/include/net/net.h b/include/net/net.h index 008d610..50ffcb9 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -156,7 +156,7 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, void *opaque); void print_net_client(Monitor *mon, NetClientState *nc); -void do_info_network(Monitor *mon, const QDict *qdict); +void hmp_info_network(Monitor *mon, const QDict *qdict); /* NIC info */ @@ -187,8 +187,8 @@ int net_client_parse(QemuOptsList *opts_list, const char *str); int net_init_clients(void); void net_check_clients(void); void net_cleanup(void); -void net_host_device_add(Monitor *mon, const QDict *qdict); -void net_host_device_remove(Monitor *mon, const QDict *qdict); +void hmp_host_net_add(Monitor *mon, const QDict *qdict); +void hmp_host_net_remove(Monitor *mon, const QDict *qdict); void netdev_add(QemuOpts *opts, Error **errp); int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret); diff --git a/include/net/slirp.h b/include/net/slirp.h index 0502389..64b795c 100644 --- a/include/net/slirp.h +++ b/include/net/slirp.h @@ -31,8 +31,8 @@ #ifdef CONFIG_SLIRP -void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict); -void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict); +void hmp_hostfwd_add(Monitor *mon, const QDict *qdict); +void hmp_hostfwd_remove(Monitor *mon, const QDict *qdict); int net_slirp_redir(const char *redir_str); @@ -40,7 +40,7 @@ int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *ret int net_slirp_smb(const char *exported_dir); -void do_info_usernet(Monitor *mon, const QDict *qdict); +void hmp_info_usernet(Monitor *mon, const QDict *qdict); #endif diff --git a/include/qapi/error.h b/include/qapi/error.h index d712089..f44c451 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -83,6 +83,11 @@ Error *error_copy(const Error *err); const char *error_get_pretty(Error *err); /** + * Convenience function to error_report() and free an error object. + */ +void error_report_err(Error *); + +/** * Propagate an error to an indirect pointer to an error. This function will * always transfer ownership of the error reference and handles the case where * dst_err is NULL correctly. Errors after the first are discarded. diff --git a/include/qom/object.h b/include/qom/object.h index 89c3092..8757573 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -273,7 +273,7 @@ typedef struct InterfaceInfo InterfaceInfo; * .name = TYPE_DERIVED, * .parent = TYPE_MY, * .class_size = sizeof(DerivedClass), - * .class_init = my_class_init, + * .class_init = derived_class_init, * }; * </programlisting> * </example> diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 2e8ebb2..3ff9aee 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -73,7 +73,7 @@ BlockBackend *blk_next(BlockBackend *blk); BlockDriverState *blk_bs(BlockBackend *blk); -void blk_hide_on_behalf_of_do_drive_del(BlockBackend *blk); +void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk); void blk_iostatus_enable(BlockBackend *blk); int blk_attach_dev(BlockBackend *blk, void *dev); diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 09d1e30..0c62643 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -67,6 +67,6 @@ DriveInfo *add_init_drive(const char *opts); void qmp_change_blockdev(const char *device, const char *filename, const char *format, Error **errp); -void do_commit(Monitor *mon, const QDict *qdict); -int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); +void hmp_commit(Monitor *mon, const QDict *qdict); +int hmp_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); #endif diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h new file mode 100644 index 0000000..5633b85 --- /dev/null +++ b/include/sysemu/numa.h @@ -0,0 +1,24 @@ +#ifndef SYSEMU_NUMA_H +#define SYSEMU_NUMA_H + +#include <stdint.h> +#include "qemu/bitmap.h" +#include "qemu/option.h" +#include "sysemu/sysemu.h" +#include "sysemu/hostmem.h" + +extern int nb_numa_nodes; /* Number of NUMA nodes */ + +typedef struct node_info { + uint64_t node_mem; + DECLARE_BITMAP(node_cpu, MAX_CPUMASK_BITS); + struct HostMemoryBackend *node_memdev; + bool present; +} NodeInfo; +extern NodeInfo numa_info[MAX_NODES]; +void parse_numa_opts(void); +void numa_post_machine_init(void); +void query_numa_node_mem(uint64_t node_mem[]); +extern QemuOptsList qemu_numa_opts; + +#endif diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 748d059..11040b4 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -74,10 +74,10 @@ void qemu_remove_exit_notifier(Notifier *notify); void qemu_add_machine_init_done_notifier(Notifier *notify); -void do_savevm(Monitor *mon, const QDict *qdict); +void hmp_savevm(Monitor *mon, const QDict *qdict); int load_vmstate(const char *name); -void do_delvm(Monitor *mon, const QDict *qdict); -void do_info_snapshots(Monitor *mon, const QDict *qdict); +void hmp_delvm(Monitor *mon, const QDict *qdict); +void hmp_info_snapshots(Monitor *mon, const QDict *qdict); void qemu_announce_self(void); @@ -90,9 +90,6 @@ void qemu_savevm_state_cancel(void); uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size); int qemu_loadvm_state(QEMUFile *f); -/* SLIRP */ -void do_info_slirp(Monitor *mon); - typedef enum DisplayType { DT_DEFAULT, @@ -147,24 +144,6 @@ extern int mem_prealloc; */ #define MAX_CPUMASK_BITS 255 -extern int nb_numa_nodes; /* Number of NUMA nodes */ -extern int max_numa_nodeid; /* Highest specified NUMA node ID, plus one. - * For all nodes, nodeid < max_numa_nodeid - */ - -typedef struct node_info { - uint64_t node_mem; - DECLARE_BITMAP(node_cpu, MAX_CPUMASK_BITS); - struct HostMemoryBackend *node_memdev; - bool present; -} NodeInfo; -extern NodeInfo numa_info[MAX_NODES]; -void set_numa_nodes(void); -void set_numa_modes(void); -void query_numa_node_mem(uint64_t node_mem[]); -extern QemuOptsList qemu_numa_opts; -int numa_init_func(QemuOpts *opts, void *opaque); - #define MAX_OPTION_ROMS 16 typedef struct QEMUOptionRom { const char *name; @@ -178,16 +157,16 @@ extern const char *prom_envs[MAX_PROM_ENVS]; extern unsigned int nb_prom_envs; /* pci-hotplug */ -void pci_device_hot_add(Monitor *mon, const QDict *qdict); +void hmp_pci_add(Monitor *mon, const QDict *qdict); int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo); -void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict); +void hmp_pci_del(Monitor *mon, const QDict *qdict); /* generic hotplug */ -void drive_hot_add(Monitor *mon, const QDict *qdict); +void hmp_drive_add(Monitor *mon, const QDict *qdict); /* pcie aer error injection */ void pcie_aer_inject_error_print(Monitor *mon, const QObject *data); -int do_pcie_aer_inject_error(Monitor *mon, +int hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict, QObject **ret_data); /* serial ports */ @@ -202,9 +181,9 @@ extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; -void do_usb_add(Monitor *mon, const QDict *qdict); -void do_usb_del(Monitor *mon, const QDict *qdict); -void usb_info(Monitor *mon, const QDict *qdict); +void hmp_usb_add(Monitor *mon, const QDict *qdict); +void hmp_usb_del(Monitor *mon, const QDict *qdict); +void hmp_info_usb(Monitor *mon, const QDict *qdict); void add_boot_device_path(int32_t bootindex, DeviceState *dev, const char *suffix); diff --git a/include/ui/console.h b/include/ui/console.h index 5c19c3c..0f97d86 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -56,7 +56,7 @@ struct MouseTransformInfo { int a[7]; }; -void do_mouse_set(Monitor *mon, const QDict *qdict); +void hmp_mouse_set(Monitor *mon, const QDict *qdict); /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */ diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 762e063..25b94c7 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -45,9 +45,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, const char *subject, MonitorCompletion cb, void *opaque); -void do_info_spice_print(Monitor *mon, const QObject *data); -void do_info_spice(Monitor *mon, QObject **ret_data); - CharDriverState *qemu_chr_open_spice_vmc(const char *type); #if SPICE_SERVER_VERSION >= 0x000c02 CharDriverState *qemu_chr_open_spice_port(const char *name); @@ -35,6 +35,7 @@ #include "sysemu/char.h" #include "ui/qemu-spice.h" #include "sysemu/sysemu.h" +#include "sysemu/numa.h" #include "monitor/monitor.h" #include "qemu/readline.h" #include "ui/console.h" @@ -73,7 +74,7 @@ #include "qapi/qmp-event.h" #include "qapi-event.h" -/* for pic/irq_info */ +/* for hmp_info_irq/pic */ #if defined(TARGET_SPARC) #include "hw/sparc/sun4m.h" #endif @@ -881,7 +882,7 @@ static void do_help_cmd(Monitor *mon, const QDict *qdict) help_cmd(mon, qdict_get_try_str(qdict, "name")); } -static void do_trace_event_set_state(Monitor *mon, const QDict *qdict) +static void hmp_trace_event(Monitor *mon, const QDict *qdict) { const char *tp_name = qdict_get_str(qdict, "name"); bool new_state = qdict_get_bool(qdict, "option"); @@ -889,13 +890,12 @@ static void do_trace_event_set_state(Monitor *mon, const QDict *qdict) qmp_trace_event_set_state(tp_name, new_state, true, true, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); } } #ifdef CONFIG_TRACE_SIMPLE -static void do_trace_file(Monitor *mon, const QDict *qdict) +static void hmp_trace_file(Monitor *mon, const QDict *qdict) { const char *op = qdict_get_try_str(qdict, "op"); const char *arg = qdict_get_try_str(qdict, "arg"); @@ -958,7 +958,7 @@ static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd, } } -static void do_info_help(Monitor *mon, const QDict *qdict) +static void hmp_info_help(Monitor *mon, const QDict *qdict) { help_cmd(mon, "info"); } @@ -1027,7 +1027,7 @@ int monitor_get_cpu_index(void) return cpu->cpu_index; } -static void do_info_registers(Monitor *mon, const QDict *qdict) +static void hmp_info_registers(Monitor *mon, const QDict *qdict) { CPUState *cpu; CPUArchState *env; @@ -1036,18 +1036,18 @@ static void do_info_registers(Monitor *mon, const QDict *qdict) cpu_dump_state(cpu, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); } -static void do_info_jit(Monitor *mon, const QDict *qdict) +static void hmp_info_jit(Monitor *mon, const QDict *qdict) { dump_exec_info((FILE *)mon, monitor_fprintf); dump_drift_info((FILE *)mon, monitor_fprintf); } -static void do_info_opcount(Monitor *mon, const QDict *qdict) +static void hmp_info_opcount(Monitor *mon, const QDict *qdict) { dump_opcount_info((FILE *)mon, monitor_fprintf); } -static void do_info_history(Monitor *mon, const QDict *qdict) +static void hmp_info_history(Monitor *mon, const QDict *qdict) { int i; const char *str; @@ -1064,7 +1064,7 @@ static void do_info_history(Monitor *mon, const QDict *qdict) } } -static void do_info_cpu_stats(Monitor *mon, const QDict *qdict) +static void hmp_info_cpustats(Monitor *mon, const QDict *qdict) { CPUState *cpu; CPUArchState *env; @@ -1074,7 +1074,7 @@ static void do_info_cpu_stats(Monitor *mon, const QDict *qdict) cpu_dump_statistics(cpu, (FILE *)mon, &monitor_fprintf, 0); } -static void do_trace_print_events(Monitor *mon, const QDict *qdict) +static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) { TraceEventInfoList *events = qmp_trace_event_get_state("*", NULL); TraceEventInfoList *elem; @@ -1095,12 +1095,13 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict, const char *subject = qdict_get_try_str(qdict, "cert-subject"); int port = qdict_get_try_int(qdict, "port", -1); int tls_port = qdict_get_try_int(qdict, "tls-port", -1); - Error *err; + Error *err = NULL; int ret; if (strcmp(protocol, "spice") == 0) { if (!qemu_using_spice(&err)) { qerror_report_err(err); + error_free(err); return -1; } @@ -1122,12 +1123,12 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict, return -1; } -static void do_logfile(Monitor *mon, const QDict *qdict) +static void hmp_logfile(Monitor *mon, const QDict *qdict) { qemu_set_log_filename(qdict_get_str(qdict, "filename")); } -static void do_log(Monitor *mon, const QDict *qdict) +static void hmp_log(Monitor *mon, const QDict *qdict) { int mask; const char *items = qdict_get_str(qdict, "items"); @@ -1144,7 +1145,7 @@ static void do_log(Monitor *mon, const QDict *qdict) qemu_set_log(mask); } -static void do_singlestep(Monitor *mon, const QDict *qdict) +static void hmp_singlestep(Monitor *mon, const QDict *qdict) { const char *option = qdict_get_try_str(qdict, "option"); if (!option || !strcmp(option, "on")) { @@ -1156,7 +1157,7 @@ static void do_singlestep(Monitor *mon, const QDict *qdict) } } -static void do_gdbserver(Monitor *mon, const QDict *qdict) +static void hmp_gdbserver(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_try_str(qdict, "device"); if (!device) @@ -1172,7 +1173,7 @@ static void do_gdbserver(Monitor *mon, const QDict *qdict) } } -static void do_watchdog_action(Monitor *mon, const QDict *qdict) +static void hmp_watchdog_action(Monitor *mon, const QDict *qdict) { const char *action = qdict_get_str(qdict, "action"); if (select_watchdog_action(action) == -1) { @@ -1331,7 +1332,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, } } -static void do_memory_dump(Monitor *mon, const QDict *qdict) +static void hmp_memory_dump(Monitor *mon, const QDict *qdict) { int count = qdict_get_int(qdict, "count"); int format = qdict_get_int(qdict, "format"); @@ -1341,7 +1342,7 @@ static void do_memory_dump(Monitor *mon, const QDict *qdict) memory_dump(mon, count, format, size, addr, 0); } -static void do_physical_memory_dump(Monitor *mon, const QDict *qdict) +static void hmp_physical_memory_dump(Monitor *mon, const QDict *qdict) { int count = qdict_get_int(qdict, "count"); int format = qdict_get_int(qdict, "format"); @@ -1377,7 +1378,7 @@ static void do_print(Monitor *mon, const QDict *qdict) monitor_printf(mon, "\n"); } -static void do_sum(Monitor *mon, const QDict *qdict) +static void hmp_sum(Monitor *mon, const QDict *qdict) { uint32_t addr; uint16_t sum; @@ -1396,7 +1397,7 @@ static void do_sum(Monitor *mon, const QDict *qdict) static int mouse_button_state; -static void do_mouse_move(Monitor *mon, const QDict *qdict) +static void hmp_mouse_move(Monitor *mon, const QDict *qdict) { int dx, dy, dz, button; const char *dx_str = qdict_get_str(qdict, "dx_str"); @@ -1420,7 +1421,7 @@ static void do_mouse_move(Monitor *mon, const QDict *qdict) qemu_input_event_sync(); } -static void do_mouse_button(Monitor *mon, const QDict *qdict) +static void hmp_mouse_button(Monitor *mon, const QDict *qdict) { static uint32_t bmap[INPUT_BUTTON_MAX] = { [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, @@ -1437,7 +1438,7 @@ static void do_mouse_button(Monitor *mon, const QDict *qdict) mouse_button_state = button_state; } -static void do_ioport_read(Monitor *mon, const QDict *qdict) +static void hmp_ioport_read(Monitor *mon, const QDict *qdict) { int size = qdict_get_int(qdict, "size"); int addr = qdict_get_int(qdict, "addr"); @@ -1471,7 +1472,7 @@ static void do_ioport_read(Monitor *mon, const QDict *qdict) suffix, addr, size * 2, val); } -static void do_ioport_write(Monitor *mon, const QDict *qdict) +static void hmp_ioport_write(Monitor *mon, const QDict *qdict) { int size = qdict_get_int(qdict, "size"); int addr = qdict_get_int(qdict, "addr"); @@ -1493,7 +1494,7 @@ static void do_ioport_write(Monitor *mon, const QDict *qdict) } } -static void do_boot_set(Monitor *mon, const QDict *qdict) +static void hmp_boot_set(Monitor *mon, const QDict *qdict) { Error *local_err = NULL; const char *bootdevice = qdict_get_str(qdict, "bootdevice"); @@ -1657,7 +1658,7 @@ static void tlb_info_64(Monitor *mon, CPUArchState *env) } #endif -static void tlb_info(Monitor *mon, const QDict *qdict) +static void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env; @@ -1880,7 +1881,7 @@ static void mem_info_64(Monitor *mon, CPUArchState *env) } #endif -static void mem_info(Monitor *mon, const QDict *qdict) +static void hmp_info_mem(Monitor *mon, const QDict *qdict) { CPUArchState *env; @@ -1919,7 +1920,7 @@ static void print_tlb(Monitor *mon, int idx, tlb_t *tlb) tlb->d, tlb->wt); } -static void tlb_info(Monitor *mon, const QDict *qdict) +static void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env = mon_get_cpu(); int i; @@ -1935,7 +1936,7 @@ static void tlb_info(Monitor *mon, const QDict *qdict) #endif #if defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_XTENSA) -static void tlb_info(Monitor *mon, const QDict *qdict) +static void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env1 = mon_get_cpu(); @@ -1943,12 +1944,12 @@ static void tlb_info(Monitor *mon, const QDict *qdict) } #endif -static void do_info_mtree(Monitor *mon, const QDict *qdict) +static void hmp_info_mtree(Monitor *mon, const QDict *qdict) { mtree_info((fprintf_function)monitor_printf, mon); } -static void do_info_numa(Monitor *mon, const QDict *qdict) +static void hmp_info_numa(Monitor *mon, const QDict *qdict) { int i; CPUState *cpu; @@ -1976,7 +1977,7 @@ static void do_info_numa(Monitor *mon, const QDict *qdict) int64_t qemu_time; int64_t dev_time; -static void do_info_profile(Monitor *mon, const QDict *qdict) +static void hmp_info_profile(Monitor *mon, const QDict *qdict) { monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n", dev_time, dev_time / (double)get_ticks_per_sec()); @@ -1986,7 +1987,7 @@ static void do_info_profile(Monitor *mon, const QDict *qdict) dev_time = 0; } #else -static void do_info_profile(Monitor *mon, const QDict *qdict) +static void hmp_info_profile(Monitor *mon, const QDict *qdict) { monitor_printf(mon, "Internal profiler not compiled\n"); } @@ -1995,7 +1996,7 @@ static void do_info_profile(Monitor *mon, const QDict *qdict) /* Capture support */ static QLIST_HEAD (capture_list_head, CaptureState) capture_head; -static void do_info_capture(Monitor *mon, const QDict *qdict) +static void hmp_info_capture(Monitor *mon, const QDict *qdict) { int i; CaptureState *s; @@ -2006,7 +2007,7 @@ static void do_info_capture(Monitor *mon, const QDict *qdict) } } -static void do_stop_capture(Monitor *mon, const QDict *qdict) +static void hmp_stopcapture(Monitor *mon, const QDict *qdict) { int i; int n = qdict_get_int(qdict, "n"); @@ -2022,7 +2023,7 @@ static void do_stop_capture(Monitor *mon, const QDict *qdict) } } -static void do_wav_capture(Monitor *mon, const QDict *qdict) +static void hmp_wavcapture(Monitor *mon, const QDict *qdict) { const char *path = qdict_get_str(qdict, "path"); int has_freq = qdict_haskey(qdict, "freq"); @@ -2057,7 +2058,7 @@ static qemu_acl *find_acl(Monitor *mon, const char *name) return acl; } -static void do_acl_show(Monitor *mon, const QDict *qdict) +static void hmp_acl_show(Monitor *mon, const QDict *qdict) { const char *aclname = qdict_get_str(qdict, "aclname"); qemu_acl *acl = find_acl(mon, aclname); @@ -2075,7 +2076,7 @@ static void do_acl_show(Monitor *mon, const QDict *qdict) } } -static void do_acl_reset(Monitor *mon, const QDict *qdict) +static void hmp_acl_reset(Monitor *mon, const QDict *qdict) { const char *aclname = qdict_get_str(qdict, "aclname"); qemu_acl *acl = find_acl(mon, aclname); @@ -2086,7 +2087,7 @@ static void do_acl_reset(Monitor *mon, const QDict *qdict) } } -static void do_acl_policy(Monitor *mon, const QDict *qdict) +static void hmp_acl_policy(Monitor *mon, const QDict *qdict) { const char *aclname = qdict_get_str(qdict, "aclname"); const char *policy = qdict_get_str(qdict, "policy"); @@ -2106,7 +2107,7 @@ static void do_acl_policy(Monitor *mon, const QDict *qdict) } } -static void do_acl_add(Monitor *mon, const QDict *qdict) +static void hmp_acl_add(Monitor *mon, const QDict *qdict) { const char *aclname = qdict_get_str(qdict, "aclname"); const char *match = qdict_get_str(qdict, "match"); @@ -2137,7 +2138,7 @@ static void do_acl_add(Monitor *mon, const QDict *qdict) } } -static void do_acl_remove(Monitor *mon, const QDict *qdict) +static void hmp_acl_remove(Monitor *mon, const QDict *qdict) { const char *aclname = qdict_get_str(qdict, "aclname"); const char *match = qdict_get_str(qdict, "match"); @@ -2154,7 +2155,7 @@ static void do_acl_remove(Monitor *mon, const QDict *qdict) } #if defined(TARGET_I386) -static void do_inject_mce(Monitor *mon, const QDict *qdict) +static void hmp_mce(Monitor *mon, const QDict *qdict) { X86CPU *cpu; CPUState *cs; @@ -2232,7 +2233,7 @@ void qmp_closefd(const char *fdname, Error **errp) error_set(errp, QERR_FD_NOT_FOUND, fdname); } -static void do_loadvm(Monitor *mon, const QDict *qdict) +static void hmp_loadvm(Monitor *mon, const QDict *qdict) { int saved_vm_running = runstate_is_running(); const char *name = qdict_get_str(qdict, "name"); @@ -2570,20 +2571,7 @@ void monitor_fdset_dup_fd_remove(int dup_fd) monitor_fdset_dup_fd_find_remove(dup_fd, true); } -int monitor_handle_fd_param(Monitor *mon, const char *fdname) -{ - int fd; - Error *local_err = NULL; - - fd = monitor_handle_fd_param2(mon, fdname, &local_err); - if (local_err) { - qerror_report_err(local_err); - error_free(local_err); - } - return fd; -} - -int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp) +int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp) { int fd; Error *local_err = NULL; @@ -2621,7 +2609,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the network state", - .mhandler.cmd = do_info_network, + .mhandler.cmd = hmp_info_network, }, { .name = "chardev", @@ -2657,7 +2645,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the cpu registers", - .mhandler.cmd = do_info_registers, + .mhandler.cmd = hmp_info_registers, }, { .name = "cpus", @@ -2671,7 +2659,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the command line history", - .mhandler.cmd = do_info_history, + .mhandler.cmd = hmp_info_history, }, #if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_MIPS) || \ defined(TARGET_LM32) || (defined(TARGET_SPARC) && !defined(TARGET_SPARC64)) @@ -2681,11 +2669,11 @@ static mon_cmd_t info_cmds[] = { .params = "", .help = "show the interrupts statistics (if available)", #ifdef TARGET_SPARC - .mhandler.cmd = sun4m_irq_info, + .mhandler.cmd = sun4m_hmp_info_irq, #elif defined(TARGET_LM32) - .mhandler.cmd = lm32_irq_info, + .mhandler.cmd = lm32_hmp_info_irq, #else - .mhandler.cmd = irq_info, + .mhandler.cmd = hmp_info_irq, #endif }, { @@ -2694,11 +2682,11 @@ static mon_cmd_t info_cmds[] = { .params = "", .help = "show i8259 (PIC) state", #ifdef TARGET_SPARC - .mhandler.cmd = sun4m_pic_info, + .mhandler.cmd = sun4m_hmp_info_pic, #elif defined(TARGET_LM32) - .mhandler.cmd = lm32_do_pic_info, + .mhandler.cmd = lm32_hmp_info_pic, #else - .mhandler.cmd = pic_info, + .mhandler.cmd = hmp_info_pic, #endif }, #endif @@ -2716,7 +2704,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show virtual to physical memory mappings", - .mhandler.cmd = tlb_info, + .mhandler.cmd = hmp_info_tlb, }, #endif #if defined(TARGET_I386) @@ -2725,7 +2713,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the active virtual memory mappings", - .mhandler.cmd = mem_info, + .mhandler.cmd = hmp_info_mem, }, #endif { @@ -2733,21 +2721,21 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show memory tree", - .mhandler.cmd = do_info_mtree, + .mhandler.cmd = hmp_info_mtree, }, { .name = "jit", .args_type = "", .params = "", .help = "show dynamic compiler info", - .mhandler.cmd = do_info_jit, + .mhandler.cmd = hmp_info_jit, }, { .name = "opcount", .args_type = "", .params = "", .help = "show dynamic compiler opcode counters", - .mhandler.cmd = do_info_opcount, + .mhandler.cmd = hmp_info_opcount, }, { .name = "kvm", @@ -2761,42 +2749,42 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show NUMA information", - .mhandler.cmd = do_info_numa, + .mhandler.cmd = hmp_info_numa, }, { .name = "usb", .args_type = "", .params = "", .help = "show guest USB devices", - .mhandler.cmd = usb_info, + .mhandler.cmd = hmp_info_usb, }, { .name = "usbhost", .args_type = "", .params = "", .help = "show host USB devices", - .mhandler.cmd = usb_host_info, + .mhandler.cmd = hmp_info_usbhost, }, { .name = "profile", .args_type = "", .params = "", .help = "show profiling information", - .mhandler.cmd = do_info_profile, + .mhandler.cmd = hmp_info_profile, }, { .name = "capture", .args_type = "", .params = "", .help = "show capture information", - .mhandler.cmd = do_info_capture, + .mhandler.cmd = hmp_info_capture, }, { .name = "snapshots", .args_type = "", .params = "", .help = "show the currently saved VM snapshots", - .mhandler.cmd = do_info_snapshots, + .mhandler.cmd = hmp_info_snapshots, }, { .name = "status", @@ -2847,7 +2835,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show CPU statistics", - .mhandler.cmd = do_info_cpu_stats, + .mhandler.cmd = hmp_info_cpustats, }, #if defined(CONFIG_SLIRP) { @@ -2855,7 +2843,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show user network stack connection states", - .mhandler.cmd = do_info_usernet, + .mhandler.cmd = hmp_info_usernet, }, #endif { @@ -2891,28 +2879,28 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show device tree", - .mhandler.cmd = do_info_qtree, + .mhandler.cmd = hmp_info_qtree, }, { .name = "qdm", .args_type = "", .params = "", .help = "show qdev device model list", - .mhandler.cmd = do_info_qdm, + .mhandler.cmd = hmp_info_qdm, }, { .name = "roms", .args_type = "", .params = "", .help = "show roms", - .mhandler.cmd = do_info_roms, + .mhandler.cmd = hmp_info_roms, }, { .name = "trace-events", .args_type = "", .params = "", .help = "show available trace-events & their state", - .mhandler.cmd = do_trace_print_events, + .mhandler.cmd = hmp_info_trace_events, }, { .name = "tpm", @@ -953,7 +953,7 @@ static int net_host_check_device(const char *device) return 0; } -void net_host_device_add(Monitor *mon, const QDict *qdict) +void hmp_host_net_add(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_str(qdict, "device"); const char *opts_str = qdict_get_try_str(qdict, "opts"); @@ -974,13 +974,12 @@ void net_host_device_add(Monitor *mon, const QDict *qdict) net_client_init(opts, 0, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); monitor_printf(mon, "adding host network device %s failed\n", device); } } -void net_host_device_remove(Monitor *mon, const QDict *qdict) +void hmp_host_net_remove(Monitor *mon, const QDict *qdict) { NetClientState *nc; int vlan_id = qdict_get_int(qdict, "vlan_id"); @@ -1117,7 +1116,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, return filter_list; } -void do_info_network(Monitor *mon, const QDict *qdict) +void hmp_info_network(Monitor *mon, const QDict *qdict) { NetClientState *nc, *peer; NetClientOptionsKind type; @@ -1270,8 +1269,7 @@ static int net_init_client(QemuOpts *opts, void *dummy) net_client_init(opts, 0, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); return -1; } @@ -1285,8 +1283,7 @@ static int net_init_netdev(QemuOpts *opts, void *dummy) ret = net_client_init(opts, 1, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); return -1; } diff --git a/net/slirp.c b/net/slirp.c index 0cbca3c..9bbed74 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -299,7 +299,7 @@ static SlirpState *slirp_lookup(Monitor *mon, const char *vlan, } } -void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict) +void hmp_hostfwd_remove(Monitor *mon, const QDict *qdict) { struct in_addr host_addr = { .s_addr = INADDR_ANY }; int host_port; @@ -420,7 +420,7 @@ static int slirp_hostfwd(SlirpState *s, const char *redir_str, return -1; } -void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict) +void hmp_hostfwd_add(Monitor *mon, const QDict *qdict) { const char *redir_str; SlirpState *s; @@ -681,7 +681,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, return -1; } -void do_info_usernet(Monitor *mon, const QDict *qdict) +void hmp_info_usernet(Monitor *mon, const QDict *qdict) { SlirpState *s; diff --git a/net/socket.c b/net/socket.c index 68a93cd..c30e03f 100644 --- a/net/socket.c +++ b/net/socket.c @@ -695,6 +695,7 @@ static int net_socket_udp_init(NetClientState *peer, int net_init_socket(const NetClientOptions *opts, const char *name, NetClientState *peer) { + Error *err = NULL; const NetdevSocketOptions *sock; assert(opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET); @@ -715,8 +716,9 @@ int net_init_socket(const NetClientOptions *opts, const char *name, if (sock->has_fd) { int fd; - fd = monitor_handle_fd_param(cur_mon, sock->fd); + fd = monitor_fd_param(cur_mon, sock->fd, &err); if (fd == -1) { + error_report_err(err); return -1; } qemu_set_nonblock(fd); @@ -605,6 +605,7 @@ static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, const char *downscript, const char *vhostfdname, int vnet_hdr, int fd) { + Error *err = NULL; TAPState *s; int vhostfd; @@ -643,8 +644,9 @@ static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, options.force = tap->has_vhostforce && tap->vhostforce; if (tap->has_vhostfd || tap->has_vhostfds) { - vhostfd = monitor_handle_fd_param(cur_mon, vhostfdname); + vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err); if (vhostfd == -1) { + error_report_err(err); return -1; } } else { @@ -704,6 +706,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, /* for the no-fd, no-helper case */ const char *script = NULL; /* suppress wrong "uninit'd use" gcc warning */ const char *downscript = NULL; + Error *err = NULL; const char *vhostfdname; char ifname[128]; @@ -729,8 +732,9 @@ int net_init_tap(const NetClientOptions *opts, const char *name, return -1; } - fd = monitor_handle_fd_param(cur_mon, tap->fd); + fd = monitor_fd_param(cur_mon, tap->fd, &err); if (fd == -1) { + error_report_err(err); return -1; } @@ -768,8 +772,9 @@ int net_init_tap(const NetClientOptions *opts, const char *name, } for (i = 0; i < nfds; i++) { - fd = monitor_handle_fd_param(cur_mon, fds[i]); + fd = monitor_fd_param(cur_mon, fds[i], &err); if (fd == -1) { + error_report_err(err); return -1; } @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "sysemu/sysemu.h" +#include "sysemu/numa.h" #include "exec/cpu-common.h" #include "qemu/bitmap.h" #include "qom/cpu.h" @@ -36,6 +36,8 @@ #include "sysemu/hostmem.h" #include "qmp-commands.h" #include "hw/mem/pc-dimm.h" +#include "qemu/option.h" +#include "qemu/config-file.h" QemuOptsList qemu_numa_opts = { .name = "numa", @@ -45,6 +47,11 @@ QemuOptsList qemu_numa_opts = { }; static int have_memdevs = -1; +static int max_numa_nodeid; /* Highest specified NUMA node ID, plus one. + * For all nodes, nodeid < max_numa_nodeid + */ +int nb_numa_nodes; +NodeInfo numa_info[MAX_NODES]; static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp) { @@ -116,7 +123,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp) max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1); } -int numa_init_func(QemuOpts *opts, void *opaque) +static int parse_numa(QemuOpts *opts, void *opaque) { NumaOptions *object = NULL; Error *err = NULL; @@ -146,8 +153,7 @@ int numa_init_func(QemuOpts *opts, void *opaque) return 0; error: - qerror_report_err(err); - error_free(err); + error_report_err(err); if (object) { QapiDeallocVisitor *dv = qapi_dealloc_visitor_new(); @@ -159,10 +165,15 @@ error: return -1; } -void set_numa_nodes(void) +void parse_numa_opts(void) { int i; + if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, + NULL, 1) != 0) { + exit(1); + } + assert(max_numa_nodeid <= MAX_NODES); /* No support for sparse NUMA node IDs yet: */ @@ -234,7 +245,7 @@ void set_numa_nodes(void) } } -void set_numa_modes(void) +void numa_post_machine_init(void) { CPUState *cpu; int i; @@ -262,8 +273,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, * regular RAM allocation. */ if (err) { - qerror_report_err(err); - error_free(err); + error_report_err(err); memory_region_init_ram(mr, owner, name, ram_size, &error_abort); } #else @@ -298,7 +308,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, } MemoryRegion *seg = host_memory_backend_get_memory(backend, &local_err); if (local_err) { - qerror_report_err(local_err); + error_report_err(local_err); exit(1); } diff --git a/pc-bios/bios-256k.bin b/pc-bios/bios-256k.bin Binary files differindex fab9da2..1c3f402 100644 --- a/pc-bios/bios-256k.bin +++ b/pc-bios/bios-256k.bin diff --git a/pc-bios/bios.bin b/pc-bios/bios.bin Binary files differindex 8c718e1..3724535 100644 --- a/pc-bios/bios.bin +++ b/pc-bios/bios.bin diff --git a/pc-bios/vgabios-cirrus.bin b/pc-bios/vgabios-cirrus.bin Binary files differindex 0c4d253..09dd0fa 100644 --- a/pc-bios/vgabios-cirrus.bin +++ b/pc-bios/vgabios-cirrus.bin diff --git a/pc-bios/vgabios-qxl.bin b/pc-bios/vgabios-qxl.bin Binary files differindex 4e08e13..92f22bf 100644 --- a/pc-bios/vgabios-qxl.bin +++ b/pc-bios/vgabios-qxl.bin diff --git a/pc-bios/vgabios-stdvga.bin b/pc-bios/vgabios-stdvga.bin Binary files differindex e5e5b14..73c3468 100644 --- a/pc-bios/vgabios-stdvga.bin +++ b/pc-bios/vgabios-stdvga.bin diff --git a/pc-bios/vgabios-vmware.bin b/pc-bios/vgabios-vmware.bin Binary files differindex cf2576d..86f9f7e 100644 --- a/pc-bios/vgabios-vmware.bin +++ b/pc-bios/vgabios-vmware.bin diff --git a/pc-bios/vgabios.bin b/pc-bios/vgabios.bin Binary files differindex bad187dc..de3226e 100644 --- a/pc-bios/vgabios.bin +++ b/pc-bios/vgabios.bin diff --git a/qdev-monitor.c b/qdev-monitor.c index ebfa701..0c25b82 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -667,13 +667,13 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent) } #undef qdev_printf -void do_info_qtree(Monitor *mon, const QDict *qdict) +void hmp_info_qtree(Monitor *mon, const QDict *qdict) { if (sysbus_get_default()) qbus_print(mon, sysbus_get_default(), 0); } -void do_info_qdm(Monitor *mon, const QDict *qdict) +void hmp_info_qdm(Monitor *mon, const QDict *qdict) { qdev_print_devinfos(true); } diff --git a/qemu-char.c b/qemu-char.c index 98d4342..8159462 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3306,8 +3306,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename) opts = qemu_opts_create(qemu_find_opts("chardev"), label, 1, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); return NULL; } @@ -3753,8 +3752,7 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*in chr = qemu_chr_new_from_opts(opts, init, &err); if (err) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); } if (chr && qemu_opt_get_bool(opts, "mux", 0)) { qemu_chr_fe_claim_no_fail(chr); @@ -883,8 +883,7 @@ done: blk_unref(blk); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); return 1; } @@ -2001,8 +2000,7 @@ static ImageInfoList *collect_image_info_list(const char *filename, bdrv_query_image_info(bs, &info, &err); if (err) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); blk_unref(blk); goto err; } @@ -3043,8 +3041,7 @@ int main(int argc, char **argv) qemu_init_exec_dir(argv[0]); if (qemu_init_main_loop(&local_error)) { - error_report("%s", error_get_pretty(local_error)); - error_free(local_error); + error_report_err(local_error); exit(EXIT_FAILURE); } @@ -440,8 +440,7 @@ int main(int argc, char **argv) } if (qemu_init_main_loop(&local_error)) { - error_report("%s", error_get_pretty(local_error)); - error_free(local_error); + error_report_err(local_error); exit(1); } @@ -228,8 +228,7 @@ static int tcp_socket_incoming(const char *address, uint16_t port) int fd = inet_listen(address_and_port, NULL, 0, SOCK_STREAM, 0, &local_err); if (local_err != NULL) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } return fd; } @@ -240,8 +239,7 @@ static int unix_socket_incoming(const char *path) int fd = unix_listen(path, NULL, 0, &local_err); if (local_err != NULL) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } return fd; } @@ -252,8 +250,7 @@ static int unix_socket_outgoing(const char *path) int fd = unix_connect(path, &local_err); if (local_err != NULL) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } return fd; } @@ -681,8 +678,7 @@ int main(int argc, char **argv) } if (qemu_init_main_loop(&local_err)) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); exit(EXIT_FAILURE); } bdrv_init(); @@ -71,8 +71,7 @@ CPUState *cpu_generic_init(const char *typename, const char *cpu_model) out: if (err != NULL) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); object_unref(OBJECT(cpu)); return NULL; } diff --git a/roms/config.seabios-128k b/roms/config.seabios-128k index e653c75..c719ba6 100644 --- a/roms/config.seabios-128k +++ b/roms/config.seabios-128k @@ -5,3 +5,4 @@ CONFIG_ROM_SIZE=128 CONFIG_XEN=n CONFIG_USB_XHCI=n CONFIG_USB_UAS=n +CONFIG_SDCARD=n diff --git a/roms/seabios b/roms/seabios -Subproject 8936dbb2cd5403c9a8279c849f7f4b0ccc0796a +Subproject 4c59f5d83044df4d57b90958b0fdfcecb913fdd @@ -1092,7 +1092,7 @@ static int del_existing_snapshots(Monitor *mon, const char *name) return 0; } -void do_savevm(Monitor *mon, const QDict *qdict) +void hmp_savevm(Monitor *mon, const QDict *qdict) { BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1; @@ -1298,7 +1298,7 @@ int load_vmstate(const char *name) return 0; } -void do_delvm(Monitor *mon, const QDict *qdict) +void hmp_delvm(Monitor *mon, const QDict *qdict) { BlockDriverState *bs; Error *err; @@ -1326,7 +1326,7 @@ void do_delvm(Monitor *mon, const QDict *qdict) } } -void do_info_snapshots(Monitor *mon, const QDict *qdict) +void hmp_info_snapshots(Monitor *mon, const QDict *qdict) { BlockDriverState *bs, *bs1; QEMUSnapshotInfo *sn_tab, *sn, s, *sn_info = &s; diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 1eb272d..db87218 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -123,16 +123,19 @@ const char *%(name)s_lookup[] = { name=name) i = 0 for value in values: + index = generate_enum_full_value(name, value) ret += mcgen(''' - "%(value)s", + [%(index)s] = "%(value)s", ''', - value=value) + index = index, value = value) + max_index = generate_enum_full_value(name, 'MAX') ret += mcgen(''' - NULL, + [%(max_index)s] = NULL, }; -''') +''', + max_index=max_index) return ret def generate_enum(name, values): diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 70fd6db..14c6c4a 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2158,8 +2158,7 @@ CPUX86State *cpu_x86_init_user(const char *cpu_model) return &cpu->env; error: - error_report("%s", error_get_pretty(error)); - error_free(error); + error_report_err(error); if (cpu != NULL) { object_unref(OBJECT(cpu)); } diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs index 2c57494..dd62cbd 100644 --- a/target-s390x/Makefile.objs +++ b/target-s390x/Makefile.objs @@ -1,5 +1,5 @@ obj-y += translate.o helper.o cpu.o interrupt.o obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o obj-y += gdbstub.o -obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o +obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o obj-$(CONFIG_KVM) += kvm.o diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index 2e2554c..b6b4632 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -287,6 +287,7 @@ typedef struct CPUS390XState { #define FLAG_MASK_32 0x00001000 /* Control register 0 bits */ +#define CR0_LOWPROT 0x0000000010000000ULL #define CR0_EDAT 0x0000000000800000ULL static inline int cpu_mmu_index (CPUS390XState *env) @@ -331,6 +332,7 @@ static inline int get_ilen(uint8_t opc) to re-compute the length by examining the insn in memory. */ #define ILEN_LATER 0x20 #define ILEN_LATER_INC 0x21 +void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen); #endif S390CPU *cpu_s390x_init(const char *cpu_model); @@ -348,10 +350,6 @@ int s390_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw, #include "ioinst.h" #ifndef CONFIG_USER_ONLY -void *s390_cpu_physical_memory_map(CPUS390XState *env, hwaddr addr, hwaddr *len, - int is_write); -void s390_cpu_physical_memory_unmap(CPUS390XState *env, void *addr, hwaddr len, - int is_write); static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb) { hwaddr addr = 0; @@ -396,6 +394,7 @@ void kvm_s390_service_interrupt(uint32_t parm); void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq); void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq); int kvm_s390_inject_flic(struct kvm_s390_irq *irq); +void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code); #else static inline void kvm_s390_virtio_irq(int config_change, uint64_t token) { @@ -403,6 +402,10 @@ static inline void kvm_s390_virtio_irq(int config_change, uint64_t token) static inline void kvm_s390_service_interrupt(uint32_t parm) { } +static inline void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, + uint64_t te_code) +{ +} #endif S390CPU *s390_cpu_addr2state(uint16_t cpu_addr); unsigned int s390_cpu_halt(S390CPU *cpu); @@ -443,13 +446,15 @@ bool css_subch_visible(SubchDev *sch); void css_conditional_io_interrupt(SubchDev *sch); int css_do_stsch(SubchDev *sch, SCHIB *schib); bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid); -int css_do_msch(SubchDev *sch, SCHIB *schib); +int css_do_msch(SubchDev *sch, const SCHIB *schib); int css_do_xsch(SubchDev *sch); int css_do_csch(SubchDev *sch); int css_do_hsch(SubchDev *sch); int css_do_ssch(SubchDev *sch, ORB *orb); -int css_do_tsch(SubchDev *sch, IRB *irb); +int css_do_tsch_get_irb(SubchDev *sch, IRB *irb, int *irb_len); +void css_do_tsch_update_subch(SubchDev *sch); int css_do_stcrw(CRW *crw); +void css_undo_stcrw(CRW *crw); int css_do_tpi(IOIntCode *int_code, int lowcore); int css_collect_chp_desc(int m, uint8_t cssid, uint8_t f_chpid, uint8_t l_chpid, int rfmt, void *buf); @@ -836,6 +841,8 @@ struct sysib_322 { #define _ASCE_TABLE_LENGTH 0x03 /* region table length */ #define _REGION_ENTRY_ORIGIN ~0xfffULL /* region/segment table origin */ +#define _REGION_ENTRY_RO 0x200 /* region/segment protection bit */ +#define _REGION_ENTRY_TF 0xc0 /* region/segment table offset */ #define _REGION_ENTRY_INV 0x20 /* invalid region table entry */ #define _REGION_ENTRY_TYPE_MASK 0x0c /* region/segment table type mask */ #define _REGION_ENTRY_TYPE_R1 0x0c /* region first table type */ @@ -850,6 +857,7 @@ struct sysib_322 { #define _PAGE_RO 0x200 /* HW read-only bit */ #define _PAGE_INVALID 0x400 /* HW invalid bit */ +#define _PAGE_RES0 0x800 /* bit must be zero */ #define SK_C (0x1 << 1) #define SK_R (0x1 << 2) @@ -883,11 +891,21 @@ struct sysib_322 { void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr); int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc, - target_ulong *raddr, int *flags); + target_ulong *raddr, int *flags, bool exc); int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code); uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst, uint64_t vr); +int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf, int len, + bool is_write); + +#define s390_cpu_virt_mem_read(cpu, laddr, dest, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, dest, len, false) +#define s390_cpu_virt_mem_write(cpu, laddr, dest, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, dest, len, true) +#define s390_cpu_virt_mem_check_write(cpu, laddr, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, NULL, len, true) + /* The value of the TOD clock for 1.1.1970. */ #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 5958343..e0fd8fc 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -27,7 +27,6 @@ #endif //#define DEBUG_S390 -//#define DEBUG_S390_PTE //#define DEBUG_S390_STDOUT #ifdef DEBUG_S390 @@ -44,12 +43,6 @@ do { } while (0) #endif -#ifdef DEBUG_S390_PTE -#define PTE_DPRINTF DPRINTF -#else -#define PTE_DPRINTF(fmt, ...) \ - do { } while (0) -#endif #ifndef CONFIG_USER_ONLY void s390x_tod_timer(void *opaque) @@ -105,8 +98,7 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, #else /* !CONFIG_USER_ONLY */ /* Ensure to exit the TB after this call! */ -static void trigger_pgm_exception(CPUS390XState *env, uint32_t code, - uint32_t ilen) +void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen) { CPUState *cs = CPU(s390_env_get_cpu(env)); @@ -115,319 +107,6 @@ static void trigger_pgm_exception(CPUS390XState *env, uint32_t code, env->int_pgm_ilen = ilen; } -static int trans_bits(CPUS390XState *env, uint64_t mode) -{ - S390CPU *cpu = s390_env_get_cpu(env); - int bits = 0; - - switch (mode) { - case PSW_ASC_PRIMARY: - bits = 1; - break; - case PSW_ASC_SECONDARY: - bits = 2; - break; - case PSW_ASC_HOME: - bits = 3; - break; - default: - cpu_abort(CPU(cpu), "unknown asc mode\n"); - break; - } - - return bits; -} - -static void trigger_prot_fault(CPUS390XState *env, target_ulong vaddr, - uint64_t mode) -{ - CPUState *cs = CPU(s390_env_get_cpu(env)); - int ilen = ILEN_LATER_INC; - int bits = trans_bits(env, mode) | 4; - - DPRINTF("%s: vaddr=%016" PRIx64 " bits=%d\n", __func__, vaddr, bits); - - stq_phys(cs->as, - env->psa + offsetof(LowCore, trans_exc_code), vaddr | bits); - trigger_pgm_exception(env, PGM_PROTECTION, ilen); -} - -static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr, - uint32_t type, uint64_t asc, int rw) -{ - CPUState *cs = CPU(s390_env_get_cpu(env)); - int ilen = ILEN_LATER; - int bits = trans_bits(env, asc); - - /* Code accesses have an undefined ilc. */ - if (rw == 2) { - ilen = 2; - } - - DPRINTF("%s: vaddr=%016" PRIx64 " bits=%d\n", __func__, vaddr, bits); - - stq_phys(cs->as, - env->psa + offsetof(LowCore, trans_exc_code), vaddr | bits); - trigger_pgm_exception(env, type, ilen); -} - -/** - * Translate real address to absolute (= physical) - * address by taking care of the prefix mapping. - */ -static target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr) -{ - if (raddr < 0x2000) { - return raddr + env->psa; /* Map the lowcore. */ - } else if (raddr >= env->psa && raddr < env->psa + 0x2000) { - return raddr - env->psa; /* Map the 0 page. */ - } - return raddr; -} - -/* Decode page table entry (normal 4KB page) */ -static int mmu_translate_pte(CPUS390XState *env, target_ulong vaddr, - uint64_t asc, uint64_t asce, - target_ulong *raddr, int *flags, int rw) -{ - if (asce & _PAGE_INVALID) { - DPRINTF("%s: PTE=0x%" PRIx64 " invalid\n", __func__, asce); - trigger_page_fault(env, vaddr, PGM_PAGE_TRANS, asc, rw); - return -1; - } - - if (asce & _PAGE_RO) { - *flags &= ~PAGE_WRITE; - } - - *raddr = asce & _ASCE_ORIGIN; - - PTE_DPRINTF("%s: PTE=0x%" PRIx64 "\n", __func__, asce); - - return 0; -} - -/* Decode EDAT1 segment frame absolute address (1MB page) */ -static int mmu_translate_sfaa(CPUS390XState *env, target_ulong vaddr, - uint64_t asc, uint64_t asce, target_ulong *raddr, - int *flags, int rw) -{ - if (asce & _SEGMENT_ENTRY_INV) { - DPRINTF("%s: SEG=0x%" PRIx64 " invalid\n", __func__, asce); - trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw); - return -1; - } - - if (asce & _SEGMENT_ENTRY_RO) { - *flags &= ~PAGE_WRITE; - } - - *raddr = (asce & 0xfffffffffff00000ULL) | (vaddr & 0xfffff); - - PTE_DPRINTF("%s: SEG=0x%" PRIx64 "\n", __func__, asce); - - return 0; -} - -static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr, - uint64_t asc, uint64_t asce, int level, - target_ulong *raddr, int *flags, int rw) -{ - CPUState *cs = CPU(s390_env_get_cpu(env)); - uint64_t offs = 0; - uint64_t origin; - uint64_t new_asce; - - PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, asce); - - if (((level != _ASCE_TYPE_SEGMENT) && (asce & _REGION_ENTRY_INV)) || - ((level == _ASCE_TYPE_SEGMENT) && (asce & _SEGMENT_ENTRY_INV))) { - /* XXX different regions have different faults */ - DPRINTF("%s: invalid region\n", __func__); - trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw); - return -1; - } - - if ((level <= _ASCE_TYPE_MASK) && ((asce & _ASCE_TYPE_MASK) != level)) { - trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw); - return -1; - } - - if (asce & _ASCE_REAL_SPACE) { - /* direct mapping */ - - *raddr = vaddr; - return 0; - } - - origin = asce & _ASCE_ORIGIN; - - switch (level) { - case _ASCE_TYPE_REGION1 + 4: - offs = (vaddr >> 50) & 0x3ff8; - break; - case _ASCE_TYPE_REGION1: - offs = (vaddr >> 39) & 0x3ff8; - break; - case _ASCE_TYPE_REGION2: - offs = (vaddr >> 28) & 0x3ff8; - break; - case _ASCE_TYPE_REGION3: - offs = (vaddr >> 17) & 0x3ff8; - break; - case _ASCE_TYPE_SEGMENT: - offs = (vaddr >> 9) & 0x07f8; - origin = asce & _SEGMENT_ENTRY_ORIGIN; - break; - } - - /* XXX region protection flags */ - /* *flags &= ~PAGE_WRITE */ - - new_asce = ldq_phys(cs->as, origin + offs); - PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n", - __func__, origin, offs, new_asce); - - if (level == _ASCE_TYPE_SEGMENT) { - /* 4KB page */ - return mmu_translate_pte(env, vaddr, asc, new_asce, raddr, flags, rw); - } else if (level - 4 == _ASCE_TYPE_SEGMENT && - (new_asce & _SEGMENT_ENTRY_FC) && (env->cregs[0] & CR0_EDAT)) { - /* 1MB page */ - return mmu_translate_sfaa(env, vaddr, asc, new_asce, raddr, flags, rw); - } else { - /* yet another region */ - return mmu_translate_asce(env, vaddr, asc, new_asce, level - 4, raddr, - flags, rw); - } -} - -static int mmu_translate_asc(CPUS390XState *env, target_ulong vaddr, - uint64_t asc, target_ulong *raddr, int *flags, - int rw) -{ - uint64_t asce = 0; - int level, new_level; - int r; - - switch (asc) { - case PSW_ASC_PRIMARY: - PTE_DPRINTF("%s: asc=primary\n", __func__); - asce = env->cregs[1]; - break; - case PSW_ASC_SECONDARY: - PTE_DPRINTF("%s: asc=secondary\n", __func__); - asce = env->cregs[7]; - break; - case PSW_ASC_HOME: - PTE_DPRINTF("%s: asc=home\n", __func__); - asce = env->cregs[13]; - break; - } - - switch (asce & _ASCE_TYPE_MASK) { - case _ASCE_TYPE_REGION1: - break; - case _ASCE_TYPE_REGION2: - if (vaddr & 0xffe0000000000000ULL) { - DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64 - " 0xffe0000000000000ULL\n", __func__, vaddr); - trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw); - return -1; - } - break; - case _ASCE_TYPE_REGION3: - if (vaddr & 0xfffffc0000000000ULL) { - DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64 - " 0xfffffc0000000000ULL\n", __func__, vaddr); - trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw); - return -1; - } - break; - case _ASCE_TYPE_SEGMENT: - if (vaddr & 0xffffffff80000000ULL) { - DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64 - " 0xffffffff80000000ULL\n", __func__, vaddr); - trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw); - return -1; - } - break; - } - - /* fake level above current */ - level = asce & _ASCE_TYPE_MASK; - new_level = level + 4; - asce = (asce & ~_ASCE_TYPE_MASK) | (new_level & _ASCE_TYPE_MASK); - - r = mmu_translate_asce(env, vaddr, asc, asce, new_level, raddr, flags, rw); - - if ((rw == 1) && !(*flags & PAGE_WRITE)) { - trigger_prot_fault(env, vaddr, asc); - return -1; - } - - return r; -} - -int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc, - target_ulong *raddr, int *flags) -{ - int r = -1; - uint8_t *sk; - - *flags = PAGE_READ | PAGE_WRITE | PAGE_EXEC; - vaddr &= TARGET_PAGE_MASK; - - if (!(env->psw.mask & PSW_MASK_DAT)) { - *raddr = vaddr; - r = 0; - goto out; - } - - switch (asc) { - case PSW_ASC_PRIMARY: - case PSW_ASC_HOME: - r = mmu_translate_asc(env, vaddr, asc, raddr, flags, rw); - break; - case PSW_ASC_SECONDARY: - /* - * Instruction: Primary - * Data: Secondary - */ - if (rw == 2) { - r = mmu_translate_asc(env, vaddr, PSW_ASC_PRIMARY, raddr, flags, - rw); - *flags &= ~(PAGE_READ | PAGE_WRITE); - } else { - r = mmu_translate_asc(env, vaddr, PSW_ASC_SECONDARY, raddr, flags, - rw); - *flags &= ~(PAGE_EXEC); - } - break; - case PSW_ASC_ACCREG: - default: - hw_error("guest switched to unknown asc mode\n"); - break; - } - - out: - /* Convert real address -> absolute address */ - *raddr = mmu_real2abs(env, *raddr); - - if (*raddr <= ram_size) { - sk = &env->storage_keys[*raddr / TARGET_PAGE_SIZE]; - if (*flags & PAGE_READ) { - *sk |= SK_R; - } - - if (*flags & PAGE_WRITE) { - *sk |= SK_C; - } - } - - return r; -} - int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int rw, int mmu_idx) { @@ -448,7 +127,7 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, vaddr &= 0x7fffffff; } - if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot)) { + if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) { /* Translation ended in exception */ return 1; } @@ -475,8 +154,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr) S390CPU *cpu = S390_CPU(cs); CPUS390XState *env = &cpu->env; target_ulong raddr; - int prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; - int old_exc = cs->exception_index; + int prot; uint64_t asc = env->psw.mask & PSW_MASK_ASC; /* 31-Bit mode */ @@ -484,8 +162,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr) vaddr &= 0x7fffffff; } - mmu_translate(env, vaddr, 2, asc, &raddr, &prot); - cs->exception_index = old_exc; + mmu_translate(env, vaddr, 2, asc, &raddr, &prot, false); return raddr; } @@ -552,31 +229,6 @@ static void cpu_unmap_lowcore(LowCore *lowcore) cpu_physical_memory_unmap(lowcore, sizeof(LowCore), 1, sizeof(LowCore)); } -void *s390_cpu_physical_memory_map(CPUS390XState *env, hwaddr addr, hwaddr *len, - int is_write) -{ - hwaddr start = addr; - - /* Mind the prefix area. */ - if (addr < 8192) { - /* Map the lowcore. */ - start += env->psa; - *len = MIN(*len, 8192 - addr); - } else if ((addr >= env->psa) && (addr < env->psa + 8192)) { - /* Map the 0 page. */ - start -= env->psa; - *len = MIN(*len, 8192 - start); - } - - return cpu_physical_memory_map(start, len, is_write); -} - -void s390_cpu_physical_memory_unmap(CPUS390XState *env, void *addr, hwaddr len, - int is_write) -{ - cpu_physical_memory_unmap(addr, len, is_write, len); -} - static void do_svc_interrupt(CPUS390XState *env) { uint64_t mask, addr; diff --git a/target-s390x/ioinst.c b/target-s390x/ioinst.c index 1ac5d61..b00a00c 100644 --- a/target-s390x/ioinst.c +++ b/target-s390x/ioinst.c @@ -1,7 +1,7 @@ /* * I/O instructions for S/390 * - * Copyright 2012 IBM Corp. + * Copyright 2012, 2015 IBM Corp. * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> * * This work is licensed under the terms of the GNU GPL, version 2 or (at @@ -144,11 +144,10 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) { int cssid, ssid, schid, m; SubchDev *sch; - SCHIB *schib; + SCHIB schib; uint64_t addr; int ret = -ENODEV; int cc; - hwaddr len = sizeof(*schib); CPUS390XState *env = &cpu->env; addr = decode_basedisp_s(env, ipb); @@ -156,20 +155,18 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) program_interrupt(env, PGM_SPECIFICATION, 2); return; } - schib = s390_cpu_physical_memory_map(env, addr, &len, 0); - if (!schib || len != sizeof(*schib)) { - program_interrupt(env, PGM_ADDRESSING, 2); - goto out; + if (s390_cpu_virt_mem_read(cpu, addr, &schib, sizeof(schib))) { + return; } if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) || - !ioinst_schib_valid(schib)) { + !ioinst_schib_valid(&schib)) { program_interrupt(env, PGM_OPERAND, 2); - goto out; + return; } trace_ioinst_sch_id("msch", cssid, ssid, schid); sch = css_find_subch(m, cssid, ssid, schid); if (sch && css_subch_visible(sch)) { - ret = css_do_msch(sch, schib); + ret = css_do_msch(sch, &schib); } switch (ret) { case -ENODEV: @@ -186,9 +183,6 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) break; } setcc(cpu, cc); - -out: - s390_cpu_physical_memory_unmap(env, schib, len, 0); } static void copy_orb_from_guest(ORB *dest, const ORB *src) @@ -216,11 +210,10 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) { int cssid, ssid, schid, m; SubchDev *sch; - ORB *orig_orb, orb; + ORB orig_orb, orb; uint64_t addr; int ret = -ENODEV; int cc; - hwaddr len = sizeof(*orig_orb); CPUS390XState *env = &cpu->env; addr = decode_basedisp_s(env, ipb); @@ -228,16 +221,14 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) program_interrupt(env, PGM_SPECIFICATION, 2); return; } - orig_orb = s390_cpu_physical_memory_map(env, addr, &len, 0); - if (!orig_orb || len != sizeof(*orig_orb)) { - program_interrupt(env, PGM_ADDRESSING, 2); - goto out; + if (s390_cpu_virt_mem_read(cpu, addr, &orig_orb, sizeof(orb))) { + return; } - copy_orb_from_guest(&orb, orig_orb); + copy_orb_from_guest(&orb, &orig_orb); if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) || !ioinst_orb_valid(&orb)) { program_interrupt(env, PGM_OPERAND, 2); - goto out; + return; } trace_ioinst_sch_id("ssch", cssid, ssid, schid); sch = css_find_subch(m, cssid, ssid, schid); @@ -259,17 +250,13 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) break; } setcc(cpu, cc); - -out: - s390_cpu_physical_memory_unmap(env, orig_orb, len, 0); } void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb) { - CRW *crw; + CRW crw; uint64_t addr; int cc; - hwaddr len = sizeof(*crw); CPUS390XState *env = &cpu->env; addr = decode_basedisp_s(env, ipb); @@ -277,17 +264,16 @@ void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb) program_interrupt(env, PGM_SPECIFICATION, 2); return; } - crw = s390_cpu_physical_memory_map(env, addr, &len, 1); - if (!crw || len != sizeof(*crw)) { - program_interrupt(env, PGM_ADDRESSING, 2); - goto out; - } - cc = css_do_stcrw(crw); + + cc = css_do_stcrw(&crw); /* 0 - crw stored, 1 - zeroes stored */ - setcc(cpu, cc); -out: - s390_cpu_physical_memory_unmap(env, crw, len, 1); + if (s390_cpu_virt_mem_write(cpu, addr, &crw, sizeof(crw)) == 0) { + setcc(cpu, cc); + } else if (cc == 0) { + /* Write failed: requeue CRW since STCRW is a suppressing instruction */ + css_undo_stcrw(&crw); + } } void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) @@ -296,8 +282,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) SubchDev *sch; uint64_t addr; int cc; - SCHIB *schib; - hwaddr len = sizeof(*schib); + SCHIB schib; CPUS390XState *env = &cpu->env; addr = decode_basedisp_s(env, ipb); @@ -305,21 +290,23 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) program_interrupt(env, PGM_SPECIFICATION, 2); return; } - schib = s390_cpu_physical_memory_map(env, addr, &len, 1); - if (!schib || len != sizeof(*schib)) { - program_interrupt(env, PGM_ADDRESSING, 2); - goto out; - } if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(env, PGM_OPERAND, 2); - goto out; + /* + * As operand exceptions have a lower priority than access exceptions, + * we check whether the memory area is writeable (injecting the + * access execption if it is not) first. + */ + if (!s390_cpu_virt_mem_check_write(cpu, addr, sizeof(schib))) { + program_interrupt(env, PGM_OPERAND, 2); + } + return; } trace_ioinst_sch_id("stsch", cssid, ssid, schid); sch = css_find_subch(m, cssid, ssid, schid); if (sch) { if (css_subch_visible(sch)) { - css_do_stsch(sch, schib); + css_do_stsch(sch, &schib); cc = 0; } else { /* Indicate no more subchannels in this css/ss */ @@ -330,25 +317,31 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) cc = 3; /* No more subchannels in this css/ss */ } else { /* Store an empty schib. */ - memset(schib, 0, sizeof(*schib)); + memset(&schib, 0, sizeof(schib)); cc = 0; } } + if (cc != 3) { + if (s390_cpu_virt_mem_write(cpu, addr, &schib, sizeof(schib)) != 0) { + return; + } + } else { + /* Access exceptions have a higher priority than cc3 */ + if (s390_cpu_virt_mem_check_write(cpu, addr, sizeof(schib)) != 0) { + return; + } + } setcc(cpu, cc); - -out: - s390_cpu_physical_memory_unmap(env, schib, len, 1); } -int ioinst_handle_tsch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) +int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) { + CPUS390XState *env = &cpu->env; int cssid, ssid, schid, m; SubchDev *sch; - IRB *irb; + IRB irb; uint64_t addr; - int ret = -ENODEV; - int cc; - hwaddr len = sizeof(*irb); + int cc, irb_len; if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(env, PGM_OPERAND, 2); @@ -360,23 +353,29 @@ int ioinst_handle_tsch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } - irb = s390_cpu_physical_memory_map(env, addr, &len, 1); - if (!irb || len != sizeof(*irb)) { - program_interrupt(env, PGM_ADDRESSING, 2); - cc = -EIO; - goto out; - } + sch = css_find_subch(m, cssid, ssid, schid); if (sch && css_subch_visible(sch)) { - ret = css_do_tsch(sch, irb); - /* 0 - status pending, 1 - not status pending */ - cc = ret; + cc = css_do_tsch_get_irb(sch, &irb, &irb_len); } else { cc = 3; } -out: - s390_cpu_physical_memory_unmap(env, irb, sizeof(*irb), 1); - return cc; + /* 0 - status pending, 1 - not status pending, 3 - not operational */ + if (cc != 3) { + if (s390_cpu_virt_mem_write(cpu, addr, &irb, irb_len) != 0) { + return -EFAULT; + } + css_do_tsch_update_subch(sch); + } else { + irb_len = sizeof(irb) - sizeof(irb.emw); + /* Access exceptions have a higher priority than cc3 */ + if (s390_cpu_virt_mem_check_write(cpu, addr, irb_len) != 0) { + return -EFAULT; + } + } + + setcc(cpu, cc); + return 0; } typedef struct ChscReq { @@ -630,8 +629,8 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb) int reg; uint16_t len; uint16_t command; - hwaddr map_size = TARGET_PAGE_SIZE; CPUS390XState *env = &cpu->env; + uint8_t buf[TARGET_PAGE_SIZE]; trace_ioinst("chsc"); reg = (ipb >> 20) & 0x00f; @@ -641,16 +640,20 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb) program_interrupt(env, PGM_SPECIFICATION, 2); return; } - req = s390_cpu_physical_memory_map(env, addr, &map_size, 1); - if (!req || map_size != TARGET_PAGE_SIZE) { - program_interrupt(env, PGM_ADDRESSING, 2); - goto out; + /* + * Reading sizeof(ChscReq) bytes is currently enough for all of our + * present CHSC sub-handlers ... if we ever need more, we should take + * care of req->len here first. + */ + if (s390_cpu_virt_mem_read(cpu, addr, buf, sizeof(ChscReq))) { + return; } + req = (ChscReq *)buf; len = be16_to_cpu(req->len); /* Length field valid? */ if ((len < 16) || (len > 4088) || (len & 7)) { program_interrupt(env, PGM_OPERAND, 2); - goto out; + return; } memset((char *)req + len, 0, TARGET_PAGE_SIZE - len); res = (void *)((char *)req + len); @@ -674,17 +677,18 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb) break; } - setcc(cpu, 0); /* Command execution complete */ -out: - s390_cpu_physical_memory_unmap(env, req, map_size, 1); + if (!s390_cpu_virt_mem_write(cpu, addr + len, res, be16_to_cpu(res->len))) { + setcc(cpu, 0); /* Command execution complete */ + } } -int ioinst_handle_tpi(CPUS390XState *env, uint32_t ipb) +int ioinst_handle_tpi(S390CPU *cpu, uint32_t ipb) { + CPUS390XState *env = &cpu->env; uint64_t addr; int lowcore; - IOIntCode *int_code; - hwaddr len, orig_len; + IOIntCode int_code; + hwaddr len; int ret; trace_ioinst("tpi"); @@ -696,16 +700,10 @@ int ioinst_handle_tpi(CPUS390XState *env, uint32_t ipb) lowcore = addr ? 0 : 1; len = lowcore ? 8 /* two words */ : 12 /* three words */; - orig_len = len; - int_code = s390_cpu_physical_memory_map(env, addr, &len, 1); - if (!int_code || (len != orig_len)) { - program_interrupt(env, PGM_ADDRESSING, 2); - ret = -EIO; - goto out; + ret = css_do_tpi(&int_code, lowcore); + if (ret == 1) { + s390_cpu_virt_mem_write(cpu, lowcore ? 184 : addr, &int_code, len); } - ret = css_do_tpi(int_code, lowcore); -out: - s390_cpu_physical_memory_unmap(env, int_code, len, 1); return ret; } diff --git a/target-s390x/ioinst.h b/target-s390x/ioinst.h index 1efe16c..203bdba 100644 --- a/target-s390x/ioinst.h +++ b/target-s390x/ioinst.h @@ -234,9 +234,9 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb); void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb); void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb); void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb); -int ioinst_handle_tsch(CPUS390XState *env, uint64_t reg1, uint32_t ipb); +int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb); void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb); -int ioinst_handle_tpi(CPUS390XState *env, uint32_t ipb); +int ioinst_handle_tpi(S390CPU *cpu, uint32_t ipb); void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, uint64_t reg2, uint32_t ipb); void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1); diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 6f2d5b4..d7c57d9 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -42,6 +42,7 @@ #include "qapi-event.h" #include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-bus.h" +#include "hw/s390x/ipl.h" /* #define DEBUG_KVM */ @@ -756,6 +757,18 @@ static void enter_pgmcheck(S390CPU *cpu, uint16_t code) kvm_s390_vcpu_interrupt(cpu, &irq); } +void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code) +{ + struct kvm_s390_irq irq = { + .type = KVM_S390_PROGRAM_INT, + .u.pgm.code = code, + .u.pgm.trans_exc_code = te_code, + .u.pgm.exc_access_id = te_code & 3, + }; + + kvm_s390_vcpu_interrupt(cpu, &irq); +} + static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run, uint16_t ipbh0) { @@ -1325,19 +1338,14 @@ static int handle_intercept(S390CPU *cpu) static int handle_tsch(S390CPU *cpu) { - CPUS390XState *env = &cpu->env; CPUState *cs = CPU(cpu); struct kvm_run *run = cs->kvm_run; int ret; cpu_synchronize_state(cs); - ret = ioinst_handle_tsch(env, env->regs[1], run->s390_tsch.ipb); - if (ret >= 0) { - /* Success; set condition code. */ - setcc(cpu, ret); - ret = 0; - } else if (ret < -1) { + ret = ioinst_handle_tsch(cpu, cpu->env.regs[1], run->s390_tsch.ipb); + if (ret < 0) { /* * Failure. * If an I/O interrupt had been dequeued, we have to reinject it. @@ -1397,7 +1405,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) ret = handle_intercept(cpu); break; case KVM_EXIT_S390_RESET: - qemu_system_reset_request(); + s390_reipl_request(); break; case KVM_EXIT_S390_TSCH: ret = handle_tsch(cpu); diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c index d67b345..0e8cd0f 100644 --- a/target-s390x/mem_helper.c +++ b/target-s390x/mem_helper.c @@ -65,7 +65,7 @@ static void mvc_fast_memset(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t asc = env->psw.mask & PSW_MASK_ASC; int flags; - if (mmu_translate(env, dest, 1, asc, &dest_phys, &flags)) { + if (mmu_translate(env, dest, 1, asc, &dest_phys, &flags, true)) { cpu_stb_data(env, dest, byte); cpu_abort(CPU(cpu), "should never reach here"); } @@ -90,13 +90,13 @@ static void mvc_fast_memmove(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t asc = env->psw.mask & PSW_MASK_ASC; int flags; - if (mmu_translate(env, dest, 1, asc, &dest_phys, &flags)) { + if (mmu_translate(env, dest, 1, asc, &dest_phys, &flags, true)) { cpu_stb_data(env, dest, 0); cpu_abort(CPU(cpu), "should never reach here"); } dest_phys |= dest & ~TARGET_PAGE_MASK; - if (mmu_translate(env, src, 0, asc, &src_phys, &flags)) { + if (mmu_translate(env, src, 0, asc, &src_phys, &flags, true)) { cpu_ldub_data(env, src); cpu_abort(CPU(cpu), "should never reach here"); } @@ -967,12 +967,12 @@ static uint32_t mvc_asc(CPUS390XState *env, int64_t l, uint64_t a1, cc = 3; } - if (mmu_translate(env, a1 & TARGET_PAGE_MASK, 1, mode1, &dest, &flags)) { + if (mmu_translate(env, a1, 1, mode1, &dest, &flags, true)) { cpu_loop_exit(CPU(s390_env_get_cpu(env))); } dest |= a1 & ~TARGET_PAGE_MASK; - if (mmu_translate(env, a2 & TARGET_PAGE_MASK, 0, mode2, &src, &flags)) { + if (mmu_translate(env, a2, 0, mode2, &src, &flags, true)) { cpu_loop_exit(CPU(s390_env_get_cpu(env))); } src |= a2 & ~TARGET_PAGE_MASK; @@ -1088,7 +1088,7 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr) } cs->exception_index = old_exc; - if (mmu_translate(env, addr, 0, asc, &ret, &flags)) { + if (mmu_translate(env, addr, 0, asc, &ret, &flags, true)) { cc = 3; } if (cs->exception_index == EXCP_PGM) { diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index ef9758a..1c3df8e 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -25,6 +25,7 @@ #include <string.h> #include "sysemu/kvm.h" #include "qemu/timer.h" +#include "exec/address-spaces.h" #ifdef CONFIG_KVM #include <linux/kvm.h> #endif @@ -34,6 +35,7 @@ #include "sysemu/cpus.h" #include "sysemu/sysemu.h" #include "hw/s390x/ebcdic.h" +#include "hw/s390x/ipl.h" #endif /* #define DEBUG_HELPER */ @@ -151,12 +153,15 @@ static int load_normal_reset(S390CPU *cpu) return 0; } +#define DIAG_308_RC_OK 0x0001 #define DIAG_308_RC_NO_CONF 0x0102 #define DIAG_308_RC_INVALID 0x0402 + void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3) { uint64_t addr = env->regs[r1]; uint64_t subcode = env->regs[r3]; + IplParameterBlock *iplb; if (env->psw.mask & PSW_MASK_PSTATE) { program_interrupt(env, PGM_PRIVILEGED, ILEN_LATER_INC); @@ -180,14 +185,38 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3) program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER_INC); return; } - env->regs[r1+1] = DIAG_308_RC_INVALID; + if (!address_space_access_valid(&address_space_memory, addr, + sizeof(IplParameterBlock), false)) { + program_interrupt(env, PGM_ADDRESSING, ILEN_LATER_INC); + return; + } + iplb = g_malloc0(sizeof(struct IplParameterBlock)); + cpu_physical_memory_read(addr, iplb, sizeof(struct IplParameterBlock)); + if (!s390_ipl_update_diag308(iplb)) { + env->regs[r1 + 1] = DIAG_308_RC_OK; + } else { + env->regs[r1 + 1] = DIAG_308_RC_INVALID; + } + g_free(iplb); return; case 6: if ((r1 & 1) || (addr & 0x0fffULL)) { program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER_INC); return; } - env->regs[r1+1] = DIAG_308_RC_NO_CONF; + if (!address_space_access_valid(&address_space_memory, addr, + sizeof(IplParameterBlock), true)) { + program_interrupt(env, PGM_ADDRESSING, ILEN_LATER_INC); + return; + } + iplb = s390_ipl_get_iplb(); + if (iplb) { + cpu_physical_memory_write(addr, iplb, + sizeof(struct IplParameterBlock)); + env->regs[r1 + 1] = DIAG_308_RC_OK; + } else { + env->regs[r1 + 1] = DIAG_308_RC_NO_CONF; + } return; default: hw_error("Unhandled diag308 subcode %" PRIx64, subcode); diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c new file mode 100644 index 0000000..b061c85 --- /dev/null +++ b/target-s390x/mmu_helper.c @@ -0,0 +1,472 @@ +/* + * S390x MMU related functions + * + * Copyright (c) 2011 Alexander Graf + * Copyright (c) 2015 Thomas Huth, IBM Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "qemu/error-report.h" +#include "exec/address-spaces.h" +#include "sysemu/kvm.h" +#include "cpu.h" + +/* #define DEBUG_S390 */ +/* #define DEBUG_S390_PTE */ +/* #define DEBUG_S390_STDOUT */ + +#ifdef DEBUG_S390 +#ifdef DEBUG_S390_STDOUT +#define DPRINTF(fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); \ + qemu_log(fmt, ##__VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) \ + do { qemu_log(fmt, ## __VA_ARGS__); } while (0) +#endif +#else +#define DPRINTF(fmt, ...) \ + do { } while (0) +#endif + +#ifdef DEBUG_S390_PTE +#define PTE_DPRINTF DPRINTF +#else +#define PTE_DPRINTF(fmt, ...) \ + do { } while (0) +#endif + +/* Fetch/store bits in the translation exception code: */ +#define FS_READ 0x800 +#define FS_WRITE 0x400 + +static void trigger_access_exception(CPUS390XState *env, uint32_t type, + uint32_t ilen, uint64_t tec) +{ + S390CPU *cpu = s390_env_get_cpu(env); + + if (kvm_enabled()) { + kvm_s390_access_exception(cpu, type, tec); + } else { + CPUState *cs = CPU(cpu); + stq_phys(cs->as, env->psa + offsetof(LowCore, trans_exc_code), tec); + trigger_pgm_exception(env, type, ilen); + } +} + +static void trigger_prot_fault(CPUS390XState *env, target_ulong vaddr, + uint64_t asc, int rw, bool exc) +{ + uint64_t tec; + + tec = vaddr | (rw == 1 ? FS_WRITE : FS_READ) | 4 | asc >> 46; + + DPRINTF("%s: trans_exc_code=%016" PRIx64 "\n", __func__, tec); + + if (!exc) { + return; + } + + trigger_access_exception(env, PGM_PROTECTION, ILEN_LATER_INC, tec); +} + +static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr, + uint32_t type, uint64_t asc, int rw, bool exc) +{ + int ilen = ILEN_LATER; + uint64_t tec; + + tec = vaddr | (rw == 1 ? FS_WRITE : FS_READ) | asc >> 46; + + DPRINTF("%s: vaddr=%016" PRIx64 " bits=%d\n", __func__, vaddr, bits); + + if (!exc) { + return; + } + + /* Code accesses have an undefined ilc. */ + if (rw == 2) { + ilen = 2; + } + + trigger_access_exception(env, type, ilen, tec); +} + +/** + * Translate real address to absolute (= physical) + * address by taking care of the prefix mapping. + */ +static target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr) +{ + if (raddr < 0x2000) { + return raddr + env->psa; /* Map the lowcore. */ + } else if (raddr >= env->psa && raddr < env->psa + 0x2000) { + return raddr - env->psa; /* Map the 0 page. */ + } + return raddr; +} + +/* Decode page table entry (normal 4KB page) */ +static int mmu_translate_pte(CPUS390XState *env, target_ulong vaddr, + uint64_t asc, uint64_t pt_entry, + target_ulong *raddr, int *flags, int rw, bool exc) +{ + if (pt_entry & _PAGE_INVALID) { + DPRINTF("%s: PTE=0x%" PRIx64 " invalid\n", __func__, pt_entry); + trigger_page_fault(env, vaddr, PGM_PAGE_TRANS, asc, rw, exc); + return -1; + } + if (pt_entry & _PAGE_RES0) { + trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw, exc); + return -1; + } + if (pt_entry & _PAGE_RO) { + *flags &= ~PAGE_WRITE; + } + + *raddr = pt_entry & _ASCE_ORIGIN; + + PTE_DPRINTF("%s: PTE=0x%" PRIx64 "\n", __func__, pt_entry); + + return 0; +} + +#define VADDR_PX 0xff000 /* Page index bits */ + +/* Decode segment table entry */ +static int mmu_translate_segment(CPUS390XState *env, target_ulong vaddr, + uint64_t asc, uint64_t st_entry, + target_ulong *raddr, int *flags, int rw, + bool exc) +{ + CPUState *cs = CPU(s390_env_get_cpu(env)); + uint64_t origin, offs, pt_entry; + + if (st_entry & _SEGMENT_ENTRY_RO) { + *flags &= ~PAGE_WRITE; + } + + if ((st_entry & _SEGMENT_ENTRY_FC) && (env->cregs[0] & CR0_EDAT)) { + /* Decode EDAT1 segment frame absolute address (1MB page) */ + *raddr = (st_entry & 0xfffffffffff00000ULL) | (vaddr & 0xfffff); + PTE_DPRINTF("%s: SEG=0x%" PRIx64 "\n", __func__, st_entry); + return 0; + } + + /* Look up 4KB page entry */ + origin = st_entry & _SEGMENT_ENTRY_ORIGIN; + offs = (vaddr & VADDR_PX) >> 9; + pt_entry = ldq_phys(cs->as, origin + offs); + PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n", + __func__, origin, offs, pt_entry); + return mmu_translate_pte(env, vaddr, asc, pt_entry, raddr, flags, rw, exc); +} + +/* Decode region table entries */ +static int mmu_translate_region(CPUS390XState *env, target_ulong vaddr, + uint64_t asc, uint64_t entry, int level, + target_ulong *raddr, int *flags, int rw, + bool exc) +{ + CPUState *cs = CPU(s390_env_get_cpu(env)); + uint64_t origin, offs, new_entry; + const int pchks[4] = { + PGM_SEGMENT_TRANS, PGM_REG_THIRD_TRANS, + PGM_REG_SEC_TRANS, PGM_REG_FIRST_TRANS + }; + + PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, entry); + + origin = entry & _REGION_ENTRY_ORIGIN; + offs = (vaddr >> (17 + 11 * level / 4)) & 0x3ff8; + + new_entry = ldq_phys(cs->as, origin + offs); + PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n", + __func__, origin, offs, new_entry); + + if ((new_entry & _REGION_ENTRY_INV) != 0) { + DPRINTF("%s: invalid region\n", __func__); + trigger_page_fault(env, vaddr, pchks[level / 4], asc, rw, exc); + return -1; + } + + if ((new_entry & _REGION_ENTRY_TYPE_MASK) != level) { + trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw, exc); + return -1; + } + + if (level == _ASCE_TYPE_SEGMENT) { + return mmu_translate_segment(env, vaddr, asc, new_entry, raddr, flags, + rw, exc); + } + + /* Check region table offset and length */ + offs = (vaddr >> (28 + 11 * (level - 4) / 4)) & 3; + if (offs < ((new_entry & _REGION_ENTRY_TF) >> 6) + || offs > (new_entry & _REGION_ENTRY_LENGTH)) { + DPRINTF("%s: invalid offset or len (%lx)\n", __func__, new_entry); + trigger_page_fault(env, vaddr, pchks[level / 4 - 1], asc, rw, exc); + return -1; + } + + if ((env->cregs[0] & CR0_EDAT) && (new_entry & _REGION_ENTRY_RO)) { + *flags &= ~PAGE_WRITE; + } + + /* yet another region */ + return mmu_translate_region(env, vaddr, asc, new_entry, level - 4, + raddr, flags, rw, exc); +} + +static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr, + uint64_t asc, uint64_t asce, target_ulong *raddr, + int *flags, int rw, bool exc) +{ + int level; + int r; + + if (asce & _ASCE_REAL_SPACE) { + /* direct mapping */ + *raddr = vaddr; + return 0; + } + + level = asce & _ASCE_TYPE_MASK; + switch (level) { + case _ASCE_TYPE_REGION1: + if ((vaddr >> 62) > (asce & _ASCE_TABLE_LENGTH)) { + trigger_page_fault(env, vaddr, PGM_REG_FIRST_TRANS, asc, rw, exc); + return -1; + } + break; + case _ASCE_TYPE_REGION2: + if (vaddr & 0xffe0000000000000ULL) { + DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64 + " 0xffe0000000000000ULL\n", __func__, vaddr); + trigger_page_fault(env, vaddr, PGM_ASCE_TYPE, asc, rw, exc); + return -1; + } + if ((vaddr >> 51 & 3) > (asce & _ASCE_TABLE_LENGTH)) { + trigger_page_fault(env, vaddr, PGM_REG_SEC_TRANS, asc, rw, exc); + return -1; + } + break; + case _ASCE_TYPE_REGION3: + if (vaddr & 0xfffffc0000000000ULL) { + DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64 + " 0xfffffc0000000000ULL\n", __func__, vaddr); + trigger_page_fault(env, vaddr, PGM_ASCE_TYPE, asc, rw, exc); + return -1; + } + if ((vaddr >> 40 & 3) > (asce & _ASCE_TABLE_LENGTH)) { + trigger_page_fault(env, vaddr, PGM_REG_THIRD_TRANS, asc, rw, exc); + return -1; + } + break; + case _ASCE_TYPE_SEGMENT: + if (vaddr & 0xffffffff80000000ULL) { + DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64 + " 0xffffffff80000000ULL\n", __func__, vaddr); + trigger_page_fault(env, vaddr, PGM_ASCE_TYPE, asc, rw, exc); + return -1; + } + if ((vaddr >> 29 & 3) > (asce & _ASCE_TABLE_LENGTH)) { + trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw, exc); + return -1; + } + break; + } + + r = mmu_translate_region(env, vaddr, asc, asce, level, raddr, flags, rw, + exc); + if ((rw == 1) && !(*flags & PAGE_WRITE)) { + trigger_prot_fault(env, vaddr, asc, rw, exc); + return -1; + } + + return r; +} + +/** + * Translate a virtual (logical) address into a physical (absolute) address. + * @param vaddr the virtual address + * @param rw 0 = read, 1 = write, 2 = code fetch + * @param asc address space control (one of the PSW_ASC_* modes) + * @param raddr the translated address is stored to this pointer + * @param flags the PAGE_READ/WRITE/EXEC flags are stored to this pointer + * @param exc true = inject a program check if a fault occured + * @return 0 if the translation was successfull, -1 if a fault occured + */ +int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc, + target_ulong *raddr, int *flags, bool exc) +{ + int r = -1; + uint8_t *sk; + + *flags = PAGE_READ | PAGE_WRITE | PAGE_EXEC; + vaddr &= TARGET_PAGE_MASK; + + if (!(env->psw.mask & PSW_MASK_DAT)) { + *raddr = vaddr; + r = 0; + goto out; + } + + switch (asc) { + case PSW_ASC_PRIMARY: + PTE_DPRINTF("%s: asc=primary\n", __func__); + r = mmu_translate_asce(env, vaddr, asc, env->cregs[1], raddr, flags, + rw, exc); + break; + case PSW_ASC_HOME: + PTE_DPRINTF("%s: asc=home\n", __func__); + r = mmu_translate_asce(env, vaddr, asc, env->cregs[13], raddr, flags, + rw, exc); + break; + case PSW_ASC_SECONDARY: + PTE_DPRINTF("%s: asc=secondary\n", __func__); + /* + * Instruction: Primary + * Data: Secondary + */ + if (rw == 2) { + r = mmu_translate_asce(env, vaddr, PSW_ASC_PRIMARY, env->cregs[1], + raddr, flags, rw, exc); + *flags &= ~(PAGE_READ | PAGE_WRITE); + } else { + r = mmu_translate_asce(env, vaddr, PSW_ASC_SECONDARY, env->cregs[7], + raddr, flags, rw, exc); + *flags &= ~(PAGE_EXEC); + } + break; + case PSW_ASC_ACCREG: + default: + hw_error("guest switched to unknown asc mode\n"); + break; + } + + out: + /* Convert real address -> absolute address */ + *raddr = mmu_real2abs(env, *raddr); + + if (*raddr <= ram_size) { + sk = &env->storage_keys[*raddr / TARGET_PAGE_SIZE]; + if (*flags & PAGE_READ) { + *sk |= SK_R; + } + + if (*flags & PAGE_WRITE) { + *sk |= SK_C; + } + } + + return r; +} + +/** + * lowprot_enabled: Check whether low-address protection is enabled + */ +static bool lowprot_enabled(const CPUS390XState *env) +{ + if (!(env->cregs[0] & CR0_LOWPROT)) { + return false; + } + if (!(env->psw.mask & PSW_MASK_DAT)) { + return true; + } + + /* Check the private-space control bit */ + switch (env->psw.mask & PSW_MASK_ASC) { + case PSW_ASC_PRIMARY: + return !(env->cregs[1] & _ASCE_PRIVATE_SPACE); + case PSW_ASC_SECONDARY: + return !(env->cregs[7] & _ASCE_PRIVATE_SPACE); + case PSW_ASC_HOME: + return !(env->cregs[13] & _ASCE_PRIVATE_SPACE); + default: + /* We don't support access register mode */ + error_report("unsupported addressing mode"); + exit(1); + } +} + +/** + * translate_pages: Translate a set of consecutive logical page addresses + * to absolute addresses + */ +static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages, + target_ulong *pages, bool is_write) +{ + bool lowprot = is_write && lowprot_enabled(&cpu->env); + uint64_t asc = cpu->env.psw.mask & PSW_MASK_ASC; + CPUS390XState *env = &cpu->env; + int ret, i, pflags; + + for (i = 0; i < nr_pages; i++) { + /* Low-address protection? */ + if (lowprot && (addr < 512 || (addr >= 4096 && addr < 4096 + 512))) { + trigger_access_exception(env, PGM_PROTECTION, ILEN_LATER_INC, 0); + return -EACCES; + } + ret = mmu_translate(env, addr, is_write, asc, &pages[i], &pflags, true); + if (ret) { + return ret; + } + if (!address_space_access_valid(&address_space_memory, pages[i], + TARGET_PAGE_SIZE, is_write)) { + program_interrupt(env, PGM_ADDRESSING, 0); + return -EFAULT; + } + addr += TARGET_PAGE_SIZE; + } + + return 0; +} + +/** + * s390_cpu_virt_mem_rw: + * @laddr: the logical start address + * @hostbuf: buffer in host memory. NULL = do only checks w/o copying + * @len: length that should be transfered + * @is_write: true = write, false = read + * Returns: 0 on success, non-zero if an exception occured + * + * Copy from/to guest memory using logical addresses. Note that we inject a + * program interrupt in case there is an error while accessing the memory. + */ +int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf, + int len, bool is_write) +{ + int currlen, nr_pages, i; + target_ulong *pages; + int ret; + + nr_pages = (((laddr & ~TARGET_PAGE_MASK) + len - 1) >> TARGET_PAGE_BITS) + + 1; + pages = g_malloc(nr_pages * sizeof(*pages)); + + ret = translate_pages(cpu, laddr, nr_pages, pages, is_write); + if (ret == 0 && hostbuf != NULL) { + /* Copy data by stepping through the area page by page */ + for (i = 0; i < nr_pages; i++) { + currlen = MIN(len, TARGET_PAGE_SIZE - (laddr % TARGET_PAGE_SIZE)); + cpu_physical_memory_rw(pages[i] | (laddr & ~TARGET_PAGE_MASK), + hostbuf, currlen, is_write); + laddr += currlen; + hostbuf += currlen; + len -= currlen; + } + } + + g_free(pages); + return ret; +} diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c index aa7626c..a952097 100644 --- a/target-sparc/cpu.c +++ b/target-sparc/cpu.c @@ -111,8 +111,7 @@ static int cpu_sparc_register(SPARCCPU *cpu, const char *cpu_model) cc->parse_features(CPU(cpu), featurestr, &err); g_free(s); if (err) { - error_report("%s", error_get_pretty(err)); - error_free(err); + error_report_err(err); return -1; } @@ -162,8 +162,7 @@ static int configure_tpm(QemuOpts *opts) /* validate backend specific opts */ qemu_opts_validate(opts, be->opts, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); return 1; } @@ -174,8 +173,7 @@ static int configure_tpm(QemuOpts *opts) tpm_backend_open(drv, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); return 1; } @@ -526,7 +526,7 @@ MouseInfoList *qmp_query_mice(Error **errp) return mice_list; } -void do_mouse_set(Monitor *mon, const QDict *qdict) +void hmp_mouse_set(Monitor *mon, const QDict *qdict) { QemuInputHandlerState *s; int index = qdict_get_int(qdict, "index"); diff --git a/util/error.c b/util/error.c index 2ace0d8..14f4351 100644 --- a/util/error.c +++ b/util/error.c @@ -41,7 +41,7 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...) err->err_class = err_class; if (errp == &error_abort) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); abort(); } @@ -77,7 +77,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass err_class, err->err_class = err_class; if (errp == &error_abort) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); abort(); } @@ -122,7 +122,7 @@ void error_set_win32(Error **errp, int win32_err, ErrorClass err_class, err->err_class = err_class; if (errp == &error_abort) { - error_report("%s", error_get_pretty(err)); + error_report_err(err); abort(); } @@ -152,6 +152,12 @@ const char *error_get_pretty(Error *err) return err->msg; } +void error_report_err(Error *err) +{ + error_report("%s", error_get_pretty(err)); + error_free(err); +} + void error_free(Error *err) { if (err) { @@ -163,7 +169,7 @@ void error_free(Error *err) void error_propagate(Error **dst_errp, Error *local_err) { if (local_err && dst_errp == &error_abort) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); abort(); } else if (dst_errp && !*dst_errp) { *dst_errp = local_err; diff --git a/util/qemu-config.c b/util/qemu-config.c index ba375c0..b13efe2 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -32,8 +32,7 @@ QemuOptsList *qemu_find_opts(const char *group) ret = find_list(vm_config_groups, group, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); } return ret; @@ -314,8 +313,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) /* group with id */ list = find_list(lists, group, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); goto out; } opts = qemu_opts_create(list, id, 1, NULL); @@ -325,8 +323,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) /* group without id */ list = find_list(lists, group, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); goto out; } opts = qemu_opts_create(list, NULL, 0, &error_abort); @@ -78,6 +78,7 @@ int main(int argc, char **argv) #include "monitor/monitor.h" #include "ui/console.h" #include "sysemu/sysemu.h" +#include "sysemu/numa.h" #include "exec/gdbstub.h" #include "qemu/timer.h" #include "sysemu/char.h" @@ -183,10 +184,6 @@ uint8_t qemu_extra_params_fw[2]; int icount_align_option; -int nb_numa_nodes; -int max_numa_nodeid; -NodeInfo numa_info[MAX_NODES]; - /* The bytes in qemu_uuid[] are in the order specified by RFC4122, _not_ in the * little-endian "wire format" described in the SMBIOS 2.6 specification. */ @@ -1284,7 +1281,7 @@ static int usb_parse(const char *cmdline) return r; } -void do_usb_add(Monitor *mon, const QDict *qdict) +void hmp_usb_add(Monitor *mon, const QDict *qdict) { const char *devname = qdict_get_str(qdict, "devname"); if (usb_device_add(devname) < 0) { @@ -1292,7 +1289,7 @@ void do_usb_add(Monitor *mon, const QDict *qdict) } } -void do_usb_del(Monitor *mon, const QDict *qdict) +void hmp_usb_del(Monitor *mon, const QDict *qdict) { const char *devname = qdict_get_str(qdict, "devname"); if (usb_device_del(devname) < 0) { @@ -2137,8 +2134,7 @@ static int chardev_init_func(QemuOpts *opts, void *opaque) qemu_chr_new_from_opts(opts, NULL, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); return -1; } return 0; @@ -2218,8 +2214,7 @@ static void monitor_parse(const char *optarg, const char *mode, bool pretty) opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, &local_err); if (!opts) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); exit(1); } qemu_opt_set(opts, "mode", mode); @@ -2583,8 +2578,7 @@ static int machine_set_property(const char *name, const char *value, g_free(qom_name); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); + error_report_err(local_err); return -1; } @@ -2637,8 +2631,7 @@ out: g_free(type); g_free(dummy); if (err) { - qerror_report_err(err); - error_free(err); + error_report_err(err); return -1; } return 0; @@ -2820,14 +2813,6 @@ int main(int argc, char **argv, char **envp) cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; - for (i = 0; i < MAX_NODES; i++) { - numa_info[i].node_mem = 0; - numa_info[i].present = false; - bitmap_zero(numa_info[i].node_cpu, MAX_CPUMASK_BITS); - } - - nb_numa_nodes = 0; - max_numa_nodeid = 0; nb_nics = 0; bdrv_init_with_whitelist(); @@ -3766,7 +3751,7 @@ int main(int argc, char **argv, char **envp) os_daemonize(); if (qemu_init_main_loop(&main_loop_err)) { - error_report("%s", error_get_pretty(main_loop_err)); + error_report_err(main_loop_err); exit(1); } @@ -4033,8 +4018,7 @@ int main(int argc, char **argv, char **envp) Error *local_err = NULL; qtest_init(qtest_chrdev, qtest_log, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_report_err(local_err); exit(1); } } @@ -4056,7 +4040,7 @@ int main(int argc, char **argv, char **envp) if (order) { validate_bootdevices(order, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } boot_order = order; @@ -4066,7 +4050,7 @@ int main(int argc, char **argv, char **envp) if (once) { validate_bootdevices(once, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); + error_report_err(local_err); exit(1); } normal_boot_order = g_strdup(boot_order); @@ -4168,12 +4152,7 @@ int main(int argc, char **argv, char **envp) default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); - if (qemu_opts_foreach(qemu_find_opts("numa"), numa_init_func, - NULL, 1) != 0) { - exit(1); - } - - set_numa_nodes(); + parse_numa_opts(); if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) { exit(1); @@ -4232,7 +4211,7 @@ int main(int argc, char **argv, char **envp) cpu_synchronize_all_post_init(); - set_numa_modes(); + numa_post_machine_init(); /* init USB devices */ if (usb_enabled()) { |