agent: fix wrong regular exp to fetch guest-cid

Fix the incorrect regular expression to fetch the guest context ID.
In " [^,][^,]* ", [^,]* will match to the next ",",
which is after "socket",  so finally got incorrect result.
Use egrep -o "guest-cid=[0-9]*" instead.

Fixes: #2124

Signed-off-by: Liang Zhou <zhoul110@chinatelecom.cn>
This commit is contained in:
Liang Zhou 2021-06-28 15:54:52 +08:00
parent 015b3baf06
commit 2c9430123e

View File

@ -80,7 +80,7 @@ $ sudo docker export $(sudo docker create "$image") | tar -C "$rootfs_dir" -xvf
value: value:
```sh ```sh
$ guest_cid=$(ps -ef | grep qemu-system-x86_64 | egrep -o "guest-cid=[^,][^,]*" | cut -d= -f2) $ guest_cid=$(ps -ef | grep qemu-system-x86_64 | egrep -o "guest-cid=[0-9]*" | cut -d= -f2)
``` ```
1. Run the tool to connect to the agent: 1. Run the tool to connect to the agent: