direct-io.hg

changeset 15292:24463758319b

[IA64] Replace mlock()/munlock() in ia64 libxc with un/lock_pages()

For Consistency. Also add some missing unlock_pages().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Sun May 20 21:23:35 2007 -0600 (2007-05-20)
parents ac28ee0ee098
children bf6f94206fec
files tools/libxc/ia64/xc_ia64_hvm_build.c tools/libxc/ia64/xc_ia64_linux_restore.c tools/libxc/ia64/xc_ia64_linux_save.c
line diff
     1.1 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c	Wed May 16 11:38:48 2007 -0600
     1.2 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c	Sun May 20 21:23:35 2007 -0600
     1.3 @@ -39,11 +39,11 @@ xc_set_hvm_param(int handle, domid_t dom
     1.4      arg.index = param;
     1.5      arg.value = value;
     1.6  
     1.7 -    if (mlock(&arg, sizeof(arg)) != 0)
     1.8 +    if (lock_pages(&arg, sizeof(arg)) != 0)
     1.9          return -1;
    1.10  
    1.11      rc = do_xen_hypercall(handle, &hypercall);
    1.12 -    safe_munlock(&arg, sizeof(arg));
    1.13 +    unlock_pages(&arg, sizeof(arg));
    1.14  
    1.15      return rc;
    1.16  }
    1.17 @@ -62,11 +62,11 @@ xc_get_hvm_param(int handle, domid_t dom
    1.18      arg.domid = dom;
    1.19      arg.index = param;
    1.20  
    1.21 -    if (mlock(&arg, sizeof(arg)) != 0)
    1.22 +    if (lock_pages(&arg, sizeof(arg)) != 0)
    1.23          return -1;
    1.24  
    1.25      rc = do_xen_hypercall(handle, &hypercall);
    1.26 -    safe_munlock(&arg, sizeof(arg));
    1.27 +    unlock_pages(&arg, sizeof(arg));
    1.28  
    1.29      *value = arg.value;
    1.30      return rc;
    1.31 @@ -723,8 +723,8 @@ xc_hvm_build(int xc_handle, uint32_t dom
    1.32  
    1.33      image_size = (image_size + PAGE_SIZE - 1) & PAGE_MASK;
    1.34  
    1.35 -    if (mlock(&st_ctxt, sizeof(st_ctxt))) {
    1.36 -        PERROR("Unable to mlock ctxt");
    1.37 +    if (lock_pages(&st_ctxt, sizeof(st_ctxt))) {
    1.38 +        PERROR("Unable to lock_pages ctxt");
    1.39          return 1;
    1.40      }
    1.41  
    1.42 @@ -748,10 +748,12 @@ xc_hvm_build(int xc_handle, uint32_t dom
    1.43  
    1.44      launch_domctl.cmd = XEN_DOMCTL_setvcpucontext;
    1.45      rc = do_domctl(xc_handle, &launch_domctl);
    1.46 +    unlock_pages(&st_ctxt, sizeof(st_ctxt));
    1.47      return rc;
    1.48  
    1.49  error_out:
    1.50      free(image);
    1.51 +    unlock_pages(&st_ctxt, sizeof(st_ctxt));
    1.52      return -1;
    1.53  }
    1.54  
     2.1 --- a/tools/libxc/ia64/xc_ia64_linux_restore.c	Wed May 16 11:38:48 2007 -0600
     2.2 +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c	Sun May 20 21:23:35 2007 -0600
     2.3 @@ -106,9 +106,9 @@ xc_domain_restore(int xc_handle, int io_
     2.4  	goto out;
     2.5      }
     2.6  
     2.7 -    if (mlock(&ctxt, sizeof(ctxt))) {
     2.8 +    if (lock_pages(&ctxt, sizeof(ctxt))) {
     2.9          /* needed for build domctl, but might as well do early */
    2.10 -        ERROR("Unable to mlock ctxt");
    2.11 +        ERROR("Unable to lock_pages ctxt");
    2.12          return 1;
    2.13      }
    2.14  
    2.15 @@ -318,6 +318,8 @@ xc_domain_restore(int xc_handle, int io_
    2.16      if (page_array != NULL)
    2.17  	    free(page_array);
    2.18  
    2.19 +    unlock_pages(&ctxt, sizeof(ctxt));
    2.20 +
    2.21      DPRINTF("Restore exit with rc=%d\n", rc);
    2.22  
    2.23      return rc;
     3.1 --- a/tools/libxc/ia64/xc_ia64_linux_save.c	Wed May 16 11:38:48 2007 -0600
     3.2 +++ b/tools/libxc/ia64/xc_ia64_linux_save.c	Sun May 20 21:23:35 2007 -0600
     3.3 @@ -281,12 +281,12 @@ xc_domain_save(int xc_handle, int io_fd,
     3.4          /* Initially all the pages must be sent.  */
     3.5          memset(to_send, 0xff, bitmap_size);
     3.6  
     3.7 -        if (mlock(to_send, bitmap_size)) {
     3.8 -            ERROR("Unable to mlock to_send");
     3.9 +        if (lock_pages(to_send, bitmap_size)) {
    3.10 +            ERROR("Unable to lock_pages to_send");
    3.11              goto out;
    3.12          }
    3.13 -        if (mlock(to_skip, bitmap_size)) {
    3.14 -            ERROR("Unable to mlock to_skip");
    3.15 +        if (lock_pages(to_skip, bitmap_size)) {
    3.16 +            ERROR("Unable to lock_pages to_skip");
    3.17              goto out;
    3.18          }
    3.19          
    3.20 @@ -492,7 +492,9 @@ xc_domain_save(int xc_handle, int io_fd,
    3.21      }
    3.22  
    3.23      free(page_array);
    3.24 +    unlock_pages(to_send, bitmap_size);
    3.25      free(to_send);
    3.26 +    unlock_pages(to_skip, bitmap_size);
    3.27      free(to_skip);
    3.28      if (live_shinfo)
    3.29          munmap(live_shinfo, PAGE_SIZE);