@samitouri / QOSamiQemu / commits / e1212b5181

monitor: Rename MonitorHMP @mon -> @hmp

Mechanical change to sanitize using the following patterns: MonitorQMP *qmp MonitorHMP *hmp Monitor *mon Rename @mon (and @hmp_mon) as @hmp when the type is MonitorHMP. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Message-Id: <20260812211708.92824-19-philmd@oss.qualcomm.com> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Philippe Mathieu-Daudé committed Aug 12, 2026 at 19:48 UTC e1212b51811bf95eaf384a9a97c481a2b888e03b
5 files changed +76 -75
include/monitor/monitor.h
+2 -2
@@ -55,8 +55,8 @@ void monitor_flush_locked(Monitor *mon);
55
56 void *gpa2hva(MemoryRegion **p_mr, hwaddr addr, uint64_t size, Error **errp);
57
58 -void monitor_read_command(MonitorHMP *mon, int show_prompt);
59 -int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
58 +void monitor_read_command(MonitorHMP *hmp, int show_prompt);
59 +int monitor_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
60 void *opaque);
61
62 AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
monitor/hmp-cmds.c
+3 -3
@@ -290,16 +290,16 @@ void hmp_info_sync_profile(Monitor *mon, const QDict *qdict)
290
291 void hmp_info_history(Monitor *mon, const QDict *qdict)
292 {
293 - MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, parent_obj);
293 + MonitorHMP *hmp = container_of(mon, MonitorHMP, parent_obj);
294 int i;
295 const char *str;
296
297 - if (!hmp_mon->rs) {
297 + if (!hmp->rs) {
298 return;
299 }
300 i = 0;
301 for(;;) {
302 - str = readline_get_history(hmp_mon->rs, i);
302 + str = readline_get_history(hmp->rs, i);
303 if (!str) {
304 break;
305 }
monitor/hmp.c
+68 -67
@@ -49,24 +49,24 @@ OBJECT_DEFINE_TYPE(MonitorHMP, monitor_hmp, MONITOR_HMP, MONITOR);
49
50 static void monitor_hmp_finalize(Object *obj)
51 {
52 - MonitorHMP *mon = MONITOR_HMP(obj);
53 - if (mon->rs) {
54 - readline_free(mon->rs);
52 + MonitorHMP *hmp = MONITOR_HMP(obj);
53 + if (hmp->rs) {
54 + readline_free(hmp->rs);
55 }
56 }
57
58 static bool monitor_hmp_get_readline(Object *obj, Error **errp)
59 {
60 - MonitorHMP *mon = MONITOR_HMP(obj);
60 + MonitorHMP *hmp = MONITOR_HMP(obj);
61
62 - return mon->use_readline;
62 + return hmp->use_readline;
63 }
64
65 static void monitor_hmp_set_readline(Object *obj, bool val, Error **errp)
66 {
67 - MonitorHMP *mon = MONITOR_HMP(obj);
67 + MonitorHMP *hmp = MONITOR_HMP(obj);
68
69 - mon->use_readline = val;
69 + hmp->use_readline = val;
70 }
71
72 int monitor_hmp_vprintf(Monitor *mon, const char *fmt, va_list ap)
@@ -128,34 +128,34 @@ static void monitor_hmp_accept_input(Monitor *mon)
128 static void monitor_command_cb(void *opaque, const char *cmdline,
129 void *readline_opaque)
130 {
131 - MonitorHMP *mon = opaque;
131 + MonitorHMP *hmp = opaque;
132
133 - monitor_suspend(&mon->parent_obj);
134 - handle_hmp_command(mon, cmdline);
135 - monitor_resume(&mon->parent_obj);
133 + monitor_suspend(&hmp->parent_obj);
134 + handle_hmp_command(hmp, cmdline);
135 + monitor_resume(&hmp->parent_obj);
136 }
137
138 -void monitor_read_command(MonitorHMP *mon, int show_prompt)
138 +void monitor_read_command(MonitorHMP *hmp, int show_prompt)
139 {
140 - if (!mon->rs) {
140 + if (!hmp->rs) {
141 return;
142 }
143
144 - readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL);
144 + readline_start(hmp->rs, "(qemu) ", 0, monitor_command_cb, NULL);
145 if (show_prompt) {
146 - readline_show_prompt(mon->rs);
146 + readline_show_prompt(hmp->rs);
147 }
148 }
149
150 -int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
150 +int monitor_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
151 void *opaque)
152 {
153 - if (mon->rs) {
154 - readline_start(mon->rs, "Password: ", 1, readline_func, opaque);
153 + if (hmp->rs) {
154 + readline_start(hmp->rs, "Password: ", 1, readline_func, opaque);
155 /* prompt is printed on return from the command handler */
156 return 0;
157 } else {
158 - monitor_printf(&mon->parent_obj,
158 + monitor_printf(&hmp->parent_obj,
159 "terminal does not support password prompting\n");
160 return -ENOTTY;
161 }
@@ -772,12 +772,12 @@ static const HMPCommand *search_dispatch_table(const HMPCommand *disp_table,
772 * Do not assume the return value points into @table! It doesn't when
773 * the command is found in a sub-command table.
774 */
775 -static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,
775 +static const HMPCommand *monitor_parse_command(MonitorHMP *hmp,
776 const char *cmdp_start,
777 const char **cmdp,
778 HMPCommand *table)
779 {
780 - Monitor *mon = &hmp_mon->parent_obj;
780 + Monitor *mon = &hmp->parent_obj;
781 const char *p;
782 const HMPCommand *cmd;
783 char cmdname[256];
@@ -809,7 +809,7 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,
809 *cmdp = p;
810 /* search sub command */
811 if (cmd->sub_table != NULL && *p != '\0') {
812 - return monitor_parse_command(hmp_mon, cmdp_start, cmdp, cmd->sub_table);
812 + return monitor_parse_command(hmp, cmdp_start, cmdp, cmd->sub_table);
813 }
814
815 return cmd;
@@ -1254,15 +1254,15 @@ static void handle_hmp_command_co(void *opaque)
1254 data->done = true;
1255 }
1256
1257 -void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
1257 +void handle_hmp_command(MonitorHMP *hmp, const char *cmdline)
1258 {
1259 QDict *qdict;
1260 const HMPCommand *cmd;
1261 const char *cmd_start = cmdline;
1262
1263 - trace_handle_hmp_command(mon, cmdline);
1263 + trace_handle_hmp_command(hmp, cmdline);
1264
1265 - cmd = monitor_parse_command(mon, cmdline, &cmdline,
1265 + cmd = monitor_parse_command(hmp, cmdline, &cmdline,
1266 hmp_cmds_for_target(false));
1267 if (!cmd) {
1268 return;
@@ -1270,17 +1270,17 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
1270
1271 if (!cmd->cmd && !cmd->cmd_info_hrt) {
1272 /* FIXME: is it useful to try autoload modules here ??? */
1273 - monitor_printf(&mon->parent_obj, "Command \"%.*s\" is not available.\n",
1273 + monitor_printf(&hmp->parent_obj, "Command \"%.*s\" is not available.\n",
1274 (int)(cmdline - cmd_start), cmd_start);
1275 return;
1276 }
1277
1278 - qdict = monitor_parse_arguments(&mon->parent_obj, &cmdline, cmd);
1278 + qdict = monitor_parse_arguments(&hmp->parent_obj, &cmdline, cmd);
1279 if (!qdict) {
1280 while (cmdline > cmd_start && qemu_isspace(cmdline[-1])) {
1281 cmdline--;
1282 }
1283 - monitor_printf(&mon->parent_obj,
1283 + monitor_printf(&hmp->parent_obj,
1284 "Try \"help %.*s\" for more information\n",
1285 (int)(cmdline - cmd_start), cmd_start);
1286 return;
@@ -1289,18 +1289,18 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
1289 if (!cmd->coroutine) {
1290 /* old_mon is non-NULL when called from qmp_human_monitor_command() */
1291 Monitor *old_mon = monitor_set_cur(qemu_coroutine_self(),
1292 - &mon->parent_obj);
1293 - handle_hmp_command_exec(&mon->parent_obj, cmd, qdict);
1292 + &hmp->parent_obj);
1293 + handle_hmp_command_exec(&hmp->parent_obj, cmd, qdict);
1294 monitor_set_cur(qemu_coroutine_self(), old_mon);
1295 } else {
1296 HandleHmpCommandCo data = {
1297 - .mon = &mon->parent_obj,
1297 + .mon = &hmp->parent_obj,
1298 .cmd = cmd,
1299 .qdict = qdict,
1300 .done = false,
1301 };
1302 Coroutine *co = qemu_coroutine_create(handle_hmp_command_co, &data);
1303 - monitor_set_cur(co, &mon->parent_obj);
1303 + monitor_set_cur(co, &hmp->parent_obj);
1304 aio_co_enter(qemu_get_aio_context(), co);
1305 AIO_WAIT_WHILE_UNLOCKED(NULL, !data.done);
1306 }
@@ -1308,7 +1308,8 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
1308 qobject_unref(qdict);
1309 }
1310
1311 -static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
1311 +static void cmd_completion(MonitorHMP *hmp,
1312 + const char *name, const char *list)
1313 {
1314 const char *p, *pstart;
1315 char cmd[128];
@@ -1324,7 +1325,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
1325 }
1326 memcpy(cmd, pstart, len);
1327 cmd[len] = '\0';
1327 - readline_add_completion_of(mon->rs, name, cmd);
1328 + readline_add_completion_of(hmp->rs, name, cmd);
1329 if (*p == '\0') {
1330 break;
1331 }
@@ -1332,7 +1333,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
1333 }
1334 }
1335
1335 -static void file_completion(MonitorHMP *mon, const char *input)
1336 +static void file_completion(MonitorHMP *hmp, const char *input)
1337 {
1338 DIR *ffs;
1339 struct dirent *d;
@@ -1384,7 +1385,7 @@ static void file_completion(MonitorHMP *mon, const char *input)
1385 if (stat(file, &sb) == 0 && S_ISDIR(sb.st_mode)) {
1386 pstrcat(file, sizeof(file), "/");
1387 }
1387 - readline_add_completion(mon->rs, file);
1388 + readline_add_completion(hmp->rs, file);
1389 }
1390 }
1391 closedir(ffs);
@@ -1396,7 +1397,7 @@ static const char *next_arg_type(const char *typestr)
1397 return (p != NULL ? ++p : typestr);
1398 }
1399
1399 -static void monitor_find_completion_by_table(MonitorHMP *mon,
1400 +static void monitor_find_completion_by_table(MonitorHMP *hmp,
1401 const HMPCommand *cmd_table,
1402 char **args,
1403 int nb_args)
@@ -1414,10 +1415,10 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
1415 } else {
1416 cmdname = args[0];
1417 }
1417 - readline_set_completion_index(mon->rs, strlen(cmdname));
1418 + readline_set_completion_index(hmp->rs, strlen(cmdname));
1419 for (cmd = cmd_table; cmd->name != NULL; cmd++) {
1420 if (cmd_available(cmd)) {
1420 - cmd_completion(mon, cmdname, cmd->name);
1421 + cmd_completion(hmp, cmdname, cmd->name);
1422 }
1423 }
1424 } else {
@@ -1434,12 +1435,12 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
1435
1436 if (cmd->sub_table) {
1437 /* do the job again */
1437 - monitor_find_completion_by_table(mon, cmd->sub_table,
1438 + monitor_find_completion_by_table(hmp, cmd->sub_table,
1439 &args[1], nb_args - 1);
1440 return;
1441 }
1442 if (cmd->command_completion) {
1442 - cmd->command_completion(mon->rs, nb_args, args[nb_args - 1]);
1443 + cmd->command_completion(hmp->rs, nb_args, args[nb_args - 1]);
1444 return;
1445 }
1446
@@ -1461,20 +1462,20 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
1462 switch (*ptype) {
1463 case 'F':
1464 /* file completion */
1464 - readline_set_completion_index(mon->rs, strlen(str));
1465 - file_completion(mon, str);
1465 + readline_set_completion_index(hmp->rs, strlen(str));
1466 + file_completion(hmp, str);
1467 break;
1468 case 'B':
1469 /* block device name completion */
1469 - readline_set_completion_index(mon->rs, strlen(str));
1470 + readline_set_completion_index(hmp->rs, strlen(str));
1471 while ((blk = blk_next(blk)) != NULL) {
1471 - readline_add_completion_of(mon->rs, str, blk_name(blk));
1472 + readline_add_completion_of(hmp->rs, str, blk_name(blk));
1473 }
1474 break;
1475 case 's':
1476 case 'S':
1477 if (!strcmp(cmd->name, "help|?")) {
1477 - monitor_find_completion_by_table(mon, cmd_table,
1478 + monitor_find_completion_by_table(hmp, cmd_table,
1479 &args[1], nb_args - 1);
1480 }
1481 break;
@@ -1487,7 +1488,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
1488 static void monitor_find_completion(void *opaque,
1489 const char *cmdline)
1490 {
1490 - MonitorHMP *mon = opaque;
1491 + MonitorHMP *hmp = opaque;
1492 char *args[MAX_ARGS];
1493 int nb_args, len;
1494
@@ -1509,7 +1510,7 @@ static void monitor_find_completion(void *opaque,
1510 }
1511
1512 /* 2. auto complete according to args */
1512 - monitor_find_completion_by_table(mon, hmp_cmds_for_target(false),
1513 + monitor_find_completion_by_table(hmp, hmp_cmds_for_target(false),
1514 args, nb_args);
1515
1516 cleanup:
@@ -1518,18 +1519,18 @@ cleanup:
1519
1520 static void monitor_read(void *opaque, const uint8_t *buf, int size)
1521 {
1521 - MonitorHMP *mon = container_of(opaque, MonitorHMP, parent_obj);
1522 + MonitorHMP *hmp = container_of(opaque, MonitorHMP, parent_obj);
1523 int i;
1524
1524 - if (mon->rs) {
1525 + if (hmp->rs) {
1526 for (i = 0; i < size; i++) {
1526 - readline_handle_byte(mon->rs, buf[i]);
1527 + readline_handle_byte(hmp->rs, buf[i]);
1528 }
1529 } else {
1530 if (size == 0 || buf[size - 1] != 0) {
1530 - monitor_printf(&mon->parent_obj, "corrupted command\n");
1531 + monitor_printf(&hmp->parent_obj, "corrupted command\n");
1532 } else {
1532 - handle_hmp_command(mon, (char *)buf);
1533 + handle_hmp_command(hmp, (char *)buf);
1534 }
1535 }
1536 }
@@ -1598,17 +1599,17 @@ static void monitor_event(void *opaque, QEMUChrEvent event)
1599 static void G_GNUC_PRINTF(2, 3) monitor_readline_printf(void *opaque,
1600 const char *fmt, ...)
1601 {
1601 - MonitorHMP *mon = opaque;
1602 + MonitorHMP *hmp = opaque;
1603 va_list ap;
1604 va_start(ap, fmt);
1604 - monitor_vprintf(&mon->parent_obj, fmt, ap);
1605 + monitor_vprintf(&hmp->parent_obj, fmt, ap);
1606 va_end(ap);
1607 }
1608
1609 static void monitor_readline_flush(void *opaque)
1610 {
1610 - MonitorHMP *mon = opaque;
1611 - monitor_flush(&mon->parent_obj);
1611 + MonitorHMP *hmp = opaque;
1612 + monitor_flush(&hmp->parent_obj);
1613 }
1614
1615 void monitor_new_hmp(const char *id, const char *chardev_id,
@@ -1626,11 +1627,11 @@ void monitor_new_hmp(const char *id, const char *chardev_id,
1627
1628 static void monitor_hmp_complete(UserCreatable *uc, Error **errp)
1629 {
1629 - MonitorHMP *mon = MONITOR_HMP(uc);
1630 + MonitorHMP *hmp = MONITOR_HMP(uc);
1631 UserCreatableClass *ucc_parent =
1632 USER_CREATABLE_CLASS(
1633 object_class_get_parent(
1633 - OBJECT_CLASS(MONITOR_HMP_GET_CLASS(mon))));
1634 + OBJECT_CLASS(MONITOR_HMP_GET_CLASS(hmp))));
1635 ERRP_GUARD();
1636
1637 ucc_parent->complete(uc, errp);
@@ -1638,21 +1639,21 @@ static void monitor_hmp_complete(UserCreatable *uc, Error **errp)
1639 return;
1640 }
1641
1641 - if (mon->parent_obj.chardev_id) {
1642 - if (mon->use_readline) {
1643 - mon->rs = readline_init(monitor_readline_printf,
1642 + if (hmp->parent_obj.chardev_id) {
1643 + if (hmp->use_readline) {
1644 + hmp->rs = readline_init(monitor_readline_printf,
1645 monitor_readline_flush,
1645 - mon,
1646 + hmp,
1647 monitor_find_completion);
1647 - monitor_read_command(mon, 0);
1648 + monitor_read_command(hmp, 0);
1649 }
1650
1650 - qemu_chr_fe_set_handlers(&mon->parent_obj.chr,
1651 + qemu_chr_fe_set_handlers(&hmp->parent_obj.chr,
1652 monitor_can_read,
1653 monitor_read,
1654 monitor_event, NULL,
1654 - &mon->parent_obj, NULL, true);
1655 - monitor_list_append(&mon->parent_obj);
1655 + &hmp->parent_obj, NULL, true);
1656 + monitor_list_append(&hmp->parent_obj);
1657 }
1658 }
1659
monitor/monitor-internal.h
+1 -1
@@ -221,7 +221,7 @@ void monitor_data_destroy_qmp(MonitorQMP *mon);
221 void coroutine_fn monitor_qmp_dispatcher_co(void *data);
222 void qmp_dispatcher_co_wake(void);
223
224 -void handle_hmp_command(MonitorHMP *mon, const char *cmdline);
224 +void handle_hmp_command(MonitorHMP *hmp, const char *cmdline);
225 int hmp_compare_cmd(const char *name, const char *list);
226
227 /*
ui/ui-hmp-cmds.c
+2 -2
@@ -343,8 +343,8 @@ void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
343 return;
344 }
345 if (!arg) {
346 - MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, parent_obj);
347 - monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
346 + MonitorHMP *hmp = container_of(mon, MonitorHMP, parent_obj);
347 + monitor_read_password(hmp, hmp_change_read_arg, NULL);
348 } else {
349 qmp_change_vnc_password(arg, errp);
350 }