details: Allow setting direct kernel/initrd boot

This commit is contained in:
Cole Robinson 2010-12-11 23:00:19 -05:00
parent 809cde787c
commit d3472fd1f1
3 changed files with 214 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import traceback
import os
import virtManager.uihelpers as uihelpers
from virtManager.storagebrowse import vmmStorageBrowser
from virtManager.baseclass import vmmGObjectUI
from virtManager.addhardware import vmmAddHardware
from virtManager.choosecd import vmmChooseCD
@ -273,6 +274,7 @@ class vmmDetails(vmmGObjectUI):
self.last_console_page = PAGE_CONSOLE
self.addhw = None
self.media_choosers = {"cdrom": None, "floppy": None}
self.storage_browser = None
self.ignorePause = False
self.ignoreDetails = False
@ -351,6 +353,11 @@ class vmmDetails(vmmGObjectUI):
False),
"on_config_autostart_changed": self.config_enable_apply,
"on_boot_menu_changed": self.config_enable_apply,
"on_boot_kernel_changed": self.config_enable_apply,
"on_boot_kernel_initrd_changed": self.config_enable_apply,
"on_boot_kernel_args_changed": self.config_enable_apply,
"on_boot_kernel_browse_clicked": self.browse_kernel,
"on_boot_kernel_initrd_browse_clicked": self.browse_initrd,
"on_disk_readonly_changed": self.config_enable_apply,
"on_disk_shareable_changed": self.config_enable_apply,
@ -1212,6 +1219,28 @@ class vmmDetails(vmmGObjectUI):
##############################
# Details/Hardware listeners #
##############################
def _browse_file(self, callback, is_media=False):
if is_media:
reason = self.config.CONFIG_DIR_MEDIA
else:
reason = self.config.CONFIG_DIR_IMAGE
if self.storage_browser == None:
self.storage_browser = vmmStorageBrowser(self.conn)
self.storage_browser.set_finish_cb(callback)
self.storage_browser.set_browse_reason(reason)
self.storage_browser.show(self.conn)
def browse_kernel(self, src_ignore):
def cb(ignore, path):
self.window.get_widget("boot-kernel").set_text(path)
self._browse_file(cb)
def browse_initrd(self, src_ignore):
def cb(ignore, path):
self.window.get_widget("boot-kernel-initrd").set_text(path)
self._browse_file(cb)
def config_enable_apply(self, ignore1=None, ignore2=None):
self.window.get_widget("config-apply").set_sensitive(True)
@ -1542,10 +1571,17 @@ class vmmDetails(vmmGObjectUI):
bootdevs = self.get_config_boot_devs()
bootmenu = self.window.get_widget("boot-menu").get_active()
kernel = self.window.get_widget("boot-kernel").get_text()
initrd = self.window.get_widget("boot-kernel-initrd").get_text()
args = self.window.get_widget("boot-kernel-args").get_text()
return self._change_config_helper([self.vm.set_boot_device,
self.vm.set_boot_menu],
self.vm.set_boot_menu,
self.vm.set_boot_kernel],
[(bootdevs,),
(bootmenu,)])
(bootmenu,),
(kernel, initrd, args)])
# CDROM
def change_storage_media(self, dev_id_info, newpath):
@ -2221,6 +2257,14 @@ class vmmDetails(vmmGObjectUI):
menu = self.vm.get_boot_menu() or False
self.window.get_widget("boot-menu").set_active(menu)
kernel, initrd, args = self.vm.get_boot_kernel_info()
expand = bool(kernel or initrd or args)
self.window.get_widget("boot-kernel").set_text(kernel or "")
self.window.get_widget("boot-kernel-initrd").set_text(initrd or "")
self.window.get_widget("boot-kernel-args").set_text(args or "")
if expand:
self.window.get_widget("boot-kernel-expander").set_expanded(True)
# Refresh Boot Device list
self.repopulate_boot_list()

View File

@ -347,6 +347,12 @@ class vmmDomainBase(vmmLibvirtObject):
def change(guest):
guest.installer.bootconfig.enable_bootmenu = bool(newval)
return self._redefine_guest(change)
def set_boot_kernel(self, kernel, initrd, args):
def change(guest):
guest.installer.bootconfig.kernel = kernel or None
guest.installer.bootconfig.initrd = initrd or None
guest.installer.bootconfig.kernel_args = args or None
return self._redefine_guest(change)
# virtinst.VirtualDevice XML persistent change Impls
def define_storage_media(self, devobj, newpath):
@ -519,10 +525,19 @@ class vmmDomainBase(vmmLibvirtObject):
return devs
return util.xml_parse_wrapper(xml, get_boot_xml)
def get_boot_menu(self):
guest = self._get_guest()
return bool(guest.installer.bootconfig.enable_bootmenu)
def get_boot_kernel_info(self):
guest = self._get_guest()
kernel = guest.installer.bootconfig.kernel
initrd = guest.installer.bootconfig.initrd
args = guest.installer.bootconfig.kernel_args
return (kernel, initrd, args)
def get_seclabel(self):
xml = self.get_xml()
model = vutil.get_xml_path(xml, "/domain/seclabel/@model")

View File

@ -2681,6 +2681,159 @@ I/O:</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="boot-kernel-expander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkAlignment" id="alignment20">
<property name="visible">True</property>
<property name="top_padding">3</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table13">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">3</property>
<property name="column_spacing">6</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkLabel" id="label38">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Kernel path:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label39">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Initrd path:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="boot-kernel-initrd">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<signal name="changed" handler="on_boot_kernel_initrd_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="boot-kernel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<signal name="changed" handler="on_boot_kernel_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="boot-kernel-browse">
<property name="label" translatable="yes">Browse</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_boot_kernel_browse_clicked"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="boot-kernel-initrd-browse">
<property name="label" translatable="yes">Browse</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_boot_kernel_initrd_browse_clicked"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="label40">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Kernel arguments:</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="boot-kernel-args">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<signal name="changed" handler="on_boot_kernel_args_changed"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label37">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Direct kernel boot&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">0</property>