From nobody Mon Feb 9 19:07:03 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=1668651323; cv=none; d=zohomail.com; s=zohoarc; b=CnWoWxzslsnqkMxnxu09SUFV6ilM9XvK4ZR4yMMViw9dfsx8BKX6l/ODSu1Ot1rTjoassflpYowugjwgO3TcZdcaJokFQY8Q5lRIsPN4BbOkdAO3CfGn+yizAme3SShPbau3sW7s2cXhTpsKBL+L2+Els2iw8tdsbwCYk0i0+30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668651323; 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=1LzOUnuDv9L7onJbmCIPsM93ARK7AHMWHkBSmIMjMV4=; b=a9voTjaUzSiNqbxg/Hw4c6Icc6yxxl1c+ay5qxOS+zBNAXI7Oodr9ZnrLkTPKu/WvS+N8d4hkxVJoou68BEDFFu0161p53foFmoy88tm+dTw4urDMcXx3t/Gh7RBh+Ag3rmCU8PAQXfNl2zyMGjybp0VXTDmNb9JHkSO1Cn1E90= 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 1668651323459970.9664700911164; Wed, 16 Nov 2022 18:15:23 -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-328-J_JRGSQMOTOEeNsahzaQpA-1; Wed, 16 Nov 2022 21:15:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75F0429DD993; Thu, 17 Nov 2022 02:15:14 +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 632BE1121331; Thu, 17 Nov 2022 02:15:14 +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 8CE5B19465B7; Thu, 17 Nov 2022 02:15:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4EAA819465A2 for ; Thu, 17 Nov 2022 02:15:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3253040C83AA; Thu, 17 Nov 2022 02:15:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A95B40C835A for ; Thu, 17 Nov 2022 02:15:11 +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 04112801585 for ; Thu, 17 Nov 2022 02:15:11 +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-74-Q4fdo6EFPk2-bqgq66bXPQ-1; Wed, 16 Nov 2022 21:15:08 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NCNlk1xdgz15Mkv for ; Thu, 17 Nov 2022 10:14:42 +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; Thu, 17 Nov 2022 10:15:03 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668651322; 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=1LzOUnuDv9L7onJbmCIPsM93ARK7AHMWHkBSmIMjMV4=; b=iQHyjEjSyKtVJ+dVq64Bu2K51qyAGSyrQfzDjrax+grtRo9HjJ+jEET+sCwxp31oG+dPQl GO35nDRQK86fyZz3V6FwniVtSHd+CStI7tKJBFUTSvWyNfIUCbLgDzAVcxO5n67A2ejjw/ fOcCTnhailTgJAzrXqg14KX/fM8H3oE= X-MC-Unique: J_JRGSQMOTOEeNsahzaQpA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Q4fdo6EFPk2-bqgq66bXPQ-1 From: Jiang Jiacheng To: Subject: [PATCH 4/7] qemu: Support update disk's bootindex Date: Thu, 17 Nov 2022 10:05:30 +0800 Message-ID: <20221117020533.45412-5-jiangjiacheng@huawei.com> In-Reply-To: <20221117020533.45412-1-jiangjiacheng@huawei.com> References: <20221117020533.45412-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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.1 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.3 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: 1668651325381100005 Content-Type: text/plain; charset="utf-8" Support to update the disk's bootindex using 'virsh update-device'. Using flag --config or --persistent to change the boot index and the change will be affected after reboot. With --persistent, we can get the result of change immediently, but it still takes effect after reboot. Currently, support update bootindex of disk type as cdrom or disk. Signed-off-by: Jiang Jiacheng --- src/qemu/qemu_domain.c | 3 ++- src/qemu/qemu_driver.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ef1a9c8c74..8cda2d814d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8234,7 +8234,8 @@ qemuDomainDiskChangeSupported(virDomainDiskDef *disk, =20 /* device alias is checked already in virDomainDefCompatibleDevice */ =20 - CHECK_EQ(info.bootIndex, "boot order", true); + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) + CHECK_EQ(info.bootIndex, "boot order", true); CHECK_EQ(rawio, "rawio", true); CHECK_EQ(sgio, "sgio", true); CHECK_EQ(discard, "discard", true); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ff5a743716..65abc04998 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6767,6 +6767,7 @@ qemuDomainChangeDiskLive(virDomainObj *vm, virDomainDiskDef *orig_disk =3D NULL; virDomainStartupPolicy origStartupPolicy; virDomainDeviceDef oldDev =3D { .type =3D dev->type }; + int needChangeIndex =3D 0; =20 if (!(orig_disk =3D virDomainDiskByTarget(vm->def, disk->dst))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -6784,6 +6785,10 @@ qemuDomainChangeDiskLive(virDomainObj *vm, if (!qemuDomainDiskChangeSupported(disk, orig_disk)) return -1; =20 + if ((needChangeIndex =3D qemuCheckBootIndex(&orig_disk->info, + disk->info.bootIndex)) < 0) + return -1; + if (!virStorageSourceIsSameLocation(disk->src, orig_disk->src)) { /* Disk source can be changed only for removable devices */ if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM && @@ -6807,6 +6812,11 @@ qemuDomainChangeDiskLive(virDomainObj *vm, dev->data.disk->src =3D NULL; } =20 + if (needChangeIndex) { + if (qemuChangeDiskBootIndex(vm, orig_disk, disk) < 0) + return -1; + } + /* in case when we aren't updating disk source we update startup polic= y here */ orig_disk->startupPolicy =3D dev->data.disk->startupPolicy; orig_disk->snapshot =3D dev->data.disk->snapshot; @@ -7503,6 +7513,24 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef, false) < 0) return -1; =20 + switch (vmdef->disks[pos]->device) { + case VIR_DOMAIN_DISK_DEVICE_CDROM: + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_LUN: + if (qemuCheckBootIndex(&vmdef->disks[pos]->info, + newDisk->info.bootIndex) < 0) + return -1; + break; + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LAST: + if ((newDisk->info.bootIndex) && + (vmdef->disks[pos]->info.bootIndex !=3D newDisk->info.boot= Index)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("this disk doesn't support update")); + return -1; + } + } + virDomainDiskDefFree(vmdef->disks[pos]); vmdef->disks[pos] =3D newDisk; dev->data.disk =3D NULL; --=20 2.33.0