test_driver: implement virDomainSaveImageDefineXML

Updates the existing image stored in @path, in case @dxml contains valid
XML supported by the fake host.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Ilias Stamatis 2019-06-10 11:05:00 +02:00 committed by Erik Skultety
parent d6650b2620
commit 4d39a99142

View File

@ -2255,6 +2255,42 @@ testDomainRestore(virConnectPtr conn,
return testDomainRestoreFlags(conn, path, NULL, 0); return testDomainRestoreFlags(conn, path, NULL, 0);
} }
static int
testDomainSaveImageDefineXML(virConnectPtr conn,
const char *path,
const char *dxml,
unsigned int flags)
{
int ret = -1;
int fd = -1;
virDomainDefPtr def = NULL;
virDomainDefPtr newdef = NULL;
testDriverPtr privconn = conn->privateData;
virCheckFlags(VIR_DOMAIN_SAVE_RUNNING |
VIR_DOMAIN_SAVE_PAUSED, -1);
if ((fd = testDomainSaveImageOpen(privconn, path, &def)) < 0)
goto cleanup;
VIR_FORCE_CLOSE(fd);
if ((newdef = virDomainDefParseString(dxml, privconn->caps, privconn->xmlopt, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
goto cleanup;
if (!testDomainSaveImageWrite(privconn, path, newdef))
goto cleanup;
ret = 0;
cleanup:
virDomainDefFree(def);
virDomainDefFree(newdef);
return ret;
}
static int testDomainCoreDumpWithFormat(virDomainPtr domain, static int testDomainCoreDumpWithFormat(virDomainPtr domain,
const char *to, const char *to,
unsigned int dumpformat, unsigned int dumpformat,
@ -7077,6 +7113,7 @@ static virHypervisorDriver testHypervisorDriver = {
.domainSaveFlags = testDomainSaveFlags, /* 0.9.4 */ .domainSaveFlags = testDomainSaveFlags, /* 0.9.4 */
.domainRestore = testDomainRestore, /* 0.3.2 */ .domainRestore = testDomainRestore, /* 0.3.2 */
.domainRestoreFlags = testDomainRestoreFlags, /* 0.9.4 */ .domainRestoreFlags = testDomainRestoreFlags, /* 0.9.4 */
.domainSaveImageDefineXML = testDomainSaveImageDefineXML, /* 5.5.0 */
.domainCoreDump = testDomainCoreDump, /* 0.3.2 */ .domainCoreDump = testDomainCoreDump, /* 0.3.2 */
.domainCoreDumpWithFormat = testDomainCoreDumpWithFormat, /* 1.2.3 */ .domainCoreDumpWithFormat = testDomainCoreDumpWithFormat, /* 1.2.3 */
.domainSetVcpus = testDomainSetVcpus, /* 0.1.4 */ .domainSetVcpus = testDomainSetVcpus, /* 0.1.4 */