On Wed, Jan 18, 2017 at 21:23 +0300, Dinar Talypov wrote:
> 
> Hi,
>

Privet, Dinar!

> The patch below fakes pv drivers installation.
> Version numbers are taken from FreeBSD sysutils/xe-guest-utilities.
> With this xen allows reboot or shutdown OpenBSD guest.
>

Which Xen version or what environment requires such properties?
Neither plain Xen 4.5+ on Ubuntu nor EC2 version have the "attr"
subtree and you can reboot and/or shutdown OpenBSD guests there
without any issues (for instance via xl on Ubuntu).

> Index: sys/dev/pv/xen.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pv/xen.c,v
> retrieving revision 1.71
> diff -u -p -u -r1.71 xen.c
> --- sys/dev/pv/xen.c  10 Jan 2017 17:16:39 -0000      1.71
> +++ sys/dev/pv/xen.c  18 Jan 2017 18:05:27 -0000
> @@ -35,6 +35,7 @@
>  #include <sys/signalvar.h>
>  #include <sys/malloc.h>
>  #include <sys/kernel.h>
> +#include <sys/systm.h>
>  #include <sys/stdint.h>
>  #include <sys/device.h>
>  #include <sys/task.h>
> @@ -75,6 +76,7 @@ void        xen_disable_emulated_devices(struct
>  int  xen_match(struct device *, void *, void *);
>  void xen_attach(struct device *, struct device *, void *);
>  void xen_deferred(struct device *);
> +void xen_inform_host(struct xen_softc *);
>  void xen_control(void *);
>  void xen_hotplug(void *);
>  void xen_resume(struct device *);
> @@ -194,6 +196,29 @@ xen_deferred(struct device *self)
>           xen_control, sc))
>               printf("%s: failed to setup shutdown control watch\n",
>                   sc->sc_dev.dv_xname);
> +     xen_inform_host(sc);
> +}
> +void
> +xen_inform_host(struct xen_softc *sc)
> +{
> +     char *os_name;
> +     
> +     /* Fake PV drivers version */
> +     xs_setnum(sc, "attr/PVAddons", "MajorVersion", 6);
> +     xs_setnum(sc, "attr/PVAddons", "MinorVersion", 2);
> +     xs_setnum(sc, "attr/PVAddons", "MicroVersion", 0);
> +     xs_setnum(sc, "attr/PVAddons", "BuildVersion", 76888);

Where did you get this build version number from?
It looks rather arbitrary.

> +     xs_setnum(sc, "attr/PVAddons", "Installed", 1);
> +
> +     /* Set OS version */
> +     snprintf(os_name, sizeof((char *)ostype) + sizeof((char *)osrelease),
> +                     "%s %s", ostype, osrelease);
> +     xs_setprop(sc, "data", "os_name", (char *)os_name, strlen(os_name));
> +     xs_setprop(sc, "data", "os_uname", (char *)osrelease, 
> strlen(osrelease));
> +     xs_setprop(sc, "data", "os_distro", (char *)ostype, strlen(ostype));
> +
> +     /* Update xenstore */
> +     xs_setnum(sc, "data", "updated", 1);
>  }
>  
>  void
> 

In any case you can set these values yourself with hostctl(8),
i.e. 'hostctl attr/PVAddons/BuildVersion 123456'.  There should
be no need to do that from the kernel.

Reply via email to