From patchwork Tue Jun 9 17:48:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 49667 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C9DB1245D4 for ; Tue, 9 Jun 2015 17:54:34 +0000 (UTC) Received: by lbbti3 with SMTP id ti3sf6487580lbb.1 for ; Tue, 09 Jun 2015 10:54:33 -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=fTrQpXbUE2zJ94YoSpcsTOoi7JNn5AWotz49koyxMQh2ZWZVI/jaRFyr1kS8b0+Yk6 4K4NpetqnJe8hj096QCClgOJRsOQH1bTy1bgJU9bXU9rAi1SDYLRgQTrzrsMr7nLvmpR s21j+D99aE4rXKVyW16yLKEqqCtVOwXbzAmqacdrux4IXQLwGz/cLNnwh7H60DhnT0gq 1hSDEh2agxJE88sI3GFof72I5chCnOZQ4XiZU6x8lAvuAKgRJgpqry3hUG3sAe0BZAuU az1yOPaoZhSNcLzN0devLlQK9bR1u+s+KYD++C2Q+F38VBetkkSCkYJHdsBhfMPThzwR tD8g== X-Gm-Message-State: ALoCoQnwWAYChxg4mQAGl3ejnhpM6NdK6/xPfNn0OJeRvWnzdccpUiZFEmnSY4EHUuRKCRWehmvB X-Received: by 10.112.161.105 with SMTP id xr9mr22737404lbb.20.1433872473596; Tue, 09 Jun 2015 10:54:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.231 with SMTP id i7ls103900lae.85.gmail; Tue, 09 Jun 2015 10:54:33 -0700 (PDT) X-Received: by 10.112.143.165 with SMTP id sf5mr23763315lbb.44.1433872473452; Tue, 09 Jun 2015 10:54:33 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id y5si6336307lay.123.2015.06.09.10.54.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2015 10:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbcmx3 with SMTP id mx3so15076632lbc.1 for ; Tue, 09 Jun 2015 10:54:33 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr23748530lbc.19.1433872446435; Tue, 09 Jun 2015 10:54:06 -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 hn6csp2773740lbb; Tue, 9 Jun 2015 10:53:58 -0700 (PDT) X-Received: by 10.70.44.236 with SMTP id h12mr40585861pdm.152.1433872111892; Tue, 09 Jun 2015 10:48:31 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id dl10si9871422pdb.10.2015.06.09.10.48.29 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 09 Jun 2015 10:48:30 -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 1Z2NdP-0007yl-Hk; Tue, 09 Jun 2015 18:48:23 +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 v2 1/3] blockdev: Factor out create_implicit_virtio_device Date: Tue, 9 Jun 2015 18:48:21 +0100 Message-Id: <1433872103-30642-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1433872103-30642-1-git-send-email-peter.maydell@linaro.org> References: <1433872103-30642-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.179 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");