mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-09 08:58:27 +03:00
virt-install: If virt-viewer will fail, default to --wait -1
This can happen if user requests explicit --graphics, but they are on a headless display. We had a few reports of this recently.
This commit is contained in:
parent
85161e4c57
commit
1f3f3fa4fc
@ -96,7 +96,6 @@ def main(conn=None):
|
||||
options.dry = True
|
||||
options.quiet = True
|
||||
|
||||
conscb = options.autoconsole and cli.show_console_for_guest or None
|
||||
print_cb = print_stdout
|
||||
if options.quiet:
|
||||
print_cb = None
|
||||
@ -109,6 +108,10 @@ def main(conn=None):
|
||||
|
||||
guest = converter.get_guest()
|
||||
|
||||
conscb = None
|
||||
if options.autoconsole:
|
||||
conscb = cli.get_console_cb(guest) or None
|
||||
|
||||
if options.xmlonly:
|
||||
print_stdout(guest.start_install(return_xml=True)[1],
|
||||
do_force=True)
|
||||
|
32
virt-install
32
virt-install
@ -675,9 +675,10 @@ def start_install(guest, continue_inst, options):
|
||||
# waiting. Otherwise, we can exit before the domain has finished
|
||||
# installing. Passing --wait will give the above semantics.
|
||||
#
|
||||
wait_on_install = continue_inst
|
||||
wait_time = -1
|
||||
if options.wait is not None:
|
||||
if options.wait is None:
|
||||
wait_on_install = continue_inst
|
||||
wait_time = -1
|
||||
else:
|
||||
wait_on_install = True
|
||||
wait_time = options.wait * 60
|
||||
|
||||
@ -686,10 +687,25 @@ def start_install(guest, continue_inst, options):
|
||||
# expires
|
||||
wait_on_console = not wait_on_install
|
||||
|
||||
# --wait 0 implies --noautoconsole
|
||||
options.autoconsole = (wait_time != 0) and options.autoconsole or False
|
||||
if wait_time == 0:
|
||||
# --wait 0 implies --noautoconsole
|
||||
autoconsole = False
|
||||
else:
|
||||
autoconsole = options.autoconsole
|
||||
|
||||
conscb = None
|
||||
if autoconsole:
|
||||
conscb = cli.get_console_cb(guest)
|
||||
if not conscb:
|
||||
# If there isn't any console to actually connect up,
|
||||
# default to --wait -1 to get similarish behavior
|
||||
autoconsole = False
|
||||
if options.wait is None:
|
||||
logging.warning(_("No console to launch for the guest, "
|
||||
"defaulting to --wait -1"))
|
||||
wait_on_install = True
|
||||
wait_time = -1
|
||||
|
||||
conscb = options.autoconsole and cli.show_console_for_guest or None
|
||||
meter = (options.quiet and
|
||||
progress.BaseMeter() or
|
||||
progress.TextMeter(fo=sys.stdout))
|
||||
@ -790,9 +806,9 @@ def check_domain(guest, dom, conscb, wait_for_install, wait_time, start_time):
|
||||
sys.exit(0)
|
||||
|
||||
timestr = (not wait_forever and
|
||||
_("%d minutes ") % (int(wait_time) / 60) or "")
|
||||
_(" %d minutes") % (int(wait_time) / 60) or "")
|
||||
print_stdout(
|
||||
_("Domain installation still in progress. Waiting "
|
||||
_("Domain installation still in progress. Waiting"
|
||||
"%(time_string)s for installation to complete.") %
|
||||
{"time_string": timestr})
|
||||
|
||||
|
@ -383,12 +383,8 @@ def _gfx_console(guest):
|
||||
"--connect", guest.conn.uri,
|
||||
"--wait", guest.name]
|
||||
|
||||
if not os.path.exists(args[0]):
|
||||
logging.warn(_("Unable to connect to graphical console: "
|
||||
"virt-viewer not installed. Please install "
|
||||
"the 'virt-viewer' package."))
|
||||
return None
|
||||
|
||||
logging.debug("Launching virt-viewer for graphics type '%s'",
|
||||
guest.get_devices("graphics")[0].type)
|
||||
return _run_console(args)
|
||||
|
||||
|
||||
@ -397,6 +393,7 @@ def _txt_console(guest):
|
||||
"--connect", guest.conn.uri,
|
||||
"console", guest.name]
|
||||
|
||||
logging.debug("Connecting to text console")
|
||||
return _run_console(args)
|
||||
|
||||
|
||||
@ -419,22 +416,31 @@ def connect_console(guest, consolecb, wait):
|
||||
logging.debug("waitpid: %s: %s", e.errno, e.message)
|
||||
|
||||
|
||||
def show_console_for_guest(guest):
|
||||
gdev = guest.get_devices("graphics")
|
||||
if not gdev:
|
||||
logging.debug("Connecting to text console")
|
||||
return _txt_console(guest)
|
||||
def get_console_cb(guest):
|
||||
gdevs = guest.get_devices("graphics")
|
||||
if not gdevs:
|
||||
return _txt_console
|
||||
|
||||
gtype = gdev[0].type
|
||||
if gtype in ["default",
|
||||
VirtualGraphics.TYPE_VNC,
|
||||
VirtualGraphics.TYPE_SPICE]:
|
||||
logging.debug("Launching virt-viewer for graphics type '%s'", gtype)
|
||||
return _gfx_console(guest)
|
||||
else:
|
||||
gtype = gdevs[0].type
|
||||
if gtype not in ["default",
|
||||
VirtualGraphics.TYPE_VNC,
|
||||
VirtualGraphics.TYPE_SPICE]:
|
||||
logging.debug("No viewer to launch for graphics type '%s'", gtype)
|
||||
return
|
||||
|
||||
if not os.path.exists("/usr/bin/virt-viewer"):
|
||||
logging.warn(_("Unable to connect to graphical console: "
|
||||
"virt-viewer not installed. Please install "
|
||||
"the 'virt-viewer' package."))
|
||||
return None
|
||||
|
||||
if not os.environ.get("DISPLAY", ""):
|
||||
logging.warn(_("Graphics requested but DISPLAY is not set. "
|
||||
"Not running virt-viewer."))
|
||||
return None
|
||||
|
||||
return _gfx_console
|
||||
|
||||
|
||||
###########################
|
||||
# Common CLI option/group #
|
||||
|
Loading…
x
Reference in New Issue
Block a user