[virt-tools-list] How to set console correctly to redirect log when using "virt-install" to install guest OS?
Cole Robinson
crobinso at redhat.com
Tue Sep 22 16:51:42 UTC 2015
On 09/22/2015 06:20 AM, Nan Xiao wrote:
> 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!
>
Thanks for the report. That's a bug: console_type is None if using xen.
Unfortunately the test suite doesn't hit this code path because we don't enter
this function if --noautoconsole is set, and the test suite basically always
uses that.
Anyways I've fixed it in virt-manager.git now:
commit 601a82cb87ebc055ba9dd52864317bd513613814
Author: Cole Robinson <crobinso at redhat.com>
Date: Tue Sep 22 08:42:09 2015 -0400
virt-install: Simplify --extra-args text install warnings
- Drop the warnings about incorrect console=, that's a little too fine
grained and was really only about virtio-console default confusion
which doesn't apply anymore
- Skip the check for xenpv which seems to always 'just work'
- Drop the opencoded arm check, use is_arm
- Fix an error when xen HVM is used (reported on virt-tools-list)
Please give that a spin and confirm it fixes your issue:
git clone git://github.com/virt-manager/virt-manager
cd virt-manager
./virt-install ...
Thanks,
Cole
More information about the virt-tools-list
mailing list