AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 471097
Accepted
Martin
Martin
Asked: 2018-09-25 06:35:53 +0800 CST2018-09-25 06:35:53 +0800 CST 2018-09-25 06:35:53 +0800 CST

使用 virt-install 在虚拟机上为虚拟设备配置串行控制台

  • 772

我有一个虚拟设备(qcow2图像),它需要 VM 上的串行控制台。换句话说,我不需要安装任何东西。我只需要从这个qcow2磁盘启动虚拟机并通过串行接口访问虚拟设备。有可能做到这一点virt-install吗?当我添加--extra-args="console=ttyS0,115200"tovirt-install时,它需要我指定一个--location. 是否有解决方法可以使用 启动启用串行的虚拟机virt-install,但不指定分发树安装源?

qemu libvirt
  • 1 1 个回答
  • 6243 Views

1 个回答

  • Voted
  1. Best Answer
    Brian Redbeard
    2018-10-02T09:58:23+08:002018-10-02T09:58:23+08:00

    是的,这是可能的,尽管添加串行控制台有多个步骤。

    --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 
    

    注意:您可以在此处获得有关可用配置的更多选项: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>
    

    如果这不起作用,您还可以通过使用( link ) 之类的工具编辑设备内的引导选项或通过指定内核的位置 initrd 并手动提供选项来实现此目的。在 guestfish 的情况下,甚至有一个方法可以实现您正在寻找的东西:guestfish-recipies:在 VM 中编辑 grub 配置。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.
    
    • 5

相关问题

  • KVM:无法销毁 VM(权限被拒绝) - AppArmor 阻止 Libvirt

  • QEMU-KVM 来宾 rootfs 只读问题

  • QEMU 4个以上的串口

  • 在 MIPS 上运行为 IRIX 制作的旧程序的方法?

  • 为什么 KVM/QEMU 中的 vm 称为域?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    ssh 无法协商:“找不到匹配的密码”,正在拒绝 cbc

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    如何卸载内核模块“nvidia-drm”?

    • 13 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Wong Jia Hau ssh-add 返回:“连接代理时出错:没有这样的文件或目录” 2018-08-24 23:28:13 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve