mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-20 22:50:16 +03:00
guest: Add single entry point for adding default devices
This commit is contained in:
parent
96c260199d
commit
2ffd5a66e6
@ -20,6 +20,16 @@
|
||||
<source file="/tmp/__virtinst__cli_scratch.raw"/>
|
||||
<target dev="xvdc" bus="xen"/>
|
||||
</disk>
|
||||
<controller type="usb" index="0" model="ich9-ehci1"/>
|
||||
<controller type="usb" index="0" model="ich9-uhci1">
|
||||
<master startport="0"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci2">
|
||||
<master startport="2"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci3">
|
||||
<master startport="4"/>
|
||||
</controller>
|
||||
<interface type="user">
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
</interface>
|
||||
|
@ -23,6 +23,16 @@
|
||||
<source file="/tmp/__virtinst__cli_root.raw"/>
|
||||
<target dev="hda" bus="ide"/>
|
||||
</disk>
|
||||
<controller type="usb" index="0" model="ich9-ehci1"/>
|
||||
<controller type="usb" index="0" model="ich9-uhci1">
|
||||
<master startport="0"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci2">
|
||||
<master startport="2"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci3">
|
||||
<master startport="4"/>
|
||||
</controller>
|
||||
<interface type="user">
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<model type="e1000"/>
|
||||
|
@ -20,6 +20,16 @@
|
||||
<source file="/tmp/__virtinst__cli_scratch.raw"/>
|
||||
<target dev="xvdc" bus="xen"/>
|
||||
</disk>
|
||||
<controller type="usb" index="0" model="ich9-ehci1"/>
|
||||
<controller type="usb" index="0" model="ich9-uhci1">
|
||||
<master startport="0"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci2">
|
||||
<master startport="2"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci3">
|
||||
<master startport="4"/>
|
||||
</controller>
|
||||
<interface type="user">
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
</interface>
|
||||
|
@ -25,7 +25,6 @@ import sys
|
||||
|
||||
import urlgrabber.progress as progress
|
||||
|
||||
import virtinst
|
||||
import virtinst.cli as cli
|
||||
from virtinst.cli import fail, print_stdout, print_stderr
|
||||
from virtinst import virtimage
|
||||
@ -124,12 +123,7 @@ def main(conn=None):
|
||||
|
||||
cli.parse_option_strings(parsermap, options, guest, None)
|
||||
|
||||
if not guest.get_devices("input"):
|
||||
guest.add_default_input_device()
|
||||
if not guest.get_devices("console") and not guest.get_devices("serial"):
|
||||
guest.add_default_console_device()
|
||||
if not guest.get_devices("video") and guest.get_devices("graphics"):
|
||||
guest.add_device(virtinst.VirtualVideoDevice(guest.conn))
|
||||
guest.add_default_devices()
|
||||
|
||||
# we've got everything -- try to start the install
|
||||
if options.xmlonly:
|
||||
|
@ -470,11 +470,7 @@ def build_guest_instance(conn, options, parsermap):
|
||||
for disk in guest.get_devices("disk"):
|
||||
cli.validate_disk(disk)
|
||||
|
||||
guest.add_default_input_device()
|
||||
guest.add_default_console_device()
|
||||
guest.add_default_video_device()
|
||||
guest.add_default_usb_controller()
|
||||
guest.add_default_channels()
|
||||
guest.add_default_devices()
|
||||
|
||||
get_install_media(guest, options.location, options.cdrom)
|
||||
|
||||
|
@ -1345,15 +1345,6 @@ class vmmCreate(vmmGObjectUI):
|
||||
page = self.widget("create-pages").get_nth_page(nr)
|
||||
page.set_visible(nr == pagenum)
|
||||
|
||||
def get_graphics_device(self, guest):
|
||||
if guest.os.is_container():
|
||||
return
|
||||
if guest.os.arch not in ["x86_64", "i686", "ppc64"]:
|
||||
return
|
||||
|
||||
guest.default_graphics_type = self.config.get_graphics_type()
|
||||
return virtinst.VirtualGraphics(guest.conn)
|
||||
|
||||
def build_guest(self, variant):
|
||||
guest = self.conn.caps.build_virtinst_guest(
|
||||
self.conn.get_backend(), self.capsguest, self.capsdomain)
|
||||
@ -1376,25 +1367,14 @@ class vmmCreate(vmmGObjectUI):
|
||||
|
||||
# Set up default devices
|
||||
try:
|
||||
gdev = self.get_graphics_device(guest)
|
||||
if gdev:
|
||||
guest.add_device(gdev)
|
||||
|
||||
if self.config.get_new_vm_sound():
|
||||
guest.add_default_sound_device()
|
||||
else:
|
||||
guest.skip_default_sound = True
|
||||
|
||||
guest.default_graphics_type = self.config.get_graphics_type()
|
||||
guest.skip_default_sound = not self.config.get_new_vm_sound()
|
||||
guest.skip_default_usbredir = (
|
||||
self.config.get_add_spice_usbredir() == "no")
|
||||
guest.x86_cpu_default = self.config.get_default_cpu_setting(
|
||||
for_cpu=True)
|
||||
|
||||
guest.add_default_video_device()
|
||||
guest.add_default_input_device()
|
||||
guest.add_default_console_device()
|
||||
guest.add_default_usb_controller()
|
||||
guest.add_default_channels()
|
||||
guest.add_default_devices()
|
||||
|
||||
if self.conn.check_support(self.conn.SUPPORT_CONN_PM_DISABLE):
|
||||
guest.pm.suspend_to_mem = False
|
||||
|
@ -390,20 +390,14 @@ def convert_old_networks(options, number_of_default_nics):
|
||||
|
||||
def _determine_default_graphics(guest, default_override):
|
||||
if default_override is True:
|
||||
return "default"
|
||||
return
|
||||
elif default_override is False:
|
||||
return "none"
|
||||
|
||||
if guest.os.is_container():
|
||||
logging.debug("Container guest, defaulting to nographics")
|
||||
return "none"
|
||||
guest.skip_default_graphics = True
|
||||
return
|
||||
|
||||
if "DISPLAY" not in os.environ.keys():
|
||||
logging.debug("DISPLAY is not set: defaulting to nographics.")
|
||||
return "none"
|
||||
|
||||
logging.debug("DISPLAY is set: using default graphics")
|
||||
return "default"
|
||||
guest.skip_default_graphics = True
|
||||
|
||||
|
||||
def convert_old_graphics(guest, options, default_override=None):
|
||||
@ -427,8 +421,7 @@ def convert_old_graphics(guest, options, default_override=None):
|
||||
return
|
||||
|
||||
if optnum == 0:
|
||||
options.graphics = [_determine_default_graphics(guest,
|
||||
default_override)]
|
||||
_determine_default_graphics(guest, default_override)
|
||||
return
|
||||
|
||||
# Build a --graphics command line from old style opts
|
||||
@ -1644,7 +1637,6 @@ class ParserGraphics(VirtCLIParser):
|
||||
def _init_params(self):
|
||||
self.devclass = virtinst.VirtualGraphics
|
||||
self.remove_first = "type"
|
||||
self.check_none = True
|
||||
|
||||
def set_keymap_cb(opts, inst, cliname, val):
|
||||
ignore = opts
|
||||
@ -1680,6 +1672,12 @@ class ParserGraphics(VirtCLIParser):
|
||||
self.set_param("passwdValidTo", "passwordvalidto")
|
||||
self.set_param("connected", "connected")
|
||||
|
||||
def _parse(self, opts, inst):
|
||||
if opts.fullopts == "none":
|
||||
self.guest.skip_default_graphics = True
|
||||
return
|
||||
return VirtCLIParser._parse(self, opts, inst)
|
||||
|
||||
|
||||
########################
|
||||
# --controller parsing #
|
||||
|
@ -109,6 +109,7 @@ class Guest(XMLBuilder):
|
||||
self.skip_default_channel = False
|
||||
self.skip_default_sound = False
|
||||
self.skip_default_usbredir = False
|
||||
self.skip_default_graphics = False
|
||||
self.x86_cpu_default = self.cpu.SPECIAL_MODE_HOST_MODEL_ONLY
|
||||
|
||||
self._os_variant = None
|
||||
@ -586,6 +587,25 @@ class Guest(XMLBuilder):
|
||||
dev.target_name = dev.CHANNEL_NAME_QEMUGA
|
||||
self.add_device(dev)
|
||||
|
||||
def add_default_graphics(self):
|
||||
if self.skip_default_graphics:
|
||||
return
|
||||
if self.get_devices("graphics"):
|
||||
return
|
||||
if self.os.is_container():
|
||||
return
|
||||
if self.os.arch not in ["x86_64", "i686", "ppc64", "ia64"]:
|
||||
return
|
||||
self.add_device(virtinst.VirtualGraphics(self.conn))
|
||||
|
||||
def add_default_devices(self):
|
||||
self.add_default_graphics()
|
||||
self.add_default_video_device()
|
||||
self.add_default_input_device()
|
||||
self.add_default_console_device()
|
||||
self.add_default_usb_controller()
|
||||
self.add_default_channels()
|
||||
|
||||
def _set_transient_device_defaults(self, install):
|
||||
def do_remove_media(d):
|
||||
# Keep cdrom around, but with no media attached,
|
||||
|
Loading…
x
Reference in New Issue
Block a user