mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
tests: Add support for passing vm to qemu monitor
Some tests need the monitor to operate on an already existing VM object rather than on a new mock-up the monitor test normally creates.
This commit is contained in:
parent
2074574821
commit
a950b4f91d
@ -242,7 +242,7 @@ testQemuHotplug(const void *data)
|
||||
|
||||
/* Now is the best time to feed the spoofed monitor with predefined
|
||||
* replies. */
|
||||
if (!(test_mon = qemuMonitorTestNew(true, driver.xmlopt)))
|
||||
if (!(test_mon = qemuMonitorTestNew(true, driver.xmlopt, vm)))
|
||||
goto cleanup;
|
||||
|
||||
tmp = test->mon;
|
||||
|
@ -35,7 +35,7 @@ static int
|
||||
testQemuMonitorJSONGetStatus(const void *data)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
bool running = false;
|
||||
virDomainPausedReason reason = 0;
|
||||
@ -129,7 +129,7 @@ static int
|
||||
testQemuMonitorJSONGetVersion(const void *data)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
int major;
|
||||
int minor;
|
||||
@ -232,7 +232,7 @@ static int
|
||||
testQemuMonitorJSONGetMachines(const void *data)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
qemuMonitorMachineInfoPtr *info;
|
||||
int ninfo = 0;
|
||||
@ -314,7 +314,7 @@ static int
|
||||
testQemuMonitorJSONGetCPUDefinitions(const void *data)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
char **cpus = NULL;
|
||||
int ncpus = 0;
|
||||
@ -380,7 +380,7 @@ static int
|
||||
testQemuMonitorJSONGetCommands(const void *data)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
char **commands = NULL;
|
||||
int ncommands = 0;
|
||||
@ -445,7 +445,7 @@ static int
|
||||
testQemuMonitorJSONGetTPMModels(const void *data)
|
||||
{
|
||||
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
char **tpmmodels = NULL;
|
||||
int ntpmmodels = 0;
|
||||
@ -498,7 +498,7 @@ static int
|
||||
testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
||||
{
|
||||
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
char **params = NULL;
|
||||
int nparams = 0;
|
||||
@ -599,7 +599,7 @@ static int
|
||||
testQemuMonitorJSONAttachChardev(const void *data)
|
||||
{
|
||||
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
virDomainChrSourceDef chr;
|
||||
int ret = 0;
|
||||
|
||||
@ -680,7 +680,7 @@ static int
|
||||
testQemuMonitorJSONDetachChardev(const void *data)
|
||||
{
|
||||
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
|
||||
if (!test)
|
||||
@ -713,7 +713,7 @@ static int
|
||||
testQemuMonitorJSONGetListPaths(const void *data)
|
||||
{
|
||||
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
qemuMonitorJSONListPathPtr *paths;
|
||||
int npaths = 0;
|
||||
@ -791,7 +791,7 @@ static int
|
||||
testQemuMonitorJSONGetObjectProperty(const void *data)
|
||||
{
|
||||
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
qemuMonitorJSONObjectProperty prop;
|
||||
|
||||
@ -834,7 +834,7 @@ static int
|
||||
testQemuMonitorJSONSetObjectProperty(const void *data)
|
||||
{
|
||||
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
qemuMonitorJSONObjectProperty prop;
|
||||
|
||||
@ -886,7 +886,7 @@ static int
|
||||
testQemuMonitorJSONGetDeviceAliases(const void *data)
|
||||
{
|
||||
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
int ret = -1;
|
||||
char **aliases = NULL;
|
||||
char **alias;
|
||||
|
@ -743,6 +743,7 @@ static qemuAgentCallbacks qemuMonitorTestAgentCallbacks = {
|
||||
|
||||
static qemuMonitorTestPtr
|
||||
qemuMonitorCommonTestNew(virDomainXMLOptionPtr xmlopt,
|
||||
virDomainObjPtr vm,
|
||||
virDomainChrSourceDefPtr src)
|
||||
{
|
||||
qemuMonitorTestPtr test = NULL;
|
||||
@ -773,8 +774,14 @@ qemuMonitorCommonTestNew(virDomainXMLOptionPtr xmlopt,
|
||||
if (virAsprintf(&path, "%s/qemumonitorjsontest.sock", test->tmpdir) < 0)
|
||||
goto error;
|
||||
|
||||
if (!(test->vm = virDomainObjNew(xmlopt)))
|
||||
if (vm) {
|
||||
virObjectRef(vm);
|
||||
test->vm = vm;
|
||||
} else {
|
||||
test->vm = virDomainObjNew(xmlopt);
|
||||
if (!test->vm)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virNetSocketNewListenUNIX(path, 0700, getuid(), getgid(),
|
||||
&test->server) < 0)
|
||||
@ -860,12 +867,14 @@ error:
|
||||
#define QEMU_TEXT_GREETING "QEMU 1.0,1 monitor - type 'help' for more information"
|
||||
|
||||
qemuMonitorTestPtr
|
||||
qemuMonitorTestNew(bool json, virDomainXMLOptionPtr xmlopt)
|
||||
qemuMonitorTestNew(bool json,
|
||||
virDomainXMLOptionPtr xmlopt,
|
||||
virDomainObjPtr vm)
|
||||
{
|
||||
qemuMonitorTestPtr test = NULL;
|
||||
virDomainChrSourceDef src;
|
||||
|
||||
if (!(test = qemuMonitorCommonTestNew(xmlopt, &src)))
|
||||
if (!(test = qemuMonitorCommonTestNew(xmlopt, vm, &src)))
|
||||
goto error;
|
||||
|
||||
test->json = json;
|
||||
@ -902,7 +911,7 @@ qemuMonitorTestNewAgent(virDomainXMLOptionPtr xmlopt)
|
||||
qemuMonitorTestPtr test = NULL;
|
||||
virDomainChrSourceDef src;
|
||||
|
||||
if (!(test = qemuMonitorCommonTestNew(xmlopt, &src)))
|
||||
if (!(test = qemuMonitorCommonTestNew(xmlopt, NULL, &src)))
|
||||
goto error;
|
||||
|
||||
if (!(test->agent = qemuAgentOpen(test->vm,
|
||||
|
@ -59,8 +59,12 @@ int qemuMonitorTestAddItemParams(qemuMonitorTestPtr test,
|
||||
...)
|
||||
ATTRIBUTE_SENTINEL;
|
||||
|
||||
# define qemuMonitorTestNewSimple(json, xmlopt) \
|
||||
qemuMonitorTestNew(json, xmlopt, NULL)
|
||||
|
||||
qemuMonitorTestPtr qemuMonitorTestNew(bool json,
|
||||
virDomainXMLOptionPtr xmlopt);
|
||||
virDomainXMLOptionPtr xmlopt,
|
||||
virDomainObjPtr vm);
|
||||
|
||||
qemuMonitorTestPtr qemuMonitorTestNewAgent(virDomainXMLOptionPtr xmlopt);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user