[virt-tools-list] How to set console correctly to redirect log when using "virt-install" to install guest OS?

Nan Xiao xiaonan830818 at gmail.com
Tue Sep 22 10:20:55 UTC 2015


Hi all,

I want to use "virt-install" command to create a virtual machine, and
output the log from the
console. The command is like this:

virt-install \
--name opensuse12 \
--ram 1024 \
--disk path=./opensuse12.qcow2,size=8 \
--vcpus 1 \
--os-type linux \
--os-variant generic \
--network bridge=virbr0 \
--graphics none \
--console 'pty,target_type=serial' \
--location 'http://download.opensuse.org/distribution/12.3/repo/oss/' \
--extra-args 'console=ttyS0' \
-d



The execution result is:

......
[Tue, 22 Sep 2015 06:13:20 virt-install 9309] ERROR (cli:296) 'in
<string>' requires string as left operand, not NoneType
[Tue, 22 Sep 2015 06:13:20 virt-install 9309] DEBUG (cli:298)
Traceback (most recent call last):
 File "/usr/share/virt-manager/virt-install", line 1084, in <module>
sys.exit(main())
 File "/usr/share/virt-manager/virt-install", line 1069, in main
guest = build_guest_instance(conn, options, parsermap)
 File "/usr/share/virt-manager/virt-install", line 651, in build_guest_instance
show_warnings(options, guest)
 File "/usr/share/virt-manager/virt-install", line 556, in show_warnings
_show_nographics_warnings(options, guest)
 File "/usr/share/virt-manager/virt-install", line 531, in
_show_nographics_warnings
if console_type in options.extra_args:
TypeError: 'in <string>' requires string as left operand, not NoneType


>From the virt-install source code:

def _show_nographics_warnings(options, guest):
......
    serial_arg = "console=ttyS0"
    serial_arm_arg = "console=ttyAMA0"
    virtio_arg = "console=hvc0"
    console_type = None
    if guest.conn.is_test() or guest.conn.is_qemu():
        console_type = serial_arg
        if guest.os.arch.startswith("arm") or guest.os.arch == "aarch64":
            console_type = serial_arm_arg
        if guest.get_devices("console")[0].target_type == "virtio":
            console_type = virtio_arg

    if not options.extra_args or "console=" not in options.extra_args:
        logging.warn(_("No 'console' seen in --extra-args, a '%s' kernel "
            "argument is likely required to see text install output from "
            "the guest."), console_type or "console=")
        return

    if console_type in options.extra_args:
        return
......

I can see since console_type is "None", so the function will return directly.


So I am confused how to set console correctly to redirect the log like
host machine?

Thanks very much in advance!

Best Regards
Nan Xiao




More information about the virt-tools-list mailing list