Wednesday, September 4, 2013

Loading the amd patched KVM on SmartOS at boot

mkdir -p /opt/custom/{smf,bin,kvm} &&
curl -kL https://raw.github.com/gist/2cb28f48a01b56c01153/postboot \
   > /opt/custom/bin/postboot &&
chmod 755 /opt/custom/bin/postboot &&
curl -kL https://raw.github.com/gist/2cb28f48a01b56c01153/postboot.xml \
   > /opt/custom/smf/postboot.xml &&
cd /opt/custom/kvm &&
curl -kL https://jmc.sysmgr.org/downloads/kvm-ec85cf5f7.tar.gz | tar xvfz - &&
svccfg import /opt/custom/smf/postboot.xml
jclulow uses this method to mount the kvm binary from the tarball over the system-provided binary and load the module at boot.


Saving the files since the links have been changed on github. Also that kernel version is no longer available at that url. So will have to self host to use in future.

postboot
#!/bin/ksh
[[ -f /var/run/.postboot ]] && {
echo "postboot already run"
exit 0
}
mount -F lofs -o ro \
/opt/custom/kvm/kvm \
/usr/kernel/drv/amd64/kvm &&
update_drv kvm
touch /var/run/.postboot
postboot.xml
<?xml version="1.0"?><!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='site:postboot'>
<service
        name='site/postboot'
        type='service'
        version='1'>
        <create_default_instance enabled='true' />
        <single_instance />
        <dependency
                name='fs-root'
                grouping='require_all'
                restart_on='none'
                type='service'>
                <service_fmri value='svc:/system/filesystem/root' />
        </dependency>
        <exec_method
                type='method'
                name='start'
                exec='/opt/custom/bin/postboot'
                timeout_seconds='0'>
        </exec_method>
        <exec_method
                type='method'
                name='stop'
                exec=':true'
                timeout_seconds='0'>
        </exec_method>
        <property_group name='startd' type='framework'>
                <propval name='duration' type='astring' value='transient' />
        </property_group>
        <stability value='Unstable' />
</service>
</service_bundle>

No comments:

Post a Comment