mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-26 10:03:54 +03:00
osxml: Ensure kernel/initrd/dtb are absolute paths
This commit is contained in:
parent
4c4bdbb8b8
commit
86417d42ca
@ -6,8 +6,8 @@
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<kernel>./virtinst-vmlinuz.</kernel>
|
||||
<initrd>./virtinst-initrd.img.</initrd>
|
||||
<kernel>/tmp/virtinst-vmlinuz.</kernel>
|
||||
<initrd>/tmp/virtinst-initrd.img.</initrd>
|
||||
<cmdline>method=tests/cli-test-xml/faketree console=ttyS0</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<kernel>./virtinst-vmlinuz.</kernel>
|
||||
<initrd>./virtinst-initrd.img.</initrd>
|
||||
<kernel>/tmp/virtinst-vmlinuz.</kernel>
|
||||
<initrd>/tmp/virtinst-initrd.img.</initrd>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
|
@ -7,8 +7,8 @@
|
||||
<os>
|
||||
<type arch="ia64">hvm</type>
|
||||
<loader>/usr/lib/xen/boot/hvmloader</loader>
|
||||
<kernel>./virtinst-vmlinuz.</kernel>
|
||||
<initrd>./virtinst-initrd.img.</initrd>
|
||||
<kernel>/tmp/virtinst-vmlinuz.</kernel>
|
||||
<initrd>/tmp/virtinst-initrd.img.</initrd>
|
||||
<cmdline>method=tests/cli-test-xml/faketree</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="ia64">linux</type>
|
||||
<kernel>./virtinst-vmlinuz.</kernel>
|
||||
<initrd>./virtinst-initrd.img.</initrd>
|
||||
<kernel>/tmp/virtinst-vmlinuz.</kernel>
|
||||
<initrd>/tmp/virtinst-initrd.img.</initrd>
|
||||
<cmdline>method=tests/cli-test-xml/faketree</cmdline>
|
||||
</os>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">linux</type>
|
||||
<kernel>./virtinst-vmlinuz.</kernel>
|
||||
<initrd>./virtinst-initrd.img.</initrd>
|
||||
<kernel>/tmp/virtinst-vmlinuz.</kernel>
|
||||
<initrd>/tmp/virtinst-initrd.img.</initrd>
|
||||
<cmdline>method=tests/cli-test-xml/faketree</cmdline>
|
||||
</os>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
|
@ -7,8 +7,8 @@
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<loader>/usr/lib/xen/boot/hvmloader</loader>
|
||||
<kernel>kernel</kernel>
|
||||
<initrd>initrd</initrd>
|
||||
<kernel>/kernel</kernel>
|
||||
<initrd>/initrd</initrd>
|
||||
<cmdline>my kernel args</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<vcpu>5</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<kernel>./virtinst-vmlinuz.</kernel>
|
||||
<initrd>./virtinst-initrd.img.</initrd>
|
||||
<kernel>/tmp/virtinst-vmlinuz.</kernel>
|
||||
<initrd>/tmp/virtinst-initrd.img.</initrd>
|
||||
<cmdline>method=tests/cli-test-xml/fakerhel6tree</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -354,8 +354,8 @@ class TestXMLConfig(unittest.TestCase):
|
||||
g = utils.get_basic_fullyvirt_guest(installer=i)
|
||||
|
||||
g.add_device(utils.get_filedisk())
|
||||
g.os.kernel = "kernel"
|
||||
g.os.initrd = "initrd"
|
||||
g.os.kernel = "/kernel"
|
||||
g.os.initrd = "/initrd"
|
||||
g.os.kernel_args = "my kernel args"
|
||||
|
||||
self._compare(g, "install-fullyvirt-import-kernel", False)
|
||||
@ -940,7 +940,7 @@ class TestXMLConfig(unittest.TestCase):
|
||||
def testFullKVMRHEL6(self):
|
||||
utils.set_conn(_plainkvm)
|
||||
i = utils.make_distro_installer(
|
||||
location="tests/cli-test-xml/fakerhel6tree")
|
||||
location="tests/cli-test-xml/fakerhel6tree")
|
||||
g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
|
||||
g.add_device(utils.get_floppy())
|
||||
g.add_device(utils.get_filedisk("/dev/default-pool/rhel6.img", fake=False))
|
||||
|
@ -7,8 +7,8 @@
|
||||
<type arch="i686">hvm</type>
|
||||
<loader>/usr/lib/xen/boot/hvmloader</loader>
|
||||
<bootmenu enable="yes"/>
|
||||
<kernel>foo.img</kernel>
|
||||
<initrd>bar.img</initrd>
|
||||
<kernel>/foo.img</kernel>
|
||||
<initrd>/bar.img</initrd>
|
||||
<cmdline>ks=foo.ks</cmdline>
|
||||
<dtb>/baz.dtb</dtb>
|
||||
<boot dev="cdrom"/>
|
||||
|
@ -266,8 +266,8 @@ class XMLParseTest(unittest.TestCase):
|
||||
check = self._make_checker(guest.os)
|
||||
check("bootorder", ['hd', 'fd', 'cdrom', 'network'], ["cdrom"])
|
||||
check("enable_bootmenu", False, True)
|
||||
check("kernel", None, "foo.img")
|
||||
check("initrd", None, "bar.img")
|
||||
check("kernel", None, "/foo.img")
|
||||
check("initrd", None, "/bar.img")
|
||||
check("dtb", None, "/baz.dtb")
|
||||
check("kernel_args", None, "ks=foo.ks")
|
||||
|
||||
|
@ -92,10 +92,10 @@ class OSXML(XMLBuilder):
|
||||
enable_bootmenu = XMLProperty("./bootmenu/@enable", is_yesno=True)
|
||||
useserial = XMLProperty("./bios/@useserial", is_yesno=True)
|
||||
|
||||
kernel = XMLProperty("./kernel")
|
||||
initrd = XMLProperty("./initrd")
|
||||
kernel = XMLProperty("./kernel", do_abspath=True)
|
||||
initrd = XMLProperty("./initrd", do_abspath=True)
|
||||
dtb = XMLProperty("./dtb", do_abspath=True)
|
||||
kernel_args = XMLProperty("./cmdline")
|
||||
dtb = XMLProperty("./dtb")
|
||||
|
||||
init = XMLProperty("./init")
|
||||
loader = XMLProperty("./loader")
|
||||
|
@ -68,7 +68,7 @@ class _ImageFetcher(object):
|
||||
|
||||
prefix = "virtinst-" + prefix
|
||||
if "VIRTINST_TEST_SUITE" in os.environ:
|
||||
fn = os.path.join(".", prefix)
|
||||
fn = os.path.join("/tmp", prefix)
|
||||
fd = os.open(fn, os.O_RDWR | os.O_CREAT, 0640)
|
||||
else:
|
||||
(fd, fn) = tempfile.mkstemp(prefix=prefix,
|
||||
|
@ -334,7 +334,8 @@ class XMLProperty(property):
|
||||
def __init__(self, xpath=None, name=None, doc=None,
|
||||
set_converter=None, validate_cb=None, make_xpath_cb=None,
|
||||
is_bool=False, is_int=False, is_yesno=False, is_onoff=False,
|
||||
clear_first=None, default_cb=None, default_name=None):
|
||||
clear_first=None, default_cb=None, default_name=None,
|
||||
do_abspath=False):
|
||||
"""
|
||||
Set a XMLBuilder class property that represents a value in the
|
||||
<domain> XML. For example
|
||||
@ -374,6 +375,7 @@ class XMLProperty(property):
|
||||
first explicit 'set'.
|
||||
@param default_name: If the user does a set and passes in this
|
||||
value, instead use the value of default_cb()
|
||||
@param do_abspath: If True, run os.path.abspath on the passed value
|
||||
"""
|
||||
|
||||
self._xpath = xpath
|
||||
@ -386,6 +388,7 @@ class XMLProperty(property):
|
||||
self._is_int = is_int
|
||||
self._is_yesno = is_yesno
|
||||
self._is_onoff = is_onoff
|
||||
self._do_abspath = do_abspath
|
||||
|
||||
self._make_xpath_cb = make_xpath_cb
|
||||
self._validate_cb = validate_cb
|
||||
@ -487,6 +490,8 @@ class XMLProperty(property):
|
||||
def _convert_set_value(self, xmlbuilder, val):
|
||||
if self._default_name and val == self._default_name:
|
||||
val = self._default_cb(xmlbuilder)
|
||||
elif self._do_abspath and val is not None:
|
||||
val = os.path.abspath(val)
|
||||
elif self._is_onoff and val is not None:
|
||||
val = bool(val) and "on" or "off"
|
||||
elif self._is_yesno and val is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user