docs: Reword virDomainGetEmulatorPinInfo description
[libvirt.git] / tests / qemuhotplugmock.c
blobdd7e2c67e07b250378c035c6b160fdf956ebb982
1 /*
2 * Copyright (C) 2019 IBM Corporation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see
16 * <http://www.gnu.org/licenses/>.
19 #include <config.h>
21 #include "qemu/qemu_command.h"
22 #include "qemu/qemu_hotplug.h"
23 #include "qemu/qemu_process.h"
24 #include "testutilsqemu.h"
25 #include "conf/domain_conf.h"
26 #include "virdevmapper.h"
27 #include "virmock.h"
28 #include <fcntl.h>
30 #define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW
31 #include "qemu/qemu_monitor_priv.h"
33 static bool (*real_virFileExists)(const char *path);
35 static void
36 init_syms(void)
38 if (real_virFileExists)
39 return;
41 VIR_MOCK_REAL_INIT(virFileExists);
44 unsigned long long
45 qemuDomainGetUnplugTimeout(virDomainObj *vm)
47 /* Wait only 100ms for DEVICE_DELETED event. Give a greater
48 * timeout in case of PSeries guest to be consistent with the
49 * original logic. */
50 if (qemuDomainIsPSeries(vm->def))
51 return 20;
52 return 10;
56 int
57 virDevMapperGetTargets(const char *path,
58 GSList **devPaths)
60 *devPaths = NULL;
62 if (STREQ(path, "/dev/mapper/virt")) {
63 *devPaths = g_slist_prepend(*devPaths, g_strdup("/dev/block/8:32")); /* /dev/sdc */
64 *devPaths = g_slist_prepend(*devPaths, g_strdup("/dev/block/8:16")); /* /dev/sdb */
65 *devPaths = g_slist_prepend(*devPaths, g_strdup("/dev/block/8:0")); /* /dev/sda */
68 return 0;
72 bool
73 virFileExists(const char *path)
75 init_syms();
77 if (STREQ(path, "/dev/mapper/virt"))
78 return true;
80 return real_virFileExists(path);
84 int
85 qemuProcessStartManagedPRDaemon(virDomainObj *vm G_GNUC_UNUSED)
87 return 0;
91 void
92 qemuProcessKillManagedPRDaemon(virDomainObj *vm G_GNUC_UNUSED)
96 int
97 qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED)
99 /* need a valid fd or sendmsg won't work. Just open /dev/null */
100 return open("/dev/null", O_RDONLY);
105 qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm,
106 virDomainDeviceDef *dev)
108 return qemuDomainDeviceBackendChardevForeachOne(dev,
109 testQemuPrepareHostBackendChardevOne,
110 vm);
114 /* we don't really want to send fake FDs across the monitor */
116 qemuMonitorIOWriteWithFD(qemuMonitor *mon,
117 const char *data,
118 size_t len,
119 int fd G_GNUC_UNUSED)
121 return write(mon->fd, data, len); /* sc_avoid_write */