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/>.
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"
30 #define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW
31 #include "qemu/qemu_monitor_priv.h"
33 static bool (*real_virFileExists
)(const char *path
);
38 if (real_virFileExists
)
41 VIR_MOCK_REAL_INIT(virFileExists
);
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
50 if (qemuDomainIsPSeries(vm
->def
))
57 virDevMapperGetTargets(const char *path
,
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 */
73 virFileExists(const char *path
)
77 if (STREQ(path
, "/dev/mapper/virt"))
80 return real_virFileExists(path
);
85 qemuProcessStartManagedPRDaemon(virDomainObj
*vm G_GNUC_UNUSED
)
92 qemuProcessKillManagedPRDaemon(virDomainObj
*vm G_GNUC_UNUSED
)
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
,
114 /* we don't really want to send fake FDs across the monitor */
116 qemuMonitorIOWriteWithFD(qemuMonitor
*mon
,
119 int fd G_GNUC_UNUSED
)
121 return write(mon
->fd
, data
, len
); /* sc_avoid_write */