From nobody Mon Feb 9 20:35:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621601291; cv=none; d=zohomail.com; s=zohoarc; b=azrkKh6uQ5USkMvbPalIjUj7Pa4WlQY9Mqy4lqfhuVAGOs6uXn8Lm4z3NoK9hNWElyZg/SWIRsGSyl36D9PQwEJchakefTjdFUGNguPDa4LSe8Rj2P/zEt/HYCNb4cfNVmNVeo9hsFqk/MH2NaEW0kLMjT7mFCL+fXnKM5zHx1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601291; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MhES0pbfZhWuTi1jayo1UwkrALZ6Bu8Z67v7VMHm8RM=; b=MmKGdj7GroSwCLLQs/BX64diGt87F5ieQEICSSfGLnW5DbWWHebJzsgmKsvdlviJLVD6pB2poX+foopIKzwucfYqT6G48gs9yhhPhfTJwyIUyLUSxGV8IO9ddiSi+eMGRvJN4hE7XisH5X4ZPpfD7VRFJG4JMFLSsneuK/4ujtw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601291821772.8821786031486; Fri, 21 May 2021 05:48:11 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-PRefy8qUNrOp5tvuEsoNLg-1; Fri, 21 May 2021 08:48:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A1D66409F; Fri, 21 May 2021 12:48:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BE811964B; Fri, 21 May 2021 12:48:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D66C91801028; Fri, 21 May 2021 12:48:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LClpof031002 for ; Fri, 21 May 2021 08:47:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 023F169FB1; Fri, 21 May 2021 12:47:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 647FE78620 for ; Fri, 21 May 2021 12:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601290; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MhES0pbfZhWuTi1jayo1UwkrALZ6Bu8Z67v7VMHm8RM=; b=L1lFMlHqEkB15dvBvzZRBFZFpBSCNswXFnLy83TaG1YuJF2bvc5Z3tpsvTZ54gu3DECrQt fkJFI7weWBGgNvICjKStRuOm/JQR37hi8mNEFlHzk3h9YOBTsnVWBBi3fa+wt/dSIzF/eq bwfZoS5h1PaTdOB1xVOFRW1hqvM/gGM= X-MC-Unique: PRefy8qUNrOp5tvuEsoNLg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/35] qemu: Move 'bootindex' handling for disks out of command line formatter Date: Fri, 21 May 2021 14:47:09 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The logic assigning the bootindices from the legacy boot orded configuration was spread through the command line formatters for the disk device and for the floppy controller. This patch adds 'effectiveBootindex' property to the disk private data which holds the calculated boot index and moves the logic of determining the boot index into 'qemuProcessPrepareDomainDiskBootorder' called from 'qemuProcessPrepareDomainStorage'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 63 +++++++-------------------------------- src/qemu/qemu_domain.h | 4 +++ src/qemu/qemu_process.c | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 53 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index dcc060bde9..b01421f61b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1976,13 +1976,11 @@ qemuCommandAddExtDevice(virCommand *cmd, static int qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd, const virDomainDef *def, - virQEMUCaps *qemuCaps, - unsigned int bootFloppy) + virQEMUCaps *qemuCaps) { g_auto(virBuffer) fdc_opts =3D VIR_BUFFER_INITIALIZER; bool explicitfdc =3D qemuDomainNeedsFDC(def); bool hasfloppy =3D false; - unsigned int bootindex; char driveLetter; size_t i; @@ -1993,26 +1991,21 @@ qemuBuildFloppyCommandLineControllerOptions(virComm= and *cmd, g_autofree char *backendStr =3D NULL; g_autofree char *bootindexStr =3D NULL; virDomainDiskDef *disk =3D def->disks[i]; + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_FDC) continue; hasfloppy =3D true; - if (disk->info.bootIndex) { - bootindex =3D disk->info.bootIndex; - } else { - bootindex =3D bootFloppy; - bootFloppy =3D 0; - } - if (disk->info.addr.drive.unit) driveLetter =3D 'B'; else driveLetter =3D 'A'; - if (bootindex) - bootindexStr =3D g_strdup_printf("bootindex%c=3D%u", driveLett= er, bootindex); + if (diskPriv->effectiveBootindex > 0) + bootindexStr =3D g_strdup_printf("bootindex%c=3D%u", driveLett= er, + diskPriv->effectiveBootindex); /* with -blockdev we setup the floppy device and it's backend with= -device */ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { @@ -2210,66 +2203,30 @@ qemuBuildDisksCommandLine(virCommand *cmd, virQEMUCaps *qemuCaps) { size_t i; - unsigned int bootCD =3D 0; - unsigned int bootFloppy =3D 0; - unsigned int bootDisk =3D 0; bool blockdev =3D virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV); - for (i =3D 0; i < def->os.nBootDevs; i++) { - switch (def->os.bootDevs[i]) { - case VIR_DOMAIN_BOOT_CDROM: - bootCD =3D i + 1; - break; - case VIR_DOMAIN_BOOT_FLOPPY: - bootFloppy =3D i + 1; - break; - case VIR_DOMAIN_BOOT_DISK: - bootDisk =3D i + 1; - break; - } - } - /* If we want to express the floppy drives via -device, the controller= needs * to be instantiated prior to that */ if (blockdev && - qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps, bo= otFloppy) < 0) + qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps) < = 0) return -1; for (i =3D 0; i < def->ndisks; i++) { virDomainDiskDef *disk =3D def->disks[i]; + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); unsigned int bootindex =3D 0; - if (disk->info.bootIndex) { - bootindex =3D disk->info.bootIndex; - } else { - switch (disk->device) { - case VIR_DOMAIN_DISK_DEVICE_CDROM: - bootindex =3D bootCD; - bootCD =3D 0; - break; - case VIR_DOMAIN_DISK_DEVICE_DISK: - case VIR_DOMAIN_DISK_DEVICE_LUN: - bootindex =3D bootDisk; - bootDisk =3D 0; - break; - case VIR_DOMAIN_DISK_DEVICE_FLOPPY: - case VIR_DOMAIN_DISK_DEVICE_LAST: - default: - break; - } - } - /* The floppy device itself does not support the bootindex property * so we need to set it up for the controller */ - if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) - bootindex =3D 0; + if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) + bootindex =3D diskPriv->effectiveBootindex; if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps, bootindex) = < 0) return -1; } if (!blockdev && - qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps, bo= otFloppy) < 0) + qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps) < = 0) return -1; return 0; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 2626f5dcaa..4fc1969d9e 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -288,6 +288,10 @@ struct _qemuDomainDiskPrivate { char *qomName; /* QOM path of the disk (also refers to the block backe= nd) */ char *nodeCopyOnRead; /* nodename of the disk-wide copy-on-read blockd= ev layer */ + + unsigned int effectiveBootindex; /* boot index of the disk based on one + of the two ways we use to select a= boot + device */ }; #define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d743a581b3..7fe051505b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6290,6 +6290,70 @@ qemuProcessPrepareDomainNUMAPlacement(virDomainObj *= vm) } +static void +qemuProcessPrepareDomainDiskBootorder(virDomainDef *def) +{ + size_t i; + unsigned int bootCD =3D 0; + unsigned int bootFloppy =3D 0; + unsigned int bootDisk =3D 0; + + for (i =3D 0; i < def->os.nBootDevs; i++) { + switch ((virDomainBootOrder) def->os.bootDevs[i]) { + case VIR_DOMAIN_BOOT_CDROM: + bootCD =3D i + 1; + break; + + case VIR_DOMAIN_BOOT_FLOPPY: + bootFloppy =3D i + 1; + break; + + case VIR_DOMAIN_BOOT_DISK: + bootDisk =3D i + 1; + break; + + case VIR_DOMAIN_BOOT_NET: + /* network boot is handled in network device formatting code */ + case VIR_DOMAIN_BOOT_LAST: + default: + break; + } + } + + for (i =3D 0; i < def->ndisks; i++) { + virDomainDiskDef *disk =3D def->disks[i]; + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); + + if (disk->info.bootIndex > 0) { + diskPriv->effectiveBootindex =3D disk->info.bootIndex; + continue; + } + + switch (disk->device) { + case VIR_DOMAIN_DISK_DEVICE_CDROM: + diskPriv->effectiveBootindex =3D bootCD; + bootCD =3D 0; + break; + + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_LUN: + diskPriv->effectiveBootindex =3D bootDisk; + bootDisk =3D 0; + break; + + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + diskPriv->effectiveBootindex =3D bootFloppy; + bootFloppy =3D 0; + break; + + case VIR_DOMAIN_DISK_DEVICE_LAST: + default: + break; + } + } +} + + static int qemuProcessPrepareDomainStorage(virQEMUDriver *driver, virDomainObj *vm, @@ -6316,6 +6380,8 @@ qemuProcessPrepareDomainStorage(virQEMUDriver *driver, return -1; } + qemuProcessPrepareDomainDiskBootorder(vm->def); + return 0; } --=20 2.31.1