From patchwork Mon Jul 16 14:25:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1201031 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 51C283FC33 for ; Mon, 16 Jul 2012 14:26:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753283Ab2GPO0Y (ORCPT ); Mon, 16 Jul 2012 10:26:24 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:48889 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753487Ab2GPO0X (ORCPT ); Mon, 16 Jul 2012 10:26:23 -0400 Received: by ghrr11 with SMTP id r11so5027484ghr.19 for ; Mon, 16 Jul 2012 07:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=2aYADnob6a5h5nojjY63GoOpy/aYXfyojt0UKKQ/u+I=; b=BQGg9yUuwcD2zPXdzc9bf7LPsnf+zG7LtRkkGQM+hYTEdTpLmdJJjgYhfGI2D/nA7u 4+ykzIPsBCvXID8SJ+wkld8kuL+D2dUXVCYzPutCGiVySI25IcaseV36Q7WWQEdoLKqi acWzxwP0bc12tXdKzgT93bRlU4mgM2ZcnnjKdqkIqCSWphxv7h7kS9v7L70YtNUg38Px nlRtn8A+rRde6E3Srt1bMieNm/b0kbN/seicCAlIL15zpvmLf+B0g5w4fWmdKlHDEbSp QWZAafKPhxqWfn/LjnafSCFmgbRd2hROxfPfalE80fLP1pQWbT3Y+2vI8VQYfsWhRqns /b6g== Received: by 10.66.85.231 with SMTP id k7mr22929697paz.76.1342448781955; Mon, 16 Jul 2012 07:26:21 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-189-113.ip51.fastwebnet.it. [93.34.189.113]) by mx.google.com with ESMTPS id qa5sm11997476pbb.19.2012.07.16.07.26.19 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jul 2012 07:26:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org Subject: [PATCH 5/5] virtio-scsi: report parameter change events Date: Mon, 16 Jul 2012 16:25:56 +0200 Message-Id: <1342448756-7582-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1342448756-7582-1-git-send-email-pbonzini@redhat.com> References: <1342448756-7582-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Paolo Bonzini --- hw/virtio-scsi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 83dbabd..80a47d7 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -27,6 +27,7 @@ /* Feature Bits */ #define VIRTIO_SCSI_F_INOUT 0 #define VIRTIO_SCSI_F_HOTPLUG 1 +#define VIRTIO_SCSI_F_CHANGE 2 /* Response codes */ #define VIRTIO_SCSI_S_OK 0 @@ -63,6 +64,7 @@ #define VIRTIO_SCSI_T_NO_EVENT 0 #define VIRTIO_SCSI_T_TRANSPORT_RESET 1 #define VIRTIO_SCSI_T_ASYNC_NOTIFY 2 +#define VIRTIO_SCSI_T_PARAM_CHANGE 3 /* Reasons for transport reset event */ #define VIRTIO_SCSI_EVT_RESET_HARD 0 @@ -554,6 +556,7 @@ static uint32_t virtio_scsi_get_features(VirtIODevice *vdev, uint32_t requested_features) { requested_features |= (1UL << VIRTIO_SCSI_F_HOTPLUG); + requested_features |= (1UL << VIRTIO_SCSI_F_CHANGE); return requested_features; } @@ -637,6 +640,18 @@ static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq) } } +static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense) +{ + VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus); + + if (((s->vdev.guest_features >> VIRTIO_SCSI_F_CHANGE) & 1) && + (s->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK) && + dev->type != TYPE_ROM) { + virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_PARAM_CHANGE, + sense.asc | (sense.ascq << 8)); + } +} + static void virtio_scsi_hotplug(SCSIBus *bus, SCSIDevice *dev) { VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus); @@ -666,6 +681,7 @@ static struct SCSIBusInfo virtio_scsi_scsi_info = { .complete = virtio_scsi_command_complete, .cancel = virtio_scsi_request_cancelled, + .change = virtio_scsi_change, .hotplug = virtio_scsi_hotplug, .hot_unplug = virtio_scsi_hot_unplug, .get_sg_list = virtio_scsi_get_sg_list,