提交 9ac4b7db 编写于 作者: P Peter Krempa

qemu: domain: Track backup job data in the status XML

Store the data of a backup job along with the index counter for new
backup jobs in the status XML. Currently we will support only one
backup job and thus there's no necessity to add arrays of jobs.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 e8712030
......@@ -62,6 +62,7 @@
#include "locking/domain_lock.h"
#include "virdomainsnapshotobjlist.h"
#include "virdomaincheckpointobjlist.h"
#include "backup_conf.h"
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
......@@ -2236,6 +2237,9 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv)
priv->pflash0 = NULL;
virObjectUnref(priv->pflash1);
priv->pflash1 = NULL;
virDomainBackupDefFree(priv->backup);
priv->backup = NULL;
}
......@@ -2643,6 +2647,26 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr buf,
}
static int
qemuDomainObjPrivateXMLFormatBackups(virBufferPtr buf,
virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_INCREMENTAL_BACKUP))
return 0;
if (priv->backup &&
virDomainBackupDefFormat(&childBuf, priv->backup, true) < 0)
return -1;
virXMLFormatElement(buf, "backups", &attrBuf, &childBuf);
return 0;
}
void
qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf,
virTristateBool allowReboot)
......@@ -2938,6 +2962,9 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<agentTimeout>%i</agentTimeout>\n", priv->agentTimeout);
if (qemuDomainObjPrivateXMLFormatBackups(buf, vm) < 0)
return -1;
return 0;
}
......@@ -3314,6 +3341,34 @@ qemuDomainObjPrivateXMLParseBlockjobs(virDomainObjPtr vm,
}
static int
qemuDomainObjPrivateXMLParseBackups(qemuDomainObjPrivatePtr priv,
xmlXPathContextPtr ctxt)
{
g_autofree xmlNodePtr *nodes = NULL;
ssize_t nnodes = 0;
if ((nnodes = virXPathNodeSet("./backups/domainbackup", ctxt, &nodes)) < 0)
return -1;
if (nnodes > 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("only one backup job is supported"));
return -1;
}
if (nnodes == 0)
return 0;
if (!(priv->backup = virDomainBackupDefParseNode(ctxt->doc, nodes[0],
priv->driver->xmlopt,
VIR_DOMAIN_BACKUP_PARSE_INTERNAL)))
return -1;
return 0;
}
int
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
virTristateBool *allowReboot)
......@@ -3743,6 +3798,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
if (qemuDomainObjPrivateXMLParseBlockjobs(vm, priv, ctxt) < 0)
goto error;
if (qemuDomainObjPrivateXMLParseBackups(priv, ctxt) < 0)
goto error;
qemuDomainStorageIdReset(priv);
if (virXPathULongLong("string(./nodename/@index)", ctxt,
&priv->nodenameindex) == -2) {
......
......@@ -414,6 +414,9 @@ struct _qemuDomainObjPrivate {
* commandline for pflash drives. */
virStorageSourcePtr pflash0;
virStorageSourcePtr pflash1;
/* running backup job */
virDomainBackupDefPtr backup;
};
#define QEMU_DOMAIN_PRIVATE(vm) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册