Index: trunk/packages/sipb-xen-database/sipb-xen-database/client/etc/xen/sipb-database
===================================================================
--- trunk/packages/sipb-xen-database/sipb-xen-database/client/etc/xen/sipb-database	(revision 243)
+++ trunk/packages/sipb-xen-database/sipb-xen-database/client/etc/xen/sipb-database	(revision 245)
@@ -73,5 +73,9 @@
     disk.append('file:'+tmptree+'/install.iso,hdc:cdrom,r')
     boot = 'd'
-    
+
+elif 'disks' in locals(): # for the copying installer's use
+    disk = disks.split(' ')
+    boot = 'c'
+
 elif 'cdrom_image' in locals():
     check(re.match('^[A-Za-z0-9][A-Za-z0-9_.-]*$', cdrom_image))
Index: trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/files/usr/sbin/sipb-xen-duplicate
===================================================================
--- trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/files/usr/sbin/sipb-xen-duplicate	(revision 243)
+++ trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/files/usr/sbin/sipb-xen-duplicate	(revision 245)
@@ -1,3 +1,3 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.5
 
 import sys
@@ -5,5 +5,5 @@
 import shutil
 import tempfile
-from subprocess import call, Popen
+from subprocess import call, check_call, Popen
 
 # TODO:
@@ -72,4 +72,29 @@
   print 'losetup -d '+destfs
 
+def duplicate_by_vm(source, target, *args):
+  # source, target should be machine names
+  prefix = 'd_'
+  # 1. copy (by dd) source to target
+  source_device = '/dev/xenvg/' + prefix + source + '_hda'
+  target_device = '/dev/xenvg/' + prefix + target + '_hda'
+  #check_call(['/bin/dd', 'bs=1M', 'conv=nocreat',
+  #            'if='+source_device, 'of='+target_device])
+  # 2. prepare arguments volume
+  args_volume = prefix+target+'_args'
+  args_device = '/dev/xenvg/' + args_volume
+  check_call(['/sbin/lvcreate', 'xenvg', '--name', args_volume, '--size', '4K'])
+  file(args_device, 'w').write('\n'.join(args) + '\n')
+
+  copier_device = '/dev/xenvg/d_wert_hda'
+  check_call(['/usr/sbin/xm', 'create', 'sipb-database',
+              'machine_name='+target,
+              'disks=' + ' '.join(['phy:'+copier_device+',hda,w',
+                                   'phy:'+target_device+',hdc,w',
+                                   'phy:'+args_device+',hdd,w'])])
+  boot = 'c'
+
+  # XXX make this happen! check_call(['/sbin/lvremove', '-f', 'xenvg/'+args_volume])
+  
+
 if __name__ == '__main__':
-  duplicate_lv(*sys.argv[1:])
+  duplicate_by_vm(*sys.argv[1:])
Index: trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/partial/copying-installer.sh
===================================================================
--- trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/partial/copying-installer.sh	(revision 245)
+++ trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/partial/copying-installer.sh	(revision 245)
@@ -0,0 +1,15 @@
+#!/bin/bash
+# hda is the copying-installer image itself
+# hdb is unused (was the source image)
+# hdc is the target image
+# hdd is the arguments image
+
+exec 3</dev/hdd
+read -r -u 3 HOSTNAME
+read -r -u 3 ROOTPW
+exec 3<&-
+
+mount /dev/hdc1 /mnt/new
+/mnt/new/post-copy /mnt/new "$HOSTNAME" "$ROOTPW"
+umount /mnt/new
+sync
Index: trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/partial/post-copy
===================================================================
--- trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/partial/post-copy	(revision 245)
+++ trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/partial/post-copy	(revision 245)
@@ -0,0 +1,6 @@
+#!/bin/bash
+TARGET="$1"
+HOSTNAME="$2"
+ROOTPW="$3"
+(printf "%s\n" "$ROOTPW"; sleep .2; printf "%s\n" "$ROOTPW") \
+ | /usr/sbin/chroot "$TARGET" /usr/bin/passwd root
