2013-06-21 18:27:59 +04:00
/*
* Copyright ( C ) 2011 - 2013 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>
2016-02-16 18:24:35 +03:00
# include "qemu/qemu_alias.h"
2013-06-21 18:27:59 +04:00
# include "qemu/qemu_conf.h"
# include "qemu/qemu_hotplug.h"
# include "qemumonitortestutils.h"
# include "testutils.h"
# include "testutilsqemu.h"
2019-06-07 14:56:14 +03:00
# include "testutilsqemuschema.h"
2019-08-29 22:19:00 +03:00
# include "virhostdev.h"
2013-06-21 18:27:59 +04:00
# include "virfile.h"
2021-04-09 16:59:42 +03:00
# define LIBVIRT_QEMU_CAPSPRIV_H_ALLOW
# include "qemu/qemu_capspriv.h"
2013-06-21 18:27:59 +04:00
# define VIR_FROM_THIS VIR_FROM_NONE
static virQEMUDriver driver ;
2013-07-02 12:16:30 +04:00
enum {
ATTACH ,
DETACH ,
UPDATE
} ;
2014-12-16 10:46:44 +03:00
# define QEMU_HOTPLUG_TEST_DOMAIN_ID 7
2013-06-21 18:27:59 +04:00
struct qemuHotplugTestData {
const char * domain_filename ;
const char * device_filename ;
bool fail ;
const char * const * mon ;
2013-07-02 12:16:30 +04:00
int action ;
bool keep ;
2021-03-11 10:16:13 +03:00
virDomainObj * vm ;
2013-07-26 16:22:10 +04:00
bool deviceDeletedEvent ;
2023-03-09 18:47:32 +03:00
const char * arch ;
GHashTable * capsLatestFiles ;
GHashTable * capsCache ;
GHashTable * schemaCache ;
2023-03-09 20:07:45 +03:00
GHashTable * schema ;
2013-06-21 18:27:59 +04:00
} ;
static int
2021-03-11 10:16:13 +03:00
qemuHotplugCreateObjects ( virDomainXMLOption * xmlopt ,
virDomainObj * * vm ,
2023-03-09 18:47:32 +03:00
const char * domxml ,
const char * arch ,
GHashTable * capsLatestFiles ,
GHashTable * capsCache ,
GHashTable * schemaCache ,
GHashTable * * schema )
2013-06-21 18:27:59 +04:00
{
2021-03-11 10:16:13 +03:00
qemuDomainObjPrivate * priv = NULL ;
2017-10-17 14:13:08 +03:00
const unsigned int parseFlags = 0 ;
2013-06-21 18:27:59 +04:00
if ( ! ( * vm = virDomainObjNew ( xmlopt ) ) )
2019-11-12 23:46:29 +03:00
return - 1 ;
2013-06-21 18:27:59 +04:00
2013-07-02 12:16:30 +04:00
priv = ( * vm ) - > privateData ;
2023-03-09 18:47:32 +03:00
if ( ! ( priv - > qemuCaps = testQemuGetRealCaps ( arch , " latest " , " " ,
capsLatestFiles , capsCache ,
schemaCache , schema ) ) )
return - 1 ;
2013-07-18 13:21:34 +04:00
2017-04-11 15:02:06 +03:00
if ( qemuTestCapsCacheInsert ( driver . qemuCapsCache , priv - > qemuCaps ) < 0 )
2019-11-12 23:46:29 +03:00
return - 1 ;
2015-09-09 17:03:15 +03:00
if ( ! ( ( * vm ) - > def = virDomainDefParseString ( domxml ,
driver . xmlopt ,
2016-09-22 18:14:17 +03:00
NULL ,
2017-10-17 14:13:08 +03:00
parseFlags ) ) )
2019-11-12 23:46:29 +03:00
return - 1 ;
2015-09-09 17:03:15 +03:00
2016-11-03 23:33:32 +03:00
if ( qemuDomainAssignAddresses ( ( * vm ) - > def , priv - > qemuCaps ,
& driver , * vm , true ) < 0 ) {
2019-11-12 23:46:29 +03:00
return - 1 ;
2016-11-03 23:33:32 +03:00
}
2013-07-18 13:21:34 +04:00
2022-07-20 10:24:50 +03:00
if ( qemuAssignDeviceAliases ( ( * vm ) - > def ) < 0 )
2019-11-12 23:46:29 +03:00
return - 1 ;
2013-07-02 12:16:30 +04:00
2014-12-16 10:46:44 +03:00
( * vm ) - > def - > id = QEMU_HOTPLUG_TEST_DOMAIN_ID ;
2016-03-30 10:01:11 +03:00
if ( qemuDomainSetPrivatePaths ( & driver , * vm ) < 0 )
2019-11-12 23:46:29 +03:00
return - 1 ;
2016-03-30 10:01:11 +03:00
2019-11-12 23:46:29 +03:00
return 0 ;
2013-06-21 18:27:59 +04:00
}
2013-07-18 18:46:13 +04:00
static int
2021-03-11 10:16:13 +03:00
testQemuHotplugCheckResult ( virDomainObj * vm ,
2013-07-18 18:46:13 +04:00
const char * expected ,
2015-12-10 16:12:13 +03:00
const char * expectedFile ,
2013-07-18 18:46:13 +04:00
bool fail )
{
2020-07-28 22:57:28 +03:00
g_autofree char * actual = NULL ;
2013-07-18 18:46:13 +04:00
int ret ;
2019-11-27 14:57:34 +03:00
actual = virDomainDefFormat ( vm - > def , driver . xmlopt ,
2016-02-04 00:40:35 +03:00
VIR_DOMAIN_DEF_FORMAT_SECURE ) ;
2013-07-18 18:46:13 +04:00
if ( ! actual )
return - 1 ;
2023-04-21 10:56:20 +03:00
if ( STREQ_NULLABLE ( expected , actual ) ) {
2015-04-23 20:38:00 +03:00
if ( fail )
2019-05-03 11:45:58 +03:00
VIR_TEST_VERBOSE ( " domain XML should not match the expected result " ) ;
2013-07-18 18:46:13 +04:00
ret = 0 ;
} else {
if ( ! fail )
2016-05-26 18:01:54 +03:00
virTestDifferenceFull ( stderr ,
expected , expectedFile ,
actual , NULL ) ;
2013-07-18 18:46:13 +04:00
ret = - 1 ;
}
return ret ;
}
2013-06-21 18:27:59 +04:00
static int
testQemuHotplug ( const void * data )
{
int ret = - 1 ;
struct qemuHotplugTestData * test = ( struct qemuHotplugTestData * ) data ;
2020-07-28 22:57:28 +03:00
g_autofree char * domain_filename = NULL ;
g_autofree char * device_filename = NULL ;
g_autofree char * result_filename = NULL ;
g_autofree char * domain_xml = NULL ;
g_autofree char * device_xml = NULL ;
g_autofree char * result_xml = NULL ;
2013-06-21 18:27:59 +04:00
const char * const * tmp ;
bool fail = test - > fail ;
2013-07-02 12:16:30 +04:00
bool keep = test - > keep ;
2014-03-19 18:46:07 +04:00
unsigned int device_parse_flags = 0 ;
2021-03-11 10:16:13 +03:00
virDomainObj * vm = NULL ;
2023-04-20 18:59:14 +03:00
g_autoptr ( virDomainDeviceDef ) dev = NULL ;
2021-11-01 11:51:01 +03:00
g_autoptr ( qemuMonitorTest ) test_mon = NULL ;
2021-03-11 10:16:13 +03:00
qemuDomainObjPrivate * priv = NULL ;
2013-06-21 18:27:59 +04:00
2019-10-22 16:26:14 +03:00
domain_filename = g_strdup_printf ( " %s/qemuhotplugtestdomains/qemuhotplug-%s.xml " ,
abs_srcdir , test - > domain_filename ) ;
device_filename = g_strdup_printf ( " %s/qemuhotplugtestdevices/qemuhotplug-%s.xml " ,
abs_srcdir , test - > device_filename ) ;
result_filename = g_strdup_printf ( " %s/qemuhotplugtestdomains/qemuhotplug-%s+%s.xml " ,
abs_srcdir , test - > domain_filename ,
test - > device_filename ) ;
2013-07-18 18:46:13 +04:00
2016-05-26 18:01:52 +03:00
if ( virTestLoadFile ( domain_filename , & domain_xml ) < 0 | |
virTestLoadFile ( device_filename , & device_xml ) < 0 )
2013-07-18 18:46:13 +04:00
goto cleanup ;
2023-04-21 10:56:20 +03:00
if ( ! fail & &
( test - > action = = ATTACH | |
test - > action = = UPDATE ) & &
2016-05-26 18:01:52 +03:00
virTestLoadFile ( result_filename , & result_xml ) < 0 )
2013-06-21 18:27:59 +04:00
goto cleanup ;
2013-07-02 12:16:30 +04:00
if ( test - > vm ) {
vm = test - > vm ;
2017-06-29 16:20:54 +03:00
if ( ! vm - > def ) {
2019-05-03 11:45:58 +03:00
VIR_TEST_VERBOSE ( " test skipped due to failure of dependent test " ) ;
2017-06-29 16:20:54 +03:00
goto cleanup ;
}
2013-07-02 12:16:30 +04:00
} else {
2023-03-09 18:47:32 +03:00
if ( qemuHotplugCreateObjects ( driver . xmlopt , & vm , domain_xml ,
test - > arch , test - > capsLatestFiles ,
test - > capsCache , test - > schemaCache ,
2023-03-09 20:07:45 +03:00
& test - > schema ) < 0 )
2013-07-02 12:16:30 +04:00
goto cleanup ;
}
2013-06-21 18:27:59 +04:00
2014-03-19 18:46:07 +04:00
if ( test - > action = = ATTACH )
2014-11-18 19:44:00 +03:00
device_parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE ;
2014-03-19 18:46:07 +04:00
2013-06-21 18:27:59 +04:00
if ( ! ( dev = virDomainDeviceDefParse ( device_xml , vm - > def ,
2019-11-27 15:29:21 +03:00
driver . xmlopt , NULL ,
2014-03-19 18:46:07 +04:00
device_parse_flags ) ) )
2013-06-21 18:27:59 +04:00
goto cleanup ;
/* Now is the best time to feed the spoofed monitor with predefined
* replies . */
2023-03-09 20:07:45 +03:00
if ( ! ( test_mon = qemuMonitorTestNew ( driver . xmlopt , vm , NULL , test - > schema ) ) )
2013-06-21 18:27:59 +04:00
goto cleanup ;
tmp = test - > mon ;
while ( tmp & & * tmp ) {
const char * command_name ;
const char * response ;
if ( ! ( command_name = * tmp + + ) | |
! ( response = * tmp + + ) )
break ;
if ( qemuMonitorTestAddItem ( test_mon , command_name , response ) < 0 )
goto cleanup ;
}
2023-04-20 18:16:46 +03:00
/* After successful attach, we list all aliases. We don't care for that in
* the test . Add a dummy reply . */
if ( test - > action = = ATTACH & &
qemuMonitorTestAddItem ( test_mon , " qom-list " , " { \" return \" :[]} " ) < 0 )
goto cleanup ;
2013-07-02 12:16:30 +04:00
priv = vm - > privateData ;
2013-06-21 18:27:59 +04:00
priv - > mon = qemuMonitorTestGetMonitor ( test_mon ) ;
2023-04-20 18:59:02 +03:00
/* We need to unlock the monitor here, as any function below talks
* ( transitively ) on the monitor . */
2013-06-21 18:27:59 +04:00
virObjectUnlock ( priv - > mon ) ;
2013-07-02 12:16:30 +04:00
switch ( test - > action ) {
case ATTACH :
2023-04-20 18:16:46 +03:00
ret = qemuDomainAttachDeviceLive ( vm , dev , & driver ) ;
2013-07-18 18:46:13 +04:00
if ( ret = = 0 | | fail )
2015-12-10 16:12:13 +03:00
ret = testQemuHotplugCheckResult ( vm , result_xml ,
result_filename , fail ) ;
2013-06-21 18:27:59 +04:00
break ;
2013-07-02 12:16:30 +04:00
case DETACH :
2023-04-20 17:53:02 +03:00
ret = qemuDomainDetachDeviceLive ( vm , dev , & driver , false ) ;
2013-07-18 18:46:13 +04:00
if ( ret = = 0 | | fail )
2015-12-10 16:12:13 +03:00
ret = testQemuHotplugCheckResult ( vm , domain_xml ,
domain_filename , fail ) ;
2013-06-21 18:27:59 +04:00
break ;
2013-07-02 12:16:30 +04:00
case UPDATE :
2023-04-20 18:47:04 +03:00
ret = qemuDomainUpdateDeviceLive ( vm , dev , & driver , false ) ;
2023-04-21 10:56:20 +03:00
if ( ret = = 0 | | fail )
ret = testQemuHotplugCheckResult ( vm , result_xml ,
result_filename , fail ) ;
2013-06-21 18:27:59 +04:00
}
2020-03-12 21:33:51 +03:00
virObjectLock ( priv - > mon ) ;
2014-03-25 10:53:44 +04:00
cleanup :
2013-06-21 18:27:59 +04:00
/* don't dispose test monitor with VM */
if ( priv )
priv - > mon = NULL ;
2013-07-02 12:16:30 +04:00
if ( keep ) {
test - > vm = vm ;
} else {
virObjectUnref ( vm ) ;
test - > vm = NULL ;
}
2013-06-21 18:27:59 +04:00
return ( ( ret < 0 & & fail ) | | ( ! ret & & ! fail ) ) ? 0 : - 1 ;
}
2016-12-04 21:08:25 +03:00
struct testQemuHotplugCpuData {
char * file_xml_dom ;
char * file_xml_res_live ;
char * file_xml_res_conf ;
char * file_json_monitor ;
char * xml_dom ;
2021-03-11 10:16:13 +03:00
virDomainObj * vm ;
qemuMonitorTest * mon ;
2016-12-04 21:08:25 +03:00
} ;
static void
testQemuHotplugCpuDataFree ( struct testQemuHotplugCpuData * data )
{
2021-03-11 10:16:13 +03:00
qemuDomainObjPrivate * priv ;
qemuMonitor * mon ;
2017-02-02 18:42:18 +03:00
2016-12-04 21:08:25 +03:00
if ( ! data )
return ;
2021-02-03 22:35:02 +03:00
g_free ( data - > file_xml_dom ) ;
g_free ( data - > file_xml_res_live ) ;
g_free ( data - > file_xml_res_conf ) ;
g_free ( data - > file_json_monitor ) ;
2016-12-04 21:08:25 +03:00
2021-02-03 22:35:02 +03:00
g_free ( data - > xml_dom ) ;
2016-12-04 21:08:25 +03:00
2017-02-02 18:42:18 +03:00
if ( data - > vm ) {
priv = data - > vm - > privateData ;
priv - > mon = NULL ;
virObjectUnref ( data - > vm ) ;
}
2020-06-27 10:20:21 +03:00
if ( data - > mon ) {
mon = qemuMonitorTestGetMonitor ( data - > mon ) ;
virObjectLock ( mon ) ;
qemuMonitorTestFree ( data - > mon ) ;
}
2021-02-03 22:35:02 +03:00
g_free ( data ) ;
2016-12-04 21:08:25 +03:00
}
2023-03-09 18:11:47 +03:00
struct testQemuHotplugCpuParams {
const char * test ;
int newcpus ;
const char * cpumap ;
bool state ;
bool fail ;
2023-03-09 18:47:32 +03:00
const char * arch ;
GHashTable * capsLatestFiles ;
GHashTable * capsCache ;
GHashTable * schemaCache ;
2023-03-09 18:11:47 +03:00
} ;
2016-12-04 21:08:25 +03:00
static struct testQemuHotplugCpuData *
2023-03-09 18:11:47 +03:00
testQemuHotplugCpuPrepare ( const struct testQemuHotplugCpuParams * params )
2016-12-04 21:08:25 +03:00
{
2021-03-11 10:16:13 +03:00
qemuDomainObjPrivate * priv = NULL ;
2020-07-28 22:57:28 +03:00
g_autofree char * prefix = NULL ;
2016-12-04 21:08:25 +03:00
struct testQemuHotplugCpuData * data = NULL ;
2023-03-09 18:47:32 +03:00
GHashTable * schema = NULL ;
2016-12-04 21:08:25 +03:00
2023-03-09 18:11:47 +03:00
prefix = g_strdup_printf ( " %s/qemuhotplugtestcpus/%s " , abs_srcdir , params - > test ) ;
2016-12-04 21:08:25 +03:00
2020-09-23 01:42:45 +03:00
data = g_new0 ( struct testQemuHotplugCpuData , 1 ) ;
2016-12-04 21:08:25 +03:00
2019-10-22 16:26:14 +03:00
data - > file_xml_dom = g_strdup_printf ( " %s-domain.xml " , prefix ) ;
data - > file_xml_res_live = g_strdup_printf ( " %s-result-live.xml " , prefix ) ;
data - > file_xml_res_conf = g_strdup_printf ( " %s-result-conf.xml " , prefix ) ;
data - > file_json_monitor = g_strdup_printf ( " %s-monitor.json " , prefix ) ;
2016-12-04 21:08:25 +03:00
if ( virTestLoadFile ( data - > file_xml_dom , & data - > xml_dom ) < 0 )
goto error ;
2023-03-09 18:47:32 +03:00
if ( qemuHotplugCreateObjects ( driver . xmlopt , & data - > vm , data - > xml_dom ,
params - > arch , params - > capsLatestFiles ,
params - > capsCache , params - > schemaCache , & schema ) < 0 )
2016-12-04 21:08:25 +03:00
goto error ;
/* create vm->newDef */
data - > vm - > persistent = true ;
2019-11-27 15:41:59 +03:00
if ( virDomainObjSetDefTransient ( driver . xmlopt , data - > vm , NULL ) < 0 )
2016-12-04 21:08:25 +03:00
goto error ;
priv = data - > vm - > privateData ;
if ( ! ( data - > mon = qemuMonitorTestNewFromFileFull ( data - > file_json_monitor ,
2023-03-09 18:47:32 +03:00
& driver , data - > vm , schema ) ) )
2016-12-04 21:08:25 +03:00
goto error ;
2023-03-09 18:11:47 +03:00
if ( params - > fail )
2020-04-29 19:27:00 +03:00
qemuMonitorTestAllowUnusedCommands ( data - > mon ) ;
2020-04-23 17:57:31 +03:00
2016-12-04 21:08:25 +03:00
priv - > mon = qemuMonitorTestGetMonitor ( data - > mon ) ;
virObjectUnlock ( priv - > mon ) ;
2022-08-10 15:57:02 +03:00
if ( qemuDomainRefreshVcpuInfo ( data - > vm , 0 , false ) < 0 )
2016-12-04 21:08:25 +03:00
goto error ;
return data ;
error :
testQemuHotplugCpuDataFree ( data ) ;
return NULL ;
}
static int
testQemuHotplugCpuFinalize ( struct testQemuHotplugCpuData * data )
{
2020-07-28 22:57:28 +03:00
g_autofree char * activeXML = NULL ;
g_autofree char * configXML = NULL ;
2016-12-04 21:08:25 +03:00
if ( data - > file_xml_res_live ) {
2019-11-27 14:57:34 +03:00
if ( ! ( activeXML = virDomainDefFormat ( data - > vm - > def , driver . xmlopt ,
2016-12-04 21:08:25 +03:00
VIR_DOMAIN_DEF_FORMAT_SECURE ) ) )
2020-07-29 00:17:02 +03:00
return - 1 ;
2016-12-04 21:08:25 +03:00
if ( virTestCompareToFile ( activeXML , data - > file_xml_res_live ) < 0 )
2020-07-29 00:17:02 +03:00
return - 1 ;
2016-12-04 21:08:25 +03:00
}
if ( data - > file_xml_res_conf ) {
2019-11-27 14:57:34 +03:00
if ( ! ( configXML = virDomainDefFormat ( data - > vm - > newDef , driver . xmlopt ,
2016-12-04 21:08:25 +03:00
VIR_DOMAIN_DEF_FORMAT_SECURE |
VIR_DOMAIN_DEF_FORMAT_INACTIVE ) ) )
2020-07-29 00:17:02 +03:00
return - 1 ;
2016-12-04 21:08:25 +03:00
if ( virTestCompareToFile ( configXML , data - > file_xml_res_conf ) < 0 )
2020-07-29 00:17:02 +03:00
return - 1 ;
2016-12-04 21:08:25 +03:00
}
2020-07-29 00:17:02 +03:00
return 0 ;
2016-12-04 21:08:25 +03:00
}
static int
testQemuHotplugCpuGroup ( const void * opaque )
{
const struct testQemuHotplugCpuParams * params = opaque ;
struct testQemuHotplugCpuData * data = NULL ;
int ret = - 1 ;
int rc ;
2023-03-09 18:11:47 +03:00
if ( ! ( data = testQemuHotplugCpuPrepare ( params ) ) )
2016-12-04 21:08:25 +03:00
return - 1 ;
rc = qemuDomainSetVcpusInternal ( & driver , data - > vm , data - > vm - > def ,
data - > vm - > newDef , params - > newcpus ,
2023-08-28 15:34:36 +03:00
true ) ;
2016-12-04 21:08:25 +03:00
if ( params - > fail ) {
if ( rc = = 0 )
fprintf ( stderr , " cpu test '%s' should have failed \n " , params - > test ) ;
else
ret = 0 ;
goto cleanup ;
} else {
if ( rc < 0 )
goto cleanup ;
}
ret = testQemuHotplugCpuFinalize ( data ) ;
cleanup :
testQemuHotplugCpuDataFree ( data ) ;
return ret ;
}
2017-02-10 19:14:22 +03:00
static int
testQemuHotplugCpuIndividual ( const void * opaque )
{
const struct testQemuHotplugCpuParams * params = opaque ;
struct testQemuHotplugCpuData * data = NULL ;
2020-07-28 22:58:18 +03:00
g_autoptr ( virBitmap ) map = NULL ;
2017-02-10 19:14:22 +03:00
int ret = - 1 ;
int rc ;
2023-03-09 18:11:47 +03:00
if ( ! ( data = testQemuHotplugCpuPrepare ( params ) ) )
2017-02-10 19:14:22 +03:00
return - 1 ;
if ( virBitmapParse ( params - > cpumap , & map , 128 ) < 0 )
goto cleanup ;
rc = qemuDomainSetVcpuInternal ( & driver , data - > vm , data - > vm - > def ,
data - > vm - > newDef , map , params - > state ) ;
if ( params - > fail ) {
if ( rc = = 0 )
fprintf ( stderr , " cpu test '%s' should have failed \n " , params - > test ) ;
else
ret = 0 ;
goto cleanup ;
} else {
if ( rc < 0 )
goto cleanup ;
}
ret = testQemuHotplugCpuFinalize ( data ) ;
cleanup :
testQemuHotplugCpuDataFree ( data ) ;
return ret ;
}
2013-06-21 18:27:59 +04:00
static int
mymain ( void )
{
int ret = 0 ;
2019-12-10 02:15:27 +03:00
g_autoptr ( virQEMUDriverConfig ) cfg = NULL ;
2023-03-09 18:47:32 +03:00
g_autoptr ( GHashTable ) capsLatestFiles = testQemuGetLatestCaps ( ) ;
g_autoptr ( GHashTable ) capsCache = virHashNew ( virObjectUnref ) ;
g_autoptr ( GHashTable ) schemaCache = virHashNew ( ( GDestroyNotify ) g_hash_table_unref ) ;
struct qemuHotplugTestData data = { . capsLatestFiles = capsLatestFiles ,
. capsCache = capsCache ,
. schemaCache = schemaCache } ;
struct testQemuHotplugCpuParams cpudata = { . capsLatestFiles = capsLatestFiles ,
. capsCache = capsCache ,
. schemaCache = schemaCache } ;
2019-08-29 22:19:00 +03:00
2019-09-16 19:44:23 +03:00
if ( qemuTestDriverInit ( & driver ) < 0 )
2013-06-21 18:27:59 +04:00
return EXIT_FAILURE ;
2019-12-10 02:15:27 +03:00
cfg = virQEMUDriverGetConfig ( & driver ) ;
2013-06-21 18:27:59 +04:00
virEventRegisterDefaultImpl ( ) ;
2013-07-18 13:21:34 +04:00
driver . lockManager = virLockManagerPluginNew ( " nop " , " qemu " ,
driver . config - > configBaseDir ,
0 ) ;
if ( ! driver . lockManager )
return EXIT_FAILURE ;
2019-08-29 22:19:00 +03:00
driver . hostdevMgr = virHostdevManagerGetDefault ( ) ;
2020-01-16 11:13:28 +03:00
if ( driver . hostdevMgr = = NULL ) {
VIR_TEST_VERBOSE ( " Could not initialize HostdevManager - %s \n " ,
virGetLastErrorMessage ( ) ) ;
return EXIT_FAILURE ;
}
2019-08-29 22:19:00 +03:00
2013-07-26 16:22:10 +04:00
2023-03-09 18:47:32 +03:00
# define DO_TEST(archname, file, ACTION, dev, fail_, keep_, ...) \
2017-11-03 15:09:47 +03:00
do { \
const char * my_mon [ ] = { __VA_ARGS__ , NULL } ; \
const char * name = file " " # ACTION " " dev ; \
2023-03-09 18:47:32 +03:00
data . arch = archname ; \
2017-11-03 15:09:47 +03:00
data . action = ACTION ; \
data . domain_filename = file ; \
data . device_filename = dev ; \
2020-09-02 22:45:38 +03:00
data . fail = fail_ ; \
2017-11-03 15:09:47 +03:00
data . mon = my_mon ; \
2020-09-02 22:45:38 +03:00
data . keep = keep_ ; \
2017-11-03 15:09:47 +03:00
if ( virTestRun ( name , testQemuHotplug , & data ) < 0 ) \
ret = - 1 ; \
2013-07-18 13:07:21 +04:00
} while ( 0 )
2013-07-02 12:16:30 +04:00
2023-03-09 18:47:32 +03:00
# define DO_TEST_ATTACH(arch, file, dev, fail, keep, ...) \
DO_TEST ( arch , file , ATTACH , dev , fail , keep , __VA_ARGS__ )
2013-07-02 12:16:30 +04:00
2023-03-09 18:47:32 +03:00
# define DO_TEST_DETACH(arch, file, dev, fail, keep, ...) \
DO_TEST ( arch , file , DETACH , dev , fail , keep , __VA_ARGS__ )
2013-07-26 16:22:10 +04:00
2023-03-09 18:47:32 +03:00
# define DO_TEST_UPDATE(arch, file, dev, fail, keep, ...) \
DO_TEST ( arch , file , UPDATE , dev , fail , keep , __VA_ARGS__ )
2013-06-21 18:27:59 +04:00
2013-07-26 17:06:37 +04:00
# define QMP_OK "{\"return\": {}}"
2023-04-19 17:49:52 +03:00
# define QMP_EMPTY_ARRAY "{\"return\": []}"
2013-07-26 17:06:37 +04:00
2013-07-19 15:04:44 +04:00
# define QMP_DEVICE_DELETED(dev) \
2017-11-03 15:09:47 +03:00
" { " \
" \" timestamp \" : { " \
" \" seconds \" : 1374137171, " \
" \" microseconds \" : 2659 " \
" }, " \
" \" event \" : \" DEVICE_DELETED \" , " \
" \" data \" : { " \
" \" device \" : \" " dev " \" , " \
" \" path \" : \" /machine/peripheral/ " dev " \" " \
" } " \
2013-07-19 15:04:44 +04:00
" } \r \n "
2019-12-10 02:15:27 +03:00
cfg - > spiceTLS = true ;
2023-03-09 18:47:32 +03:00
DO_TEST_UPDATE ( " x86_64 " , " graphics-spice " , " graphics-spice-nochange " , false , false , NULL ) ;
DO_TEST_UPDATE ( " x86_64 " , " graphics-spice-timeout " , " graphics-spice-timeout-nochange " , false , false ,
2013-07-26 17:06:37 +04:00
" set_password " , QMP_OK , " expire_password " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_UPDATE ( " x86_64 " , " graphics-spice-timeout " , " graphics-spice-timeout-password " , false , false ,
2013-07-26 17:06:37 +04:00
" set_password " , QMP_OK , " expire_password " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_UPDATE ( " x86_64 " , " graphics-spice " , " graphics-spice-listen " , true , false , NULL ) ;
DO_TEST_UPDATE ( " x86_64 " , " graphics-spice-listen-network " , " graphics-spice-listen-network-password " , false , false ,
2013-07-26 17:06:37 +04:00
" set_password " , QMP_OK , " expire_password " , QMP_OK ) ;
2019-12-10 02:15:27 +03:00
cfg - > spiceTLS = false ;
2023-04-20 18:47:04 +03:00
DO_TEST_UPDATE ( " x86_64 " , " disk-cdrom " , " disk-cdrom-nochange " , false , false , NULL ) ;
2013-07-02 12:16:30 +04:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " console-compat-2-live " , " console-virtio " , false , true ,
2013-07-02 12:16:30 +04:00
" chardev-add " , " { \" return \" : { \" pty \" : \" /dev/pts/26 \" }} " ,
2013-07-26 17:06:37 +04:00
" device_add " , QMP_OK ) ;
2013-07-02 12:16:30 +04:00
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " console-compat-2-live " , " console-virtio " , false , false ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " console1 " ) QMP_OK ,
2022-02-03 12:35:03 +03:00
" chardev-remove " , QMP_OK , " query-fdsets " , " { \" return \" : []} " ) ;
2013-06-21 18:27:59 +04:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " disk-virtio " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " disk-virtio " , true , true ,
2020-04-23 11:36:59 +03:00
" device_del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " disk-virtio " , false , false ,
2013-07-19 15:04:44 +04:00
" device_del " , QMP_DEVICE_DELETED ( " virtio-disk4 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2013-07-19 15:04:44 +04:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " disk-usb " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " disk-usb " , true , true ,
2020-04-23 11:36:59 +03:00
" device_del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " disk-usb " , false , false ,
2013-07-26 16:44:52 +04:00
" device_del " , QMP_DEVICE_DELETED ( " usb-disk16 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2013-07-26 16:44:52 +04:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " disk-scsi " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " disk-scsi " , true , true ,
2020-04-23 11:36:59 +03:00
" device_del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " disk-scsi " , false , false ,
2013-07-26 17:28:33 +04:00
" device_del " , QMP_DEVICE_DELETED ( " scsi0-0-0-5 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2013-07-26 17:28:33 +04:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-without-scsi-controller-live " , " disk-scsi-2 " , false , true ,
2019-02-07 14:06:12 +03:00
/* Four controllers added */
" device_add " , QMP_OK ,
" device_add " , QMP_OK ,
" device_add " , QMP_OK ,
" device_add " , QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-with-scsi-controller-live " , " disk-scsi-2 " , true , true ,
2020-04-23 17:38:30 +03:00
" device_del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-with-scsi-controller-live " , " disk-scsi-2 " , false , false ,
2023-03-09 19:12:54 +03:00
" device_del " , QMP_DEVICE_DELETED ( " scsi3-0-6 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2016-06-27 17:43:48 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " disk-scsi-multipath " , false , true ,
2019-11-13 17:34:50 +03:00
" object-add " , QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " disk-scsi-multipath " , true , true ,
2020-04-23 17:38:30 +03:00
" device_del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " disk-scsi-multipath " , false , false ,
2019-11-13 17:34:50 +03:00
" device_del " , QMP_DEVICE_DELETED ( " scsi0-0-0-0 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ,
2020-04-23 13:03:21 +03:00
" object-del " , QMP_OK ) ;
2019-11-13 17:34:50 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " qemu-agent " , false , true ,
2022-02-14 18:51:20 +03:00
" getfd " , QMP_OK ,
2016-03-30 17:43:28 +03:00
" chardev-add " , QMP_OK ,
" device_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " qemu-agent-detach " , false , false ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " channel0 " ) QMP_OK ,
2022-02-03 12:35:03 +03:00
" chardev-remove " , QMP_OK , " query-fdsets " , " { \" return \" : []} " ) ;
2016-03-30 17:43:28 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " s390x " , " base-ccw-live " , " ccw-virtio " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " s390x " , " base-ccw-live " , " ccw-virtio " , false , false ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " virtio-disk4 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2016-07-22 21:10:47 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " s390x " , " base-ccw-live-with-ccw-virtio " , " ccw-virtio-2 " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2016-07-22 21:10:47 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " s390x " , " base-ccw-live-with-ccw-virtio " , " ccw-virtio-2 " , false , false ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " virtio-disk0 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2016-07-22 21:10:47 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " s390x " , " base-ccw-live-with-ccw-virtio " , " ccw-virtio-2-explicit " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2016-07-22 21:10:47 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " s390x " , " base-ccw-live-with-ccw-virtio " , " ccw-virtio-2-explicit " , false , false ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " virtio-disk0 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2016-07-22 21:10:47 +03:00
/* Attach a second device, then detach the first one. Then attach the first one again. */
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " s390x " , " base-ccw-live-with-ccw-virtio " , " ccw-virtio-2-explicit " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2016-07-22 21:10:47 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " s390x " , " base-ccw-live-with-2-ccw-virtio " , " ccw-virtio-1-explicit " , false , true ,
2022-07-21 15:33:06 +03:00
" device_del " , QMP_DEVICE_DELETED ( " virtio-disk4 " ) QMP_OK ) ;
2016-07-22 21:10:47 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " s390x " , " base-ccw-live-with-2-ccw-virtio " , " ccw-virtio-1-reverse " , false , false ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2016-07-22 21:10:47 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " ivshmem-plain " , false , true ,
2016-09-12 16:40:48 +03:00
" object-add " , QMP_OK ,
" device_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " ivshmem-doorbell " , false , true ,
2016-09-12 16:40:48 +03:00
" chardev-add " , QMP_OK ,
" device_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live+ivshmem-plain " , " ivshmem-doorbell-detach " , false , true ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " shmem1 " ) QMP_OK ,
2016-09-12 16:40:48 +03:00
" chardev-remove " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " ivshmem-plain-detach " , false , false ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " shmem0 " ) QMP_OK ,
2016-09-12 16:40:48 +03:00
" object-del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live+disk-scsi-wwn " ,
2017-09-01 14:39:15 +03:00
" disk-scsi-duplicate-wwn " , false , false ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2016-09-12 16:40:48 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " hostdev-pci " , false , true ,
2019-08-29 22:19:00 +03:00
" device_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " hostdev-pci " , false , false ,
2019-08-29 22:19:00 +03:00
" device_del " , QMP_DEVICE_DELETED ( " hostdev0 " ) QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " ppc64 " , " pseries-base-live " , " hostdev-pci " , false , true ,
2019-08-29 22:19:00 +03:00
" device_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " ppc64 " , " pseries-base-live " , " hostdev-pci " , false , false ,
2019-08-29 22:19:00 +03:00
" device_del " , QMP_DEVICE_DELETED ( " hostdev0 " ) QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " interface-vdpa " , false , true ,
2022-05-05 17:34:52 +03:00
" query-fdsets " , " { \" return \" :[{ \" fdset-id \" :99999}]} " ,
2020-10-14 20:08:29 +03:00
" add-fd " , " { \" return \" : { \" fdset-id \" : 1, \" fd \" : 95 }} " ,
" netdev_add " , QMP_OK , " device_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " interface-vdpa " , false , false ,
2020-10-14 20:08:29 +03:00
" device_del " , QMP_DEVICE_DELETED ( " net0 " ) QMP_OK ,
" netdev_del " , QMP_OK ,
" query-fdsets " ,
" { \" return \" : [{ \" fds \" : [{ \" fd \" : 95, \" opaque \" : \" /dev/vhost-vdpa-0 \" }], \" fdset-id \" : 1}]} " ,
" remove-fd " , QMP_OK
) ;
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " watchdog " , false , true ,
2023-03-09 18:53:25 +03:00
" set-action " , QMP_OK ,
2017-09-01 14:39:15 +03:00
" device_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " watchdog-full " , false , false ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " watchdog0 " ) QMP_OK ) ;
2017-09-01 14:39:15 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " watchdog-user-alias " , false , true ,
2023-03-09 18:53:25 +03:00
" set-action " , QMP_OK ,
2017-10-22 16:42:45 +03:00
" device_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " watchdog-user-alias-full " , false , false ,
2019-02-07 13:55:12 +03:00
" device_del " , QMP_DEVICE_DELETED ( " ua-UserWatchdog " ) QMP_OK ) ;
2017-10-22 16:42:45 +03:00
2023-04-19 15:07:26 +03:00
/* attaching a watchdog with different action should fail */
DO_TEST_ATTACH ( " x86_64 " , " base-live+watchdog " , " watchdog-reset " , true , false , NULL ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " guestfwd " , false , true ,
2022-02-14 18:51:20 +03:00
" getfd " , QMP_OK ,
2019-02-11 18:17:53 +03:00
" chardev-add " , QMP_OK ,
" netdev_add " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " guestfwd " , false , false ,
2019-02-11 18:17:53 +03:00
" netdev_del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " cdrom-usb " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " cdrom-usb " , true , true ,
2022-07-06 12:57:10 +03:00
" device_del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " cdrom-usb " , false , false ,
2022-07-06 12:57:10 +03:00
" device_del " , QMP_DEVICE_DELETED ( " usb-disk4 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2022-07-06 12:57:10 +03:00
2023-03-09 18:47:32 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " cdrom-scsi " , false , true ,
2022-07-21 15:33:06 +03:00
" blockdev-add " , QMP_OK ,
2023-04-19 17:49:52 +03:00
" device_add " , QMP_OK ,
" query-block " , QMP_EMPTY_ARRAY ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " cdrom-scsi " , true , true ,
2022-07-06 12:57:10 +03:00
" device_del " , QMP_OK ) ;
2023-03-09 18:47:32 +03:00
DO_TEST_DETACH ( " x86_64 " , " base-live " , " cdrom-scsi " , false , false ,
2022-07-06 12:57:10 +03:00
" device_del " , QMP_DEVICE_DELETED ( " scsi0-0-0-4 " ) QMP_OK ,
2022-07-21 15:33:06 +03:00
" blockdev-del " , QMP_OK ) ;
2024-05-15 13:27:54 +03:00
DO_TEST_ATTACH ( " x86_64 " , " base-live " , " input-evdev " , false , true ,
" object-add " , QMP_OK ) ;
DO_TEST_DETACH ( " x86_64 " , " base-live " , " input-evdev " , false , false ,
" object-del " , QMP_OK ) ;
2022-07-06 12:57:10 +03:00
2023-08-28 15:34:36 +03:00
# define DO_TEST_CPU_GROUP(archname, prefix, vcpus, expectfail) \
2017-11-03 15:09:47 +03:00
do { \
cpudata . test = prefix ; \
2023-03-09 18:47:32 +03:00
cpudata . arch = archname ; \
2017-11-03 15:09:47 +03:00
cpudata . newcpus = vcpus ; \
cpudata . fail = expectfail ; \
if ( virTestRun ( " hotplug vcpus group " prefix , \
testQemuHotplugCpuGroup , & cpudata ) < 0 ) \
ret = - 1 ; \
2016-12-04 21:08:25 +03:00
} while ( 0 )
2023-08-28 15:34:36 +03:00
DO_TEST_CPU_GROUP ( " x86_64 " , " x86-modern-bulk " , 7 , false ) ;
DO_TEST_CPU_GROUP ( " ppc64 " , " ppc64-modern-bulk " , 24 , false ) ;
DO_TEST_CPU_GROUP ( " ppc64 " , " ppc64-modern-bulk " , 15 , true ) ;
DO_TEST_CPU_GROUP ( " ppc64 " , " ppc64-modern-bulk " , 23 , true ) ;
DO_TEST_CPU_GROUP ( " ppc64 " , " ppc64-modern-bulk " , 25 , true ) ;
2016-12-04 21:08:25 +03:00
2023-08-28 15:34:36 +03:00
# define DO_TEST_CPU_INDIVIDUAL(archname, prefix, mapstr, statefl, expectfail) \
2017-11-03 15:09:47 +03:00
do { \
cpudata . test = prefix ; \
2023-03-09 18:47:32 +03:00
cpudata . arch = archname ; \
2017-11-03 15:09:47 +03:00
cpudata . cpumap = mapstr ; \
cpudata . state = statefl ; \
cpudata . fail = expectfail ; \
if ( virTestRun ( " hotplug vcpus group " prefix , \
testQemuHotplugCpuIndividual , & cpudata ) < 0 ) \
ret = - 1 ; \
2017-02-10 19:14:22 +03:00
} while ( 0 )
2023-08-28 15:34:36 +03:00
DO_TEST_CPU_INDIVIDUAL ( " x86_64 " , " x86-modern-individual-add " , " 7 " , true , false ) ;
DO_TEST_CPU_INDIVIDUAL ( " x86_64 " , " x86-modern-individual-add " , " 6,7 " , true , true ) ;
DO_TEST_CPU_INDIVIDUAL ( " x86_64 " , " x86-modern-individual-add " , " 7 " , false , true ) ;
2017-02-10 19:14:22 +03:00
2023-08-28 15:34:36 +03:00
DO_TEST_CPU_INDIVIDUAL ( " ppc64 " , " ppc64-modern-individual " , " 16-23 " , true , false ) ;
DO_TEST_CPU_INDIVIDUAL ( " ppc64 " , " ppc64-modern-individual " , " 16-22 " , true , true ) ;
DO_TEST_CPU_INDIVIDUAL ( " ppc64 " , " ppc64-modern-individual " , " 17 " , true , true ) ;
2017-02-10 19:14:22 +03:00
2015-09-15 09:16:02 +03:00
qemuTestDriverFree ( & driver ) ;
2017-08-04 16:25:40 +03:00
virObjectUnref ( data . vm ) ;
2013-06-21 18:27:59 +04:00
return ( ret = = 0 ) ? EXIT_SUCCESS : EXIT_FAILURE ;
}
2019-08-29 22:19:00 +03:00
VIR_TEST_MAIN_PRELOAD ( mymain ,
2020-05-06 15:38:42 +03:00
VIR_TEST_MOCK ( " virhostdev " ) ,
2019-08-29 22:19:00 +03:00
VIR_TEST_MOCK ( " virpci " ) ,
2019-11-15 13:56:46 +03:00
VIR_TEST_MOCK ( " domaincaps " ) ,
2019-10-18 21:36:32 +03:00
VIR_TEST_MOCK ( " virprocess " ) ,
VIR_TEST_MOCK ( " qemuhotplug " ) ) ;