Skip to content

Commit

Permalink
virt-install-ubuntu: Add create_pool() function
Browse files Browse the repository at this point in the history
It seems that on fresh Ubuntu systems the default storage pool for
libvirt is not created by default. So we check for its existance and
create it if needed.
  • Loading branch information
sbates130272 committed Oct 31, 2022
1 parent 29d9a67 commit 7cb66dc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libvirt/virt-install-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ EOF
cloud-localds -v --network-config=network-config-${NAME}.cfg \
${NAME}-seed.qcow2 cloud-config-${NAME}

create_pool() {
rc=0
`virsh pool-info $1 > /dev/null 2>&1` || rc=$?
if [[ $rc -ne 0 ]]; then
virsh pool-define-as $1 dir --target /var/lib/libvirt/images/
virsh pool-autostart $1
virsh pool-start $1
fi
}

remove_vol() {
rc=0
`virsh vol-info --pool default $1 > /dev/null 2>&1` || rc=$?
Expand All @@ -154,6 +164,8 @@ remove_vol() {
fi
}

create_pool default

remove_vol ${NAME}.qcow2
virsh vol-create-as default ${NAME}.qcow2 ${SIZE}G --format qcow2
virsh vol-upload --pool default ${NAME}.qcow2 ${NAME}.qcow2
Expand Down

0 comments on commit 7cb66dc

Please sign in to comment.