From nobody Thu May 15 06:06:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1511198788104811.9198639067808; Mon, 20 Nov 2017 09:26:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E00C673C; Mon, 20 Nov 2017 17:26:26 +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 BC2365FFE9; Mon, 20 Nov 2017 17:26:26 +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 85B9E180212C; Mon, 20 Nov 2017 17:26:26 +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 vAKHQK5C025214 for ; Mon, 20 Nov 2017 12:26:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 26B8F649D2; Mon, 20 Nov 2017 17:26:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id C521E60476; Mon, 20 Nov 2017 17:26:11 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 20 Nov 2017 18:25:27 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 10/12] qemu: command: Move around logic for formatting bootindex 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 20 Nov 2017 17:26:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Propagate the raw bootindex and let the code decide whether to use it when formatting. --- src/qemu/qemu_command.c | 16 +++++++--------- src/qemu/qemu_command.h | 2 +- src/qemu/qemu_hotplug.c | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 03a2e6855a..89bc41e468 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1716,7 +1716,7 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr d= isk, char * qemuBuildDriveStr(virDomainDiskDefPtr disk, virQEMUDriverConfigPtr cfg, - bool bootable, + int bootindex, virQEMUCapsPtr qemuCaps) { virBuffer opt =3D VIR_BUFFER_INITIALIZER; @@ -1764,12 +1764,14 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } } - if (bootable && + if (bootindex && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) && (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK || disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) && disk->bus !=3D VIR_DOMAIN_DISK_BUS_IDE) virBufferAddLit(&opt, ",boot=3Don"); + if (disk->src->readonly) virBufferAddLit(&opt, ",readonly=3Don"); @@ -2219,7 +2221,6 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, for (i =3D 0; i < def->ndisks; i++) { char *optstr; unsigned int bootindex =3D 0; - bool driveBoot =3D false; virDomainDiskDefPtr disk =3D def->disks[i]; qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_= SOURCE_PRIVATE(disk->src); qemuDomainSecretInfoPtr secinfo =3D NULL; @@ -2248,10 +2249,6 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, bootDisk =3D 0; break; } - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) { - driveBoot =3D !!bootindex; - bootindex =3D 0; - } } if (qemuBuildDiskSecinfoCommandLine(cmd, secinfo) < 0) @@ -2266,7 +2263,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, virCommandAddArg(cmd, "-drive"); - if (!(optstr =3D qemuBuildDriveStr(disk, cfg, driveBoot, qemuCaps)= )) + if (!(optstr =3D qemuBuildDriveStr(disk, cfg, bootindex, qemuCaps)= )) return -1; virCommandAddArg(cmd, optstr); @@ -2287,7 +2284,8 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, } VIR_FREE(optstr); - if (bootindex) { + if (bootindex && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) { if (virAsprintf(&optstr, "bootindex%c=3D%u", disk->info.addr.drive.unit ? 'B' : 'A', diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 2bcfc6c707..e60245427a 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -102,7 +102,7 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk= ); /* Both legacy & current support */ char *qemuBuildDriveStr(virDomainDiskDefPtr disk, virQEMUDriverConfigPtr cfg, - bool bootable, + int bootindex, virQEMUCapsPtr qemuCaps); /* Current, best practice */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 72a57d89ed..5c8054f72d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -409,7 +409,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, disk->info.alias) < 0) goto error; - if (!(drivestr =3D qemuBuildDriveStr(disk, cfg, false, priv->qemuCaps)= )) + if (!(drivestr =3D qemuBuildDriveStr(disk, cfg, 0, priv->qemuCaps))) goto error; if (!(drivealias =3D qemuAliasFromDisk(disk))) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list