virt-install を使用した仮想マシンの仮想デバイスのシリアルコンソールの構成

virt-install を使用した仮想マシンの仮想デバイスのシリアルコンソールの構成

qcow2仮想マシンにシリアルコンソールが必要な仮想デバイス(イメージ)があります。つまり、何もインストールする必要はありません。そのディスクから仮想マシンを起動し、qcow2シリアルインターフェイスを介して仮想デバイスにアクセスします。これを行うために使用できますかvirt-install--extra-args="console=ttyS0,115200"に追加すると、virt-installを指定するように求められます--locationvirt-install展開ツリーのインストールソースを指定せずにシリアルサポート仮想マシンの起動を使用する回避策はありますか?

ベストアンサー1

はい、可能です。ただし、シリアルコンソールを追加するにはいくつかの手順が必要です。

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

それでも機能しない場合は、スタートアップオプションを編集してこれを行うこともできます。~へ同様のツールを備えた機器guestfish協会)またはカーネルの場所initrdを指定し、手動で提供されるオプションを使用します--boot。お客さまの魚の場合、欲しいものを達成できるレシピもあります。guestfish-recipies: 仮想マシンで 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.

おすすめ記事