Move a VM from user to system

Page content

Migrating a VM from qemu:///session to qemu:///system

Sometimes you’ll spin up a machine in qemu:///session and later decide it should live in qemu:///system due to network limitations etc. Here’s how to do that. You can also migrate the qcow2 image if you like.

  1. Find your VM, in this example we’re going to be working with the freenas VM.

    [jsj:~/temp] $ virsh list --all
    Id   Name              State
    ----------------------------------
    8    win10             running
    -    centos7_default   shut off
    -    freenas           shut off
    
  2. Dump the config

    [jsj:~/temp] $ virsh dumpxml --domain freenas > freenas.xml
    
  3. Remove the VM

    [jsj:~/temp] $ virsh undefine --domain freenas
    Domain freenas has been undefined
    
  4. Import the dumped machine config as root

    [jsj:~/temp] $ sudo virsh define freenas.xml
    [sudo] password for jsj:
    Domain freenas defined from freenas.xml
    
  5. Fire it up

    [jsj:~/temp] $ sudo virsh start --domain freenas
    [sudo] password for jsj:
    Domain freenas started