tests: Make qemuAgent single sync

The qemuAgent has option to issue guest-sync command before each
intended command or issue the sync commend just once, right after
the socket is opened and before the first intended command is
issued. The latter is referred to as single sync agent and is
enabled by VSERPORT_CHANGED event which allows us to detect
when the agent (dis-)connects in the guest.

Now, every QEMU that we support (4.2.0 or newer) has the event
and thus will use single sync agent. Therefore, adjust
qemuagenttest to make it test what's used in the real world,
rather than old approach.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2022-11-07 18:42:32 +01:00
parent b697b702ac
commit bb5bc36792
2 changed files with 4 additions and 48 deletions

View File

@ -56,16 +56,10 @@ testQemuAgentSSHKeys(const void *data)
"}}") < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItem(test, "guest-ssh-add-authorized-keys",
"{ \"return\" : {} }") < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItem(test, "guest-ssh-remove-authorized-keys",
"{ \"return\" : {} }") < 0)
return -1;
@ -121,9 +115,6 @@ testQemuAgentFSFreeze(const void *data)
"{ \"return\" : 5 }") < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze",
"{ \"return\" : 7 }") < 0)
return -1;
@ -168,9 +159,6 @@ testQemuAgentFSThaw(const void *data)
"{ \"return\" : 5 }") < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw",
"{ \"return\" : 7 }") < 0)
return -1;
@ -358,9 +346,6 @@ testQemuAgentGetFSInfo(const void *data)
goto cleanup;
}
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
goto cleanup;
if (qemuMonitorTestAddItem(test, "guest-get-fsinfo",
"{\"error\":"
" {\"class\":\"CommandDisabled\","
@ -404,16 +389,10 @@ testQemuAgentSuspend(const void *data)
"{ \"return\" : {} }") < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItem(test, "guest-suspend-disk",
"{ \"return\" : {} }") < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItem(test, "guest-suspend-hybrid",
"{ \"return\" : {} }") < 0)
return -1;
@ -505,9 +484,6 @@ testQemuAgentShutdown(const void *data)
QEMU_AGENT_SHUTDOWN_HALT) < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
priv.mode = "powerdown";
@ -520,9 +496,6 @@ testQemuAgentShutdown(const void *data)
QEMU_AGENT_SHUTDOWN_POWERDOWN) < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
priv.event = QEMU_AGENT_EVENT_RESET;
priv.mode = "reboot";
@ -539,9 +512,6 @@ testQemuAgentShutdown(const void *data)
/* check negative response, so that we can verify that the agent breaks
* out from sleep */
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItem(test, "guest-shutdown",
"{\"error\":"
" {\"class\":\"CommandDisabled\","
@ -628,9 +598,6 @@ testQemuAgentCPU(const void *data)
if (qemuAgentUpdateCPUInfo(2, cpuinfo, nvcpus) < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
"{ \"return\" : 1 }",
"vcpus", testQemuAgentCPUArguments1,
@ -641,18 +608,12 @@ testQemuAgentCPU(const void *data)
return -1;
/* try to hotplug two, second one will fail */
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
"{ \"return\" : 1 }",
"vcpus", testQemuAgentCPUArguments2,
NULL) < 0)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
return -1;
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
"{ \"error\" : \"random error\" }",
"vcpus", testQemuAgentCPUArguments3,
@ -1171,9 +1132,6 @@ testQemuAgentUsers(const void *data)
checkUserInfo(params, nparams, 1, "test2", NULL, 1561739229190) < 0)
goto cleanup;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
goto cleanup;
if (qemuMonitorTestAddItem(test, "guest-get-users",
testQemuAgentUsersResponse2) < 0)
goto cleanup;
@ -1290,9 +1248,6 @@ testQemuAgentOSInfo(const void *data)
nparams = 0;
maxparams = 0;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
goto cleanup;
if (qemuMonitorTestAddItem(test, "guest-get-osinfo",
testQemuAgentOSInfoResponse2) < 0)
goto cleanup;
@ -1347,13 +1302,14 @@ testQemuAgentTimezone(const void *data)
if (!test)
return -1;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
goto cleanup;
#define VALIDATE_TIMEZONE(response_, expected_name_, expected_offset_) \
do { \
int maxparams_ = 0; \
const char *name_ = NULL; \
int offset_; \
if (qemuMonitorTestAddAgentSyncResponse(test) < 0) \
goto cleanup; \
if (qemuMonitorTestAddItem(test, "guest-get-timezone", \
response_) < 0) \
goto cleanup; \

View File

@ -1418,7 +1418,7 @@ qemuMonitorTestNewAgent(virDomainXMLOption *xmlopt)
&src,
virEventThreadGetContext(test->eventThread),
&qemuMonitorTestAgentCallbacks,
false)))
true)))
goto error;
virObjectLock(test->agent);