Professional Xen® Virtualization
Total Page:16
File Type:pdf, Size:1020Kb
Professional Xen® Virtualization William von Hagen Wiley Publishing, Inc. fffirs.inddfirs.indd iiiiii 112/14/072/14/07 44:35:46:35:46 PPMM fffirs.inddfirs.indd iiii 112/14/072/14/07 44:35:46:35:46 PPMM Professional Xen® Virtualization Acknowledgments .........................................................................................ix Introduction ................................................................................................ xix Chapter 1: Overview of Virtualization .............................................................. 1 Chapter 2: Introduction to Xen ..................................................................... 27 Chapter 3: Obtaining and Installing Xen........................................................ 57 Chapter 4: Booting and Configuring a Xen Host ............................................ 87 Chapter 5: Configuring and Booting Virtual Machines ................................. 117 Chapter 6: Building Filesystems for Virtual Machines ................................. 141 Chapter 7: Managing and Monitoring Virtual Machines ............................... 175 Chapter 8: Xen Networking ........................................................................ 201 Chapter 9: Advanced Virtual Machine Configuration ................................... 231 Chapter 10: Using Xen in the Data Center .................................................. 283 Appendix A: xm Command and Option Reference ........................................ 339 Appendix B: Xen Virtual Machine Configuration File Reference ................... 383 Index ........................................................................................................ 391 fffirs.inddfirs.indd i 112/14/072/14/07 44:35:45:35:45 PPMM fffirs.inddfirs.indd iiii 112/14/072/14/07 44:35:46:35:46 PPMM Professional Xen® Virtualization William von Hagen Wiley Publishing, Inc. fffirs.inddfirs.indd iiiiii 112/14/072/14/07 44:35:46:35:46 PPMM Professional Xen® Virtualization Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-13811-3 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data is available from the publisher. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Xen is a registered trademark of XenSource, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. fffirs.inddfirs.indd iivv 112/14/072/14/07 44:35:47:35:47 PPMM For Dorothy, my wife and best friend. As always, and forever. fffirs.inddfirs.indd v 112/14/072/14/07 44:35:47:35:47 PPMM About the Author William von Hagen (Bill) has been a UNIX system administrator for over 20 years and a Linux fanatic since the early 1990s. He has worked as a systems programmer, system administrator, writer, applications developer, drummer, and documentation manager. Bill has written or co-written books on such topics as Ubuntu Linux, GCC, Linux server hacks, Linux filesystems, SUSE Linux, Red Hat Linux, SGML, Mac OS X, and hacking the TiVo. He has also written numerous articles on Linux, embedded computing, Mac OS X, Unix, and open source technology. fffirs.inddfirs.indd vvii 112/14/072/14/07 44:35:47:35:47 PPMM Credits Acquisitions Editor Production Manager Jenny Watson Tim Tate Senior Development Editor Vice President and Executive Group Publisher Tom Dinse Richard Swadley Technical Editors Vice President and Executive Publisher Dan Magenheimer Joseph B. Wikert Richard Artz Project Coordinator, Cover Production Editor Lynsey Stanford Eric Charbonneau Proofreader Copy Editor Kathryn Duggan Nancy Rapoport Indexer Editorial Manager Johnna VanHoose Dinse Mary Beth Wakefield fffirs.inddfirs.indd vviiii 112/14/072/14/07 44:35:47:35:47 PPMM fffirs.inddfirs.indd vviiiiii 112/14/072/14/07 44:35:47:35:47 PPMM Acknowledgments First, I’d like to thank my wife and best friend forever, Dorothy Fisher, who has been more supportive than any human could be expected to be. Fish, the best day of my life was the day I met you! There’s no way to thank you enough for the life that I have today. Next, friends like Jim Morgan, Dr. Joe O’Lear, Larry Rippel, and Kim Walter are an amazing bonus to life itself. Similarly, incredible relatives such as Morgan Gable, Elise Platz, and Luke Platz are the real hope of the future. My life is richer for having all of you as a part of it. Lucky me, indeed! Thanks to Dan Magenheimer and Richard Artz, who did the technical edit on this book, and made it far better than it would have been without their insightful involvement. Thanks to Kit Kemper, ex-Wiley, who helped me promote the idea for this book in the first place, and thanks to the amazing (and patient) people at Wiley who helped make it a reality: Tom Dinse, Carol Long, Rebekah Gholdson, Jenny Watson, and others that I probably don’t even know. It takes a team to create a book, and I’m lucky to have worked with all of you. All errors and omissions are mine alone, but this book would be poorer without all of your contributions. fffirs.inddfirs.indd iixx 112/14/072/14/07 44:35:47:35:47 PPMM fffirs.inddfirs.indd x 112/14/072/14/07 44:35:48:35:48 PPMM Contents Acknowledgments ix Introduction xix Chapter 1: Overview of Virtualization 1 What Is Virtualization? 2 Application Virtualization 2 Desktop Virtualization 3 Network Virtualization 3 Server and Machine Virtualization 4 Storage Virtualization 7 System-Level or Operating System Virtualization 9 Why Virtualization Today? 10 Basic Approaches to Virtual Systems 11 Advantages of Virtualization 15 Better Use of Existing Hardware 15 Reduction in New Hardware Costs 16 Reduction in IT Infrastructure Costs 16 Simplified System Administration 17 Increased Uptime and Faster Failure Recovery 18 Simplified Capacity Expansion 18 Simpler Support for Legacy Systems and Applications 18 Simplified System-Level Development 19 Simplified System Installation and Deployment 20 Simplified System and Application Testing 20 Virtualization Caveats 21 Single Point of Failure Problems 21 Server Sharing and Performance Issues 22 Per-Server Network Congestion 23 Increase in Networking Complexity and Debugging Time 23 Increased Administrative Complexity 24 Identifying Candidates for Virtualization 24 Summary 26 fftoc.inddtoc.indd xxii 112/14/072/14/07 44:37:03:37:03 PPMM Contents Chapter 2: Introduction to Xen 27 History of Xen 27 Overview of Xen and x86 Virtualization 29 X86 Protection Levels: One Ring to Rule Them All 30 X86 Protection Levels and Virtualization 31 Xen Domains and the Hypervisor 32 Interacting with the Hypervisor 33 Controlling Hypervisor Scheduling 33 Advanced Topics in Operating System Schedulers 34 Types of Virtual Machines Supported by Xen 35 Paravirtualized Systems 36 Unmodified Guest Systems 36 Combining 32-Bit