summaryrefslogtreecommitdiff
path: root/libvirt-write-disk-attach-xml
diff options
context:
space:
mode:
Diffstat (limited to 'libvirt-write-disk-attach-xml')
-rwxr-xr-xlibvirt-write-disk-attach-xml23
1 files changed, 23 insertions, 0 deletions
diff --git a/libvirt-write-disk-attach-xml b/libvirt-write-disk-attach-xml
new file mode 100755
index 0000000..e813452
--- /dev/null
+++ b/libvirt-write-disk-attach-xml
@@ -0,0 +1,23 @@
+#!/bin/sh -f
+
+disks="$1" && [ -n "$disks" ] ||
+ { echo "must give disk image"; exit 1; }
+name=${2:-my-example-dom}
+devs=bcdefghij
+n=0
+for disk in "$@"; do
+ disk=$(readlink -f "$disk") || { echo "failed to get path to $disk" 1>&2; exit 1; }
+ t=${devs#?}
+ dev=vd${devs%${t}}
+ devs=${devs#?}
+ n=$(($n+1))
+ cat <<EOF
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='$disk'/>
+ <target dev='$dev' bus='virtio'/>
+ <boot order='$n'/>
+ </disk>
+EOF
+done
+