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

Peter Krempa pkrempa at redhat.com
Wed Oct 12 13:43:20 UTC 2011


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

diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 2b7219a..265faf1 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -73,6 +73,8 @@ typedef umlDomainObjPrivate *umlDomainObjPrivatePtr;
 struct _umlDomainObjPrivate {
     int monitor;
     int monitorWatch;
+
+    virStreamPtr console;
 };


@@ -95,6 +97,9 @@ static void umlDomainObjPrivateFree(void *data)
 {
     umlDomainObjPrivatePtr priv = data;

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

@@ -2244,8 +2249,10 @@ umlDomainOpenConsole(virDomainPtr dom,
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     int ret = -1;
     virDomainChrDefPtr chr = NULL;
+    umlDomainObjPrivatePtr priv;

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

     umlDriverLock(driver);
     virUUIDFormat(dom->uuid, uuidstr);
@@ -2274,6 +2281,8 @@ umlDomainOpenConsole(virDomainPtr dom,
             chr = vm->def->serials[0];
     }

+    priv = vm->privateData;
+
     if (!chr) {
         umlReportError(VIR_ERR_INTERNAL_ERROR,
                         _("cannot find character device %s"), dev_name);
@@ -2286,10 +2295,27 @@ umlDomainOpenConsole(virDomainPtr dom,
         goto cleanup;
     }

+    /* kill open console stream */
+    if (priv->console) {
+        if (virFDStreamIsOpen(priv->console) &&
+            !(flags & VIR_DOMAIN_CONSOLE_FORCE)) {
+            umlReportError(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




More information about the libvir-list mailing list