From patchwork Wed Mar 20 05:56:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 229253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 36E512C00A5 for ; Wed, 20 Mar 2013 16:56:58 +1100 (EST) Received: from localhost ([::1]:35567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIC1A-0003Yr-9E for incoming@patchwork.ozlabs.org; Wed, 20 Mar 2013 01:56:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIC0s-0003Ye-S9 for qemu-devel@nongnu.org; Wed, 20 Mar 2013 01:56:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIC0p-00036a-GH for qemu-devel@nongnu.org; Wed, 20 Mar 2013 01:56:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIC0p-00036I-8W for qemu-devel@nongnu.org; Wed, 20 Mar 2013 01:56:35 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2K5uXH5019081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 20 Mar 2013 01:56:33 -0400 Received: from hj.localdomain.com ([10.66.4.126]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2K5uUD1006051; Wed, 20 Mar 2013 01:56:31 -0400 From: Asias He To: qemu-devel@nongnu.org Date: Wed, 20 Mar 2013 13:56:08 +0800 Message-Id: <1363758968-28549-1-git-send-email-asias@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Asias He , kvm@vger.kernel.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH] virtio-blk: Set default serial id 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 If user does not specify a serial id, e.g. -device virtio-blk-pci,serial="serial_id" or -drive serial="serial_id" no serial id will be assigned. Add a default serial id in this case to help identifying the disk in guest. Signed-off-by: Asias He --- hw/virtio-blk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index f2143fd..c016817 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -642,6 +642,13 @@ static int virtio_blk_device_init(VirtIODevice *vdev) } blkconf_serial(&blk->conf, &blk->serial); + + if (!blk->serial) { + char serial[VIRTIO_BLK_ID_BYTES]; + snprintf(serial, VIRTIO_BLK_ID_BYTES, "ID%05d", virtio_blk_id); + blk->serial = g_strdup(serial); + } + if (blkconf_geometry(&blk->conf, NULL, 65535, 255, 255) < 0) { return -1; }