From nobody Sun Nov 9 14:35:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551120200226651.4017230697121; Mon, 25 Feb 2019 10:43:20 -0800 (PST) Received: from localhost ([127.0.0.1]:42718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyLDh-0002Sn-84 for importer@patchew.org; Mon, 25 Feb 2019 13:43:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyL8r-00075n-Oh for qemu-devel@nongnu.org; Mon, 25 Feb 2019 13:38:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyL8o-0005Z9-Si for qemu-devel@nongnu.org; Mon, 25 Feb 2019 13:38:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50500) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyL8g-0005IX-Rt; Mon, 25 Feb 2019 13:38:07 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AFCDC05000B; Mon, 25 Feb 2019 18:38:05 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 037ED60863; Mon, 25 Feb 2019 18:38:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E52921133040; Mon, 25 Feb 2019 19:37:57 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 25 Feb 2019 19:37:56 +0100 Message-Id: <20190225183757.27378-6-armbru@redhat.com> In-Reply-To: <20190225183757.27378-1-armbru@redhat.com> References: <20190225183757.27378-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 25 Feb 2019 18:38:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 5/6] vl: Create block backends before setting machine properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-block@nongnu.org, mst@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qemu-system-FOO's main() acts on command line arguments in its own idiosyncratic order. There's not much method to its madness. Whenever we find a case where one kind of command line argument needs to refer to something created for another kind later, we rejigger the order. Block devices get created long after machine properties get processed. Therefore, block device machine properties can be created, but not set. No such properties exist. But the next commit will create some. Time to rejigger again: create block devices earlier. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- vl.c | 66 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/vl.c b/vl.c index 6ce3d2d448..5cb0810ffa 100644 --- a/vl.c +++ b/vl.c @@ -4232,6 +4232,39 @@ int main(int argc, char **argv, char **envp) exit(0); } =20 + /* If the currently selected machine wishes to override the units-per-= bus + * property of its default HBA interface type, do so now. */ + if (machine_class->units_per_default_bus) { + override_max_devs(machine_class->block_default_type, + machine_class->units_per_default_bus); + } + + /* open the virtual block devices */ + while (!QSIMPLEQ_EMPTY(&bdo_queue)) { + BlockdevOptions_queue *bdo =3D QSIMPLEQ_FIRST(&bdo_queue); + + QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry); + loc_push_restore(&bdo->loc); + qmp_blockdev_add(bdo->bdo, &error_fatal); + loc_pop(&bdo->loc); + qapi_free_BlockdevOptions(bdo->bdo); + g_free(bdo); + } + if (snapshot || replay_mode !=3D REPLAY_MODE_NONE) { + qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, + NULL, NULL); + } + if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, + &machine_class->block_default_type, &error_fatal= )) { + /* We printed help */ + exit(0); + } + + default_drive(default_cdrom, snapshot, machine_class->block_default_ty= pe, 2, + CDROM_OPTS); + default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); + default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); + machine_opts =3D qemu_get_machine_opts(); qemu_opt_foreach(machine_opts, machine_set_property, current_machine, &error_fatal); @@ -4355,39 +4388,6 @@ int main(int argc, char **argv, char **envp) ram_mig_init(); dirty_bitmap_mig_init(); =20 - /* If the currently selected machine wishes to override the units-per-= bus - * property of its default HBA interface type, do so now. */ - if (machine_class->units_per_default_bus) { - override_max_devs(machine_class->block_default_type, - machine_class->units_per_default_bus); - } - - /* open the virtual block devices */ - while (!QSIMPLEQ_EMPTY(&bdo_queue)) { - BlockdevOptions_queue *bdo =3D QSIMPLEQ_FIRST(&bdo_queue); - - QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry); - loc_push_restore(&bdo->loc); - qmp_blockdev_add(bdo->bdo, &error_fatal); - loc_pop(&bdo->loc); - qapi_free_BlockdevOptions(bdo->bdo); - g_free(bdo); - } - if (snapshot || replay_mode !=3D REPLAY_MODE_NONE) { - qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, - NULL, NULL); - } - if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, - &machine_class->block_default_type, &error_fatal= )) { - /* We printed help */ - exit(0); - } - - default_drive(default_cdrom, snapshot, machine_class->block_default_ty= pe, 2, - CDROM_OPTS); - default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); - default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); - qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, &error_fatal); =20 --=20 2.17.2