Hi Is there a way to run a script just *before* booting a domain? This is easy when starting up a domain (using a wrapper around xm create) but I find no way to do it if a restart is triggered from inside the domU. Reason: I''d like to automatically mount the root drive and copy the kernel and initramdisk to dom0 and unmont again. So updates of the kernel can be done inside the domU. Regards, Steffen _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Steffen Heil wrote:> Hi > > Is there a way to run a script just *before* booting a domain? > This is easy when starting up a domain (using a wrapper around xm create) > but I find no way to do it if a restart is triggered from inside the domU. > > Reason: I''d like to automatically mount the root drive and copy the kernel > and initramdisk to dom0 and unmont again. So updates of the kernel can be > done inside the domU. > >Is there a reason for not using pyrgub, which does exactly what you want with regards to kernel and initrd? Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
On Fri, 27 Jun 2008, Steffen Heil wrote:> Is there a way to run a script just *before* booting a domain? > This is easy when starting up a domain (using a wrapper around xm create) > but I find no way to do it if a restart is triggered from inside the domU. > > Reason: I''d like to automatically mount the root drive and copy the kernel > and initramdisk to dom0 and unmont again. So updates of the kernel can be > done inside the domU.You could make your own block script, and do this in it. Stefan _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Hi> > Reason: I''d like to automatically mount the root drive and copy the > > kernel and initramdisk to dom0 and unmont again. So updates of the > > kernel can be done inside the domU. > Is there a reason for not using pyrgub, which does exactly > what you want with regards to kernel and initrd?I''ve read that pygrub would have some security problems. If this is wrong, please correct me. However, I also did not find a how-to how to use pygrup. Regards, Steffen _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Hi> You could make your own block script, and do this in it.Never heard of these. Could you give me a hint, where to start looking for that? Regards, Steffen _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
On Fri, 27 Jun 2008, Steffen Heil wrote:> > You could make your own block script, and do this in it. > > Never heard of these. > Could you give me a hint, where to start looking for that?Sure; Go to /etc/xen/scripts there you find a massive script called block. Now imagine you don''t use file:// for your block thing but fancyrootcopy:// With a script named block-fancyrootcopy you can parse the arguments after that. For example this is my iscsi script: http://kinkrsoftware.nl/contrib/xen/block-iscsi If you do file based stuff I suggest you to look at a wrapper around tap:aio:// Stefan _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Steffen Heil wrote:>>> Reason: I''d like to automatically mount the root drive and copy the >>> kernel and initramdisk to dom0 and unmont again. So updates of the >>> kernel can be done inside the domU. >>> >> Is there a reason for not using pyrgub, which does exactly >> what you want with regards to kernel and initrd? >> > > I''ve read that pygrub would have some security problems. > If this is wrong, please correct me. > >It HAD one. They fixed it. I think the same security problem will also bite you if you implement it manually using home-made script :)> However, I also did not find a how-to how to use pygrup. > > >Yeah, that''s the thing. Weird, considering it''s the default bootloader when installed using virt-manager/virt-install. Try here http://www.centos.org/docs/5/html/5.2/Virtualization/sect-Virtualization-Tips_and_tricks-Example_guest_configuration_files_and_parameters.html http://www.centos.org/docs/5/html/5.2/Virtualization/sect-Virtualization-Installing_guests-Create_a_guest_using_virt_manager.html In short, if your domU has kernel, initrd, and grub config on it (as is the case when installed with virt-manager), you can boot it with pygrub. Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Hi I did include "bootloader = /usr/bin/pygrub" in my config (and the root partition does have a /boot/grub/menu.lst"), but xm create states that the bootloader did not return any data. My root partition is a LVM-based xfs filesystem. Does pygrub support this? Where can I find documentation about pygrub? Regards, Steffen (BTW: using debootstraped ubuntu hardy only.)> -----Original Message----- > From: xen-users-bounces@lists.xensource.com > [mailto:xen-users-bounces@lists.xensource.com] On Behalf Of > Fajar A. Nugraha > Sent: Friday, June 27, 2008 11:47 AM > To: xen-users@lists.xensource.com > Subject: Re: [Xen-users] Startup-Hook Script ? > > Steffen Heil wrote: > >>> Reason: I''d like to automatically mount the root drive > and copy the > >>> kernel and initramdisk to dom0 and unmont again. So > updates of the > >>> kernel can be done inside the domU. > >>> > >> Is there a reason for not using pyrgub, which does exactly > what you > >> want with regards to kernel and initrd? > >> > > > > I''ve read that pygrub would have some security problems. > > If this is wrong, please correct me. > > > > > > It HAD one. They fixed it. > I think the same security problem will also bite you if you > implement it manually using home-made script :) > > > However, I also did not find a how-to how to use pygrup. > > > > > > > > Yeah, that''s the thing. Weird, considering it''s the default > bootloader when installed using virt-manager/virt-install. > > Try here > http://www.centos.org/docs/5/html/5.2/Virtualization/sect-Virt > ualization-Tips_and_tricks-Example_guest_configuration_files_a > nd_parameters.html > http://www.centos.org/docs/5/html/5.2/Virtualization/sect-Virt > ualization-Installing_guests-Create_a_guest_using_virt_manager.html > > In short, if your domU has kernel, initrd, and grub config on > it (as is the case when installed with virt-manager), you can > boot it with pygrub. > > Regards, > > Fajar >_______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Steffen Heil wrote:> Hi > > I did include "bootloader = /usr/bin/pygrub" in my config (and the root > partition does have a /boot/grub/menu.lst"), but xm create states that the > bootloader did not return any data. > > My root partition is a LVM-based xfs filesystem. > >I don''t think pygrub supports xfs. Try ext3. On xen-3.2.1 pygrub supports ext2/3, fat, iso9660, reiserfs, and ufs. Since I use pygrub from xen-unstable, I also have zfs support. Try this : pygrub -i /dev/your_vg/your_lv ;echo On a properly-configured-and-recognized root, pygrub will popup a grub-like boot menu. If the fs type is not recognized, pygrub fill show something like : Traceback (most recent call last): File "/usr/bin/pygrub", line 655, in ? fs = fsimage.open(file, get_fs_offset(file)) IOError: [Errno 95] Operation not supported Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Hi> Sure; Go to /etc/xen/scripts there you find a massive script > called block. > Now imagine you don''t use file:// for your block thing but > fancyrootcopy:// > > With a script named block-fancyrootcopy you can parse the > arguments after that. > > For example this is my iscsi script: > > http://kinkrsoftware.nl/contrib/xen/block-iscsi > > If you do file based stuff I suggest you to look at a wrapper > around tap:aio://As I use "phy:" for my devices, I added a script "block-boot-phy" as a copy of block and modified it to copy the kernel out of the device that was attached using "boot-phy:" and this works. But it works too late. The kernel or initrd is already loaded at that point. Anything else I can do? Regards, Steffen _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Steffen Heil wrote:> >> For example this is my iscsi script: >> >> http://kinkrsoftware.nl/contrib/xen/block-iscsi >> >> If you do file based stuff I suggest you to look at a wrapper >> around tap:aio:// >> > > As I use "phy:" for my devices, I added a script "block-boot-phy" as a copy > of block and modified it to copy the kernel out of the device that was > attached using "boot-phy:" and this works. > > But it works too late. The kernel or initrd is already loaded at that point. > >Since function-wise you''re trying to achieve what pygrub does, it might be easier to create another pygrub-like script and put it as bootloader on your config file. for example, pygrub takes these parameters : /usr/bin/pygrub [-q|--quiet] [-i|--interactive] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] <image> when used as bootloader on domU config file, pygrub will be invoked with something like pygrub --output=/var/run/xend/boot/xenbl.3079 /dev/rootvg/testlv Your script should only need to parse --output and <image>. The script output should be something like this, redirected to wherever --output points to : linux (kernel /var/run/xend/boot/boot_kernel._rjEHS)(ramdisk /var/run/xend/boot/boot_ramdisk.5uZPgQ)(args "ro root=/dev/hda1") Attached is bash script that MIGHT work you. This script does not parse grub''s config file, so you might need to manually adjust ARGS at the top of the script as needed (my test works fine with empty ARGS though). Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Hi> Since function-wise you''re trying to achieve what pygrub > does, it might be easier to create another pygrub-like script > and put it as bootloader on your config file. > ... > Attached is bash script that MIGHT work you. This script does > not parse grub''s config file, so you might need to manually > adjust ARGS at the top of the script as needed (my test works > fine with empty ARGS though).Great idea. I didn''t know I could implement bootloaders myself. I merged my block-script with your bootloader-script and it works great. I parses /boot/grub/menu.lst (inside the domUs-root-partition), reads "kernel" and "ramdisk" path of the "default"-th entry in the configuration list, copies those to the dom0, and returns appropiate paths to xen. Last problem: The "exit 3" does not seem to work correctly. Whenever a problem exists, xm create just hangs instead of stopping... For anyone interested I have pasted it below. Regards, Steffen #!/bin/bash arg_count=$# device=${!arg_count} args="" output="" until [ -z "$1" ] do if [ ${1:0:7} = "--args=" ];then args=${1:7} elif [ ${1:0:9} = "--output=" ];then output=${1:9} fi shift done if [ -z "$args" ] || [ -z "$output" ] || [ ! -e "$device" ] then exit 3 fi mount="$output-mount" mkdir "$mount" mount -o ro "$device" "$mount" if [ $? -gt 0 ];then rmdir "$mount" exit 3 fi config=`awk ''BEGIN { x=-1 } $1=="default" { x=$2+1 } $1=="title" { x=x-1 } x==0 && $1=="kernel" && $2~/(\/[a-z0-9-]|[\\.a-z0-9-]*)*/ { kernel=$2 } x==0 && $1=="initrd" && $2~/(\/[a-z0-9-]|[\\.a-z0-9-]*)*/ { initrd=$2 } END { print kernel " " initrd }'' < $mount/boot/grub/menu.lst` kernel=${config% *} initrd=${config#* } if [ -z "$kernel" ] || [ -z "$initrd" ] || [ ! -e "$mount$kernel" ] || [ ! -e "$mount$initrd" ] then umount "$mount" rmdir "$mount" exit 3 fi echo "$device, $mount, $kernel, $initrd, $output" >>/block.log cp "$mount$kernel" "$output-kernel" cp "$mount$initrd" "$output-initrd" umount "$mount" rmdir "$mount" echo -n "linux (kernel $output-kernel)(ramdisk $output-initrd)(args \"$args\")" >> "$output" _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Steffen Heil wrote:> Great idea. I didn''t know I could implement bootloaders myself. > I merged my block-script with your bootloader-script and it works great. > >> Last problem: The "exit 3" does not seem to work correctly. Whenever a > problem exists, xm create just hangs instead of stopping... > >When that happens, I have to "xm destroy" the newly created domU :) I believe that''s because --output (/var/run/xend/boot/xenbl.3079 in my example) is a pipe, and xen is simply waiting on that pipe. It doesn''t know that the bootloader has quit. Perhaps you can try feeding it with an empty line, or perhaps some garbage like linux (kernel /tmp/not_found)(ramdisk /tmp/not_found)(args "") whose purpose is simply to tell xen it has finished. AFAIK, if xen can''t find the mentioned kernel/initrd it simply quits with an error message anyway. Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users