Skip to contentSkip to conversation

hmp: add info iothreads command

PATCH Superseded Ting Wang 3 participants 7 messages Mar 12, 2015 – Mar 13, 2015

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Ting Wang

author
#0 lore raw

PATCH v2 1/1 hmp: add info iothreads command

Make "info iothreads" available on the HMP monitor.

The results are as follows:
id1: thread_id1
id2: thread_id2

---
v2: add braces for if

---
 hmp-commands.hx |  2 ++
 hmp.c           | 22 ++++++++++++++++++++++
 hmp.h           |  1 +
 monitor.c       |  7 +++++++
 4 files changed, 32 insertions(+)
hmp-commands.hx +2 -0
index d5022d8..67d76ed 100644
@@ -1746,6 +1746,8 @@ show roms
 show the TPM device
 @item info memory-devices
 show the memory devices
+@item info iothreads
+show iothreads
 @end table
 ETEXI
 
hmp.c +22 -0
index 71c28bc..e87cb14 100644
@@ -821,6 +821,28 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
     qapi_free_TPMInfoList(info_list);
 }
 
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
+{
+    IOThreadInfoList *head = NULL, *elem = NULL;
+
+    head = qmp_query_iothreads(NULL);
+    if (!head) {
+        monitor_printf(mon, "No iothread has been added\n");
+        return;
+    }
+
+    elem = head;
+    while (elem) {
+        if (elem->value) {
+            monitor_printf(mon, "%s: thread_id=%ld\n", elem->value->id, 
+                    elem->value->thread_id);
+        }
+        elem = elem->next;
+    }
+
+    qapi_free_IOThreadInfoList(head);
+}
+
 void hmp_quit(Monitor *mon, const QDict *qdict)
 {
     monitor_suspend(mon);
hmp.h +1 -0
index 81177b2..d99090e 100644
@@ -38,6 +38,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict);
 void hmp_quit(Monitor *mon, const QDict *qdict);
 void hmp_stop(Monitor *mon, const QDict *qdict);
 void hmp_system_reset(Monitor *mon, const QDict *qdict);
monitor.c +7 -0
index c86a89e..076a306 100644
@@ -2924,6 +2924,13 @@ static mon_cmd_t info_cmds[] = {
         .mhandler.cmd = hmp_info_memory_devices,
     },
     {
+        .name       = "iothreads",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show iothreads",
+        .mhandler.cmd = hmp_info_iothreads,
+    },
+    {
         .name       = NULL,
     },
 };
Signature · 1 line
1.8.5
#1 lore raw
Quoted 5 lines · Ting Wang

Make "info iothreads" available on the HMP monitor.

The results are as follows:
id1: thread_id1
id2: thread_id2

Does this match the actual output format? I think you're missing a "=".

Quoted 36 lines

---
v2: add braces for if

---
 hmp-commands.hx |  2 ++
 hmp.c           | 22 ++++++++++++++++++++++
 hmp.h           |  1 +
 monitor.c       |  7 +++++++
 4 files changed, 32 insertions(+)
hmp-commands.hx +2 -0
index d5022d8..67d76ed 100644
@@ -1746,6 +1746,8 @@ show roms
 show the TPM device
 @item info memory-devices
 show the memory devices
+@item info iothreads
+show iothreads
 @end table
 ETEXI
 
hmp.c +4 -0
index 71c28bc..e87cb14 100644
@@ -821,6 +821,28 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
     qapi_free_TPMInfoList(info_list);
 }
 
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
+{
+    IOThreadInfoList *head = NULL, *elem = NULL;
+

hmp.c void hmp_info_tpm(Monitor *mon, const QDict *qdict) · line 837

Quoted 10 lines
hmp.c +10 -0
+    head = qmp_query_iothreads(NULL);
+    if (!head) {
+        monitor_printf(mon, "No iothread has been added\n");
+        return;
+    }
+
+    elem = head;
+    while (elem) {
+        if (elem->value) {
+            monitor_printf(mon, "%s: thread_id=%ld\n", elem->value->id, 

Please remove the trailing whitespace. You can use scripts/checkpatch.pl to catch the coding style issues your self.

You should also add documentation in hmp-commands.hx.

Fam

Quoted 45 lines
hmp.c +8 -0
+                    elem->value->thread_id);
+        }
+        elem = elem->next;
+    }
+
+    qapi_free_IOThreadInfoList(head);
+}
+
 void hmp_quit(Monitor *mon, const QDict *qdict)
 {
     monitor_suspend(mon);
hmp.h +1 -0
index 81177b2..d99090e 100644
@@ -38,6 +38,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict);
 void hmp_quit(Monitor *mon, const QDict *qdict);
 void hmp_stop(Monitor *mon, const QDict *qdict);
 void hmp_system_reset(Monitor *mon, const QDict *qdict);
monitor.c +7 -0
index c86a89e..076a306 100644
@@ -2924,6 +2924,13 @@ static mon_cmd_t info_cmds[] = {
         .mhandler.cmd = hmp_info_memory_devices,
     },
     {
+        .name       = "iothreads",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show iothreads",
+        .mhandler.cmd = hmp_info_iothreads,
+    },
+    {
         .name       = NULL,
     },
 };
Signature · 1 line
1.8.5
author
#2 lore raw
Quoted 9 lines · Fam Zheng
Quoted 5 lines · Ting Wang

Make "info iothreads" available on the HMP monitor.

The results are as follows:
id1: thread_id1
id2: thread_id2

Does this match the actual output format? I think you're missing a "=".

Oh, sorry. I will fix it.

Ting

Quoted 102 lines
Quoted 36 lines

---
v2: add braces for if

---
 hmp-commands.hx |  2 ++
 hmp.c           | 22 ++++++++++++++++++++++
 hmp.h           |  1 +
 monitor.c       |  7 +++++++
 4 files changed, 32 insertions(+)
hmp-commands.hx +2 -0
index d5022d8..67d76ed 100644
@@ -1746,6 +1746,8 @@ show roms
 show the TPM device
 @item info memory-devices
 show the memory devices
+@item info iothreads
+show iothreads
 @end table
 ETEXI
 
hmp.c +4 -0
index 71c28bc..e87cb14 100644
@@ -821,6 +821,28 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
     qapi_free_TPMInfoList(info_list);
 }
 
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
+{
+    IOThreadInfoList *head = NULL, *elem = NULL;
+

hmp.c void hmp_info_tpm(Monitor *mon, const QDict *qdict) · line 837

Quoted 10 lines
hmp.c +10 -0
+    head = qmp_query_iothreads(NULL);
+    if (!head) {
+        monitor_printf(mon, "No iothread has been added\n");
+        return;
+    }
+
+    elem = head;
+    while (elem) {
+        if (elem->value) {
+            monitor_printf(mon, "%s: thread_id=%ld\n", elem->value->id, 

Please remove the trailing whitespace. You can use scripts/checkpatch.pl to catch the coding style issues your self.

You should also add documentation in hmp-commands.hx.

Fam

Quoted 45 lines
hmp.c +8 -0
+                    elem->value->thread_id);
+        }
+        elem = elem->next;
+    }
+
+    qapi_free_IOThreadInfoList(head);
+}
+
 void hmp_quit(Monitor *mon, const QDict *qdict)
 {
     monitor_suspend(mon);
hmp.h +1 -0
index 81177b2..d99090e 100644
@@ -38,6 +38,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict);
 void hmp_quit(Monitor *mon, const QDict *qdict);
 void hmp_stop(Monitor *mon, const QDict *qdict);
 void hmp_system_reset(Monitor *mon, const QDict *qdict);
monitor.c +7 -0
index c86a89e..076a306 100644
@@ -2924,6 +2924,13 @@ static mon_cmd_t info_cmds[] = {
         .mhandler.cmd = hmp_info_memory_devices,
     },
     {
+        .name       = "iothreads",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show iothreads",
+        .mhandler.cmd = hmp_info_iothreads,
+    },
+    {
         .name       = NULL,
     },
 };
Signature · 1 line
1.8.5

.

author
#3 lore raw
In reply to Fam Zheng
Quoted 50 lines · Fam Zheng
Quoted 5 lines · Ting Wang

Make "info iothreads" available on the HMP monitor.

The results are as follows:
id1: thread_id1
id2: thread_id2

Does this match the actual output format? I think you're missing a "=".

Quoted 41 lines

---
v2: add braces for if

---
 hmp-commands.hx |  2 ++
 hmp.c           | 22 ++++++++++++++++++++++
 hmp.h           |  1 +
 monitor.c       |  7 +++++++
 4 files changed, 32 insertions(+)
hmp-commands.hx +2 -0
index d5022d8..67d76ed 100644
@@ -1746,6 +1746,8 @@ show roms
 show the TPM device
 @item info memory-devices
 show the memory devices
+@item info iothreads
+show iothreads
 @end table
 ETEXI
 
hmp.c +9 -0
index 71c28bc..e87cb14 100644
@@ -821,6 +821,28 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
     qapi_free_TPMInfoList(info_list);
 }
 
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
+{
+    IOThreadInfoList *head = NULL, *elem = NULL;
+
+    head = qmp_query_iothreads(NULL);
+    if (!head) {
+        monitor_printf(mon, "No iothread has been added\n");
+        return;
+    }
Quoted 8 lines

hmp.c void hmp_info_tpm(Monitor *mon, const QDict *qdict) · line 837

Quoted 5 lines
hmp.c +5 -0
+
+    elem = head;
+    while (elem) {
+        if (elem->value) {
+            monitor_printf(mon, "%s: thread_id=%ld\n", elem->value->id, 

Please remove the trailing whitespace. You can use scripts/checkpatch.pl to catch the coding style issues your self.

OK. Thank you.

Quoted 5 lines

You should also add documentation in hmp-commands.hx.

Fam

It is a command in "info" group, I think documentation as follows is OK, do you agree with it?

Quoted 4 lines
Quoted 4 lines
hmp-commands.hx +0 -0
index d5022d8..67d76ed 100644
Quoted 8 lines

hmp-commands.hx show roms · line 1752

Quoted 8 lines
hmp-commands.hx +2 -0
@@ -1746,6 +1746,8 @@ show roms
 show the TPM device
 @item info memory-devices
 show the memory devices
+@item info iothreads
+show iothreads
 @end table
 ETEXI

Ting

Quoted 48 lines
Quoted 45 lines
hmp-commands.hx +8 -0
+                    elem->value->thread_id);
+        }
+        elem = elem->next;
+    }
+
+    qapi_free_IOThreadInfoList(head);
+}
+
 void hmp_quit(Monitor *mon, const QDict *qdict)
 {
     monitor_suspend(mon);
hmp.h +1 -0
index 81177b2..d99090e 100644
@@ -38,6 +38,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict);
 void hmp_quit(Monitor *mon, const QDict *qdict);
 void hmp_stop(Monitor *mon, const QDict *qdict);
 void hmp_system_reset(Monitor *mon, const QDict *qdict);
monitor.c +7 -0
index c86a89e..076a306 100644
@@ -2924,6 +2924,13 @@ static mon_cmd_t info_cmds[] = {
         .mhandler.cmd = hmp_info_memory_devices,
     },
     {
+        .name       = "iothreads",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show iothreads",
+        .mhandler.cmd = hmp_info_iothreads,
+    },
+    {
         .name       = NULL,
     },
 };
Signature · 1 line
1.8.5

.

#4 lore raw
Quoted 13 lines · Ting Wang

It is a command in "info" group, I think documentation as follows is OK, do you agree with it?

Quoted 4 lines
Quoted 4 lines
hmp-commands.hx +0 -0
index d5022d8..67d76ed 100644
Quoted 8 lines

hmp-commands.hx show roms · line 1752

Quoted 8 lines
hmp-commands.hx +2 -0
@@ -1746,6 +1746,8 @@ show roms
 show the TPM device
 @item info memory-devices
 show the memory devices
+@item info iothreads
+show iothreads
 @end table
 ETEXI

Yes, looks good.

Fam

#5 lore raw
In reply to Ting Wang
Quoted 5 lines · Ting Wang
hmp.c +5 -0
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
+{
+    IOThreadInfoList *head = NULL, *elem = NULL;
+
+    head = qmp_query_iothreads(NULL);

hmp.c void hmp_info_tpm(Monitor *mon, const QDict *qdict) · line 838

Quoted 10 lines
hmp.c +10 -0
+    if (!head) {
+        monitor_printf(mon, "No iothread has been added\n");
+        return;
+    }
+
+    elem = head;
+    while (elem) {
+        if (elem->value) {
+            monitor_printf(mon, "%s: thread_id=%ld\n", elem->value->id, 
+                    elem->value->thread_id);

%ld does not work on 32-bit hosts or 64-bit Windows hosts where long is 32-bit.

Please use the PRId64 format specifier macro for the int64_t thread_id.

author
#6 lore raw
Quoted 20 lines · Stefan Hajnoczi
Quoted 5 lines · Ting Wang
hmp.c +5 -0
+void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
+{
+    IOThreadInfoList *head = NULL, *elem = NULL;
+
+    head = qmp_query_iothreads(NULL);

hmp.c void hmp_info_tpm(Monitor *mon, const QDict *qdict) · line 838

Quoted 10 lines
hmp.c +10 -0
+    if (!head) {
+        monitor_printf(mon, "No iothread has been added\n");
+        return;
+    }
+
+    elem = head;
+    while (elem) {
+        if (elem->value) {
+            monitor_printf(mon, "%s: thread_id=%ld\n", elem->value->id, 
+                    elem->value->thread_id);

%ld does not work on 32-bit hosts or 64-bit Windows hosts where long is 32-bit.

Quoted 2 lines

Please use the PRId64 format specifier macro for the int64_t thread_id.

OK, I will fix it.

Thank you very much.

Ting