From patchwork Mon Jan 30 14:41:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9545551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B2D2460417 for ; Mon, 30 Jan 2017 14:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A82C61FF1D for ; Mon, 30 Jan 2017 14:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CD022811D; Mon, 30 Jan 2017 14:57:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 476351FF1D for ; Mon, 30 Jan 2017 14:57:17 +0000 (UTC) Received: from localhost ([::1]:33086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYDOO-0005Z3-BS for patchwork-qemu-devel@patchwork.kernel.org; Mon, 30 Jan 2017 09:57:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYD9H-00018X-6M for qemu-devel@nongnu.org; Mon, 30 Jan 2017 09:41:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYD9C-0000tX-Bi for qemu-devel@nongnu.org; Mon, 30 Jan 2017 09:41:39 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:33273) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYD9C-0000sO-6m for qemu-devel@nongnu.org; Mon, 30 Jan 2017 09:41:34 -0500 Received: by mail-pf0-x242.google.com with SMTP id e4so23365482pfg.0 for ; Mon, 30 Jan 2017 06:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wbWfkPYpkZxCVuTUE5BK610mFkxAxe0rokbn6QRZxbA=; b=BgbbXMM9HmyBkVV0NwvTb4hmVjVE6ILCu9969QqryyXEUFk55YxTJBiPYBgLfwn1Du +SYPx5sKhagtoGJfZ5PrvMJ1IOmktoYOhzoRAYWNuqygIdDm9HHdMkSr+1xmaYxjRMzP GGfDncf+jtvFqA+PsfDs7iEy0G+eiH/QvMJuu7g9DCVcTz5cJuzifJS4w1Rd+otm0tFi QXakJxt6YLLSMCUwh3HgXJrYpVmo8zRKZWnEzHghjJWRkk1zfnrYnS/M1maPBaMQsXur dHswea4v8ipbJpymDD3rAiMGacnyAmV7/bNqEjG3Shq4/fmmz7seoQEC1tcmGg7UKoHc 8F2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wbWfkPYpkZxCVuTUE5BK610mFkxAxe0rokbn6QRZxbA=; b=dqiqGI1xTTX9Ehdfz4S961plba5g0gnmzGn52n3TwmS3LIeeJxMOaAg5GG0I10OSCw ECnI0OAk83iZLhNiWV7C3H5HsWEYQyQUg9rV78+7BIaTt4MO0YEjY4f46p2vtU3A100q uvoxVvtub7WaTdYzngza3QvsFb0H8K8rYZ9YUY4A+Dp2cpPfmOZfXfw/kO0Gjbin+bPS YWjuYc4tSdXQnQ/a3E/W7pZwkkP1beTshI0NViinZRlHa5HtvOZZMJOvTolxn7uey0F6 77kt14a188LVpSNDC+v2jnO4lX/HoUuW+Qp+LJk3G5YDmGZMQg3YF7SUq+go4xmYs/QL wjCw== X-Gm-Message-State: AIkVDXLFMECdaCHapTOBw79NSDr3GuilrDXZt6T5oEPL+m049YWajUEPctk9cAlMmM8Wxw== X-Received: by 10.99.222.17 with SMTP id f17mr24731191pgg.127.1485787291762; Mon, 30 Jan 2017 06:41:31 -0800 (PST) Received: from linux.local ([27.251.197.196]) by smtp.gmail.com with ESMTPSA id h17sm33294920pfh.62.2017.01.30.06.41.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Jan 2017 06:41:31 -0800 (PST) From: Ashijeet Acharya To: dgilbert@redhat.com Date: Mon, 30 Jan 2017 20:11:11 +0530 Message-Id: <1485787271-8754-1-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH] migrate: Introduce a 'dc->vmsd' check to avoid segfault for --only-migratable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amit.shah@redhat.com, qemu-devel@nongnu.org, Ashijeet Acharya , quintela@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit a3a3d8c7 introduced a segfault bug while checking for 'dc->vmsd->unmigratable' which caused QEMU to crash when trying to add devices which do no set their 'dc->vmsd' yet while initialization. Place a 'dc->vmsd' check prior to it so that we do not segfault for such devices. NOTE: This doesn't compromise the functioning of --only-migratable option as all the unmigratable devices do set their 'dc->vmsd'. Signed-off-by: Ashijeet Acharya Reviewed-by: Juan Quintela --- qdev-monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index 81d01df..a1106fd 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -578,7 +578,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp) return NULL; } - if (only_migratable) { + if (only_migratable && dc->vmsd) { if (dc->vmsd->unmigratable) { error_setg(errp, "Device %s is not migratable, but " "--only-migratable was specified", driver);