我有一个虚拟设备(qcow2映像),它需要VM上的串行控制台。换句话说,我不需要安装任何东西。我只需要从这个qcow2磁盘启动VM并通过串行接口访问虚拟设备。用virt-install可以做到这一点吗?当我将--extra-args="console=ttyS0,115200"添加到virt-install时,它要求我指定一个--location。是否存在使用virt-install启动串行启用但没有指定分发树安装源的虚拟机的解决办法?
发布于 2018-10-01 17:58:23
是的,这是可能的,尽管添加串行控制台有多个步骤。
--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).在实践中,添加如下内容(在现代Linux系统上):
--console pty,target_type=virtio Note__:您可以在这里获得关于可用配置的更多选项:https://libvirt.org/formatdomain.html#elementsConsole
由于我已经准备了一个基于QCOW2的设备,所以我能够对其进行如下测试:
virt-install --name thing --memory 512 \
--console pty,target_type=virtio --disk appliance.qcow2 --boot hd在幕后,这将对“域”(存储主机配置的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>如果这不起作用,还可以通过使用guestfish(链接)这样的工具编辑设备内部的引导选项,或者指定内核initrd的位置,并手动使用--boot提供这些选项。在游鱼的例子中,甚至有一个实现你想要的东西的方法:食谱:在VM中编辑grub配置。
--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.https://unix.stackexchange.com/questions/471097
复制相似问题