Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
KVM Virtualization Cookbook

You're reading from   KVM Virtualization Cookbook Learn how to use KVM effectively in production

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781788294676
Length 340 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Konstantin Ivanov Konstantin Ivanov
Author Profile Icon Konstantin Ivanov
Konstantin Ivanov
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Getting Started with QEMU and KVM FREE CHAPTER 2. Using libvirt to Manage KVM 3. KVM Networking with libvirt 4. Migrating KVM Instances 5. Monitoring and Backup of KVM Virtual Machines 6. Deploying KVM Instances with OpenStack 7. Using Python to Build and Manage KVM Instances 8. Kernel Tuning for KVM Performance

Connecting to a running instance with VNC

In this recipe, we are going to connect to a running KVM instance using a VNC client. Once connected, we are going to log in and check the CPU type and available memory of the instance. We've already seen how to start QEMU/KVM instances with VNC support in the previous recipes, but we are going to do it again, in case you are not reading this book from cover to cover.

Virtual Network Computing (VNC) uses the Remote Frame Buffer (RFB) protocol to remotely control another system. It relays the screen from the remote computer back to the client, allowing the full keyboard and mouse control.

There are many different VNC client and server implementations, but for this recipe, we are going to use a freely available version named chicken of the VNC for macOS. You can download the client from https://sourceforge.net/projects/cotvnc/.

Getting ready

In order to complete this recipe, you will need the following:

  • The QEMU binaries, provided after following the Installing and configuring QEMU recipe
  • The custom raw Debian image we built in the Installing a custom OS on the image with debootstrap recipe
  • A processor that supports virtualization
  • The loaded KVM kernel modules
  • The chicken of the VNC client, installed, as described in the previous section

How to do it...

  1. Start a new KVM-accelerated qemu instance:
root@kvm:~# qemu-system-x86_64 -name debian -vnc 146.20.141.254:0 -cpu Nehalem -m 1024 -drive format=raw,index=2,file=debian.img -daemonize    
root@kvm:~#

 

 

  1. Ensure that the instance is running:
root@kvm:~# pgrep -lfa qemu    
4987 qemu-system-x86_64 -name debian -vnc 146.20.141.254:0 -cpu Nehalem -m 1024 -drive format=raw,index=2,file=debian.img -daemonize
root@kvm:~#
  1. Start the VNC client and connect to the VNC server on the IP address and display port you specified in step 1:
The VNC login screen
  1. Log in to the instance using the root user, then check the CPU type and available memory as shown here:
VNC session

How it works...

In step 1, we started a new QEMU instance with KVM acceleration and enabled a VNC server on it with the specified IP address and display port. We specified the amount of available memory and the CPU model name.

In step 4, we logged in the instance using the root user and the password we created when building the image, then obtained the CPU information by running the lscpu command. Note how the CPU model name matches what we specified with the -cpu flag when we started the virtual machine. Next, we checked the allocated memory with the free command, which also matches what we previously specified with the -m parameter.

You have been reading a chapter from
KVM Virtualization Cookbook
Published in: Jun 2017
Publisher: Packt
ISBN-13: 9781788294676
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime