I recently provisioned a Virtual Machine in a KVM Hypervisor with a typo in the name. Even worse I also created the storage LV with a typo. Here is how I fixed it. Off course shut the VM down first.

LV Rename

<pre class="brush: bash"># lvrename VolumeGroup oldLVname newLVname
  Renamed "oldLVname" to "newLVname" in volume group "VolumeGroup"

Change reference to storage in VM XML

<pre class="brush: bash"># virsh edit oldVMname
Domain oldVMname XML configuration edited.

# grep newLVname oldVMname.xml 
      <source dev="/dev/VolumeGroup/newLVname"></source>

Recreate VM

<pre class="brush: bash"># virsh dumpxml oldVMname > /tmp/newVMname.xml

# virsh undefine oldVMname
Domain newVMname has been undefined

# grep newVMname /tmp/newVMname.xml 
  newVMname
      <source dev="/dev/VolumeGroup/newVMname"></source>

# virsh define /tmp/newVMname.xml 
Domain newVMname defined from /tmp/newVMname.xml

# virsh list --all
 Id Name                 State
----------------------------------
  7 aVMname            running
  - newVMname         shut off

# virsh start newVMname
Domain newVMname started

Next Post Previous Post