mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
tests: Drop cleanup/error labels
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
74da85bcb9
commit
7c79cfe4da
@ -111,48 +111,45 @@ testQemuAgentFSFreeze(const void *data)
|
|||||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||||
const char *mountpoints[] = {"/fs1", "/fs2", "/fs3", "/fs4", "/fs5"};
|
const char *mountpoints[] = {"/fs1", "/fs2", "/fs3", "/fs4", "/fs5"};
|
||||||
int ret = -1;
|
int rc;
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze-list",
|
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze-list",
|
||||||
"{ \"return\" : 5 }") < 0)
|
"{ \"return\" : 5 }") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze",
|
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze",
|
||||||
"{ \"return\" : 7 }") < 0)
|
"{ \"return\" : 7 }") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if ((ret = qemuAgentFSFreeze(qemuMonitorTestGetAgent(test),
|
if ((rc = qemuAgentFSFreeze(qemuMonitorTestGetAgent(test),
|
||||||
mountpoints, 5)) < 0)
|
mountpoints, 5)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (ret != 5) {
|
if (rc != 5) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"expected 5 frozen filesystems, got %d", ret);
|
"expected 5 frozen filesystems, got %d", rc);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0)) < 0)
|
if ((rc = qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (ret != 7) {
|
if (rc != 7) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"expected 7 frozen filesystems, got %d", ret);
|
"expected 7 frozen filesystems, got %d", rc);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -161,47 +158,44 @@ testQemuAgentFSThaw(const void *data)
|
|||||||
{
|
{
|
||||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||||
int ret = -1;
|
int rc;
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw",
|
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw",
|
||||||
"{ \"return\" : 5 }") < 0)
|
"{ \"return\" : 5 }") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw",
|
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw",
|
||||||
"{ \"return\" : 7 }") < 0)
|
"{ \"return\" : 7 }") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if ((ret = qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0)
|
if ((rc = qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (ret != 5) {
|
if (rc != 5) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"expected 5 thawed filesystems, got %d", ret);
|
"expected 5 thawed filesystems, got %d", rc);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0)
|
if ((rc = qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (ret != 7) {
|
if (rc != 7) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"expected 7 thawed filesystems, got %d", ret);
|
"expected 7 thawed filesystems, got %d", rc);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -210,27 +204,23 @@ testQemuAgentFSTrim(const void *data)
|
|||||||
{
|
{
|
||||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItemParams(test, "guest-fstrim",
|
if (qemuMonitorTestAddItemParams(test, "guest-fstrim",
|
||||||
"{ \"return\" : {} }",
|
"{ \"return\" : {} }",
|
||||||
"minimum", "1337",
|
"minimum", "1337",
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentFSTrim(qemuMonitorTestGetAgent(test), 1337) < 0)
|
if (qemuAgentFSTrim(qemuMonitorTestGetAgent(test), 1337) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -239,7 +229,6 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlopt,
|
|||||||
qemuMonitorTest **test,
|
qemuMonitorTest **test,
|
||||||
virDomainDef **def)
|
virDomainDef **def)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
g_autofree char *domain_filename = NULL;
|
g_autofree char *domain_filename = NULL;
|
||||||
g_autoptr(qemuMonitorTest) ret_test = NULL;
|
g_autoptr(qemuMonitorTest) ret_test = NULL;
|
||||||
g_autoptr(virDomainDef) ret_def = NULL;
|
g_autoptr(virDomainDef) ret_def = NULL;
|
||||||
@ -254,10 +243,10 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlopt,
|
|||||||
|
|
||||||
if (!(ret_def = virDomainDefParseFile(domain_filename, xmlopt,
|
if (!(ret_def = virDomainDefParseFile(domain_filename, xmlopt,
|
||||||
NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(ret_test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(ret_test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(ret_test, "guest-get-fsinfo",
|
if (qemuMonitorTestAddItem(ret_test, "guest-get-fsinfo",
|
||||||
"{\"return\": ["
|
"{\"return\": ["
|
||||||
@ -293,14 +282,11 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlopt,
|
|||||||
" {\"name\": \"sdb1\","
|
" {\"name\": \"sdb1\","
|
||||||
" \"mountpoint\": \"/mnt/disk\","
|
" \"mountpoint\": \"/mnt/disk\","
|
||||||
" \"disk\": [], \"type\": \"xfs\"}]}") < 0)
|
" \"disk\": [], \"type\": \"xfs\"}]}") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
*test = g_steal_pointer(&ret_test);
|
*test = g_steal_pointer(&ret_test);
|
||||||
*def = g_steal_pointer(&ret_def);
|
*def = g_steal_pointer(&ret_def);
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -408,43 +394,39 @@ testQemuAgentSuspend(const void *data)
|
|||||||
{
|
{
|
||||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||||
int ret = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-suspend-ram",
|
if (qemuMonitorTestAddItem(test, "guest-suspend-ram",
|
||||||
"{ \"return\" : {} }") < 0)
|
"{ \"return\" : {} }") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-suspend-disk",
|
if (qemuMonitorTestAddItem(test, "guest-suspend-disk",
|
||||||
"{ \"return\" : {} }") < 0)
|
"{ \"return\" : {} }") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-suspend-hybrid",
|
if (qemuMonitorTestAddItem(test, "guest-suspend-hybrid",
|
||||||
"{ \"return\" : {} }") < 0)
|
"{ \"return\" : {} }") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* try the commands - fail if ordering changes */
|
/* try the commands - fail if ordering changes */
|
||||||
for (i = 0; i < VIR_NODE_SUSPEND_TARGET_LAST; i++) {
|
for (i = 0; i < VIR_NODE_SUSPEND_TARGET_LAST; i++) {
|
||||||
if (qemuAgentSuspend(qemuMonitorTestGetAgent(test), i) < 0)
|
if (qemuAgentSuspend(qemuMonitorTestGetAgent(test), i) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -506,13 +488,12 @@ testQemuAgentShutdown(const void *data)
|
|||||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||||
struct qemuAgentShutdownTestData priv;
|
struct qemuAgentShutdownTestData priv;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
|
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
|
||||||
priv.mode = "halt";
|
priv.mode = "halt";
|
||||||
@ -520,14 +501,14 @@ testQemuAgentShutdown(const void *data)
|
|||||||
if (qemuMonitorTestAddHandler(test, "guest-shutdown",
|
if (qemuMonitorTestAddHandler(test, "guest-shutdown",
|
||||||
qemuAgentShutdownTestMonitorHandler,
|
qemuAgentShutdownTestMonitorHandler,
|
||||||
&priv, NULL) < 0)
|
&priv, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
||||||
QEMU_AGENT_SHUTDOWN_HALT) < 0)
|
QEMU_AGENT_SHUTDOWN_HALT) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
|
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
|
||||||
priv.mode = "powerdown";
|
priv.mode = "powerdown";
|
||||||
@ -535,14 +516,14 @@ testQemuAgentShutdown(const void *data)
|
|||||||
if (qemuMonitorTestAddHandler(test, "guest-shutdown",
|
if (qemuMonitorTestAddHandler(test, "guest-shutdown",
|
||||||
qemuAgentShutdownTestMonitorHandler,
|
qemuAgentShutdownTestMonitorHandler,
|
||||||
&priv, NULL) < 0)
|
&priv, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
||||||
QEMU_AGENT_SHUTDOWN_POWERDOWN) < 0)
|
QEMU_AGENT_SHUTDOWN_POWERDOWN) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
priv.event = QEMU_AGENT_EVENT_RESET;
|
priv.event = QEMU_AGENT_EVENT_RESET;
|
||||||
priv.mode = "reboot";
|
priv.mode = "reboot";
|
||||||
@ -551,17 +532,17 @@ testQemuAgentShutdown(const void *data)
|
|||||||
"guest-shutdown",
|
"guest-shutdown",
|
||||||
qemuAgentShutdownTestMonitorHandler,
|
qemuAgentShutdownTestMonitorHandler,
|
||||||
&priv, NULL) < 0)
|
&priv, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
||||||
QEMU_AGENT_SHUTDOWN_REBOOT) < 0)
|
QEMU_AGENT_SHUTDOWN_REBOOT) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* check negative response, so that we can verify that the agent breaks
|
/* check negative response, so that we can verify that the agent breaks
|
||||||
* out from sleep */
|
* out from sleep */
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-shutdown",
|
if (qemuMonitorTestAddItem(test, "guest-shutdown",
|
||||||
"{\"error\":"
|
"{\"error\":"
|
||||||
@ -571,19 +552,16 @@ testQemuAgentShutdown(const void *data)
|
|||||||
" \"data\":{\"name\":\"guest-shutdown\"}"
|
" \"data\":{\"name\":\"guest-shutdown\"}"
|
||||||
" }"
|
" }"
|
||||||
"}") < 0)
|
"}") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
||||||
QEMU_AGENT_SHUTDOWN_REBOOT) != -1) {
|
QEMU_AGENT_SHUTDOWN_REBOOT) != -1) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"agent shutdown command should have failed");
|
"agent shutdown command should have failed");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -626,75 +604,71 @@ testQemuAgentCPU(const void *data)
|
|||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||||
g_autofree qemuAgentCPUInfo *cpuinfo = NULL;
|
g_autofree qemuAgentCPUInfo *cpuinfo = NULL;
|
||||||
int nvcpus;
|
int nvcpus;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "guest-get-vcpus",
|
if (qemuMonitorTestAddItem(test, "guest-get-vcpus",
|
||||||
testQemuAgentCPUResponse) < 0)
|
testQemuAgentCPUResponse) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* get cpus */
|
/* get cpus */
|
||||||
if ((nvcpus = qemuAgentGetVCPUs(qemuMonitorTestGetAgent(test),
|
if ((nvcpus = qemuAgentGetVCPUs(qemuMonitorTestGetAgent(test),
|
||||||
&cpuinfo)) < 0)
|
&cpuinfo)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (nvcpus != 4) {
|
if (nvcpus != 4) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Expected '4' cpus, got '%d'", nvcpus);
|
"Expected '4' cpus, got '%d'", nvcpus);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to unplug one */
|
/* try to unplug one */
|
||||||
if (qemuAgentUpdateCPUInfo(2, cpuinfo, nvcpus) < 0)
|
if (qemuAgentUpdateCPUInfo(2, cpuinfo, nvcpus) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
||||||
"{ \"return\" : 1 }",
|
"{ \"return\" : 1 }",
|
||||||
"vcpus", testQemuAgentCPUArguments1,
|
"vcpus", testQemuAgentCPUArguments1,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) < 0)
|
if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* try to hotplug two, second one will fail */
|
/* try to hotplug two, second one will fail */
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
||||||
"{ \"return\" : 1 }",
|
"{ \"return\" : 1 }",
|
||||||
"vcpus", testQemuAgentCPUArguments2,
|
"vcpus", testQemuAgentCPUArguments2,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
||||||
"{ \"error\" : \"random error\" }",
|
"{ \"error\" : \"random error\" }",
|
||||||
"vcpus", testQemuAgentCPUArguments3,
|
"vcpus", testQemuAgentCPUArguments3,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentUpdateCPUInfo(4, cpuinfo, nvcpus) < 0)
|
if (qemuAgentUpdateCPUInfo(4, cpuinfo, nvcpus) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* this should fail */
|
/* this should fail */
|
||||||
if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) != -1)
|
if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) != -1)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -706,37 +680,33 @@ testQemuAgentArbitraryCommand(const void *data)
|
|||||||
{
|
{
|
||||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||||
int ret = -1;
|
|
||||||
g_autofree char *reply = NULL;
|
g_autofree char *reply = NULL;
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "ble",
|
if (qemuMonitorTestAddItem(test, "ble",
|
||||||
testQemuAgentArbitraryCommandResponse) < 0)
|
testQemuAgentArbitraryCommandResponse) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test),
|
if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test),
|
||||||
"{\"execute\":\"ble\"}",
|
"{\"execute\":\"ble\"}",
|
||||||
&reply,
|
&reply,
|
||||||
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
|
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (STRNEQ(reply, testQemuAgentArbitraryCommandResponse)) {
|
if (STRNEQ(reply, testQemuAgentArbitraryCommandResponse)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"invalid processing of guest agent reply: "
|
"invalid processing of guest agent reply: "
|
||||||
"got '%s' expected '%s'",
|
"got '%s' expected '%s'",
|
||||||
reply, testQemuAgentArbitraryCommandResponse);
|
reply, testQemuAgentArbitraryCommandResponse);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -755,36 +725,33 @@ testQemuAgentTimeout(const void *data)
|
|||||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||||
g_autofree char *reply = NULL;
|
g_autofree char *reply = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virTestGetExpensive() == 0) {
|
if (virTestGetExpensive() == 0)
|
||||||
ret = EXIT_AM_SKIP;
|
return EXIT_AM_SKIP;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuMonitorTestAddHandler(test, NULL,
|
if (qemuMonitorTestAddHandler(test, NULL,
|
||||||
qemuAgentTimeoutTestMonitorHandler,
|
qemuAgentTimeoutTestMonitorHandler,
|
||||||
NULL, NULL) < 0)
|
NULL, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0) != -1) {
|
if (qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0) != -1) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"agent command should have failed");
|
"agent command should have failed");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test timeout */
|
/* test timeout */
|
||||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddHandler(test,
|
if (qemuMonitorTestAddHandler(test,
|
||||||
NULL,
|
NULL,
|
||||||
qemuAgentTimeoutTestMonitorHandler,
|
qemuAgentTimeoutTestMonitorHandler,
|
||||||
NULL, NULL) < 0)
|
NULL, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test),
|
if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test),
|
||||||
"{\"execute\":\"ble\"}",
|
"{\"execute\":\"ble\"}",
|
||||||
@ -792,13 +759,10 @@ testQemuAgentTimeout(const void *data)
|
|||||||
1) != -2) {
|
1) != -2) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"agent command didn't time out");
|
"agent command didn't time out");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char testQemuAgentGetInterfacesResponse[] =
|
static const char testQemuAgentGetInterfacesResponse[] =
|
||||||
|
@ -68,7 +68,6 @@ testQemuDataReset(testQemuData *data)
|
|||||||
static int
|
static int
|
||||||
testQemuCaps(const void *opaque)
|
testQemuCaps(const void *opaque)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
testQemuData *data = (void *) opaque;
|
testQemuData *data = (void *) opaque;
|
||||||
g_autofree char *repliesFile = NULL;
|
g_autofree char *repliesFile = NULL;
|
||||||
g_autofree char *capsFile = NULL;
|
g_autofree char *capsFile = NULL;
|
||||||
@ -88,10 +87,10 @@ testQemuCaps(const void *opaque)
|
|||||||
|
|
||||||
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL,
|
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL,
|
||||||
NULL)))
|
NULL)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)
|
if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
binary = g_strdup_printf("/usr/bin/qemu-system-%s",
|
binary = g_strdup_printf("/usr/bin/qemu-system-%s",
|
||||||
data->archName);
|
data->archName);
|
||||||
@ -99,17 +98,17 @@ testQemuCaps(const void *opaque)
|
|||||||
if (!(capsActual = virQEMUCapsNewBinary(binary)) ||
|
if (!(capsActual = virQEMUCapsNewBinary(binary)) ||
|
||||||
virQEMUCapsInitQMPMonitor(capsActual,
|
virQEMUCapsInitQMPMonitor(capsActual,
|
||||||
qemuMonitorTestGetMonitor(mon)) < 0)
|
qemuMonitorTestGetMonitor(mon)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) {
|
if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) {
|
||||||
qemuMonitorResetCommandID(qemuMonitorTestGetMonitor(mon));
|
qemuMonitorResetCommandID(qemuMonitorTestGetMonitor(mon));
|
||||||
|
|
||||||
if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)
|
if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virQEMUCapsInitQMPMonitorTCG(capsActual,
|
if (virQEMUCapsInitQMPMonitorTCG(capsActual,
|
||||||
qemuMonitorTestGetMonitor(mon)) < 0)
|
qemuMonitorTestGetMonitor(mon)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* calculate fake microcode version based on filename for a reproducible
|
/* calculate fake microcode version based on filename for a reproducible
|
||||||
* number for testing which does not change with the contents */
|
* number for testing which does not change with the contents */
|
||||||
@ -125,14 +124,12 @@ testQemuCaps(const void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(actual = virQEMUCapsFormatCache(capsActual)))
|
if (!(actual = virQEMUCapsFormatCache(capsActual)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(actual, capsFile) < 0)
|
if (virTestCompareToFile(actual, capsFile) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,7 +100,6 @@ qemuMigParamsTestXML(const void *opaque)
|
|||||||
g_autoptr(virJSONValue) params = NULL;
|
g_autoptr(virJSONValue) params = NULL;
|
||||||
g_autoptr(qemuMigrationParams) migParams = NULL;
|
g_autoptr(qemuMigrationParams) migParams = NULL;
|
||||||
g_autofree char *actualXML = NULL;
|
g_autofree char *actualXML = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
|
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
|
||||||
abs_srcdir, data->name);
|
abs_srcdir, data->name);
|
||||||
@ -108,27 +107,24 @@ qemuMigParamsTestXML(const void *opaque)
|
|||||||
abs_srcdir, data->name);
|
abs_srcdir, data->name);
|
||||||
|
|
||||||
if (!(mon = qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true)))
|
if (!(mon = qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorGetMigrationParams(qemuMonitorTestGetMonitor(mon),
|
if (qemuMonitorGetMigrationParams(qemuMonitorTestGetMonitor(mon),
|
||||||
¶ms) < 0)
|
¶ms) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(migParams = qemuMigrationParamsFromJSON(params)))
|
if (!(migParams = qemuMigrationParamsFromJSON(params)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
qemuMigParamsTestFormatXML(&buf, migParams);
|
qemuMigParamsTestFormatXML(&buf, migParams);
|
||||||
|
|
||||||
if (!(actualXML = virBufferContentAndReset(&buf)))
|
if (!(actualXML = virBufferContentAndReset(&buf)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(actualXML, xmlFile) < 0)
|
if (virTestCompareToFile(actualXML, xmlFile) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,7 +140,6 @@ qemuMigParamsTestJSON(const void *opaque)
|
|||||||
g_autoptr(qemuMigrationParams) migParams = NULL;
|
g_autoptr(qemuMigrationParams) migParams = NULL;
|
||||||
g_autofree char *actualJSON = NULL;
|
g_autofree char *actualJSON = NULL;
|
||||||
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
|
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
|
||||||
abs_srcdir, data->name);
|
abs_srcdir, data->name);
|
||||||
@ -152,18 +147,18 @@ qemuMigParamsTestJSON(const void *opaque)
|
|||||||
abs_srcdir, data->name);
|
abs_srcdir, data->name);
|
||||||
|
|
||||||
if (!(mon = qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true)))
|
if (!(mon = qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorGetMigrationParams(qemuMonitorTestGetMonitor(mon),
|
if (qemuMonitorGetMigrationParams(qemuMonitorTestGetMonitor(mon),
|
||||||
¶msIn) < 0)
|
¶msIn) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(migParams = qemuMigrationParamsFromJSON(paramsIn)))
|
if (!(migParams = qemuMigrationParamsFromJSON(paramsIn)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(paramsOut = qemuMigrationParamsToJSON(migParams)) ||
|
if (!(paramsOut = qemuMigrationParamsToJSON(migParams)) ||
|
||||||
!(actualJSON = virJSONValueToString(paramsOut, true)))
|
!(actualJSON = virJSONValueToString(paramsOut, true)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (testQEMUSchemaValidateCommand("migrate-set-parameters",
|
if (testQEMUSchemaValidateCommand("migrate-set-parameters",
|
||||||
paramsOut,
|
paramsOut,
|
||||||
@ -174,16 +169,13 @@ qemuMigParamsTestJSON(const void *opaque)
|
|||||||
&debug) < 0) {
|
&debug) < 0) {
|
||||||
VIR_TEST_VERBOSE("failed to validate migration params '%s' against QMP schema: %s",
|
VIR_TEST_VERBOSE("failed to validate migration params '%s' against QMP schema: %s",
|
||||||
actualJSON, virBufferCurrentContent(&debug));
|
actualJSON, virBufferCurrentContent(&debug));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virTestCompareToFile(actualJSON, jsonFile) < 0)
|
if (virTestCompareToFile(actualJSON, jsonFile) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,7 +243,6 @@ testQemuMonitorJSONGetVersion(const void *opaque)
|
|||||||
{
|
{
|
||||||
const testGenericData *data = opaque;
|
const testGenericData *data = opaque;
|
||||||
virDomainXMLOption *xmlopt = data->xmlopt;
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
||||||
int ret = -1;
|
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
int micro;
|
int micro;
|
||||||
@ -264,7 +263,7 @@ testQemuMonitorJSONGetVersion(const void *opaque)
|
|||||||
" \"package\":\"\""
|
" \"package\":\"\""
|
||||||
" }"
|
" }"
|
||||||
"}") < 0)
|
"}") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "query-version",
|
if (qemuMonitorTestAddItem(test, "query-version",
|
||||||
"{ "
|
"{ "
|
||||||
@ -277,67 +276,64 @@ testQemuMonitorJSONGetVersion(const void *opaque)
|
|||||||
" \"package\":\"2.283.el6\""
|
" \"package\":\"2.283.el6\""
|
||||||
" }"
|
" }"
|
||||||
"}") < 0)
|
"}") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test),
|
if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test),
|
||||||
&major, &minor, µ,
|
&major, &minor, µ,
|
||||||
&package) < 0)
|
&package) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (major != 1) {
|
if (major != 1) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Major %d was not 1", major);
|
"Major %d was not 1", major);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (minor != 2) {
|
if (minor != 2) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Minor %d was not 2", major);
|
"Minor %d was not 2", major);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (micro != 3) {
|
if (micro != 3) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Micro %d was not 3", major);
|
"Micro %d was not 3", major);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ(package, "")) {
|
if (STRNEQ(package, "")) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Package %s was not ''", package);
|
"Package %s was not ''", package);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_FREE(package);
|
VIR_FREE(package);
|
||||||
|
|
||||||
if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test),
|
if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test),
|
||||||
&major, &minor, µ,
|
&major, &minor, µ,
|
||||||
&package) < 0)
|
&package) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (major != 0) {
|
if (major != 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Major %d was not 0", major);
|
"Major %d was not 0", major);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (minor != 11) {
|
if (minor != 11) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Minor %d was not 11", major);
|
"Minor %d was not 11", major);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (micro != 6) {
|
if (micro != 6) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Micro %d was not 6", major);
|
"Micro %d was not 6", major);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ(package, "2.283.el6")) {
|
if (STRNEQ(package, "2.283.el6")) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Package %s was not '2.283.el6'", package);
|
"Package %s was not '2.283.el6'", package);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -652,10 +648,9 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
|||||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewSchema(xmlopt, schema);
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewSchema(xmlopt, schema);
|
||||||
g_autofree char *jsonreply = NULL;
|
g_autofree char *jsonreply = NULL;
|
||||||
g_autofree char *fulllabel = NULL;
|
g_autofree char *fulllabel = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!reply)
|
if (!reply)
|
||||||
reply = "";
|
reply = "";
|
||||||
@ -668,7 +663,7 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
|||||||
|
|
||||||
if (qemuMonitorTestAddItemExpect(test, "chardev-add",
|
if (qemuMonitorTestAddItemExpect(test, "chardev-add",
|
||||||
expectargs, true, jsonreply) < 0)
|
expectargs, true, jsonreply) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
data.chr = chr;
|
data.chr = chr;
|
||||||
data.fail = fail;
|
data.fail = fail;
|
||||||
@ -676,12 +671,9 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
|||||||
data.test = test;
|
data.test = test;
|
||||||
|
|
||||||
if (virTestRun(fulllabel, &testQemuMonitorJSONAttachChardev, &data) < 0)
|
if (virTestRun(fulllabel, &testQemuMonitorJSONAttachChardev, &data) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1028,15 +1020,15 @@ testQemuMonitorJSONGetDeviceAliases(const void *opaque)
|
|||||||
" \"type\": \"child<piix3-usb-uhci>\"},"
|
" \"type\": \"child<piix3-usb-uhci>\"},"
|
||||||
" {\"name\": \"type\", \"type\": \"string\"}"
|
" {\"name\": \"type\", \"type\": \"string\"}"
|
||||||
"]}") < 0)
|
"]}") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONGetDeviceAliases(qemuMonitorTestGetMonitor(test),
|
if (qemuMonitorJSONGetDeviceAliases(qemuMonitorTestGetMonitor(test),
|
||||||
&aliases) < 0)
|
&aliases) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!aliases) {
|
if (!aliases) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "no aliases returned");
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "no aliases returned");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -1053,7 +1045,6 @@ testQemuMonitorJSONGetDeviceAliases(const void *opaque)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2839,7 +2830,6 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
|
|||||||
g_autoptr(virCPUDef) cpu_a = virCPUDefNew();
|
g_autoptr(virCPUDef) cpu_a = virCPUDefNew();
|
||||||
g_autoptr(virCPUDef) cpu_b = virCPUDefNew();
|
g_autoptr(virCPUDef) cpu_b = virCPUDefNew();
|
||||||
g_autoptr(qemuMonitorCPUModelInfo) baseline = NULL;
|
g_autoptr(qemuMonitorCPUModelInfo) baseline = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -2864,26 +2854,26 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
|
|||||||
if (virCPUDefAddFeature(cpu_a, "feat_a", VIR_CPU_FEATURE_REQUIRE) < 0 ||
|
if (virCPUDefAddFeature(cpu_a, "feat_a", VIR_CPU_FEATURE_REQUIRE) < 0 ||
|
||||||
virCPUDefAddFeature(cpu_a, "feat_b", VIR_CPU_FEATURE_REQUIRE) < 0 ||
|
virCPUDefAddFeature(cpu_a, "feat_b", VIR_CPU_FEATURE_REQUIRE) < 0 ||
|
||||||
virCPUDefAddFeature(cpu_a, "feat_c", VIR_CPU_FEATURE_REQUIRE) < 0)
|
virCPUDefAddFeature(cpu_a, "feat_c", VIR_CPU_FEATURE_REQUIRE) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONGetCPUModelBaseline(qemuMonitorTestGetMonitor(test),
|
if (qemuMonitorJSONGetCPUModelBaseline(qemuMonitorTestGetMonitor(test),
|
||||||
cpu_a, cpu_b, &baseline) < 0)
|
cpu_a, cpu_b, &baseline) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!baseline) {
|
if (!baseline) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"Baseline missing result");
|
"Baseline missing result");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!baseline->name) {
|
if (!baseline->name) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"Baseline missing model name");
|
"Baseline missing model name");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (baseline->nprops != 2) {
|
if (baseline->nprops != 2) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"Baseline missing properties");
|
"Baseline missing properties");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (STRNEQ(baseline->props[0].name, "feat_a") ||
|
if (STRNEQ(baseline->props[0].name, "feat_a") ||
|
||||||
!baseline->props[0].value.boolean ||
|
!baseline->props[0].value.boolean ||
|
||||||
@ -2891,13 +2881,10 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
|
|||||||
baseline->props[1].value.boolean) {
|
baseline->props[1].value.boolean) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"Baseline property error");
|
"Baseline property error");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1014,7 +1014,7 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt,
|
|||||||
if (!(test->tmpdir = g_mkdtemp(tmpdir_template))) {
|
if (!(test->tmpdir = g_mkdtemp(tmpdir_template))) {
|
||||||
virReportSystemError(errno, "%s",
|
virReportSystemError(errno, "%s",
|
||||||
"Failed to create temporary directory");
|
"Failed to create temporary directory");
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpdir_template = NULL;
|
tmpdir_template = NULL;
|
||||||
@ -1026,14 +1026,14 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt,
|
|||||||
} else {
|
} else {
|
||||||
test->vm = virDomainObjNew(xmlopt);
|
test->vm = virDomainObjNew(xmlopt);
|
||||||
if (!test->vm)
|
if (!test->vm)
|
||||||
goto error;
|
return NULL;
|
||||||
if (!(test->vm->def = virDomainDefNew(xmlopt)))
|
if (!(test->vm->def = virDomainDefNew(xmlopt)))
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virNetSocketNewListenUNIX(path, 0700, geteuid(), getegid(),
|
if (virNetSocketNewListenUNIX(path, 0700, geteuid(), getegid(),
|
||||||
&test->server) < 0)
|
&test->server) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
memset(src, 0, sizeof(*src));
|
memset(src, 0, sizeof(*src));
|
||||||
src->type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
src->type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||||
@ -1042,13 +1042,9 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt,
|
|||||||
path = NULL;
|
path = NULL;
|
||||||
|
|
||||||
if (virNetSocketListen(test->server, 1) < 0)
|
if (virNetSocketListen(test->server, 1) < 0)
|
||||||
goto error;
|
|
||||||
|
|
||||||
return g_steal_pointer(&test);
|
|
||||||
|
|
||||||
error:
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
return g_steal_pointer(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1200,12 +1196,12 @@ qemuMonitorTestNewFromFile(const char *fileName,
|
|||||||
|
|
||||||
if (test) {
|
if (test) {
|
||||||
if (qemuMonitorTestAddItem(test, NULL, singleReply) < 0)
|
if (qemuMonitorTestAddItem(test, NULL, singleReply) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
/* Create new mocked monitor with our greeting */
|
/* Create new mocked monitor with our greeting */
|
||||||
if (!(test = qemuMonitorTestNew(xmlopt, NULL, NULL,
|
if (!(test = qemuMonitorTestNew(xmlopt, NULL, NULL,
|
||||||
singleReply, NULL)))
|
singleReply, NULL)))
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eof) {
|
if (!eof) {
|
||||||
@ -1220,12 +1216,9 @@ qemuMonitorTestNewFromFile(const char *fileName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (test && qemuMonitorTestAddItem(test, NULL, singleReply) < 0)
|
if (test && qemuMonitorTestAddItem(test, NULL, singleReply) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
return g_steal_pointer(&test);
|
return g_steal_pointer(&test);
|
||||||
|
|
||||||
error:
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1344,7 +1337,7 @@ qemuMonitorTestNewFromFileFull(const char *fileName,
|
|||||||
if (response) {
|
if (response) {
|
||||||
if (qemuMonitorTestFullAddItem(ret, fileName, command,
|
if (qemuMonitorTestFullAddItem(ret, fileName, command,
|
||||||
response, commandln) < 0)
|
response, commandln) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
command = NULL;
|
command = NULL;
|
||||||
response = NULL;
|
response = NULL;
|
||||||
}
|
}
|
||||||
@ -1364,18 +1357,15 @@ qemuMonitorTestNewFromFileFull(const char *fileName,
|
|||||||
if (!response) {
|
if (!response) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "missing response for command "
|
virReportError(VIR_ERR_INTERNAL_ERROR, "missing response for command "
|
||||||
"on line '%zu' in '%s'", commandln, fileName);
|
"on line '%zu' in '%s'", commandln, fileName);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMonitorTestFullAddItem(ret, fileName, command,
|
if (qemuMonitorTestFullAddItem(ret, fileName, command,
|
||||||
response, commandln) < 0)
|
response, commandln) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_steal_pointer(&ret);
|
return g_steal_pointer(&ret);
|
||||||
|
|
||||||
error:
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user