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

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

 



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@xxxxxxxxxxxxxxxxxx>

---
 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
@@ -212,6 +212,9 @@ static void *qemuDomainObjPrivateAlloc(v
     if (VIR_ALLOC(priv) < 0)
         return NULL;
 
+    if (!(priv->fdset = virFdSetNew()))
+        goto error;
+
     if (qemuDomainObjInitJob(priv) < 0)
         goto error;
 
@@ -223,6 +226,7 @@ static void *qemuDomainObjPrivateAlloc(v
     return priv;
 
 error:
+    virFdSetFree(priv->fdset);
     VIR_FREE(priv);
     return NULL;
 }
@@ -252,6 +256,7 @@ static void qemuDomainObjPrivateFree(voi
         qemuAgentClose(priv->agent);
     }
     VIR_FREE(priv->cleanupCallbacks);
+    virFdSetFree(priv->fdset);
     VIR_FREE(priv);
 }
 
@@ -326,9 +331,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 +481,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
@@ -4337,6 +4337,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));

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]