From: shawn Subject: Re: [patch]Make xend to take care of dead qemu-dm process Date: Wed, 21 May 2008 15:34:46 +0800 Message-ID: <1211355286.2219.27.camel@redfuture-desktop.cn.oracle.com> References: <1211351585.2219.21.camel@redfuture-desktop.cn.oracle.com> <87C8BB1351E547kanno.masaki@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <87C8BB1351E547kanno.masaki@jp.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Masaki Kanno Cc: xen-devel List-Id: xen-devel@lists.xenproject.org Hi Kan=A3=AC Thanks for your comment. Correctted that,and some other mistakes. Please review this patch again. thanks xiaowei --- tools/python/xen/xend/server/SrvServer.py.org 2008-05-21 13:53:08.000000000 +0800 +++ tools/python/xen/xend/server/SrvServer.py 2008-05-21 15:28:09.000000000 +0800 @@ -44,6 +44,7 @@ import re import time import signal +import os from threading import Thread =20 from xen.web.httpserver import HttpServer, UnixHttpServer @@ -148,14 +149,26 @@ =20 # Reaching this point means we can auto start domains try: - xenddomain().autostart_domains() + dom =3D xenddomain() + dom.autostart_domains() except Exception, e: log.exception("Failed while autostarting domains") =20 # loop to keep main thread alive until it receives a SIGTERM self.running =3D True while self.running: - time.sleep(100000000) + # loop to destroy those hvm domain that whoes DM has dead unexpectedly. + for item in dom.domains.values(): + if item.info.is_hvm(): + device_model_pid =3D item.gatherDom(('image/device-model-pid', str)) + dm_stat_cmd =3D "ps -o stat --no-headers -p"+device_model_pid + dm_stat =3D os.popen(dm_stat_cmd).readline().rstrip() + if dm_stat =3D=3D 'Z': + log.warn("Devices Model for domain " + str(item.domid) + "was killed unexpectedly") + item.destroy() + else: + continue + time.sleep(30) =20 if self.reloadingConfig: log.info("Restarting all XML-RPC and Xen-API servers...") On Wed, 2008-05-21 at 16:21 +0900, Masaki Kanno wrote: > Hi Xiaowei, >=20 > Nonessential comment. >=20 > Your patch includes both tab-indent and space-indent. > Could you change tab-indent to space-indent? >=20 > Best regards, > Kan >=20 > Wed, 21 May 2008 14:33:05 +0800, shawn wrote: >=20 > >Hi all, > > > >There is a problem in Xen now,When fatal error happened on VM like > >qemu-dm process died, xend should take care of it. Don't leave it as > >defunct process (zombie process).=20 > >Because of mis-configuration or some other reason, qemu-dm process wou= ld > >die.=20 > > > >For now, xend haven't taken care of this dead process and it remains a= s > >defunct process, and xm list shows VM status assigned to the process a= s=20 > >vserv1134 5 6144 1 ------ 0.0=20 > > > >This patch fix xend as when fatal error happened (e.g. qemu-dm process > >was killed)=20 > >log error meesge then destroy that domain and clean up the process (n= o > >zombies) > > > >This is caused by the xend daemon, xend forks a process and run the > >qemu-dm program, when qemu-dm was killed directly ,xend doesn't have = a > >chance to call=20 > >the wait() function to collect this zombie child(qemu-dm is executed b= y > >a thread).For the xend doesn't have any idea of the qemu-dm child is > >alive or being killed.=20 > > > >For the above reason,added some code in xend to check those hvm DM > >status each 30 seconds.=20 > > > >Have made a patch based on the open source xen3.2.1 source code.=20 > > > >Please review this patch. > > > >Thanks. > >Xiaowei > > > >--- xen-3.2.1/tools/python/xen/xend/server/SrvServer.py.org 2008-05-21 > >13:53:08.000000000 +0800 > >+++ xen-3.2.1/tools/python/xen/xend/server/SrvServer.py 2008-05-21 > >13:58:56.000000000 +0800 > >@@ -44,6 +44,7 @@ > > import re > > import time > > import signal > >+import os > > from threading import Thread > >=20 > > from xen.web.httpserver import HttpServer, UnixHttpServer > >@@ -148,14 +149,28 @@ > >=20 > > # Reaching this point means we can auto start domains > > try: > >- xenddomain().autostart_domains() > >+ dom =3D xenddomain() > >+ dom.autostart_domains() > > except Exception, e: > > log.exception("Failed while autostarting domains") > >=20 > > # loop to keep main thread alive until it receives a > >SIGTERM > > self.running =3D True > > while self.running: > >- time.sleep(100000000) > >+ # loop to destroy those hvm domain that whoes DM has dead > >unexpectedly. > >+ for item in dom.domains.values(): > >+ if item.info.is_hvm(): > >+ device_model_pid =3D > >item.gatherDom(('image/device-model-pid', str)) > >+ dm_stat_cmd =3D "ps -o stat --no-headers -p"+ > device_model_pid > >+ dm_stat =3D os.popen(dm_stat_cmd).readline().rstrip() > >+ log.info("status of the command is:" + dm_stat + "end=20 > of output") > >+ if dm_stat =3D=3D 'Z': > >+ log.info("status of the command is:" + dm_stat +=20 > "end of > >output") > >+ log.warn("Devices Model for " + str(item) + "was=20 > killed > >unexpectedly") > >+ item.destroy() > >+ else: > >+ continue > >+ time.sleep(30) > > =20 > > if self.reloadingConfig: > > log.info("Restarting all XML-RPC and Xen-API > >servers...") > > > > > >_______________________________________________ > >Xen-devel mailing list > >Xen-devel@lists.xensource.com > >http://lists.xensource.com/xen-devel >=20 >=20 > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel