mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
qemu: domain: Store list of temporary bitmaps for migration in status XML
Add status XML infrastructure for storing a list of block dirty bitmaps which are temporarily used when migrating a VM with VIR_MIGRATE_NON_SHARED_DISK for cleanup after a libvirtd restart during migration. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
49957f5f69
commit
516906d681
@ -86,6 +86,18 @@ qemuJobAllocPrivate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuDomainJobPrivateMigrateTempBitmapFree(qemuDomainJobPrivateMigrateTempBitmapPtr bmp)
|
||||||
|
{
|
||||||
|
if (!bmp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_free(bmp->nodename);
|
||||||
|
g_free(bmp->bitmapname);
|
||||||
|
g_free(bmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qemuJobFreePrivate(void *opaque)
|
qemuJobFreePrivate(void *opaque)
|
||||||
{
|
{
|
||||||
@ -95,6 +107,9 @@ qemuJobFreePrivate(void *opaque)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
qemuMigrationParamsFree(priv->migParams);
|
qemuMigrationParamsFree(priv->migParams);
|
||||||
|
if (priv->migTempBitmaps)
|
||||||
|
g_slist_free_full(priv->migTempBitmaps,
|
||||||
|
(GDestroyNotify) qemuDomainJobPrivateMigrateTempBitmapFree);
|
||||||
g_free(priv);
|
g_free(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +180,28 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
qemuDomainObjPrivateXMLFormatMigrateTempBitmap(virBufferPtr buf,
|
||||||
|
GSList *bitmaps)
|
||||||
|
{
|
||||||
|
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
||||||
|
GSList *next;
|
||||||
|
|
||||||
|
for (next = bitmaps; next; next = next->next) {
|
||||||
|
qemuDomainJobPrivateMigrateTempBitmapPtr t = next->data;
|
||||||
|
g_auto(virBuffer) bitmapBuf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
|
virBufferAsprintf(&bitmapBuf, " name='%s'", t->bitmapname);
|
||||||
|
virBufferAsprintf(&bitmapBuf, " nodename='%s'", t->nodename);
|
||||||
|
|
||||||
|
virXMLFormatElement(&childBuf, "bitmap", &bitmapBuf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
virXMLFormatElement(buf, "tempBlockDirtyBitmaps", NULL, &childBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainFormatJobPrivate(virBufferPtr buf,
|
qemuDomainFormatJobPrivate(virBufferPtr buf,
|
||||||
qemuDomainJobObjPtr job,
|
qemuDomainJobObjPtr job,
|
||||||
@ -172,9 +209,12 @@ qemuDomainFormatJobPrivate(virBufferPtr buf,
|
|||||||
{
|
{
|
||||||
qemuDomainJobPrivatePtr priv = job->privateData;
|
qemuDomainJobPrivatePtr priv = job->privateData;
|
||||||
|
|
||||||
if (job->asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT &&
|
if (job->asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) {
|
||||||
qemuDomainObjPrivateXMLFormatNBDMigration(buf, vm) < 0)
|
if (qemuDomainObjPrivateXMLFormatNBDMigration(buf, vm) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
qemuDomainObjPrivateXMLFormatMigrateTempBitmap(buf, priv->migTempBitmaps);
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->migParams)
|
if (priv->migParams)
|
||||||
qemuMigrationParamsFormat(buf, priv->migParams);
|
qemuMigrationParamsFormat(buf, priv->migParams);
|
||||||
@ -267,6 +307,44 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainObjPrivateXMLParseMigrateTempBitmap(qemuDomainJobPrivatePtr jobPriv,
|
||||||
|
xmlXPathContextPtr ctxt)
|
||||||
|
{
|
||||||
|
g_autoslist(qemuDomainJobPrivateMigrateTempBitmap) bitmaps = NULL;
|
||||||
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
|
size_t i;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
if ((n = virXPathNodeSet("./tempBlockDirtyBitmaps/bitmap", ctxt, &nodes)) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
qemuDomainJobPrivateMigrateTempBitmapPtr bmp;
|
||||||
|
|
||||||
|
bmp = g_new0(qemuDomainJobPrivateMigrateTempBitmap, 1);
|
||||||
|
bmp->nodename = virXMLPropString(nodes[i], "nodename");
|
||||||
|
bmp->bitmapname = virXMLPropString(nodes[i], "name");
|
||||||
|
|
||||||
|
bitmaps = g_slist_prepend(bitmaps, bmp);
|
||||||
|
|
||||||
|
if (!bmp->bitmapname || !bmp->nodename) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("malformed <tempBlockDirtyBitmaps> in status XML"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
jobPriv->migTempBitmaps = g_slist_reverse(g_steal_pointer(&bitmaps));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainParseJobPrivate(xmlXPathContextPtr ctxt,
|
qemuDomainParseJobPrivate(xmlXPathContextPtr ctxt,
|
||||||
qemuDomainJobObjPtr job,
|
qemuDomainJobObjPtr job,
|
||||||
@ -277,6 +355,9 @@ qemuDomainParseJobPrivate(xmlXPathContextPtr ctxt,
|
|||||||
if (qemuDomainObjPrivateXMLParseJobNBD(vm, ctxt) < 0)
|
if (qemuDomainObjPrivateXMLParseJobNBD(vm, ctxt) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (qemuDomainObjPrivateXMLParseMigrateTempBitmap(priv, ctxt) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (qemuMigrationParamsParse(ctxt, &priv->migParams) < 0)
|
if (qemuMigrationParamsParse(ctxt, &priv->migParams) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -487,6 +487,20 @@ struct _qemuDomainXmlNsDef {
|
|||||||
char **capsdel;
|
char **capsdel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _qemuDomainJobPrivateMigrateTempBitmap qemuDomainJobPrivateMigrateTempBitmap;
|
||||||
|
typedef qemuDomainJobPrivateMigrateTempBitmap *qemuDomainJobPrivateMigrateTempBitmapPtr;
|
||||||
|
|
||||||
|
struct _qemuDomainJobPrivateMigrateTempBitmap {
|
||||||
|
char *nodename;
|
||||||
|
char *bitmapname;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuDomainJobPrivateMigrateTempBitmapFree(qemuDomainJobPrivateMigrateTempBitmapPtr bmp);
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainJobPrivateMigrateTempBitmap, qemuDomainJobPrivateMigrateTempBitmapFree);
|
||||||
|
|
||||||
|
|
||||||
typedef struct _qemuDomainJobPrivate qemuDomainJobPrivate;
|
typedef struct _qemuDomainJobPrivate qemuDomainJobPrivate;
|
||||||
typedef qemuDomainJobPrivate *qemuDomainJobPrivatePtr;
|
typedef qemuDomainJobPrivate *qemuDomainJobPrivatePtr;
|
||||||
struct _qemuDomainJobPrivate {
|
struct _qemuDomainJobPrivate {
|
||||||
@ -495,6 +509,7 @@ struct _qemuDomainJobPrivate {
|
|||||||
bool spiceMigrated; /* spice migration completed */
|
bool spiceMigrated; /* spice migration completed */
|
||||||
bool dumpCompleted; /* dump completed */
|
bool dumpCompleted; /* dump completed */
|
||||||
qemuMigrationParamsPtr migParams;
|
qemuMigrationParamsPtr migParams;
|
||||||
|
GSList *migTempBitmaps; /* temporary block dirty bitmaps - qemuDomainJobPrivateMigrateTempBitmap */
|
||||||
};
|
};
|
||||||
|
|
||||||
int qemuDomainObjStartWorker(virDomainObjPtr dom);
|
int qemuDomainObjStartWorker(virDomainObjPtr dom);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user