[PATCH] Catch unimplemented sentinel of GetMaxVcpus and be less stupid

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1228245240 28800 # Node ID 03af2846604b1fdc8d1d7fa3aef737f727b0414b # Parent c9a0e8c2f4e85f9bbdbe1857ac5689e8a8efc909 Catch unimplemented sentinel of GetMaxVcpus and be less stupid Currently, we stuff the result of GetMaxVcpus into a u64 directly. Since that function can return -1 for unimplemented (as it does for LXC), we end up with a ridiculously large number of vcpus as the maximum. Assuming nothing can run with less than 1 cpu, I think it's a safe default for this case. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r c9a0e8c2f4e8 -r 03af2846604b src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Dec 01 13:01:42 2008 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Dec 02 11:14:00 2008 -0800 @@ -342,6 +342,7 @@ { bool ret = false; virConnectPtr conn; + int max; conn = connect_by_classname(_BROKER, CLASSNAME(ref), s); if (conn == NULL) { @@ -351,8 +352,14 @@ goto out; } - *num_procs = virConnectGetMaxVcpus(conn, NULL); - CU_DEBUG("libvirt says %d max vcpus", *num_procs); + max = virConnectGetMaxVcpus(conn, NULL); + if (max == -1) { + CU_DEBUG("GetMaxVcpus not supported, assuming 1"); + *num_procs = 1; + } else { + *num_procs = max; + CU_DEBUG("libvirt says %d max vcpus", *num_procs); + } ret = true; out:

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1228245240 28800 # Node ID 03af2846604b1fdc8d1d7fa3aef737f727b0414b # Parent c9a0e8c2f4e85f9bbdbe1857ac5689e8a8efc909 Catch unimplemented sentinel of GetMaxVcpus and be less stupid
Currently, we stuff the result of GetMaxVcpus into a u64 directly. Since that function can return -1 for unimplemented (as it does for LXC), we end up with a ridiculously large number of vcpus as the maximum.
Assuming nothing can run with less than 1 cpu, I think it's a safe default for this case.
Signed-off-by: Dan Smith <danms@us.ibm.com>
diff -r c9a0e8c2f4e8 -r 03af2846604b src/Virt_SettingsDefineCapabilities.c
+1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1228245240 28800 # Node ID 03af2846604b1fdc8d1d7fa3aef737f727b0414b # Parent c9a0e8c2f4e85f9bbdbe1857ac5689e8a8efc909 Catch unimplemented sentinel of GetMaxVcpus and be less stupid
Currently, we stuff the result of GetMaxVcpus into a u64 directly. Since that function can return -1 for unimplemented (as it does for LXC), we end up with a ridiculously large number of vcpus as the maximum.
Assuming nothing can run with less than 1 cpu, I think it's a safe default for this case.
Makes sense and looks sane :-). Jim
participants (3)
-
Dan Smith
-
Jim Fehlig
-
Kaitlin Rupert