Difference between revisions of "Managing Xen using the xm Command-line Tool"
(→Shutting Down a Guest System) |
|||
Line 78: | Line 78: | ||
== Shutting Down a Guest System == | == Shutting Down a Guest System == | ||
− | The ''shutdown'' option of the ''xm'' tool is used to shutdown a guest operating system | + | The ''shutdown'' option of the ''xm'' tool is used to shutdown a guest operating system: |
<pre> | <pre> | ||
Line 84: | Line 84: | ||
</pre> | </pre> | ||
− | where ''guestName'' is the name of the guest system, to be shutdown. | + | where ''guestName'' is the name of the guest system, to be shutdown. |
+ | |||
+ | Note that the shutdown option allows the guest operating system to perform an orderly shutdown when it receives the shutdown instruction. To instantly stop a guest operating system the ''destroy'' option may be used (with all the attendant risk of filesystem damage and data loss): | ||
+ | |||
+ | <pre> | ||
+ | xm destroy myGuestOS | ||
+ | </pre> | ||
== Pausing and Resuming a Guest System == | == Pausing and Resuming a Guest System == |
Revision as of 19:01, 30 August 2007
In previous chapters we have covered the steps necessary to install and configure Xen and Xen based guest operating systems. This chapter is dedicated to explaining the xm tool, and how it can be used to manage guest operating systems from the command-line. If you prefer to use the graphical virt-manager tool to administer your Xen configuration see Managing and Monitoring Fedora based Xen Guest Systems.
xm Command-line vs Console
The xm options covered in this chapter may be invoked individually as coomand-line arguments to xm or used with sm in shell mode. To use the options as command-line arguments place use them as follows:
su - xm list
To run commands in the xm shell, run the following command:
[root@fedora7 ~]# xm shell The Xen Master. Type "help" for a list of functions. xm>
At the xm> prompt enter the options you wish to run, for example:
su - [root@fedora7 ~]# xm shell The Xen Master. Type "help" for a list of functions. xm> list Name ID Mem VCPUs State Time(s) Domain-0 0 384 1 r----- 455.1 XenFed 2 305 1 -b---- 7.7 myFedoraXen 300 1 0.0 myXenGuest 300 1 0.0 xm> xm> start XenFed xm> suspend XenFed xm> restore
Listing Guest System Status
The status of the host and guest systems may be viewed at any time using the list option of the xm tool. For example:
su - xm list
The above command will display output containing a line for the host system and a line for each guest similar to the following:
Name ID Mem VCPUs State Time(s) Domain-0 0 389 1 r----- 1414.9 XenFed 305 1 349.9 myFedoraXen 300 1 0.0 myXenGuest 6 300 1 -b---- 10.6
Starting a Xen Guest System
A system can be started using the xm tool with the start option followed by the name of the guest operating system to be launched. For example:
su - xm start XenFed
Connecting to a Running Xen Guest System
Once the guest operating system has started, a connection to the guest may be established using either the vncviewer tool or the virt-manager console. To use virt-manager, select Applications->System Tools->Virtual Machine Manager, select the desired system and click Open.
To connect using vncviewer enter the following command in Terminal window:
vncviewer
When prompted for a server enter localhost:5900. A VNC window will subsequently appear containing the running guest system.
Shutting Down a Guest System
The shutdown option of the xm tool is used to shutdown a guest operating system:
xm shutdown guestName
where guestName is the name of the guest system, to be shutdown.
Note that the shutdown option allows the guest operating system to perform an orderly shutdown when it receives the shutdown instruction. To instantly stop a guest operating system the destroy option may be used (with all the attendant risk of filesystem damage and data loss):
xm destroy myGuestOS
Pausing and Resuming a Guest System
A guest system can be paused and resumed using the xm tool's pause and restore options. For example, to pause a specific system named myXenGuest:
xm pause myXenGuest
Similarly, to resume the paused system:
xm resume myXenGuest
Note that a paused session will be lost if the host system is rebooted. Also, be aware that a paused system continues to reside in memory. To save a session such that it no longer takes up memory and can be restored to its exact state after a reboot, it is necessary to either suspend and resume or save and restore the guest.
Suspending and Resuming a Guest OS
A running guest operating system can be suspended and resumed using the xm utility. When suspended, the current status of the guest operating system is written to disk and removed from system memory. A suspended system may subsequently be restored at any time (including after a hosty system reboot):
To suspend a guest OS named myGuestOS:
xm suspend myGuestOS
To restore a suspect guest OS:
xm resume myGuestOS
Saving and Restoring Xen Guest Systems
Saving and restoring of a Xen guest operating system is similar to suspending with the exception that file used to contain the suspended operating system memory image can be specified by the user:
To save a guest:
xm save myGuestOS path_to_save_file <pre> To restore a saved guest operating system session: <pre> xm restore path_to_save_file
Rebooting a Guest System
To reboot a guest operating system:
xm reboot myGuestOS
Configuring the Memory Assigned to a Xen Guest OS
To configure the memory assigned to a guest OS, use the mem-set option of the xm command. For example, the following command reduces the memory allocated to a guest system named myGuestOS to 256Mb:
xm mem-set myGuestOS 256