xcp
xcp copied to clipboard
FreeBSD / FreeNAS xen-guest-tools with Python3 support
Upgrade the xen-guest-tools and the other packages that depends on python2 to python3. This will allow in case to enable them back in FreeNas and to allow other FreeBsd to use the flavor of python they prefer.
Hi!
Note sure to understand, should it be FreeBSD/FreeNAS packager responsibility? Or it's something else that should be done in the code itself of the tools?
For what I know, the code itself is not compatible with Python 3 and because of it for example in FreeNas they are no more including the xen-guest-tools in the distribution.
Take a look at here: https://redmine.ixsystems.com/issues/24824
I really don't know who's in charge to fix this, but it seems quite stuck. Even the package in fresh ports is seen compatible with python2 and nothing else.
On Thu, 11 Apr 2019 at 14:23, Olivier Lambert [email protected] wrote:
Hi!
Note sure to understand, should it be FreeBSD/FreeNAS packager responsibility? Or it's something else that should be done in the code itself of the tools?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xcp-ng/xcp/issues/172#issuecomment-482092237, or mute the thread https://github.com/notifications/unsubscribe-auth/AF05vwG-zXm_q1tsMWeyw1SM81htS0j2ks5vfyk6gaJpZM4cpcXL .
The tools that we provide are not written in python. They are written in Go and compiled. See https://github.com/xenserver/xe-guest-utilities/
I don't know what xen-guest-tools
is, maybe tools directly related to the Xen project and not used in XCP-ng?
There's a xen-tools
package that does contain python scripts: https://koji.xcp-ng.org/rpminfo?rpmID=3100
It is not installed inside the guests, though, it's installed in dom0. It comes from the Xen project so the upstream you're looking for regarding the port to python 3 is definitely the Xen project, according to me.
But I remember that when I was using XenServer 7.2 and FreeNas 9.1 those were working. So do you think they are compatible. The Go way clearly seems more trustable than Python, and moreover they are for XCP-ng. So I should give a try maybe.
So, I am nor a GO expert, nor a FreeBSD or Linux expert, but at least I am a dev. Trying to cross compile the xe-guest-utilities, system.go does not cross compile at all. `/*
-
Send a notification on @c when the system has just been resumed after
-
sleep. This is implemented by watching for a change in real time compared
-
with monotonic time. This may cause a spurious notification if the time
-
is changed by a user or NTP jump. */ func NotifyResumed(c chan int) { ts := ITimerSpec{Interval: syscall.Timespec{math.MaxInt32, 0}, Value: syscall.Timespec{0, 0}} buf := make([]byte, 8) for { fd, err := timerfdCreate(CLOCK_REALTIME, TFD_CLOEXEC) if err != nil { return }
err = timerfdSettime(fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &ts, nil) if err != nil { return } _, err = syscall.Read(fd, buf) if err == syscall.ECANCELED { // Wait a bit for the system to settle down after resuming time.Sleep(time.Duration(1) * time.Second) c <- 1 } syscall.Close(fd)
} }`
Mostly this is unsupported in FreeBSD and reading around seems I should switch to use kqueue that exists, but really I can't figure out how to use it. Someone has a good example? I imagine that the idea is to create a timer linked to the realtime clock that will fire in the future showing the machine in fact it is working.
From what I can see, the xe-guest-utilities
package in FreeBSD is not really built on FreeBSD, but rather packaged directly from a binary: https://svnweb.freebsd.org/ports/head/sysutils/xe-guest-utilities/Makefile?revision=412349&view=markup
@stormi and that executable do you mean it is committed to the FreeBSD repo? Seems fairly strange.
I don't know how their buildsystem works and what's committed where, but clearly, I see no dependency to Go in the file and it says NO_BUILD= yes
.
That seems fairly ok with what I know. All the dependencies they talk about is always to python2 and if you take a look at those dependencies they have something related to python2 too.
I was just wanting to know, if starting from the xe-guest-utilities repo that you pasted before if I can cross compile it to freebsd, but unfortunately there is that piece of code I pasted before that does not compile. I should switch to use kqueue, but I can't find exactly how to use it. Do you have any suggestion?
Let's first try to summarize (and add some pieces of information that I obtained).
-
xe-guest-utilities
are the guest tools for VMs running in XenServer and XCP-ng. They are developed by Citrix: https://github.com/xenserver/xe-guest-utilities/ -
xen-guest-tools
are just a collection of binaries allowing to interact with the host throughxenstore
. They are developed by the Xen project: https://xenproject.org/ (original name of the tools: Xen Tools)
From what I know, only a handful of people would really use those "xen-guest-tools" from inside a VM running inside a XCP-ng or XenServer host. In my opinion it makes absolutely no sense that xe-guest-utilities
requires xen-guest-tools
as a runtime dependency.
From what I understand, FreeBSD has the packages in their repositories but recent FreeNAS doesn't because they did not manage to build the tools using python3 (contrarily as what I said earlier, the Xen tools themselves are not in python, but it looks like they need python during the build process). Maybe you should try to see if you can manage to build them with python3 (I don't know if it's been fixed in more recent versions of the tools, maybe looking at more recent versions of Xen would give clues). If it doesn't work, you should contact people from the Xen project itself.
xe-guest-utilities
should not require xen-guest-tools
, so if your target is XCP-ng and XenServer rather than Xen itself, you could just break the dependency. This alone would allow to provide xe-guest-utilities
, if the fact that the binaries are not built through their buildsystem is OK. If it's not OK, then indeed you need to manage to build the tools on FreeBSD. I don't know if it's supported by XenServer. I'll not be able to help much: I know little about Go and FreeBSD. You could try to reach the developers through https://github.com/xenserver/xe-guest-utilities/issues
Good luck and keep us posted!
Above comment updated to make it more accurate.
But I remember that when I was using XenServer 7.2 and FreeNas 9.1 those were working.
I concur. I've been stuck at using FreeNas 9.1 exactly for that reason and haven't upgraded since.
@jeremfg that is because in FreeNas 9.x Python 2 was used and they enabled the ability to build those packages too. Those packages were working with XenServer too, but it is enough true that in fact xe-guest-utilities can do the trick. Unfortunately I could not go on the case anymore. I really have too few time to look into this.
So I did not had any time to look into the go build, but this week I tried a weird thing. FreeNAS is locked down to avoid using pkg. So I enabled in /usr/local/etc/pkg/repos the FreeBSD repo and then I tried to pkg install xe-guest-utilities. It worked and I was able to use xenguest script under rc.d to start correctly the daemon.
Unfortunately after rebooting the script xenguest was disappearing.
I tried various way to let it stay without success.
Then I found out that xe-daemon was still there with all the xen** commands, just the script and the pkg repos modifications and installed packages has been lost.
Maybe they were always there, and I never noticed.
After this I added a preinit startup script and as command i inserted /usr/local/sbin/xe-daemon -p /var/run/xe-daemon.pid &
This is enough to let XCP recognize it and allow to use the Reboot and Shutdown commands (instead of the forced ones).
@etomm that worked for me, thanks! Note that in FreeNAS 11.2, you have to also disable the local package repo (per this guy), or you'll get error messages from pkg
when trying to update the repo package lists
@etomm and @woopla thanks a lot! Could you add a detailed "how to" in XCP-ng wiki? This would be awesome and let people find a quick way to have tools for FreeNas :+1:
@olivierlambert done, see here. I also added a pointer on the home page, in the Miscellaneous section.
@woopla thanks a lot!
I added the link in https://github.com/xcp-ng/xcp/wiki/Guest-Tools#misc
Thank you @woopla I really had no time for it! :D
Thank you for this @etomm and @woopla ! Gives me a path forward, away from FreeNAS 9.x that I'm looking forward in trying out.
The info in the wiki worked, although I had to edit the files manually for it to actually work. Glad I can now shutdown properly, Saved me some head scratching for sure!
Same for me; the sed commands didn't work, manually editing (with nano) did.
root@freenas[~]# cat /usr/local/etc/pkg/repos/FreeBSD.conf
FreeBSD: {
enabled: no
}
root@freenas[~]# sed 's/enabled: no/enabled: yes/' /usr/local/etc/pkg/repos/FreeBSD.conf
FreeBSD: {
enabled: yes
}
root@freenas[~]# cat /usr/local/etc/pkg/repos/FreeBSD.conf
FreeBSD: {
enabled: no
}
root@freenas[~]#
Hi all. I've installed the xe-guest-utilities package on a few different FreeNAS installations (versions 11.2-U7 and 11.3-RELEASE) over the last couple of weeks, but I just created a fresh FreeNAS 11.2-U7 install yesterday and when I try to run the 'pkg install xe-guest-utilities' command I'm now running into the following error (with the debug flag enabled for more verbose output):
DBG(1)[7363]> pkg initialized
Updating FreeBSD repository catalogue...
DBG(1)[7363]> PkgRepo: verifying update for FreeBSD
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
DBG(1)[7363]> PkgRepo: need forced update of FreeBSD
DBG(1)[7363]> Pkgrepo, begin update of '/var/db/pkg/repo-FreeBSD.sqlite'
DBG(1)[7363]> Fetch: fetching from: http://pkgmir.geo.freebsd.org/FreeBSD:11:amd64/latest/meta.txz with opts "i"
Fetching meta.txz: 100% 916 B 0.9kB/s 00:01
DBG(1)[7363]> PkgRepo: extracting meta of repo FreeBSD
DBG(1)[7386]> PkgRepo: extracting signature of repo in a sandbox
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
repository FreeBSD has no meta file, using default settings
DBG(1)[7363]> Fetch: fetching from: http://pkgmir.geo.freebsd.org/FreeBSD:11:amd64/latest/packagesite.txz with opts "i"
Fetching packagesite.txz: 100% 6 MiB 6.5MB/s 00:01
DBG(1)[7363]> PkgRepo: extracting packagesite.yaml of repo FreeBSD
DBG(1)[7388]> PkgRepo: extracting signature of repo in a sandbox
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Unable to open created repository FreeBSD
Unable to update repository FreeBSD
Error updating repositories!
Hi @amp88
I did a fresh install of 11.3-RELEASE last weekend with no issues.
I've got a 11.2-U7 that I plan to do when I can find some time and then update to 11.3, so will revert if I have any issues. I currently have the tools running via this method - https://xcp-ng.org/forum/topic/996/freenas-in-a-vm/9?_=1582023651858 maybe a workaround if you need it.......
Hi @amp88
I did a fresh install of 11.3-RELEASE last weekend with no issues.
I've got a 11.2-U7 that I plan to do when I can find some time and then update to 11.3, so will revert if I have any issues. I currently have the tools running via this method - https://xcp-ng.org/forum/topic/996/freenas-in-a-vm/9?_=1582023651858 maybe a workaround if you need it.......
Thanks, I'll give that workaround a try tonight.
One of the issues I'm having with FreeNAS 11.3 (which isn't happening on 11.2-U7) is that when I try to install the plex server plugin it fails with the message "Error: plex-static had a failure Exception: RuntimeError Message: Stopped plex-static due to VNET failure Partial plugin destroyed". From the research I tried to do it appears this 'VNET failure' could be related to creating a virtualised network adapter for plex within a virtualised environment. I don't get this failure with FreeNAS 11.2-U7, which suggests the problem might be related to FreeBSD 11.3 and its interaction with XCP-ng 8.0, but I don't know.
I made a thread about the issue on the FreeNAS forum, but didn't get any responses (possibly because the problem is occurring on a virtualised installation):
https://www.ixsystems.com/community/threads/freenas-11-3-plex-server-installed-failed-caused-server-reboot-crash-cant-remove-broken-install.82091/
@amp88 A bit off topic for this thread, but have you enabled Nested Virtualization (long shot), can be done in Xen Orchestra. I tried to run a VM in FreeNAS on top of XCP-ng once and it didn't work, think it crashed. I assumed it was something to do with FreeBSD virtualization on top of Linux virtualization and just created a VM instead.
Would be interesting to see if xen-tools fixes things though....
I did a fresh install of 11.3-RELEASE last weekend with no issues.
I have installed a fresh 11.3 as well, everything related to the install and adding guest tools goes smooth. But afterwards, well that's another thread... Have had quite few little hiccups with 11.3 vs 11.2
@amp88 A bit off topic for this thread, but have you enabled Nested Virtualization (long shot), can be done in Xen Orchestra. I tried to run a VM in FreeNAS on top of XCP-ng once and it didn't work, think it crashed. I assumed it was something to do with FreeBSD virtualization on top of Linux virtualization and just created a VM instead.
Would be interesting to see if xen-tools fixes things though....
I didn't get a chance to test it last night, but according to someone on the FreeNAS forum the issue with the "pkg install xe-guest-utilities" command not working on FreeNAS 11.2 is that FreeBSD 11.2 is now no longer supported, so the packages for that version are no longer in the package repository. So it looks like I'll just go back to FreeNAS 11.3 and try and work around the issues I'm having with it. I'll have a look at the Nested Virtualisation feature you suggested, and if that doesn't work I'll just run my Plex server from a Windows VM instead. Thanks for your help.