guest: Absorb more default device checks

This commit is contained in:
Cole Robinson 2013-10-06 08:30:33 -04:00
parent 4911cb990e
commit dae3678d26
3 changed files with 16 additions and 12 deletions

View File

@ -529,17 +529,10 @@ def build_guest_instance(conn, options):
cli.get_tpms(guest, options.tpm)
cli.get_rngs(guest, options.rng)
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_default_video_device()
do_default_usb = all([d.type != "usb" for d in
guest.get_devices("controller")])
if do_default_usb:
guest.add_default_usb_controller()
guest.add_default_input_device()
guest.add_default_console_device()
guest.add_default_video_device()
guest.add_default_usb_controller()
# Install options
cli.set_os_variant(guest, options.distro_type, options.distro_variant)

View File

@ -1488,8 +1488,8 @@ class vmmCreate(vmmGObjectUI):
gdev = self.get_graphics_device(guest)
if gdev:
guest.add_device(gdev)
guest.add_default_video_device()
guest.add_default_video_device()
guest.add_default_input_device()
guest.add_default_console_device()
if self.config.get_new_vm_sound():

View File

@ -507,6 +507,8 @@ class Guest(XMLBuilder):
return
if not self.os.is_x86():
return
if self.get_devices("input"):
return
self.add_device(virtinst.VirtualInputDevice(self.conn))
def add_default_sound_device(self):
@ -519,6 +521,9 @@ class Guest(XMLBuilder):
def add_default_console_device(self):
if self.os.is_xenpv():
return
if self.get_devices("console") or self.get_devices("serial"):
return
dev = virtinst.VirtualConsoleDevice(self.conn)
dev.type = dev.TYPE_PTY
self.add_device(dev)
@ -526,6 +531,10 @@ class Guest(XMLBuilder):
def add_default_video_device(self):
if self.os.is_container():
return
if self.get_devices("video"):
return
if not self.get_devices("graphics"):
return
self.add_device(virtinst.VirtualVideoDevice(self.conn))
def add_default_usb_controller(self):
@ -533,6 +542,8 @@ class Guest(XMLBuilder):
return
if not self.os.is_x86():
return
if any([d.type == "usb" for d in self.get_devices("controller")]):
return
if not self.conn.check_conn_support(
self.conn.SUPPORT_CONN_DEFAULT_USB2):
return