From nobody Tue Feb 10 09:24:40 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=1668651366; cv=none; d=zohomail.com; s=zohoarc; b=IVzabNRrQ77cHP41zIqMX8z8lYGB9hDgEa/i8ovZpBvm5K0l4x+b7YNP4Qyq2/lDrXU9LcAaebzFWHfc67mGK2p1qX0KmDJ5CpaGd+LEY20TSNKUdon4gDxEnZOv4WOF2P5GXoc1mGj43WNwHnxrxtcn+hdIa6f6Jcr6SvL/Www= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668651366; 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=idkbAmm7G8juPa0m5Azr2839UXkkovfafT38n+5KgLI=; b=UqW93aGQgW6OllG6sqC0Ksj5a3R4Ef6iN5OjtjeHvEcZiVHRFmaZnkmeOgX68X3s2q8+FbF9BXybNXAp7LssYIBJ2BEor95WO0IZEmzbd8H+LIDmX/yH0DQzJQG9Ccg2/4QOCmENL4kczlwwu5scSikaYsM6bKdc8d09b9ojiKY= 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 1668651366589779.4866434227686; Wed, 16 Nov 2022 18:16:06 -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-9-Q90sweoJPmun-4Z8zPztFA-1; Wed, 16 Nov 2022 21:15:19 -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 3F8451C068E2; Thu, 17 Nov 2022 02:15:16 +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 2A27140C6EC3; Thu, 17 Nov 2022 02:15:16 +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 0D2C519465A3; Thu, 17 Nov 2022 02:15:16 +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 F027A19465A2 for ; Thu, 17 Nov 2022 02:15:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D5EFE40C835A; Thu, 17 Nov 2022 02:15:14 +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 CE5DA40C2086 for ; Thu, 17 Nov 2022 02:15:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 AD5371C05B16 for ; Thu, 17 Nov 2022 02:15:14 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-353-xkW2UgJNMSeBYElrd42G9g-1; Wed, 16 Nov 2022 21:15:12 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NCNlr3TRQzRpNr for ; Thu, 17 Nov 2022 10:14:48 +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:04 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668651365; 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=idkbAmm7G8juPa0m5Azr2839UXkkovfafT38n+5KgLI=; b=J3/v1tnMXbkQpjxXZwP6urtEnxxx7G2fAAABCUNPMN3gWsVH5gOWVEQky3RRJerfdmbP1E aNiYuXyVcsjAYDWa4FkwE219YYy5nHsVF32y2l8lqZgKJlxg52AWrNM4MYBi2gp+mx62mI enUiWcnhcj5z/tg1hIhY49V3VtGTIm0= X-MC-Unique: Q90sweoJPmun-4Z8zPztFA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: xkW2UgJNMSeBYElrd42G9g-1 From: Jiang Jiacheng To: Subject: [PATCH 7/7] qemu: Reserve bootIndexSpecified when update device Date: Thu, 17 Nov 2022 10:05:33 +0800 Message-ID: <20221117020533.45412-8-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.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: 1668651367547100003 Content-Type: text/plain; charset="utf-8" If the 'boot order' is not specified in the xml, we cancel its bootindex setting and set it to '0'. However, the bootIndexSpecified will be set to false because we cannot parse boot order from XML, so copy bootIndexSpecified from origin device when updating it. Signed-off-by: Jiang Jiacheng --- src/qemu/qemu_conf.c | 33 +++++++++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 4 ++++ src/qemu/qemu_driver.c | 3 +++ 3 files changed, 40 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 9a7992db01..517fc813f2 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1748,3 +1748,36 @@ qemuChangeDiskBootIndex(virDomainObj *vm, } return 0; } + +/** + * qemuDomainDefCopyBootState: + * @dev: pointer to device parsed from xml + * @vmdef: pointer to vm definition structure + * + * copy the bootIndexSpecified from vmDef's device info + * + * Returns: 0 on success or no need to copy + * -1 on fail to find the device + */ +int +qemuDomainDefCopyBootState(virDomainDeviceDef *dev, virDomainDef *vmDef) +{ + int idx =3D -1; + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) { + if ((idx =3D virDomainDiskIndexByName(vmDef, dev->data.disk->dst, = false)) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("target %s doesn't exist."), dev->data.disk->= info.alias); + return -1; + } + dev->data.disk->info.bootIndexSpecified =3D vmDef->disks[idx]->inf= o.bootIndexSpecified; + } + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET) { + if ((idx =3D virDomainNetFindIdx(vmDef, dev->data.net)) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("target %s doesn't exist."), dev->data.net->i= nfo.alias); + return -1; + } + dev->data.net->info.bootIndexSpecified =3D vmDef->nets[idx]->info.= bootIndexSpecified; + } + return 0; +} diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 5b05a7392b..c1e9a2120f 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -387,3 +387,7 @@ int qemuCheckBootIndex(virDomainDeviceInfo *devInfo, int qemuChangeDiskBootIndex(virDomainObj *vm, virDomainDiskDef *orig_disk, virDomainDiskDef *disk); + + +int qemuDomainDefCopyBootState(virDomainDeviceDef *dev, + virDomainDef *vmDef); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 863b779514..3dbf95041e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7841,6 +7841,9 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, if (dev =3D=3D NULL) goto endjob; =20 + if (qemuDomainDefCopyBootState(dev, vm->def) < 0) + goto endjob; + if (flags & VIR_DOMAIN_AFFECT_CONFIG && flags & VIR_DOMAIN_AFFECT_LIVE) { /* If we are affecting both CONFIG and LIVE --=20 2.33.0