2014-01-07 13:20:44 +04:00
# Copyright (C) 2006-2008, 2013, 2014 Red Hat, Inc.
2006-06-28 23:50:17 +04:00
# Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
#
2018-04-04 16:35:41 +03:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 22:00:02 +03:00
# See the COPYING file in the top-level directory.
2006-06-14 18:59:40 +04:00
2019-05-06 02:00:40 +03:00
import re
2007-04-11 03:07:53 +04:00
2012-05-14 17:24:56 +04:00
from gi . repository import Gtk
2011-04-29 00:17:44 +04:00
import libvirt
2016-12-13 20:36:49 +03:00
import virtinst
2019-06-17 04:12:39 +03:00
from virtinst import log
2016-12-13 20:36:49 +03:00
2019-06-17 05:19:17 +03:00
from . . lib import uiutil
2019-06-17 04:56:34 +03:00
from . . addhardware import vmmAddHardware
from . . baseclass import vmmGObjectUI
from . . device . addstorage import vmmAddStorage
from . . device . fsdetails import vmmFSDetails
from . . device . gfxdetails import vmmGraphicsDetails
from . . device . mediacombo import vmmMediaCombo
from . . device . netlist import vmmNetworkList
from . . device . vsockdetails import vmmVsockDetails
2019-06-17 05:19:17 +03:00
from . . lib . graphwidgets import Sparkline
2019-06-17 04:56:34 +03:00
from . . oslist import vmmOSList
from . . storagebrowse import vmmStorageBrowser
from . . xmleditor import vmmXMLEditor
2020-01-24 11:33:54 +03:00
from . . delete import vmmDeleteStorage
2007-04-11 03:07:53 +04:00
2012-02-02 20:32:29 +04:00
2014-02-04 16:03:52 +04:00
# Parameters that can be edited in the details window
2019-05-06 02:00:40 +03:00
( EDIT_XML ,
EDIT_NAME ,
2017-09-07 12:03:04 +03:00
EDIT_TITLE ,
EDIT_MACHTYPE ,
EDIT_FIRMWARE ,
EDIT_DESC ,
2018-09-29 23:04:05 +03:00
EDIT_OS_NAME ,
2017-09-07 12:03:04 +03:00
EDIT_VCPUS ,
EDIT_CPU ,
EDIT_TOPOLOGY ,
EDIT_MEM ,
EDIT_AUTOSTART ,
EDIT_BOOTORDER ,
EDIT_BOOTMENU ,
EDIT_KERNEL ,
EDIT_INIT ,
EDIT_DISK_RO ,
EDIT_DISK_SHARE ,
EDIT_DISK_REMOVABLE ,
EDIT_DISK_CACHE ,
2018-08-24 02:38:07 +03:00
EDIT_DISK_DISCARD ,
2018-08-24 02:40:18 +03:00
EDIT_DISK_DETECT_ZEROES ,
2017-09-07 12:03:04 +03:00
EDIT_DISK_BUS ,
2018-10-06 21:26:31 +03:00
EDIT_DISK_PATH ,
2017-09-07 12:03:04 +03:00
EDIT_SOUND_MODEL ,
EDIT_SMARTCARD_MODE ,
EDIT_NET_MODEL ,
EDIT_NET_SOURCE ,
EDIT_NET_MAC ,
2018-08-16 18:30:31 +03:00
EDIT_NET_LINKSTATE ,
2017-09-07 12:03:04 +03:00
EDIT_GFX_PASSWD ,
EDIT_GFX_TYPE ,
EDIT_GFX_LISTEN ,
EDIT_GFX_ADDRESS ,
EDIT_GFX_PORT ,
EDIT_GFX_OPENGL ,
EDIT_GFX_RENDERNODE ,
EDIT_VIDEO_MODEL ,
EDIT_VIDEO_3D ,
EDIT_WATCHDOG_MODEL ,
EDIT_WATCHDOG_ACTION ,
EDIT_CONTROLLER_MODEL ,
EDIT_TPM_TYPE ,
2018-06-09 00:42:44 +03:00
EDIT_TPM_MODEL ,
2017-09-07 12:03:04 +03:00
2018-12-14 17:34:19 +03:00
EDIT_VSOCK_AUTO ,
EDIT_VSOCK_CID ,
2017-09-07 12:03:04 +03:00
EDIT_FS ,
2020-01-26 00:31:49 +03:00
EDIT_HOSTDEV_ROMBAR ) = range ( 1 , 49 )
2011-07-15 00:18:42 +04:00
2007-07-14 22:43:20 +04:00
# Columns in hw list model
Initial snapshot support
This adds initial UI for managing snapshots: list, run/revert, delete,
add, and redefining (for changing <description>) supported, but currently
only for internal snapshots. The UI is mostly in its final form except for
some bells and whistles.
The real remaining question is what do we want to advertise and support.
Internal (qcow2) snapshots are by far the simplest to manage, very
mature, and already have the semantics we want.
However most recent libvirt and qemu work has been to facilitate
external snapshots, which are more extensible and can be performed
live, and with qemu-ga coordination for extra safety. However
they make things much harder for virt-manager at the moment.
Until we have a plan, this work should be considered experimental
and not be relied upon.
2013-08-02 18:18:47 +04:00
( HW_LIST_COL_LABEL ,
HW_LIST_COL_ICON_NAME ,
HW_LIST_COL_TYPE ,
2019-05-08 19:23:06 +03:00
HW_LIST_COL_DEVICE ,
HW_LIST_COL_KEY ) = range ( 5 )
2007-07-14 22:43:20 +04:00
2008-07-24 00:23:56 +04:00
# Types for the hw list model: numbers specify what order they will be listed
Initial snapshot support
This adds initial UI for managing snapshots: list, run/revert, delete,
add, and redefining (for changing <description>) supported, but currently
only for internal snapshots. The UI is mostly in its final form except for
some bells and whistles.
The real remaining question is what do we want to advertise and support.
Internal (qcow2) snapshots are by far the simplest to manage, very
mature, and already have the semantics we want.
However most recent libvirt and qemu work has been to facilitate
external snapshots, which are more extensible and can be performed
live, and with qemu-ga coordination for extra safety. However
they make things much harder for virt-manager at the moment.
Until we have a plan, this work should be considered experimental
and not be relied upon.
2013-08-02 18:18:47 +04:00
( HW_LIST_TYPE_GENERAL ,
2018-09-29 23:04:05 +03:00
HW_LIST_TYPE_OS ,
Initial snapshot support
This adds initial UI for managing snapshots: list, run/revert, delete,
add, and redefining (for changing <description>) supported, but currently
only for internal snapshots. The UI is mostly in its final form except for
some bells and whistles.
The real remaining question is what do we want to advertise and support.
Internal (qcow2) snapshots are by far the simplest to manage, very
mature, and already have the semantics we want.
However most recent libvirt and qemu work has been to facilitate
external snapshots, which are more extensible and can be performed
live, and with qemu-ga coordination for extra safety. However
they make things much harder for virt-manager at the moment.
Until we have a plan, this work should be considered experimental
and not be relied upon.
2013-08-02 18:18:47 +04:00
HW_LIST_TYPE_STATS ,
HW_LIST_TYPE_CPU ,
HW_LIST_TYPE_MEMORY ,
HW_LIST_TYPE_BOOT ,
HW_LIST_TYPE_DISK ,
HW_LIST_TYPE_NIC ,
HW_LIST_TYPE_INPUT ,
HW_LIST_TYPE_GRAPHICS ,
HW_LIST_TYPE_SOUND ,
HW_LIST_TYPE_CHAR ,
HW_LIST_TYPE_HOSTDEV ,
HW_LIST_TYPE_VIDEO ,
HW_LIST_TYPE_WATCHDOG ,
HW_LIST_TYPE_CONTROLLER ,
HW_LIST_TYPE_FILESYSTEM ,
HW_LIST_TYPE_SMARTCARD ,
HW_LIST_TYPE_REDIRDEV ,
2013-09-23 17:39:56 +04:00
HW_LIST_TYPE_TPM ,
2014-01-10 13:37:55 +04:00
HW_LIST_TYPE_RNG ,
2018-12-14 17:34:19 +03:00
HW_LIST_TYPE_PANIC ,
HW_LIST_TYPE_VSOCK ) = range ( 23 )
2006-06-14 18:59:40 +04:00
2010-12-10 19:47:07 +03:00
remove_pages = [ HW_LIST_TYPE_NIC , HW_LIST_TYPE_INPUT ,
HW_LIST_TYPE_GRAPHICS , HW_LIST_TYPE_SOUND , HW_LIST_TYPE_CHAR ,
HW_LIST_TYPE_HOSTDEV , HW_LIST_TYPE_DISK , HW_LIST_TYPE_VIDEO ,
2011-05-19 23:18:33 +04:00
HW_LIST_TYPE_WATCHDOG , HW_LIST_TYPE_CONTROLLER ,
2011-09-02 05:23:27 +04:00
HW_LIST_TYPE_FILESYSTEM , HW_LIST_TYPE_SMARTCARD ,
2013-09-23 17:39:56 +04:00
HW_LIST_TYPE_REDIRDEV , HW_LIST_TYPE_TPM ,
2018-12-14 17:34:19 +03:00
HW_LIST_TYPE_RNG , HW_LIST_TYPE_PANIC , HW_LIST_TYPE_VSOCK ]
2009-07-09 22:35:36 +04:00
2010-02-25 04:37:41 +03:00
# Boot device columns
2014-02-10 01:21:26 +04:00
( BOOT_KEY ,
Initial snapshot support
This adds initial UI for managing snapshots: list, run/revert, delete,
add, and redefining (for changing <description>) supported, but currently
only for internal snapshots. The UI is mostly in its final form except for
some bells and whistles.
The real remaining question is what do we want to advertise and support.
Internal (qcow2) snapshots are by far the simplest to manage, very
mature, and already have the semantics we want.
However most recent libvirt and qemu work has been to facilitate
external snapshots, which are more extensible and can be performed
live, and with qemu-ga coordination for extra safety. However
they make things much harder for virt-manager at the moment.
Until we have a plan, this work should be considered experimental
and not be relied upon.
2013-08-02 18:18:47 +04:00
BOOT_LABEL ,
BOOT_ICON ,
2014-02-10 01:21:26 +04:00
BOOT_ACTIVE ,
BOOT_CAN_SELECT ) = range ( 5 )
2010-02-25 04:37:41 +03:00
2013-04-13 22:34:52 +04:00
2018-03-21 21:42:50 +03:00
def _calculate_disk_bus_index ( disklist ) :
# Iterate through all disks and calculate what number they are
# This sets disk.disk_bus_index which is not a standard property
idx_mapping = { }
for dev in disklist :
devtype = dev . device
bus = dev . bus
key = devtype + ( bus or " " )
if key not in idx_mapping :
idx_mapping [ key ] = 1
dev . disk_bus_index = idx_mapping [ key ]
idx_mapping [ key ] + = 1
return disklist
2015-08-03 19:52:07 +03:00
def _label_for_device ( dev ) :
2018-03-21 01:59:14 +03:00
devtype = dev . DEVICE_TYPE
2014-02-10 00:20:41 +04:00
if devtype == " disk " :
2020-07-13 11:25:59 +03:00
if dev . device == " floppy " :
return _ ( " Floppy %(index)d " ) % { " index " : dev . disk_bus_index }
2020-08-25 15:47:11 +03:00
busstr = " "
2020-07-14 10:41:46 +03:00
if dev . bus :
busstr = vmmAddHardware . disk_pretty_bus ( dev . bus )
2020-08-25 15:47:11 +03:00
if dev . device == " cdrom " :
return _ ( " %(bus)s CDROM %(index)d " ) % {
2020-07-14 10:41:46 +03:00
" bus " : busstr ,
" index " : dev . disk_bus_index ,
}
2015-09-22 02:16:31 +03:00
elif dev . device == " disk " :
2020-08-25 15:47:11 +03:00
return _ ( " %(bus)s Disk %(index)d " ) % {
" bus " : busstr ,
" index " : dev . disk_bus_index ,
}
return _ ( " %(bus)s %(device)s %(index)d " ) % {
" bus " : busstr ,
2020-07-14 10:41:46 +03:00
" device " : dev . device . capitalize ( ) ,
" index " : dev . disk_bus_index ,
}
2014-02-10 00:20:41 +04:00
if devtype == " interface " :
2020-08-27 01:01:02 +03:00
mac = dev . macaddr [ - 9 : ] or " "
return _ ( " NIC %(mac)s " ) % { " mac " : mac }
2014-02-10 00:20:41 +04:00
if devtype == " input " :
if dev . type == " tablet " :
return _ ( " Tablet " )
elif dev . type == " mouse " :
return _ ( " Mouse " )
2014-05-04 21:23:54 +04:00
elif dev . type == " keyboard " :
return _ ( " Keyboard " )
2020-08-27 01:01:02 +03:00
return _ ( " Input " ) # pragma: no cover
2014-02-10 00:20:41 +04:00
2020-07-13 11:25:44 +03:00
if devtype == " serial " :
2020-08-27 01:01:02 +03:00
port = dev . target_port or 0
return _ ( " Serial %(num)d " ) % { " num " : port + 1 }
2020-07-13 11:25:44 +03:00
if devtype == " parallel " :
2020-08-27 01:01:02 +03:00
port = dev . target_port or 0
return _ ( " Parallel %(num)d " ) % { " num " : port + 1 }
2020-07-13 11:25:44 +03:00
if devtype == " console " :
2020-08-27 01:01:02 +03:00
port = dev . target_port or 0
return _ ( " Console %(num)d " ) % { " num " : port + 1 }
2014-02-10 00:20:41 +04:00
if devtype == " channel " :
2019-06-09 22:29:44 +03:00
name = vmmAddHardware . char_pretty_channel_name ( dev . target_name )
2014-02-10 00:20:41 +04:00
if name :
2020-07-13 11:25:40 +03:00
return _ ( " Channel %(name)s " ) % { " name " : name }
pretty_type = vmmAddHardware . char_pretty_type ( dev . type )
2020-08-27 01:01:02 +03:00
return _ ( " Channel %(type)s " ) % { " type " : pretty_type }
2014-02-10 00:20:41 +04:00
if devtype == " graphics " :
2019-06-09 22:29:44 +03:00
pretty = vmmGraphicsDetails . graphics_pretty_type_simple ( dev . type )
return _ ( " Display %s " ) % pretty
2014-02-10 00:20:41 +04:00
if devtype == " redirdev " :
2020-07-13 11:25:56 +03:00
return _ ( " %(bus)s Redirector %(index)d " ) % {
" bus " : vmmAddHardware . disk_pretty_bus ( dev . bus ) ,
" index " : dev . get_xml_idx ( ) + 1 ,
}
2014-02-10 00:20:41 +04:00
if devtype == " hostdev " :
2019-06-09 22:29:44 +03:00
return vmmAddHardware . hostdev_pretty_name ( dev )
2014-02-10 00:20:41 +04:00
if devtype == " sound " :
2018-01-21 01:25:40 +03:00
return _ ( " Sound %s " ) % dev . model
2014-02-10 00:20:41 +04:00
if devtype == " video " :
2019-06-09 22:29:44 +03:00
return _ ( " Video %s " ) % vmmAddHardware . video_pretty_model ( dev . model )
2014-02-10 00:20:41 +04:00
if devtype == " filesystem " :
2020-07-13 11:25:58 +03:00
return _ ( " Filesystem %(path)s " ) % { " path " : dev . target [ : 8 ] }
2014-02-10 00:20:41 +04:00
if devtype == " controller " :
2020-07-13 20:07:06 +03:00
idx = dev . index
2020-07-14 10:41:53 +03:00
if idx is not None :
return _ ( " Controller %(controller)s %(index)s " ) % {
" controller " : vmmAddHardware . controller_pretty_desc ( dev ) ,
" index " : idx ,
}
return _ ( " Controller %(controller)s " ) % {
2020-07-13 11:25:47 +03:00
" controller " : vmmAddHardware . controller_pretty_desc ( dev ) ,
}
2017-03-09 01:48:26 +03:00
if devtype == " rng " :
if dev . device :
2020-07-13 11:25:45 +03:00
return _ ( " RNG %(device)s " ) % { " device " : dev . device }
return _ ( " RNG " )
2017-03-09 01:48:26 +03:00
if devtype == " tpm " :
if dev . device_path :
2020-07-13 11:25:46 +03:00
return _ ( " TPM %(device)s " ) % { " device " : dev . device_path }
return _ ( " TPM v %(version)s " ) % { " version " : dev . version }
2014-02-10 00:20:41 +04:00
devmap = {
" panic " : _ ( " Panic Notifier " ) ,
" smartcard " : _ ( " Smartcard " ) ,
2020-07-13 11:25:39 +03:00
" vsock " : _ ( " VirtIO VSOCK " ) ,
2014-02-10 00:20:41 +04:00
" watchdog " : _ ( " Watchdog " ) ,
}
return devmap [ devtype ]
def _icon_for_device ( dev ) :
2018-03-21 01:59:14 +03:00
devtype = dev . DEVICE_TYPE
2014-02-10 00:20:41 +04:00
if devtype == " disk " :
if dev . device == " cdrom " :
return " media-optical "
elif dev . device == " floppy " :
return " media-floppy "
return " drive-harddisk "
if devtype == " input " :
2015-04-09 20:36:40 +03:00
if dev . type == " keyboard " :
return " input-keyboard "
2014-02-10 00:20:41 +04:00
if dev . type == " tablet " :
return " input-tablet "
return " input-mouse "
if devtype == " redirdev " :
2020-08-27 01:01:02 +03:00
return " device_usb "
2014-02-10 00:20:41 +04:00
if devtype == " hostdev " :
if dev . type == " usb " :
return " device_usb "
return " device_pci "
typemap = {
" interface " : " network-idle " ,
" graphics " : " video-display " ,
" serial " : " device_serial " ,
" parallel " : " device_serial " ,
" console " : " device_serial " ,
" channel " : " device_serial " ,
" video " : " video-display " ,
" watchdog " : " device_pci " ,
" sound " : " audio-card " ,
" rng " : " system-run " ,
" tpm " : " device_cpu " ,
" smartcard " : " device_serial " ,
2014-10-04 15:45:50 +04:00
" filesystem " : " folder " ,
2014-02-10 00:20:41 +04:00
" controller " : " device_pci " ,
" panic " : " system-run " ,
2018-12-14 17:34:19 +03:00
" vsock " : " network-idle " ,
2014-02-10 00:20:41 +04:00
}
return typemap [ devtype ]
2014-06-01 04:13:08 +04:00
def _chipset_label_from_machine ( machine ) :
if machine and " q35 " in machine :
return " Q35 "
return " i440FX "
2020-01-26 23:41:21 +03:00
def _get_performance_icon_name ( ) :
# This icon isn't in standard adwaita-icon-theme, so
# fallback to system-run if it is missing
icon = " utilities-system-monitor "
if not Gtk . IconTheme . get_default ( ) . has_icon ( icon ) :
2020-08-27 01:01:02 +03:00
icon = " system-run " # pragma: no cover
2020-01-26 23:41:21 +03:00
return icon
2019-05-06 02:00:40 +03:00
def _unindent_device_xml ( xml ) :
"""
The device parsed from a domain will have no indent
for the first line , but then < domain > expected indent
from the remaining lines . Try to unindent the remaining
lines so it looks nice in the XML editor .
"""
lines = xml . splitlines ( )
if not xml . startswith ( " < " ) or len ( lines ) < 2 :
return xml
ret = " "
unindent = 0
for c in lines [ 1 ] :
if c != " " :
break
unindent + = 1
unindent = max ( 0 , unindent - 2 )
ret = lines [ 0 ] + " \n "
for line in lines [ 1 : ] :
if re . match ( r " ^ %s *<.*$ " % ( unindent * " " ) , line ) :
line = line [ unindent : ]
ret + = line + " \n "
return ret
2010-12-09 01:26:19 +03:00
class vmmDetails ( vmmGObjectUI ) :
2019-05-05 23:25:35 +03:00
def __init__ ( self , vm , builder , topwin , is_customize_dialog ) :
vmmGObjectUI . __init__ ( self , " details.ui " ,
None , builder = builder , topwin = topwin )
2018-03-15 12:53:58 +03:00
2006-06-14 18:59:40 +04:00
self . vm = vm
2020-08-27 21:36:48 +03:00
self . _active_edits = [ ]
2019-05-05 23:25:35 +03:00
self . top_box = self . widget ( " details-top-box " )
2011-07-15 00:18:42 +04:00
2007-04-12 23:36:04 +04:00
self . addhw = None
2010-12-12 07:00:19 +03:00
self . storage_browser = None
2018-10-06 21:26:31 +03:00
self . _mediacombo = None
2019-05-05 23:25:35 +03:00
self . is_customize_dialog = is_customize_dialog
2008-04-08 22:30:47 +04:00
2020-08-27 21:36:48 +03:00
def _e ( edittype ) :
def signal_cb ( * args ) :
self . _enable_apply ( edittype )
return signal_cb
2018-10-06 21:26:31 +03:00
self . _mediacombo = vmmMediaCombo ( self . conn , self . builder , self . topwin )
self . widget ( " disk-source-align " ) . add ( self . _mediacombo . top_box )
self . _mediacombo . set_mnemonic_label (
self . widget ( " disk-source-mnemonic " ) )
2020-08-27 21:36:48 +03:00
self . _mediacombo . connect ( " changed " , _e ( EDIT_DISK_PATH ) )
2018-10-06 21:26:31 +03:00
self . _mediacombo . show_clear_icon ( )
2014-01-27 20:03:59 +04:00
self . fsDetails = vmmFSDetails ( self . vm , self . builder , self . topwin )
self . widget ( " fs-alignment " ) . add ( self . fsDetails . top_box )
2020-08-27 21:36:48 +03:00
self . fsDetails . connect ( " changed " , _e ( EDIT_FS ) )
2014-01-27 20:03:59 +04:00
2014-01-29 03:44:40 +04:00
self . gfxdetails = vmmGraphicsDetails (
self . vm , self . builder , self . topwin )
self . widget ( " graphics-align " ) . add ( self . gfxdetails . top_box )
2020-08-27 21:36:48 +03:00
self . gfxdetails . connect ( " changed-type " , _e ( EDIT_GFX_TYPE ) )
self . gfxdetails . connect ( " changed-port " , _e ( EDIT_GFX_PORT ) )
self . gfxdetails . connect ( " changed-opengl " , _e ( EDIT_GFX_OPENGL ) )
self . gfxdetails . connect ( " changed-rendernode " , _e ( EDIT_GFX_RENDERNODE ) )
self . gfxdetails . connect ( " changed-listen " , _e ( EDIT_GFX_LISTEN ) )
self . gfxdetails . connect ( " changed-address " , _e ( EDIT_GFX_ADDRESS ) )
self . gfxdetails . connect ( " changed-password " , _e ( EDIT_GFX_PASSWD ) )
2014-01-29 03:44:40 +04:00
2014-01-28 01:58:45 +04:00
self . netlist = vmmNetworkList ( self . conn , self . builder , self . topwin )
self . widget ( " network-source-label-align " ) . add ( self . netlist . top_label )
self . widget ( " network-source-ui-align " ) . add ( self . netlist . top_box )
2020-08-27 21:36:48 +03:00
self . netlist . connect ( " changed " , _e ( EDIT_NET_SOURCE ) )
2014-01-28 01:58:45 +04:00
2018-12-14 17:34:19 +03:00
self . vsockdetails = vmmVsockDetails ( self . vm , self . builder , self . topwin )
self . widget ( " vsock-align " ) . add ( self . vsockdetails . top_box )
2020-08-27 21:36:48 +03:00
self . vsockdetails . connect ( " changed-auto-cid " , _e ( EDIT_VSOCK_AUTO ) )
self . vsockdetails . connect ( " changed-cid " , _e ( EDIT_VSOCK_CID ) )
2018-12-14 17:34:19 +03:00
2019-05-06 02:00:40 +03:00
self . _xmleditor = vmmXMLEditor ( self . builder , self . topwin ,
self . widget ( " hw-panel-align " ) ,
self . widget ( " hw-panel " ) )
2020-08-27 21:36:48 +03:00
self . _xmleditor . connect ( " changed " , _e ( EDIT_XML ) )
2019-05-06 02:00:40 +03:00
self . _xmleditor . connect ( " xml-requested " ,
self . _xmleditor_xml_requested_cb )
self . _xmleditor . connect ( " xml-reset " ,
self . _xmleditor_xml_reset_cb )
2020-08-27 21:36:48 +03:00
self . _oldhwkey = None
self . _popupmenu = None
self . _popupmenuitems = None
2018-09-29 23:04:05 +03:00
self . _os_list = None
2020-08-27 21:36:48 +03:00
self . _init_menus ( )
self . _init_details ( )
self . _graph_cpu = None
self . _graph_memory = None
self . _graph_disk = None
self . _graph_network = None
self . _init_graphs ( )
2009-11-02 19:21:50 +03:00
2020-08-27 21:36:48 +03:00
self . vm . connect ( " inspection-changed " , self . _vm_inspection_changed_cb )
2008-04-08 22:30:47 +04:00
2013-02-16 22:31:46 +04:00
self . builder . connect_signals ( {
2020-08-27 21:36:48 +03:00
" on_hw_list_changed " : self . _hw_changed_cb ,
2006-06-14 18:59:40 +04:00
2020-08-27 21:36:48 +03:00
" on_overview_name_changed " : _e ( EDIT_NAME ) ,
" on_overview_title_changed " : _e ( EDIT_TITLE ) ,
" on_machine_type_changed " : _e ( EDIT_MACHTYPE ) ,
" on_overview_firmware_changed " : _e ( EDIT_FIRMWARE ) ,
" on_overview_chipset_changed " : _e ( EDIT_MACHTYPE ) ,
2010-02-25 04:37:41 +03:00
2020-08-27 21:36:48 +03:00
" on_details_inspection_refresh_clicked " : self . _inspection_refresh_clicked_cb ,
2017-02-23 13:22:27 +03:00
2020-01-25 23:11:02 +03:00
" on_cpu_vcpus_changed " : self . _config_vcpus_changed_cb ,
2020-08-27 21:36:48 +03:00
" on_cpu_model_changed " : _e ( EDIT_CPU ) ,
" on_cpu_copy_host_clicked " : self . _cpu_copy_host_clicked_cb ,
" on_cpu_secure_toggled " : _e ( EDIT_CPU ) ,
" on_cpu_cores_changed " : self . _cpu_topology_changed_cb ,
" on_cpu_sockets_changed " : self . _cpu_topology_changed_cb ,
" on_cpu_threads_changed " : self . _cpu_topology_changed_cb ,
" on_cpu_topology_enable_toggled " : self . _cpu_topology_enable_cb ,
" on_mem_memory_changed " : _e ( EDIT_MEM ) ,
" on_boot_list_changed " : self . _boot_list_changed_cb ,
" on_boot_moveup_clicked " : self . _boot_moveup_clicked_cb ,
" on_boot_movedown_clicked " : self . _boot_movedown_clicked_cb ,
" on_boot_autostart_changed " : _e ( EDIT_AUTOSTART ) ,
" on_boot_menu_changed " : _e ( EDIT_BOOTMENU ) ,
" on_boot_kernel_enable_toggled " : self . _boot_kernel_toggled_cb ,
" on_boot_kernel_changed " : _e ( EDIT_KERNEL ) ,
" on_boot_initrd_changed " : _e ( EDIT_KERNEL ) ,
" on_boot_dtb_changed " : _e ( EDIT_KERNEL ) ,
" on_boot_kernel_args_changed " : _e ( EDIT_KERNEL ) ,
" on_boot_kernel_browse_clicked " : self . _browse_kernel_clicked_cb ,
" on_boot_initrd_browse_clicked " : self . _browse_initrd_clicked_cb ,
" on_boot_dtb_browse_clicked " : self . _browse_dtb_clicked_cb ,
" on_boot_init_path_changed " : _e ( EDIT_INIT ) ,
" on_boot_init_args_changed " : _e ( EDIT_INIT ) ,
2012-05-14 17:24:56 +04:00
2018-10-06 21:26:31 +03:00
" on_disk_source_browse_clicked " : self . _disk_source_browse_clicked_cb ,
2020-08-27 21:36:48 +03:00
" on_disk_readonly_changed " : _e ( EDIT_DISK_RO ) ,
" on_disk_shareable_changed " : _e ( EDIT_DISK_SHARE ) ,
" on_disk_removable_changed " : _e ( EDIT_DISK_REMOVABLE ) ,
" on_disk_cache_combo_changed " : _e ( EDIT_DISK_CACHE ) ,
" on_disk_discard_combo_changed " : _e ( EDIT_DISK_DISCARD ) ,
" on_disk_detect_zeroes_combo_changed " : _e ( EDIT_DISK_DETECT_ZEROES ) ,
" on_disk_bus_combo_changed " : _e ( EDIT_DISK_BUS ) ,
2012-05-14 17:24:56 +04:00
2020-08-27 21:36:48 +03:00
" on_network_model_combo_changed " : _e ( EDIT_NET_MODEL ) ,
" on_network_mac_entry_changed " : _e ( EDIT_NET_MAC ) ,
" on_network_link_state_checkbox_toggled " : _e ( EDIT_NET_LINKSTATE ) ,
" on_network_refresh_ip_clicked " : self . _refresh_ip_clicked_cb ,
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
" on_sound_model_combo_changed " : _e ( EDIT_SOUND_MODEL ) ,
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
" on_video_model_combo_changed " : self . _video_model_changed_cb ,
" on_video_3d_toggled " : self . _video_3d_toggled_cb ,
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
" on_watchdog_model_combo_changed " : _e ( EDIT_WATCHDOG_MODEL ) ,
" on_watchdog_action_combo_changed " : _e ( EDIT_WATCHDOG_ACTION ) ,
2011-06-23 19:42:03 +04:00
2020-08-27 21:36:48 +03:00
" on_smartcard_mode_combo_changed " : _e ( EDIT_SMARTCARD_MODE ) ,
2014-02-10 23:24:22 +04:00
2020-08-27 21:36:48 +03:00
" on_hostdev_rombar_toggled " : _e ( EDIT_HOSTDEV_ROMBAR ) ,
" on_controller_model_combo_changed " : _e ( EDIT_CONTROLLER_MODEL ) ,
" on_tpm_model_combo_changed " : _e ( EDIT_TPM_MODEL ) ,
2009-07-09 22:35:36 +04:00
2020-08-27 21:36:48 +03:00
" on_config_apply_clicked " : self . _config_apply_clicked_cb ,
" on_config_cancel_clicked " : self . _config_cancel_clicked_cb ,
" on_config_remove_clicked " : self . _config_remove_clicked_cb ,
" on_add_hardware_button_clicked " : self . _addhw_clicked_cb ,
2008-04-08 22:30:47 +04:00
2020-08-27 21:36:48 +03:00
" on_hw_list_button_press_event " : self . _popup_addhw_menu_cb ,
2009-10-30 20:25:27 +03:00
} )
2006-06-14 18:59:40 +04:00
2020-08-27 21:36:48 +03:00
self . _init_hw_list ( )
self . _refresh_page ( )
2018-03-18 18:36:02 +03:00
2006-08-29 23:52:19 +04:00
2018-03-15 14:43:56 +03:00
@property
def conn ( self ) :
return self . vm . conn
2011-07-24 05:16:54 +04:00
def _cleanup ( self ) :
2020-08-27 21:36:48 +03:00
self . _oldhwkey = None
2011-07-20 04:29:07 +04:00
2011-07-24 05:16:54 +04:00
if self . addhw :
self . addhw . cleanup ( )
self . addhw = None
if self . storage_browser :
self . storage_browser . cleanup ( )
self . storage_browser = None
2011-04-12 02:35:21 +04:00
2018-10-06 21:26:31 +03:00
self . _mediacombo . cleanup ( )
self . _mediacombo = None
2015-09-13 21:07:43 +03:00
2018-03-15 14:43:56 +03:00
self . conn . disconnect_by_obj ( self )
2011-07-24 05:16:54 +04:00
self . vm = None
2020-08-27 21:36:48 +03:00
self . _popupmenu = None
self . _popupmenuitems = None
2008-04-08 22:30:47 +04:00
2014-01-29 03:44:40 +04:00
self . gfxdetails . cleanup ( )
self . gfxdetails = None
2014-01-21 13:05:31 +04:00
self . fsDetails . cleanup ( )
2014-01-28 01:58:45 +04:00
self . fsDetails = None
self . netlist . cleanup ( )
self . netlist = None
2019-04-13 19:02:33 +03:00
self . vsockdetails . cleanup ( )
self . vsockdetails = None
2019-05-06 02:00:40 +03:00
self . _xmleditor . cleanup ( )
self . _xmleditor = None
2014-01-21 13:05:31 +04:00
2009-11-04 21:18:14 +03:00
2009-11-02 19:21:50 +03:00
##########################
# Initialization helpers #
##########################
2020-08-27 21:36:48 +03:00
def _init_menus ( self ) :
2010-02-12 22:01:59 +03:00
# Add HW popup menu
2020-08-27 21:36:48 +03:00
self . _popupmenu = Gtk . Menu ( )
2011-07-13 05:42:19 +04:00
2014-02-26 00:57:38 +04:00
addHW = Gtk . ImageMenuItem . new_with_label ( _ ( " _Add Hardware " ) )
2013-04-17 02:47:16 +04:00
addHW . set_use_underline ( True )
2012-05-14 17:24:56 +04:00
addHWImg = Gtk . Image ( )
addHWImg . set_from_stock ( Gtk . STOCK_ADD , Gtk . IconSize . MENU )
2010-02-12 22:01:59 +03:00
addHW . set_image ( addHWImg )
addHW . show ( )
2020-08-27 21:36:48 +03:00
def _addhw_clicked_cb ( * args , * * kwargs ) :
self . _show_addhw ( )
addHW . connect ( " activate " , _addhw_clicked_cb )
2011-07-13 05:42:19 +04:00
2014-02-26 00:57:38 +04:00
rmHW = Gtk . ImageMenuItem . new_with_label ( _ ( " _Remove Hardware " ) )
2013-04-17 02:47:16 +04:00
rmHW . set_use_underline ( True )
2012-05-14 17:24:56 +04:00
rmHWImg = Gtk . Image ( )
rmHWImg . set_from_stock ( Gtk . STOCK_REMOVE , Gtk . IconSize . MENU )
2011-07-13 05:42:19 +04:00
rmHW . set_image ( rmHWImg )
rmHW . show ( )
2020-08-27 21:36:48 +03:00
def _remove_clicked_cb ( * args , * * kwargs ) :
self . _config_remove ( )
rmHW . connect ( " activate " , _remove_clicked_cb )
2011-07-13 05:42:19 +04:00
2020-08-27 21:36:48 +03:00
self . _popupmenuitems = { " add " : addHW , " remove " : rmHW }
for i in list ( self . _popupmenuitems . values ( ) ) :
self . _popupmenu . add ( i )
2010-02-12 22:01:59 +03:00
2011-07-14 21:13:13 +04:00
self . widget ( " hw-panel " ) . set_show_tabs ( False )
2009-11-02 19:21:50 +03:00
2020-08-27 21:36:48 +03:00
def _init_graphs ( self ) :
2013-09-27 22:17:57 +04:00
def _make_graph ( ) :
g = Sparkline ( )
g . set_property ( " reversed " , True )
g . show ( )
return g
2009-11-02 19:21:50 +03:00
2020-08-27 21:36:48 +03:00
self . _graph_cpu = _make_graph ( )
self . widget ( " overview-cpu-usage-align " ) . add ( self . _graph_cpu )
2009-11-02 19:21:50 +03:00
2020-08-27 21:36:48 +03:00
self . _graph_memory = _make_graph ( )
self . widget ( " overview-memory-usage-align " ) . add ( self . _graph_memory )
2009-11-02 19:21:50 +03:00
2020-08-27 21:36:48 +03:00
self . _graph_disk = _make_graph ( )
self . _graph_disk . set_property ( " filled " , False )
self . _graph_disk . set_property ( " num_sets " , 2 )
self . _graph_disk . set_property ( " rgb " , [ x / 255.0 for x in
2013-04-12 00:32:00 +04:00
[ 0x82 , 0x00 , 0x3B , 0x29 , 0x5C , 0x45 ] ] )
2020-08-27 21:36:48 +03:00
self . widget ( " overview-disk-usage-align " ) . add ( self . _graph_disk )
2009-11-02 19:21:50 +03:00
2020-08-27 21:36:48 +03:00
self . _graph_network = _make_graph ( )
self . _graph_network . set_property ( " filled " , False )
self . _graph_network . set_property ( " num_sets " , 2 )
self . _graph_network . set_property ( " rgb " , [ x / 255.0 for x in
2009-11-02 19:21:50 +03:00
[ 0x82 , 0x00 , 0x3B ,
2013-04-12 00:32:00 +04:00
0x29 , 0x5C , 0x45 ] ] )
2013-09-27 22:17:57 +04:00
self . widget ( " overview-network-traffic-align " ) . add (
2020-08-27 21:36:48 +03:00
self . _graph_network )
2010-06-21 21:47:07 +04:00
2020-08-27 21:36:48 +03:00
def _init_details ( self ) :
2009-11-04 21:18:14 +03:00
# Hardware list
2019-05-08 19:23:06 +03:00
# [ label, icon name, hw type, dev xmlobj, unique key (dev or title)]
hw_list_model = Gtk . ListStore ( str , str , int , object , object )
2011-07-14 21:13:13 +04:00
self . widget ( " hw-list " ) . set_model ( hw_list_model )
2009-11-04 21:18:14 +03:00
2016-02-05 18:18:16 +03:00
hwCol = Gtk . TreeViewColumn ( _ ( " Hardware " ) )
2009-11-04 21:18:14 +03:00
hwCol . set_spacing ( 6 )
hwCol . set_min_width ( 165 )
2012-05-14 17:24:56 +04:00
hw_txt = Gtk . CellRendererText ( )
hw_img = Gtk . CellRendererPixbuf ( )
2019-05-08 18:57:37 +03:00
hw_img . set_property ( " stock-size " , Gtk . IconSize . LARGE_TOOLBAR )
2009-11-04 21:18:14 +03:00
hwCol . pack_start ( hw_img , False )
hwCol . pack_start ( hw_txt , True )
hwCol . add_attribute ( hw_txt , ' text ' , HW_LIST_COL_LABEL )
hwCol . add_attribute ( hw_img , ' icon-name ' , HW_LIST_COL_ICON_NAME )
2011-07-14 21:13:13 +04:00
self . widget ( " hw-list " ) . append_column ( hwCol )
2009-11-04 21:18:14 +03:00
2010-02-10 20:16:59 +03:00
# Description text view
2011-07-14 21:13:13 +04:00
desc = self . widget ( " overview-description " )
2012-05-14 17:24:56 +04:00
buf = Gtk . TextBuffer ( )
2020-08-27 21:36:48 +03:00
def _buf_changed_cb ( * args ) :
self . _enable_apply ( EDIT_DESC )
buf . connect ( " changed " , _buf_changed_cb )
2010-02-10 20:16:59 +03:00
desc . set_buffer ( buf )
2012-01-05 13:35:40 +04:00
arch = self . vm . get_arch ( )
2013-07-06 22:12:13 +04:00
caps = self . vm . conn . caps
2012-01-05 13:35:40 +04:00
2013-09-02 03:21:21 +04:00
# Machine type
2013-09-28 20:21:35 +04:00
machtype_combo = self . widget ( " machine-type " )
2013-09-02 03:21:21 +04:00
machtype_model = Gtk . ListStore ( str )
machtype_combo . set_model ( machtype_model )
2015-04-10 20:04:02 +03:00
uiutil . init_combo_text_column ( machtype_combo , 0 )
2013-09-02 03:21:21 +04:00
machtype_model . set_sort_column_id ( 0 , Gtk . SortType . ASCENDING )
2012-01-05 13:35:40 +04:00
2014-06-01 04:13:08 +04:00
machines = [ ]
try :
2015-04-04 00:24:32 +03:00
capsinfo = caps . guest_lookup (
2014-06-01 04:13:08 +04:00
os_type = self . vm . get_abi_type ( ) ,
arch = self . vm . get_arch ( ) ,
typ = self . vm . get_hv_type ( ) ,
machine = self . vm . get_machtype ( ) )
2015-04-04 00:24:32 +03:00
machines = capsinfo . machines [ : ]
2017-07-24 11:26:48 +03:00
except Exception :
2019-06-17 04:12:39 +03:00
log . exception ( " Error determining machine list " )
2014-06-01 04:13:08 +04:00
2015-09-06 00:32:03 +03:00
show_machine = ( arch not in [ " i686 " , " x86_64 " ] )
2015-02-22 01:54:15 +03:00
uiutil . set_grid_row_visible ( self . widget ( " machine-type-title " ) ,
show_machine )
2013-09-28 20:21:35 +04:00
if show_machine :
2013-09-02 03:21:21 +04:00
for machine in machines :
machtype_model . append ( [ machine ] )
2012-01-05 13:35:40 +04:00
2015-02-22 01:54:15 +03:00
self . widget ( " machine-type " ) . set_visible ( self . is_customize_dialog )
self . widget ( " machine-type-label " ) . set_visible (
not self . is_customize_dialog )
2014-09-18 01:25:03 +04:00
# Firmware
combo = self . widget ( " overview-firmware " )
2015-02-22 19:13:21 +03:00
# [label, path, is_sensitive]
2014-09-18 01:25:03 +04:00
model = Gtk . ListStore ( str , str , bool )
combo . set_model ( model )
text = Gtk . CellRendererText ( )
combo . pack_start ( text , True )
combo . add_attribute ( text , " text " , 0 )
combo . add_attribute ( text , " sensitive " , 2 )
domcaps = self . vm . get_domain_capabilities ( )
2015-02-22 19:13:21 +03:00
uefipaths = [ v . value for v in domcaps . os . loader . values ]
2014-09-18 01:25:03 +04:00
warn_icon = self . widget ( " overview-firmware-warn " )
2015-02-18 23:16:48 +03:00
hv_supports_uefi = domcaps . supports_uefi_xml ( )
2014-09-18 01:25:03 +04:00
if not hv_supports_uefi :
warn_icon . set_tooltip_text (
_ ( " Libvirt or hypervisor does not support UEFI. " ) )
2015-02-22 19:13:21 +03:00
elif not uefipaths :
2020-08-27 23:37:15 +03:00
warn_icon . set_tooltip_text ( # pragma: no cover
2014-09-18 01:25:03 +04:00
_ ( " Libvirt did not detect any UEFI/OVMF firmware image "
" installed on the host. " ) )
2015-02-22 19:13:21 +03:00
model . append ( [ domcaps . label_for_firmware_path ( None ) , None , True ] )
if not uefipaths :
model . append ( [ _ ( " UEFI not found " ) , None , False ] )
else :
for path in uefipaths :
model . append ( [ domcaps . label_for_firmware_path ( path ) ,
path , True ] )
2014-09-18 01:25:03 +04:00
combo . set_active ( 0 )
self . widget ( " overview-firmware-warn " ) . set_visible (
2015-02-22 19:13:21 +03:00
not ( uefipaths and hv_supports_uefi ) and self . is_customize_dialog )
2014-09-18 01:25:03 +04:00
self . widget ( " overview-firmware " ) . set_visible ( self . is_customize_dialog )
self . widget ( " overview-firmware-label " ) . set_visible (
not self . is_customize_dialog )
2016-06-16 13:03:42 +03:00
show_firmware = ( ( self . conn . is_qemu ( ) or
2017-06-27 21:13:36 +03:00
self . conn . is_test ( ) or
2016-06-16 13:03:42 +03:00
self . conn . is_xen ( ) ) and
domcaps . arch_can_uefi ( ) )
2014-09-18 01:25:03 +04:00
uiutil . set_grid_row_visible (
self . widget ( " overview-firmware-title " ) , show_firmware )
2014-06-01 04:13:08 +04:00
# Chipset
combo = self . widget ( " overview-chipset " )
model = Gtk . ListStore ( str , str )
combo . set_model ( model )
model . append ( [ _chipset_label_from_machine ( " pc " ) , " pc " ] )
if " q35 " in machines :
model . append ( [ _chipset_label_from_machine ( " q35 " ) , " q35 " ] )
combo . set_active ( 0 )
self . widget ( " overview-chipset " ) . set_visible ( self . is_customize_dialog )
self . widget ( " overview-chipset-label " ) . set_visible (
not self . is_customize_dialog )
2017-06-27 21:13:36 +03:00
show_chipset = ( ( self . conn . is_qemu ( ) or self . conn . is_test ( ) ) and
2015-09-06 00:32:03 +03:00
arch in [ " i686 " , " x86_64 " ] )
2014-06-01 04:13:08 +04:00
uiutil . set_grid_row_visible (
self . widget ( " overview-chipset-title " ) , show_chipset )
2018-09-29 23:04:05 +03:00
# OS/Inspection page
self . _os_list = vmmOSList ( )
self . widget ( " details-os-align " ) . add ( self . _os_list . search_entry )
self . widget ( " details-os-label " ) . set_mnemonic_widget (
self . _os_list . search_entry )
self . _os_list . connect ( " os-selected " , self . _os_list_name_selected_cb )
2014-01-26 23:07:35 +04:00
apps_list = self . widget ( " inspection-apps " )
apps_model = Gtk . ListStore ( str , str , str )
apps_list . set_model ( apps_model )
name_col = Gtk . TreeViewColumn ( _ ( " Name " ) )
version_col = Gtk . TreeViewColumn ( _ ( " Version " ) )
summary_col = Gtk . TreeViewColumn ( )
apps_list . append_column ( name_col )
apps_list . append_column ( version_col )
apps_list . append_column ( summary_col )
name_text = Gtk . CellRendererText ( )
name_col . pack_start ( name_text , True )
name_col . add_attribute ( name_text , ' text ' , 0 )
name_col . set_sort_column_id ( 0 )
version_text = Gtk . CellRendererText ( )
version_col . pack_start ( version_text , True )
version_col . add_attribute ( version_text , ' text ' , 1 )
version_col . set_sort_column_id ( 1 )
summary_text = Gtk . CellRendererText ( )
summary_col . pack_start ( summary_text , True )
summary_col . add_attribute ( summary_text , ' text ' , 2 )
summary_col . set_sort_column_id ( 2 )
2009-11-04 21:18:14 +03:00
# Boot device list
2015-09-14 01:01:39 +03:00
boot_list = self . widget ( " boot-list " )
2014-02-10 01:21:26 +04:00
# [XML boot type, display name, icon name, enabled, can select]
boot_list_model = Gtk . ListStore ( str , str , str , bool , bool )
2009-11-04 21:18:14 +03:00
boot_list . set_model ( boot_list_model )
2009-11-02 19:21:50 +03:00
2012-05-14 17:24:56 +04:00
chkCol = Gtk . TreeViewColumn ( )
txtCol = Gtk . TreeViewColumn ( )
2010-02-25 04:37:41 +03:00
boot_list . append_column ( chkCol )
boot_list . append_column ( txtCol )
2012-05-14 17:24:56 +04:00
chk = Gtk . CellRendererToggle ( )
2020-08-27 21:36:48 +03:00
chk . connect ( " toggled " , self . _config_boot_toggled_cb )
2010-02-25 04:37:41 +03:00
chkCol . pack_start ( chk , False )
chkCol . add_attribute ( chk , ' active ' , BOOT_ACTIVE )
2014-02-10 01:21:26 +04:00
chkCol . add_attribute ( chk , ' visible ' , BOOT_CAN_SELECT )
2010-02-25 04:37:41 +03:00
2012-05-14 17:24:56 +04:00
icon = Gtk . CellRendererPixbuf ( )
2010-02-25 04:37:41 +03:00
txtCol . pack_start ( icon , False )
txtCol . add_attribute ( icon , ' icon-name ' , BOOT_ICON )
2012-05-14 17:24:56 +04:00
text = Gtk . CellRendererText ( )
2010-02-25 04:37:41 +03:00
txtCol . pack_start ( text , True )
txtCol . add_attribute ( text , ' text ' , BOOT_LABEL )
txtCol . add_attribute ( text , ' sensitive ' , BOOT_ACTIVE )
2008-04-08 22:30:47 +04:00
2011-03-18 00:41:29 +03:00
# CPU model combo
2011-07-14 21:13:13 +04:00
cpu_model = self . widget ( " cpu-model " )
2010-12-17 03:36:07 +03:00
2014-01-31 22:40:09 +04:00
def sep_func ( model , it , ignore ) :
return model [ it ] [ 3 ]
# [label, sortkey, idstring, is sep]
model = Gtk . ListStore ( str , str , str , bool )
2010-12-17 03:36:07 +03:00
cpu_model . set_model ( model )
2012-05-14 17:24:56 +04:00
cpu_model . set_entry_text_column ( 0 )
2014-01-31 22:40:09 +04:00
cpu_model . set_row_separator_func ( sep_func , None )
2014-02-02 01:36:40 +04:00
model . set_sort_column_id ( 1 , Gtk . SortType . ASCENDING )
2018-10-04 21:19:32 +03:00
model . append ( [ _ ( " Application Default " ) , " 1 " ,
virtinst . DomainCpu . SPECIAL_MODE_APP_DEFAULT , False ] )
2014-02-05 22:51:53 +04:00
model . append ( [ _ ( " Hypervisor Default " ) , " 2 " ,
2018-03-20 22:10:04 +03:00
virtinst . DomainCpu . SPECIAL_MODE_HV_DEFAULT , False ] )
2014-02-05 22:51:53 +04:00
model . append ( [ _ ( " Clear CPU configuration " ) , " 3 " ,
2018-03-20 22:10:04 +03:00
virtinst . DomainCpu . SPECIAL_MODE_CLEAR , False ] )
2014-01-31 22:40:09 +04:00
model . append ( [ None , None , None , True ] )
2019-03-15 11:49:29 +03:00
for name in domcaps . get_cpu_models ( ) :
2014-01-31 22:40:09 +04:00
model . append ( [ name , name , name , False ] )
2010-12-17 03:36:07 +03:00
2010-05-20 16:34:32 +04:00
# Disk cache combo
2013-09-28 20:21:35 +04:00
disk_cache = self . widget ( " disk-cache " )
2014-01-27 02:09:07 +04:00
vmmAddHardware . build_disk_cache_combo ( self . vm , disk_cache )
2010-05-20 16:34:32 +04:00
2018-08-24 02:38:07 +03:00
# Discard combo
combo = self . widget ( " disk-discard " )
vmmAddHardware . build_disk_discard_combo ( self . vm , combo )
2018-08-24 02:40:18 +03:00
# Detect zeroes combo
combo = self . widget ( " disk-detect-zeroes " )
vmmAddHardware . build_disk_detect_zeroes_combo ( self . vm , combo )
2010-12-11 04:33:41 +03:00
# Disk bus combo
2013-09-28 20:21:35 +04:00
disk_bus = self . widget ( " disk-bus " )
2014-01-27 02:09:07 +04:00
vmmAddHardware . build_disk_bus_combo ( self . vm , disk_bus )
2020-01-26 00:04:12 +03:00
self . widget ( " disk-bus-label " ) . set_visible (
not self . is_customize_dialog )
self . widget ( " disk-bus " ) . set_visible ( self . is_customize_dialog )
if not self . is_customize_dialog :
# Remove the mnemonic
self . widget ( " disk-bus-labeller " ) . set_text ( _ ( " Disk bus: " ) )
2010-12-11 04:33:41 +03:00
2010-03-24 05:15:53 +03:00
# Network model
2013-09-28 20:21:35 +04:00
net_model = self . widget ( " network-model " )
2014-01-27 02:09:07 +04:00
vmmAddHardware . build_network_model_combo ( self . vm , net_model )
2010-03-24 05:15:53 +03:00
2015-04-08 01:52:35 +03:00
# Network mac
self . widget ( " network-mac-label " ) . set_visible (
not self . is_customize_dialog )
self . widget ( " network-mac-entry " ) . set_visible ( self . is_customize_dialog )
2010-03-24 05:15:53 +03:00
# Sound model
2013-09-28 20:21:35 +04:00
sound_dev = self . widget ( " sound-model " )
2015-05-19 23:44:08 +03:00
vmmAddHardware . build_sound_combo ( self . vm , sound_dev )
2010-03-24 05:15:53 +03:00
2009-11-05 22:59:11 +03:00
# Video model combo
2013-09-28 20:21:35 +04:00
video_dev = self . widget ( " video-model " )
2015-05-19 23:44:08 +03:00
vmmAddHardware . build_video_combo ( self . vm , video_dev )
2010-03-24 05:15:53 +03:00
2010-03-24 07:22:17 +03:00
# Watchdog model combo
2013-09-28 20:21:35 +04:00
combo = self . widget ( " watchdog-model " )
2015-05-19 23:44:08 +03:00
vmmAddHardware . build_watchdogmodel_combo ( self . vm , combo )
2010-03-24 07:22:17 +03:00
# Watchdog action combo
2013-09-28 20:21:35 +04:00
combo = self . widget ( " watchdog-action " )
2015-05-19 23:44:08 +03:00
vmmAddHardware . build_watchdogaction_combo ( self . vm , combo )
2010-03-24 07:22:17 +03:00
2011-06-23 19:42:03 +04:00
# Smartcard mode
2013-09-28 20:21:35 +04:00
sc_mode = self . widget ( " smartcard-mode " )
2014-01-27 02:09:07 +04:00
vmmAddHardware . build_smartcard_mode_combo ( self . vm , sc_mode )
2011-06-23 19:42:03 +04:00
2018-06-09 00:42:44 +03:00
# TPM model
tpm_model = self . widget ( " tpm-model " )
vmmAddHardware . build_tpm_model_combo ( self . vm , tpm_model , None )
2011-09-23 19:14:15 +04:00
# Controller model
2013-09-28 20:21:35 +04:00
combo = self . widget ( " controller-model " )
2012-05-14 17:24:56 +04:00
model = Gtk . ListStore ( str , str )
2011-09-23 19:14:15 +04:00
combo . set_model ( model )
2015-04-10 20:04:02 +03:00
uiutil . init_combo_text_column ( combo , 1 )
2011-09-23 19:14:15 +04:00
combo . set_active ( - 1 )
2017-11-23 12:32:48 +03:00
combo = self . widget ( " controller-device-list " )
model = Gtk . ListStore ( str )
combo . set_model ( model )
combo . set_headers_visible ( False )
col = Gtk . TreeViewColumn ( )
text = Gtk . CellRendererText ( )
col . pack_start ( text , True )
col . add_attribute ( text , ' text ' , 0 )
combo . append_column ( col )
2011-09-23 19:14:15 +04:00
2009-11-04 21:18:14 +03:00
##########################
# Window state listeners #
##########################
2006-09-01 19:18:49 +04:00
2020-08-27 21:36:48 +03:00
def _popup_addhw_menu_cb ( self , widget , event ) :
2010-02-12 22:01:59 +03:00
if event . button != 3 :
return
2014-04-26 18:45:50 +04:00
# force select the list entry before showing popup_menu
path_tuple = widget . get_path_at_pos ( int ( event . x ) , int ( event . y ) )
if path_tuple is None :
2020-08-27 01:01:02 +03:00
return False # pragma: no cover
2014-04-26 18:45:50 +04:00
path = path_tuple [ 0 ]
_iter = widget . get_model ( ) . get_iter ( path )
widget . get_selection ( ) . select_iter ( _iter )
2020-08-27 21:36:48 +03:00
rmdev = self . _popupmenuitems [ " remove " ]
2014-04-22 03:31:18 +04:00
rmdev . set_visible ( self . widget ( " config-remove " ) . get_visible ( ) )
rmdev . set_sensitive ( self . widget ( " config-remove " ) . get_sensitive ( ) )
2014-03-27 15:40:42 +04:00
2020-08-27 21:36:48 +03:00
self . _popupmenu . popup_at_pointer ( event )
2011-07-20 04:29:07 +04:00
2020-08-27 21:36:48 +03:00
def _set_hw_selection ( self , page , _disable_apply = True ) :
if _disable_apply :
self . _disable_apply ( )
2015-05-20 01:13:33 +03:00
uiutil . set_list_selection_by_number ( self . widget ( " hw-list " ) , page )
2010-11-24 22:19:44 +03:00
2020-08-27 21:36:48 +03:00
def _get_hw_row ( self ) :
2015-05-20 00:17:53 +03:00
return uiutil . get_list_selected_row ( self . widget ( " hw-list " ) )
2011-07-20 04:29:07 +04:00
2020-08-27 21:36:48 +03:00
def _has_unapplied_changes ( self , row ) :
2020-08-27 01:01:02 +03:00
"""
This is a bit confusing .
* If there are now changes pending , we return False
* If there are changes pending , we prompt the user whether
they want to apply them . If they say no , return False
* If the applying the changes succeeds , return False
* Return True if applying the changes failed . In this
case the caller should attempt to abort the action they
are trying to perform , if possible
"""
2011-07-20 04:29:07 +04:00
if not row :
return False
2012-11-09 15:13:22 +04:00
if not self . widget ( " config-apply " ) . get_sensitive ( ) :
2011-07-20 04:29:07 +04:00
return False
2019-04-14 23:19:56 +03:00
if not self . err . confirm_unapplied_changes ( ) :
2011-07-20 04:29:07 +04:00
return False
2020-08-27 21:36:48 +03:00
return not self . _config_apply ( row = row )
2011-07-20 04:29:07 +04:00
2020-08-27 21:36:48 +03:00
def _hw_changed_cb ( self , src ) :
"""
When user changes the hw - list selection
"""
newrow = self . _get_hw_row ( )
2011-07-20 04:29:07 +04:00
model = self . widget ( " hw-list " ) . get_model ( )
2020-08-27 21:36:48 +03:00
if not newrow or newrow [ HW_LIST_COL_KEY ] == self . _oldhwkey :
2011-07-20 04:29:07 +04:00
return
2013-04-17 03:17:47 +04:00
oldhwrow = None
for row in model :
2020-08-27 21:36:48 +03:00
if row [ HW_LIST_COL_KEY ] == self . _oldhwkey :
2013-04-17 03:17:47 +04:00
oldhwrow = row
break
2020-08-27 21:36:48 +03:00
if self . _has_unapplied_changes ( oldhwrow ) :
2011-07-20 04:29:07 +04:00
# Unapplied changes, and syncing them failed
pageidx = 0
2016-04-18 23:42:12 +03:00
for idx , row in enumerate ( model ) :
2020-08-27 21:36:48 +03:00
if row [ HW_LIST_COL_KEY ] == self . _oldhwkey :
2011-07-20 04:29:07 +04:00
pageidx = idx
break
2020-08-27 21:36:48 +03:00
self . _set_hw_selection ( pageidx , _disable_apply = False )
2011-07-20 04:29:07 +04:00
else :
2020-08-27 21:36:48 +03:00
self . _oldhwkey = newrow [ HW_LIST_COL_KEY ]
self . _refresh_page ( )
2011-07-20 04:29:07 +04:00
2018-07-31 17:47:18 +03:00
def _disable_device_remove ( self , tooltip ) :
self . widget ( " config-remove " ) . set_sensitive ( False )
self . widget ( " config-remove " ) . set_tooltip_text ( tooltip )
2010-02-10 19:54:12 +03:00
2020-08-27 21:36:48 +03:00
#######################
# vmwindow Public API #
#######################
2007-04-12 23:36:04 +04:00
2020-08-27 21:36:48 +03:00
def vmwindow_resources_refreshed ( self ) :
if self . _get_hw_row ( ) [ HW_LIST_COL_TYPE ] == HW_LIST_TYPE_STATS :
self . _refresh_stats_page ( )
2018-09-06 02:17:04 +03:00
2020-08-27 21:36:48 +03:00
def vmwindow_page_refresh ( self ) :
self . _repopulate_hw_list ( )
2009-03-01 03:27:20 +03:00
2020-08-27 21:36:48 +03:00
pagetype = self . _get_hw_row ( ) [ HW_LIST_COL_TYPE ]
if pagetype is None :
2020-08-27 23:37:15 +03:00
return # pragma: no cover
2009-07-09 22:35:36 +04:00
2020-08-27 21:36:48 +03:00
if self . widget ( " config-apply " ) . get_sensitive ( ) :
# Apply button sensitive means user is making changes, don't
# erase them
return
self . _refresh_page ( pagetype = pagetype )
def vmwindow_activate_performance_page ( self ) :
index = 0
model = self . widget ( " hw-list " ) . get_model ( )
for idx , row in enumerate ( model ) :
if row [ HW_LIST_COL_TYPE ] == HW_LIST_TYPE_STATS :
index = idx
break
self . _set_hw_selection ( index )
def vmwindow_has_unapplied_changes ( self ) :
return self . _has_unapplied_changes ( self . _get_hw_row ( ) )
2006-06-14 18:59:40 +04:00
2019-05-05 23:25:35 +03:00
def vmwindow_refresh_vm_state ( self ) :
active = self . vm . is_active ( )
2011-07-14 21:13:13 +04:00
self . widget ( " overview-name " ) . set_editable ( not active )
2011-03-23 23:56:12 +03:00
2014-03-18 18:13:57 +04:00
reason = self . vm . run_status_reason ( )
if reason :
status = " %s ( %s ) " % ( self . vm . run_status ( ) , reason )
else :
status = self . vm . run_status ( )
self . widget ( " overview-status-text " ) . set_text ( status )
2011-07-14 21:13:13 +04:00
self . widget ( " overview-status-icon " ) . set_from_icon_name (
2019-05-05 23:25:35 +03:00
self . vm . run_status_icon_name ( ) ,
Gtk . IconSize . BUTTON )
2013-10-01 04:33:42 +04:00
2020-08-27 21:36:48 +03:00
def vmwindow_show_details ( self ) :
# When vmwindow switches to use, refresh the current page
self . _refresh_page ( )
2009-11-04 21:18:14 +03:00
2020-08-27 21:36:48 +03:00
##############################
# Add/remove device handling #
##############################
2019-05-06 02:00:40 +03:00
2020-08-27 21:36:48 +03:00
def _show_addhw ( self ) :
2011-03-23 17:06:59 +03:00
try :
if self . addhw is None :
2019-05-08 23:50:08 +03:00
self . addhw = vmmAddHardware ( self . vm )
2009-11-04 21:18:14 +03:00
2011-04-14 16:47:42 +04:00
self . addhw . show ( self . topwin )
2020-08-25 15:47:11 +03:00
except Exception as e : # pragma: no cover
2011-03-23 17:06:59 +03:00
self . err . show_err ( ( _ ( " Error launching hardware dialog: %s " ) %
2011-04-06 19:22:03 +04:00
str ( e ) ) )
2020-08-27 01:01:02 +03:00
def _remove_non_disk ( self , devobj ) :
2019-12-19 12:35:08 +03:00
if not self . err . chkbox_helper ( self . config . get_confirm_removedev ,
self . config . set_confirm_removedev ,
text1 = ( _ ( " Are you sure you want to remove this device? " ) ) ) :
return
2009-11-04 21:18:14 +03:00
2020-08-27 01:01:02 +03:00
success = vmmDeleteStorage . remove_devobj_internal (
self . vm , self . err , devobj )
if not success :
return
2020-08-27 23:37:15 +03:00
# This call here means when the vm config changes and triggers
# refresh event, the UI page will be updated, rather than leaving
# it untouched because it thinks changes are in progress
2020-08-27 21:36:48 +03:00
self . _disable_apply ( )
2020-08-27 01:01:02 +03:00
def _remove_disk ( self , disk ) :
2020-01-02 11:03:04 +03:00
dialog = vmmDeleteStorage ( disk )
2019-12-18 11:39:57 +03:00
dialog . show ( self . topwin , self . vm )
2019-12-18 10:48:49 +03:00
2020-08-27 21:36:48 +03:00
def _config_remove ( self ) :
devobj = self . _get_hw_row ( ) [ HW_LIST_COL_DEVICE ]
2019-12-18 10:48:49 +03:00
if devobj . DEVICE_TYPE == " disk " :
2020-08-27 01:01:02 +03:00
self . _remove_disk ( devobj )
2019-12-18 10:48:49 +03:00
else :
2020-08-27 01:01:02 +03:00
self . _remove_non_disk ( devobj )
2009-11-04 21:18:14 +03:00
2008-08-19 22:25:25 +04:00
2010-02-25 04:37:41 +03:00
############################
# Details/Hardware getters #
############################
2020-08-27 21:36:48 +03:00
def _get_config_boot_order ( self ) :
2015-09-14 01:01:39 +03:00
boot_model = self . widget ( " boot-list " ) . get_model ( )
2010-02-25 04:37:41 +03:00
devs = [ ]
for row in boot_model :
if row [ BOOT_ACTIVE ] :
2014-02-10 01:21:26 +04:00
devs . append ( row [ BOOT_KEY ] )
2010-02-25 04:37:41 +03:00
return devs
2009-03-01 03:27:20 +03:00
2020-08-27 21:36:48 +03:00
def _get_config_boot_selection ( self ) :
return uiutil . get_list_selected_row ( self . widget ( " boot-list " ) )
def _get_config_cpu_model ( self ) :
2011-07-14 21:13:13 +04:00
cpu_list = self . widget ( " cpu-model " )
2014-01-31 22:40:09 +04:00
text = cpu_list . get_child ( ) . get_text ( )
2014-02-05 22:51:53 +04:00
if self . widget ( " cpu-copy-host " ) . get_active ( ) :
2018-03-20 22:10:04 +03:00
return virtinst . DomainCpu . SPECIAL_MODE_HOST_MODEL
2014-02-05 22:51:53 +04:00
key = None
for row in cpu_list . get_model ( ) :
if text == row [ 0 ] :
key = row [ 2 ]
2014-01-31 22:40:09 +04:00
break
2014-02-05 22:51:53 +04:00
if not key :
return text
2010-12-17 03:36:07 +03:00
2018-10-04 21:19:32 +03:00
if key == virtinst . DomainCpu . SPECIAL_MODE_APP_DEFAULT :
return self . config . get_default_cpu_setting ( )
2014-02-05 22:51:53 +04:00
return key
2010-12-17 03:36:07 +03:00
2020-08-27 21:36:48 +03:00
def _get_config_vcpus ( self ) :
return uiutil . spin_get_helper ( self . widget ( " cpu-vcpus " ) )
2017-02-23 13:22:27 +03:00
2020-08-27 21:36:48 +03:00
def _get_text ( self , widgetname , strip = True , checksens = False ) :
"""
Helper for reading widget text with a few options
"""
widget = self . widget ( widgetname )
if ( checksens and
( not widget . is_sensitive ( ) or not widget . is_visible ( ) ) ) :
return " "
ret = widget . get_text ( )
if strip :
ret = ret . strip ( )
return ret
2018-09-29 23:04:05 +03:00
2010-12-17 03:36:07 +03:00
2009-11-04 21:18:14 +03:00
##############################
# Details/Hardware listeners #
##############################
2011-01-13 21:32:19 +03:00
2020-08-25 15:47:11 +03:00
def _browse_file ( self , callback , reason = None ) :
2018-10-06 21:26:31 +03:00
if not reason :
2010-12-12 07:00:19 +03:00
reason = self . config . CONFIG_DIR_IMAGE
2012-11-08 17:15:02 +04:00
if self . storage_browser is None :
2010-12-12 07:00:19 +03:00
self . storage_browser = vmmStorageBrowser ( self . conn )
self . storage_browser . set_finish_cb ( callback )
self . storage_browser . set_browse_reason ( reason )
2015-04-09 01:29:48 +03:00
self . storage_browser . show ( self . topwin )
2010-12-12 07:00:19 +03:00
2020-08-27 21:36:48 +03:00
def _inspection_refresh_clicked_cb ( self , src ) :
from . . lib . inspection import vmmInspection
inspection = vmmInspection . get_instance ( )
if inspection :
inspection . vm_refresh ( self . vm )
2010-06-21 21:32:59 +04:00
2020-08-27 21:36:48 +03:00
def _os_list_name_selected_cb ( self , src , osobj ) :
self . _enable_apply ( EDIT_OS_NAME )
2011-01-13 21:32:19 +03:00
2020-01-25 23:11:02 +03:00
def _config_vcpus_changed_cb ( self , src ) :
2020-08-27 21:36:48 +03:00
self . _enable_apply ( EDIT_VCPUS )
2011-01-13 21:32:19 +03:00
2011-07-23 00:43:26 +04:00
conn = self . vm . conn
2010-05-13 20:55:08 +04:00
host_active_count = conn . host_active_processor_count ( )
2020-08-27 21:36:48 +03:00
cur = self . _get_config_vcpus ( )
2010-05-13 20:55:08 +04:00
# Warn about overcommit
2011-01-13 21:32:19 +03:00
warn = bool ( cur > host_active_count )
2015-09-14 01:01:39 +03:00
self . widget ( " cpu-vcpus-warn-box " ) . set_visible ( warn )
2010-05-13 20:55:08 +04:00
2020-08-27 21:36:48 +03:00
def _cpu_copy_host_clicked_cb ( self , src ) :
2014-01-31 22:40:09 +04:00
uiutil . set_grid_row_visible (
self . widget ( " cpu-model " ) , not src . get_active ( ) )
2019-04-03 16:23:20 +03:00
uiutil . set_grid_row_visible (
self . widget ( " cpu-secure " ) , not src . get_active ( ) )
2020-08-27 21:36:48 +03:00
self . _enable_apply ( EDIT_CPU )
2013-12-03 06:46:47 +04:00
2020-08-27 21:36:48 +03:00
def _sync_cpu_topology_ui ( self ) :
2014-02-01 18:14:55 +04:00
manual_top = self . widget ( " cpu-topology-table " ) . is_sensitive ( )
2020-01-25 23:11:02 +03:00
self . widget ( " cpu-vcpus " ) . set_sensitive ( not manual_top )
2014-02-01 18:14:55 +04:00
if manual_top :
cores = uiutil . spin_get_helper ( self . widget ( " cpu-cores " ) ) or 1
sockets = uiutil . spin_get_helper ( self . widget ( " cpu-sockets " ) ) or 1
threads = uiutil . spin_get_helper ( self . widget ( " cpu-threads " ) ) or 1
total = cores * sockets * threads
2015-09-14 01:01:39 +03:00
if uiutil . spin_get_helper ( self . widget ( " cpu-vcpus " ) ) > total :
self . widget ( " cpu-vcpus " ) . set_value ( total )
2020-01-25 23:11:02 +03:00
self . widget ( " cpu-vcpus " ) . set_value ( total )
2014-02-01 18:14:55 +04:00
else :
2020-01-25 23:11:02 +03:00
vcpus = uiutil . spin_get_helper ( self . widget ( " cpu-vcpus " ) )
self . widget ( " cpu-sockets " ) . set_value ( vcpus or 1 )
2014-02-01 18:14:55 +04:00
self . widget ( " cpu-cores " ) . set_value ( 1 )
self . widget ( " cpu-threads " ) . set_value ( 1 )
2020-08-27 21:36:48 +03:00
self . _enable_apply ( EDIT_TOPOLOGY )
2014-02-01 18:14:55 +04:00
2020-08-27 21:36:48 +03:00
def _cpu_topology_enable_cb ( self , src ) :
2010-12-17 00:05:55 +03:00
do_enable = src . get_active ( )
2011-07-14 21:13:13 +04:00
self . widget ( " cpu-topology-table " ) . set_sensitive ( do_enable )
2020-08-27 21:36:48 +03:00
self . _sync_cpu_topology_ui ( )
2010-12-17 00:05:55 +03:00
2020-08-27 21:36:48 +03:00
def _cpu_topology_changed_cb ( self , src ) :
self . _sync_cpu_topology_ui ( )
def _video_model_changed_cb ( self , src ) :
2017-02-21 16:01:02 +03:00
model = uiutil . get_list_selection ( self . widget ( " video-model " ) )
uiutil . set_grid_row_visible (
self . widget ( " video-3d " ) , model == " virtio " )
2020-08-27 21:36:48 +03:00
self . _enable_apply ( EDIT_VIDEO_MODEL )
2017-02-21 16:01:02 +03:00
2020-08-27 21:36:48 +03:00
def _video_3d_toggled_cb ( self , src ) :
2017-02-21 16:01:02 +03:00
self . widget ( " video-3d " ) . set_inconsistent ( False )
2020-08-27 21:36:48 +03:00
self . _enable_apply ( EDIT_VIDEO_3D )
2017-02-21 16:01:02 +03:00
2020-08-27 21:36:48 +03:00
def _config_bootdev_selected ( self ) :
boot_row = self . _get_config_boot_selection ( )
2014-02-10 01:21:26 +04:00
boot_selection = boot_row and boot_row [ BOOT_KEY ]
2020-08-27 21:36:48 +03:00
boot_devs = self . _get_config_boot_order ( )
2015-09-14 01:01:39 +03:00
up_widget = self . widget ( " boot-moveup " )
down_widget = self . widget ( " boot-movedown " )
2010-02-25 04:37:41 +03:00
down_widget . set_sensitive ( bool ( boot_devs and
boot_selection and
boot_selection in boot_devs and
boot_selection != boot_devs [ - 1 ] ) )
up_widget . set_sensitive ( bool ( boot_devs and boot_selection and
boot_selection in boot_devs and
boot_selection != boot_devs [ 0 ] ) )
2020-08-27 21:36:48 +03:00
def _config_boot_toggled_cb ( self , src , index ) :
2015-09-14 01:01:39 +03:00
model = self . widget ( " boot-list " ) . get_model ( )
2014-02-10 01:21:26 +04:00
row = model [ index ]
2010-02-25 04:37:41 +03:00
2014-02-10 01:21:26 +04:00
row [ BOOT_ACTIVE ] = not row [ BOOT_ACTIVE ]
2020-08-27 21:36:48 +03:00
self . _config_bootdev_selected ( )
self . _enable_apply ( EDIT_BOOTORDER )
2010-02-25 04:37:41 +03:00
2020-08-27 21:36:48 +03:00
def _config_boot_move ( self , move_up ) :
row = self . _get_config_boot_selection ( )
2014-02-10 01:21:26 +04:00
if not row :
2020-08-27 01:01:02 +03:00
return # pragma: no cover
2010-02-25 04:37:41 +03:00
2014-02-10 01:21:26 +04:00
row_key = row [ BOOT_KEY ]
2020-08-27 21:36:48 +03:00
boot_order = self . _get_config_boot_order ( )
2014-02-10 01:21:26 +04:00
key_idx = boot_order . index ( row_key )
2010-02-25 04:37:41 +03:00
if move_up :
2014-02-10 01:21:26 +04:00
new_idx = key_idx - 1
2010-02-25 04:37:41 +03:00
else :
2014-02-10 01:21:26 +04:00
new_idx = key_idx + 1
2010-02-25 04:37:41 +03:00
2014-02-10 01:21:26 +04:00
if new_idx < 0 or new_idx > = len ( boot_order ) :
# Somehow we went out of bounds
2020-08-27 23:37:15 +03:00
return # pragma: no cover
2010-02-25 04:37:41 +03:00
2015-09-14 01:01:39 +03:00
boot_list = self . widget ( " boot-list " )
2014-02-10 01:21:26 +04:00
model = boot_list . get_model ( )
prev_row = None
for row in model :
2016-04-18 23:42:12 +03:00
# pylint: disable=unsubscriptable-object
2014-02-10 01:21:26 +04:00
if prev_row and prev_row [ BOOT_KEY ] == row_key :
model . swap ( prev_row . iter , row . iter )
break
if row [ BOOT_KEY ] == row_key and prev_row and move_up :
model . swap ( prev_row . iter , row . iter )
break
2010-02-25 04:37:41 +03:00
2014-02-10 01:21:26 +04:00
prev_row = row
boot_list . get_selection ( ) . emit ( " changed " )
2020-08-27 21:36:48 +03:00
self . _enable_apply ( EDIT_BOOTORDER )
2018-10-06 21:26:31 +03:00
def _disk_source_browse_clicked_cb ( self , src ) :
2020-08-27 21:36:48 +03:00
disk = self . _get_hw_row ( ) [ HW_LIST_COL_DEVICE ]
2018-10-06 21:26:31 +03:00
if disk . is_floppy ( ) :
reason = self . config . CONFIG_DIR_FLOPPY_MEDIA
else :
reason = self . config . CONFIG_DIR_ISO_MEDIA
def cb ( ignore , path ) :
self . _mediacombo . set_path ( path )
self . _browse_file ( cb , reason = reason )
2015-05-19 20:57:53 +03:00
2018-09-06 21:04:00 +03:00
def _set_network_ip_details ( self , net ) :
2020-08-27 23:29:10 +03:00
ipv4 , ipv6 = self . vm . get_ips ( net )
2018-09-06 21:04:00 +03:00
label = ipv4 or " "
if ipv6 :
if label :
label + = " \n "
label + = ipv6
self . widget ( " network-ip " ) . set_text ( label or _ ( " Unknown " ) )
2020-08-27 21:36:48 +03:00
def _refresh_ip ( self ) :
net = self . _get_hw_row ( ) [ HW_LIST_COL_DEVICE ]
2020-08-27 23:29:10 +03:00
self . vm . refresh_ips ( net )
2018-09-06 21:04:00 +03:00
self . _set_network_ip_details ( net )
2018-08-31 13:37:30 +03:00
2009-11-04 21:18:14 +03:00
##################################################
# Details/Hardware config changes (apply button) #
##################################################
2009-07-07 20:16:03 +04:00
2020-08-27 21:36:48 +03:00
def _disable_apply ( self ) :
self . _active_edits = [ ]
self . widget ( " config-apply " ) . set_sensitive ( False )
self . widget ( " config-cancel " ) . set_sensitive ( False )
self . _xmleditor . details_changed = False
def _enable_apply ( self , edittype ) :
self . widget ( " config-apply " ) . set_sensitive ( True )
self . widget ( " config-cancel " ) . set_sensitive ( True )
if edittype not in self . _active_edits :
self . _active_edits . append ( edittype )
if edittype != EDIT_XML :
self . _xmleditor . details_changed = True
def _config_cancel ( self , ignore = None ) :
2019-03-18 19:48:40 +03:00
# Remove current changes and deactivate 'apply' button
2020-08-27 21:36:48 +03:00
self . _refresh_page ( )
2011-07-19 22:51:16 +04:00
2020-08-27 21:36:48 +03:00
def _config_apply ( self , row = None ) :
2011-07-20 04:29:07 +04:00
pagetype = None
2019-05-08 19:29:00 +03:00
dev = None
2011-07-20 04:29:07 +04:00
if not row :
2020-08-27 21:36:48 +03:00
row = self . _get_hw_row ( )
2011-07-20 04:29:07 +04:00
if row :
pagetype = row [ HW_LIST_COL_TYPE ]
2019-05-08 19:29:00 +03:00
dev = row [ HW_LIST_COL_DEVICE ]
2009-11-04 21:18:14 +03:00
2019-05-08 19:29:00 +03:00
success = False
2011-06-01 19:17:19 +04:00
try :
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_XML ) :
2019-05-06 02:00:40 +03:00
if dev :
2020-08-27 21:36:48 +03:00
success = self . _apply_device_xml ( dev )
2019-05-06 02:00:40 +03:00
else :
2020-08-27 21:36:48 +03:00
success = self . _apply_domain_xml ( )
2019-05-06 02:00:40 +03:00
elif pagetype is HW_LIST_TYPE_GENERAL :
2020-08-27 21:36:48 +03:00
success = self . _apply_overview ( )
2018-09-29 23:04:05 +03:00
elif pagetype is HW_LIST_TYPE_OS :
2020-08-27 21:36:48 +03:00
success = self . _apply_os ( )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_CPU :
2020-08-27 21:36:48 +03:00
success = self . _apply_vcpus ( )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_MEMORY :
2020-08-27 21:36:48 +03:00
success = self . _apply_memory ( )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_BOOT :
2020-08-27 21:36:48 +03:00
success = self . _apply_boot_options ( )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_DISK :
2020-08-27 21:36:48 +03:00
success = self . _apply_disk ( dev )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_NIC :
2020-08-27 21:36:48 +03:00
success = self . _apply_network ( dev )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_GRAPHICS :
2020-08-27 21:36:48 +03:00
success = self . _apply_graphics ( dev )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_SOUND :
2020-08-27 21:36:48 +03:00
success = self . _apply_sound ( dev )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_VIDEO :
2020-08-27 21:36:48 +03:00
success = self . _apply_video ( dev )
2011-06-01 19:17:19 +04:00
elif pagetype is HW_LIST_TYPE_WATCHDOG :
2020-08-27 21:36:48 +03:00
success = self . _apply_watchdog ( dev )
2011-06-23 19:42:03 +04:00
elif pagetype is HW_LIST_TYPE_SMARTCARD :
2020-08-27 21:36:48 +03:00
success = self . _apply_smartcard ( dev )
2011-09-23 19:14:15 +04:00
elif pagetype is HW_LIST_TYPE_CONTROLLER :
2020-08-27 21:36:48 +03:00
success = self . _apply_controller ( dev )
2014-01-21 13:05:31 +04:00
elif pagetype is HW_LIST_TYPE_FILESYSTEM :
2020-08-27 21:36:48 +03:00
success = self . _apply_filesystem ( dev )
2014-02-10 23:24:22 +04:00
elif pagetype is HW_LIST_TYPE_HOSTDEV :
2020-08-27 21:36:48 +03:00
success = self . _apply_hostdev ( dev )
2018-06-09 00:42:44 +03:00
elif pagetype is HW_LIST_TYPE_TPM :
2020-08-27 21:36:48 +03:00
success = self . _apply_tpm ( dev )
2018-12-14 17:34:19 +03:00
elif pagetype is HW_LIST_TYPE_VSOCK :
2020-08-27 21:36:48 +03:00
success = self . _apply_vsock ( dev )
2017-05-05 19:47:21 +03:00
except Exception as e :
2020-08-27 20:01:01 +03:00
self . err . show_err ( _ ( " Error applying changes: %s " ) % e )
2009-07-07 20:16:03 +04:00
2019-05-08 19:29:00 +03:00
if success is not False :
2020-08-27 21:36:48 +03:00
self . _disable_apply ( )
2020-08-27 20:01:01 +03:00
success = True
return success
2009-07-07 20:16:03 +04:00
2020-08-27 21:36:48 +03:00
def _edited ( self , pagetype ) :
return pagetype in self . _active_edits
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
def _apply_domain_xml ( self ) :
2019-05-06 02:00:40 +03:00
newxml = self . _xmleditor . get_xml ( )
def change_cb ( ) :
return self . vm . define_xml ( newxml )
return vmmAddHardware . change_config_helper (
change_cb , { } , self . vm , self . err )
2020-08-27 21:36:48 +03:00
def _apply_device_xml ( self , devobj ) :
2019-05-06 02:00:40 +03:00
newxml = self . _xmleditor . get_xml ( )
def change_cb ( ) :
return self . vm . replace_device_xml ( devobj , newxml )
return vmmAddHardware . change_config_helper (
change_cb , { } , self . vm , self . err )
2020-08-27 21:36:48 +03:00
def _apply_overview ( self ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
hotplug_args = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_TITLE ) :
2014-03-22 22:34:23 +04:00
kwargs [ " title " ] = self . widget ( " overview-title " ) . get_text ( )
hotplug_args [ " title " ] = kwargs [ " title " ]
2013-09-24 15:02:27 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_FIRMWARE ) :
2014-09-18 01:25:03 +04:00
kwargs [ " loader " ] = uiutil . get_list_selection (
2015-05-20 00:17:53 +03:00
self . widget ( " overview-firmware " ) , column = 1 )
2014-09-18 01:25:03 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_MACHTYPE ) :
2014-06-01 04:13:08 +04:00
if self . widget ( " overview-chipset " ) . is_visible ( ) :
kwargs [ " machine " ] = uiutil . get_list_selection (
2015-05-20 00:17:53 +03:00
self . widget ( " overview-chipset " ) , column = 1 )
2014-06-01 04:13:08 +04:00
else :
2015-05-20 00:54:53 +03:00
kwargs [ " machine " ] = uiutil . get_list_selection (
2014-06-01 04:13:08 +04:00
self . widget ( " machine-type " ) )
2012-01-05 13:35:40 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DESC ) :
2011-07-15 00:18:42 +04:00
desc_widget = self . widget ( " overview-description " )
2014-03-22 22:34:23 +04:00
kwargs [ " description " ] = (
desc_widget . get_buffer ( ) . get_property ( " text " ) or " " )
hotplug_args [ " description " ] = kwargs [ " description " ]
2012-10-14 22:55:24 +04:00
2014-09-21 00:18:10 +04:00
# This needs to be last
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_NAME ) :
2014-09-21 00:18:10 +04:00
# Renaming is pretty convoluted, so do it here synchronously
2017-03-06 11:43:10 +03:00
self . vm . rename_domain ( self . widget ( " overview-name " ) . get_text ( ) )
2014-09-21 00:18:10 +04:00
if not kwargs and not hotplug_args :
# Saves some useless redefine attempts
return
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_overview ,
kwargs , self . vm , self . err ,
2014-03-22 22:34:23 +04:00
hotplug_args = hotplug_args )
2014-02-21 14:13:11 +04:00
2020-08-27 21:36:48 +03:00
def _apply_os ( self ) :
2018-09-29 23:04:05 +03:00
kwargs = { }
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_OS_NAME ) :
2018-09-29 23:04:05 +03:00
osobj = self . _os_list . get_selected_os ( )
kwargs [ " os_name " ] = osobj and osobj . name or " generic "
return vmmAddHardware . change_config_helper ( self . vm . define_os ,
kwargs , self . vm , self . err )
2020-08-27 21:36:48 +03:00
def _apply_vcpus ( self ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_VCPUS ) :
kwargs [ " vcpus " ] = self . _get_config_vcpus ( )
2014-06-17 16:13:30 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_CPU ) :
kwargs [ " model " ] = self . _get_config_cpu_model ( )
2019-04-03 16:23:20 +03:00
kwargs [ " secure " ] = self . widget ( " cpu-secure " ) . get_active ( )
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_TOPOLOGY ) :
2011-07-15 00:18:42 +04:00
do_top = self . widget ( " cpu-topology-enable " ) . get_active ( )
2020-08-28 01:05:48 +03:00
kwargs [ " clear_topology " ] = not do_top
2014-03-22 22:34:23 +04:00
kwargs [ " sockets " ] = self . widget ( " cpu-sockets " ) . get_value ( )
kwargs [ " cores " ] = self . widget ( " cpu-cores " ) . get_value ( )
kwargs [ " threads " ] = self . widget ( " cpu-threads " ) . get_value ( )
2011-07-15 00:18:42 +04:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_cpu ,
2020-01-25 23:11:02 +03:00
kwargs , self . vm , self . err )
2006-06-14 18:59:40 +04:00
2020-08-27 21:36:48 +03:00
def _apply_memory ( self ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_MEM ) :
2020-01-25 23:25:16 +03:00
memory = uiutil . spin_get_helper ( self . widget ( " mem-memory " ) )
kwargs [ " memory " ] = int ( memory ) * 1024
2009-11-04 21:18:14 +03:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_memory ,
2020-01-25 23:25:16 +03:00
kwargs , self . vm , self . err )
2009-11-04 21:18:14 +03:00
2020-08-27 21:36:48 +03:00
def _apply_boot_options ( self ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2009-11-04 21:23:22 +03:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_AUTOSTART ) :
2015-09-14 01:01:39 +03:00
auto = self . widget ( " boot-autostart " )
2009-11-04 21:18:14 +03:00
try :
self . vm . set_autostart ( auto . get_active ( ) )
2020-08-25 15:47:11 +03:00
except Exception as e : # pragma: no cover
2011-07-15 00:18:42 +04:00
self . err . show_err (
( _ ( " Error changing autostart value: %s " ) % str ( e ) ) )
2009-11-04 21:18:14 +03:00
return False
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_BOOTORDER ) :
kwargs [ " boot_order " ] = self . _get_config_boot_order ( )
2010-12-12 07:00:19 +03:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_BOOTMENU ) :
2014-03-22 22:34:23 +04:00
kwargs [ " boot_menu " ] = self . widget ( " boot-menu " ) . get_active ( )
2010-12-12 07:00:19 +03:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_KERNEL ) :
kwargs [ " kernel " ] = self . _get_text ( " boot-kernel " , checksens = True )
kwargs [ " initrd " ] = self . _get_text ( " boot-initrd " , checksens = True )
kwargs [ " dtb " ] = self . _get_text ( " boot-dtb " , checksens = True )
kwargs [ " kernel_args " ] = self . _get_text ( " boot-kernel-args " ,
2014-03-22 22:34:23 +04:00
checksens = True )
2011-07-15 00:31:38 +04:00
2014-03-22 22:34:23 +04:00
if kwargs [ " initrd " ] and not kwargs [ " kernel " ] :
2020-08-23 21:15:17 +03:00
msg = _ ( " Cannot set initrd without specifying a kernel path " )
return self . err . val_err ( msg )
2014-03-22 22:34:23 +04:00
if kwargs [ " kernel_args " ] and not kwargs [ " kernel " ] :
2020-08-23 21:15:17 +03:00
msg = _ ( " Cannot set kernel arguments without specifying a kernel path " )
return self . err . val_err ( msg )
2011-07-15 00:31:38 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_INIT ) :
kwargs [ " init " ] = self . _get_text ( " boot-init-path " )
kwargs [ " initargs " ] = self . _get_text ( " boot-init-args " ) or " "
2014-03-22 22:34:23 +04:00
if not kwargs [ " init " ] :
2011-05-26 20:38:48 +04:00
return self . err . val_err ( _ ( " An init path must be specified " ) )
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_boot ,
kwargs , self . vm , self . err )
2009-11-04 21:23:22 +03:00
2015-05-19 20:57:53 +03:00
2020-08-27 21:36:48 +03:00
def _apply_disk ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DISK_PATH ) :
2018-10-06 21:26:31 +03:00
path = self . _mediacombo . get_path ( )
names = virtinst . DeviceDisk . path_in_use_by ( devobj . conn , path )
if names :
2020-07-12 00:31:40 +03:00
msg = ( _ ( " Disk ' %(path)s ' is already in use by other "
" guests %(names)s " ) %
{ " path " : path , " names " : names } )
res = self . err . yes_no ( msg ,
2018-10-06 21:26:31 +03:00
_ ( " Do you really want to use the disk? " ) )
if not res :
return False
vmmAddStorage . check_path_search ( self , self . conn , path )
kwargs [ " path " ] = path or None
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DISK_RO ) :
2014-03-22 22:34:23 +04:00
kwargs [ " readonly " ] = self . widget ( " disk-readonly " ) . get_active ( )
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DISK_SHARE ) :
2014-03-22 22:34:23 +04:00
kwargs [ " shareable " ] = self . widget ( " disk-shareable " ) . get_active ( )
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DISK_REMOVABLE ) :
2014-06-24 15:59:12 +04:00
kwargs [ " removable " ] = bool (
2014-03-22 22:34:23 +04:00
self . widget ( " disk-removable " ) . get_active ( ) )
2013-10-04 05:39:01 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DISK_CACHE ) :
2015-05-20 00:54:53 +03:00
kwargs [ " cache " ] = uiutil . get_list_selection (
self . widget ( " disk-cache " ) )
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DISK_DISCARD ) :
2018-08-24 02:38:07 +03:00
kwargs [ " discard " ] = uiutil . get_list_selection (
self . widget ( " disk-discard " ) )
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DISK_DETECT_ZEROES ) :
2018-08-24 02:40:18 +03:00
kwargs [ " detect_zeroes " ] = uiutil . get_list_selection (
self . widget ( " disk-detect-zeroes " ) )
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_DISK_BUS ) :
2020-01-25 21:36:17 +03:00
kwargs [ " bus " ] = uiutil . get_list_selection (
self . widget ( " disk-bus " ) )
2009-11-05 00:30:51 +03:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_disk ,
kwargs , self . vm , self . err ,
2014-03-22 22:34:23 +04:00
devobj = devobj )
2020-08-27 21:36:48 +03:00
def _apply_sound ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_SOUND_MODEL ) :
2015-05-20 00:54:53 +03:00
model = uiutil . get_list_selection ( self . widget ( " sound-model " ) )
2011-07-15 00:18:42 +04:00
if model :
2014-03-22 22:34:23 +04:00
kwargs [ " model " ] = model
2011-07-15 00:18:42 +04:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_sound ,
kwargs , self . vm , self . err ,
2014-03-22 22:34:23 +04:00
devobj = devobj )
2009-11-05 00:30:51 +03:00
2020-08-27 21:36:48 +03:00
def _apply_smartcard ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_SMARTCARD_MODE ) :
2015-05-20 00:54:53 +03:00
model = uiutil . get_list_selection ( self . widget ( " smartcard-mode " ) )
2011-07-15 00:18:42 +04:00
if model :
2014-03-22 22:34:23 +04:00
kwargs [ " model " ] = model
2011-07-15 00:18:42 +04:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_smartcard ,
kwargs , self . vm , self . err ,
2014-03-22 22:34:23 +04:00
devobj = devobj )
2011-06-23 19:42:03 +04:00
2020-08-27 21:36:48 +03:00
def _apply_network ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_NET_MODEL ) :
2015-05-20 00:54:53 +03:00
model = uiutil . get_list_selection ( self . widget ( " network-model " ) )
2014-03-22 22:34:23 +04:00
kwargs [ " model " ] = model
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_NET_SOURCE ) :
2020-01-26 01:57:28 +03:00
( kwargs [ " ntype " ] , kwargs [ " source " ] , kwargs [ " mode " ] ) = (
2014-03-22 22:34:23 +04:00
self . netlist . get_network_selection ( ) )
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_NET_MAC ) :
2015-04-08 01:52:35 +03:00
kwargs [ " macaddr " ] = self . widget ( " network-mac-entry " ) . get_text ( )
2020-07-06 01:56:36 +03:00
virtinst . DeviceInterface . check_mac_in_use (
2019-06-15 04:11:37 +03:00
self . conn . get_backend ( ) , kwargs [ " macaddr " ] )
2015-04-08 01:52:35 +03:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_NET_LINKSTATE ) :
2018-08-16 18:30:31 +03:00
kwargs [ " linkstate " ] = self . widget ( " network-link-state-checkbox " ) . get_active ( )
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_network ,
kwargs , self . vm , self . err ,
devobj = devobj )
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
def _apply_graphics ( self , devobj ) :
2020-01-25 00:48:39 +03:00
( gtype , port , listen ,
2020-01-25 00:00:20 +03:00
addr , passwd , gl , rendernode ) = self . gfxdetails . get_values ( )
2014-01-29 03:44:40 +04:00
2014-03-22 22:34:23 +04:00
kwargs = { }
2010-12-12 04:54:48 +03:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_GFX_PASSWD ) :
2014-03-22 22:34:23 +04:00
kwargs [ " passwd " ] = passwd
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_GFX_LISTEN ) :
2017-02-21 16:00:59 +03:00
kwargs [ " listen " ] = listen
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_GFX_ADDRESS ) or self . _edited ( EDIT_GFX_LISTEN ) :
2017-02-21 16:00:59 +03:00
kwargs [ " addr " ] = addr
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_GFX_PORT ) or self . _edited ( EDIT_GFX_LISTEN ) :
2014-03-22 22:34:23 +04:00
kwargs [ " port " ] = port
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_GFX_OPENGL ) :
2017-02-21 16:00:56 +03:00
kwargs [ " gl " ] = gl
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_GFX_RENDERNODE ) :
2017-02-21 16:01:01 +03:00
kwargs [ " rendernode " ] = rendernode
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_GFX_TYPE ) :
2014-03-22 22:34:23 +04:00
kwargs [ " gtype " ] = gtype
2010-12-12 04:54:48 +03:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_graphics ,
kwargs , self . vm , self . err ,
2014-03-22 22:34:23 +04:00
devobj = devobj )
2010-12-12 04:54:48 +03:00
2020-08-27 21:36:48 +03:00
def _apply_video ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_VIDEO_MODEL ) :
2015-05-20 00:54:53 +03:00
model = uiutil . get_list_selection ( self . widget ( " video-model " ) )
2011-07-15 00:18:42 +04:00
if model :
2014-03-22 22:34:23 +04:00
kwargs [ " model " ] = model
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_VIDEO_3D ) :
2017-02-21 16:01:02 +03:00
kwargs [ " accel3d " ] = self . widget ( " video-3d " ) . get_active ( )
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_video ,
kwargs , self . vm , self . err ,
2014-03-22 22:34:23 +04:00
devobj = devobj )
2009-11-04 21:18:14 +03:00
2020-08-27 21:36:48 +03:00
def _apply_controller ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-09-23 19:14:15 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_CONTROLLER_MODEL ) :
2015-05-20 00:54:53 +03:00
model = uiutil . get_list_selection ( self . widget ( " controller-model " ) )
2015-05-19 19:50:39 +03:00
kwargs [ " model " ] = model
2011-09-23 19:14:15 +04:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_controller ,
kwargs , self . vm , self . err ,
devobj = devobj )
2011-09-23 19:14:15 +04:00
2020-08-27 21:36:48 +03:00
def _apply_watchdog ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_WATCHDOG_MODEL ) :
2015-05-20 00:54:53 +03:00
kwargs [ " model " ] = uiutil . get_list_selection (
2014-03-22 22:34:23 +04:00
self . widget ( " watchdog-model " ) )
2011-07-15 00:18:42 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_WATCHDOG_ACTION ) :
2015-05-20 00:54:53 +03:00
kwargs [ " action " ] = uiutil . get_list_selection (
2014-03-22 22:34:23 +04:00
self . widget ( " watchdog-action " ) )
2011-07-15 00:18:42 +04:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_watchdog ,
kwargs , self . vm , self . err ,
2014-03-22 22:34:23 +04:00
devobj = devobj )
2010-03-24 07:22:17 +03:00
2020-08-27 21:36:48 +03:00
def _apply_filesystem ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2014-01-21 13:05:31 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_FS ) :
2020-08-22 21:31:37 +03:00
kwargs [ " newdev " ] = self . fsDetails . build_xmlobj ( )
2014-01-21 13:05:31 +04:00
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_filesystem ,
kwargs , self . vm , self . err ,
devobj = devobj )
2014-01-21 13:05:31 +04:00
2020-08-27 21:36:48 +03:00
def _apply_hostdev ( self , devobj ) :
2014-03-22 22:34:23 +04:00
kwargs = { }
2014-02-10 23:24:22 +04:00
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_HOSTDEV_ROMBAR ) :
2014-03-22 22:34:23 +04:00
kwargs [ " rom_bar " ] = self . widget ( " hostdev-rombar " ) . get_active ( )
2014-06-16 07:47:19 +04:00
return vmmAddHardware . change_config_helper ( self . vm . define_hostdev ,
kwargs , self . vm , self . err ,
2014-03-22 22:34:23 +04:00
devobj = devobj )
2014-02-10 23:24:22 +04:00
2020-08-27 21:36:48 +03:00
def _apply_tpm ( self , devobj ) :
2018-06-09 00:42:44 +03:00
kwargs = { }
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_TPM_MODEL ) :
2018-06-09 00:42:44 +03:00
model = uiutil . get_list_selection ( self . widget ( " tpm-model " ) )
kwargs [ " model " ] = model
return vmmAddHardware . change_config_helper ( self . vm . define_tpm ,
kwargs , self . vm , self . err ,
devobj = devobj )
2020-08-27 21:36:48 +03:00
def _apply_vsock ( self , devobj ) :
2018-12-14 17:34:19 +03:00
auto_cid , cid = self . vsockdetails . get_values ( )
kwargs = { }
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_VSOCK_AUTO ) :
2018-12-14 17:34:19 +03:00
kwargs [ " auto_cid " ] = auto_cid
2020-08-27 21:36:48 +03:00
if self . _edited ( EDIT_VSOCK_CID ) :
2018-12-14 17:34:19 +03:00
kwargs [ " cid " ] = cid
return vmmAddHardware . change_config_helper ( self . vm . define_vsock ,
kwargs , self . vm , self . err ,
devobj = devobj )
2014-02-10 23:24:22 +04:00
2020-08-27 21:36:48 +03:00
###########################
# Details page refreshers #
###########################
2020-01-24 11:25:12 +03:00
2020-08-27 21:36:48 +03:00
def _refresh_page ( self , pagetype = None ) :
2009-11-04 21:18:14 +03:00
if pagetype is None :
2020-08-27 21:36:48 +03:00
pagetype = self . _get_hw_row ( ) [ HW_LIST_COL_TYPE ]
2009-11-04 21:18:14 +03:00
2020-08-27 21:36:48 +03:00
self . widget ( " config-remove " ) . set_sensitive ( True )
self . widget ( " config-remove " ) . set_tooltip_text (
_ ( " Remove this device from the virtual machine " ) )
2019-05-05 23:25:35 +03:00
2020-08-27 21:36:48 +03:00
try :
dev = self . _get_hw_row ( ) [ HW_LIST_COL_DEVICE ]
if dev :
self . _xmleditor . set_xml ( _unindent_device_xml ( dev . get_xml ( ) ) )
else :
self . _xmleditor . set_xml_from_libvirtobject ( self . vm )
2019-05-05 23:25:35 +03:00
2020-08-27 21:36:48 +03:00
if pagetype == HW_LIST_TYPE_GENERAL :
self . _refresh_overview_page ( )
elif pagetype == HW_LIST_TYPE_OS :
self . _refresh_os_page ( )
elif pagetype == HW_LIST_TYPE_STATS :
self . _refresh_stats_page ( )
elif pagetype == HW_LIST_TYPE_CPU :
self . _refresh_config_cpu ( )
elif pagetype == HW_LIST_TYPE_MEMORY :
self . _refresh_config_memory ( )
elif pagetype == HW_LIST_TYPE_BOOT :
self . _refresh_boot_page ( )
elif pagetype == HW_LIST_TYPE_DISK :
self . _refresh_disk_page ( dev )
elif pagetype == HW_LIST_TYPE_NIC :
self . _refresh_network_page ( dev )
elif pagetype == HW_LIST_TYPE_INPUT :
self . _refresh_input_page ( dev )
elif pagetype == HW_LIST_TYPE_GRAPHICS :
self . _refresh_graphics_page ( dev )
elif pagetype == HW_LIST_TYPE_SOUND :
self . _refresh_sound_page ( dev )
elif pagetype == HW_LIST_TYPE_CHAR :
self . _refresh_char_page ( dev )
elif pagetype == HW_LIST_TYPE_HOSTDEV :
self . _refresh_hostdev_page ( dev )
elif pagetype == HW_LIST_TYPE_VIDEO :
self . _refresh_video_page ( dev )
elif pagetype == HW_LIST_TYPE_WATCHDOG :
self . _refresh_watchdog_page ( dev )
elif pagetype == HW_LIST_TYPE_CONTROLLER :
self . _refresh_controller_page ( dev )
elif pagetype == HW_LIST_TYPE_FILESYSTEM :
self . _refresh_filesystem_page ( dev )
elif pagetype == HW_LIST_TYPE_SMARTCARD :
self . _refresh_smartcard_page ( dev )
elif pagetype == HW_LIST_TYPE_REDIRDEV :
self . _refresh_redir_page ( dev )
elif pagetype == HW_LIST_TYPE_TPM :
self . _refresh_tpm_page ( dev )
elif pagetype == HW_LIST_TYPE_RNG :
self . _refresh_rng_page ( dev )
elif pagetype == HW_LIST_TYPE_PANIC :
self . _refresh_panic_page ( dev )
elif pagetype == HW_LIST_TYPE_VSOCK :
self . _refresh_vsock_page ( dev )
else : # pragma: no cover
pagetype = - 1
except Exception as e : # pragma: no cover
self . err . show_err ( _ ( " Error refreshing hardware page: %s " ) % str ( e ) )
# Don't return, we want the rest of the bits to run regardless
2019-05-05 23:25:35 +03:00
2020-08-27 21:36:48 +03:00
self . _disable_apply ( )
rem = pagetype in remove_pages
self . widget ( " config-remove " ) . set_visible ( rem )
self . widget ( " hw-panel " ) . set_current_page ( pagetype )
2019-05-05 23:25:35 +03:00
2020-08-27 21:36:48 +03:00
def _refresh_overview_page ( self ) :
2009-11-04 21:18:14 +03:00
# Basic details
2011-07-14 21:13:13 +04:00
self . widget ( " overview-name " ) . set_text ( self . vm . get_name ( ) )
self . widget ( " overview-uuid " ) . set_text ( self . vm . get_uuid ( ) )
2010-02-10 20:16:59 +03:00
desc = self . vm . get_description ( ) or " "
2011-07-14 21:13:13 +04:00
desc_widget = self . widget ( " overview-description " )
2010-02-10 20:16:59 +03:00
desc_widget . get_buffer ( ) . set_text ( desc )
2009-11-04 21:18:14 +03:00
2013-09-24 15:02:27 +04:00
title = self . vm . get_title ( )
self . widget ( " overview-title " ) . set_text ( title or " " )
2009-11-04 21:18:14 +03:00
# Hypervisor Details
2011-07-14 21:13:13 +04:00
self . widget ( " overview-hv " ) . set_text ( self . vm . get_pretty_hv_type ( ) )
2009-11-04 21:18:14 +03:00
arch = self . vm . get_arch ( ) or _ ( " Unknown " )
emu = self . vm . get_emulator ( ) or _ ( " None " )
2011-07-14 21:13:13 +04:00
self . widget ( " overview-arch " ) . set_text ( arch )
self . widget ( " overview-emulator " ) . set_text ( emu )
2009-11-04 21:18:14 +03:00
2014-09-18 01:25:03 +04:00
# Firmware
2015-02-22 19:13:21 +03:00
domcaps = self . vm . get_domain_capabilities ( )
2020-07-21 13:33:56 +03:00
if self . vm . get_xmlobj ( ) . os . firmware == " efi " :
2020-01-15 05:34:12 +03:00
firmware = ' UEFI '
else :
firmware = domcaps . label_for_firmware_path (
self . vm . get_xmlobj ( ) . os . loader )
2014-09-18 01:25:03 +04:00
if self . widget ( " overview-firmware " ) . is_visible ( ) :
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection (
2014-09-18 01:25:03 +04:00
self . widget ( " overview-firmware " ) , firmware )
elif self . widget ( " overview-firmware-label " ) . is_visible ( ) :
self . widget ( " overview-firmware-label " ) . set_text ( firmware )
2014-01-26 23:07:35 +04:00
# Machine settings
2015-07-31 15:28:00 +03:00
machtype = self . vm . get_machtype ( ) or _ ( " Unknown " )
2020-08-27 23:37:15 +03:00
self . widget ( " machine-type-label " ) . set_text ( machtype )
2015-02-22 01:54:15 +03:00
if self . widget ( " machine-type " ) . is_visible ( ) :
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection (
2015-02-22 01:54:15 +03:00
self . widget ( " machine-type " ) , machtype )
2014-01-26 23:07:35 +04:00
2015-02-22 01:54:15 +03:00
# Chipset
2014-06-01 04:13:08 +04:00
chipset = _chipset_label_from_machine ( machtype )
2020-08-27 23:37:15 +03:00
self . widget ( " overview-chipset-label " ) . set_text ( chipset )
2014-06-01 04:13:08 +04:00
if self . widget ( " overview-chipset " ) . is_visible ( ) :
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection (
2014-06-01 04:13:08 +04:00
self . widget ( " overview-chipset " ) , chipset )
2020-08-27 21:36:48 +03:00
def _refresh_os_page ( self ) :
2018-09-29 23:04:05 +03:00
self . _os_list . select_os ( self . vm . xmlobj . osinfo )
2018-03-13 20:00:59 +03:00
inspection_supported = self . config . inspection_supported ( )
2014-01-27 03:15:50 +04:00
uiutil . set_grid_row_visible ( self . widget ( " details-overview-error " ) ,
2018-03-13 23:37:46 +03:00
bool ( self . vm . inspection . errorstr ) )
if self . vm . inspection . errorstr :
self . widget ( " details-overview-error " ) . set_text (
self . vm . inspection . errorstr )
inspection_supported = False
2013-11-25 19:10:03 +04:00
2018-03-13 20:00:59 +03:00
self . widget ( " details-inspection-apps " ) . set_visible ( inspection_supported )
2018-09-29 23:04:05 +03:00
self . widget ( " details-inspection-refresh " ) . set_visible (
inspection_supported )
2018-03-13 20:00:59 +03:00
if not inspection_supported :
return
2011-07-18 22:53:57 +04:00
# Applications (also inspection data)
2018-03-13 20:00:59 +03:00
apps = self . vm . inspection . applications or [ ]
apps_list = self . widget ( " inspection-apps " )
apps_model = apps_list . get_model ( )
apps_model . clear ( )
for app in apps :
name = " "
2019-04-18 17:08:30 +03:00
if app . display_name :
name = app . display_name
2019-04-18 17:08:32 +03:00
elif app . name :
name = app . name
2018-03-13 20:00:59 +03:00
version = " "
2019-04-18 17:08:30 +03:00
if app . epoch > 0 :
version + = str ( app . epoch ) + " : "
if app . version :
version + = app . version
if app . release :
version + = " - " + app . release
2018-03-13 20:00:59 +03:00
summary = " "
2019-04-18 17:08:30 +03:00
if app . summary :
summary = app . summary
elif app . description :
summary = app . description
2018-03-13 20:00:59 +03:00
pos = summary . find ( " \n " )
if pos > - 1 :
summary = _ ( " %(summary)s ... " ) % {
" summary " : summary [ 0 : pos ]
}
apps_model . append ( [ name , version , summary ] )
2011-07-18 22:53:57 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_stats_page ( self ) :
2015-09-23 23:28:46 +03:00
def _multi_color ( text1 , text2 ) :
2015-09-24 00:31:26 +03:00
return ( ' <span color= " #82003B " > %s </span> '
' <span color= " #295C45 " > %s </span> ' % ( text1 , text2 ) )
2010-08-22 03:27:45 +04:00
def _dsk_rx_tx_text ( rx , tx , unit ) :
2018-05-21 22:42:50 +03:00
opts = { " received " : rx , " transferred " : tx , " units " : unit }
2015-09-23 23:28:46 +03:00
return _multi_color ( _ ( " %(received)d %(units)s read " ) % opts ,
2018-05-21 22:42:50 +03:00
_ ( " %(transferred)d %(units)s write " ) % opts )
2010-08-22 03:27:45 +04:00
def _net_rx_tx_text ( rx , tx , unit ) :
2018-05-21 22:42:50 +03:00
opts = { " received " : rx , " transferred " : tx , " units " : unit }
2015-09-23 23:28:46 +03:00
return _multi_color ( _ ( " %(received)d %(units)s in " ) % opts ,
2018-05-21 22:42:50 +03:00
_ ( " %(transferred)d %(units)s out " ) % opts )
2009-11-04 21:18:14 +03:00
cpu_txt = _ ( " Disabled " )
mem_txt = _ ( " Disabled " )
dsk_txt = _ ( " Disabled " )
net_txt = _ ( " Disabled " )
2014-02-12 00:29:30 +04:00
if self . config . get_stats_enable_cpu_poll ( ) :
cpu_txt = " %d %% " % self . vm . guest_cpu_time_percentage ( )
2009-11-04 21:18:14 +03:00
2014-02-11 00:13:31 +04:00
if self . config . get_stats_enable_memory_poll ( ) :
cur_vm_memory = self . vm . stats_memory ( )
2020-01-25 23:25:16 +03:00
vm_memory = self . vm . xmlobj . memory
2015-09-24 00:31:26 +03:00
mem_txt = _ ( " % (current-memory)s of % (total-memory)s " ) % {
2019-06-08 00:19:23 +03:00
" current-memory " : uiutil . pretty_mem ( cur_vm_memory ) ,
" total-memory " : uiutil . pretty_mem ( vm_memory )
2015-09-23 23:28:46 +03:00
}
2009-11-04 21:18:14 +03:00
if self . config . get_stats_enable_disk_poll ( ) :
2010-08-22 03:27:45 +04:00
dsk_txt = _dsk_rx_tx_text ( self . vm . disk_read_rate ( ) ,
2014-06-16 07:56:02 +04:00
self . vm . disk_write_rate ( ) , " KiB/s " )
2009-11-04 21:18:14 +03:00
if self . config . get_stats_enable_net_poll ( ) :
2010-08-22 03:27:45 +04:00
net_txt = _net_rx_tx_text ( self . vm . network_rx_rate ( ) ,
2014-06-16 07:56:02 +04:00
self . vm . network_tx_rate ( ) , " KiB/s " )
2009-11-04 21:18:14 +03:00
2011-07-14 21:13:13 +04:00
self . widget ( " overview-cpu-usage-text " ) . set_text ( cpu_txt )
self . widget ( " overview-memory-usage-text " ) . set_text ( mem_txt )
self . widget ( " overview-network-traffic-text " ) . set_markup ( net_txt )
self . widget ( " overview-disk-usage-text " ) . set_markup ( dsk_txt )
2009-11-04 21:18:14 +03:00
2020-08-27 21:36:48 +03:00
self . _graph_cpu . set_property ( " data_array " ,
2013-04-28 02:42:32 +04:00
self . vm . guest_cpu_time_vector ( ) )
2020-08-27 21:36:48 +03:00
self . _graph_memory . set_property ( " data_array " ,
2011-04-10 07:03:01 +04:00
self . vm . stats_memory_vector ( ) )
2015-05-04 23:33:56 +03:00
d1 , d2 = self . vm . disk_io_vectors ( )
2020-08-27 21:36:48 +03:00
self . _graph_disk . set_property ( " data_array " , d1 + d2 )
2015-05-04 23:33:56 +03:00
n1 , n2 = self . vm . network_traffic_vectors ( )
2020-08-27 21:36:48 +03:00
self . _graph_network . set_property ( " data_array " , n1 + n2 )
2009-11-04 21:18:14 +03:00
2019-04-03 16:23:20 +03:00
def _cpu_secure_is_available ( self ) :
domcaps = self . vm . get_domain_capabilities ( )
features = domcaps . get_cpu_security_features ( )
return self . vm . get_xmlobj ( ) . os . is_x86 ( ) and len ( features ) > 0
2020-08-27 21:36:48 +03:00
def _refresh_config_cpu ( self ) :
2020-01-25 23:11:02 +03:00
# Set topology first, because it impacts vcpus values
2020-08-28 01:02:10 +03:00
cpu = self . vm . xmlobj . cpu
show_top = cpu . has_topology ( )
2014-04-03 18:30:37 +04:00
self . widget ( " cpu-topology-enable " ) . set_active ( show_top )
2020-08-28 01:02:10 +03:00
sockets = cpu . topology . sockets or 1
cores = cpu . topology . cores or 1
threads = cpu . topology . threads or 1
2010-12-17 00:05:55 +03:00
2011-07-14 21:13:13 +04:00
self . widget ( " cpu-sockets " ) . set_value ( sockets )
self . widget ( " cpu-cores " ) . set_value ( cores )
self . widget ( " cpu-threads " ) . set_value ( threads )
2014-02-01 18:14:55 +04:00
if show_top :
self . widget ( " cpu-topology-expander " ) . set_expanded ( True )
2010-12-17 00:05:55 +03:00
2015-09-24 16:31:04 +03:00
host_active_count = self . vm . conn . host_active_processor_count ( )
2020-01-25 23:11:02 +03:00
vcpus = self . vm . xmlobj . vcpus
2015-09-24 16:31:04 +03:00
2020-01-25 23:11:02 +03:00
self . widget ( " cpu-vcpus " ) . set_value ( int ( vcpus ) )
2015-09-24 16:31:04 +03:00
self . widget ( " state-host-cpus " ) . set_text ( str ( host_active_count ) )
2020-01-25 23:11:02 +03:00
# Trigger this again to make sure vcpus is correct
2020-08-27 21:36:48 +03:00
self . _sync_cpu_topology_ui ( )
2015-09-24 16:31:04 +03:00
# Warn about overcommit
2020-08-27 21:36:48 +03:00
warn = bool ( self . _get_config_vcpus ( ) > host_active_count )
2015-09-24 16:31:04 +03:00
self . widget ( " cpu-vcpus-warn-box " ) . set_visible ( warn )
# CPU model config
2014-01-31 22:40:09 +04:00
model = cpu . model or None
if not model :
if cpu . mode == " host-model " or cpu . mode == " host-passthrough " :
model = cpu . mode
if model :
self . widget ( " cpu-model " ) . get_child ( ) . set_text ( model )
else :
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection (
2014-02-05 22:51:53 +04:00
self . widget ( " cpu-model " ) ,
2018-03-20 22:10:04 +03:00
virtinst . DomainCpu . SPECIAL_MODE_HV_DEFAULT , column = 2 )
2014-01-31 22:40:09 +04:00
2014-09-21 04:40:05 +04:00
is_host = ( cpu . mode == " host-model " )
2014-01-31 22:40:09 +04:00
self . widget ( " cpu-copy-host " ) . set_active ( bool ( is_host ) )
2020-08-27 21:36:48 +03:00
self . _cpu_copy_host_clicked_cb ( self . widget ( " cpu-copy-host " ) )
2010-12-17 00:05:55 +03:00
2019-04-03 16:23:20 +03:00
if not self . _cpu_secure_is_available ( ) :
self . widget ( " cpu-secure " ) . set_sensitive ( False )
self . widget ( " cpu-secure " ) . set_tooltip_text (
" No security features to copy, the host is missing "
" security patches or the host CPU is not vulnerable. " )
cpu . check_security_features ( self . vm . get_xmlobj ( ) )
self . widget ( " cpu-secure " ) . set_active ( cpu . secure )
2020-08-27 21:36:48 +03:00
def _refresh_config_memory ( self ) :
2011-07-14 21:13:13 +04:00
host_mem_widget = self . widget ( " state-host-memory " )
2017-10-11 14:35:55 +03:00
host_mem = self . vm . conn . host_memory_size ( ) / / 1024
2020-01-25 23:25:16 +03:00
vm_cur_mem = self . vm . xmlobj . memory / 1024.0
2009-11-11 20:56:58 +03:00
2014-06-16 07:56:02 +04:00
host_mem_widget . set_text ( " %d MiB " % ( int ( round ( host_mem ) ) ) )
2008-03-18 21:37:22 +03:00
2015-09-14 01:01:39 +03:00
curmem = self . widget ( " mem-memory " )
2013-04-17 02:37:00 +04:00
curmem . set_value ( int ( round ( vm_cur_mem ) ) )
2009-11-11 20:56:58 +03:00
2020-08-27 21:36:48 +03:00
def _refresh_disk_page ( self , disk ) :
2010-09-03 22:10:04 +04:00
path = disk . path
devtype = disk . device
ro = disk . read_only
share = disk . shareable
bus = disk . bus
2013-10-04 05:39:01 +04:00
removable = disk . removable
2010-09-03 22:10:04 +04:00
cache = disk . driver_cache
2018-08-24 02:38:07 +03:00
discard = disk . driver_discard
2018-08-24 02:40:18 +03:00
detect_zeroes = disk . driver_detect_zeroes
2013-02-17 17:40:37 +04:00
2015-09-06 00:59:47 +03:00
size = " - "
if path :
size = _ ( " Unknown " )
vol = self . conn . get_vol_by_path ( path )
2010-03-04 02:43:48 +03:00
if vol :
size = vol . get_pretty_capacity ( )
2013-10-04 05:39:01 +04:00
is_usb = ( bus == " usb " )
can_set_removable = ( is_usb and ( self . conn . is_qemu ( ) or
2017-06-27 21:13:36 +03:00
self . conn . is_test ( ) ) )
2013-10-04 05:39:01 +04:00
if removable is None :
removable = False
2013-10-04 05:39:02 +04:00
else :
can_set_removable = True
2009-11-05 00:30:51 +03:00
2015-08-03 19:52:07 +03:00
pretty_name = _label_for_device ( disk )
2009-11-04 23:41:18 +03:00
2011-07-14 21:13:13 +04:00
self . widget ( " disk-target-type " ) . set_text ( pretty_name )
2009-11-04 23:41:18 +03:00
2011-07-14 21:13:13 +04:00
self . widget ( " disk-readonly " ) . set_active ( ro )
2018-10-06 21:26:31 +03:00
self . widget ( " disk-readonly " ) . set_sensitive ( not disk . is_cdrom ( ) )
2011-07-14 21:13:13 +04:00
self . widget ( " disk-shareable " ) . set_active ( share )
2013-10-04 05:39:01 +04:00
self . widget ( " disk-removable " ) . set_active ( removable )
2014-01-27 03:15:50 +04:00
uiutil . set_grid_row_visible ( self . widget ( " disk-removable " ) ,
2013-10-04 05:39:01 +04:00
can_set_removable )
2015-03-13 16:39:47 +03:00
2011-07-14 21:13:13 +04:00
self . widget ( " disk-size " ) . set_text ( size )
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection ( self . widget ( " disk-cache " ) , cache )
2018-08-24 02:38:07 +03:00
uiutil . set_list_selection ( self . widget ( " disk-discard " ) , discard )
2018-08-24 02:40:18 +03:00
uiutil . set_list_selection ( self . widget ( " disk-detect-zeroes " ) ,
detect_zeroes )
2011-03-09 18:36:21 +03:00
2015-04-08 02:31:30 +03:00
vmmAddHardware . populate_disk_bus_combo ( self . vm , devtype ,
2015-08-03 19:52:06 +03:00
self . widget ( " disk-bus " ) . get_model ( ) )
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection ( self . widget ( " disk-bus " ) , bus )
2020-01-26 00:04:12 +03:00
self . widget ( " disk-bus-label " ) . set_text (
vmmAddHardware . disk_pretty_bus ( bus ) or " - " )
2010-12-11 04:33:41 +03:00
2018-10-06 21:26:31 +03:00
is_removable = disk . is_cdrom ( ) or disk . is_floppy ( )
self . widget ( " disk-source-box " ) . set_visible ( is_removable )
self . widget ( " disk-source-label " ) . set_visible ( not is_removable )
self . widget ( " disk-source-label " ) . set_text ( path or " - " )
if is_removable :
self . _mediacombo . reset_state ( is_floppy = disk . is_floppy ( ) )
self . _mediacombo . set_path ( path or " " )
2007-04-11 22:48:36 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_network_page ( self , net ) :
2014-01-28 01:58:45 +04:00
vmmAddHardware . populate_network_model_combo (
self . vm , self . widget ( " network-model " ) )
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection ( self . widget ( " network-model " ) , net . model )
details: do not show MAC address if not set
Fixes this exception:
Traceback (most recent call last):
File "virt-manager/virtManager/create.py", line 1780, in finish
self.customize(guest)
File "virt-manager/virtManager/create.py", line 1812, in customize
self.config_window = vmmDetails(virtinst_guest, self.topwin)
File "virt-manager/virtManager/details.py", line 560, in __init__
self.populate_hw_list()
File "virt-manager/virtManager/details.py", line 3165, in populate_hw_list
self.repopulate_hw_list()
File "virt-manager/virtManager/details.py", line 3220, in repopulate_hw_list
update_hwlist(HW_LIST_TYPE_NIC, dev)
File "virt-manager/virtManager/details.py", line 3195, in update_hwlist
label = _label_for_device(dev)
File "virt-manager/virtManager/details.py", line 188, in _label_for_device
return "NIC %s" % dev.macaddr[-9:]
TypeError: 'NoneType' object has no attribute '__getitem__'
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1164123
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2014-11-14 11:45:07 +03:00
2015-04-08 01:52:35 +03:00
macaddr = net . macaddr or " "
if self . widget ( " network-mac-label " ) . is_visible ( ) :
self . widget ( " network-mac-label " ) . set_text ( macaddr )
else :
self . widget ( " network-mac-entry " ) . set_text ( macaddr )
2011-03-17 23:33:40 +03:00
2018-08-16 18:30:31 +03:00
state = net . link_state == " up " or net . link_state is None
self . widget ( " network-link-state-checkbox " ) . set_active ( state )
2018-09-06 21:04:00 +03:00
self . _set_network_ip_details ( net )
2018-08-31 13:37:30 +03:00
2014-01-28 01:58:45 +04:00
self . netlist . set_dev ( net )
2007-04-12 23:36:04 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_input_page ( self , inp ) :
2019-06-09 22:29:44 +03:00
dev = vmmAddHardware . input_pretty_name ( inp . type , inp . bus )
2007-09-26 04:05:45 +04:00
2014-05-04 21:23:54 +04:00
mode = None
2010-09-03 23:59:33 +04:00
if inp . type == " tablet " :
2009-11-11 20:56:58 +03:00
mode = _ ( " Absolute Movement " )
2014-05-04 21:23:54 +04:00
elif inp . type == " mouse " :
2009-11-11 20:56:58 +03:00
mode = _ ( " Relative Movement " )
2011-07-14 21:13:13 +04:00
self . widget ( " input-dev-type " ) . set_text ( dev )
2014-05-04 21:23:54 +04:00
self . widget ( " input-dev-mode " ) . set_text ( mode or " " )
uiutil . set_grid_row_visible ( self . widget ( " input-dev-mode " ) , bool ( mode ) )
2009-01-15 19:23:23 +03:00
2014-05-04 21:23:54 +04:00
if ( ( inp . type == " mouse " and inp . bus in ( " xen " , " ps2 " ) ) or
2014-06-03 02:54:28 +04:00
( inp . type == " keyboard " and inp . bus in ( " xen " , " ps2 " ) ) ) :
2018-07-31 17:47:18 +03:00
self . _disable_device_remove (
_ ( " Hypervisor does not support removing this device " ) )
2007-09-26 04:05:45 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_graphics_page ( self , gfx ) :
2014-01-29 03:44:40 +04:00
title = self . gfxdetails . set_dev ( gfx )
2013-09-28 20:21:35 +04:00
self . widget ( " graphics-title " ) . set_markup ( " <b> %s </b> " % title )
2020-08-27 21:36:48 +03:00
def _refresh_sound_page ( self , sound ) :
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection ( self . widget ( " sound-model " ) , sound . model )
2008-07-31 03:52:39 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_smartcard_page ( self , sc ) :
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection ( self . widget ( " smartcard-mode " ) , sc . mode )
2011-06-23 19:42:03 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_redir_page ( self , rd ) :
2014-09-20 18:23:19 +04:00
address = None
if rd . type == ' tcp ' :
2020-07-12 00:31:40 +03:00
address = " %s : %s " % ( rd . source . host , rd . source . service )
2011-09-02 05:23:27 +04:00
2015-08-03 19:52:07 +03:00
self . widget ( " redir-title " ) . set_markup ( _label_for_device ( rd ) )
2019-06-09 22:29:44 +03:00
self . widget ( " redir-type " ) . set_text (
vmmAddHardware . redirdev_pretty_type ( rd . type ) )
2011-09-02 05:23:27 +04:00
2014-09-20 18:23:19 +04:00
self . widget ( " redir-address " ) . set_text ( address or " " )
uiutil . set_grid_row_visible (
self . widget ( " redir-address " ) , bool ( address ) )
2011-09-02 05:23:27 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_tpm_page ( self , tpmdev ) :
2019-05-13 20:35:04 +03:00
def show_ui ( widgetname , val ) :
doshow = bool ( val )
2014-01-27 03:15:50 +04:00
uiutil . set_grid_row_visible ( self . widget ( widgetname ) , doshow )
2013-06-26 05:45:08 +04:00
self . widget ( widgetname ) . set_text ( val or " - " )
dev_type = tpmdev . type
2013-07-15 20:18:23 +04:00
self . widget ( " tpm-dev-type " ) . set_text (
2019-06-09 22:29:44 +03:00
vmmAddHardware . tpm_pretty_type ( dev_type ) )
2013-06-26 05:45:08 +04:00
2018-06-09 00:42:44 +03:00
vmmAddHardware . populate_tpm_model_combo (
self . vm , self . widget ( " tpm-model " ) , tpmdev . version )
uiutil . set_list_selection ( self . widget ( " tpm-model " ) , tpmdev . model )
2013-06-26 05:45:08 +04:00
# Device type specific properties, only show if apply to the cur dev
2019-05-13 20:35:04 +03:00
show_ui ( " tpm-device-path " , tpmdev . device_path )
show_ui ( " tpm-version " , tpmdev . version )
2013-06-26 05:45:08 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_panic_page ( self , dev ) :
2017-09-16 02:36:58 +03:00
model = dev . model or " isa "
2019-06-09 22:29:44 +03:00
pmodel = vmmAddHardware . panic_pretty_model ( model )
2017-09-04 19:40:34 +03:00
self . widget ( " panic-model " ) . set_text ( pmodel )
2014-01-10 13:37:55 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_rng_page ( self , dev ) :
2019-05-13 21:42:50 +03:00
is_random = dev . backend_model == " random "
2018-09-03 23:30:20 +03:00
uiutil . set_grid_row_visible ( self . widget ( " rng-device " ) , is_random )
2019-05-13 21:42:50 +03:00
self . widget ( " rng-type " ) . set_text (
2019-06-09 22:29:44 +03:00
vmmAddHardware . rng_pretty_type ( dev . backend_model ) )
2018-09-03 23:30:20 +03:00
self . widget ( " rng-device " ) . set_text ( dev . device or " " )
2013-10-25 19:13:29 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_vsock_page ( self , dev ) :
2018-12-14 17:34:19 +03:00
self . vsockdetails . set_dev ( dev )
2020-08-27 21:36:48 +03:00
def _refresh_char_page ( self , chardev ) :
2020-08-27 01:01:02 +03:00
char_type = chardev . DEVICE_TYPE
2010-09-09 01:53:51 +04:00
target_port = chardev . target_port
2013-07-16 17:14:37 +04:00
dev_type = chardev . type or " pty "
2018-03-21 21:42:50 +03:00
primary = self . vm . serial_is_console_dup ( chardev )
2020-08-27 01:01:02 +03:00
show_target_type = not ( char_type in [ " serial " , " parallel " ] )
2009-12-03 18:37:57 +03:00
2010-09-13 17:31:32 +04:00
if char_type == " serial " :
typelabel = _ ( " Serial Device " )
elif char_type == " parallel " :
typelabel = _ ( " Parallel Device " )
elif char_type == " console " :
typelabel = _ ( " Console Device " )
elif char_type == " channel " :
typelabel = _ ( " Channel Device " )
2020-08-27 23:37:15 +03:00
else : # pragma: no cover
2010-09-13 17:31:32 +04:00
typelabel = _ ( " %s Device " ) % char_type . capitalize ( )
2014-01-29 06:44:55 +04:00
if ( target_port is not None and
2018-03-21 01:59:14 +03:00
chardev . DEVICE_TYPE == " console " ) :
2014-01-29 06:44:55 +04:00
typelabel + = " %s " % ( int ( target_port ) + 1 )
2011-04-06 01:29:44 +04:00
if target_port is not None and not show_target_type :
2010-09-04 01:56:40 +04:00
typelabel + = " %s " % ( int ( target_port ) + 1 )
2009-12-03 18:37:57 +03:00
if primary :
typelabel + = " ( %s ) " % _ ( " Primary Console " )
typelabel = " <b> %s </b> " % typelabel
2011-07-14 21:13:13 +04:00
self . widget ( " char-type " ) . set_markup ( typelabel )
self . widget ( " char-dev-type " ) . set_text ( dev_type )
2011-04-06 01:29:44 +04:00
2019-05-13 20:35:04 +03:00
def show_ui ( widgetname , val ) :
doshow = bool ( val )
uiutil . set_grid_row_visible ( self . widget ( widgetname ) , doshow )
self . widget ( widgetname ) . set_text ( val or " - " )
def build_host_str ( host , port ) :
ret = " "
if host :
ret + = host
if port :
ret + = " : %s " % str ( port )
return ret
connect_str = build_host_str (
2019-05-13 21:23:27 +03:00
chardev . source . connect_host , chardev . source . connect_service )
bind_str = build_host_str (
chardev . source . bind_host , chardev . source . bind_service )
2019-05-13 20:35:04 +03:00
target_type = show_target_type and chardev . target_type or None
2011-04-06 01:29:44 +04:00
# Device type specific properties, only show if apply to the cur dev
2019-05-13 20:35:04 +03:00
show_ui ( " char-source-host " , connect_str )
show_ui ( " char-bind-host " , bind_str )
2019-05-13 21:23:27 +03:00
show_ui ( " char-source-path " , chardev . source . path )
2019-05-13 20:35:04 +03:00
show_ui ( " char-target-type " , target_type )
show_ui ( " char-target-name " , chardev . target_name )
show_ui ( " char-target-state " , chardev . target_state )
2009-06-17 02:04:29 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_hostdev_page ( self , hostdev ) :
2014-02-10 23:24:22 +04:00
rom_bar = hostdev . rom_bar
if rom_bar is None :
rom_bar = True
2014-09-20 18:23:19 +04:00
devtype = hostdev . type
if hostdev . type == ' usb ' :
devtype = ' usb_device '
nodedev = None
2019-06-05 21:45:48 +03:00
for trydev in self . vm . conn . filter_nodedevs ( devtype ) :
2015-04-07 21:12:00 +03:00
if trydev . xmlobj . compare_to_hostdev ( hostdev ) :
2019-06-09 22:29:44 +03:00
nodedev = trydev
2014-09-20 18:23:19 +04:00
2010-09-07 20:09:48 +04:00
pretty_name = None
if nodedev :
pretty_name = nodedev . pretty_name ( )
if not pretty_name :
2019-06-09 22:29:44 +03:00
pretty_name = vmmAddHardware . hostdev_pretty_name ( hostdev )
2008-03-07 00:43:46 +03:00
2014-02-10 23:24:22 +04:00
uiutil . set_grid_row_visible (
self . widget ( " hostdev-rombar " ) , hostdev . type == " pci " )
2016-02-05 18:18:16 +03:00
devlabel = " <b> " + _ ( " Physical %s Device " ) % hostdev . type . upper ( ) + " </b> "
2011-07-14 21:13:13 +04:00
self . widget ( " hostdev-title " ) . set_markup ( devlabel )
self . widget ( " hostdev-source " ) . set_text ( pretty_name )
2014-02-10 23:24:22 +04:00
self . widget ( " hostdev-rombar " ) . set_active ( rom_bar )
2006-11-13 23:31:17 +03:00
2020-08-27 21:36:48 +03:00
def _refresh_video_page ( self , vid ) :
2013-07-15 19:07:40 +04:00
model = vid . model
2015-07-28 08:19:17 +03:00
if model == " qxl " and vid . vgamem :
ram = vid . vgamem
else :
ram = vid . vram
2010-09-03 23:59:33 +04:00
heads = vid . heads
2009-11-04 21:18:14 +03:00
try :
2017-10-11 14:35:55 +03:00
ramlabel = ram and " %d MiB " % ( int ( ram ) / / 1024 ) or " - "
2020-08-25 15:47:11 +03:00
except Exception : # pragma: no cover
2009-11-04 21:18:14 +03:00
ramlabel = " - "
2008-07-31 04:38:09 +04:00
2011-07-14 21:13:13 +04:00
self . widget ( " video-ram " ) . set_text ( ramlabel )
2013-07-15 19:07:40 +04:00
self . widget ( " video-heads " ) . set_text ( heads and str ( heads ) or " - " )
2007-04-11 22:48:36 +04:00
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection ( self . widget ( " video-model " ) , model )
2009-11-05 22:59:11 +03:00
2017-02-21 16:01:02 +03:00
if vid . accel3d is None :
self . widget ( " video-3d " ) . set_inconsistent ( True )
else :
self . widget ( " video-3d " ) . set_active ( vid . accel3d )
2019-01-28 19:52:38 +03:00
if ( self . vm . xmlobj . devices . graphics and
len ( self . vm . xmlobj . devices . video ) < = 1 ) :
2018-08-05 12:37:41 +03:00
self . _disable_device_remove (
2019-01-28 19:52:38 +03:00
_ ( " Cannot remove last video device while "
" Graphics/Display is attached. " ) )
2018-08-05 12:37:41 +03:00
2020-08-27 21:36:48 +03:00
def _refresh_watchdog_page ( self , watch ) :
2010-09-03 23:59:33 +04:00
model = watch . model
action = watch . action
2010-03-24 07:22:17 +03:00
2015-05-20 01:22:49 +03:00
uiutil . set_list_selection ( self . widget ( " watchdog-model " ) , model )
uiutil . set_list_selection ( self . widget ( " watchdog-action " ) , action )
2010-03-24 07:22:17 +03:00
2020-08-27 21:36:48 +03:00
def _refresh_controller_page ( self , controller ) :
2017-11-23 12:32:48 +03:00
uiutil . set_grid_row_visible ( self . widget ( " device-list-label " ) , False )
uiutil . set_grid_row_visible ( self . widget ( " controller-device-box " ) , False )
2017-11-23 12:32:47 +03:00
if self . vm . get_xmlobj ( ) . os . is_x86 ( ) and controller . type == " usb " :
2018-08-05 12:37:41 +03:00
self . _disable_device_remove (
_ ( " Hypervisor does not support removing this device " ) )
2017-11-23 12:32:47 +03:00
if controller . type == " pci " :
2018-08-05 12:37:41 +03:00
self . _disable_device_remove (
_ ( " Hypervisor does not support removing this device " ) )
2018-07-18 13:00:19 +03:00
elif controller . type in [ " scsi " , " sata " , " ide " , " fdc " ] :
2017-11-23 12:32:50 +03:00
model = self . widget ( " controller-device-list " ) . get_model ( )
model . clear ( )
2020-01-27 16:02:19 +03:00
disks = controller . get_attached_devices ( self . vm . xmlobj )
for disk in disks :
name = _label_for_device ( disk )
2020-07-14 10:41:45 +03:00
infoStr = _ ( " %(device)s on %(address)s " ) % {
" device " : name ,
" address " : disk . address . pretty_desc ( ) ,
}
2020-01-27 16:02:19 +03:00
model . append ( [ infoStr ] )
self . _disable_device_remove (
_ ( " Cannot remove controller while devices are attached. " ) )
uiutil . set_grid_row_visible (
self . widget ( " device-list-label " ) , True )
uiutil . set_grid_row_visible (
self . widget ( " controller-device-box " ) , True )
2018-07-18 13:00:21 +03:00
elif controller . type == " virtio-serial " :
2020-01-27 16:02:19 +03:00
devs = controller . get_attached_devices ( self . vm . xmlobj )
if devs :
self . _disable_device_remove (
_ ( " Cannot remove controller while devices are attached. " ) )
2017-11-23 12:32:50 +03:00
2019-06-09 22:29:44 +03:00
type_label = vmmAddHardware . controller_pretty_desc ( controller )
2011-07-14 21:13:13 +04:00
self . widget ( " controller-type " ) . set_text ( type_label )
2011-09-23 19:14:15 +04:00
2015-05-19 19:50:39 +03:00
combo = self . widget ( " controller-model " )
2017-11-23 12:32:47 +03:00
vmmAddHardware . populate_controller_model_combo ( combo , controller . type )
show_model = ( controller . model or len ( combo . get_model ( ) ) > 1 )
if controller . type == " pci " :
2017-06-27 22:32:54 +03:00
show_model = False
uiutil . set_grid_row_visible ( combo , show_model )
2018-10-04 16:53:36 +03:00
model = controller . model
if controller . type == " usb " and " xhci " in str ( model ) :
model = " usb3 "
uiutil . set_list_selection ( self . widget ( " controller-model " ) , model )
2010-12-16 20:41:47 +03:00
2020-08-27 21:36:48 +03:00
def _refresh_filesystem_page ( self , dev ) :
2014-01-21 13:05:31 +04:00
self . fsDetails . set_dev ( dev )
self . fsDetails . update_fs_rows ( )
2011-05-19 23:18:33 +04:00
2020-08-27 21:36:48 +03:00
def _refresh_boot_page ( self ) :
2009-11-04 21:18:14 +03:00
# Refresh autostart
try :
2009-12-03 18:37:57 +03:00
# Older libvirt versions return None if not supported
2009-11-04 21:18:14 +03:00
autoval = self . vm . get_autostart ( )
2020-08-25 15:47:11 +03:00
except libvirt . libvirtError : # pragma: no cover
2009-12-03 18:37:57 +03:00
autoval = None
2011-05-26 20:38:48 +04:00
# Autostart
2015-09-14 01:01:39 +03:00
autostart_chk = self . widget ( " boot-autostart " )
2010-12-12 06:00:52 +03:00
enable_autostart = ( autoval is not None )
autostart_chk . set_sensitive ( enable_autostart )
autostart_chk . set_active ( enable_autostart and autoval or False )
2011-05-26 20:38:48 +04:00
show_kernel = not self . vm . is_container ( )
show_init = self . vm . is_container ( )
show_boot = ( not self . vm . is_container ( ) and not self . vm . is_xenpv ( ) )
2009-11-04 21:18:14 +03:00
2014-02-10 01:21:26 +04:00
uiutil . set_grid_row_visible (
self . widget ( " boot-order-frame " ) , show_boot )
uiutil . set_grid_row_visible (
self . widget ( " boot-kernel-expander " ) , show_kernel )
uiutil . set_grid_row_visible (
self . widget ( " boot-init-frame " ) , show_init )
2011-05-26 20:38:48 +04:00
# Kernel/initrd boot
2013-08-18 20:25:20 +04:00
kernel , initrd , dtb , args = self . vm . get_boot_kernel_info ( )
expand = bool ( kernel or dtb or initrd or args )
def keep_text ( wname , guestval ) :
# If the user unsets kernel/initrd by unchecking the
# 'enable kernel boot' box, we keep the previous values cached
# in the text fields to allow easy switching back and forth.
guestval = guestval or " "
2020-08-27 21:36:48 +03:00
if self . _get_text ( wname ) and not guestval :
2013-08-18 20:25:20 +04:00
return
self . widget ( wname ) . set_text ( guestval )
keep_text ( " boot-kernel " , kernel )
keep_text ( " boot-initrd " , initrd )
keep_text ( " boot-dtb " , dtb )
keep_text ( " boot-kernel-args " , args )
2010-12-12 07:00:19 +03:00
if expand :
2013-08-18 20:25:20 +04:00
# Only 'expand' if requested, so a refresh doesn't
# magically unexpand the UI the user just touched
2011-07-14 21:13:13 +04:00
self . widget ( " boot-kernel-expander " ) . set_expanded ( True )
2013-08-18 20:25:20 +04:00
self . widget ( " boot-kernel-enable " ) . set_active ( expand )
self . widget ( " boot-kernel-enable " ) . toggled ( )
# Only show dtb if it's supported
arch = self . vm . get_arch ( ) or " "
2020-08-27 21:36:48 +03:00
show_dtb = ( self . _get_text ( " boot-dtb " ) or
2013-08-18 20:25:20 +04:00
self . vm . get_hv_type ( ) == " test " or
" arm " in arch or " microblaze " in arch or " ppc " in arch )
self . widget ( " boot-dtb-label " ) . set_visible ( show_dtb )
self . widget ( " boot-dtb-box " ) . set_visible ( show_dtb )
2010-12-12 07:00:19 +03:00
2011-05-26 20:38:48 +04:00
# <init> populate
2014-06-01 01:34:23 +04:00
init , initargs = self . vm . get_init ( )
2011-07-14 21:13:13 +04:00
self . widget ( " boot-init-path " ) . set_text ( init or " " )
2014-06-01 01:34:23 +04:00
self . widget ( " boot-init-args " ) . set_text ( initargs or " " )
2011-05-26 20:38:48 +04:00
# Boot menu populate
menu = self . vm . get_boot_menu ( ) or False
2011-07-14 21:13:13 +04:00
self . widget ( " boot-menu " ) . set_active ( menu )
2020-08-27 21:36:48 +03:00
self . _refresh_boot_order ( )
def _make_boot_rows ( self ) :
if not self . vm . can_use_device_boot_order ( ) :
return [
[ " hd " , _ ( " Hard Disk " ) , " drive-harddisk " , False , True ] ,
[ " cdrom " , _ ( " CDROM " ) , " media-optical " , False , True ] ,
[ " network " , _ ( " Network (PXE) " ) , " network-idle " , False , True ] ,
[ " fd " , _ ( " Floppy " ) , " media-floppy " , False , True ] ,
]
ret = [ ]
for dev in self . vm . get_bootable_devices ( ) :
icon = _icon_for_device ( dev )
label = _label_for_device ( dev )
ret . append ( [ dev . get_xml_id ( ) , label , icon , False , True ] )
if not ret :
ret . append ( [ None , _ ( " No bootable devices " ) , None , False , False ] )
return ret
def _refresh_boot_order ( self ) :
boot_list = self . widget ( " boot-list " )
boot_model = boot_list . get_model ( )
boot_model . clear ( )
boot_rows = self . _make_boot_rows ( )
boot_order = self . vm . get_boot_order ( )
for key in boot_order :
for row in boot_rows [ : ] :
if key != row [ BOOT_KEY ] :
continue
row [ BOOT_ACTIVE ] = True
boot_model . append ( row )
boot_rows . remove ( row )
break
for row in boot_rows :
boot_model . append ( row )
2008-03-07 00:43:46 +03:00
2007-04-12 23:36:04 +04:00
2009-11-04 21:18:14 +03:00
############################
# Hardware list population #
############################
2009-07-20 23:09:32 +04:00
2019-05-08 19:11:43 +03:00
def _make_hw_list_entry ( self , title , page_id , icon_name , devobj = None ) :
hw_entry = [ ]
hw_entry . insert ( HW_LIST_COL_LABEL , title )
hw_entry . insert ( HW_LIST_COL_ICON_NAME , icon_name )
hw_entry . insert ( HW_LIST_COL_TYPE , page_id )
2019-05-08 19:23:06 +03:00
hw_entry . insert ( HW_LIST_COL_DEVICE , devobj )
hw_entry . insert ( HW_LIST_COL_KEY , devobj or title )
2019-05-08 19:11:43 +03:00
return hw_entry
2020-08-27 21:36:48 +03:00
def _init_hw_list ( self ) :
"""
Add the static entries to the hw list , like Overview
"""
2011-07-14 21:13:13 +04:00
hw_list_model = self . widget ( " hw-list " ) . get_model ( )
2007-04-11 22:48:36 +04:00
hw_list_model . clear ( )
2009-07-20 23:09:32 +04:00
2019-05-08 19:11:43 +03:00
def add_hw_list_option ( * args , * * kwargs ) :
hw_list_model . append ( self . _make_hw_list_entry ( * args , * * kwargs ) )
2009-07-20 23:09:32 +04:00
2014-01-26 23:07:35 +04:00
add_hw_list_option ( _ ( " Overview " ) , HW_LIST_TYPE_GENERAL , " computer " )
2018-09-29 23:04:05 +03:00
add_hw_list_option ( _ ( " OS information " ) , HW_LIST_TYPE_OS , " computer " )
2010-02-07 20:18:28 +03:00
if not self . is_customize_dialog :
2015-09-22 02:16:31 +03:00
add_hw_list_option ( _ ( " Performance " ) , HW_LIST_TYPE_STATS ,
2020-01-26 23:41:21 +03:00
_get_performance_icon_name ( ) )
2015-09-22 02:16:31 +03:00
add_hw_list_option ( _ ( " CPUs " ) , HW_LIST_TYPE_CPU , " device_cpu " )
add_hw_list_option ( _ ( " Memory " ) , HW_LIST_TYPE_MEMORY , " device_mem " )
add_hw_list_option ( _ ( " Boot Options " ) , HW_LIST_TYPE_BOOT , " system-run " )
2007-04-11 22:48:36 +04:00
2020-08-27 21:36:48 +03:00
self . _repopulate_hw_list ( )
self . _set_hw_selection ( 0 )
2009-07-20 23:09:32 +04:00
2020-08-27 21:36:48 +03:00
def _repopulate_hw_list ( self ) :
"""
Refresh the hardware list entries with the latest VM config
"""
2011-07-14 21:13:13 +04:00
hw_list = self . widget ( " hw-list " )
2007-04-13 02:54:33 +04:00
hw_list_model = hw_list . get_model ( )
2007-04-11 22:48:36 +04:00
2010-09-08 02:38:01 +04:00
currentDevices = [ ]
def dev_cmp ( origdev , newdev ) :
2019-05-08 19:23:06 +03:00
if not origdev :
2010-09-08 02:38:01 +04:00
return False
if origdev == newdev :
return True
2018-02-14 23:35:53 +03:00
return origdev . get_xml_id ( ) == newdev . get_xml_id ( )
2010-09-08 02:38:01 +04:00
2014-02-10 00:20:41 +04:00
def update_hwlist ( hwtype , dev ) :
2009-07-20 23:09:32 +04:00
"""
See if passed hw is already in list , and if so , update info .
If not in list , add it !
2009-01-15 19:17:30 +03:00
"""
2015-08-03 19:52:07 +03:00
label = _label_for_device ( dev )
2014-02-10 00:20:41 +04:00
icon = _icon_for_device ( dev )
currentDevices . append ( dev )
2010-09-08 02:38:01 +04:00
2007-04-12 23:36:04 +04:00
insertAt = 0
for row in hw_list_model :
2010-09-08 02:38:01 +04:00
rowdev = row [ HW_LIST_COL_DEVICE ]
2014-02-10 00:20:41 +04:00
if dev_cmp ( rowdev , dev ) :
2009-07-20 23:09:32 +04:00
# Update existing HW info
2014-02-10 00:20:41 +04:00
row [ HW_LIST_COL_DEVICE ] = dev
row [ HW_LIST_COL_LABEL ] = label
row [ HW_LIST_COL_ICON_NAME ] = icon
2009-07-20 23:09:32 +04:00
return
2007-09-26 04:05:45 +04:00
2009-01-15 19:17:30 +03:00
if row [ HW_LIST_COL_TYPE ] < = hwtype :
insertAt + = 1
2009-07-20 23:09:32 +04:00
# Add the new HW row
2019-05-08 19:11:43 +03:00
hw_entry = self . _make_hw_list_entry ( label , hwtype , icon , dev )
hw_list_model . insert ( insertAt , hw_entry )
2014-02-10 00:20:41 +04:00
2018-03-21 21:42:50 +03:00
consoles = self . vm . xmlobj . devices . console
serials = self . vm . xmlobj . devices . serial
if serials and consoles and self . vm . serial_is_console_dup ( serials [ 0 ] ) :
consoles . pop ( 0 )
for dev in _calculate_disk_bus_index ( self . vm . xmlobj . devices . disk ) :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_DISK , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . interface :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_NIC , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . input :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_INPUT , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . graphics :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_GRAPHICS , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . sound :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_SOUND , dev )
2018-03-21 21:42:50 +03:00
for dev in serials :
update_hwlist ( HW_LIST_TYPE_CHAR , dev )
for dev in self . vm . xmlobj . devices . parallel :
update_hwlist ( HW_LIST_TYPE_CHAR , dev )
for dev in consoles :
update_hwlist ( HW_LIST_TYPE_CHAR , dev )
for dev in self . vm . xmlobj . devices . channel :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_CHAR , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . hostdev :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_HOSTDEV , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . redirdev :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_REDIRDEV , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . video :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_VIDEO , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . watchdog :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_WATCHDOG , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . controller :
2011-09-23 19:14:15 +04:00
# skip USB2 ICH9 companion controllers
2014-02-10 00:20:41 +04:00
if dev . model in [ " ich9-uhci1 " , " ich9-uhci2 " , " ich9-uhci3 " ] :
2011-09-23 19:14:15 +04:00
continue
2017-06-27 22:28:12 +03:00
# These are all parts of a default PCIe setup, which we
# condense down to one listing
if dev . model in [ " pcie-root-port " , " dmi-to-pci-bridge " ,
" pci-bridge " ] :
continue
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_CONTROLLER , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . filesystem :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_FILESYSTEM , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . smartcard :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_SMARTCARD , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . tpm :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_TPM , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . rng :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_RNG , dev )
2018-03-21 21:42:50 +03:00
for dev in self . vm . xmlobj . devices . panic :
2014-02-10 00:20:41 +04:00
update_hwlist ( HW_LIST_TYPE_PANIC , dev )
2018-12-14 17:34:19 +03:00
for dev in self . vm . xmlobj . devices . vsock :
update_hwlist ( HW_LIST_TYPE_VSOCK , dev )
2014-01-10 13:37:55 +04:00
2017-10-11 14:35:57 +03:00
devs = list ( range ( len ( hw_list_model ) ) )
2007-04-13 02:54:33 +04:00
devs . reverse ( )
for i in devs :
2008-11-19 01:01:22 +03:00
_iter = hw_list_model . iter_nth_child ( None , i )
2010-09-08 02:38:01 +04:00
olddev = hw_list_model [ i ] [ HW_LIST_COL_DEVICE ]
# Existing device, don't remove it
2019-05-08 19:23:06 +03:00
if not olddev or olddev in currentDevices :
2010-09-08 02:38:01 +04:00
continue
hw_list_model . remove ( _iter )
2007-04-13 02:54:33 +04:00
2014-02-10 01:21:26 +04:00
2020-08-27 21:36:48 +03:00
################
# UI listeners #
################
2010-02-25 04:37:41 +03:00
2020-08-27 21:36:48 +03:00
def _config_apply_clicked_cb ( self , src ) :
self . _config_apply ( )
def _config_cancel_clicked_cb ( self , src ) :
self . _config_cancel ( )
def _config_remove_clicked_cb ( self , src ) :
self . _config_remove ( )
2010-02-25 04:37:41 +03:00
2020-08-27 21:36:48 +03:00
def _refresh_ip_clicked_cb ( self , src ) :
self . _refresh_ip ( )
2010-02-25 04:37:41 +03:00
2020-08-27 21:36:48 +03:00
def _browse_kernel_clicked_cb ( self , src ) :
def cb ( ignore , path ) :
self . widget ( " boot-kernel " ) . set_text ( path )
self . _browse_file ( cb )
def _browse_initrd_clicked_cb ( self , src ) :
def cb ( ignore , path ) :
self . widget ( " boot-initrd " ) . set_text ( path )
self . _browse_file ( cb )
def _browse_dtb_clicked_cb ( self , src ) :
def cb ( ignore , path ) :
self . widget ( " boot-dtb " ) . set_text ( path )
self . _browse_file ( cb )
2010-02-25 04:37:41 +03:00
2020-08-27 21:36:48 +03:00
def _xmleditor_xml_requested_cb ( self , src ) :
self . _refresh_page ( )
def _xmleditor_xml_reset_cb ( self , src ) :
self . _refresh_page ( )
2010-02-25 04:37:41 +03:00
2020-08-27 21:36:48 +03:00
def _addhw_clicked_cb ( self , src ) :
self . _show_addhw ( )
2010-02-25 04:37:41 +03:00
2020-08-27 21:36:48 +03:00
def _boot_kernel_toggled_cb ( self , src ) :
self . widget ( " boot-kernel-box " ) . set_sensitive ( src . get_active ( ) )
self . _enable_apply ( EDIT_KERNEL )
def _boot_list_changed_cb ( self , src ) :
self . _config_bootdev_selected ( )
def _boot_moveup_clicked_cb ( self , src ) :
self . _config_boot_move ( True )
def _boot_movedown_clicked_cb ( self , src ) :
self . _config_boot_move ( False )
def _vm_inspection_changed_cb ( self , vm ) :
self . _refresh_os_page ( )