[virt-tools-list] How to open the graphical console from the command line

Pavel Hrdina phrdina at redhat.com
Wed Jul 18 09:58:55 UTC 2018


On Tue, Jul 17, 2018 at 04:46:00PM +0200, R. Diez wrote:
> Hi there:
> 
> I am a newbie with KVM. Every day, I normally start virt-manager, select my
> one and only virtual machine, click on the "Start" toolbar button, and then
> click on the "Open" toolbar icon. I finally close virt-manager, and only
> keep the other window with the graphical console. That's too many mouse
> clicks.
> 
> I would like to start and open the virtual machine graphical console with a
> single mouse click.
> 
> I can issue command "virsh start UbuntuMATE1804" to start the virtual
> machine, and I can issue command "virt-viewer UbuntuMATE1804" to open the
> graphical console. However, that graphical console is not exactly the same
> as the one that virt-manager opens. For example, it lacks the "Virtual
> Machine" menu.
> 
> It seems that virt-manager launches a process like this:
> 
> /usr/bin/qemu-system-x86_64 -name UbuntuMATE1804 -S -machine
> pc-i440fx-xenial,accel=kvm,usb=off -cpu Opteron_G5 -m 4096 -realtime
> mlock=off - (text cut off by ps)
> 
> Is there any way to get virt-manager or something else to create or start
> such a qemu command for me? Ideally, the script would also check whether the
> virtual machine is already running, and not try to start it if it is.

Hi,

So to make clarify some things for you, creating QEMU command line is
not simple.

Virt-manager is GUI application written in python that communicates with
libvirt (virtualization library) using libvirt-python APIs.

Virsh is a CLI that is written in C and communicates with libvirt using
directly C API.

Libvirt itself is a virtualization library that offers APIs to manage
and run virtual machines and libvirt is the one that creates the command
line and starts the QEMU process.

Virt-viewer is yet another project that is using again libvirt API in
order to open console for your virtual machines.

Now to answer your question, there is no other simple way how to create
and start the QEMU process unless you want to do it manually which I
would not recommend, the best for you is to stick with libvirt.

To automate it you can create a script looking like this:

virsh --connect qemu:///system start UbuntuMATE1804
virt-manager --connect qemu:///system --show-domain-console UbuntuMATE1804


If you notice, in order to directly open the console you need to specify
connection as well because virt-manager can be configured to use
multiple connections and there is no thing as default connection.  Virsh
also has the same parameter but it has some default connection which is
most likely the same but since it will be one script you can configure
the same connection for virsh as well.

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20180718/36bb9db8/attachment.sig>


More information about the virt-tools-list mailing list