199 lines
7.6 KiB
Diff
199 lines
7.6 KiB
Diff
Index: virt-manager-0.3.1/src/virtManager/details.py
|
|
===================================================================
|
|
--- virt-manager-0.3.1.orig/src/virtManager/details.py
|
|
+++ virt-manager-0.3.1/src/virtManager/details.py
|
|
@@ -23,6 +23,10 @@ import gtk.glade
|
|
import libvirt
|
|
import sparkline
|
|
import logging
|
|
+import os
|
|
+
|
|
+import xen.install
|
|
+import xen.install.gui
|
|
|
|
class vmmDetails(gobject.GObject):
|
|
__gsignals__ = {
|
|
@@ -44,6 +48,7 @@ class vmmDetails(gobject.GObject):
|
|
topwin = self.window.get_widget("vmm-details")
|
|
topwin.hide()
|
|
topwin.set_title(self.vm.get_name() + " " + topwin.get_title())
|
|
+ self.topwin = topwin
|
|
|
|
self.window.get_widget("overview-name").set_text(self.vm.get_name())
|
|
self.window.get_widget("overview-uuid").set_text(self.vm.get_uuid())
|
|
@@ -129,15 +134,14 @@ class vmmDetails(gobject.GObject):
|
|
self.window.get_widget("details-toolbar").hide()
|
|
|
|
def show(self):
|
|
- dialog = self.window.get_widget("vmm-details")
|
|
- dialog.show_all()
|
|
+ self.topwin.show_all()
|
|
self.window.get_widget("overview-network-traffic-text").hide()
|
|
self.window.get_widget("overview-network-traffic-label").hide()
|
|
self.window.get_widget("overview-disk-usage-bar").hide()
|
|
self.window.get_widget("overview-disk-usage-text").hide()
|
|
self.window.get_widget("overview-disk-usage-label").hide()
|
|
self.network_traffic_graph.hide()
|
|
- dialog.present()
|
|
+ self.topwin.present()
|
|
|
|
def activate_performance_page(self):
|
|
self.window.get_widget("details-pages").set_current_page(0)
|
|
@@ -146,11 +150,11 @@ class vmmDetails(gobject.GObject):
|
|
self.window.get_widget("details-pages").set_current_page(1)
|
|
|
|
def close(self,ignore1=None,ignore2=None):
|
|
- self.window.get_widget("vmm-details").hide()
|
|
+ self.topwin.hide()
|
|
return 1
|
|
|
|
def is_visible(self):
|
|
- if self.window.get_widget("vmm-details").flags() & gtk.VISIBLE:
|
|
+ if self.topwin.flags() & gtk.VISIBLE:
|
|
return 1
|
|
return 0
|
|
|
|
@@ -387,45 +391,109 @@ class vmmDetails(gobject.GObject):
|
|
self.window.get_widget("config-memory-apply").set_sensitive(False)
|
|
|
|
|
|
+ def add_cdrom(self, button):
|
|
+ return self.add_disk(True)
|
|
+
|
|
+ def add_harddisk(self, button):
|
|
+ return self.add_disk(False)
|
|
+
|
|
+ def add_disk(self, is_cdrom):
|
|
+ disks = self.disks_widget.get_disks()
|
|
+ unused_vdevs = xen.install.get_unused_vdevs(self.options.full_virt, disks)
|
|
+ if len(unused_vdevs) == 0:
|
|
+ return
|
|
+ name = self.vm.get_name()
|
|
+
|
|
+ w = gtk.Window()
|
|
+ self.add_disk_window = w
|
|
+ w.set_modal(True)
|
|
+ w.set_transient_for(self.topwin)
|
|
+ w.set_title(xen.install.msg.title_disk)
|
|
+ self.disk_editor = xen.install.gui.DiskEditWidget()
|
|
+ disk_edit_widget = self.disk_editor.get_widget()
|
|
+ vbox = gtk.VBox()
|
|
+ w.add(vbox)
|
|
+ vbox.pack_start(disk_edit_widget, False)
|
|
+ bbox = gtk.HButtonBox()
|
|
+ bbox.set_layout(gtk.BUTTONBOX_END)
|
|
+ cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
|
|
+ bbox.pack_start(cancel_button)
|
|
+ ok_button = gtk.Button(stock=gtk.STOCK_OK)
|
|
+ bbox.pack_start(ok_button)
|
|
+ vbox.pack_start(bbox, False)
|
|
+
|
|
+ ok_button.connect("clicked", self.do_add_disk)
|
|
+ cancel_button.connect("clicked", self.do_cancel_disk)
|
|
+
|
|
+ if is_cdrom:
|
|
+ cdrom = self.disk_editor.default_cdrom()
|
|
+ disk = xen.install.XenDisk(pdev=cdrom, vdev=unused_vdevs[0],
|
|
+ vdevType=xen.install.XenDisk.DEVICE_CDROM,
|
|
+ options=self.options, disk_group=disks)
|
|
+ else:
|
|
+ disk = xen.install.XenDisk(pdev=None, vdev=unused_vdevs[0],
|
|
+ vdevType=xen.install.XenDisk.DEVICE_DISK,
|
|
+ mb=4096, sparse=True,
|
|
+ options=self.options, disk_group=disks)
|
|
+ self.disk_editor.set(disk)
|
|
+ w.show_all()
|
|
+ w.present()
|
|
+
|
|
+ def do_add_disk(self, button):
|
|
+ disks = self.disks_widget.get_disks()
|
|
+ disk = self.disk_editor.get()
|
|
+ self.xen_add_disk(disk)
|
|
+ disks.append(disk)
|
|
+ self.disks_widget.set_disks(disks)
|
|
+ self.add_disk_window.destroy()
|
|
+
|
|
+ def do_cancel_disk(self, button):
|
|
+ self.add_disk_window.destroy()
|
|
+
|
|
+ def xen_add_disk(self, disk):
|
|
+ disk.setup()
|
|
+ if self.vm.is_active():
|
|
+ mode = 'w'
|
|
+ if disk.ro:
|
|
+ mode = 'r'
|
|
+ xfd = os.popen('xm block-attach %s "%s:%s" %s %s' % (self.vm.get_id(), disk.get_driver(),
|
|
+ disk.pdev, disk.vdev, mode))
|
|
+ status = xfd.close()
|
|
+ else:
|
|
+ # FIXME
|
|
+ pass
|
|
+
|
|
+ def xen_remove_disk(self, disk):
|
|
+ if self.vm.is_active():
|
|
+ xfd = os.popen('xm block-detach %s %s -f' % (self.vm.get_id(), disk.vdev))
|
|
+ status = xfd.close()
|
|
+ else:
|
|
+ # FIXME
|
|
+ pass
|
|
|
|
def prepare_disk_list(self):
|
|
- disks = self.window.get_widget("storage-view")
|
|
- disksModel = gtk.TreeStore(str,str,str,str)
|
|
- disks.set_model(disksModel)
|
|
-
|
|
- diskType_col = gtk.TreeViewColumn("Type")
|
|
- diskType_text = gtk.CellRendererText()
|
|
- diskType_col.pack_start(diskType_text, True)
|
|
- diskType_col.add_attribute(diskType_text, 'text', 0)
|
|
-
|
|
- diskSrc_col = gtk.TreeViewColumn("Source")
|
|
- diskSrc_text = gtk.CellRendererText()
|
|
- diskSrc_col.pack_start(diskSrc_text, True)
|
|
- diskSrc_col.add_attribute(diskSrc_text, 'text', 1)
|
|
-
|
|
- diskDevice_col = gtk.TreeViewColumn("Device")
|
|
- diskDevice_text = gtk.CellRendererText()
|
|
- diskDevice_col.pack_start(diskDevice_text, True)
|
|
- diskDevice_col.add_attribute(diskDevice_text, 'text', 2)
|
|
-
|
|
- diskDst_col = gtk.TreeViewColumn(_("Destination"))
|
|
- diskDst_text = gtk.CellRendererText()
|
|
- diskDst_col.pack_start(diskDst_text, True)
|
|
- diskDst_col.add_attribute(diskDst_text, 'text', 3)
|
|
-
|
|
- disks.append_column(diskType_col)
|
|
- disks.append_column(diskSrc_col)
|
|
- disks.append_column(diskDevice_col)
|
|
- disks.append_column(diskDst_col)
|
|
+ self.disks_widget = xen.install.gui.DisksWidget(allow_reorder=False,
|
|
+ remove_fn=self.xen_remove_disk,
|
|
+ add_cdrom_fn=self.add_cdrom,
|
|
+ add_harddisk_fn=self.add_harddisk)
|
|
+ notebook = self.window.get_widget("hw-panel")
|
|
+ notebook.remove_page(2)
|
|
+ notebook.insert_page(self.disks_widget.get_widget(), None, 2)
|
|
+ class Options:
|
|
+ pass
|
|
+ self.options = Options()
|
|
+ self.options.full_virt = self.vm.vm.OSType() == 'hvm'
|
|
+ self.options.name = self.vm.get_name()
|
|
|
|
def populate_disk_list(self):
|
|
diskList = self.vm.get_disk_devices()
|
|
-
|
|
- disks = self.window.get_widget("storage-view")
|
|
- disksModel = disks.get_model()
|
|
- disksModel.clear()
|
|
+ disks = []
|
|
for d in diskList:
|
|
- disksModel.append(None, d)
|
|
+ disks.append(xen.install.XenDisk(d[1], d[3], options=self.options,
|
|
+ disk_group=disks))
|
|
+ max_disks = len(xen.install.get_possible_vdevs(self.options.full_virt))
|
|
+ self.disks_widget.set_max_disks(max_disks)
|
|
+ self.disks_widget.set_disks(disks)
|
|
|
|
def prepare_network_list(self):
|
|
nets = self.window.get_widget("network-view")
|