Chapter 14. Administrating Virtual Machines with QEMU Monitor?
Contents
-
14.1. Accessing Monitor Console
14.2. Getting Information about the Guest System
14.3. Changing VNC Password
14.4. Managing Devices
14.5. Controlling Keyboard and Mouse
14.6. Changing Available Memory
14.7. Dumping Virtual Machine Memory
14.8. Managing Virtual Machine Snapshots
14.9. Suspending and Resuming Virtual Machine Execution
14.10. Live Migration
When QEMU is running, a monitor console is provided for performing interaction with the user. Using the commands available in the monitor console, it is possible to inspect the running operating system, change removable media, take screenshots or audio grabs and control several other aspects of the virtual machine.
14.1. Accessing Monitor Console?
To access the monitor console from QEMU, press Ctrl+Alt+2. To return back to QEMU from the monitor console, press Ctrl+Alt+1.
To get help while using the console, use help or ?. To get help for a specific command, use helpcommand
.
14.2. Getting Information about the Guest System?
To get information about the guest system, use the info option
command. If used without any option, the list of possible options is printed. Options determine which part of the system will be analyzed:
-
info version
-
Shows the version of QEMU
info commands
-
Lists available QMP commands
info network
-
Shows the network state
info chardev
-
Shows the character devices
info block
-
Information about block devices, such as hard drives, floppy drives, or CD-ROMs
info blockstats
-
Read and write statistics on block devices
info registers
-
Shows the CPU registers
info cpus
-
Shows information about available CPUs
info history
-
Shows the command line history
info irq
-
Shows the interrupts statistics
info pic
-
Shows the i8259 (PIC) state
info pci
-
Shows the PCI information
info tlb
-
Shows virtual to physical memory mappings
info mem
-
Shows the active virtual memory mappings
info jit
-
Shows dynamic compiler information
info kvm
-
Shows the KVM information
info numa
-
Shows the NUMA information
info usb
-
Shows the guest USB devices
info usbhost
-
Shows the host USB devices
info profile
-
Shows the profiling information
info capture
-
Shows the capture (audio grab) information
info snapshots
-
Shows the currently saved virtual machine snapshots
info status
-
Shows the current virtual machine status
info pcmcia
-
Shows the guest PCMCIA status
info mice
-
Shows which guest mice is receiving events
info vnc
-
Shows the VNC server status
info name
-
Shows the current virtual machine name
info uuid
-
Shows the current virtual machine UUID
info usernet
-
Shows the user network stack connection states
info migrate
-
Shows the migration status
info balloon
-
Shows the balloon device information
info qtree
-
Shows the device tree
info qdm
-
Shows the qdev device model list
info roms
-
Shows the ROMs
14.3. Changing VNC Password?
To change the VNC password, use the change vnc password command and enter the new password:
(qemu) change vnc password Password: ******** (qemu)
14.4. Managing Devices?
To release the device or file connected to the removable media device, use the eject device
command. Use the optional -f
to force ejection.
To change removable media (like CD-ROMs), use the change device
command. The name of the removable media can be determined using the info block command:
(qemu) info block ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/sr0 ro=1 drv=host_device (qemu) change ide1-cd0 /path/to/image
14.5. Controlling Keyboard and Mouse?
It is possible to use the monitor console to emulate keyboard and mouse input if necessary. For example, if your graphical user interface intercepts some key combinations at low level (such asCtrl+Alt+F1 in X Window), you can still enter them using the sendkey keys
:
sendkey ctrl-alt-f1
To list the key names used in the keys
option, enter sendkey and press Tab.
To control the mouse, the following commands can be used:
-
mouse_move
-
Move the active mouse pointer to the specified coordinates dx, dy with the optional scroll axis dz.
mouse_button -
Change the state of the mouse buttons (1=left, 2=middle, 4=right).
mouse_set -
Set which mouse device receives events. Device index numbers can be obtained with theinfo mice command.
dx
dy
[dz
]
val
index
14.6. Changing Available Memory?
If the virtual machine was started with the -balloon virtio
option and the paravirtualized balloon device that allows to dynamically change the amount of memory available is therefore enabled, it is possible to change the available memory dynamically. For more information about enabling the balloon device, see Section 12.1, “Basic Installation with qemu-kvm”.
To get information about the balloon device in the monitor console and to determine whether the device is enabled, use the info balloon command:
(qemu) info balloon
If the balloon device is enabled, use the balloon memory_in_MB
command to set the requested amount of memory:
(qemu) balloon 400
14.7. Dumping Virtual Machine Memory?
To save the content of the virtual machine memory to a disk or console output, use the following commands:
-
memsave
-
Saves virtual memory dump starting at
addr
of sizesize
to filefilename
pmemsave -
Saves physical memory dump starting at
addr
of sizesize
to filefilename
-
x / -
Makes a virtual memory dump starting at address
addr
and formatted according to thefmt
string. Thefmt
string consists of three parameters
:count
format
size
The
count
parameter is the number of items to be dumped.The
format
can bex
(hex),d
(signed decimal),u
(unsigned decimal),o
(octal),c
(char) ori
(assembly instruction).The
size
parameter can beb
(8 bits),h
(16 bits),w
(32 bits) org
(64 bits). On x86,h
orw
can be specified with thei
format to respectively select 16 or 32-bit code instruction size. is the number of the items to be dumped.
xp / -
Makes a physical memory dump starting at address
addr
and formatted according to thefmt
string. Thefmt
string consists of three parameters
:count
format
size
The
count
parameter is the number of the items to be dumped.The
format
can bex
(hex),d
(signed decimal),u
(unsigned decimal),o
(octal),c
(char) ori
(asm instruction).The
size
parameter can beb
(8 bits),h
(16 bits),w
(32 bits) org
(64 bits). On x86,h
orw
can be specified with thei
format to respectively select 16 or 32-bit code instruction size. is the number of the items to be dumped.
addr
size
filename
addr
size
filename
fmt
addr
fmt
addr
14.8. Managing Virtual Machine Snapshots?
![]() | |
Managing snapshots in QEMU monitor is not officially supported by SUSE yet. However, the information found in this section may be helpful in specific cases. |
Virtual machine snapshots are snapshots of the complete virtual machine including the state of CPU, RAM, and the content of all writable disks. To use virtual machine snapshots, you must have at least one non-removable and writable block device using the qcow2
disk image format.
Snapshots are helpful when you need to save your virtual machine in a particular state. For example, after you configured network services on a virtualized server and want to quickly start the virtual machine in the same state that has been saved last. You can also create a snapshot after the virtual machine has been powered off to create a backup state before you try something experimental and possibly make VM Guest unstable. This section introduces the former case, while the latter is described in Section 12.2.3, “Managing Snapshots of Virtual Machines with qemu-img”.
The following commands are available for managing snapshots in QEMU monitor:
-
savevm
-
Creates a new virtual machine snapshot under the tag
name
or replaces an existing snapshot.
loadvm -
Loads a virtual machine snapshot tagged
name
.
delvm
-
Deletes a virtual machine snapshot.
info snapshots
-
Prints information about available snapshots.
(qemu) info snapshots Snapshot list: ID
TAG
VM SIZE
DATE
VM CLOCK
1 booting 4.4M 2010-11-22 10:51:10 00:00:20.476 2 booted 184M 2010-11-22 10:53:03 00:02:05.394 3 logged_in 273M 2010-11-22 11:00:25 00:04:34.843 4 ff_and_term_running 372M 2010-11-22 11:12:27 00:08:44.965
Unique identification number of the snapshot. Usually auto-incremented.
Unique description string of the snapshot. It is meant as a human readable version of the ID.
The disk space occupied by the snapshot. Note that the more memory is consumed by running applications, the bigger the snapshot is.
Time and date the snapshot was created.
The current state of the virtual machine's clock.
name
name
14.9. Suspending and Resuming Virtual Machine Execution?
The following commands are available for suspending and resuming virtual machines:
-
stop
-
Suspends the execution of the virtual machine.
cont
-
Resumes the execution of the virtual machine.
system_powerdown
-
Sends an ACPI shutdown request to the machine. The effect is similar to the power button on a physical machine.
q or quit
-
Terminates QEMU immediately.
14.10. Live Migration?
The live migration process allows to transmit any virtual machine from one host system to another host system without any interruption in availability. It is possible to change hosts permanently or just during a maintenance. It is recommended that the source and destination systems have the same architecture, however it is possible to migrate between hosts with AMD and Intel architectures.
The requirements for the live migration:
The virtual machine image must be accessible on both source and destination hosts. For example, it can be located on a shared NFS disk.
The image directory should be located in the same path on both hosts.
Both hosts must be located in the same subnet.
The guest on the source and destination hosts must be started in the same way.
The live migration process has the following steps:
The virtual machine instance is running on the source host.
The virtual machine is started on the destination host in the frozen listening mode. The parameters used are the same as on the source host plus the
-incoming tcp:
parameter, whereip
:port
ip
specifies the IP address andport
specifies the port for listening to the incoming migration. If 0 is set as IP address, the virtual machine listens on all interfaces.On the source host, switch to the monitor console and use the migrate -d tcp:
destination_ip
:port
command to initiate the migration.To determine the state of the migration, use the info migrate command in the monitor console on the source host.
To cancel the migration, use the migrate_cancel command in the monitor console on the source host.
To set the maximum tolerable downtime for migration in seconds, use themigrate_set_downtime
number_of_seconds
command.To set the maximum speed for migration in bytes per second, use the migrate_set_speed
bytes_per_second
command.声明文章转自:http://doc.opensuse.org/products/draft/SLES/SLES-kvm_sd_draft/cha.qemu.monitor.html