From patchwork Thu Jun 4 16:20:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 49537 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ED2C22154F for ; Thu, 4 Jun 2015 16:21:16 +0000 (UTC) Received: by wgme6 with SMTP id e6sf11349279wgm.3 for ; Thu, 04 Jun 2015 09:21:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=JfkPOFTy4Ax3XKHXaDY1bFCs52PhK5idFZazdRNoudw=; b=DtZM1oKFSI7UWZ39rInNU94tnvgi8vjPRH667eywCxmEc/VXnlAjLNMe3CZ7VzOupt JVbDXrxuxhyJ+ZFLZnB3f5vndC4uvp5u1c5m6s6EzjPb7jcViZdpH5Orr/nnEFSmkSpp oQhlPdJrwRYZIQ21Aw9L6ETvMRtvq5bRbeoWFAEBil+8nxmmj0jIbTFG3mDYqOsC1hM9 cERyiODALVI5GevgrvRqAnW1r/GpQA8hAIHvtIR0Sv5sNzzMmdaMj2cGVceBQkj0USfJ TGeTAHDtmmgQmjUgvxUnsbHPc6joX+PQnPvsqvEj3Z+Q8fRvEo2HGU8sHJrXfZcmYYQo 4tnw== X-Gm-Message-State: ALoCoQmKUBtCgTqGuJxfgBbQaTItfusPOOPdSn65YK/G5VehWK0zQbHYGbAUQ9oHA7Qj6IUOyHNb X-Received: by 10.194.236.230 with SMTP id ux6mr36213911wjc.5.1433434876288; Thu, 04 Jun 2015 09:21:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.100 with SMTP id z4ls199865laz.57.gmail; Thu, 04 Jun 2015 09:21:16 -0700 (PDT) X-Received: by 10.152.2.38 with SMTP id 6mr29890942lar.80.1433434876125; Thu, 04 Jun 2015 09:21:16 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id h3si2272741lag.12.2015.06.04.09.21.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jun 2015 09:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbcue7 with SMTP id ue7so30557326lbc.0 for ; Thu, 04 Jun 2015 09:21:16 -0700 (PDT) X-Received: by 10.112.204.6 with SMTP id ku6mr38448054lbc.73.1433434876018; Thu, 04 Jun 2015 09:21:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp729263lbb; Thu, 4 Jun 2015 09:21:14 -0700 (PDT) X-Received: by 10.70.134.198 with SMTP id pm6mr70994279pdb.17.1433434861641; Thu, 04 Jun 2015 09:21:01 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id nb8si6514583pdb.250.2015.06.04.09.20.59 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Jun 2015 09:21:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Z0Xsz-00050g-Rj; Thu, 04 Jun 2015 17:20:53 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Markus Armbruster , Kevin Wolf , qemu-block@nongnu.org, Christian Borntraeger , Cornelia Huck , Alexander Graf Subject: [PATCH 1/4] blockdev: Factor out create_implicit_virtio_device Date: Thu, 4 Jun 2015 17:20:50 +0100 Message-Id: <1433434853-19229-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1433434853-19229-1-git-send-email-peter.maydell@linaro.org> References: <1433434853-19229-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Factor out the code which creates the implicit virtio device for IF_VIRTIO drives, so we can call it from drive_check_orphaned(). Signed-off-by: Peter Maydell --- blockdev.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/blockdev.c b/blockdev.c index de94a8b..9cf6123 100644 --- a/blockdev.c +++ b/blockdev.c @@ -212,6 +212,27 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit) return NULL; } +/* Create the virtio device whose existence is implied by the + * creation of a block device with if=virtio. + */ +static void create_implicit_virtio_device(const char *driveid, + const char *devaddr) +{ + QemuOpts *devopts; + + devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, + &error_abort); + if (arch_type == QEMU_ARCH_S390X) { + qemu_opt_set(devopts, "driver", "virtio-blk-s390", &error_abort); + } else { + qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort); + } + qemu_opt_set(devopts, "drive", driveid, &error_abort); + if (devaddr) { + qemu_opt_set(devopts, "addr", devaddr, &error_abort); + } +} + bool drive_check_orphaned(void) { BlockBackend *blk; @@ -929,19 +950,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) } if (type == IF_VIRTIO) { - QemuOpts *devopts; - devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, - &error_abort); - if (arch_type == QEMU_ARCH_S390X) { - qemu_opt_set(devopts, "driver", "virtio-blk-s390", &error_abort); - } else { - qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort); - } - qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"), - &error_abort); - if (devaddr) { - qemu_opt_set(devopts, "addr", devaddr, &error_abort); - } + create_implicit_virtio_device(qdict_get_str(bs_opts, "id"), devaddr); } filename = qemu_opt_get(legacy_opts, "file");