WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH] Move nvram from /usr to /var

To: Alex Williamson <alex.williamson@xxxxxx>
Subject: [Xen-ia64-devel] [PATCH] Move nvram from /usr to /var
From: Aron Griffis <aron@xxxxxx>
Date: Mon, 27 Aug 2007 11:55:46 -0400
Cc: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 27 Aug 2007 08:56:02 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Aron Griffis <aron@xxxxxx>
# Date 1188230128 14400
# Node ID c221bb40b5fdac267463fd69f3521b497948737f
# Parent  36eb4e464c8c77c65aacff0a40c50bc45e067f49
Move nvram from /usr to /var

Presently nvram is stored in /usr/lib/xen/boot/nvram_<domain> next to the guest
firmware.  This violates the FHS because /usr might be mounted read-only.  This
patch moves the nvram storage to /var/lib/xen/nvram/nvram_<domain>

Also clean up:
- references to stat_buf assumed that stat() had succeeded; use access()
  instead since it's easier and doesn't require stat_buf at all
- nvram_path[PATH_MAX] instead of nvram_path[100]
- strncpy(..., strlen(src)) is meaningless, re-order length tests to work
  correctly

Tested on rx3600 using virt-install on RHEL; /var/lib/xen/nvram/nvram_hvm1 was
created and used correctly.  Searching through xen-unstable.hg, there don't
appear to be other references to the /usr location.

Signed-off-by: Aron Griffis <aron@xxxxxx>

diff -r 36eb4e464c8c -r c221bb40b5fd tools/libxc/ia64/xc_ia64_hvm_build.c
--- a/tools/libxc/ia64/xc_ia64_hvm_build.c      Mon Aug 27 08:50:22 2007 -0400
+++ b/tools/libxc/ia64/xc_ia64_hvm_build.c      Mon Aug 27 11:55:28 2007 -0400
@@ -5,6 +5,7 @@
 #include "xc_elf.h"
 #include "xc_efi.h"
 #include <stdlib.h>
+#include <unistd.h>
 #include <assert.h>
 #include <zlib.h>
 #include "xen/arch-ia64.h"
@@ -596,7 +597,7 @@ copy_from_nvram_to_GFW(int xc_handle, ui
     unsigned int nr_pages = NVRAM_SIZE >> PAGE_SHIFT;
     struct stat file_stat;
     char buf[NVRAM_SIZE] = {0};
-       
+
     if ( fstat(nvram_fd, &file_stat) < 0 )
     {
         PERROR("Cannot get Nvram file info! Guest will boot without "
@@ -751,7 +752,7 @@ int xc_ia64_save_to_nvram(int xc_handle,
         PERROR("Nvram not initialized. Nvram save failed!\n");
     else
         copy_from_GFW_to_nvram(xc_handle, dom, (int)nvram_fd); 
-       
+
     // although save to nvram maybe fail, we don't return any error number
     // to Xend. This is quite logical because damage of NVRAM on native would 
     // not block OS's executive path. Return error number will cause an
@@ -759,43 +760,41 @@ int xc_ia64_save_to_nvram(int xc_handle,
     return 0;
 }
 
-#define NVRAM_DIR       "/usr/lib/xen/boot/"
-#define NVRAM_FILE_PATH "/usr/lib/xen/boot/nvram_"
+#define NVRAM_DIR         "/var/lib/xen/nvram/"
+#define NVRAM_FILE_PREFIX "nvram_"
 
 int xc_ia64_nvram_init(int xc_handle, char *dom_name, uint32_t dom)
 {
-    int file_path_len = strlen(NVRAM_FILE_PATH);
-    uint64_t nvram_fd = 0;
-    char nvram_path[100] = {0};
-    struct stat stat_buf;
-
-    if ( stat(NVRAM_DIR, &stat_buf) == -1 ) {
+    uint64_t nvram_fd;
+    char nvram_path[PATH_MAX] = NVRAM_DIR;
+
+    if ( access(nvram_path, R_OK|W_OK|X_OK) == -1 ) {
         if ( errno != ENOENT )
         {
-            PERROR("Error stat'ing NVRAM dir %s.", NVRAM_DIR);
+            PERROR("Error stat'ing NVRAM dir %s.", nvram_path);
             return -1;
         }
-        if ( mkdir(NVRAM_DIR, 0755) == -1 )
+        if ( mkdir(nvram_path, 0755) == -1 )
         {
-            PERROR("Unable to create NVRAM store directory %s.", NVRAM_DIR);
+            PERROR("Unable to create NVRAM store directory %s.", nvram_path);
             return -1;
         }
     }
 
-    if ( !(stat_buf.st_mode & S_IRUSR) || !(stat_buf.st_mode & S_IWUSR) )
-    {
+    if ( access(nvram_path, R_OK|W_OK|X_OK) == -1 ) {
         errno = EACCES;
-        PERROR("No R/W permission to NVRAM store directory %s.", NVRAM_DIR);
-        return -1;
-    }
-
-    strncpy(nvram_path, NVRAM_FILE_PATH, file_path_len);
-    if ( file_path_len + strlen(dom_name) + 1 > sizeof(nvram_path) )
+        PERROR("No RWX permission to NVRAM store directory %s.", nvram_path);
+        return -1;
+    }
+
+    if ( strlen(nvram_path) + strlen(NVRAM_FILE_PREFIX) +
+         strlen(dom_name) + 1 > sizeof(nvram_path) )
     {
         PERROR("Nvram file path is too long!\n");
         return -1;
     }
-    strcpy(nvram_path + file_path_len, dom_name);
+    strcat(nvram_path, NVRAM_FILE_PREFIX);
+    strcat(nvram_path, dom_name);
 
     nvram_fd = nvram_init(nvram_path);
     if ( nvram_fd == (uint64_t)(-1) )

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel

<Prev in Thread] Current Thread [Next in Thread>