|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
SYS-CON Events announced today that robomq.io will exhibit at SYS-CON's @ThingsExpo, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. robomq.io is an interoperable and composable platform that connects any device to any application. It helps systems integrators and the solution providers build new and innovative products and service for industries requiring monitoring or intelligence from devices and sensors.
Apr. 1, 2015 06:00 PM EDT Reads: 1,632
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps 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 opportunity. Submit your speaking proposal today!
Apr. 1, 2015 05:15 PM EDT Reads: 632
SYS-CON Events announced today that Litmus Automation will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Litmus Automation’s vision is to provide a solution for companies that are in a rush to embrace the disruptive Internet of Things technology and leverage it for real business challenges. Litmus Automation simplifies the complexity of connected devices applications with Loop, a secure and scalable cloud platform.
Apr. 1, 2015 04:00 PM EDT Reads: 809
While not quite mainstream yet, WebRTC is starting to gain ground with Carriers, Enterprises and Independent Software Vendors (ISV’s) alike. WebRTC makes it easy for developers to add audio and video communications into their applications by using Web browsers as their platform. But like any market, every customer engagement has unique requirements, as well as constraints. And of course, one size does not fit all. In her session at WebRTC Summit, Dr. Natasha Tamaskar, Vice President, Head of Cloud and Mobile Strategy at GENBAND, will explore what is needed to take a real time communications ...
Apr. 1, 2015 03:45 PM EDT Reads: 724
As Marc Andreessen says software is eating the world. Everything is rapidly moving toward being software-defined – from our phones and cars through our washing machines to the datacenter. However, there are larger challenges when implementing software defined on a larger scale - when building software defined infrastructure. In his session at 16th Cloud Expo, Boyan Ivanov, CEO of StorPool, will provide some practical insights on what, how and why when implementing "software-defined" in the datacenter.
Apr. 1, 2015 03:45 PM EDT Reads: 656
SYS-CON Events announced today that Solgenia will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY, and the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Solgenia is the global market leader in Cloud Collaboration and Cloud Infrastructure software solutions. Designed to “Bridge the Gap” between Personal and Professional Social, Mobile and Cloud user experiences, our solutions help large and medium-sized organizations dr...
Apr. 1, 2015 03:00 PM EDT Reads: 3,111
Internet of Things (IoT) will be a hybrid ecosystem of diverse devices and sensors collaborating with operational and enterprise systems to create the next big application. In their session at @ThingsExpo, Bramh Gupta, founder and CEO of robomq.io, and Fred Yatzeck, principal architect leading product development at robomq.io, will discuss how choosing the right middleware and integration strategy from the get-go will enable IoT solution developers to adapt and grow with the industry, while at the same time reduce Time to Market (TTM) by using plug and play capabilities offered by a robust I...
Apr. 1, 2015 01:45 PM EDT Reads: 869
The world's leading Cloud event, Cloud Expo has launched Microservices Journal on the SYS-CON.com portal, featuring over 19,000 original articles, news stories, features, and blog entries. DevOps Journal is focused on this critical enterprise IT topic in the world of cloud computing. Microservices Journal offers top articles, news stories, and blog posts from the world's well-known experts and guarantees better exposure for its authors than any other publication. Follow new article posts on Twitter at @MicroservicesE
Apr. 1, 2015 12:00 PM EDT Reads: 1,616
After making a doctor’s appointment via your mobile device, you receive a calendar invite. The day of your appointment, you get a reminder with the doctor’s location and contact information. As you enter the doctor’s exam room, the medical team is equipped with the latest tablet containing your medical history – he or she makes real time updates to your medical file. At the end of your visit, you receive an electronic prescription to your preferred pharmacy and can schedule your next appointment.
Apr. 1, 2015 12:00 PM EDT Reads: 1,060
Wearable technology was dominant at this year’s International Consumer Electronics Show (CES) , and MWC was no exception to this trend. New versions of favorites, such as the Samsung Gear (three new products were released: the Gear 2, the Gear 2 Neo and the Gear Fit), shared the limelight with new wearables like Pebble Time Steel (the new premium version of the company’s previously released smartwatch) and the LG Watch Urbane. The most dramatic difference at MWC was an emphasis on presenting wearables as fashion accessories and moving away from the original clunky technology associated with t...
Apr. 1, 2015 12:00 PM EDT Reads: 1,645
SYS-CON Events announced today the IoT Bootcamp – Jumpstart Your IoT Strategy, being held June 9–10, 2015, in conjunction with 16th Cloud Expo and Internet of @ThingsExpo at the Javits Center in New York City. This is your chance to jumpstart your IoT strategy. Combined with real-world scenarios and use cases, the IoT Bootcamp is not just based on presentations but includes hands-on demos and walkthroughs. We will introduce you to a variety of Do-It-Yourself IoT platforms including Arduino, Raspberry Pi, BeagleBone, Spark and Intel Edison. You will also get an overview of cloud technologies s...
Apr. 1, 2015 11:00 AM EDT Reads: 2,280
Containers and microservices have become topics of intense interest throughout the cloud developer and enterprise IT communities. Accordingly, attendees at the upcoming 16th Cloud Expo at the Javits Center in New York June 9-11 will find fresh new content in a new track called PaaS | Containers & Microservices Containers are not being considered for the first time by the cloud community, but a current era of re-consideration has pushed them to the top of the cloud agenda. With the launch of Docker's initial release in March of 2013, interest was revved up several notches. Then late last...
Apr. 1, 2015 09:15 AM EDT Reads: 2,328
The WebRTC Summit 2015 New York, to be held June 9-11, 2015, at the Javits Center in New York, NY, announces that its Call for Papers is open. Topics include all aspects of improving IT delivery by eliminating waste through automated business models leveraging cloud technologies. WebRTC Summit is co-located with 16th International Cloud Expo, @ThingsExpo, Big Data Expo, and DevOps Summit.
Apr. 1, 2015 09:00 AM EDT Reads: 1,759
SOA Software has changed its name to Akana. With roots in Web Services and SOA Governance, Akana has established itself as a leader in API Management and is expanding into cloud integration as an alternative to the traditional heavyweight enterprise service bus (ESB). The company recently announced that it achieved more than 90% year-over-year growth. As Akana, the company now addresses the evolution and diversification of SOA, unifying security, management, and DevOps across SOA, APIs, microservices, and more.
Apr. 1, 2015 08:30 AM EDT Reads: 2,134
The list of ‘new paradigm’ technologies that now surrounds us appears to be at an all time high. From cloud computing and Big Data analytics to Bring Your Own Device (BYOD) and the Internet of Things (IoT), today we have to deal with what the industry likes to call ‘paradigm shifts’ at every level of IT. This is disruption; of course, we understand that – change is almost always disruptive.
Mar. 30, 2015 04:00 PM EDT Reads: 1,214
SYS-CON Events announced today that SafeLogic has been named “Bag Sponsor” of SYS-CON's 16th International Cloud Expo® New York, which will take place June 9-11, 2015, at the Javits Center in New York City, NY. SafeLogic provides security products for applications in mobile and server/appliance environments. SafeLogic’s flagship product CryptoComply is a FIPS 140-2 validated cryptographic engine designed to secure data on servers, workstations, appliances, mobile devices, and in the Cloud.
Mar. 30, 2015 11:00 AM EDT Reads: 1,583
GENBAND has announced that SageNet is leveraging the Nuvia platform to deliver Unified Communications as a Service (UCaaS) to its large base of retail and enterprise customers. Nuvia’s cloud-based solution provides SageNet’s customers with a full suite of business communications and collaboration tools. Two large national SageNet retail customers have recently signed up to deploy the Nuvia platform and the company will continue to sell the service to new and existing customers. Nuvia’s capabilities include HD voice, video, multimedia messaging, mobility, conferencing, Web collaboration, deskt...
Mar. 30, 2015 01:00 AM EDT Reads: 1,550
SYS-CON Media announced today that @WebRTCSummit Blog, the largest WebRTC resource in the world, has been launched. @WebRTCSummit Blog offers top articles, news stories, and blog posts from the world's well-known experts and guarantees better exposure for its authors than any other publication. @WebRTCSummit Blog can be bookmarked ▸ Here @WebRTCSummit conference site can be bookmarked ▸ Here
Mar. 29, 2015 10:00 PM EDT Reads: 1,899
SYS-CON Events announced today that Cisco, the worldwide leader in IT that transforms how people connect, communicate and collaborate, has been named “Gold Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Cisco makes amazing things happen by connecting the unconnected. Cisco has shaped the future of the Internet by becoming the worldwide leader in transforming how people connect, communicate and collaborate. Cisco and our partners are building the platform for the Internet of Everything by connecting the...
Mar. 29, 2015 07:00 PM EDT Reads: 5,321
Temasys has announced senior management additions to its team. Joining are David Holloway as Vice President of Commercial and Nadine Yap as Vice President of Product. Over the past 12 months Temasys has doubled in size as it adds new customers and expands the development of its Skylink platform. Skylink leads the charge to move WebRTC, traditionally seen as a desktop, browser based technology, to become a ubiquitous web communications technology on web and mobile, as well as Internet of Things compatible devices.
Mar. 29, 2015 06:00 PM EDT Reads: 1,910