Expose hostdev rombar in UI and cli (bz 768857)

This commit is contained in:
Cole Robinson 2014-02-10 14:24:22 -05:00
parent 2ea6b7e35d
commit 82754ddc84
14 changed files with 88 additions and 18 deletions

View File

@ -118,6 +118,7 @@
<source>
<address domain="0" bus="0" slot="25" function="0"/>
</source>
<rom bar="off"/>
<boot order="4"/>
</hostdev>
<smartcard mode="passthrough" type="spicevmc"/>
@ -257,6 +258,7 @@
<source>
<address domain="0" bus="0" slot="25" function="0"/>
</source>
<rom bar="off"/>
<boot order="4"/>
</hostdev>
<smartcard mode="passthrough" type="spicevmc"/>

View File

@ -14,6 +14,7 @@
<source>
<address domain="0x0000" bus="0x00" slot="0x19" function="0x0"/>
</source>
<rom bar="off"/>
+ <driver name="vfio"/>
</hostdev>
<hostdev mode="subsystem" type="pci" managed="yes">

View File

@ -9,7 +9,7 @@
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
@@ -331,4 +326,5 @@
@@ -332,4 +327,5 @@
<address type="isa" iobase="0x505"/>
</panic>
</devices>

View File

@ -21,7 +21,7 @@
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
@@ -331,4 +314,5 @@
@@ -332,4 +315,5 @@
<address type="isa" iobase="0x505"/>
</panic>
</devices>

View File

@ -12,7 +12,7 @@
<memory unit="KiB">409600</memory>
<currentMemory unit="KiB">204800</currentMemory>
<blkiotune>
@@ -331,4 +331,5 @@
@@ -332,4 +332,5 @@
<address type="isa" iobase="0x505"/>
</panic>
</devices>

View File

@ -563,7 +563,7 @@ c.add_compare("""--hvm --pxe \
--blkiotune weight=200,device_path=/dev/sdc,device_weight=300 \
--idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10 \
--boot loader=/foo/bar \
--host-device net_00_1c_25_10_b1_e4,boot_order=4 \
--host-device net_00_1c_25_10_b1_e4,boot_order=4,rom_bar=off \
--features acpi=off,eoi=on,privnet=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=1234 \
--clock offset=localtime,hpet_present=no,rtc_tickpolicy=merge \
--pm suspend_to_mem=yes,suspend_to_disk=no \

View File

@ -271,6 +271,7 @@
<source>
<address bus='0x00' slot='0x19' function="0x0"/>
</source>
<rom bar='off'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>

View File

@ -38,6 +38,7 @@
<address domain="0x4" bus="0x5" slot="0x6" function="0x7"/>
</source>
<driver name="vfio"/>
<rom bar="on"/>
</hostdev>
</devices>
</domain>

View File

@ -614,6 +614,7 @@ class XMLParseTest(unittest.TestCase):
check("slot", "0x2", "0x6")
check("function", "0x3", "0x7")
check("driver_name", None, "vfio")
check("rom_bar", None, True)
self._alter_compare(guest.get_xml_config(), outfile)

View File

@ -4422,12 +4422,11 @@
<property name="top_padding">3</property>
<property name="left_padding">12</property>
<child>
<object class="GtkTable" id="table50">
<object class="GtkGrid" id="table50">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">4</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="label15">
<property name="visible">True</property>
@ -4436,8 +4435,10 @@
<property name="label" translatable="yes">Device:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -4450,9 +4451,41 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">ROM _BAR:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">hostdev-rombar</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="hostdev-rombar">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_hostdev_rombar_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>

View File

@ -100,7 +100,10 @@ EDIT_CONTROLLER_MODEL,
EDIT_TPM_TYPE,
EDIT_FS,
) = range(1, 41)
EDIT_HOSTDEV_ROMBAR,
) = range(1, 42)
# Columns in hw list model
@ -632,6 +635,9 @@ class vmmDetails(vmmGObjectUI):
"on_smartcard_mode_combo_changed": lambda *x: self.enable_apply(x,
EDIT_SMARTCARD_MODE),
"on_hostdev_rombar_toggled": lambda *x: self.enable_apply(
x, EDIT_HOSTDEV_ROMBAR),
"on_config_apply_clicked": self.config_apply,
"on_config_cancel_clicked": self.config_cancel,
@ -1884,6 +1890,8 @@ class vmmDetails(vmmGObjectUI):
ret = self.config_controller_apply(key)
elif pagetype is HW_LIST_TYPE_FILESYSTEM:
ret = self.config_filesystem_apply(key)
elif pagetype is HW_LIST_TYPE_HOSTDEV:
ret = self.config_hostdev_apply(key)
else:
ret = False
except Exception, e:
@ -2243,6 +2251,16 @@ class vmmDetails(vmmGObjectUI):
return self._change_config_helper(df, da, hf, ha)
def config_hostdev_apply(self, dev_id_info):
df, da, add_define, hf, ha, add_hotplug = self.make_apply_data()
ignore = add_hotplug
if self.edited(EDIT_HOSTDEV_ROMBAR):
add_define(self.vm.define_hostdev_rombar, dev_id_info,
self.widget("hostdev-rombar").get_active())
return self._change_config_helper(df, da, hf, ha)
# Device removal
def remove_device(self, dev_type, dev_id_info):
logging.debug("Removing device: %s %s", dev_type, dev_id_info)
@ -2928,18 +2946,24 @@ class vmmDetails(vmmGObjectUI):
if not hostdev:
return
devtype = hostdev.type
rom_bar = hostdev.rom_bar
if rom_bar is None:
rom_bar = True
pretty_name = None
nodedev = lookup_nodedev(self.vm.conn, hostdev)
if nodedev:
pretty_name = nodedev.pretty_name()
if not pretty_name:
pretty_name = _build_hostdev_label(hostdev)[0] or "-"
devlabel = "<b>Physical %s Device</b>" % devtype.upper()
uiutil.set_grid_row_visible(
self.widget("hostdev-rombar"), hostdev.type == "pci")
devlabel = "<b>Physical %s Device</b>" % hostdev.type.upper()
self.widget("hostdev-title").set_markup(devlabel)
self.widget("hostdev-source").set_text(pretty_name)
self.widget("hostdev-rombar").set_active(rom_bar)
def refresh_video_page(self):
vid = self.get_hw_selection(HW_LIST_COL_DEVICE)

View File

@ -879,6 +879,11 @@ class vmmDomain(vmmLibvirtObject):
return self._redefine_device(change, devobj)
def define_hostdev_rombar(self, devobj, val):
def change(editdev):
editdev.rom_bar = val
return self._redefine_device(change, devobj)
####################
# Hotplug routines #

View File

@ -2107,7 +2107,7 @@ class ParserSound(VirtCLIParser):
#####################
# --hostdev parsing #
# --host-device parsing #
#####################
class ParserHostdev(VirtCLIParser):
@ -2124,6 +2124,7 @@ class ParserHostdev(VirtCLIParser):
self.set_param(None, "name", setter_cb=set_name_cb)
self.set_param("driver_name", "driver_name")
self.set_param("boot.order", "boot_order")
self.set_param("rom_bar", "rom_bar", is_onoff=True)
###########################

View File

@ -87,6 +87,7 @@ class VirtualHostDevice(VirtualDevice):
slot = XMLProperty("./source/address/@slot")
driver_name = XMLProperty("./driver/@name")
rom_bar = XMLProperty("./rom/@bar", is_onoff=True)
VirtualHostDevice.register_type()