qemuxml2argvmock.c 3.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * Copyright (C) 2014 Red Hat, Inc.
 *
 * 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/>.
 *
 * Author: Michal Privoznik <mprivozn@redhat.com>
 */

#include <config.h>

23
#include "internal.h"
24
#include "vircommand.h"
25
#include "virmock.h"
26 27 28 29
#include "virnetdev.h"
#include "virnetdevtap.h"
#include "virnuma.h"
#include "virscsi.h"
30 31
#include "virstring.h"
#include "virtpm.h"
32
#include "virutil.h"
33
#include <time.h>
34 35
#include <unistd.h>

36 37
#define VIR_FROM_THIS VIR_FROM_NONE

38 39 40 41
long virGetSystemPageSize(void)
{
    return 4096;
}
42 43 44 45 46 47 48 49

time_t time(time_t *t)
{
    const time_t ret = 1234567890;
    if (t)
        *t = ret;
    return ret;
}
50 51 52 53 54 55 56 57

int
virNumaGetMaxNode(void)
{
   const int maxnodesNum = 7;

   return maxnodesNum;
}
58 59 60 61 62 63 64 65 66 67 68 69

#if WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET
/*
 * In case libvirt is compiled with full NUMA support, we need to mock
 * this function in order to fake what numa nodes are available.
 */
bool
virNumaNodeIsAvailable(int node)
{
    return node >= 0 && node <= virNumaGetMaxNode();
}
#endif /* WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET */
70 71 72 73 74 75 76 77 78 79 80

char *
virTPMCreateCancelPath(const char *devpath)
{
    char *path;
    (void)devpath;

    ignore_value(VIR_STRDUP(path, "/sys/class/misc/tpm0/device/cancel"));

    return path;
}
81 82 83 84 85 86 87 88 89 90

/**
 * Large values for memory would fail on 32 bit systems, despite having
 * variables that support it.
 */
unsigned long long
virMemoryMaxValue(bool capped ATTRIBUTE_UNUSED)
{
    return LLONG_MAX;
}
91 92 93 94 95 96 97 98 99 100 101 102 103

char *
virSCSIDeviceGetSgName(const char *sysfs_prefix ATTRIBUTE_UNUSED,
                       const char *adapter ATTRIBUTE_UNUSED,
                       unsigned int bus ATTRIBUTE_UNUSED,
                       unsigned int target ATTRIBUTE_UNUSED,
                       unsigned long long unit ATTRIBUTE_UNUSED)
{
    char *ret;

    ignore_value(VIR_STRDUP(ret, "sg0"));
    return ret;
}
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

int
virNetDevTapCreate(char **ifname,
                   const char *tunpath ATTRIBUTE_UNUSED,
                   int *tapfd,
                   size_t tapfdSize,
                   unsigned int flags ATTRIBUTE_UNUSED)
{
    size_t i;

    for (i = 0; i < tapfdSize; i++)
        tapfd[i] = STDERR_FILENO + 1 + i;

    return VIR_STRDUP(*ifname, "vnet0");
}

int
virNetDevSetMAC(const char *ifname ATTRIBUTE_UNUSED,
                const virMacAddr *macaddr ATTRIBUTE_UNUSED)
{
    return 0;
}

int
virCommandRun(virCommandPtr cmd ATTRIBUTE_UNUSED,
              int *exitstatus)
{
    if (exitstatus)
        *exitstatus = 0;

    return 0;
}

void
virCommandPassFD(virCommandPtr cmd ATTRIBUTE_UNUSED,
                 int fd ATTRIBUTE_UNUSED,
                 unsigned int flags ATTRIBUTE_UNUSED)
{
    /* nada */
}