|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2] tools/xl: refuse to set number of vcpus to 0 via xl vcpu-set
Trying to set the number of vcpus of a domain to 0 isn't refused.
We should not allow that.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
tools/libxl/libxl_domain.c | 6 ++++++
tools/xl/xl_vcpu.c | 5 +++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index 533bcdf240..3377bba994 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -1369,6 +1369,12 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid,
libxl_bitmap *cpumap)
}
maxcpus = libxl_bitmap_count_set(cpumap);
+ if (maxcpus == 0)
+ {
+ LOGED(ERROR, domid, "Requested 0 VCPUs!");
+ rc = ERROR_FAIL;
+ goto out;
+ }
if (maxcpus > info.vcpu_max_id + 1)
{
LOGED(ERROR, domid, "Requested %d VCPUs, however maxcpus is %d!",
diff --git a/tools/xl/xl_vcpu.c b/tools/xl/xl_vcpu.c
index aef486864c..3057c22aae 100644
--- a/tools/xl/xl_vcpu.c
+++ b/tools/xl/xl_vcpu.c
@@ -331,13 +331,14 @@ int main_vcpupin(int argc, char **argv)
static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)
{
char *endptr;
- unsigned int max_vcpus, i;
+ unsigned int i;
+ unsigned long max_vcpus;
libxl_bitmap cpumap;
int rc;
libxl_bitmap_init(&cpumap);
max_vcpus = strtoul(nr_vcpus, &endptr, 10);
- if (nr_vcpus == endptr) {
+ if (nr_vcpus == endptr || max_vcpus > INT_MAX) {
fprintf(stderr, "Error: Invalid argument.\n");
return 1;
}
--
2.16.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |