* [PATCH] Expand non absolute paths in domain config to xen dir
@ 2006-10-03 19:58 Bastian Blank
2006-10-03 20:10 ` Anthony Liguori
2006-10-03 20:13 ` Anthony Liguori
0 siblings, 2 replies; 3+ messages in thread
From: Bastian Blank @ 2006-10-03 19:58 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 580 bytes --]
Hi folks
The attached patch changes the behaviour of xm create to expand the
values of kernel, ramdisk and device_model with the correct path within
the xen dir if relative, like /usr/lib/xen/boot and /usr/lib/xen/bin.
The old behaviour was unreliable as it used the working dir.
This change makes it possible to use only relative paths for supplied
parts like hvmloader and qemu-dm and don't rely on a known location.
Bastian
--
Without facts, the decision cannot be made logically. You must rely on
your human intuition.
-- Spock, "Assignment: Earth", stardate unknown
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 1885 bytes --]
diff -r 38f9bd7a4ce6 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py Tue Oct 03 11:39:22 2006 +0100
+++ b/tools/python/xen/xm/create.py Tue Oct 03 19:45:29 2006 +0000
@@ -460,6 +460,14 @@ def strip(pre, s):
else:
return s
+def abspath(file, dir):
+ if file[0] == '/':
+ return file
+
+ import xen.util.auxbin
+ path = xen.util.auxbin.libpath()
+ return os.path.join(path, dir, file)
+
def configure_image(vals):
"""Create the image config.
"""
@@ -467,9 +475,9 @@ def configure_image(vals):
return None
config_image = [ vals.builder ]
if vals.kernel:
- config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
+ config_image.append([ 'kernel', abspath(vals.kernel, 'boot') ])
if vals.ramdisk:
- config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
+ config_image.append([ 'ramdisk', abspath(vals.ramdisk, 'boot') ])
if vals.cmdline_ip:
cmdline_ip = strip('ip=', vals.cmdline_ip)
config_image.append(['ip', cmdline_ip])
@@ -631,13 +639,15 @@ def configure_hvm(config_image, vals):
def configure_hvm(config_image, vals):
"""Create the config for HVM devices.
"""
- args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb',
+ args = [ 'pae', 'vcpus', 'boot', 'fda', 'fdb',
'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'sdl', 'display',
'acpi', 'apic', 'xauthority', 'usb', 'usbdevice' ]
for a in args:
if (vals.__dict__[a]):
config_image.append([a, vals.__dict__[a]])
+ if vals.device_model:
+ config_image.append([ 'device_model', abspath(vals.device_model, 'bin') ])
def run_bootloader(vals, config_image):
if not os.access(vals.bootloader, os.X_OK):
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Expand non absolute paths in domain config to xen dir
2006-10-03 19:58 [PATCH] Expand non absolute paths in domain config to xen dir Bastian Blank
@ 2006-10-03 20:10 ` Anthony Liguori
2006-10-03 20:13 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2006-10-03 20:10 UTC (permalink / raw)
To: xen-devel
Bastian Blank wrote:
> Hi folks
>
> The attached patch changes the behaviour of xm create to expand the
> values of kernel, ramdisk and device_model with the correct path within
> the xen dir if relative, like /usr/lib/xen/boot and /usr/lib/xen/bin.
>
> The old behaviour was unreliable as it used the working dir.
Why does that make it unreliable?
This patch will break a large number of existing configs that rely on
relative path being the CWD.
I frequently make use of this behavior.
Regards,
Anthony Liguori
>
> This change makes it possible to use only relative paths for supplied
> parts like hvmloader and qemu-dm and don't rely on a known location.
>
> Bastian
>
>
>
> ------------------------------------------------------------------------
>
> diff -r 38f9bd7a4ce6 tools/python/xen/xm/create.py
> --- a/tools/python/xen/xm/create.py Tue Oct 03 11:39:22 2006 +0100
> +++ b/tools/python/xen/xm/create.py Tue Oct 03 19:45:29 2006 +0000
> @@ -460,6 +460,14 @@ def strip(pre, s):
> else:
> return s
>
> +def abspath(file, dir):
> + if file[0] == '/':
> + return file
> +
> + import xen.util.auxbin
> + path = xen.util.auxbin.libpath()
> + return os.path.join(path, dir, file)
> +
> def configure_image(vals):
> """Create the image config.
> """
> @@ -467,9 +475,9 @@ def configure_image(vals):
> return None
> config_image = [ vals.builder ]
> if vals.kernel:
> - config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
> + config_image.append([ 'kernel', abspath(vals.kernel, 'boot') ])
> if vals.ramdisk:
> - config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
> + config_image.append([ 'ramdisk', abspath(vals.ramdisk, 'boot') ])
> if vals.cmdline_ip:
> cmdline_ip = strip('ip=', vals.cmdline_ip)
> config_image.append(['ip', cmdline_ip])
> @@ -631,13 +639,15 @@ def configure_hvm(config_image, vals):
> def configure_hvm(config_image, vals):
> """Create the config for HVM devices.
> """
> - args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb',
> + args = [ 'pae', 'vcpus', 'boot', 'fda', 'fdb',
> 'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
> 'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'sdl', 'display',
> 'acpi', 'apic', 'xauthority', 'usb', 'usbdevice' ]
> for a in args:
> if (vals.__dict__[a]):
> config_image.append([a, vals.__dict__[a]])
> + if vals.device_model:
> + config_image.append([ 'device_model', abspath(vals.device_model, 'bin') ])
>
> def run_bootloader(vals, config_image):
> if not os.access(vals.bootloader, os.X_OK):
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Expand non absolute paths in domain config to xen dir
2006-10-03 19:58 [PATCH] Expand non absolute paths in domain config to xen dir Bastian Blank
2006-10-03 20:10 ` Anthony Liguori
@ 2006-10-03 20:13 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2006-10-03 20:13 UTC (permalink / raw)
To: Bastian Blank; +Cc: xen-devel
Bastian Blank wrote:
> Hi folks
>
> The attached patch changes the behaviour of xm create to expand the
> values of kernel, ramdisk and device_model with the correct path within
> the xen dir if relative, like /usr/lib/xen/boot and /usr/lib/xen/bin.
>
> The old behaviour was unreliable as it used the working dir.
Why does this make it unreliable? I suspect you'll break many existing
configs with this patch.
I rely on the current CWD expansion to specify kernel/disk paths.
Regards,
Anthony Liguori
> This change makes it possible to use only relative paths for supplied
> parts like hvmloader and qemu-dm and don't rely on a known location.
>
> Bastian
>
>
>
> ------------------------------------------------------------------------
>
> diff -r 38f9bd7a4ce6 tools/python/xen/xm/create.py
> --- a/tools/python/xen/xm/create.py Tue Oct 03 11:39:22 2006 +0100
> +++ b/tools/python/xen/xm/create.py Tue Oct 03 19:45:29 2006 +0000
> @@ -460,6 +460,14 @@ def strip(pre, s):
> else:
> return s
>
> +def abspath(file, dir):
> + if file[0] == '/':
> + return file
> +
> + import xen.util.auxbin
> + path = xen.util.auxbin.libpath()
> + return os.path.join(path, dir, file)
> +
> def configure_image(vals):
> """Create the image config.
> """
> @@ -467,9 +475,9 @@ def configure_image(vals):
> return None
> config_image = [ vals.builder ]
> if vals.kernel:
> - config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
> + config_image.append([ 'kernel', abspath(vals.kernel, 'boot') ])
> if vals.ramdisk:
> - config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
> + config_image.append([ 'ramdisk', abspath(vals.ramdisk, 'boot') ])
> if vals.cmdline_ip:
> cmdline_ip = strip('ip=', vals.cmdline_ip)
> config_image.append(['ip', cmdline_ip])
> @@ -631,13 +639,15 @@ def configure_hvm(config_image, vals):
> def configure_hvm(config_image, vals):
> """Create the config for HVM devices.
> """
> - args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb',
> + args = [ 'pae', 'vcpus', 'boot', 'fda', 'fdb',
> 'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
> 'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'sdl', 'display',
> 'acpi', 'apic', 'xauthority', 'usb', 'usbdevice' ]
> for a in args:
> if (vals.__dict__[a]):
> config_image.append([a, vals.__dict__[a]])
> + if vals.device_model:
> + config_image.append([ 'device_model', abspath(vals.device_model, 'bin') ])
>
> def run_bootloader(vals, config_image):
> if not os.access(vals.bootloader, os.X_OK):
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-03 20:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-03 19:58 [PATCH] Expand non absolute paths in domain config to xen dir Bastian Blank
2006-10-03 20:10 ` Anthony Liguori
2006-10-03 20:13 ` Anthony Liguori
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.