From nobody Sat Feb 7 04:40:27 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=1671891719; cv=none; d=zohomail.com; s=zohoarc; b=QlujnAEo9mmqveA1tQTqw3NNYqR/98WD5RY+Ri2OKqZayqpsIGQfVxHUpt2OM2eXWBkqD3UINrT6QfpMnFNhBV2xyy92UR1+WmHbMzZDh4HwZLkVav0Wd8zeuVlnrZ1/S+8M4HfVTwdrUL7WevDK8oiBfy31yIh0AzCbXxlZ+qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671891719; 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=M+t7fjgbFexi2YWeut8NmgTsyvpC0l3lh8NdXLLv4bI=; b=SXZm/pjm22PsvkqLghwL9u5lV7mbkh2KlGIrIYtR9VH5VHKmSdB98FReMXmML0chzEfkbXlTQG1ebu8w0h0SabLdL75SRpORI866GCBh4uOH5vheBL5/Za03JEDnEbZE7RFAQFsJG6Wyzw8ewVhban3WvtjCrtXL23gU31V0D1k= 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 1671891719377280.49950743975876; Sat, 24 Dec 2022 06:21:59 -0800 (PST) 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-531-UEUkkzDgOsq0UFrWOAOFaQ-1; Sat, 24 Dec 2022 09:21:52 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FEF5380391A; Sat, 24 Dec 2022 14:21:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 453A24085720; Sat, 24 Dec 2022 14:21:48 +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 2B1F81947046; Sat, 24 Dec 2022 14:21:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 298041946588 for ; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0D534C15BAE; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06511C15BA0 for ; Sat, 24 Dec 2022 14:21:45 +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 DFCEC3C02523 for ; Sat, 24 Dec 2022 14:21:44 +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-178-ioYZEXztOZugp63sQmK8aA-1; Sat, 24 Dec 2022 09:21:42 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NfR6275S5z16LkF for ; Sat, 24 Dec 2022 22:20:26 +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.34; Sat, 24 Dec 2022 22:21:38 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671891718; 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=M+t7fjgbFexi2YWeut8NmgTsyvpC0l3lh8NdXLLv4bI=; b=BWga235MNeimBY40DQxVY5cvwqVVXe9ykqgahJ36VlkUhoEW3VbqCwCwl5Ri53z5btIC8Z vnGifSfLdshthycMgDJbMW2IOu3/K+wphyTA0hpa941TejkEUoHKUJTEPVn7Y0RJ8OAIZh BQ7WrXNI3vHGjJ5vtpC8tS7j1tgzR1U= X-MC-Unique: UEUkkzDgOsq0UFrWOAOFaQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ioYZEXztOZugp63sQmK8aA-1 From: Jiang Jiacheng To: Subject: [PATCH V3 3/7] qemu: check the bootIndex could be changed or not Date: Sat, 24 Dec 2022 22:09:20 +0800 Message-ID: <20221224140924.581972-4-jiangjiacheng@huawei.com> In-Reply-To: <20221224140924.581972-1-jiangjiacheng@huawei.com> References: <20221224140924.581972-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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.8 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.2 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: 1671891720856100004 Content-Type: text/plain; charset="utf-8" Introduce qemuCheckBootIndex to check whether the device's bootIndex can be changed or need to be changed. Only bootindex of devices whose bootIndexSpecified is true can be changed. Signed-off-by: Jiang Jiacheng --- src/qemu/qemu_domain.c | 32 ++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5c05032ce3..6ec3be14c0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12277,3 +12277,35 @@ qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv) priv->schedCoreChildPID =3D -1; } } + +/** + * qemuCheckBootIndex: + * @devInfo: origin device info + * @new_bootindex: new bootIndex + * + * Check whether the device's bootIndex can be changed or need to + * be changed. Only devices with bootIndex specified before can be + * changed with @new_bootindex. + * + * Returns: 1 on need to change + * 0 on no need to change + * -1 on could not change with an error + */ +int +qemuCheckBootIndex(virDomainDeviceInfo *devInfo, + const int new_bootindex) +{ + if (new_bootindex && !devInfo->bootIndexSpecified) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("this device does not set boot index, cannot chan= ge it.")); + return -1; + } + + /* if the new bootindex is different from the old bootindex, + * we will update the bootindex. */ + if (devInfo->bootIndex !=3D new_bootindex) { + return 1; + } + + return 0; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 2f027fad87..5869771a0d 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1140,3 +1140,7 @@ qemuDomainSchedCoreStart(virQEMUDriverConfig *cfg, =20 void qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv); + +int +qemuCheckBootIndex(virDomainDeviceInfo *devInfo, + const int new_bootindex); --=20 2.33.0