-
Notifications
You must be signed in to change notification settings - Fork 93
Updates for libvirt image removal and use directory #1722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
SimonFair
wants to merge
69
commits into
unraid:master
Choose a base branch
from
SimonFair:Remove-Vm-Image
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 9 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
8b495f8
Updates for image removal
SimonFair 6663975
Update VMSettings.page
SimonFair 12da995
Update rc.libvirt
SimonFair 81dd45a
Add libvirt_update script
SimonFair c1cf813
Make script executable
SimonFair ea49630
Update rc.libvirt
SimonFair f2822c7
Changes to VM Settings
SimonFair 28ec848
revert rc.libvirt changes
SimonFair de53cf4
Initial moving libvirt image to folder and vice versa.
SimonFair 3ffebdf
Update help text
SimonFair a9d8167
Merge remote-tracking branch 'upstream/master' into Remove-Vm-Image
SimonFair 7b03382
Remove secondary path.
SimonFair fca221a
Remove secondary code.
SimonFair d5d3bad
Merge remote-tracking branch 'upstream/master' into Remove-Vm-Image
SimonFair 79e2e53
Merge remote-tracking branch 'upstream/master' into Remove-Vm-Image
SimonFair 7256297
Create location file.
SimonFair 00ed5d2
Make script executable
SimonFair d13e6b2
XML movements
SimonFair a41622b
Make script executable
SimonFair 092af90
Udates to XML movement.
SimonFair 6d7c50c
Updates
SimonFair 5287435
Add XML processing to save configs in vm dir.
SimonFair 111f3d0
Update libvirt.php
SimonFair 75ffb61
Update libvirt.php
SimonFair eab65bf
Update emhttp/languages/en_US/helptext.txt
SimonFair f82fc7b
Update emhttp/plugins/dynamix.vm.manager/VMSettings.page
SimonFair 3b4139b
Update emhttp/plugins/dynamix.vm.manager/include/fs_helpers.php
SimonFair ab766fb
Update emhttp/plugins/dynamix.vm.manager/scripts/libvirt_init
SimonFair 2e45d29
Update emhttp/plugins/dynamix.vm.manager/scripts/libvirt_init
SimonFair 4e7b667
Update emhttp/plugins/dynamix.vm.manager/scripts/libvirtcopy
SimonFair 80b04cb
Update etc/rc.d/rc.libvirt
SimonFair 835b348
Update emhttp/plugins/dynamix.vm.manager/scripts/libvirtmigrate
SimonFair 9668907
Update emhttp/plugins/dynamix.vm.manager/scripts/libvirtrestore
SimonFair 62629a1
Update emhttp/plugins/dynamix.vm.manager/scripts/savehook.php
SimonFair a9c4b21
Update libvirt.php
SimonFair 1b1f4f4
Merge branch 'Remove-Vm-Image' of https://github.com/SimonFair/webgui…
SimonFair a640587
Update libvirtmigrate
SimonFair 0f4cda7
Coderabbit updates
SimonFair c2533c6
check for new model flag and change paths
SimonFair b1ae311
Update libvirt_paths.php
SimonFair 43d6d87
Create rc.libvirt.conf
SimonFair b689eab
Merge remote-tracking branch 'upstream/master' into Remove-Vm-Image
SimonFair 560ed51
Make script executable
SimonFair 0f8de49
Path changes.
SimonFair 3283bfe
Path processing.
SimonFair e0524d9
Fix delete issue.
SimonFair 9ff9afb
fix snapshot GPF
SimonFair 6fff228
fix nvram creation issue and snapshotdb location.
SimonFair f0f671a
fix nvram processing.
SimonFair 28de0ee
add delete all option
SimonFair 62a461f
remove debug logging
SimonFair c9ec4dd
Code rabbit changes
SimonFair 36b7e58
further updates
SimonFair cae0c9c
Updates
SimonFair 5c10559
Remove nvram for block commit.
SimonFair 6569d17
purge nvram during block operations if removed by qemu
SimonFair 091bb18
Remove directory if empty.
SimonFair 44d7fcf
refactor by creating single is_vm_new_model
SimonFair e6bba6b
code rabbit updates.
SimonFair 23dd144
Migrate to new model
SimonFair fbcc6db
Update libvirt_init
SimonFair 7203a1f
Update libvirt.php
SimonFair 9d745cc
Update libvirt.php
SimonFair 827c65a
Update libvirt.php
SimonFair e0cae04
Update migration process.
SimonFair 05dae8f
Update rc.libvirt
SimonFair b9c7a1b
fix snapshot lookups
SimonFair 8c3026a
Fix for VM autostart post migration
SimonFair 3c406f7
Update rc.libvirt
SimonFair File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,64 @@ | |
| # run & log functions | ||
| . /etc/rc.d/rc.runlog | ||
|
|
||
|
|
||
| # Sync domain data if IMAGE_FILE and OLD_IMAGE_FILE differ | ||
| DOMAIN_CFG=/boot/config/domain.cfg | ||
|
|
||
| # Read values from domain.cfg | ||
| eval $(grep -E '^(IMAGE_FILE|OLD_IMAGE_FILE)=' "$DOMAIN_CFG") | ||
|
|
||
| # Remove quotes | ||
| IMAGE_FILE="${IMAGE_FILE%\"}" | ||
| IMAGE_FILE="${IMAGE_FILE#\"}" | ||
| OLD_IMAGE_FILE="${OLD_IMAGE_FILE%\"}" | ||
| OLD_IMAGE_FILE="${OLD_IMAGE_FILE#\"}" | ||
|
SimonFair marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Proceed only if both variables are set and OLD_IMAGE_FILE exists | ||
| if [ -n "$IMAGE_FILE" ] && [ -n "$OLD_IMAGE_FILE" ] && [ "$IMAGE_FILE" != "$OLD_IMAGE_FILE" ]; then | ||
| if [ ! -e "$OLD_IMAGE_FILE" ]; then | ||
| log "OLD_IMAGE_FILE not found: $OLD_IMAGE_FILE — skipping sync" | ||
| else | ||
| log "IMAGE_FILE and OLD_IMAGE_FILE differ, syncing..." | ||
|
|
||
| TMP_MNT=/etc/libvirt-sync | ||
| IMG_FILE_NAME=$(basename "$IMAGE_FILE") | ||
| OLD_IMG_FILE_NAME=$(basename "$OLD_IMAGE_FILE") | ||
| TIMESTAMP=$(date +%Y%m%d-%H%M%S) | ||
|
|
||
| if [[ "$OLD_IMAGE_FILE" == *.img ]]; then | ||
| # Backup image before mounting | ||
| BACKUP_PATH="${OLD_IMAGE_FILE%.img}.bak-${TIMESTAMP}.img" | ||
| log "Creating backup of OLD_IMAGE_FILE: $BACKUP_PATH" | ||
| cp -p "$OLD_IMAGE_FILE" "$BACKUP_PATH" | ||
|
|
||
| log "Mounting $OLD_IMAGE_FILE to $TMP_MNT" | ||
| mkdir -p "$TMP_MNT" | ||
| mount "$OLD_IMAGE_FILE" "$TMP_MNT" | ||
| log "Copying full contents from image to directory $IMAGE_FILE" | ||
| rsync -a --exclude="$OLD_IMG_FILE_NAME" "$TMP_MNT/" "$IMAGE_FILE/" | ||
| umount "$TMP_MNT" | ||
|
SimonFair marked this conversation as resolved.
Outdated
|
||
| elif [[ "$IMAGE_FILE" == *.img ]]; then | ||
| log "Mounting $IMAGE_FILE to $TMP_MNT" | ||
| mkdir -p "$TMP_MNT" | ||
| mount "$IMAGE_FILE" "$TMP_MNT" | ||
| log "Copying full contents from directory $OLD_IMAGE_FILE to image" | ||
| rsync -a --exclude="$IMG_FILE_NAME" --exclude='*.bak-*.img' "$OLD_IMAGE_FILE/" "$TMP_MNT/" | ||
| umount "$TMP_MNT" | ||
|
SimonFair marked this conversation as resolved.
|
||
| else | ||
| log "Both IMAGE_FILE and OLD_IMAGE_FILE are directories, copying full contents" | ||
| rsync -a --exclude="$IMG_FILE_NAME" "$OLD_IMAGE_FILE/" "$IMAGE_FILE/" | ||
| fi | ||
|
|
||
| # Update OLD_IMAGE_FILE in domain.cfg | ||
| log "Updating OLD_IMAGE_FILE in $DOMAIN_CFG" | ||
| sed -i "s|^OLD_IMAGE_FILE=.*|OLD_IMAGE_FILE=\"$IMAGE_FILE\"|" "$DOMAIN_CFG" | ||
|
Comment on lines
+65
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Escape If 🛠️ Suggested fix- sed -i "s|^OLD_IMAGE_FILE=.*|OLD_IMAGE_FILE=\"$IMAGE_FILE\"|" "$DOMAIN_CFG"
+ SAFE_IMAGE_FILE=$(printf '%s' "$IMAGE_FILE" | sed 's/[\\&|]/\\&/g')
+ sed -i "s|^OLD_IMAGE_FILE=.*|OLD_IMAGE_FILE=\"$SAFE_IMAGE_FILE\"|" "$DOMAIN_CFG"🤖 Prompt for AI Agents |
||
| fi | ||
| else | ||
| log "IMAGE_FILE and OLD_IMAGE_FILE match, or one is unset — skipping sync" | ||
| fi | ||
|
|
||
|
|
||
| # missing qemu directory would indicate new libvirt image file created | ||
| if [ ! -d /etc/libvirt/qemu ]; then | ||
| log "initializing /etc/libvirt" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.