[libvirt] [PATCH 2/2] domaincapstest: Don't read data from host
Andrea Bolognani
abologna at redhat.com
Mon Jun 27 14:41:08 UTC 2016
On Mon, 2016-06-27 at 15:50 +0200, Jiri Denemark wrote:
> virQEMUCapsFillDomainCaps would use virHostCPUGetKVMMaxVCPUs for KVM
> domains.
>
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
> tests/Makefile.am | 7 +++++++
> tests/domaincapsmock.c | 26 ++++++++++++++++++++++++++
> tests/domaincapstest.c | 2 +-
> 3 files changed, 34 insertions(+), 1 deletion(-)
> create mode 100644 tests/domaincapsmock.c
>
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 444e0fd..1639540 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -404,6 +404,7 @@ test_libraries = libshunload.la \
> virrandommock.la \
> virhostcpumock.la \
> nssmock.la \
> + domaincapsmock.la \
> $(NULL)
> if WITH_QEMU
> test_libraries += libqemumonitortestutils.la \
> @@ -919,6 +920,12 @@ vircaps2xmltest_SOURCES = \
> vircaps2xmltest.c testutils.h testutils.c
> vircaps2xmltest_LDADD = $(LDADDS)
>
> +
> +domaincapsmock_la_SOURCES = domaincapsmock.c
> +domaincapsmock_la_CFLAGS = $(AM_CFLAGS)
> +domaincapsmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
> +domaincapsmock_la_LIBADD = $(MOCKLIBS_LIBS)
> +
> domaincapstest_SOURCES = \
> domaincapstest.c testutils.h testutils.c
> domaincapstest_LDADD = $(LDADDS)
> diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c
> new file mode 100644
> index 0000000..5266b73
> --- /dev/null
> +++ b/tests/domaincapsmock.c
> @@ -0,0 +1,26 @@
> +/*
Missing copyright statement.
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library. If not, see
> + * <http://www.gnu.org/licenses/>.
> + *
Unneeded empty line.
> + */
> +
> +#include <config.h>
> +
> +#include "virhostcpu.h"
> +
> +int
> +virHostCPUGetKVMMaxVCPUs(void)
> +{
> + return -1;
As discussed offline, returning -1 signals the caller that
an error has occurred.
We should return a positive number instead, either something
like 160 (so we can check that limiting vCPUs based on
MAX_VCPUS works) or INT_MAX (so we know it'll never be
smaller than the QEMU limit).
> +}
> diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
> index ae31146..5b7b7d0 100644
> --- a/tests/domaincapstest.c
> +++ b/tests/domaincapstest.c
> @@ -385,4 +385,4 @@ mymain(void)
> return ret;
> }
>
> -VIRT_TEST_MAIN(mymain)
> +VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/domaincapsmock.so")
ACK with that fixed.
--
Andrea Bolognani / Red Hat / Virtualization
More information about the libvir-list
mailing list