From patchwork Mon Jul 23 20:17:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10541139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6401991E for ; Mon, 23 Jul 2018 21:44:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51D9B285BE for ; Mon, 23 Jul 2018 21:44:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4412B285CB; Mon, 23 Jul 2018 21:44:19 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,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 E168D285BE for ; Mon, 23 Jul 2018 21:44:18 +0000 (UTC) Received: from localhost ([::1]:36906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhics-0005E4-6c for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Jul 2018 17:44:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLN-0004Xm-7v for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLM-0005jl-9i for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:09 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:40418) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLM-0005jb-4U; Mon, 23 Jul 2018 16:22:08 -0400 Received: by mail-oi0-x243.google.com with SMTP id w126-v6so3485918oie.7; Mon, 23 Jul 2018 13:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=XRI5SBS5RpBzOViBiFp15yPGNFkoOKkwfNAtq1Rxf+0=; b=O8QQSx629XztAQrLB+Hkq7PRkiJHSMjfsL7HGR4abX4mGNQ5RlWz93RgYuRG1Z67Yo tlPM8qLF9xA56s8+RKZ4pZ4+56GrO7lq0Ek7Yg8m1cOiNjIbJ+qTOeILvLCg5nxMAG3Z +OzcCLkV8r6CZegRIGuS8cewxc50vyzKzdY9GBmNOQPYO2AE5BVq7l25Uycj9a/uGqLe AOM5PpQoVxNf/NW8aNc8gzlxTVj4fglOuW+TosnMRDyFn48qnB5q+NhTPAGv5RgJWrQs eVO52mGoEtDuercvLGJF0xUN9FrMBmsJMG+Wdjln2Z1ScmHaX14rkaqRLZCh41nZI7YU DPSA== 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 :in-reply-to:references; bh=XRI5SBS5RpBzOViBiFp15yPGNFkoOKkwfNAtq1Rxf+0=; b=dqEjp3g1pbCXi8+ttUsiyrlnk+i9F+8YLWSLCTrnAga+5HD7r75tr9LFQYFS7gIC0X eqUo9hWVqHP/ypR57buYksgY/gOwQn4FfXnY17LJv8zBn5Cau87WU2ry73XXCJdD8Xs6 4Wu2VxYhVs3HOOJY+PSi6Nyqfd3OlVtXDwOyFK4hhOQ3fELGdPpH0xMcBdg6bAd9ChIH pxAu4UTzUkGmoEXKzF4U+yKgiRRnMkL3mtfUZAEziXDDVRinxbDEmy5cBdExIhdPahMo TXXuXT2m5V2/IEdHNOo3ZTfrFxgaMPtjjDJp/bthgxEL4m6auzrIgXVceH6TapQpmsre 8KiQ== X-Gm-Message-State: AOUpUlEAntwAMyazYXk0odAJ6yk2HWnkxWFNBsTB7Srv+Z4VOgJgFc1N ipsfKfRV5tx7hZoXu18hFaR1cqfmSJrvhQ== X-Google-Smtp-Source: AAOMgpfyDcHXOXdcgxph2idukc0UUZ1KSlUfKNJ4QV5YcgTfmyH2eYR1uspZ0HZEuqw5e3mOwUwgPw== X-Received: by 2002:aca:6cc6:: with SMTP id h189-v6mr344256oic.140.1532377326840; Mon, 23 Jul 2018 13:22:06 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id b3-v6sm6698475oiy.11.2018.07.23.13.22.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:05 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:44 -0500 Message-Id: <20180723201748.25573-96-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 95/99] virtio-rng: process pending requests on DRIVER_OK 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: Pankaj Gupta , qemu-stable@nongnu.org, Stefan Hajnoczi , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Pankaj Gupta virtio-rng device causes old guest kernels(2.6.32) to hang on latest qemu. The driver attempts to read from the virtio-rng device too early in it's initialization. Qemu detects guest is not ready and returns, resulting in hang. To fix handle pending requests when guest is running and driver status is set to 'VIRTIO_CONFIG_S_DRIVER_OK'. CC: qemu-stable@nongnu.org Reported-by: Sergio lopez Signed-off-by: Stefan Hajnoczi Signed-off-by: Pankaj Gupta Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 5d9c9ea22ab4f3b3ee497523e34b6f4d3281f62d) Signed-off-by: Michael Roth --- hw/virtio/virtio-rng.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 289bbcac03..855f1b41d1 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -156,6 +156,19 @@ static void check_rate_limit(void *opaque) vrng->activate_timer = true; } +static void virtio_rng_set_status(VirtIODevice *vdev, uint8_t status) +{ + VirtIORNG *vrng = VIRTIO_RNG(vdev); + + if (!vdev->vm_running) { + return; + } + vdev->status = status; + + /* Something changed, try to process buffers */ + virtio_rng_process(vrng); +} + static void virtio_rng_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -261,6 +274,7 @@ static void virtio_rng_class_init(ObjectClass *klass, void *data) vdc->realize = virtio_rng_device_realize; vdc->unrealize = virtio_rng_device_unrealize; vdc->get_features = get_features; + vdc->set_status = virtio_rng_set_status; } static const TypeInfo virtio_rng_info = {