From nobody Mon May 6 22:51:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576223296; cv=none; d=zohomail.com; s=zohoarc; b=BQGpKPZvi+MTRvqZvxFUHVmbUD7Zx+c/k6xpc+v7KU79XKiMjC2ny6lfUcUBnMZ0HQkC8ihc7RRJSmO1jeJ46jkTi14teNv8LO7aAwZYpcNoyQin9TtoHrn7iskndw7/Pn7qTKlSDxtDgvF0bqW1sPPM8oNNDhb3mQ3rin1ZANg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576223296; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=/yZBKLxK/iDoDILJNU4Y0W46bwQ5ungCpYzy1+ONSgQ=; b=iuHqg3opBR+OPF3eR94vSKuD//dggGjKHWV8a6U82c2+rTbcsEy2csEsseCnG4a1H+5HRrefgtwnnuuVaO7Q/0l8W6witT0yPkC5BZMa+F4HySFYcuA0aV8/MDJjTZDCJZ0uBv9G4ofBm5vNYZ3lObURcviTWWL1f3fGL54Jcws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1576223296641510.88856344246585; Thu, 12 Dec 2019 23:48:16 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-v7oRYk8APDWFmo0knnMYMg-1; Fri, 13 Dec 2019 02:48:12 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20C5C1856A61; Fri, 13 Dec 2019 07:48:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 21C9046E77; Fri, 13 Dec 2019 07:48:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 654AF65D21; Fri, 13 Dec 2019 07:48:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBD7m2SN011050 for ; Fri, 13 Dec 2019 02:48:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id A7916165420; Fri, 13 Dec 2019 07:48:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A246D165429 for ; Fri, 13 Dec 2019 07:48:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75479185B0BA for ; Fri, 13 Dec 2019 07:48:00 +0000 (UTC) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-88--SCBWLQCNwC2vxTuoscpnQ-1; Fri, 13 Dec 2019 02:47:59 -0500 Received: by mail-pf1-f172.google.com with SMTP id 2so1025534pfx.6; Thu, 12 Dec 2019 23:47:57 -0800 (PST) Received: from t440p.suse.asia ([45.122.156.254]) by smtp.gmail.com with ESMTPSA id p5sm9676542pgj.63.2019.12.12.23.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2019 23:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576223295; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/yZBKLxK/iDoDILJNU4Y0W46bwQ5ungCpYzy1+ONSgQ=; b=NpTiUDXqvihyU+CreqHWIxOTGdVgG+vqD71MKPeVGUa21Ir6v7b/g8sjk/vDK/JrQDSaNR 40lU1SxTvsWHonrEIjUNpHa/9SJmBqlceGgtF2xGiXyUbU4J72+0wJRn3/dbHUmPBzI9o2 Li+ga0WGDPei9SiPmo2fYJb188ZXw1U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=eDsFJbi4f6nPoKEDKBqN+mmzglr+eQfP7Mb2xU6jhDs=; b=m53tsj1/BOIHGpKbx2PnEX+SkP0sqS0V11VTYbjWer6KZ1uKWd1HtDSea4AIp8sR3R jZN2Wqs+qfvWNwkNTrK7uwdP7bsNOXEBJp8gIfCu1l74jDiVjgqG6F8FXr9pP2f9FJ+I uY2nPjqM96gRfItP81UCj6OhJls6Z194O165uwgK/dQqRTcyY9MjlQ+sn4NW54vOU0LY grJULuROe0jD9vER9FmLj5p0uRi/sAqjEktcrg/WcY2LMh7Ww2wYqKToSJe6IDQlBs+b IvB2sZNCFABA0ACJWfcEshDGGcAQMAvSBCrOvUiA3oD1/0tSIT2ZXUiGBqpKiFszuPl6 RgvQ== X-Gm-Message-State: APjAAAUiza90IU4jzdScnVg261/rADdk2tEmdVs+POiBZGqJ6T6Q04i8 ryFkA4wG5rNcvE2o+dWXQ9v6rrqTiXY= X-Google-Smtp-Source: APXvYqzexbnfwfjQ6unaXgkkx0MOMs4RrKOT4Jr/nFMeHzoQ3pCnVekniqSW1xrfl07S3DC04slCSw== X-Received: by 2002:aa7:954d:: with SMTP id w13mr258965pfq.176.1576223276700; Thu, 12 Dec 2019 23:47:56 -0800 (PST) From: Lin Ma To: libvir-list@redhat.com Date: Fri, 13 Dec 2019 15:47:36 +0800 Message-Id: <20191213074736.21641-1-lma@suse.com> MIME-Version: 1.0 X-MC-Unique: -SCBWLQCNwC2vxTuoscpnQ-1 X-MC-Unique: v7oRYk8APDWFmo0knnMYMg-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xBD7m2SN011050 X-loop: libvir-list@redhat.com Cc: pkrempa@redhat.com, Lin Ma Subject: [libvirt] [PATCH] qemu: snapshot: Fix libvirtd crash in snapshot-revert X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When reverting a running domain to a snapshot(active state), We need to use the FORCE flag for snapshot-revert if current domain configuration is different from the target domain configuration, and this will start a new qemu instance for the target domain. In this situation, if there is existing connection to the domain, say Spice or VNC through virt-manager, Then the libvirtd would crash during snapshot revert because: Both of snapshot revert worker and new worker job 'remoteDispatchDomainOpenGraphicsFd' are waiting for mon->msg->finished in qemuMonitorSend(), We know if IO process resulted in an error with a message, Libvirtd main thread calls qemuMonitorIO() to wakeup the waiter. Then mon->msg will be set to NULL in qemuMonitorSend() once the worker GraphicsFD is woken up, which causes snapshot revert worker dereferences this null pointer. Not sure whether this scenario makes sense, But at least the libvirtd should not crash, So fix it. Thread 6 "libvirtd" hit Breakpoint 1, qemuMonitorSend 987 if (mon->lastError.code !=3D VIR_ERR_OK) { (gdb) bt #0 in qemuMonitorSend #1 in qemuMonitorJSONCommandWithFd #2 in qemuMonitorJSONSendFileHandle #3 in qemuMonitorSendFileHandle #4 in qemuMonitorOpenGraphics #5 in qemuDomainOpenGraphicsFD #6 in virDomainOpenGraphicsFD #7 in remoteDispatchDomainOpenGraphicsFd #8 in remoteDispatchDomainOpenGraphicsFdHelper #9 in virNetServerProgramDispatchCall #10 in virNetServerProgramDispatch #11 in virNetServerProcessMsg #12 in virNetServerHandleJob #13 in virThreadPoolWorker #14 in virThreadHelper #15 in start_thread #16 in clone (gdb) c Continuing. Thread 2 "libvirtd" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fbd20fe2700 (LWP 19014)] 0x00007fbd1c3be838 in qemuMonitorSend (mon=3Dmon@entry=3D0x7fbd1804a940, msg=3Dmsg@entry=3D0x7fbd20fe15b0) at ../../src/qemu/qemu_monitor.c:1001 1001 while (!mon->msg->finished) { (gdb) bt #0 in qemuMonitorSend #1 in qemuMonitorJSONCommandWithFd #2 in qemuMonitorJSONCommand #3 in qemuMonitorJSONGetChardevInfo #4 in qemuMonitorGetChardevInfo #5 in qemuProcessWaitForMonitor #6 in qemuProcessLaunch #7 in qemuProcessStart #8 in qemuDomainRevertToSnapshot #9 in virDomainRevertToSnapshot #10 in remoteDispatchDomainRevertToSnapshot #11 in remoteDispatchDomainRevertToSnapshotHelper #12 in virNetServerProgramDispatchCall #13 in virNetServerProgramDispatch #14 in virNetServerProcessMsg #15 in virNetServerHandleJob #16 in virThreadPoolWorker #17 in virThreadHelper #18 in start_thread #19 in clone Signed-off-by: Lin Ma --- src/qemu/qemu_monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index ea3e62dc8e..a8344e698b 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -994,7 +994,7 @@ qemuMonitorSend(qemuMonitorPtr mon, "mon=3D%p msg=3D%s fd=3D%d", mon, mon->msg->txBuffer, mon->msg->txFD); =20 - while (!mon->msg->finished) { + while (mon->msg && !mon->msg->finished) { if (virCondWait(&mon->notify, &mon->parent.lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to wait on monitor condition")); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list