|By Rob Hirschfeld, Richard Cardona||
|December 7, 2004 12:00 AM EST||
Microsoft Virtual Server 2005 (VS2005), a new addition to the Microsoft Server family, emulates physical hardware to create multiple independently operating environments or virtual machines (VMs).
This article reviews portions of a C# application leveraging the VS2005 API. We will get you started with VS2005 here. The complete application code demonstrates one of the more interesting aspects of VMs: differencing hard drives. These drive disks allow you to toggle a VM from one configuration to a different configuration and back. This capability is especially useful for software testing and verification, where hardware resources are limited.
VS2005 is amazingly powerful but also adds a new level of complexity to server management. The VS2005 background and code provided in this article are just the tip of the iceberg to get you started. Take some time to work with virtualization. You'll quickly see how easily virtualization can benefit your organization.
Virtual Server Background
A full introduction to VS2005 could fill a book. The objective of this article is not to overwhelm you with details, but to show you how to write a simple interface program to VS2005 that does useful work. Before diving into code, some brief background on virtualization is necessary.
Virtualization enables a single physical server, or host, to be partitioned into many independently operating virtual servers. As depicted in Figure 1, the VS2005 software emulates the disk, network, keyboard/video/ mouse, processor, and memory needed to create a server. Each server is totally isolated from the others with no visibility into other VMs running on the same host. The virtualization software governs resource usage to ensure that one VM does not consume all of the host's CPU capacity.
It is important to distinguish between hosts and VMs for VS2005 compatibility. The host that runs the virtualization software must be running Windows Server 2003 (Windows XP works but is not "supported"). The VMs run a broad range of operating systems, including most flavors of Linux, DOS, Novell, Windows NT, and recent Windows releases but Microsoft will only support Windows. Microsoft, in fact, intends for VMs to become the primary supported platform for Windows NT.
What Makes Virtualization Compelling?
Virtualization is compelling because of the increased efficiency and control it brings to the physical server data center. Our company, Surgient, Inc., is an on-demand enterprise software company whose applications automate software sales, marketing, training, and testing processes. Surgient has been using virtualization platforms since 2001 as early beta testers of first-generation virtual server products. During that time, we have deployed over a thousand hosts and uncountable VMs. If you've experienced the Microsoft Visual Studio.NET hands-on trial, then you've used the Surgient demo management product and you've also used a VM! The VMs powering that site have served over 100,000 demos of VS.NET.
From the beginning, we recognized that VMs were fundamentally different and much more flexible than physical servers. The host's APIs enable programmatic control to manage the virtual servers. The price of this flexibility is additional planning and management of data center operations.
On a virtualization host, servers compete for limited amounts of memory (RAM), processor (CPU), and storage (disk). VS2005 VMs, like physical servers, need sufficient RAM to operate. They block out their full memory footprint on the host. You can, however, release a VM's memory by turning off the VM, which enables you to maintain more VM configurations than you can concurrently run.
These idle virtual images voraciously consume large amounts of disk. This means that a typical host may not have enough space to store many idle 4-10 GB virtual image files. VS2005 partially solves this problem by allowing VMs to chain image files into differencing layers that share a common base image.
The VS2005 differencing layer technology is called differencing disks (undo drives are a variant of differencing disks). This technology enables you to create a base image of the operating system and then install applications into a difference disk layer. A single base image can then be used by several VMs that each have a unique differencing disk.
Our sample scenario is a code development and testing environment for a three-tier application. The host server is a dual-processor server with 2GB of RAM and 120GB of RAID 5 disk. The proposed demo application must support both SQL Server and Oracle, each of which requires at least 1GB of RAM for testing. How can we use VS2005 to test the application in all its permutations using only the host server?
Memory is the obvious contention point. Of the available 2GB on the host, one quarter is reserved as overhead for the host operating system and VS2005, leaving just 1.5GB for the three application tiers. Since the databases each require 1GB, the entire application will just barely run on the host. To test both database platforms, we will have to keep one turned off while we are testing the other. Toggling the servers will keep our RAM use within the limits of the host.
Storage is a less obvious but equally serious challenge. Assuming 100GB available of the 120GB total should give ample room to store VM disk files. If we assume 10GB per VM, then we could store 10 VMs. Ten quickly drops to five if we plan to keep one archive copy of each VM.
Differencing disks provide the solution to both these issues. Our database server requires a 4GB Windows 2003 base image and two distinct differencing disks (SQL at 4GB and Oracle at 6GB). Without differencing, the two servers would consume 18GB of disk. Sharing the base image uses just 14, saving 4GB of disk. It is not necessary to archive the shared base because it does not change. We do, however, want to archive each differencing disk. The total storage is 24 GB, down from 36 GB without the use of differencing disks (see Figure 2).
Toggling the VM power states and working with shared base images addresses the resource limitations of the host.
Programming Virtualization Control
To use our testing environment, we must create a small .NET application that toggles between server configurations by changing both the VM's power state and its differencing disk configuration.
The C# sample application will provide the following features:
- Create a VM with appropriate components, including differencing and undo drives
- Manage the VM's power (Start and Stop)
- Change the disk configuration of an existing machine
- Simple user interface
Before the program can run, it needs a reference for the VS2005 API. VS2005 provides a COM interface and requires a .NET Interop to use it. Visual Studio creates the Interop automatically when we add Microsoft Virtual Server from the COM Components tab from the Tools...Add/Remove Toolbox Items menu. This process will add the using Microsoft.VirtualServer.Interop reference to the code.
In addition to referencing the COM Interop, VS2005 requires COM security to enforce access control. Our sample application includes a dedicated class, COMServices, to provide this critical initialization. Your VS2005 application must include this or similar code. A call to COMServices. Initialize() is all that is needed before we can start using the VS2005 API.
The VS2005 API has two primary categories of functions. The first category controls the virtualization platform on the host, while the second controls states and attributes of individual VMs. The interface to the host is created by instantiating a new VMVirtualServerClass object. Once this object exists, it is possible to create VMVirtualMachine objects by either creating new VMs using CreateVirtualMachineVM or getting a reference to an existing VM using FindVirtualMachine.
The example application calls the host object "vs" for Virtual Server. Here is the code to attach to the host API:
VMVirtualServerClass vs = new VMVirtualServerClass();
Creating a Virtual Machine
The first step in creating a VM is deciding where to store the multigigabyte virtual disk files that store the data of the VM's hard drives. The VS2005 default is to bury the files deep in the Documents and Settings directory tree, which can cause serious issues on systems with multiple partitions as the largest files default to the operating system's partition. Change the default path for VMs from the VS2005 Web interface in the Virtual Server...Server Properties section. The VMs are stored in directories under the default virtual machine configuration folder. In this example, the host will store VMs on the second partition (d:) in the "vms" subdirectory.
Creating a VM is a multistep process. The basic CreateVirtualMachine method only creates a VM stub. The VM's RAM, disk, and network must be configured before it is usable. However, you cannot just attach disk and network to a VM; you must "install" virtual devices before you can attach media to them. Specifically, you must add a network adapter to your VM before you can attach it to the network and you must specify which IDE or SCSI ports you are using when you attach drives.
The first step is to create the VM stub. The application calls the VM object vm. Here is the code requesting the host object to create a VM:
VMVirtualMachine vm = vs.CreateVirtualMachine("vm01","d:\vms\vm01");
With the VM stub, it is possible to configure the VM's properties. Memory is the easiest to configure:
vm.Memory = 256;
Attaching a hard drive requires an existing virtual hard disk (VHD) file. You can use an existing one or create one dynamically. VHD files are configured to a maximum possible size and expand dynamically as data is added. The maximum size is specified in megabytes, so the code sample uses a 1K multiplication to improve readability. Here is how the host object is told to create a VHD file:
vs.CreateDynamicVirtualHardDisk("d:\vms\vm01.vhd", 16 * 1024)
Instead of creating a new disk (shown above), you can add a differencing disk to an existing hard disk. A differencing disk inherits the maximum size from its parent and also stores the parent's location in its header. You must supply both a unique disk name and the parent disk when you create a difference disk:
Once the disk file exists, it can be attached to the VM by selecting a bus (IDE or SCSI) and the bus address. If the disk is a differencing disk, only the difference disk file is provided for connection. The parent disk is not programmatically connected because the difference disk already has the reference location for its parent disk. In this example, VS2005 will connect the drive at address IDE 0:0:
vm.AddHardDiskConnection("d:\vms\vm01.vhd", VMDriveBusType.vmDriveBusType_IDE, 0, 0);
Undoable mode is an important VS2005 feature because it allows you to maintain a working session for your server. When using undoable drives, you can maintain, commit, or discard the working session. There is minimal performance impact for this feature, and it eliminates the time wasted recovering or rebuilding server environments. Undoable mode is an attribute of the VM and applies to all drives:
vm.undoable = true;
Connecting the new network adapter to the correct host network is more challenging. The result is that the attached adapters are available as a NetworkAdapters array on the VM object. To create the network adapter for the VM:
When installed, VS2005 automatically creates a virtual network for each physical host network interface card (NIC) and an extra "internal" network that can be shared between VMs but is not externally connected. Virtual networks may be created or added from the Web interface in the Virtual Networks section. The host object offers an array of VirtualNetworks. Connect a VM to a network by providing a reference to the desired host network with AttachToVirtualNework method for an adapter:
Managing VM Power
VS2005 allows absolute control over a VM's power, including a saved state that releases a VM's memory and CPU resources. Suspend is useful because the VM immediately resumes work when restarted, avoiding an operating system reboot.
Basic power management uses the VM's Startup and TurnOff methods. These are not advised for most cases. TurnOff is dangerous because it does not gracefully shutdown, and Startup does not wait for the start before returning control.
To provide a graceful shutdown, the "Virtual Machine Additions" must be installed on the VM's GuestOS - Microsoft's name for the operating system running on the VM. VS2005 prompts you for the Additions in the Web interface. Once the additions are installed, you first check the CanShutdown property from the VM's GuestOS attribute:
If (vm.GuestOS.CanShutown vm.GuestOS.Shutdown();
Waiting for start or shutdown completion requires asynchronous calls to the VS2005 interface. Many VS2005 methods return a VMTask object that can be used to monitor task completion:
VMTask vt = vs.GuestOS.Shutdown();
if (vt !=null) vt.WaitForCompletion(-1);
Programming helps you unlock and automate some of the most powerful features of Microsoft Virtual Server 2005. This article covered key points to consider about using and programming Virtual Server. The complete sample application provides additional context and more features, including switching a VM's differencing disk as discussed in the example scenario. We believe that virtualization technology can radically improve the way you use server capacity and hope this article takes you a step closer to that realization.
|lawrence hordy 01/18/05 01:06:39 PM EST|
i see a 3d spreadsheet emulating a 3d array of strings == done in RPG or RPG2 == done IN CALCSTAR for a Z80 with CPM/80
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life sett...
Jun. 27, 2016 02:30 PM EDT Reads: 1,142
Basho Technologies has announced the latest release of Basho Riak TS, version 1.3. Riak TS is an enterprise-grade NoSQL database optimized for Internet of Things (IoT). The open source version enables developers to download the software for free and use it in production as well as make contributions to the code and develop applications around Riak TS. Enhancements to Riak TS make it quick, easy and cost-effective to spin up an instance to test new ideas and build IoT applications. In addition to...
Jun. 27, 2016 01:01 PM EDT Reads: 173
There are several IoTs: the Industrial Internet, Consumer Wearables, Wearables and Healthcare, Supply Chains, and the movement toward Smart Grids, Cities, Regions, and Nations. There are competing communications standards every step of the way, a bewildering array of sensors and devices, and an entire world of competing data analytics platforms. To some this appears to be chaos. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, Bradley Holt, Developer Advocate a...
Jun. 27, 2016 12:00 PM EDT Reads: 776
Presidio has received the 2015 EMC Partner Services Quality Award from EMC Corporation for achieving outstanding service excellence and customer satisfaction as measured by the EMC Partner Services Quality (PSQ) program. Presidio was also honored as the 2015 EMC Americas Marketing Excellence Partner of the Year and 2015 Mid-Market East Partner of the Year. The EMC PSQ program is a project-specific survey program designed for partners with Service Partner designations to solicit customer feedbac...
Jun. 27, 2016 11:55 AM EDT Reads: 229
Connected devices and the industrial internet are growing exponentially every year with Cisco expecting 50 billion devices to be in operation by 2020. In this period of growth, location-based insights are becoming invaluable to many businesses as they adopt new connected technologies. Knowing when and where these devices connect from is critical for a number of scenarios in supply chain management, disaster management, emergency response, M2M, location marketing and more. In his session at @Th...
Jun. 27, 2016 10:00 AM EDT Reads: 1,011
The cloud market growth today is largely in public clouds. While there is a lot of spend in IT departments in virtualization, these aren’t yet translating into a true “cloud” experience within the enterprise. What is stopping the growth of the “private cloud” market? In his general session at 18th Cloud Expo, Nara Rajagopalan, CEO of Accelerite, explored the challenges in deploying, managing, and getting adoption for a private cloud within an enterprise. What are the key differences between wh...
Jun. 27, 2016 09:30 AM EDT Reads: 853
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, wh...
Jun. 27, 2016 07:30 AM EDT Reads: 1,021
Cloud computing is being adopted in one form or another by 94% of enterprises today. Tens of billions of new devices are being connected to The Internet of Things. And Big Data is driving this bus. An exponential increase is expected in the amount of information being processed, managed, analyzed, and acted upon by enterprise IT. This amazing is not part of some distant future - it is happening today. One report shows a 650% increase in enterprise data by 2020. Other estimates are even higher....
Jun. 26, 2016 05:00 PM EDT Reads: 1,312
SYS-CON Events announced today that Bsquare has been named “Silver Sponsor” of SYS-CON's @ThingsExpo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. For more than two decades, Bsquare has helped its customers extract business value from a broad array of physical assets by making them intelligent, connecting them, and using the data they generate to optimize business processes.
Jun. 26, 2016 05:00 PM EDT Reads: 1,223
19th Cloud Expo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Meanwhile, 94% of enterpri...
Jun. 26, 2016 04:00 PM EDT Reads: 1,341
Internet of @ThingsExpo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 19th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devices - comp...
Jun. 26, 2016 04:00 PM EDT Reads: 1,280
It is one thing to build single industrial IoT applications, but what will it take to build the Smart Cities and truly society changing applications of the future? The technology won’t be the problem, it will be the number of parties that need to work together and be aligned in their motivation to succeed. In his Day 2 Keynote at @ThingsExpo, Henrik Kenani Dahlgren, Portfolio Marketing Manager at Ericsson, discussed how to plan to cooperate, partner, and form lasting all-star teams to change t...
Jun. 26, 2016 02:00 PM EDT Reads: 1,172
The 19th International Cloud Expo has announced that its Call for Papers is open. Cloud Expo, to be held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, Big Data, Internet of Things, DevOps, Digital Transformation, Microservices and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportuni...
Jun. 26, 2016 12:00 PM EDT Reads: 1,304
Internet of @ThingsExpo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with the 19th International Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world and ThingsExpo Silicon Valley Call for Papers is now open.
Jun. 26, 2016 12:00 PM EDT Reads: 1,134
There is little doubt that Big Data solutions will have an increasing role in the Enterprise IT mainstream over time. Big Data at Cloud Expo - to be held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA - has announced its Call for Papers is open. Cloud computing is being adopted in one form or another by 94% of enterprises today. Tens of billions of new devices are being connected to The Internet of Things. And Big Data is driving this bus. An exponential increase is...
Jun. 26, 2016 12:00 PM EDT Reads: 1,360
In his general session at 18th Cloud Expo, Lee Atchison, Principal Cloud Architect and Advocate at New Relic, discussed cloud as a ‘better data center’ and how it adds new capacity (faster) and improves application availability (redundancy). The cloud is a ‘Dynamic Tool for Dynamic Apps’ and resource allocation is an integral part of your application architecture, so use only the resources you need and allocate /de-allocate resources on the fly.
Jun. 26, 2016 12:00 PM EDT Reads: 1,105
Machine Learning helps make complex systems more efficient. By applying advanced Machine Learning techniques such as Cognitive Fingerprinting, wind project operators can utilize these tools to learn from collected data, detect regular patterns, and optimize their own operations. In his session at 18th Cloud Expo, Stuart Gillen, Director of Business Development at SparkCognition, discussed how research has demonstrated the value of Machine Learning in delivering next generation analytics to imp...
Jun. 26, 2016 09:45 AM EDT Reads: 671
Cognitive Computing is becoming the foundation for a new generation of solutions that have the potential to transform business. Unlike traditional approaches to building solutions, a cognitive computing approach allows the data to help determine the way applications are designed. This contrasts with conventional software development that begins with defining logic based on the current way a business operates. In her session at 18th Cloud Expo, Judith S. Hurwitz, President and CEO of Hurwitz & ...
Jun. 25, 2016 03:00 PM EDT Reads: 1,631
SYS-CON Events announced today that ReadyTalk, a leading provider of online conferencing and webinar services, has been named Vendor Presentation Sponsor at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. ReadyTalk delivers audio and web conferencing services that inspire collaboration and enable the Future of Work for today’s increasingly digital and mobile workforce. By combining intuitive, innovative tec...
Jun. 24, 2016 01:00 PM EDT Reads: 1,374
Amazon has gradually rolled out parts of its IoT offerings, but these are just the tip of the iceberg. In addition to optimizing their backend AWS offerings, Amazon is laying the ground work to be a major force in IoT - especially in the connected home and office. In his session at @ThingsExpo, Chris Kocher, founder and managing director of Grey Heron, explained how Amazon is extending its reach to become a major force in IoT by building on its dominant cloud IoT platform, its Dash Button strat...
Jun. 24, 2016 12:00 PM EDT Reads: 1,673