From nobody Mon Feb 9 22:03:51 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=fail(p=quarantine dis=quarantine) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1665495943; cv=none; d=zohomail.com; s=zohoarc; b=PP3REch8xb4WmPadllElhBQx3HB9irLQi5a9T7aQztYMRmb6xEKHl3lV3QyIokhEYizKrBj8BA0kvJpDtib+x5l7Nn/0jxrca5lqFwvi4DmaUoNDYdY9fJHzFq2t2r8xzUTHIzFn/hNzce3X6TrXsL9e5ZaQdyCQV44fWWSv81c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495943; 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=JltxJfq8r7RWT8qABuABqwuZJ1Cj5HI/alU12w2pppI=; b=N/CcGeZzLDLdpeNB9U7nKs3JdJdGDesB9u7Y3YRUGcaNA7MEm5HBemwRneD3pbsQyLt0RR1TzHTba78Ik2XMYiJFCn5Lay94CVgwgQlCAWgU3x/dQ0YVSBKcteIqrDZ5iQfHOiPsJNWYH46ZoOUCrxkeUIn8BJbAiVD1rb8QYA4= 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=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.133.124]) by mx.zohomail.com with SMTPS id 1665495943367898.0902835863715; Tue, 11 Oct 2022 06:45:43 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-QttTzETYMQagtYFf-Gz5SA-1; Tue, 11 Oct 2022 09:45:27 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BF5718E0930; 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 85016492B05; 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 A2EC51946A5E; Tue, 11 Oct 2022 13:45:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 83C181946A45 for ; Tue, 11 Oct 2022 13:45:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EF4384B4017; Tue, 11 Oct 2022 13:45:13 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7C644B4016 for ; Tue, 11 Oct 2022 13:45:13 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 84DB51C05ACE for ; Tue, 11 Oct 2022 13:45:13 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-xGO9lJfwPryNljCXpb8INQ-1; Tue, 11 Oct 2022 09:45:11 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Mmxln6lFpzpSxV for ; Tue, 11 Oct 2022 21:41:57 +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:07 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495941; 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=JltxJfq8r7RWT8qABuABqwuZJ1Cj5HI/alU12w2pppI=; b=O5ce4MQrG0opIEgbK/ET2WPrC4LBt28DDkl++Kvd2w+Rypgy+U0W4v6yA+G/pd35BIecWt eQf8zAAsPEc7ISvdywfMIzA1GBF/wY0GbVpAuY3cS031eCny4VMHkVgqYcofZJSHjLcaL2 w+lRyTETCO+MMaemcbK8DVWATQVDWIY= X-MC-Unique: QttTzETYMQagtYFf-Gz5SA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: xGO9lJfwPryNljCXpb8INQ-1 From: Jiang Jiacheng To: Subject: [PATCH 2/7] qemu: Introduce qemuCheckBootIndex and qemuChangeDiskBootIndex API Date: Tue, 11 Oct 2022 21:38:28 +0800 Message-ID: <20221011133834.384749-3-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.9 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.10 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: 1665495946200100001 Content-Type: text/plain; charset="utf-8" Introduce qemuCheckBootIndex to check the new bootindex and is it nessary to update the bootindex. Introduce qemuChangeDiskBootIndex to support update disk's bootindex according to different disks' type. Signed-off-by: Jiang Jiacheng --- src/qemu/qemu_conf.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 7 +++++++ 2 files changed, 52 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index b653f44f25..3255632254 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1595,3 +1595,48 @@ qemuDomainChangeBootIndex(virDomainObj *vm, =20 return ret; } + +int +qemuCheckBootIndex(const int orig_bootindex, + const int new_bootindex) +{ + if ((new_bootindex =3D=3D -1) && ((orig_bootindex =3D=3D 0) || (orig_b= ootindex =3D=3D -1))) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("this device does not set boot index, cannot canc= el it.")); + return -1; + } + + /* if the new bootindex is different from the old bootindex and not + * equal to 0, we will update the old bootindex. + */ + if (new_bootindex && (orig_bootindex !=3D new_bootindex)) { + return 1; + } + + return 0; +} + +int +qemuChangeDiskBootIndex(virDomainObj *vm, + virDomainDiskDef *orig_disk, + virDomainDiskDef *disk) +{ + switch (disk->device) { + case VIR_DOMAIN_DISK_DEVICE_CDROM: + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_LUN: + if (qemuDomainChangeBootIndex(vm, &orig_disk->info, + disk->info.bootIndex) < 0) + return -1; + + orig_disk->info.bootIndex =3D disk->info.bootIndex; + break; + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The boot index of disk bus '%s' cannot be update= d."), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + return 0; +} diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 4e2cd84fe5..43197afb7d 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -364,3 +364,10 @@ int qemuDomainChangeBootIndex(virDomainObj *vm, virDomainDeviceInfo *devInfo, int newBootIndex) ATTRIBUTE_NONNULL(2); + +int qemuCheckBootIndex(const int orig_bootindex, + const int new_bootindex); + +int qemuChangeDiskBootIndex(virDomainObj *vm, + virDomainDiskDef *orig_disk, + virDomainDiskDef *disk); --=20 2.33.0