[meta-arm] arm-autonomy/xenguest-init: fix guest shutdown issues after host reboot

Submitted by Kamil Dziezyk on Nov. 13, 2020, 10:19 a.m. | Patch ID: 178102

Details

Message ID 20201113101931.6372-1-kamil.dziezyk@arm.com
State New
Headers show

Commit Message

Kamil Dziezyk Nov. 13, 2020, 10:19 a.m.
This patch contain following changes:
 * xenguest-init stop action uses now blocking call,
   and additional 'xl destroy guest' call if normal shutdown has failed.
 * xenguest-init stop action stops only running guest.
 * xenguest-init script is now caled before xen-tools scripts
   on host shutdown or reboot.
 * xenguest-network-bridge script is now called before ifupdown script
   on host shutdown or reboot.

Change-Id: I46e307fd0ad36b2e35559b4e8a071be9bbc50e34
Issue-Id: SCM-1632
Signed-off-by: Kamil Dziezyk <kamil.dziezyk@arm.com>

---
 .../recipes-extended/xenguest/files/xenguest-init             | 4 +++-
 .../recipes-extended/xenguest/xenguest-manager.bb             | 3 ++-
 .../recipes-extended/xenguest/xenguest-network.bb             | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)

-- 
2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#1364): https://lists.yoctoproject.org/g/meta-arm/message/1364
Mute This Topic: https://lists.yoctoproject.org/mt/78226730/1003190
Group Owner: meta-arm+owner@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-

Patch hide | download patch | download mbox

diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
index cd249cf..d580908 100755
--- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
+++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init
@@ -65,8 +65,10 @@  case "$1" in
         ;;
   stop)
         echo "Stopping xenguest"
+        # update guest list
+        guestlist=$(xenguest-manager status | grep Running | cut -d ":" -f1)
         for f in ${guestlist}; do
-            /usr/bin/xenguest-manager stop ${f}
+            xl shutdown -w ${f} || xl destroy ${f}
         done
         ;;
   reload)
diff --git a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb
index bd7963f..9c29bde 100644
--- a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb
+++ b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb
@@ -21,8 +21,9 @@  XENGUEST_MANAGER_VOLUME_NAME ?= "vg-xen"
 XENGUEST_MANAGER_GUEST_DIR ?= "${datadir}/guests/"
 
 # We add an init script to create and start guests automatically
+# run start script after xen-tools and run stop script before xen-tools
 INITSCRIPT_NAME = "xenguest"
-INITSCRIPT_PARAMS = "defaults 90"
+INITSCRIPT_PARAMS = "start 90 2 3 4 5 . stop 79 0 1 6 ."
 
 inherit update-rc.d
 
diff --git a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb
index d0517b6..9464d43 100644
--- a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb
+++ b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb
@@ -29,9 +29,10 @@  PACKAGES =+ "${PN}-kea-dhcp4"
 
 # Bridge configurator needs to run before S01networking init script
 # Prefix with a_ to make sure it is executed in runlevel 01 before others
+# run start script before ifupdown and run stop script after ifupdown
 INITSCRIPT_PACKAGES = "${PN} ${PN}-kea-dhcp4"
 INITSCRIPT_NAME_${PN} = "a_xenguest-network-bridge"
-INITSCRIPT_PARAMS_${PN} = "defaults 01"
+INITSCRIPT_PARAMS_${PN} = "start 01 2 3 4 5 . stop 81 0 1 6 ."
 
 # Kea configuration needs to be restored before kea init scripts:
 # Kea dhcp4 server is 30, so lets use 20, to have higher priority

Comments

Jon Mason Nov. 16, 2020, 2:26 p.m.
On Fri, Nov 13, 2020 at 11:19:31AM +0100, Kamil Dziezyk wrote:
> This patch contain following changes:

>  * xenguest-init stop action uses now blocking call,

>    and additional 'xl destroy guest' call if normal shutdown has failed.

>  * xenguest-init stop action stops only running guest.

>  * xenguest-init script is now caled before xen-tools scripts

>    on host shutdown or reboot.

>  * xenguest-network-bridge script is now called before ifupdown script

>    on host shutdown or reboot.

> 

> Change-Id: I46e307fd0ad36b2e35559b4e8a071be9bbc50e34

> Issue-Id: SCM-1632

> Signed-off-by: Kamil Dziezyk <kamil.dziezyk@arm.com>


Applied to master.

Thanks,
Jon

> ---

>  .../recipes-extended/xenguest/files/xenguest-init             | 4 +++-

>  .../recipes-extended/xenguest/xenguest-manager.bb             | 3 ++-

>  .../recipes-extended/xenguest/xenguest-network.bb             | 3 ++-

>  3 files changed, 7 insertions(+), 3 deletions(-)

> 

> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init

> index cd249cf..d580908 100755

> --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init

> +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init

> @@ -65,8 +65,10 @@ case "$1" in

>          ;;

>    stop)

>          echo "Stopping xenguest"

> +        # update guest list

> +        guestlist=$(xenguest-manager status | grep Running | cut -d ":" -f1)

>          for f in ${guestlist}; do

> -            /usr/bin/xenguest-manager stop ${f}

> +            xl shutdown -w ${f} || xl destroy ${f}

>          done

>          ;;

>    reload)

> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb

> index bd7963f..9c29bde 100644

> --- a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb

> +++ b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb

> @@ -21,8 +21,9 @@ XENGUEST_MANAGER_VOLUME_NAME ?= "vg-xen"

>  XENGUEST_MANAGER_GUEST_DIR ?= "${datadir}/guests/"

>  

>  # We add an init script to create and start guests automatically

> +# run start script after xen-tools and run stop script before xen-tools

>  INITSCRIPT_NAME = "xenguest"

> -INITSCRIPT_PARAMS = "defaults 90"

> +INITSCRIPT_PARAMS = "start 90 2 3 4 5 . stop 79 0 1 6 ."

>  

>  inherit update-rc.d

>  

> diff --git a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb

> index d0517b6..9464d43 100644

> --- a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb

> +++ b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb

> @@ -29,9 +29,10 @@ PACKAGES =+ "${PN}-kea-dhcp4"

>  

>  # Bridge configurator needs to run before S01networking init script

>  # Prefix with a_ to make sure it is executed in runlevel 01 before others

> +# run start script before ifupdown and run stop script after ifupdown

>  INITSCRIPT_PACKAGES = "${PN} ${PN}-kea-dhcp4"

>  INITSCRIPT_NAME_${PN} = "a_xenguest-network-bridge"

> -INITSCRIPT_PARAMS_${PN} = "defaults 01"

> +INITSCRIPT_PARAMS_${PN} = "start 01 2 3 4 5 . stop 81 0 1 6 ."

>  

>  # Kea configuration needs to be restored before kea init scripts:

>  # Kea dhcp4 server is 30, so lets use 20, to have higher priority

> -- 

> 2.17.1

> 


> 

> 

>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#1372): https://lists.yoctoproject.org/g/meta-arm/message/1372
Mute This Topic: https://lists.yoctoproject.org/mt/78226730/1003190
Group Owner: meta-arm+owner@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-
Jon Mason Nov. 19, 2020, 2:59 p.m.
On Tue, Nov 17, 2020 at 07:12:19AM -0800, Kamil Dziezyk wrote:
> Can you backport this change to gatesgarth?


Done


> 

> 

>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#1398): https://lists.yoctoproject.org/g/meta-arm/message/1398
Mute This Topic: https://lists.yoctoproject.org/mt/78226730/1003190
Group Owner: meta-arm+owner@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-