[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2] tools/xl: refuse to set number of vcpus to 0 via xl vcpu-set
On Mon, Sep 03, 2018 at 02:59:42PM +0200, Juergen Gross wrote: > 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) { e -I/build/tools/xl/../../tools/include -D__XEN_TOOLS__ -I/build/tools/xl/../../tools/include -Wshadow -include /build/tools/xl/../../tools/config.h -c -o xl_cdrom.o xl_cdrom.c xl_vcpu.c: In function 'vcpuset': xl_vcpu.c:341:43: error: 'INT_MAX' undeclared (first use in this function) if (nr_vcpus == endptr || max_vcpus > INT_MAX) { ^~~~~~~ xl_vcpu.c:341:43: note: each undeclared identifier is reported only once for each function it appears in xl_vcpu.c:361:29: error: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Werror=format=] fprintf(stderr, "You are overcommmitting! You have %d physical" \ ^ xl_vcpu.c:379:74: error: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Werror=format=] fprintf(stderr, "libxl_set_vcpuonline failed domid=%u max_vcpus=%d," \ Missing a header? Wei. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |