Breaking News

Main Menu

Libvirt Xml Serial Console

пятница 24 апреля admin 32

Hi

The virsh console domain -devname devicename -force -safe command connects the virtual serial console for the guest virtual machine. This is very useful.

I have used libvirt on Raspberry Pi Debian.

I can start the vm, but it just starts and doesn’t continue.

I find the qemu-system-arm command generated by virsh has a parameter “-S”, when I copy the command, remove the parameter, run it in the console, the vm can run normally.

But I don’t know how to remove the parameter in the xml file, or in virsh.

Regards

Thank you

Xu

Here’s the qemu-system-arm command, generated by libvirt:

LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/local/bin/qemu-system-arm -name test-S -machine vexpress-a15,accel=kvm,usb=off -cpu host -m 500 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid cab134ea-eed8-42e7-88cb-403ee2801e22 -nographic -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/test.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot menu=off,strict=on -kernel /home/pi/src/vexpress-zImage -append 'root=/dev/vda rw console=ttyAMA0' -dtb /home/pi/src/vexpress-v2p-ca15-tc1.dtb -usb -drive file=/home/pi/src/test.qcow2,if=none,id=drive-virtio-disk0,format=qcow2 -device virtio-blk-device,scsi=off,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive file=/home/pi/src/opensuse.img,if=none,media=cdrom,id=drive-virtio-disk1,readonly=on,format=raw -device virtio-blk-device,scsi=off,drive=drive-virtio-disk1,id=virtio-disk1 -net nic,macaddr=00:16:3e:5d:aa:a8,vlan=0,model=lan9118,name=net0 -net tap,fd=23,vlan=0,name=hostnet0 -serial file:/var/log/libvirt/qemu/console.log -serial pty -msg timestamp=on

Here’s my xml file:

<domain type='kvm'>

<name>test</name>

<uuid>cab134ea-eed8-42e7-88cb-403ee2801e22</uuid>

<memory unit='KiB'>512000</memory>

<currentMemory unit='KiB'>512000</currentMemory>

<vcpu placement='static'>1</vcpu>

<cputune>

<vcpupin vcpu='0' cpuset='3'/>

</cputune>

<os>

<type arch='armv7l' machine='vexpress-a15'>hvm</type>

<kernel>/home/pi/src/vexpress-zImage</kernel>

<cmdline>&quot;root=/dev/vda rw console=ttyAMA0&quot;</cmdline>

<dtb>/home/pi/src/vexpress-v2p-ca15-tc1.dtb</dtb>

<boot dev='hd'/>

<bootmenu enable='no'/>

</os>

<features>

<acpi/>

<apic/>

<pae/>

</features>

<cpu mode='host-model'>

<model fallback='allow'/>

</cpu>

Good value a1188 110w power supply for mac. <clock offset='utc'/>

<on_poweroff>destroy</on_poweroff>

<on_reboot>restart</on_reboot>

<on_crash>destroy</on_crash>

<devices>

<emulator>/usr/local/bin/qemu-system-arm</emulator>

<disk type='file' device='disk'>

<driver name='qemu' type='qcow2'/>

<source file='/home/pi/src/test.qcow2'/>

<target dev='hda' bus='virtio'/>

<address type='virtio-mmio'/>

</disk>

<disk type='file' device='cdrom'>

<driver name='qemu' type='raw'/>

<source file='/home/pi/src/opensuse.img'/>

<target dev='hdb' bus='virtio'/>

<readonly/>

<address type='virtio-mmio'/>

</disk>

<interface type='bridge'>

<mac address='00:16:3e:5d:aa:a8'/>

<source bridge='br0'/>

<model type='lan9118'/>

</interface>

<serial type='file'>

<source path='/var/log/libvirt/qemu/console.log'/>

Virsh

<target port='0'/>

</serial>

<serial type='pty'>

<target port='1'/>

</serial>

<console type='file'>

<source path='/var/log/libvirt/qemu/console.log'/>

<target type='serial' port='0'/>

</console>

</devices>

</domain>

Contents.Error 'internal error cannot find character device' when trying to connect a domain's console Symptom% virsh console test2Connected to domain test2Escape character is ^error: internal error cannot find character device (null)InvestigationThe error tells there is no serial console configured for the domain.SolutionSetup serial console in the domain's XML.1) Add the following XML in domain's XML (using 'virsh edit')2) Setup console in guest kernel command line, you can login into the guest to edit /boot/grub/grub.conf directly, or using tool 'virt-edit'. Append followingto the guest kernel command line:console=ttyS0,1152003)% virsh start vm && virsh console vm.