Skip to content

scripts/attach-static-vdis: Toggle nullglob to fix behavior on empty dir - #7204

Open
last-genius wants to merge 1 commit into
xapi-project:masterfrom
last-genius:asv/static-vdis-fix
Open

scripts/attach-static-vdis: Toggle nullglob to fix behavior on empty dir#7204
last-genius wants to merge 1 commit into
xapi-project:masterfrom
last-genius:asv/static-vdis-fix

Conversation

@last-genius

Copy link
Copy Markdown
Contributor

If STATE_DIR exists but is not empty, then globs for it in the form of STATE_DIR/* and STATE_DIR/*/vdi-uuid will be passed in literal form, causing errors like:

cat: /etc/xensource/static-vdis-test/*/vdi-uuid: No such file or directory

Toggle nullglob instead, which turns the whole glob string empty and does not enter the body of the loop iterating over the matches.

If STATE_DIR exists but is not empty, then globs for it in the form of
STATE_DIR/* and STATE_DIR/*/vdi-uuid will be passed in literal form, causing
errors like:

    cat: /etc/xensource/static-vdis-test/*/vdi-uuid: No such file or directory

Toggle nullglob instead, which turns the whole glob string empty and does not
enter the body of the loop iterating over the matches.

Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>

@changlei-li changlei-li left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What else problem other than the cat error log? I think the error log is just no-harm

@last-genius

last-genius commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

What else problem other than the cat error log? I think the error log is just no-harm

exit code is 1 so the systemd service fails:

$ ./attach-static-vdis start
cat: /etc/xensource/static-vdis/*/vdi-uuid: No such file or directory
Attempting to attach VDI:
Attempt to attach VDI:  failed -- skipping (Error was: Traceback (most recent call last):
  File "/opt/xensource/bin/static-vdis", line 413, in <module>
    main()
  File "/opt/xensource/bin/static-vdis", line 404, in main
    disk_path = attach(sys.argv[2])
  File "/opt/xensource/bin/static-vdis", line 343, in attach
    raise Exception("Disk configuration not found")
Exception: Disk configuration not found)
$ echo $?
1
$ ./nullglob-attach-static-vdis start
Attempting to attach all statically-configured VDIs
$ echo $?
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants