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

[Xen-devel] [PATCH RFC] libxl: make firmware_override able to cope with relative path



And also document that option in xl.cfg(5).

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

I suppose this should be able to make xtf free from absolute paths in
config files.
---
 docs/man/xl.cfg.pod.5.in | 12 +++++++++++-
 tools/libxl/libxl_dom.c  | 11 +++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 48c9c0d..f1fffbf 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1189,7 +1189,7 @@ accept the defaults for these options wherever possible.
 
 =item B<bios="STRING">
 
-Select the virtual firmware that is exposed to the guest.
+Select the virtual bios that is exposed to the guest.
 By default, a guess is made based on the device model, but sometimes
 it may be useful to request a different one, like UEFI.
 
@@ -1214,6 +1214,16 @@ Requires device_model_version=qemu-xen.
 
 =back
 
+=item B<firmware_override="STRING">
+
+Override the virtual firmware provided by Xen. The value can be an
+absolute or relative path to a file.
+
+If the value is a relative path, searching is frist done in current
+working directory then Xen firmware directory.
+
+If not set, the default hvmloader is used.
+
 =item B<pae=BOOLEAN>
 
 Hide or expose the IA32 Physical Address Extensions. These extensions
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index eef5045..f05aae3 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -905,8 +905,15 @@ static int libxl__domain_firmware(libxl__gc *gc,
         if (rc == 0 && info->ramdisk != NULL)
             rc = xc_dom_ramdisk_file(dom, info->ramdisk);
     } else {
-        rc = xc_dom_kernel_file(dom, libxl__abs_path(gc, firmware,
-                                                 
libxl__xenfirmwaredir_path()));
+        const char *firmware_path;
+        struct stat stab;
+
+        if (info->u.hvm.firmware && !stat(firmware, &stab))
+            firmware_path = firmware;
+        else
+            firmware_path =
+                libxl__abs_path(gc, firmware, libxl__xenfirmwaredir_path());
+        rc = xc_dom_kernel_file(dom, firmware_path);
     }
 
     if (rc != 0) {
-- 
2.1.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®.