Opensuse Leap 15.3 Virtualization Guide Virtualization Guide Opensuse Leap 15.3
Total Page:16
File Type:pdf, Size:1020Kb
openSUSE Leap 15.3 Virtualization Guide Virtualization Guide openSUSE Leap 15.3 This guide describes virtualization technology in general. It introduces libvirt—the unied interface to virtualization—and provides detailed information on specic hypervisors. Publication Date: June 22, 2021 SUSE LLC 1800 South Novell Place Provo, UT 84606 USA https://documentation.suse.com Copyright © 2006– 2021 SUSE LLC and contributors. All rights reserved. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or (at your option) version 1.3; with the Invariant Section being this copyright notice and license. A copy of the license version 1.2 is included in the section entitled “GNU Free Documentation License”. For SUSE trademarks, see https://www.suse.com/company/legal/ . All other third-party trademarks are the property of their respective owners. Trademark symbols (®, ™ etc.) denote trademarks of SUSE and its aliates. Asterisks (*) denote third-party trademarks. All information found in this book has been compiled with utmost attention to detail. However, this does not guarantee complete accuracy. Neither SUSE LLC, its aliates, the authors nor the translators shall be held liable for possible errors or the consequences thereof. Contents Preface xvi 1 Available documentation xvi 2 Improving the documentation xvi 3 Documentation conventions xvii I INTRODUCTION 1 1 Virtualization technology 2 1.1 Overview 2 1.2 Virtualization benefits 2 1.3 Virtualization modes 3 1.4 I/O virtualization 4 2 Virtualization scenarios 6 2.1 Server consolidation 6 2.2 Isolation 7 2.3 Disaster recovery 7 2.4 Dynamic load balancing 7 3 Introduction to Xen virtualization 8 3.1 Basic components 8 3.2 Xen virtualization architecture 9 4 Introduction to KVM virtualization 11 4.1 Basic components 11 4.2 KVM virtualization architecture 11 iii Virtualization Guide 5 Virtualization tools 13 5.1 Virtualization console tools 13 5.2 Virtualization GUI tools 14 6 Installation of virtualization components 18 6.1 Specifying a system role 18 6.2 Running the yast2-vm module 19 Installing KVM 19 • Installing Xen 19 6.3 Patterns 20 6.4 Installing UEFI support 20 6.5 Enable nested virtualization in KVM 22 II MANAGING VIRTUAL MACHINES WITH libvirt 24 7 Starting and stopping libvirtd 25 8 Preparing the VM Host Server 27 8.1 Configuring networks 27 Network bridge 27 • Virtual networks 31 8.2 Configuring a storage pool 41 Managing storage with virsh 43 • Managing storage with Virtual Machine Manager 49 9 Guest installation 55 9.1 GUI-based guest installation 55 Configuring the virtual machine for PXE boot 57 9.2 Installing from the command line with virt-install 58 9.3 Advanced guest installation scenarios 60 Including add-on products in the installation 61 iv Virtualization Guide 10 Basic VM Guest management 62 10.1 Listing VM Guests 62 Listing VM Guests with Virtual Machine Manager 62 • Listing VM Guests with virsh 63 10.2 Accessing the VM Guest via console 63 Opening a graphical console 63 • Opening a serial console 65 10.3 Changing a VM Guest's state: start, stop, pause 66 Changing a VM Guest's state with Virtual Machine Manager 67 • Changing a VM Guest's state with virsh 67 10.4 Saving and restoring the state of a VM Guest 68 Saving/restoring with Virtual Machine Manager 69 • Saving and restoring with virsh 70 10.5 Creating and managing snapshots 70 Terminology 70 • Creating and managing snapshots with Virtual Machine Manager 71 • Creating and managing snapshots with virsh 73 10.6 Deleting a VM Guest 75 Deleting a VM Guest with Virtual Machine Manager 75 • Deleting a VM Guest with virsh 76 10.7 Migrating VM Guests 76 Migration requirements 76 • Migrating with Virtual Machine Manager 78 • Migrating with virsh 79 • Step-by-step example 81 10.8 Monitoring 83 Monitoring with Virtual Machine Manager 83 • Monitoring with virt- top 84 • Monitoring with kvm_stat 85 11 Connecting and authorizing 87 11.1 Authentication 87 libvirtd authentication 88 • VNC authentication 92 11.2 Connecting to a VM Host Server 96 “system” access for non-privileged users 97 • Managing connections with Virtual Machine Manager 98 v Virtualization Guide 11.3 Configuring remote connections 99 Remote tunnel over SSH (qemu+ssh or xen+ssh) 100 • Remote TLS/SSL connection with x509 certificate (qemu+tls or xen+tls) 100 12 Advanced storage topics 108 12.1 Locking disk files and block devices with virtlockd 108 Enable locking 108 • Configure locking 109 12.2 Online resizing of guest block devices 110 12.3 Sharing directories between host and guests (file system pass- through) 111 12.4 Using RADOS block devices with libvirt 112 13 Configuring virtual machines with Virtual Machine Manager 113 13.1 Machine setup 114 Overview 114 • Performance 115 • Processor 116 • Memory 117 • Boot options 118 13.2 Storage 119 13.3 Controllers 120 13.4 Networking 121 13.5 Input devices 123 13.6 Video 124 13.7 USB redirectors 126 13.8 Miscellaneous 126 13.9 Adding a CD/DVD-ROM device with Virtual Machine Manager 127 13.10 Adding a floppy device with Virtual Machine Manager 128 13.11 Ejecting and changing floppy or CD/DVD-ROM media with Virtual Machine Manager 129 vi Virtualization Guide 13.12 Assigning a host PCI device to a VM Guest 130 Adding a PCI device with Virtual Machine Manager 130 13.13 Assigning a host USB device to a VM Guest 131 Adding a USB device with Virtual Machine Manager 131 14 Configuring virtual machines with virsh 133 14.1 Editing the VM configuration 133 14.2 Changing the machine type 134 14.3 Configuring hypervisor features 135 14.4 Configuring CPU allocation 136 14.5 Changing boot options 137 Changing boot order 137 • Using direct kernel boot 138 14.6 Configuring memory allocation 138 14.7 Adding a PCI device 139 PCI Pass-Through for IBM Z 142 14.8 Adding a USB device 143 14.9 Adding SR-IOV devices 144 Requirements 144 • Loading and configuring the SR-IOV host drivers 145 • Adding a VF network device to a VM Guest 148 • Dynamic allocation of VFs from a pool 150 14.10 Listing attached devices 152 14.11 Configuring storage devices 153 14.12 Configuring controller devices 154 14.13 Configuring video devices 155 Changing the amount of allocated VRAM 155 • Changing the state of 2D/3D acceleration 156 14.14 Configuring network devices 156 Scaling network performance with multiqueue virtio-net 157 vii Virtualization Guide 14.15 Using macvtap to share VM Host Server network interfaces 157 14.16 Disabling a memory balloon device 159 14.17 Configuring multiple monitors (dual head) 159 14.18 Crypto adapter pass-through to KVM guests on IBM Z 160 Introduction 160 • What is covered 160 • Requirements 161 • Dedicate a crypto adapter to a KVM host 161 • Further reading 163 15 Managing virtual machines with Vagrant 164 15.1 Introduction to Vagrant 164 Vagrant concepts 164 • Vagrant example 165 15.2 Vagrant boxes for SUSE Linux Enterprise 165 15.3 Further reading 166 16 Xen to KVM migration guide 167 16.1 Migration to KVM using virt-v2v 167 Introduction to virt-v2v 167 • Installing virt-v2v 168 • Preparing the virtual machine 168 • Converting virtual machines to run under KVM managed by libvirt 169 • Running converted virtual machines 174 16.2 Xen to KVM manual migration 174 General outline 174 • Back up the Xen VM Guest 175 • Changes specific to paravirtualized guests 175 • Update the Xen VM Guest configuration 178 • Migrate the VM Guest 182 16.3 More information 183 III HYPERVISOR-INDEPENDENT FEATURES 184 17 Disk cache modes 185 17.1 Disk interface cache modes 185 17.2 Description of cache modes 185 17.3 Data integrity implications of cache modes 187 viii Virtualization Guide 17.4 Performance implications of cache modes 188 17.5 Effect of cache modes on live migration 188 18 VM Guest clock settings 189 18.1 KVM: using kvm_clock 189 Other timekeeping methods 190 18.2 Xen virtual machine clock settings 190 19 libguestfs 191 19.1 VM Guest manipulation overview 191 VM Guest manipulation risk 191 • libguestfs design 192 19.2 Package installation 192 19.3 Guestfs tools 193 Modifying virtual machines 193 • Supported file systems and disk images 193 • virt-rescue 194 • virt-resize 194 • Other virt-* tools 196 • guestfish 198 • Converting a physical machine into a KVM guest 199 19.4 Troubleshooting 201 Btrfs-related problems 201 • Environment 202 • libguestfs-test- tool 202 19.5 More information 202 20 QEMU guest agent 203 20.1 Running QEMU GA commands 203 20.2 virsh commands that require QEMU GA 203 20.3 Enhancing libvirt commands 204 20.4 More information 205 21 Software TPM emulator 206 21.1 Introduction 206 21.2 Prerequisites 206 ix Virtualization Guide 21.3 Installation 206 21.4 Using swtpm with QEMU 206 21.5 Using swtpm with libvirt 208 21.6 TPM measurement with OVMF firmware 208 21.7 Resources 208 IV MANAGING VIRTUAL MACHINES WITH XEN 209 22 Setting up a virtual machine host 210 22.1 Best practices and suggestions 210 22.2 Managing Dom0 memory 211 Setting Dom0 memory allocation 212 22.3 Network card in fully virtualized guests 212 22.4 Starting the virtual machine host 213 22.5 PCI Pass-Through 215 Configuring the hypervisor for PCI Pass-Through 215 • Assigning PCI devices to VM Guest systems 216 • VGA Pass- Through 217 • Troubleshooting 217 • More information 218 22.6 USB pass-through 218 Identify the USB device 219 • Emulated USB device 219 • Paravirtualized PVUSB 219 23 Virtual networking 222 23.1 Network devices for guest systems 222 23.2 Host-based routing in Xen 224 23.3 Creating a masqueraded network setup 227 23.4 Special configurations 229 Bandwidth