Guest Editing SOP

Various virsh commands

Contact Information

Owner

Fedora Infrastructure Team

Contact

#admin, sysadmin-main

Location

all

Servers

kvm/libvirt servers.

Purpose

Various virsh commands for vm’s

How to do it

Add cpu

  1. SSH to the virthost server

  2. Calculate the number of CPUs the system needs

  3. sudo virsh setvcpus <guest> <num_of_cpus> --config - ie:

    sudo virsh setvcpus bapp01 16 --config
  4. Shutdown the virtual system

  5. Start the virtual system

    Note that using virsh reboot is insufficient. You have to actually stop the domain and start it with virsh destroy <guest> and virsh start <guest> for the change to take effect.

  6. Login and check that cpu count matches

  7. Remember to update the group_vars in ansible to match the new value you set, if appropriate.

Resize memory

  1. SSH to the virthost server

  2. Calculate the amount of memory the system needs in kb

  3. sudo virsh setmem <guest> <num_in_kilobytes> --config - ie:

    sudo virsh setmem bapp01 16777216 --config
  4. Shutdown the virtual system

  5. Start the virtual system

    Note that using virsh reboot is insufficient. You have to actually stop the domain and start it with virsh destroy <guest> and virsh start <guest> for the change to take effect.

  6. Login and check that memory matches

  7. Remember to update the group_vars in ansible to match the new value you set, if appropriate.

Chaining commands with console

When shutting down instances to edit them you can use virsh console to wait until the guest is fully shutdown:

  1. virsh shutdown guestfqdn; virsh console guestfqdn; virsh edit guestfqdn; virsh start guestfqdn

Set / Unset autostart for guests

Normally ansible sets all guests to autostart by default, but if a guest is manually installed or something you can enable autostart with:

  1. virsh autostart guestfqdn

Or disable autostart:

  1. virsh autostart --disable guestfqdn

libvirt group

You can add your user to the libvirt group in /etc/groups on the virthost in case you need to use virt-manager or the like to manage vm’s on the host for some reason.