[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH V4 2/3] Introduce file descriptor set for QEMU domains



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 linux vnet ibm com>

---
 src/qemu/qemu_domain.c  |   10 ++++++++++
 src/qemu/qemu_domain.h  |    3 +++
 src/qemu/qemu_process.c |    2 ++
 3 files changed, 15 insertions(+)

Index: libvirt/src/qemu/qemu_domain.c
===================================================================
--- libvirt.orig/src/qemu/qemu_domain.c
+++ libvirt/src/qemu/qemu_domain.c
@@ -219,6 +219,7 @@ static void *qemuDomainObjPrivateAlloc(v
         goto error;
 
     priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
+    virFdsetInit(&priv->fdset);
 
     return priv;
 
@@ -252,6 +253,7 @@ static void qemuDomainObjPrivateFree(voi
         qemuAgentClose(priv->agent);
     }
     VIR_FREE(priv->cleanupCallbacks);
+    virFdsetClear(&priv->fdset);
     VIR_FREE(priv);
 }
 
@@ -326,9 +328,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;
@@ -471,6 +478,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;
+
+    virFdset fdset;
 };
 
 struct qemuDomainWatchdogEvent
Index: libvirt/src/qemu/qemu_process.c
===================================================================
--- libvirt.orig/src/qemu/qemu_process.c
+++ libvirt/src/qemu/qemu_process.c
@@ -4258,6 +4258,8 @@ void qemuProcessStop(virQEMUDriverPtr dr
         priv->monConfig = NULL;
     }
 
+    virFdsetReset(&priv->fdset);
+
     /* shut it off for sure */
     ignore_value(qemuProcessKill(driver, vm, VIR_QEMU_PROCESS_KILL_FORCE|
                                              VIR_QEMU_PROCESS_KILL_NOCHECK));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]