[PATCH 09/10] lxc: Add ability to abort existing console when creating a new one

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

 



This patch is identical to the patch fixing this same issue in the qemu
hypervisor.
---
 src/lxc/lxc_driver.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c475887..a2ef8a1 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -67,6 +67,8 @@ typedef lxcDomainObjPrivate *lxcDomainObjPrivatePtr;
 struct _lxcDomainObjPrivate {
     int monitor;
     int monitorWatch;
+
+    virStreamPtr console;
 };


@@ -102,6 +104,9 @@ static void lxcDomainObjPrivateFree(void *data)
 {
     lxcDomainObjPrivatePtr priv = data;

+    if (priv->console)
+        virStreamFree(priv->console);
+
     VIR_FREE(priv);
 }

@@ -2868,8 +2873,10 @@ lxcDomainOpenConsole(virDomainPtr dom,
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     int ret = -1;
     virDomainChrDefPtr chr = NULL;
+    lxcDomainObjPrivatePtr priv;

-    virCheckFlags(0, -1);
+    virCheckFlags(VIR_DOMAIN_CONSOLE_TRY |
+                  VIR_DOMAIN_CONSOLE_FORCE, -1);

     lxcDriverLock(driver);
     virUUIDFormat(dom->uuid, uuidstr);
@@ -2898,6 +2905,8 @@ lxcDomainOpenConsole(virDomainPtr dom,
             chr = vm->def->serials[0];
     }

+    priv = vm->privateData;
+
     if (!chr) {
         lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
                  _("cannot find default console device"));
@@ -2910,10 +2919,27 @@ lxcDomainOpenConsole(virDomainPtr dom,
         goto cleanup;
     }

+    /* kill open console stream */
+    if (priv->console) {
+        if (virFDStreamIsOpen(priv->console) &&
+            !(flags & VIR_DOMAIN_CONSOLE_FORCE)) {
+            lxcError(VIR_ERR_OPERATION_FAILED,
+                            _("Active console session exists for this domain"));
+            goto cleanup;
+        }
+
+        virStreamAbort(priv->console);
+        virStreamFree(priv->console);
+        priv->console = NULL;
+    }
+
     if (virFDStreamOpenFile(st, chr->source.data.file.path,
                             0, 0, O_RDWR) < 0)
         goto cleanup;

+    virStreamRef(st);
+    priv->console = st;
+
     ret = 0;
 cleanup:
     if (vm)
-- 
1.7.3.4

--
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]