Add support for 'initenv' elements
To better support container based virtualization, libvirt domain XML format has the 'initenv' element [1] to setup env variables for the container's init process. This patch add to nova instance configuration a new dictionary called 'os_init_env' so that its entries are mapped to/from 'initenv' elements. [1] https://libvirt.org/formatdomain.html#elementsOSContainer Change-Id: I93c1b1c392a100240be0cac0051bbec2aed8242d Signed-off-by: Miguel Herranz <miguel@midokura.com>
This commit is contained in:
parent
e493d33128
commit
b3aed10ee0
|
@ -2284,6 +2284,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
|||
obj.uuid = "b38a3f43-4be2-4046-897f-b67c2f5e0147"
|
||||
obj.os_type = "exe"
|
||||
obj.os_init_path = "/sbin/init"
|
||||
obj.os_init_env["foo"] = "bar"
|
||||
|
||||
fs = config.LibvirtConfigGuestFilesys()
|
||||
fs.source_dir = "/root/lxc"
|
||||
|
@ -2301,6 +2302,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
|||
<os>
|
||||
<type>exe</type>
|
||||
<init>/sbin/init</init>
|
||||
<initenv name="foo">bar</initenv>
|
||||
</os>
|
||||
<devices>
|
||||
<filesystem type="mount">
|
||||
|
@ -2765,6 +2767,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
|||
<boot dev="fd"/>
|
||||
<bootmenu enable="yes"/>
|
||||
<smbios mode="sysinfo"/>
|
||||
<initenv name="foo">bar</initenv>
|
||||
</os>
|
||||
</domain>
|
||||
"""
|
||||
|
@ -2781,6 +2784,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
|||
self.assertEqual('console=xvc0', obj.os_cmdline)
|
||||
self.assertEqual('root=xvda', obj.os_root)
|
||||
self.assertEqual('/sbin/init', obj.os_init_path)
|
||||
self.assertEqual('bar', obj.os_init_env['foo'])
|
||||
self.assertEqual(['hd', 'cdrom', 'fd'], obj.os_boot_dev)
|
||||
self.assertTrue(obj.os_bootmenu)
|
||||
self.assertIsNone(obj.os_smbios)
|
||||
|
|
|
@ -2502,6 +2502,7 @@ class LibvirtConfigGuest(LibvirtConfigObject):
|
|||
self.os_kernel = None
|
||||
self.os_initrd = None
|
||||
self.os_cmdline = None
|
||||
self.os_init_env = {}
|
||||
self.os_root = None
|
||||
self.os_init_path = None
|
||||
self.os_boot_dev = []
|
||||
|
@ -2561,6 +2562,10 @@ class LibvirtConfigGuest(LibvirtConfigObject):
|
|||
os.append(self._text_node("root", self.os_root))
|
||||
if self.os_init_path is not None:
|
||||
os.append(self._text_node("init", self.os_init_path))
|
||||
for name, value in self.os_init_env.items():
|
||||
initenv = self._text_node("initenv", value)
|
||||
initenv.set("name", name)
|
||||
os.append(initenv)
|
||||
|
||||
for boot_dev in self.os_boot_dev:
|
||||
os.append(etree.Element("boot", dev=boot_dev))
|
||||
|
@ -2674,6 +2679,8 @@ class LibvirtConfigGuest(LibvirtConfigObject):
|
|||
elif c.tag == 'bootmenu':
|
||||
if c.get('enable') == 'yes':
|
||||
self.os_bootmenu = True
|
||||
elif c.tag == 'initenv':
|
||||
self.os_init_env[c.get('name')] = c.text
|
||||
|
||||
def parse_dom(self, xmldoc):
|
||||
self.virt_type = xmldoc.get('type')
|
||||
|
|
Loading…
Reference in New Issue