Extend the QEMU private domain structure with virFdSet.
Persist the virFdSet using XML and parse its XML.
Reset the FdSet upon domain stop.
Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
v5->v6:
- change found in patch 3 moved to this patch
---
src/qemu/qemu_domain.c | 13 +++++++++++++
src/qemu/qemu_domain.h | 3 +++
src/qemu/qemu_process.c | 2 ++
3 files changed, 18 insertions(+)
Index: libvirt/src/qemu/qemu_domain.c
===================================================================
--- libvirt.orig/src/qemu/qemu_domain.c
+++ libvirt/src/qemu/qemu_domain.c
@@ -211,6 +211,9 @@ static void *qemuDomainObjPrivateAlloc(v
if (VIR_ALLOC(priv) < 0)
return NULL;
+ if (!(priv->fdset = virFdSetNew()))
+ goto error;
+
if (qemuDomainObjInitJob(priv) < 0)
goto error;
@@ -222,6 +225,7 @@ static void *qemuDomainObjPrivateAlloc(v
return priv;
error:
+ virFdSetFree(priv->fdset);
VIR_FREE(priv);
return NULL;
}
@@ -251,6 +255,7 @@ static void qemuDomainObjPrivateFree(voi
qemuAgentClose(priv->agent);
}
VIR_FREE(priv->cleanupCallbacks);
+ virFdSetFree(priv->fdset);
VIR_FREE(priv);
}
@@ -325,9 +330,14 @@ static int qemuDomainObjPrivateXMLFormat
if (priv->fakeReboot)
virBufferAsprintf(buf, " <fakereboot/>\n");
+ virBufferAdjustIndent(buf, 2);
+ virFdSetFormatXML(priv->fdset, buf);
+ virBufferAdjustIndent(buf, -2);
+
return 0;
}
+
static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
{
qemuDomainObjPrivatePtr priv = data;
@@ -470,6 +480,9 @@ static int qemuDomainObjPrivateXMLParse(
priv->fakeReboot = virXPathBoolean("boolean(./fakereboot)", ctxt) == 1;
+ if (virFdSetParseXML(priv->fdset, "./fdset/entry", ctxt) < 0)
+ goto error;
+
return 0;
error:
Index: libvirt/src/qemu/qemu_domain.h
===================================================================
--- libvirt.orig/src/qemu/qemu_domain.h
+++ libvirt/src/qemu/qemu_domain.h
@@ -32,6 +32,7 @@
# include "qemu_conf.h"
# include "qemu_capabilities.h"
# include "virchrdev.h"
+# include "virfdset.h"
# define QEMU_EXPECTED_VIRT_TYPES \
((1 << VIR_DOMAIN_VIRT_QEMU) | \
@@ -160,6 +161,8 @@ struct _qemuDomainObjPrivate {
qemuDomainCleanupCallback *cleanupCallbacks;
size_t ncleanupCallbacks;
size_t ncleanupCallbacks_max;
+
+ virFdSetPtr fdset;
};
struct qemuDomainWatchdogEvent
Index: libvirt/src/qemu/qemu_process.c
===================================================================
--- libvirt.orig/src/qemu/qemu_process.c
+++ libvirt/src/qemu/qemu_process.c
@@ -4255,6 +4255,8 @@ void qemuProcessStop(virQEMUDriverPtr dr
priv->monConfig = NULL;
}
+ virFdSetReset(priv->fdset);
+
/* shut it off for sure */
ignore_value(qemuProcessKill(vm,
VIR_QEMU_PROCESS_KILL_FORCE|