[LU-8832] no virt-what command in SLES Created: 14/Nov/16  Updated: 23/Apr/17  Resolved: 17/Dec/16

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.10.0

Type: Bug Priority: Major
Reporter: Bob Glossman (Inactive) Assignee: James Nunez (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by LU-8831 sanity test_248: test-framework.sh: l... Resolved
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

The virt-what command that is used in the function runnng_in_vm() in test-framework.sh only exists in RHEL, not in SLES. This makes the behavior of any test that uses this function unpredictable on anything but RHEL distros.

The running_in_vm() function was added in http://review.whamcloud.com/20698, part of the fix for LU-8248.



 Comments   
Comment by Andreas Dilger [ 15/Nov/16 ]

The code should be able to handle the lack of "virt-what" by running dmidecode and finally just returning nothing:

running_in_vm() {
        local virt=$(virt-what 2> /dev/null)

        [ $? -eq 0 ] && [ -n "$virt" ] && { echo $virt; return; }

        virt=$(dmidecode -s system-product-name | awk '{print $1}')

        case $virt in
                VMware|KVM|VirtualBox|Parallels) echo ${virt,,} ;;
                *) ;;
        esac
}

What sort of error are you seeing?

Comment by Bob Glossman (Inactive) [ 15/Nov/16 ]

see LU-8831 for an example of an error.

another branch, not master, has a different instance of using virt-what but in that case it makes sure it really exists using 'which virt-what' before using it.

Comment by Andreas Dilger [ 15/Nov/16 ]

Bob, could you please try the above sequence of commands manually to see what "virt" is, and what dmidecode returns. It may be that the problem is really that the ${virt,,} expansion (which converts the string to lower case) is not working in the SLES version of bash. We know that the $virt string is not empty since it has to match one of the guest machine names to even be run.

Comment by Bob Glossman (Inactive) [ 15/Nov/16 ]

Andreas,
It appears you are correct, the SLES version of bash doesn't know about the ,, expansion.
Here are the manual commands:

sles11sp4gm:/home/bogl/lustre-release # virt=$(dmidecode -s system-product-name | awk '{print $1}')
sles11sp4gm:/home/bogl/lustre-release # echo $virt
VMware
sles11sp4gm:/home/bogl/lustre-release # echo ${virt,,}
bash: ${virt,,}: bad substitution

Since it only matters if the string echo'ed by this function is empty or not, why not just echo $virt ?
Who cares if it has some caps in it.

Comment by Bob Glossman (Inactive) [ 15/Nov/16 ]

if it absolutely needs conversion, I think this will work everywhere:

echo $virt | tr '[A-Z]' '[a-z]'

Comment by Bob Glossman (Inactive) [ 15/Nov/16 ]

it looks like only the sles11 bash doesn't know about the ,, expansion. it does work fine in sles12.

fwiw, it works as expected in all versions of el6 and el7 I can find and try.

Comment by Joseph Gmitter (Inactive) [ 15/Nov/16 ]

Assigning to James for the test update

Comment by James Nunez (Inactive) [ 15/Nov/16 ]

Bob - Do you have a patch for this or should I create one?

Comment by Bob Glossman (Inactive) [ 15/Nov/16 ]

James, I have no patch. The simplest patch would be to just change echo ${virt,,} to echo $virt.

Comment by Jinshan Xiong (Inactive) [ 15/Nov/16 ]

I would propose 'echo $virt | tr '[A-Z]' '[a-z]'' to avoid puzzles like 'VMWare', 'VMware', 'KVM', 'kvm'

Comment by Bob Glossman (Inactive) [ 15/Nov/16 ]

fine, I won't argue. if the favored solution is to continue to translate to all lower case I'm ok with that. It just seems unnecessary.

Comment by Andreas Dilger [ 15/Nov/16 ]

I was going to suggest the same thing as Jinshan, to keep the output constant. Even if we don't need to know the VM details today, it may help in the future.

Comment by Jinshan Xiong (Inactive) [ 15/Nov/16 ]

Sorry if this would introduce extra work on your side. I proposed that way because dmidecode and virt-what can produce different results.

[root@centos7 tests]# dmidecode -s system-product-name |awk '{print $1}'
VMware
[root@centos7 tests]# virt-what
vmware
Comment by Gerrit Updater [ 15/Nov/16 ]

James Nunez (james.a.nunez@intel.com) uploaded a new patch: http://review.whamcloud.com/23774
Subject: LU-8832 tests: Generalize check of virtual machine
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 8ef7cc5073ba246b0700bdf9ce5c108ae104a12a

Comment by Gerrit Updater [ 17/Dec/16 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch https://review.whamcloud.com/23774/
Subject: LU-8832 tests: Generalize check of virtual machine
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: fb4e9d58e387af627e3599ddaa2ae553d078b6e1

Comment by Peter Jones [ 17/Dec/16 ]

Landed for 2.10

Comment by Gerrit Updater [ 28/Feb/17 ]

Andreas Dilger (andreas.dilger@intel.com) uploaded a new patch: https://review.whamcloud.com/25660
Subject: LU-8832 tests: fix module loading for Parallels
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: fb06483bf3a6dbeabd569997704723010104073a

Comment by Gerrit Updater [ 23/Apr/17 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch https://review.whamcloud.com/25660/
Subject: LU-8832 tests: fix module loading for Parallels
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: c49c8b146fdb45ef621fbba288758611c6d35cf3

Generated at Sat Feb 10 02:20:55 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.