mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API now performs the same functions as the old. VBox is excluded from this list, because its existing domainsave is broken (there is no corresponding domainrestore, and there is no control over the filename used in the save). A later patch should change vbox to use its implementation for managedsave, and teach start to use managedsave results. * src/libxl/libxl_driver.c (libxlDomainSave): Move guts... (libxlDomainSaveFlags): ...to new function. (libxlDomainRestore): Move guts... (libxlDomainRestoreFlags): ...to new function. * src/test/test_driver.c (testDomainSave, testDomainSaveFlags) (testDomainRestore, testDomainRestoreFlags): Likewise. * src/xen/xen_driver.c (xenUnifiedDomainSave) (xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore) (xenUnifiedDomainRestoreFlags): Likewise. * src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore): Rename and move guts. (qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore) (qemuDomainRestoreFlags): ...here. (qemudDomainSaveFlag): Rename... (qemuDomainSaveInternal): ...to this, and update callers.
This commit is contained in:
parent
1700345708
commit
b1083a4c53
@ -1915,12 +1915,20 @@ cleanup:
|
||||
}
|
||||
|
||||
static int
|
||||
libxlDomainSave(virDomainPtr dom, const char *to)
|
||||
libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
||||
unsigned int flags)
|
||||
{
|
||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
||||
virDomainObjPtr vm;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
libxlError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("xml modification unsupported"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
libxlDriverLock(driver);
|
||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||
|
||||
@ -1947,7 +1955,14 @@ cleanup:
|
||||
}
|
||||
|
||||
static int
|
||||
libxlDomainRestore(virConnectPtr conn, const char *from)
|
||||
libxlDomainSave(virDomainPtr dom, const char *to)
|
||||
{
|
||||
return libxlDomainSaveFlags(dom, to, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
|
||||
const char *dxml, unsigned int flags)
|
||||
{
|
||||
libxlDriverPrivatePtr driver = conn->privateData;
|
||||
virDomainObjPtr vm = NULL;
|
||||
@ -1956,6 +1971,13 @@ libxlDomainRestore(virConnectPtr conn, const char *from)
|
||||
int fd = -1;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
libxlError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("xml modification unsupported"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
libxlDriverLock(driver);
|
||||
|
||||
fd = libxlSaveImageOpen(driver, from, &def, &hdr);
|
||||
@ -1986,6 +2008,12 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
libxlDomainRestore(virConnectPtr conn, const char *from)
|
||||
{
|
||||
return libxlDomainRestoreFlags(conn, from, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
||||
{
|
||||
@ -3860,7 +3888,9 @@ static virDriver libxlDriver = {
|
||||
.domainGetInfo = libxlDomainGetInfo, /* 0.9.0 */
|
||||
.domainGetState = libxlDomainGetState, /* 0.9.2 */
|
||||
.domainSave = libxlDomainSave, /* 0.9.2 */
|
||||
.domainSaveFlags = libxlDomainSaveFlags, /* 0.9.4 */
|
||||
.domainRestore = libxlDomainRestore, /* 0.9.2 */
|
||||
.domainRestoreFlags = libxlDomainRestoreFlags, /* 0.9.4 */
|
||||
.domainCoreDump = libxlDomainCoreDump, /* 0.9.2 */
|
||||
.domainSetVcpus = libxlDomainSetVcpus, /* 0.9.0 */
|
||||
.domainSetVcpusFlags = libxlDomainSetVcpusFlags, /* 0.9.0 */
|
||||
|
@ -2187,9 +2187,10 @@ qemuCompressProgramName(int compress)
|
||||
* shutdown). So 'vm' must not be referenced by the caller after
|
||||
* this returns (whether returning success or failure).
|
||||
*/
|
||||
static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
|
||||
virDomainObjPtr vm, const char *path,
|
||||
int compressed)
|
||||
static int
|
||||
qemuDomainSaveInternal(struct qemud_driver *driver, virDomainPtr dom,
|
||||
virDomainObjPtr vm, const char *path,
|
||||
int compressed)
|
||||
{
|
||||
char *xml = NULL;
|
||||
struct qemud_save_header header;
|
||||
@ -2431,13 +2432,22 @@ static bool qemudCompressProgramAvailable(enum qemud_save_formats compress)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int qemudDomainSave(virDomainPtr dom, const char *path)
|
||||
static int
|
||||
qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct qemud_driver *driver = dom->conn->privateData;
|
||||
int compressed;
|
||||
int ret = -1;
|
||||
virDomainObjPtr vm = NULL;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
qemuReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("xml modification unsupported"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemuDriverLock(driver);
|
||||
|
||||
if (driver->saveImageFormat == NULL)
|
||||
@ -2473,7 +2483,7 @@ static int qemudDomainSave(virDomainPtr dom, const char *path)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = qemudDomainSaveFlag(driver, dom, vm, path, compressed);
|
||||
ret = qemuDomainSaveInternal(driver, dom, vm, path, compressed);
|
||||
vm = NULL;
|
||||
|
||||
cleanup:
|
||||
@ -2484,6 +2494,12 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
qemuDomainSave(virDomainPtr dom, const char *path)
|
||||
{
|
||||
return qemuDomainSaveFlags(dom, path, NULL, 0);
|
||||
}
|
||||
|
||||
static char *
|
||||
qemuDomainManagedSavePath(struct qemud_driver *driver, virDomainObjPtr vm) {
|
||||
char *ret;
|
||||
@ -2530,7 +2546,7 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
||||
VIR_INFO("Saving state to %s", name);
|
||||
|
||||
compressed = QEMUD_SAVE_FORMAT_RAW;
|
||||
ret = qemudDomainSaveFlag(driver, dom, vm, name, compressed);
|
||||
ret = qemuDomainSaveInternal(driver, dom, vm, name, compressed);
|
||||
vm = NULL;
|
||||
|
||||
cleanup:
|
||||
@ -3832,8 +3848,10 @@ out:
|
||||
}
|
||||
|
||||
static int
|
||||
qemuDomainRestore(virConnectPtr conn,
|
||||
const char *path)
|
||||
qemuDomainRestoreFlags(virConnectPtr conn,
|
||||
const char *path,
|
||||
const char *dxml,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct qemud_driver *driver = conn->privateData;
|
||||
virDomainDefPtr def = NULL;
|
||||
@ -3842,6 +3860,13 @@ qemuDomainRestore(virConnectPtr conn,
|
||||
int ret = -1;
|
||||
struct qemud_save_header header;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
qemuReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("xml modification unsupported"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemuDriverLock(driver);
|
||||
|
||||
fd = qemuDomainSaveImageOpen(driver, path, &def, &header);
|
||||
@ -3880,6 +3905,13 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
qemuDomainRestore(virConnectPtr conn,
|
||||
const char *path)
|
||||
{
|
||||
return qemuDomainRestoreFlags(conn, path, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
qemuDomainObjRestore(virConnectPtr conn,
|
||||
struct qemud_driver *driver,
|
||||
@ -8940,8 +8972,10 @@ static virDriver qemuDriver = {
|
||||
.domainGetInfo = qemudDomainGetInfo, /* 0.2.0 */
|
||||
.domainGetState = qemuDomainGetState, /* 0.9.2 */
|
||||
.domainGetControlInfo = qemuDomainGetControlInfo, /* 0.9.3 */
|
||||
.domainSave = qemudDomainSave, /* 0.2.0 */
|
||||
.domainSave = qemuDomainSave, /* 0.2.0 */
|
||||
.domainSaveFlags = qemuDomainSaveFlags, /* 0.9.4 */
|
||||
.domainRestore = qemuDomainRestore, /* 0.2.0 */
|
||||
.domainRestoreFlags = qemuDomainRestoreFlags, /* 0.9.4 */
|
||||
.domainCoreDump = qemudDomainCoreDump, /* 0.7.0 */
|
||||
.domainScreenshot = qemuDomainScreenshot, /* 0.9.2 */
|
||||
.domainSetVcpus = qemuDomainSetVcpus, /* 0.4.4 */
|
||||
|
@ -1726,8 +1726,9 @@ cleanup:
|
||||
|
||||
#define TEST_SAVE_MAGIC "TestGuestMagic"
|
||||
|
||||
static int testDomainSave(virDomainPtr domain,
|
||||
const char *path)
|
||||
static int
|
||||
testDomainSaveFlags(virDomainPtr domain, const char *path,
|
||||
const char *dxml, unsigned int flags)
|
||||
{
|
||||
testConnPtr privconn = domain->conn->privateData;
|
||||
char *xml = NULL;
|
||||
@ -1737,6 +1738,13 @@ static int testDomainSave(virDomainPtr domain,
|
||||
virDomainEventPtr event = NULL;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
testError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("xml modification unsupported"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
testDriverLock(privconn);
|
||||
privdom = virDomainFindByName(&privconn->domains,
|
||||
domain->name);
|
||||
@ -1820,8 +1828,18 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int testDomainRestore(virConnectPtr conn,
|
||||
const char *path)
|
||||
static int
|
||||
testDomainSave(virDomainPtr domain,
|
||||
const char *path)
|
||||
{
|
||||
return testDomainSaveFlags(domain, path, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
testDomainRestoreFlags(virConnectPtr conn,
|
||||
const char *path,
|
||||
const char *dxml,
|
||||
unsigned int flags)
|
||||
{
|
||||
testConnPtr privconn = conn->privateData;
|
||||
char *xml = NULL;
|
||||
@ -1833,6 +1851,13 @@ static int testDomainRestore(virConnectPtr conn,
|
||||
virDomainEventPtr event = NULL;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
testError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("xml modification unsupported"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((fd = open(path, O_RDONLY)) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("cannot read domain image '%s'"),
|
||||
@ -1909,6 +1934,13 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testDomainRestore(virConnectPtr conn,
|
||||
const char *path)
|
||||
{
|
||||
return testDomainRestoreFlags(conn, path, NULL, 0);
|
||||
}
|
||||
|
||||
static int testDomainCoreDump(virDomainPtr domain,
|
||||
const char *to,
|
||||
unsigned int flags)
|
||||
@ -5550,7 +5582,9 @@ static virDriver testDriver = {
|
||||
.domainGetInfo = testGetDomainInfo, /* 0.1.1 */
|
||||
.domainGetState = testDomainGetState, /* 0.9.2 */
|
||||
.domainSave = testDomainSave, /* 0.3.2 */
|
||||
.domainSaveFlags = testDomainSaveFlags, /* 0.9.4 */
|
||||
.domainRestore = testDomainRestore, /* 0.3.2 */
|
||||
.domainRestoreFlags = testDomainRestoreFlags, /* 0.9.4 */
|
||||
.domainCoreDump = testDomainCoreDump, /* 0.3.2 */
|
||||
.domainSetVcpus = testSetVcpus, /* 0.1.4 */
|
||||
.domainSetVcpusFlags = testDomainSetVcpusFlags, /* 0.8.5 */
|
||||
|
@ -1061,11 +1061,19 @@ xenUnifiedDomainGetState(virDomainPtr dom,
|
||||
}
|
||||
|
||||
static int
|
||||
xenUnifiedDomainSave (virDomainPtr dom, const char *to)
|
||||
xenUnifiedDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
||||
unsigned int flags)
|
||||
{
|
||||
GET_PRIVATE(dom->conn);
|
||||
int i;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
xenUnifiedError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("xml modification unsupported"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] &&
|
||||
drivers[i]->domainSave &&
|
||||
@ -1076,11 +1084,25 @@ xenUnifiedDomainSave (virDomainPtr dom, const char *to)
|
||||
}
|
||||
|
||||
static int
|
||||
xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
|
||||
xenUnifiedDomainSave(virDomainPtr dom, const char *to)
|
||||
{
|
||||
return xenUnifiedDomainSaveFlags(dom, to, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
xenUnifiedDomainRestoreFlags(virConnectPtr conn, const char *from,
|
||||
const char *dxml, unsigned int flags)
|
||||
{
|
||||
GET_PRIVATE(conn);
|
||||
int i;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
xenUnifiedError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("xml modification unsupported"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] &&
|
||||
drivers[i]->domainRestore &&
|
||||
@ -1090,6 +1112,12 @@ xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
|
||||
{
|
||||
return xenUnifiedDomainRestoreFlags(conn, from, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, unsigned int flags)
|
||||
{
|
||||
@ -2223,7 +2251,9 @@ static virDriver xenUnifiedDriver = {
|
||||
.domainGetInfo = xenUnifiedDomainGetInfo, /* 0.0.3 */
|
||||
.domainGetState = xenUnifiedDomainGetState, /* 0.9.2 */
|
||||
.domainSave = xenUnifiedDomainSave, /* 0.0.3 */
|
||||
.domainSaveFlags = xenUnifiedDomainSaveFlags, /* 0.9.4 */
|
||||
.domainRestore = xenUnifiedDomainRestore, /* 0.0.3 */
|
||||
.domainRestoreFlags = xenUnifiedDomainRestoreFlags, /* 0.9.4 */
|
||||
.domainCoreDump = xenUnifiedDomainCoreDump, /* 0.1.9 */
|
||||
.domainSetVcpus = xenUnifiedDomainSetVcpus, /* 0.1.4 */
|
||||
.domainSetVcpusFlags = xenUnifiedDomainSetVcpusFlags, /* 0.8.5 */
|
||||
|
Loading…
Reference in New Issue
Block a user