test_driver: implement virDomainSendKey
Validate @keycodes before successfully returning. Since this is test driver, @holdtime is being unused here. Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
a84922c09e
commit
8ad2f8cc43
@ -64,6 +64,7 @@
|
|||||||
#include "virinterfaceobj.h"
|
#include "virinterfaceobj.h"
|
||||||
#include "virhostcpu.h"
|
#include "virhostcpu.h"
|
||||||
#include "virdomainsnapshotobjlist.h"
|
#include "virdomainsnapshotobjlist.h"
|
||||||
|
#include "virkeycode.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_TEST
|
#define VIR_FROM_THIS VIR_FROM_TEST
|
||||||
|
|
||||||
@ -6004,6 +6005,45 @@ testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
testDomainSendKey(virDomainPtr domain,
|
||||||
|
unsigned int codeset,
|
||||||
|
unsigned int holdtime ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int *keycodes,
|
||||||
|
int nkeycodes,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
size_t i;
|
||||||
|
virDomainObjPtr vm = NULL;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
if (!(vm = testDomObjFromDomain(domain)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
for (i = 0; i < nkeycodes; i++) {
|
||||||
|
if (virKeycodeValueTranslate(codeset, codeset, keycodes[i]) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("invalid keycode %u of %s codeset"),
|
||||||
|
keycodes[i],
|
||||||
|
virKeycodeSetTypeToString(codeset));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virDomainObjEndAPI(&vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED,
|
testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
const char *archName,
|
const char *archName,
|
||||||
@ -7025,6 +7065,7 @@ static virHypervisorDriver testHypervisorDriver = {
|
|||||||
.nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */
|
.nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */
|
||||||
.domainRename = testDomainRename, /* 4.1.0 */
|
.domainRename = testDomainRename, /* 4.1.0 */
|
||||||
.domainScreenshot = testDomainScreenshot, /* 1.0.5 */
|
.domainScreenshot = testDomainScreenshot, /* 1.0.5 */
|
||||||
|
.domainSendKey = testDomainSendKey, /* 5.5.0 */
|
||||||
.domainGetMetadata = testDomainGetMetadata, /* 1.1.3 */
|
.domainGetMetadata = testDomainGetMetadata, /* 1.1.3 */
|
||||||
.domainSetMetadata = testDomainSetMetadata, /* 1.1.3 */
|
.domainSetMetadata = testDomainSetMetadata, /* 1.1.3 */
|
||||||
.connectGetCPUModelNames = testConnectGetCPUModelNames, /* 1.1.3 */
|
.connectGetCPUModelNames = testConnectGetCPUModelNames, /* 1.1.3 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user