Recover VM XML files


Recommended Posts

  • 3 months later...

Not a real VM guy, but I believe that are actually stored within domain.img (/config/plugins/dynamix.kvm.manager).

 

Probably won't help you now, but your best way of backing up your XML's is to actually set up CA's appdata backup feature, and enable to VM XML backup option (set it to backup to the appdata folder), and use dated backups. 

 

Your XMLs will wind up getting saved outside of the domain.img, and with the dated backup feature, you'll have access to them for as long as you choose.

Link to comment

Not a real VM guy, but I believe that are actually stored within domain.img (/config/plugins/dynamix.kvm.manager).

 

Probably won't help you now, but your best way of backing up your XML's is to actually set up CA's appdata backup feature, and enable to VM XML backup option (set it to backup to the appdata folder), and use dated backups. 

 

Your XMLs will wind up getting saved outside of the domain.img, and with the dated backup feature, you'll have access to them for as long as you choose.

 

Hey Squid!

 

Ok, thanks, so if we pretend they are inside domain.img, how do you think we could open the iso and extract the files?

Do you think I can pull it to my Windows PC and use a ISO-Mount program like Deamon Tools or something and mount it here and then extract the files? :)

 

Ok, yeah you're right. That won't help me now. But maybe in the future!

How does the backup work, I've never used it before? What's your backup-settings? :)

Link to comment

Not a real VM guy, but I believe that are actually stored within domain.img (/config/plugins/dynamix.kvm.manager).

 

Probably won't help you now, but your best way of backing up your XML's is to actually set up CA's appdata backup feature, and enable to VM XML backup option (set it to backup to the appdata folder), and use dated backups. 

 

Your XMLs will wind up getting saved outside of the domain.img, and with the dated backup feature, you'll have access to them for as long as you choose.

 

Hey Squid!

 

Ok, thanks, so if we pretend they are inside domain.img, how do you think we could open the iso and extract the files?

Do you think I can pull it to my Windows PC and use a ISO-Mount program like Deamon Tools or something and mount it here and then extract the files? :)

dunno.  Rather than just jerking around, I'd just do something like

cp /etc/libvirt/qemu/*.xml /boot

to copy them to the flash drive (but they probably don't exist there if you've deleted them already)

 

What's your backup-settings? :)

Settings - CA section - Appdata Backup
Link to comment

dunno.  Rather than just jerking around, I'd just do something like

cp /etc/libvirt/qemu/*.xml /boot

to copy them to the flash drive (but they probably don't exist there if you've deleted them already)

 

HOLY GUACAMOLE! :D

 

I managed to solve it! :D

 

I went to my domain.img that I backed up from my old Unraid USB.

Opened it with Notepad++ and there at line 1500-something I found the complete XML Domain configs!!

 

Looked like this for me:

<domain type='kvm'>
  <name>Windows 10 Virtual Desktop</name>
  <uuid>621b4448-c2b5-4d85-409b-281282f0aa69</uuid>
  <metadata>
    <vmtemplate name="Custom" icon="windows.png" os="windows"/>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <memoryBacking>
    <nosharepages/>
    <locked/>
  </memoryBacking>
  <vcpu placement='static'>4</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='4'/>
    <vcpupin vcpu='1' cpuset='5'/>
    <vcpupin vcpu='2' cpuset='6'/>
    <vcpupin vcpu='3' cpuset='7'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.3'>hvm</type>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
  </features>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='4' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='hypervclock' present='yes'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/user/vdisks/Windows 10 Virtual Desktop/vdisk1.img'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/ISOs/Windows 10.iso'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <boot order='2'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/ISOs/virtio-win-0.1.110.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:06:5b:93'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/Windows 10 Virtual Desktop.org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='0.0.0.0' keymap='sv'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='vmvga' vram='16384' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x1781'/>
        <product id='0x0c31'/>
      </source>
    </hostdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
</domain>

 

So all I did was changing:

<source file='/mnt/user/vdisks/Windows 10 Virtual Desktop/vdisk1.img'/>

to

<source file='/mnt/user/domains/Windows 10 Virtual Desktop/vdisk1.img'/>

As it is named to in unraid 6.2 and above.

 

Paste everything into a custom VM XML Gui and then it booted all like it used to before, no more configurations needed. :D

 

 

 

  • Like 1
Link to comment

Opened it with Notepad++ and there at line 1500-something I found the complete XML Domain configs!!

Now there's something I never would have thought of doing...  Glad you got what you needed

 

And without you I wouldn't find the domain.img! :)

 

Though now I am going to read more about CA backups, how to use it and what's good to back up.

Link to comment

Opened it with Notepad++ and there at line 1500-something I found the complete XML Domain configs!!

Now there's something I never would have thought of doing...  Glad you got what you needed

 

And without you I wouldn't find the domain.img! :)

 

Though now I am going to read more about CA backups, how to use it and what's good to back up.

 

Heres a script you can use with squids user script plugin that will backup all vm xml files and ovmf nvram files to a choosen dated folder.

http://lime-technology.com/forum/index.php?topic=50416.msg505867#msg505867

Link to comment
  • 4 years later...
  • 1 year later...

had an account snaffoo

First off, I know this is an old thread but I feel this updated information is useful if someone were to try this today. Also, truetype, you are a BOSS for pulling that one off. Saved my buns! (I had stopped the VM service while a VM was running due to looking at an out of date tab that told me they werent >.> and corrupted my libvirt.img so had to rebuild it)

Secondly, I can verify your notepad++ recovery of the XML config settings does work, with a caveat. 

Thirdly, the Caveat. If anyone else attempts this and has an OVMF or OVMF-TPM for their BIOS on the VM, you will run into an issue where simply copying these XML texts over wont be enough. To make a long story short here's what you do to fix that. Follow truetypes instructions exactly like they did, but when you paste the XML into the config for unraid you will do this.
 

~~Truncated code to make smaller~~
  <os>
    <type arch='x86_64' machine='pc-q35-6.2'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd</loader>
    <nvram>/etc/libvirt/qemu/nvram/BLAHBLAHBLAHRANDOMHEXVARSHERE_VARS-pure-efi.fd</nvram>
  </os>
~~Truncated code to make smaller~~

This is what you need to change in the XML. Just remove the OVMF parts. so your left with this
 

  

  <os>
    <type arch='x86_64' machine='pc-q35-6.2'>hvm</type>
  </os>


After you do that and click build, it will launch the machine, it will then boot into the windows installer (if you still have that setup) but cant install windows because the drive is in GPT format 
Force shut it down then go and edit the VM. You will notice the BIOS is set to SeaBIOS and is greyed out and wont let you change it. Go into the XML mode and add those two lines back where they were. Click update. It will accept. BUT if you launch the VM now it will fail saying it cant find "/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd" or some var to that effect. So were going to go into edit the machine again in GUI mode this time, were going to change the BIOS to OVMF-TPM and click update. Then Edit it ANOTHER time, and this time set it to OVMF and hit update. Viola. your VM will boot up.  (If your VM was already OVMF-TPM then try OVMF first and then switch to OVMF-TPM)

Not 100% how this black magic fixed it but im guessing something is missing when you build just from XML for OVMF type BIOS VM's that you dont get when XML editing. However, when you get it in the GUI and swap them back and forth, it probably builds/places the files needed in the libvirt.img file allowing it to boot up properly. 


Fourthly, I am just a humble ADHD nerd who took ALOT of google-fu and combined it all together to get this. So big thanks to all the OG sources. Namely truetype because holy cow. I would have never thought to use a text editor to pry open a .img file. Its like using a shoe to open a can of soup XD Seeing Squid genuinely be surprised made my day.

Edited by taeleus
fixed some spacing in code inserts
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.