2019-10-18 21:36:32 +03:00
/*
* Copyright ( C ) 2019 IBM Corporation
*
* 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>
2023-05-30 23:33:46 +03:00
# include "qemu/qemu_command.h"
2019-10-18 21:36:32 +03:00
# include "qemu/qemu_hotplug.h"
2019-11-13 17:34:50 +03:00
# include "qemu/qemu_process.h"
2022-02-09 17:43:03 +03:00
# include "testutilsqemu.h"
2019-10-18 21:36:32 +03:00
# include "conf/domain_conf.h"
2019-11-13 17:34:50 +03:00
# include "virdevmapper.h"
# include "virmock.h"
2020-10-14 20:08:29 +03:00
# include <fcntl.h>
2019-11-13 17:34:50 +03:00
2022-02-14 17:51:37 +03:00
# define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW
# include "qemu/qemu_monitor_priv.h"
2019-11-13 17:34:50 +03:00
static bool ( * real_virFileExists ) ( const char * path ) ;
static void
init_syms ( void )
{
if ( real_virFileExists )
return ;
VIR_MOCK_REAL_INIT ( virFileExists ) ;
}
2019-10-18 21:36:32 +03:00
unsigned long long
2021-03-11 10:16:13 +03:00
qemuDomainGetUnplugTimeout ( virDomainObj * vm )
2019-10-18 21:36:32 +03:00
{
/* Wait only 100ms for DEVICE_DELETED event. Give a greater
* timeout in case of PSeries guest to be consistent with the
* original logic . */
if ( qemuDomainIsPSeries ( vm - > def ) )
2020-04-23 11:33:58 +03:00
return 20 ;
return 10 ;
2019-10-18 21:36:32 +03:00
}
2019-11-13 17:34:50 +03:00
int
virDevMapperGetTargets ( const char * path ,
2021-09-20 15:30:59 +03:00
GSList * * devPaths )
2019-11-13 17:34:50 +03:00
{
* devPaths = NULL ;
if ( STREQ ( path , " /dev/mapper/virt " ) ) {
2021-09-20 15:30:59 +03:00
* devPaths = g_slist_prepend ( * devPaths , g_strdup ( " /dev/block/8:32 " ) ) ; /* /dev/sdc */
* devPaths = g_slist_prepend ( * devPaths , g_strdup ( " /dev/block/8:16 " ) ) ; /* /dev/sdb */
* devPaths = g_slist_prepend ( * devPaths , g_strdup ( " /dev/block/8:0 " ) ) ; /* /dev/sda */
2019-11-13 17:34:50 +03:00
}
return 0 ;
}
bool
virFileExists ( const char * path )
{
init_syms ( ) ;
if ( STREQ ( path , " /dev/mapper/virt " ) )
return true ;
return real_virFileExists ( path ) ;
}
int
2021-03-11 10:16:13 +03:00
qemuProcessStartManagedPRDaemon ( virDomainObj * vm G_GNUC_UNUSED )
2019-11-13 17:34:50 +03:00
{
return 0 ;
}
void
2021-03-11 10:16:13 +03:00
qemuProcessKillManagedPRDaemon ( virDomainObj * vm G_GNUC_UNUSED )
2019-11-13 17:34:50 +03:00
{
}
2020-10-14 20:08:29 +03:00
int
2023-05-30 23:33:46 +03:00
qemuVDPAConnect ( const char * devicepath G_GNUC_UNUSED )
2020-10-14 20:08:29 +03:00
{
/* need a valid fd or sendmsg won't work. Just open /dev/null */
return open ( " /dev/null " , O_RDONLY ) ;
}
2022-02-09 17:43:03 +03:00
int
qemuProcessPrepareHostBackendChardevHotplug ( virDomainObj * vm ,
virDomainDeviceDef * dev )
{
return qemuDomainDeviceBackendChardevForeachOne ( dev ,
testQemuPrepareHostBackendChardevOne ,
vm ) ;
}
2022-02-14 17:51:37 +03:00
/* we don't really want to send fake FDs across the monitor */
int
qemuMonitorIOWriteWithFD ( qemuMonitor * mon ,
const char * data ,
size_t len ,
int fd G_GNUC_UNUSED )
{
return write ( mon - > fd , data , len ) ; /* sc_avoid_write */
}