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

[Xen-devel] xenconsole: Define and use a macro INVALID_XEN_PFN instead of -1



xenconsole will use a new macro INVALID_XEN_PFN instead of -1 for initializing 
ring-ref.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@xxxxxxxxxx>
---
CC: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
CC: Jan Beulich <jbeulich@xxxxxxxx>
CC: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>

 tools/console/daemon/io.c | 10 +++++-----
 xen/include/public/xen.h  |  2 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 1839973..9129f5a 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -658,12 +658,12 @@ static void console_unmap_interface(struct console *con)
 {
        if (con->interface == NULL)
                return;
-       if (xgt_handle && con->ring_ref == -1)
+       if (xgt_handle && con->ring_ref == INVALID_XEN_PFN)
                xengnttab_unmap(xgt_handle, con->interface, 1);
        else
                munmap(con->interface, XC_PAGE_SIZE);
        con->interface = NULL;
-       con->ring_ref = -1;
+       con->ring_ref = INVALID_XEN_PFN;
 }
  
 static int console_create_ring(struct console *con)
@@ -698,7 +698,7 @@ static int console_create_ring(struct console *con)
        free(type);
 
        /* If using ring_ref and it has changed, remap */
-       if (ring_ref != con->ring_ref && con->ring_ref != -1)
+       if (ring_ref != con->ring_ref && con->ring_ref != INVALID_XEN_PFN)
                console_unmap_interface(con);
 
        if (!con->interface && xgt_handle && con->use_gnttab) {
@@ -706,7 +706,7 @@ static int console_create_ring(struct console *con)
                con->interface = xengnttab_map_grant_ref(xgt_handle,
                        dom->domid, GNTTAB_RESERVED_CONSOLE,
                        PROT_READ|PROT_WRITE);
-               con->ring_ref = -1;
+               con->ring_ref = INVALID_XEN_PFN;
        }
        if (!con->interface) {
                /* Fall back to xc_map_foreign_range */
@@ -812,7 +812,7 @@ static int console_init(struct console *con, struct domain 
*dom, void **data)
        con->master_pollfd_idx = -1;
        con->slave_fd = -1;
        con->log_fd = -1;
-       con->ring_ref = -1;
+       con->ring_ref = INVALID_XEN_PFN;
        con->local_port = -1;
        con->remote_port = -1;
        con->xce_pollfd_idx = -1;
diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h
index 308109f..fc383ca 100644
--- a/xen/include/public/xen.h
+++ b/xen/include/public/xen.h
@@ -37,6 +37,8 @@
 #error "Unsupported architecture"
 #endif
 
+#define INVALID_XEN_PFN (~(xen_pfn_t)0)
+
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
 DEFINE_XEN_GUEST_HANDLE(char);
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.