Skip to contentSkip to conversation

libxl: avoid bringing up vcpus already online

PATCH In review Chao Peng 4 participants 5 messages Nov 17, 2014 – Nov 21, 2014

lore
Share & tools
lore

Chao Peng

author
#0 lore raw

PATCH 1/1 libxl: avoid bringing up vcpus already online

Avoid sending duplicated qmp commands and eliminate the confusing error messages like "Unable to add CPU: 0, it already exists".

---
 tools/libxl/libxl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl.c +1 -1
index f7961f6..d040e5c 100644
@@ -5450,7 +5450,7 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
         LOGE(ERROR, "getting domain info list");
         return ERROR_FAIL;
     }
-    for (i = 0; i <= info.vcpu_max_id; i++) {
+    for (i = info.vcpu_online; i <= info.vcpu_max_id; i++) {
         if (libxl_bitmap_test(cpumap, i)) {
             /* Return value is ignore because it does not tell anything useful
              * on the completion of the command.
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 13 lines · Chao Peng

Avoid sending duplicated qmp commands and eliminate the confusing error messages like "Unable to add CPU: 0, it already exists".

---
 tools/libxl/libxl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl.c +0 -0
index f7961f6..d040e5c 100644

tools/libxl/libxl.c static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid, · line 5453

Quoted 5 lines
tools/libxl/libxl.c +1 -1
@@ -5450,7 +5450,7 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
         LOGE(ERROR, "getting domain info list");
         return ERROR_FAIL;
     }
-    for (i = 0; i <= info.vcpu_max_id; i++) {
+    for (i = info.vcpu_online; i <= info.vcpu_max_id; i++) {

I don't think this is right. You're making an assumption that vcpu 0 to vcpu "info.vcpu_online" are online, which might not be true in hotplug / hot-unplug scenario.

Wei.

Quoted 5 lines
tools/libxl/libxl.c +0 -0
         if (libxl_bitmap_test(cpumap, i)) {
             /* Return value is ignore because it does not tell anything useful
              * on the completion of the command.
Signature · 1 line
1.7.9.5
#2 lore raw
Quoted 9 lines · Wei Liu
Quoted 8 lines · Chao Peng

Avoid sending duplicated qmp commands and eliminate the confusing error messages like "Unable to add CPU: 0, it already exists".

---
 tools/libxl/libxl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

tools/libxl/libxl.c static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid, · line 5453

Quoted 10 lines
tools/libxl/libxl.c +1 -1
index f7961f6..d040e5c 100644
@@ -5450,7 +5450,7 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
         LOGE(ERROR, "getting domain info list");
         return ERROR_FAIL;
     }
-    for (i = 0; i <= info.vcpu_max_id; i++) {
+    for (i = info.vcpu_online; i <= info.vcpu_max_id; i++) {

I don't think this is right. You're making an assumption that vcpu 0 to vcpu "info.vcpu_online" are online, which might not be true in hotplug / hot-unplug scenario.

Indeed. Adding Anthony for his input.

Quoted 8 lines

Wei.

Quoted 5 lines
tools/libxl/libxl.c +0 -0
         if (libxl_bitmap_test(cpumap, i)) {
             /* Return value is ignore because it does not tell anything useful
              * on the completion of the command.
Signature · 1 line
1.7.9.5
#3 lore raw
Quoted 25 lines · Ian Campbell
Quoted 9 lines · Wei Liu
Quoted 8 lines · Chao Peng

Avoid sending duplicated qmp commands and eliminate the confusing error messages like "Unable to add CPU: 0, it already exists".

---
 tools/libxl/libxl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

tools/libxl/libxl.c static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid, · line 5453

Quoted 10 lines
tools/libxl/libxl.c +1 -1
index f7961f6..d040e5c 100644
@@ -5450,7 +5450,7 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
         LOGE(ERROR, "getting domain info list");
         return ERROR_FAIL;
     }
-    for (i = 0; i <= info.vcpu_max_id; i++) {
+    for (i = info.vcpu_online; i <= info.vcpu_max_id; i++) {

I don't think this is right. You're making an assumption that vcpu 0 to vcpu "info.vcpu_online" are online, which might not be true in hotplug / hot-unplug scenario.

Quoted 1 line

Indeed. Adding Anthony for his input.

It's probably not a good "fix" to avoid the error message. As Wei said, vcpu 0 to vcpu ${info.vcpu_online} might not all be online.

At the time I've written this function, there were no way to query QEMU to know which CPU are online. So the only way was to send the QMP command anyway and get an error back. Unfortunately, the error that QEMU send back is not suppose to be parsed (as it's only for human to read and might change in the futur) and libxl_qmp is not ready to handle this kind of error in a better way, so it just print them.

Signature · 1 line
Anthony PERARD
author
#4 lore raw
In reply to Wei Liu
Quoted 9 lines · Wei Liu
Quoted 8 lines · Chao Peng

Avoid sending duplicated qmp commands and eliminate the confusing error messages like "Unable to add CPU: 0, it already exists".

---
 tools/libxl/libxl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

tools/libxl/libxl.c static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid, · line 5453

Quoted 10 lines
tools/libxl/libxl.c +1 -1
index f7961f6..d040e5c 100644
@@ -5450,7 +5450,7 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
         LOGE(ERROR, "getting domain info list");
         return ERROR_FAIL;
     }
-    for (i = 0; i <= info.vcpu_max_id; i++) {
+    for (i = info.vcpu_online; i <= info.vcpu_max_id; i++) {

I don't think this is right. You're making an assumption that vcpu 0 to vcpu "info.vcpu_online" are online, which might not be true in hotplug / hot-unplug scenario.

You are right. Though the assumption is true right now as QEMU has not implemented cpu hot-unplug.

The problem is: There is no way to obtain the vcpu online status in xl as cpu hot-plug/hot-unplug for HVM are all done in QEMU. I guess it's hard to fix it now. While it's also a minor issue :-)

Chao

Quoted 11 lines
Quoted 6 lines
tools/libxl/libxl.c +0 -0
         if (libxl_bitmap_test(cpumap, i)) {
             /* Return value is ignore because it does not tell anything useful
              * on the completion of the command.
Signature · 1 line
1.7.9.5

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel