summaryrefslogtreecommitdiff
path: root/tests/domaincapsmock.c
blob: d382d06e2718523f25e3c624e005954bbac297a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * 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/>.
 */

#include <config.h>

#include "virhostcpu.h"
#include "virhostmem.h"

#if WITH_QEMU
# include "virmock.h"
# include "qemu/qemu_capabilities.h"
#endif

int
virHostCPUGetKVMMaxVCPUs(void)
{
    return INT_MAX;
}

unsigned int
virHostCPUGetMicrocodeVersion(virArch hostArch G_GNUC_UNUSED)
{
    return 0;
}

#if WITH_QEMU
static bool (*real_virQEMUCapsGetKVMSupportsSecureGuest)(virQEMUCaps *qemuCaps);

bool
virQEMUCapsGetKVMSupportsSecureGuest(virQEMUCaps *qemuCaps)
{
    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_CONFIDENTAL_GUEST_SUPPORT) &&
        virQEMUCapsGet(qemuCaps, QEMU_CAPS_S390_PV_GUEST))
        return true;

    if (!real_virQEMUCapsGetKVMSupportsSecureGuest)
        VIR_MOCK_REAL_INIT(virQEMUCapsGetKVMSupportsSecureGuest);

    return real_virQEMUCapsGetKVMSupportsSecureGuest(qemuCaps);
}
#endif

int
virHostMemGetTHPSize(unsigned long long *size)
{
    /* Pretend Transparent Huge Page size is 2MiB. */
    *size = 2048;
    return 0;
}