Skip to contentSkip to conversation

qemu: implement support for secondary consoles in the console backend

PATCH In review Stefano Stabellini 2 participants 3 messages Jun 11, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu: implement support for secondary consoles in the console backend

This patch adds support for secondary consoles in the console backend.

---

hw/xen_console.c +19 -7
index 27f809d..2cdfb1f 100644
@@ -185,7 +185,10 @@ static int con_init(struct XenDevice *xendev)
 
     /* setup */
     dom = xs_get_domain_path(xenstore, con->xendev.dom);
-    snprintf(con->console, sizeof(con->console), "%s/console", dom);
+    if (!xendev->dev)
+        snprintf(con->console, sizeof(con->console), "%s/console", dom);
+    else
+        snprintf(con->console, sizeof(con->console), "%s/device/console/%d", dom, xendev->dev);
     free(dom);
 
     type = xenstore_read_str(con->console, "type");
@@ -215,10 +218,15 @@ static int con_connect(struct XenDevice *xendev)
     if (xenstore_read_int(con->console, "limit", &limit) == 0)
 	con->buffer.max_capacity = limit;
 
-    con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,
-				      XC_PAGE_SIZE,
-				      PROT_READ|PROT_WRITE,
-				      con->ring_ref);
+    if (!xendev->dev)
+        con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,
+                                          XC_PAGE_SIZE,
+                                          PROT_READ|PROT_WRITE,
+                                          con->ring_ref);
+    else
+        con->sring = xc_gnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom,
+                                             con->ring_ref,
+                                             PROT_READ|PROT_WRITE);
     if (!con->sring)
 	return -1;
 
@@ -244,7 +252,10 @@ static void con_disconnect(struct XenDevice *xendev)
     xen_be_unbind_evtchn(&con->xendev);
 
     if (con->sring) {
-	munmap(con->sring, XC_PAGE_SIZE);
+        if (!xendev->gnttabdev)
+	    munmap(con->sring, XC_PAGE_SIZE);
+        else
+            xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1);
 	con->sring = NULL;
     }
 }
@@ -262,9 +273,10 @@ static void con_event(struct XenDevice *xendev)
 
 struct XenDevOps xen_console_ops = {
     .size       = sizeof(struct XenConsole),
-    .flags      = DEVOPS_FLAG_IGNORE_STATE,
+    .flags      = DEVOPS_FLAG_IGNORE_STATE|DEVOPS_FLAG_NEED_GNTDEV,
     .init       = con_init,
     .connect    = con_connect,
     .event      = con_event,
     .disconnect = con_disconnect,
 };
+
#1 lore raw

Hi,

Quoted 4 lines
(quoted diff) +4 -0
+    if (!xendev->dev)
+        snprintf(con->console, sizeof(con->console), "%s/console", dom);
+    else
+        snprintf(con->console, sizeof(con->console), "%s/device/console/%d", dom, xendev->dev);

Review

Quoted 10 lines
(quoted diff) +8 -0
 
+    if (!xendev->dev)
+        con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,
+    else
+        con->sring = xc_gnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom,
 
+        if (!xendev->gnttabdev)
+	    munmap(con->sring, XC_PAGE_SIZE);
+        else
+            xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1);

This should check for xendev->dev too, like the other ones.

Also this changes code already merged to upstream qemu, so it should be crossposted to qemu-devel.

cheers,
Gerd

#2 lore raw
Quoted 12 lines · Gerd Hoffmann
   Hi,
Quoted 9 lines
hw/xen_console.c +8 -0
+    if (!xendev->dev)
+        snprintf(con->console, sizeof(con->console), "%s/console", dom);
+    else
+        snprintf(con->console, sizeof(con->console), "%s/device/console/%d", dom, xendev->dev);
 
+    if (!xendev->dev)
+        con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,
+    else
+        con->sring = xc_gnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom,
Quoted 6 lines

hw/xen_console.c static void con_disconnect(struct XenDevice *xendev) · line 258

Quoted 4 lines
hw/xen_console.c +4 -0
+        if (!xendev->gnttabdev)
+	    munmap(con->sring, XC_PAGE_SIZE);
+        else
+            xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1);

This should check for xendev->dev too, like the other ones.

right.

Quoted 2 lines

Also this changes code already merged to upstream qemu, so it should be crossposted to qemu-devel.

I'll do.