From a458bbcdeb06686bd34826fa8bcb1c4f4d2a4888 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 19 Oct 2016 13:06:18 +0200 Subject: virsh, virt-install: explicitly pass connect URI "qemu:///system" --- tdfvm-install | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tdfvm-install b/tdfvm-install index ed02fba..859d913 100755 --- a/tdfvm-install +++ b/tdfvm-install @@ -14,6 +14,7 @@ usage() { } +LIBVIRT_URI=qemu:///system ARCH=$(dpkg-architecture -qDEB_TARGET_ARCH) unset ISO USER_NAME=root @@ -219,11 +220,11 @@ grep -q '^kvm\s' /proc/modules || echo 'WARN: KVM not available!' >&2 [ ! ${OUTPUT+x} ] || mkdir -p "$OUTPUT" if [ "$FORCE" = y ]; then - virsh destroy "$VM_NAME" >/dev/null 2>&1 || true - virsh undefine "$VM_NAME" >/dev/null 2>&1 || true + virsh -c "$LIBVIRT_URI" destroy "$VM_NAME" >/dev/null 2>&1 || true + virsh -c "$LIBVIRT_URI" undefine "$VM_NAME" >/dev/null 2>&1 || true fi -virt-install -q \ +virt-install -q --connect "$LIBVIRT_URI" \ --name "$VM_NAME" \ --os-variant "debianwheezy" \ --arch "$(dpkg-architecture -A"$ARCH" -qDEB_TARGET_GNU_CPU)" \ @@ -241,13 +242,13 @@ virt-install -q \ ( vmdef="$(mktemp --tmpdir)" trap 'rm -f "$vmdef"' EXIT TERM INT - virsh dumpxml "$VM_NAME" >"$vmdef" + virsh -c "$LIBVIRT_URI" dumpxml "$VM_NAME" >"$vmdef" for xpath in \ "/domain/devices/filesystem[source/@dir=\"$VMTMPDIR/virtfs\"][target/@dir='virtfs']" \ "/domain/devices/disk[@type='file'][@device='cdrom']"; do if [ -z "$TRANSIENT" ]; then - virsh --quiet detach-device --config "$VM_NAME" \ + virsh -c "$LIBVIRT_URI" --quiet detach-device --config "$VM_NAME" \ <(xmlstarlet select --template --copy-of "$xpath" <"$vmdef") elif [ ${OUTPUT+x} ]; then xmlstarlet edit --inplace --delete "$xpath" "$vmdef" @@ -257,7 +258,7 @@ virt-install -q \ ) # wait until the VM terminates (there is actually a race condition here, # but the XML massaging above should be faster than any install) -virsh console "$VM_NAME" --safe >/dev/null +virsh -c "$LIBVIRT_URI" console "$VM_NAME" --safe >/dev/null ( if [ -f "$VMTMPDIR/virtfs/minion.pub" ]; then -- cgit v1.2.3