sections in this module City College of San Francisco - CS260A
Unix/Linux System Administration

Module: rsyslog
module list

Starting and Stopping Virtual Machines Remotely

If you are at the GUI of the host system, it is easy to start and stop your virtual machine. Simply start virt-manager, select your VM and click the start button, or connect to the console and issue whatever shutdown command you like. You can also easily clone your VM using the GUI as well.

If you want to access your VM remotely, however, and it is not running, or to clone a new one and activate it, you have a little bit of a problem if you want to use the GUI. Of course, there are command-line tools to handle all of the virtualization tasks. We will begin to discuss a few of them in this section:

virt-clone  - clone a new VM from an existing VM

virsh - control (start, reboot, examine) a VM

Cloning a new VM

Given a powered-down VM that you want to use as the master, it is simple to clone a new VM using the command-line. The only required arguments to virt-clone are

For example, if the master VM is VM-master and you want to use the default naming convention, here's the command to clone VM-master and create a new VM myVM:

virt-clone -o VM-master -n myVM -f /var/lib/libvirt/images/myVM.img

The virsh command 

virsh is used for most command-line operations on VMs. It is fully featured. We will discuss virsh in more detail later, but for now we will just introduce a few virsh commands that we will invoke from the bash command-line (rather than interactively in virsh):

Note: in KVM terminology the name of the VM is called the domain-id.

virsh dominfo domain-id   show the status (running/stopped/managedsave/persistence) of domain-id

virsh list --all    list all known virtual machines (domain-ids) and whether they are running or not.

virsh start domain-id    start the VM

virsh autostart [--disable] domain-id    set (or unset) whether the VM should be autostarted (started when the host is started)

virsh reboot domain-id    issue a reboot command on domain-id

virsh destroy domain-id   hard-reset the domain. (Like pulling the power cord.)

virsh managedsave-remove domain-id  deletes the saved image of domain-id. The saved image is created when the host is rebooted and the VM is running. The intention is to resume the VM using the saved image, but sometimes this does not work. If the saved image cannot be restarted you must remove it before you can boot the VM

virsh shutdown domain-id    issue a shutdown command on domain-id (note if a user is logged in on the GUI of the VM this will bring up a confirmation message. The GUI user will have some amount of time to avoid the action. This is true of virsh reboot as well.)

virsh undefine domain-id    delete the XML description for the VM. The VM should be shutoff first using destroy (or shutdown). You must still physically delete the image file.

Connecting to the VM remotely

Once your VM is running, you can ssh to it if you know its IP address. If you configured the VM to use a static IP, it is  your responsibility to remember it or to discover it. If your VM uses DHCP when it starts, it will announce its IP address using ARP. You can use this fact to narrow down the choices for where your VM is.

$ ip neighbor list
192.168.122.228 dev virbr0 lladdr 52:54:00:3d:5d:91 STALE
192.168.1.1 dev eth0 lladdr 00:0f:b5:e7:9b:e0 STALE

You can see from this output that one VM has announced itself as 192.168.122.228. If you had just started your VM and it was using DHCP this would probably be it. Go ahead and ssh to it!

(Note: I may have given you a shell script that more reliably finds VMs on the host, called findVMs. Use it if you have it. It is more reliable than ip neighbor list.)

Now let's continue with our rsyslog.conf discussion.

Preview question: Using more(1), examine /etc/rsyslog.conf

Prev This page was made entirely with free software on linux:  
the Mozilla Project
and Openoffice.org      
Next

Copyright 2012 Greg Boyd - All Rights Reserved.