2017-08-01 13:17:51 +00:00
|
|
|
/*
|
2019-02-08 16:51:25 +00:00
|
|
|
* libxlmock.c: mocking of xenstore/libxs for libxl
|
2017-08-01 13:17:51 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2018-08-13 11:40:18 +00:00
|
|
|
#if defined(WITH_LIBXL) && defined(WITH_YAJL)
|
2017-08-01 13:17:51 +00:00
|
|
|
# include "virmock.h"
|
|
|
|
# include <sys/stat.h>
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <libxl.h>
|
|
|
|
# include <xenstore.h>
|
|
|
|
# include <xenctrl.h>
|
|
|
|
|
2020-02-22 12:56:19 +00:00
|
|
|
# include "libxl/libxl_capabilities.h"
|
2018-04-18 07:37:09 +00:00
|
|
|
|
2017-08-01 13:17:51 +00:00
|
|
|
VIR_MOCK_IMPL_RET_VOID(xs_daemon_open,
|
|
|
|
struct xs_handle *)
|
|
|
|
{
|
|
|
|
VIR_MOCK_REAL_INIT(xs_daemon_open);
|
|
|
|
return (void*)0x1;
|
|
|
|
}
|
|
|
|
|
2021-05-17 17:52:25 +00:00
|
|
|
VIR_MOCK_IMPL_RET_ARGS(xs_open,
|
|
|
|
struct xs_handle *,
|
|
|
|
unsigned long, flags)
|
|
|
|
{
|
|
|
|
VIR_MOCK_REAL_INIT(xs_open);
|
|
|
|
return (void*)0x1;
|
|
|
|
}
|
|
|
|
|
2017-08-01 13:17:51 +00:00
|
|
|
VIR_MOCK_IMPL_RET_ARGS(xc_interface_open,
|
|
|
|
xc_interface *,
|
|
|
|
xentoollog_logger *, logger,
|
|
|
|
xentoollog_logger *, dombuild_logger,
|
|
|
|
unsigned, open_flags)
|
|
|
|
{
|
|
|
|
VIR_MOCK_REAL_INIT(xc_interface_open);
|
|
|
|
return (void*)0x1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-12 01:03:20 +00:00
|
|
|
VIR_MOCK_IMPL_RET_ARGS(libxl_get_version_info,
|
|
|
|
const libxl_version_info*,
|
|
|
|
libxl_ctx *, ctx)
|
|
|
|
{
|
|
|
|
static libxl_version_info info;
|
|
|
|
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
|
|
|
|
/* silence gcc warning about unused function */
|
|
|
|
if (0)
|
|
|
|
real_libxl_get_version_info(ctx);
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_MOCK_STUB_RET_ARGS(libxl_get_free_memory,
|
|
|
|
int, 0,
|
|
|
|
libxl_ctx *, ctx,
|
2021-03-25 16:26:08 +00:00
|
|
|
# if LIBXL_API_VERSION < 0x040800
|
|
|
|
uint32_t *,
|
|
|
|
# else
|
|
|
|
uint64_t *,
|
|
|
|
# endif
|
|
|
|
memkb);
|
2018-04-12 01:03:20 +00:00
|
|
|
|
2017-08-01 13:17:51 +00:00
|
|
|
VIR_MOCK_STUB_RET_ARGS(xc_interface_close,
|
|
|
|
int, 0,
|
|
|
|
xc_interface *, handle)
|
|
|
|
|
2017-11-10 20:03:16 +00:00
|
|
|
VIR_MOCK_STUB_RET_ARGS(xc_physinfo,
|
|
|
|
int, 0,
|
|
|
|
xc_interface *, handle,
|
|
|
|
xc_physinfo_t *, put_info)
|
|
|
|
|
|
|
|
VIR_MOCK_STUB_RET_ARGS(xc_sharing_freed_pages,
|
|
|
|
long, 0,
|
|
|
|
xc_interface *, handle)
|
|
|
|
|
|
|
|
VIR_MOCK_STUB_RET_ARGS(xc_sharing_used_frames,
|
|
|
|
long, 0,
|
|
|
|
xc_interface *, handle)
|
|
|
|
|
2017-08-01 13:17:51 +00:00
|
|
|
VIR_MOCK_STUB_VOID_ARGS(xs_daemon_close,
|
|
|
|
struct xs_handle *, handle)
|
|
|
|
|
2021-05-17 17:52:25 +00:00
|
|
|
VIR_MOCK_STUB_VOID_ARGS(xs_close,
|
|
|
|
struct xs_handle *, xsh)
|
|
|
|
|
2018-02-06 09:09:09 +00:00
|
|
|
VIR_MOCK_STUB_RET_ARGS(bind,
|
|
|
|
int, 0,
|
|
|
|
int, sockfd,
|
|
|
|
const struct sockaddr *, addr,
|
|
|
|
socklen_t, addrlen)
|
|
|
|
|
2017-08-01 13:17:51 +00:00
|
|
|
VIR_MOCK_IMPL_RET_ARGS(__xstat, int,
|
|
|
|
int, ver,
|
|
|
|
const char *, path,
|
|
|
|
struct stat *, sb)
|
|
|
|
{
|
|
|
|
VIR_MOCK_REAL_INIT(__xstat);
|
|
|
|
|
|
|
|
if (strstr(path, "xenstored.pid")) {
|
|
|
|
memset(sb, 0, sizeof(*sb));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return real___xstat(ver, path, sb);
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_MOCK_IMPL_RET_ARGS(stat, int,
|
|
|
|
const char *, path,
|
|
|
|
struct stat *, sb)
|
|
|
|
{
|
|
|
|
VIR_MOCK_REAL_INIT(stat);
|
|
|
|
|
|
|
|
if (strstr(path, "xenstored.pid")) {
|
|
|
|
memset(sb, 0, sizeof(*sb));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return real_stat(path, sb);
|
|
|
|
}
|
|
|
|
|
2020-02-22 12:56:19 +00:00
|
|
|
int
|
|
|
|
libxlDomainGetEmulatorType(const virDomainDef *def G_GNUC_UNUSED)
|
|
|
|
{
|
|
|
|
return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
|
|
|
|
}
|
|
|
|
|
2018-08-13 11:40:18 +00:00
|
|
|
#endif /* WITH_LIBXL && WITH_YAJL */
|