Various libvirt back compat fixes

- Fix a check for domain support flags that was breaking inactive XML updates
- Even if requested XML hasn't changed, redefine. Needed for changes to
  take permenant effect if INACTIVE XML flag not supported
- Fix setting HD as a boot device
- Detect autostart unavailability on older libvirt
- Clean up how we display console devices to give more concise output
This commit is contained in:
Cole Robinson 2009-12-03 10:37:57 -05:00
parent 5e6d5b0b73
commit 99c7c25f73
3 changed files with 31 additions and 46 deletions

View File

@ -1110,7 +1110,7 @@ class vmmDetails(gobject.GObject):
str(e)), "".join(traceback.format_exc()))
return False
if boot.get_property("sensitive") and boot.get_active() > 0:
if boot.get_property("sensitive") and boot.get_active() > -1:
bootdev = boot.get_model()[boot.get_active()][2]
return self._change_config_helper(self.vm.set_boot_device,
(bootdev,))
@ -1601,13 +1601,22 @@ class vmmDetails(gobject.GObject):
if not charinfo:
return
typelabel = "<b>%s Device %s</b>" % (charinfo[0].capitalize(),
charinfo[6] and \
_("(Primary Console)") or "")
char_type = charinfo[0].capitalize()
target_port = charinfo[3]
dev_type = charinfo[4] or "pty"
src_path = charinfo[5]
primary = charinfo[6]
typelabel = "%s Device" % char_type
if target_port:
typelabel += " %s" % target_port
if primary:
typelabel += " (%s)" % _("Primary Console")
typelabel = "<b>%s</b>" % typelabel
self.window.get_widget("char-type").set_markup(typelabel)
self.window.get_widget("char-dev-type").set_text(charinfo[4] or "-")
self.window.get_widget("char-target-port").set_text(charinfo[3] or "")
self.window.get_widget("char-source-path").set_text(charinfo[5] or "-")
self.window.get_widget("char-dev-type").set_text(dev_type)
self.window.get_widget("char-source-path").set_text(src_path or "-")
def refresh_hostdev_page(self):
hostdevinfo = self.get_hw_selection(HW_LIST_COL_DEVICE)
@ -1711,10 +1720,15 @@ class vmmDetails(gobject.GObject):
def refresh_boot_page(self):
# Refresh autostart
try:
# Older libvirt versions return None if not supported
autoval = self.vm.get_autostart()
except libvirt.libvirtError:
autoval = None
if autoval is not None:
self.window.get_widget("config-autostart").set_active(autoval)
self.window.get_widget("config-autostart").set_sensitive(True)
except libvirt.libvirtError:
else:
# Autostart isn't supported
self.window.get_widget("config-autostart").set_active(False)
self.window.get_widget("config-autostart").set_sensitive(False)

View File

@ -301,7 +301,7 @@ class vmmDomain(gobject.GObject):
if not self.connection.has_dom_flags(flags):
flags = libvirt.VIR_DOMAIN_XML_INACTIVE
if not self.connection.has_dom_flags:
if not self.connection.has_dom_flags(flags):
flags = 0
self._inactive_xml = self._XMLDesc(flags)
@ -321,9 +321,8 @@ class vmmDomain(gobject.GObject):
newxml = xml_func(origxml, *args)
if origxml == newxml:
logging.debug("Redefinition requested, but new xml was not"
" different")
return
logging.debug("Redefinition request XML was no different,"
" redefining anyways")
else:
diff = "".join(difflib.unified_diff(origxml.splitlines(1),
newxml.splitlines(1),
@ -1455,6 +1454,7 @@ class vmmDomain(gobject.GObject):
if node.name == "console":
cons_port = target_port
cons_dev = dev
dev[6] = True
continue
elif node.name == "serial" and cons_port \
and target_port == cons_port:

View File

@ -3226,7 +3226,7 @@ I/O:</property>
<widget class="GtkTable" id="table37">
<property name="visible">True</property>
<property name="border_width">3</property>
<property name="n_rows">3</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">4</property>
@ -3241,19 +3241,6 @@ I/O:</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label504">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Target Port:</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"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label505">
<property name="visible">True</property>
@ -3261,8 +3248,8 @@ I/O:</property>
<property name="label" translatable="yes">Source Path:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_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"></property>
</packing>
@ -3281,22 +3268,6 @@ I/O:</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="char-target-port">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">label507</property>
<property name="selectable">True</property>
</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="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="char-source-path">
<property name="visible">True</property>
@ -3307,8 +3278,8 @@ I/O:</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_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"></property>
</packing>