From patchwork Thu Sep 12 11:17:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 274517 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0FEF02C0396 for ; Thu, 12 Sep 2013 21:20:46 +1000 (EST) Received: from localhost ([::1]:41084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK4x2-00043x-1u for incoming@patchwork.ozlabs.org; Thu, 12 Sep 2013 07:20:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK4u0-0007j4-9r for qemu-devel@nongnu.org; Thu, 12 Sep 2013 07:17:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK4tt-0004xN-8N for qemu-devel@nongnu.org; Thu, 12 Sep 2013 07:17:36 -0400 Received: from mail-ee0-x230.google.com ([2a00:1450:4013:c00::230]:35058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK4tt-0004vN-10; Thu, 12 Sep 2013 07:17:29 -0400 Received: by mail-ee0-f48.google.com with SMTP id l10so5224399eei.21 for ; Thu, 12 Sep 2013 04:17:28 -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:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=8Wlo28twtfY8uMs8eMEJOc2zwdPoVDcHoBZ8nlkFy4o=; b=TpaPVrnHWnNz/Cub0veMffKxJTiCBuA6WSbFzI3Gdka1kkkcnmwI//foaqRJdups4t TY9dAzgSgerrJyPE1wF7YOcuJjZNef8K37K+Eil5UJAVfC0lvloqTFWLsXkxXwUkN6Gj FAGZAqH6BbplNH5DNYOn3AgJhaMmg2LIcF0oigoy/oVWAhlB+Zy/ieN2hc3VTUnmkOYQ +rQAPfkHuH/D8em8rrnOoLy26BlJJb3sg3eV3/e3Czp4PPkcPECb04LkV4JiClLLDspR 9/XXZFMu7Tb4OS8rEud7UxP14lDziRo0PXhCvFHsgwG5oOqD1Ez+n57A1i3VNlfLkp2j pLMg== X-Received: by 10.15.43.206 with SMTP id x54mr1760812eev.79.1378984647943; Thu, 12 Sep 2013 04:17:27 -0700 (PDT) Received: from playground.lan (net-37-117-144-28.cust.dsl.vodafone.it. [37.117.144.28]) by mx.google.com with ESMTPSA id f49sm4970629eec.7.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 12 Sep 2013 04:17:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 12 Sep 2013 13:17:07 +0200 Message-Id: <1378984634-765-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1378984634-765-1-git-send-email-pbonzini@redhat.com> References: <1378984634-765-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::230 Cc: Markus Armbruster , qemu-stable@nongnu.org Subject: [Qemu-devel] [PULL 04/11] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster scsi_bus_legacy_add_drive() creates either a scsi-disk or a scsi-generic device. It sets property "serial" to argument serial unless null. Crashes with scsi-generic, because it doesn't have such the property. Only usb_msd_initfn_storage() passes non-null serial. Reproducer: $ qemu-system-x86_64 -nodefaults -display none -S -usb \ -drive if=none,file=/dev/sg1,id=usb-drv0 \ -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123 qemu-system-x86_64: -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123: Property '.serial' not found Aborted (core dumped) Fix by handling exactly like "removable": set the property only when it exists. Cc: qemu-stable@nongnu.org Reviewed-by: Andreas Färber Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 5cd6137..4d36841 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -224,7 +224,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv, if (object_property_find(OBJECT(dev), "removable", NULL)) { qdev_prop_set_bit(dev, "removable", removable); } - if (serial) { + if (serial && object_property_find(OBJECT(dev), "serial", NULL)) { qdev_prop_set_string(dev, "serial", serial); } if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {