From nobody Tue Feb 10 03:37:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1665495937; cv=none; d=zohomail.com; s=zohoarc; b=UCk8RbQa7FuHV4qfmNBxYIfRvAMYEUTFM0czuTvxQk7AN+za/64GEzdUIkejiNIY4b/i23vmV2mD2u7G/Tp8K9gQhfPIemW4ihclJy3r+Rg1dE/oloxLBCJ1ZQK8owIrFPRXD3+odBFe+9ATi5XhBKiwHJkzd93M5y75Wi3ZMS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495937; h=Content-Type:Content-Transfer-Encoding:Cc: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=XTee7ty9D+5ievVxWRlCbSBWdRnLXR7S75pPCnm/2HQ=; b=AXUr78gSAA56b8IkFH5/YLgbbSH/wj5btbTJ1ofyJhPGRXI0pEhG53NCxk6lHTJkHJbFzxUV4w+lzGpp8ydhD8EigNllaLObJtnIE4b2P1DIKyAf9IWr8h42OU/Wre80dEdUJQm19enDGOk2PWKIp5psool+85mU2d+WFFq/RxA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1665495937810253.19114439319083; Tue, 11 Oct 2022 06:45:37 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-AjaF_fbqPLC-zzhwOJbHpA-1; Tue, 11 Oct 2022 09:45:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3EA63C6EABA; Tue, 11 Oct 2022 13:45:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DBF2C8E405; Tue, 11 Oct 2022 13:45:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C3D4E1946A6D; Tue, 11 Oct 2022 13:45:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 81A461946A44 for ; Tue, 11 Oct 2022 13:45:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F24BB2166B26; Tue, 11 Oct 2022 13:45:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E69DA2144B22 for ; Tue, 11 Oct 2022 13:45:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9F491010424 for ; Tue, 11 Oct 2022 13:45:15 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-632-3o08V_5bNMO0bVbsduiGqA-1; Tue, 11 Oct 2022 09:45:13 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MmxkD0Zs2z1M8yS for ; Tue, 11 Oct 2022 21:40:36 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 21:45:09 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495935; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=XTee7ty9D+5ievVxWRlCbSBWdRnLXR7S75pPCnm/2HQ=; b=AWZFV2dfuUuJqxzipt24YrF9NqYTmbxseYlqQXJTATP1rBD34N2tpoeoZgcHsOOVXx6UBk 7PZ0NMnXTHxswf7tLAzglmIDr9hnu5VrfOO1wIkM1/Fjv6SZTdFm4FDfJ+sFgMMthnSYYu ClnSr/Wku1NBjcYV2vkyMD6f4SW6j7M= X-MC-Unique: AjaF_fbqPLC-zzhwOJbHpA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 3o08V_5bNMO0bVbsduiGqA-1 From: Jiang Jiacheng To: Subject: [PATCH 5/7] qemu: Support set bootindex to -1 Date: Tue, 11 Oct 2022 21:38:31 +0800 Message-ID: <20221011133834.384749-6-jiangjiacheng@huawei.com> In-Reply-To: <20221011133834.384749-1-jiangjiacheng@huawei.com> References: <20221011133834.384749-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yubihong@huawei.com, zhengchuan@huawei.com, linyilu@huawei.com, jiangjiacheng@huawei.com, xiexiangyou@huawei.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665495940121100009 Content-Type: text/plain; charset="utf-8" Enable bootindex can be set to -1, it means cancel the device's bootindex. Change bootindex's type from unsigned int to int and modify other related codes concered with type. Signed-off-by: Jiang Jiacheng --- src/conf/device_conf.h | 4 ++-- src/conf/domain_conf.c | 15 ++++++++++----- src/conf/domain_postparse.c | 2 +- src/qemu/qemu_command.c | 38 ++++++++++++++++++------------------- src/qemu/qemu_process.c | 8 ++++---- src/qemu/qemu_validate.c | 6 +++--- 6 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index f2907dc596..a9df2e6e5d 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -139,11 +139,11 @@ struct _virDomainDeviceInfo { char *romfile; /* bootIndex is only used for disk, network interface, hostdev * and redirdev devices */ - unsigned int bootIndex; + int bootIndex; /* 'effectiveBootIndex' is same as 'bootIndex' (if provided in the XML= ) but * not formatted back. This allows HV drivers to update it if bootIndex) { - virBufferAsprintf(buf, "bootIndex); + virBufferAsprintf(buf, "bootIndex); =20 if (info->loadparm) virBufferAsprintf(buf, " loadparm=3D'%s'", info->loadparm); @@ -5254,10 +5254,15 @@ virDomainDeviceBootParseXML(xmlNodePtr node, { g_autofree char *loadparm =3D NULL; =20 - if (virXMLPropUInt(node, "order", 10, - VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, - &info->bootIndex) < 0) + if (virXMLPropInt(node, "order", 10, + VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + &info->bootIndex, -1) < 0) return -1; + if (info->bootIndex =3D=3D 0 || info->bootIndex < -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("incorrect boot order '%d', expecting positive in= teger or -1"), + info->bootIndex); + } =20 info->effectiveBootIndex =3D info->bootIndex; =20 @@ -27652,7 +27657,7 @@ virDomainDeviceInfoCheckBootIndex(virDomainDef *def= G_GNUC_UNUSED, =20 if (info->bootIndex =3D=3D data->newInfo->bootIndex) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("boot order %u is already used by another device"= ), + _("boot order %d is already used by another device"= ), data->newInfo->bootIndex); return -1; } diff --git a/src/conf/domain_postparse.c b/src/conf/domain_postparse.c index df59de2d0d..9810de7437 100644 --- a/src/conf/domain_postparse.c +++ b/src/conf/domain_postparse.c @@ -1041,7 +1041,7 @@ virDomainDefCollectBootOrder(virDomainDef *def G_GNUC= _UNUSED, */ return 0; } - order =3D g_strdup_printf("%u", info->bootIndex); + order =3D g_strdup_printf("%d", info->bootIndex); =20 if (virHashLookup(bootHash, order)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a31b8ee438..e124800bcc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1765,7 +1765,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, virTristateSwitch shareRW =3D VIR_TRISTATE_SWITCH_ABSENT; g_autofree char *chardev =3D NULL; g_autofree char *drive =3D NULL; - unsigned int bootindex =3D 0; + int bootindex =3D 0; unsigned int logical_block_size =3D 0; unsigned int physical_block_size =3D 0; g_autoptr(virJSONValue) wwn =3D NULL; @@ -1951,7 +1951,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, "S:drive", drive, "S:chardev", chardev, "s:id", disk->info.alias, - "p:bootindex", bootindex, + "z:bootindex", bootindex, "p:logical_block_size", logical_block_size, "p:physical_block_size", physical_block_size, "A:wwn", &wwn, @@ -2019,25 +2019,25 @@ qemuCommandAddExtDevice(virCommand *cmd, =20 static void qemuBuildFloppyCommandLineControllerOptionsImplicit(virCommand *cmd, - unsigned int bootindex= A, - unsigned int bootindex= B) + int bootindexA, + int bootindexB) { if (bootindexA > 0) { virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "isa-fdc.bootindexA=3D%u", bootindexA); + virCommandAddArgFormat(cmd, "isa-fdc.bootindexA=3D%d", bootindexA); } =20 if (bootindexB > 0) { virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "isa-fdc.bootindexB=3D%u", bootindexB); + virCommandAddArgFormat(cmd, "isa-fdc.bootindexB=3D%d", bootindexB); } } =20 =20 static int qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand *cmd, - unsigned int bootindex= A, - unsigned int bootindex= B, + int bootindexA, + int bootindexB, const virDomainDef *de= f, virQEMUCaps *qemuCaps) { @@ -2045,8 +2045,8 @@ qemuBuildFloppyCommandLineControllerOptionsExplicit(v= irCommand *cmd, =20 if (virJSONValueObjectAdd(&props, "s:driver", "isa-fdc", - "p:bootindexA", bootindexA, - "p:bootindexB", bootindexB, + "z:bootindexA", bootindexA, + "z:bootindexB", bootindexB, NULL) < 0) return -1; =20 @@ -2062,8 +2062,8 @@ qemuBuildFloppyCommandLineControllerOptions(virComman= d *cmd, const virDomainDef *def, virQEMUCaps *qemuCaps) { - unsigned int bootindexA =3D 0; - unsigned int bootindexB =3D 0; + int bootindexA =3D 0; + int bootindexB =3D 0; bool hasfloppy =3D false; size_t i; =20 @@ -2286,7 +2286,7 @@ qemuBuildVHostUserFsDevProps(virDomainFSDef *fs, "s:chardev", chardev_alias, "P:queue-size", fs->queue_size, "s:tag", fs->dst, - "p:bootindex", fs->info.bootIndex, + "z:bootindex", fs->info.bootIndex, NULL) < 0) return NULL; =20 @@ -3762,7 +3762,7 @@ qemuBuildNicDevProps(virDomainDef *def, "s:netdev", netdev, "s:id", net->info.alias, "s:mac", macaddr, - "p:bootindex", net->info.effectiveBootIndex, + "z:bootindex", net->info.effectiveBootIndex, NULL) < 0) return NULL; =20 @@ -4576,7 +4576,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, "s:driver", "vfio-pci", "s:host", host, "s:id", dev->info->alias, - "p:bootindex", dev->info->effectiveBootIndex, + "z:bootindex", dev->info->effectiveBootIndex, "S:failover_pair_id", failover_pair_id, NULL) < 0) return NULL; @@ -4643,7 +4643,7 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def, "p:hostbus", hostbus, "p:hostaddr", hostaddr, "s:id", dev->info->alias, - "p:bootindex", dev->info->bootIndex, + "z:bootindex", dev->info->bootIndex, "T:guest-reset", guestReset, "T:guest-resets-all", guestResetsAll, NULL) < 0) @@ -4733,7 +4733,7 @@ qemuBuildSCSIHostdevDevProps(const virDomainDef *def, "s:driver", "scsi-generic", "s:drive", backendAlias, "s:id", dev->info->alias, - "p:bootindex", dev->info->bootIndex, + "z:bootindex", dev->info->bootIndex, NULL) < 0) return NULL; =20 @@ -4831,7 +4831,7 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *= def, "s:sysfsdev", mdevPath, "S:display", qemuOnOffAuto(mdevsrc->display), "B:ramfb", ramfb, - "p:bootindex", dev->info->bootIndex, + "z:bootindex", dev->info->bootIndex, NULL) < 0) return NULL; =20 @@ -9022,7 +9022,7 @@ qemuBuildRedirdevDevProps(const virDomainDef *def, "s:chardev", chardev, "s:id", dev->info.alias, "S:filter", filter, - "p:bootindex", dev->info.bootIndex, + "z:bootindex", dev->info.bootIndex, NULL) < 0) return NULL; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 32f03ff79a..327307de9c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6264,10 +6264,10 @@ static void qemuProcessPrepareDeviceBootorder(virDomainDef *def) { size_t i; - unsigned int bootCD =3D 0; - unsigned int bootFloppy =3D 0; - unsigned int bootDisk =3D 0; - unsigned int bootNetwork =3D 0; + int bootCD =3D 0; + int bootFloppy =3D 0; + int bootDisk =3D 0; + int bootNetwork =3D 0; =20 if (def->os.nBootDevs =3D=3D 0) return; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 6403266559..c3ecd03dfb 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2520,7 +2520,7 @@ qemuValidateDomainMdevDefVFIOPCI(const virDomainHostd= evDef *hostdev, } =20 /* VFIO-PCI does not support boot */ - if (hostdev->info->bootIndex) { + if (hostdev->info->bootIndex > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("booting from assigned devices is not " "supported by mediated devices of " @@ -2576,7 +2576,7 @@ qemuValidateDomainMdevDefVFIOAP(const virDomainHostde= vDef *hostdev, } =20 /* VFIO-AP does not support boot */ - if (hostdev->info->bootIndex) { + if (hostdev->info->bootIndex > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("booting from assigned devices is not " "supported by mediated devices of " @@ -2687,7 +2687,7 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHos= tdevDef *hostdev, break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: - if (hostdev->info->bootIndex) { + if (hostdev->info->bootIndex > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("booting from assigned devices is not " "supported by vhost SCSI devices")); --=20 2.33.0