我有一个虚拟设备(qcow2图像),它需要在 VM 上使用串行控制台。换句话说,我不需要安装任何东西。我只需要从这个qcow2磁盘启动虚拟机并通过串行接口访问虚拟设备。有可能做到这一点virt-install吗?当我添加--extra-args="console=ttyS0,115200"to 时virt-install,它需要我指定一个--location. 是否有解决方法来启动启用了串行的虚拟机virt-install,但未指定分发树安装源?
是的,这是可能的,尽管添加串行控制台有多个步骤。
--extra-args只能与 结合使用--location。当您从本地qcow2磁盘映像工作时,--location实际上并不是您正在寻找的机制。
相反,您正在寻找 --console:
--console
Connect a text console between the guest and host. Certain guest and
hypervisor combinations can automatically set up a getty in the guest, so an
out of the box text login can be provided (target_type=xen for xen paravirt
guests, and possibly target_type=virtio in the future).
Run Code Online (Sandbox Code Playgroud)
在实践中,添加如下(在现代 Linux 系统上):
--console pty,target_type=virtio
Run Code Online (Sandbox Code Playgroud)
注意:您可以在此处获得有关可用配置的更多选项:https : //libvirt.org/formatdomain.html#elementsConsole
由于我已经准备了基于 QCOW2 的设备,因此我可以按如下方式进行测试:
virt-install --name thing --memory 512 \
--console pty,target_type=virtio --disk appliance.qcow2 --boot hd
Run Code Online (Sandbox Code Playgroud)
在幕后,这是对“域”(一个存储主机配置的 XML 文件)执行一些添加操作。例如:
<controller type='virtio-serial' index='0'>
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</controller>
<console type='pty' tty='/dev/pts/14'>
<source path='/dev/pts/14'/>
<target type='virtio' port='0'/>
<alias name='console0'/>
</console>
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,您还可以通过使用类似( link )的工具编辑组件内的引导选项或通过指定内核的位置 initrd 并使用 手动提供选项来实现此目的。在 guestfish 的情况下,甚至有一个方法可以实现您正在寻找的内容:guestfish-recipies: Edit grub configuration in a VM。guestfish--boot
--boot
Optionally specify the post-install VM boot configuration. This option
allows specifying a boot device order, permanently booting off
kernel/initrd with option kernel arguments, and enabling a BIOS boot menu
(requires libvirt 0.8.3 or later)
--boot kernel=KERNEL,initrd=INITRD,kernel_args="console=/dev/ttyS0"
Have guest permanently boot off a local kernel/initrd pair, with the
specified kernel options.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4451 次 |
| 最近记录: |