XO created snapshots are too visible
I'm still seeing issues with this. Does anyone have any ideas on how to deal with this?
I don't think that's an issue per se. What's the actual problem?
The problem seems to be that snapshots created by XO show up in a list of available VMs on a server (by getting a list of all VMs at a server's console) while snapshots created by XCP-ng Center or the xe vm-snapshot command do not. The xe vm-list command also lists snapshots created by XO but not other snapshots.
This really causes problems for any kind of processing using xe (or, I assume, the equivalent XAPI) that gets a list of VMs from a server and does something with them as it will also try to affect the snapshots created by XO as though they're normal VMs. It's also confusing to see what should be snapshots showing up in a list of available VMs on a server and could lead to an operator at the console trying to start what's supposed to be a snapshot as though it's a VM.
I've traced the difference in snapshots down to the is-a-template parameter on the snapshot; snapshots created by the xe vm-snapshot command or anything that uses it or the equivalent XAPI (which I assume is what XCP-ng Center does) have the is-a-template parameter set to true while snapshots created by XO do not.
I'm not sure if this is a bug in how XO creates its snapshots or possibly some bug in XAPI which lists snapshots as VMs when it shouldn't. I suspect the latter but don't know for certain as I don't know what the intended design was there. I'd think that the expected behavior for xe vn-list (or it's XAPI equivalent) shouldn't show anything with is-a-snapshot true OR is-a-template true while it currently seems to be just basing visibility on the is-a-template parameter.
My biggest problem at the moment is that I have some shell scripts using xe commands for various functions and they're trying to act on XO snapshots as well. I'm working around it at the moment by modifying the scripts to work with an exclusion list (i.e. don't operate on VMs with names in a specific list) but that's not really maintainable and certainly not a good solution to the problem.
Thanks in advance for any help you can give me for this.
I agree with you about the logic; That's why I'm thinking this might be more of a problem in XAPI or xe than what you're doing in XO. By my logic, if something is tagged as a snapshot, it shouldn't be getting returned on a list of normal VMs. XO is definitely tagging snapshots as snapshots just as I'd expect it to. I just wanted to let you know I'm not trying to point fingers at XO here, just mentioning what's happening and what kind of effects it's having elsewhere. (As well as having it mentioned somewhere others can search for it in case it's causing issues for anyone else.) Should we be looking at this as an XCP problem and not an XO problem?
XO does set
is_a_templateat false to avoid issue when exporting/importing those snapshots, maybe there could be a better approach though:
// VM snapshots are marked as templates, unfortunately it does not play well with XVA export/import // which will import them as templates and not VM snapshots or plain VMs
Ah yes I remember now: if you export those, the XVA you'll import later won't appear as a VM, but as a template. Why? It doesn't make sense to me. When you import an XVA, you want to enjoy the VM (or convert it later in a template if you want).
@JeffBerntsen can you try to export a snapshot from XCP-ng Center, then import it. Does it appear as a VM (so without is a template at true) or as a template?
Based on my experience with earlier versions, it always shows up as a VM after import, not a template, but I haven't tested this with 8.2 or the corresponding version of XCP-ng Center.
I'll test and let you know. Is there anything more specific you need as part of the test? Exporting snapshots created by XO vs. snapshots created by xe vm-snapshot? Importing using one vs. the other? All combinations?
I'd like to understand what
xeand XCP-ng Center are doing
So much for my memory.....
XCP-ng center always exports a snapshot as a template. The menu item is called that and the xva files made always re-import as templates. The equivalent xe function is xe snapshot-export-to-template which does the same thing. The only way to export the snapshot as a VM is to set the is-a-template parameter to false then export with xe vm-export. Once that's been done it looks impossible to set is-a-template back to true. Using either xe vm-param-set or xe snapshot-param-set and trying to set is-a-template back to true gives an error "VM_IS_SNAPSHOT"
I remember one of the backup scripts, NAUBackup/VMBackup if you're familiar with it, doing this and was never quite sure why until now. Looking through its code, it's creating a snapshot, setting is-a-template to false, exporting it as a VM, then deleting the snapshot in order to make an xva file backup while keeping the VM live. I'm not familiar with backups made by XO but I'm guessing you must be doing them in a similar fashion.
Edit: I just did some more testing and discovered that as soon as I set the is-a-template parameter to false on a snapshot made by XCP-ng Center or xe vm-snapshot, it starts showing up in the xsconsole "All VMs" list and in xe vm-list commands just as snapshots created by XO do. In addition, they're showing up both on xe vm-list and xe snapshot-list. Fresh snapshots made with is-a-template still set to true show up in xe snapshot-list but do not show up in xe vm-list or xe template-list. They do show up in the list of templates available in XCP-ng Center when creating a new VM but those with is-a-template set to false do not.
This is starting to smell to me more like a bug in xe or XAPI and possibly XCP-ng center as well but definitely in xe or XAPI. Is there any way to look into what's going on there?