X-Git-Url: https://repo.jachan.dev/qemu.git/blobdiff_plain/4acc8fdfd315f7ee474bea28fcbcc4dca9717d13..518cb31fa7d2dd648bc400d68c25e0df8394683f:/hmp.c diff --git a/hmp.c b/hmp.c index 997a768214..cc2056e9e2 100644 --- a/hmp.c +++ b/hmp.c @@ -1077,31 +1077,28 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict) void hmp_drive_mirror(Monitor *mon, const QDict *qdict) { - const char *device = qdict_get_str(qdict, "device"); const char *filename = qdict_get_str(qdict, "target"); const char *format = qdict_get_try_str(qdict, "format"); bool reuse = qdict_get_try_bool(qdict, "reuse", false); bool full = qdict_get_try_bool(qdict, "full", false); - enum NewImageMode mode; Error *err = NULL; + DriveMirror mirror = { + .device = (char *)qdict_get_str(qdict, "device"), + .target = (char *)filename, + .has_format = !!format, + .format = (char *)format, + .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, + .has_mode = true, + .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS, + .unmap = true, + }; if (!filename) { error_setg(&err, QERR_MISSING_PARAMETER, "target"); hmp_handle_error(mon, &err); return; } - - if (reuse) { - mode = NEW_IMAGE_MODE_EXISTING; - } else { - mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; - } - - qmp_drive_mirror(device, filename, !!format, format, - false, NULL, false, NULL, - full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, - true, mode, false, 0, false, 0, false, 0, - false, 0, false, 0, false, true, &err); + qmp_drive_mirror(&mirror, &err); hmp_handle_error(mon, &err); } @@ -1127,7 +1124,7 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; } - qmp_drive_backup(device, filename, !!format, format, + qmp_drive_backup(false, NULL, device, filename, !!format, format, full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, true, mode, false, 0, false, NULL, false, 0, false, 0, &err); @@ -1439,42 +1436,17 @@ void hmp_change(Monitor *mon, const QDict *qdict) void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err = NULL; + BlockIOThrottle throttle = { + .device = (char *) qdict_get_str(qdict, "device"), + .bps = qdict_get_int(qdict, "bps"), + .bps_rd = qdict_get_int(qdict, "bps_rd"), + .bps_wr = qdict_get_int(qdict, "bps_wr"), + .iops = qdict_get_int(qdict, "iops"), + .iops_rd = qdict_get_int(qdict, "iops_rd"), + .iops_wr = qdict_get_int(qdict, "iops_wr"), + }; - qmp_block_set_io_throttle(qdict_get_str(qdict, "device"), - qdict_get_int(qdict, "bps"), - qdict_get_int(qdict, "bps_rd"), - qdict_get_int(qdict, "bps_wr"), - qdict_get_int(qdict, "iops"), - qdict_get_int(qdict, "iops_rd"), - qdict_get_int(qdict, "iops_wr"), - false, /* no burst max via HMP */ - 0, - false, - 0, - false, - 0, - false, - 0, - false, - 0, - false, - 0, - false, /* no burst length via HMP */ - 0, - false, - 0, - false, - 0, - false, - 0, - false, - 0, - false, - 0, - false, /* No default I/O size */ - 0, - false, - NULL, &err); + qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } @@ -1485,7 +1457,7 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict) const char *base = qdict_get_try_str(qdict, "base"); int64_t speed = qdict_get_try_int(qdict, "speed", 0); - qmp_block_stream(device, base != NULL, base, false, NULL, + qmp_block_stream(false, NULL, device, base != NULL, base, false, NULL, qdict_haskey(qdict, "speed"), speed, true, BLOCKDEV_ON_ERROR_REPORT, &error); @@ -1722,7 +1694,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict) { Error *err = NULL; QemuOpts *opts; - OptsVisitor *ov; + Visitor *v; Object *obj = NULL; opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err); @@ -1731,9 +1703,9 @@ void hmp_object_add(Monitor *mon, const QDict *qdict) return; } - ov = opts_visitor_new(opts); - obj = user_creatable_add(qdict, opts_get_visitor(ov), &err); - opts_visitor_cleanup(ov); + v = opts_visitor_new(opts); + obj = user_creatable_add(qdict, v, &err); + visit_free(v); qemu_opts_del(opts); if (err) { @@ -1983,15 +1955,14 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) Error *err = NULL; MemdevList *memdev_list = qmp_query_memdev(&err); MemdevList *m = memdev_list; - StringOutputVisitor *ov; + Visitor *v; char *str; int i = 0; while (m) { - ov = string_output_visitor_new(false); - visit_type_uint16List(string_output_get_visitor(ov), NULL, - &m->value->host_nodes, NULL); + v = string_output_visitor_new(false, &str); + visit_type_uint16List(v, NULL, &m->value->host_nodes, NULL); monitor_printf(mon, "memory backend: %d\n", i); monitor_printf(mon, " size: %" PRId64 "\n", m->value->size); monitor_printf(mon, " merge: %s\n", @@ -2002,11 +1973,11 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) m->value->prealloc ? "true" : "false"); monitor_printf(mon, " policy: %s\n", HostMemPolicy_lookup[m->value->policy]); - str = string_output_get_string(ov); + visit_complete(v, &str); monitor_printf(mon, " host nodes: %s\n", str); g_free(str); - string_output_visitor_cleanup(ov); + visit_free(v); m = m->next; i++; } @@ -2457,17 +2428,17 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict) c = l->value->props; monitor_printf(mon, " CPUInstance Properties:\n"); - if (c->has_node) { - monitor_printf(mon, " node: \"%" PRIu64 "\"\n", c->node); + if (c->has_node_id) { + monitor_printf(mon, " node-id: \"%" PRIu64 "\"\n", c->node_id); } - if (c->has_socket) { - monitor_printf(mon, " socket: \"%" PRIu64 "\"\n", c->socket); + if (c->has_socket_id) { + monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->socket_id); } - if (c->has_core) { - monitor_printf(mon, " core: \"%" PRIu64 "\"\n", c->core); + if (c->has_core_id) { + monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id); } - if (c->has_thread) { - monitor_printf(mon, " thread: \"%" PRIu64 "\"\n", c->thread); + if (c->has_thread_id) { + monitor_printf(mon, " thread-id: \"%" PRIu64 "\"\n", c->thread_id); } l = l->next;