qemush : n'exporter QEMUSH_NAME que quand on en a besoin

This commit is contained in:
Ahurac 2024-03-24 22:52:37 +01:00
parent d1d579fcd2
commit b9b96f6467

View file

@ -51,7 +51,7 @@ error_usage() {
# Function to start a virtual machine # Function to start a virtual machine
public_start() { public_start() {
QEMUSH_NAME="$1" export QEMUSH_NAME="$1"
set -- "$@" \ set -- "$@" \
-name "$QEMUSH_NAME" \ -name "$QEMUSH_NAME" \
@ -66,7 +66,7 @@ public_start() {
# Attach to a running virtual machine output, the latest opened if no # Attach to a running virtual machine output, the latest opened if no
# argument is provided # argument is provided
public_attach() { public_attach() {
QEMUSH_NAME="$1" export QEMUSH_NAME="$1"
shift shift
exec socat -,rawer,escape=15 "UNIX-CONNECT:$(pathof socket)" exec socat -,rawer,escape=15 "UNIX-CONNECT:$(pathof socket)"
@ -90,7 +90,7 @@ public_ls() {
# Create a copy-on-write disk for a virtual machine # Create a copy-on-write disk for a virtual machine
public_diskadd() { public_diskadd() {
QEMUSH_NAME="$1" export QEMUSH_NAME="$1"
shift shift
exec qemu-img create -f qcow2 "$(pathof disk)" "$1" exec qemu-img create -f qcow2 "$(pathof disk)" "$1"
} }
@ -98,7 +98,7 @@ public_diskadd() {
# Delete a disk # Delete a disk
public_diskrm() { public_diskrm() {
for disk in "$@"; do for disk in "$@"; do
QEMUSH_NAME="$disk" export QEMUSH_NAME="$disk"
rm -vi -- "$(pathof disk)" rm -vi -- "$(pathof disk)"
done done
} }
@ -170,7 +170,7 @@ public_do() {
# Expose SPICE via TCP # Expose SPICE via TCP
public_spice() { public_spice() {
QEMUSH_NAME="$1" export QEMUSH_NAME="$1"
if [ -n "$2" ]; then if [ -n "$2" ]; then
port=$2 port=$2
else else