mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-26 10:03:54 +03:00
Merge heads
This commit is contained in:
commit
a9c295f0b2
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,7 @@ import gobject
|
||||
|
||||
# Displays a progress bar while executing the "callback" method.
|
||||
|
||||
class asyncJob(gobject.GObject):
|
||||
class vmmAsyncJob(gobject.GObject):
|
||||
# This thin wrapper only exists so we can put debugging
|
||||
# code in the run() method every now & then
|
||||
class asyncJobWorker(threading.Thread):
|
||||
@ -42,7 +42,7 @@ class asyncJob(gobject.GObject):
|
||||
self.pbar = self.pbar_glade.get_widget("pbar")
|
||||
self.pbar_win.set_title(title)
|
||||
self.pbar_win.hide()
|
||||
self.bg_thread = asyncJob.asyncJobWorker(callback, args)
|
||||
self.bg_thread = vmmAsyncJob.asyncJobWorker(callback, args)
|
||||
|
||||
def run(self):
|
||||
self.timer = gobject.timeout_add (100, self.pulse_pbar)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import gobject
|
||||
import libvirt
|
||||
import os
|
||||
from time import time
|
||||
|
||||
from virtManager.domain import vmmDomain
|
||||
@ -86,7 +87,10 @@ class vmmConnection(gobject.GObject):
|
||||
return self.hostinfo[4] * self.hostinfo[5] * self.hostinfo[6] * self.hostinfo[7]
|
||||
|
||||
def restore(self, frm):
|
||||
self.vmm.restore(frm)
|
||||
status = self.vmm.restore(frm)
|
||||
if(status == 0):
|
||||
os.remove(frm)
|
||||
return status
|
||||
|
||||
def tick(self):
|
||||
if self.vmm == None:
|
||||
|
@ -112,6 +112,10 @@ class vmmDetails(gobject.GObject):
|
||||
"on_control_terminal_clicked": self.control_vm_terminal,
|
||||
"on_control_save_clicked": self.control_vm_save_domain,
|
||||
"on_control_console_clicked": self.control_vm_console,
|
||||
"on_config_cpus_apply_clicked": self.config_cpus_apply,
|
||||
"on_config_vm_cpus_changed": self.config_vm_cpus,
|
||||
"on_config_memory_value_changed": self.config_memory_value,
|
||||
"on_config_memory_apply_clicked": self.config_memory_apply
|
||||
})
|
||||
|
||||
self.hw_selected()
|
||||
@ -145,6 +149,12 @@ class vmmDetails(gobject.GObject):
|
||||
self.window.get_widget("hw-panel").set_current_page(active[0].get_value(active[1], 0))
|
||||
else:
|
||||
self.window.get_widget("hw-panel").set_sensitive(False)
|
||||
# When the user changes tabs on the hw panel, reset to the default state
|
||||
self.update_config_memory()
|
||||
self.update_config_cpus()
|
||||
self.update_state_cpus()
|
||||
self.window.get_widget("config-memory-apply").set_sensitive(False)
|
||||
self.window.get_widget("config-cpus-apply").set_sensitive(False)
|
||||
|
||||
def control_vm_run(self, src):
|
||||
return 0
|
||||
@ -215,7 +225,9 @@ class vmmDetails(gobject.GObject):
|
||||
|
||||
def refresh_resources(self, vm):
|
||||
self.window.get_widget("overview-cpu-usage-text").set_text("%d %%" % self.vm.cpu_time_percentage())
|
||||
self.window.get_widget("overview-memory-usage-text").set_text("%d MB of %d MB" % (self.vm.current_memory()/1024, self.vm.get_connection().host_memory_size()/1024))
|
||||
vm_memory = self.vm.current_memory()
|
||||
host_memory = self.vm.get_connection().host_memory_size()
|
||||
self.window.get_widget("overview-memory-usage-text").set_text("%d MB of %d MB" % (vm_memory/1024, host_memory/1024))
|
||||
|
||||
history_len = self.config.get_stats_history_length()
|
||||
cpu_vector = self.vm.cpu_time_vector()
|
||||
@ -230,5 +242,40 @@ class vmmDetails(gobject.GObject):
|
||||
network_vector.reverse()
|
||||
self.network_traffic_graph.set_property("data_array", network_vector)
|
||||
|
||||
# update HW config values
|
||||
self.window.get_widget("state-host-memory").set_text("%d MB" % (host_memory/1024))
|
||||
self.window.get_widget("config-memory").get_adjustment().upper = vm.maximum_memory()/1024
|
||||
self.window.get_widget("state-vm-memory").set_text("%d MB" % (vm_memory/1024))
|
||||
|
||||
def update_config_memory(self):
|
||||
self.window.get_widget("config-memory").get_adjustment().value = self.vm.current_memory()/1024
|
||||
|
||||
def update_config_cpus(self):
|
||||
self.window.get_widget("config-vm-cpus").get_adjustment().value = self.vm.vcpu_count()
|
||||
|
||||
def update_state_cpus(self):
|
||||
self.window.get_widget("state-host-cpus").set_text(`(self.vm.get_connection().host_maximum_processor_count())`)
|
||||
def config_cpus_apply(self, src):
|
||||
# Apply the change to the number of CPUs
|
||||
|
||||
vcpus = self.window.get_widget("config-vm-cpus").get_adjustment().value
|
||||
|
||||
# if requested # of CPUS > host CPUS, pop up warning dialog (not implemented yet)
|
||||
|
||||
self.vm.set_vcpu_count(vcpus)
|
||||
self.window.get_widget("config-cpus-apply").set_sensitive(False)
|
||||
|
||||
def config_vm_cpus(self, src):
|
||||
# cpu spinbox changed, make the apply button available
|
||||
self.window.get_widget("config-cpus-apply").set_sensitive(True)
|
||||
|
||||
def config_memory_value(self, src):
|
||||
self.window.get_widget("config-memory-apply").set_sensitive(True)
|
||||
|
||||
def config_memory_apply(self, src):
|
||||
memory = self.window.get_widget("config-memory").get_adjustment().value
|
||||
newmem = self.vm.set_memory(memory*1024)
|
||||
self.window.get_widget("config-memory-apply").set_sensitive(False)
|
||||
self.window.get_widget("state-vm-memory").set_text("%d MB" % (newmem/1024))
|
||||
|
||||
gobject.type_register(vmmDetails)
|
||||
|
@ -270,5 +270,14 @@ class vmmDomain(gobject.GObject):
|
||||
# added
|
||||
return ["vnc", "localhost", 5900 + self.get_id()]
|
||||
|
||||
def set_vcpu_count(self, vcpus):
|
||||
print "If this was implemented, it would set this domain to have " + `vcpus` + " virtual cpus."
|
||||
|
||||
def set_memory(self, memory):
|
||||
memory = int(memory)
|
||||
if(memory > self.maximum_memory()):
|
||||
print "XXX add proper error handling here. You may not set vm memory larger than the maximum set for the vm."
|
||||
self.vm.setMemory(memory)
|
||||
return self.vm.info()[2]
|
||||
|
||||
gobject.type_register(vmmDomain)
|
||||
|
@ -28,7 +28,7 @@ from virtManager.preferences import vmmPreferences
|
||||
from virtManager.manager import vmmManager
|
||||
from virtManager.details import vmmDetails
|
||||
from virtManager.console import vmmConsole
|
||||
from virtManager.asyncjob import asyncJob
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
|
||||
class vmmEngine:
|
||||
def __init__(self, config):
|
||||
@ -222,7 +222,7 @@ class vmmEngine:
|
||||
self.fcdialog.hide()
|
||||
if(response == gtk.RESPONSE_ACCEPT):
|
||||
file_to_save = self.fcdialog.get_filename()
|
||||
progWin = asyncJob(self.config, vm.save,
|
||||
progWin = vmmAsyncJob(self.config, vm.save,
|
||||
[file_to_save], "Saving Virtual Machine")
|
||||
progWin.run()
|
||||
self.fcdialog.destroy()
|
||||
|
@ -24,7 +24,7 @@ import threading
|
||||
|
||||
import sparkline
|
||||
|
||||
from virtManager.asyncjob import asyncJob
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
|
||||
VMLIST_SORT_ID = 1
|
||||
VMLIST_SORT_NAME = 2
|
||||
@ -125,6 +125,9 @@ class vmmManager(gobject.GObject):
|
||||
self.window.get_widget("vm-list").get_selection().connect("changed", self.vm_selected)
|
||||
self.connection.connect("disconnected", self.close)
|
||||
|
||||
# store any error message from the restore-domain callback
|
||||
self.domain_restore_error = ""
|
||||
|
||||
def show(self):
|
||||
win = self.window.get_widget("vmm-manager")
|
||||
win.show_all()
|
||||
@ -155,11 +158,28 @@ class vmmManager(gobject.GObject):
|
||||
self.fcdialog.hide()
|
||||
if(response == gtk.RESPONSE_ACCEPT):
|
||||
file_to_load = self.fcdialog.get_filename()
|
||||
progWin = asyncJob(self.config, self.connection.restore,
|
||||
progWin = vmmAsyncJob(self.config, self.restore_saved_callback,
|
||||
[file_to_load], "Restoring Virtual Machine")
|
||||
progWin.run()
|
||||
|
||||
self.fcdialog.destroy()
|
||||
if(self.domain_restore_error != ""):
|
||||
self.error_msg = gtk.MessageDialog(self.window.get_widget("vmm-manager"),
|
||||
gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
gtk.MESSAGE_ERROR,
|
||||
gtk.BUTTONS_OK,
|
||||
self.domain_restore_error)
|
||||
self.error_msg.run()
|
||||
self.error_msg.destroy()
|
||||
self.domain_restore_error = ""
|
||||
|
||||
|
||||
def restore_saved_callback(self, file_to_load):
|
||||
status = self.connection.restore(file_to_load)
|
||||
if(status != 0):
|
||||
self.domain_restore_error = "Error restoring domain " + file_to_load + \
|
||||
". Is the domain already running?"
|
||||
|
||||
|
||||
def vm_added(self, connection, uri, vmuuid):
|
||||
vmlist = self.window.get_widget("vm-list")
|
||||
|
Loading…
x
Reference in New Issue
Block a user