[PATCH] Check for Alibaba Cloud X-Dragon Architecture

Richard W.M. Jones rjones at redhat.com
Tue Jun 1 15:54:31 UTC 2021


On Tue, Jun 01, 2021 at 08:49:17PM +0800, Weisson wrote:
> Thanks to Richard W.M. Jones' Super Powerful Bash Script
> ---
>  virt-what.in | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/virt-what.in b/virt-what.in
> index 3dac91a..f5a4f23 100644
> --- a/virt-what.in
> +++ b/virt-what.in
> @@ -114,10 +114,16 @@ dmi=$(LANG=C dmidecode 2>&1)
>  arch=$(uname -m | sed -e 's/i.86/i386/' | sed -e 's/arm.*/arm/')
>  
>  # Check for Alibaba Cloud
> -if echo "$dmi" | grep -q 'Manufacturer: Alibaba Cloud'; then
> -    echo "alibaba_cloud"
> +if echo "$dmi" | grep -q 'Manufacturer: Alibaba'; then
> +    # Check for Alibaba Cloud X-Dragon Architecture
> +    if { echo -e "GET /latest/meta-datainstance/instance-type HTTP/1.0\r\nHost: 100.100.100.200\r\n\r" >&3; grep -sq 'ebm' <&3 ; } 3<> /dev/tcp/100.100.100.200/80 ; then
> +        echo "alibaba_cloud-x_dragon"
> +    else
> +        echo "alibaba_cloud"
> +    fi
>  fi
>  
> +
>  # Check for VMware.
>  # cpuid check added by Chetan Loke.

Thanks - I pushed this which is very slightly different but should
still work:

http://git.annexia.org/?p=virt-what.git;a=commitdiff;h=b7cc3d93a613ef6d0ac5ccd6e32cc3d66e057243

The differences are:

* Added ( .. ) 2>/dev/null around the HTTP request, so that if it
  fails then the output of virt-what does not contain an error
  message.  This also fixes the test.

* Removed extra whitespace.

* Added documentation.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the virt-tools-list mailing list