Virsh domain has space in it, can not remove

6,250

Kids, don't try this at home:

Libvirt should have rejected the creation of a domain with a space in its name, so someone did something strange to create the domain to begin with. To recover from this is going to require some hand-editing of files you aren't normally supposed to touch manually.

So this is what I would do:

  1. Stop libvirtd (your VMs will continue running).

    service libvirtd stop
    
  2. Find the offending XML file, which should be somewhere in /etc/libvirt/qemu.

    # ls /etc/libvirt/qemu
    autostart
    Centos_6.5_64.xml
    Git Server.xml
    networks
    pxe.xml
    
  3. Rename the offending file.

    # mv /etc/libvirt/qemu/Git\ Server.xml /etc/libvirt/qemu/Git_Server.xml
    
  4. Edit the name in the offending file.

    # vi /etc/libvirt/qemu/Git_Server.xml
    
    <domain type='kvm'>
      <name>Git_Server</name>
    ...
    
  5. Restart libvirtd.

    service libvirtd start
    
Share:
6,250

Related videos on Youtube

DevOops
Author by

DevOops

Updated on September 18, 2022

Comments

  • DevOops
    DevOops almost 2 years

    I'm having trouble starting, or destroying a domain:

    virsh # list --all
     Id    Name                           State
    ----------------------------------------------------
     1     pxe                            running
     -     Centos_6.5_64                  shut off
     -     Git Server                     shut off
    

    I can't start the domain:

    virsh # start Git
    error: failed to get domain 'Git'
    error: Domain not found: no domain with matching name 'Git'
    
    virsh # start Git Server
    error: unexpected data 'Server'
    

    Because of this I'm not able to destroy the domain.

    How can I assign an ID or otherwise remove this VM?

    Because it has a space in it, I'm not able to manage it like I am other domains.

    I know that they are not supposed to have spaces, but then again, end users don't always listen to what they're told :P

    Thank you for any help you might provide.

  • DevOops
    DevOops almost 10 years
    Thank you Michael, and amazing supporting documentation. I had forgotten that those xml files were how these are instantiated. Also, how did you hack my server and get my ls output?! Just kidding. I'm sure libvirt would have tried to stop me, but I'm working with a Python app that doesn't currently check for spaces, will have to rectify that.