From nobody Sat May 4 18:45:32 2024 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=1671891716; cv=none; d=zohomail.com; s=zohoarc; b=B8lIaDzHmuvrpS71Fa1NeI9WEepXQZUvFLlcx4pb4ZDYnZSanhhT/ZsNDCyJZILj6WZny4ms9fTiPSG1nsk9gW8GZFYfuqANWAfVRMyPxoj3CCau8048xIdvoIKRpFK9YgqHpiqwpCdHAoqWFtPqqexgzMqujnFu1XfaBCX85uo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671891716; 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=P5k6AVbISdtlOAyEu03YcmXYHwr6HsdmdZxQaZU2Bak=; b=nxca+WDXYwL4UjgN4AJGLE/CzSkUgCdh7ruxCdd6Bha4U1lbnkJ5dDFaMIxXMT6fGO6ANrbEMOJagTWPAeUTWyvK6IgtikmUcZtp3RLVgNZbBFTRSBKDViYTrlv0VrY0OOuGVVywT1ZaVLUTLrhD5HoKA5jriO2qqK51A9gDp4k= 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 1671891716501160.1919367536981; Sat, 24 Dec 2022 06:21:56 -0800 (PST) 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-308-bqgwEaw1OUO-ds-W2R1X-g-1; Sat, 24 Dec 2022 09:21:51 -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 9FB5D8F6E8D; 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 6042240ED76E; Sat, 24 Dec 2022 14:21:47 +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 CFDE71946A73; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D702F19465B1 for ; Sat, 24 Dec 2022 14:21:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 97D972026D68; Sat, 24 Dec 2022 14:21:43 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 904392026D4B for ; Sat, 24 Dec 2022 14:21:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 704E0185A78B for ; Sat, 24 Dec 2022 14:21:43 +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-199-mgZK4BcCN82Gj2TDqKqMSw-1; Sat, 24 Dec 2022 09:21:41 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NfR6B6GQZzJqV3 for ; Sat, 24 Dec 2022 22:20:34 +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:37 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671891715; 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=P5k6AVbISdtlOAyEu03YcmXYHwr6HsdmdZxQaZU2Bak=; b=Om9sUwXx8fmdQ/33IC1y1NxxXXEAzsBwOuQrR1F/AB3YHhpbas2N0R3W+/CdWxRyJa4kE3 REp5L0j6DywmCKgyIRnrkiGeG8qlEMGtBQrwRZrVn/2fNeW5ZKI8K/toIb6xePFO2EIUtA hDp51B20aDqrfT/1J29j4GaPOnPu1ck= X-MC-Unique: bqgwEaw1OUO-ds-W2R1X-g-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: mgZK4BcCN82Gj2TDqKqMSw-1 From: Jiang Jiacheng To: Subject: [PATCH V3 1/7] qemu: Introduce qemuDomainChangeBootIndex to update device's bootindex Date: Sat, 24 Dec 2022 22:09:18 +0800 Message-ID: <20221224140924.581972-2-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.4 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: 1671891718983100001 Content-Type: text/plain; charset="utf-8" Introduce qemuDomainChangeBootIndex to support update device's bootindex. These function will be used in following patches to support change device's (support cdrom, disk and net) bootindex with virsh command like 'virsh update-device [--flag]'. Signed-off-by: Jiang Jiacheng --- src/qemu/qemu_conf.c | 41 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 5 +++++ src/qemu/qemu_monitor.c | 12 +++++++++++ src/qemu/qemu_monitor.h | 6 ++++++ src/qemu/qemu_monitor_json.c | 22 +++++++++++++++++++ src/qemu/qemu_monitor_json.h | 6 ++++++ 6 files changed, 92 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ae5bbcd138..601357a7ee 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1641,3 +1641,44 @@ qemuHugepageMakeBasedir(virQEMUDriver *driver, =20 return 0; } + +/** + * qemuDomainChangeBootIndex: + * @vm: domain object + * @devInfo: origin device info + * @newBootIndex: new bootIndex + * + * Update the bootIndex of @devInfo with @newBootIndex. Only the devices + * whose bootIndexSpecified =3D true can be updated with @newBootIndex. + * BootIndex of 0 means cancel the bootindex setting of @devInfo. + * + */ +int +qemuDomainChangeBootIndex(virDomainObj *vm, + virDomainDeviceInfo *devInfo, + int newBootIndex) +{ + int ret =3D -1; + qemuDomainObjPrivate *priv =3D vm->privateData; + + if (!devInfo->alias) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("cannot change boot index: device alias not found= ")); + return -1; + } + + VIR_DEBUG("Change dev: %s boot index from %d to %d", devInfo->alias, + devInfo->bootIndex, newBootIndex); + + /* qemu dosen't support multiple bootIndex =3D 0 and need a negative b= ootIndex + * to delete the device from fw_boot_order. So transmit -1 to qemu whe= n setting + * bootIndex =3D 0 to cancel the bootIndex setting. */ + if (newBootIndex =3D=3D 0) + newBootIndex =3D -1; + + qemuDomainObjEnterMonitor(vm); + ret =3D qemuMonitorSetBootIndex(priv->mon, devInfo->alias, newBootInde= x); + qemuDomainObjExitMonitor(vm); + + return ret; +} diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 8cf2dd2ec5..e7447191df 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -375,3 +375,8 @@ int qemuGetMemoryBackingPath(virQEMUDriver *driver, =20 int qemuHugepageMakeBasedir(virQEMUDriver *driver, virHugeTLBFS *hugepage); + +int qemuDomainChangeBootIndex(virDomainObj *vm, + virDomainDeviceInfo *devInfo, + int newBootIndex) + ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 734364e070..7866347564 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4493,3 +4493,15 @@ qemuMonitorGetStatsByQOMPath(virJSONValue *arr, =20 return NULL; } + +int +qemuMonitorSetBootIndex(qemuMonitor *mon, + const char *alias, + int bootIndex) +{ + VIR_DEBUG("name=3D%s, bootIndex=3D%d", alias, bootIndex); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONSetBootIndex(mon, alias, bootIndex); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 906a919f52..fab6f7bcbf 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1569,3 +1569,9 @@ qemuMonitorExtractQueryStats(virJSONValue *info); virJSONValue * qemuMonitorGetStatsByQOMPath(virJSONValue *arr, char *qom_path); + +int +qemuMonitorSetBootIndex(qemuMonitor *mon, + const char *alias, + int bootIndex) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9822097bd7..39a84c8ae6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8859,3 +8859,25 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, =20 return virJSONValueObjectStealArray(reply, "return"); } + +int +qemuMonitorJSONSetBootIndex(qemuMonitor *mon, + const char *alias, + int bootIndex) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-set", "s:path", alias, + "s:property", "bootindex", + "i:value", bootIndex, NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + return 0; +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 484cb09830..00c04e62d1 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -825,3 +825,9 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, qemuMonitorQueryStatsTargetType target, char **vcpus, GPtrArray *providers); + +int +qemuMonitorJSONSetBootIndex(qemuMonitor *mon, + const char *alias, + int bootIndex) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.33.0 From nobody Sat May 4 18:45:32 2024 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=1671891723; cv=none; d=zohomail.com; s=zohoarc; b=KtPEmCuDf0GWFTOK8J845+pFg9dMKqKIq0DBzbLjM0OA4W6DVvsX2tC5HM2BaeWbNpU5bOit2bTTMIeJ0CbcdOyj3vTFX9CtliRgVvgiTq0mKx21cVtOd6n7fYyQhBX2eVrHcWwJRAdo+iUwwne9IdHwie43o+6jmuf2mHEwWDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671891723; 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=WsmvcMPQsLIE/6h+yHavejswEV+vki35btfiDXCdZUg=; b=KhgSPV78M1lq6dL29WaVtN5RMCFX8Alta/ewPu8ZqjL4scNGZnvVlA3eKxG+gYanPpswi5Zv9VYqLmvmXSod4/YrRFkHZzy2xlVKspxm6jAT1fcgJezLxIaiZGLhyh7+BKnnjK2ygXtwkk9YzcF/fjGUjsKeuiJbmkAX8Eo14XU= 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 1671891723588879.9775055878032; Sat, 24 Dec 2022 06:22:03 -0800 (PST) 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-527-upzsuThVMsKUVfHTnhKTcw-1; Sat, 24 Dec 2022 09:21:52 -0500 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 9EDA080D0FF; 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 3D256492B03; 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 1B2BF1947042; Sat, 24 Dec 2022 14:21:46 +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 D93B319465B3 for ; Sat, 24 Dec 2022 14:21:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B12B82166B34; Sat, 24 Dec 2022 14:21:43 +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 AA2152166B33 for ; Sat, 24 Dec 2022 14:21:43 +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 8B963101A5B4 for ; Sat, 24 Dec 2022 14:21:43 +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-317-pfz1R3dkMcahzNljMp6q8A-1; Sat, 24 Dec 2022 09:21:41 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NfR6C0pmmzJqc7 for ; Sat, 24 Dec 2022 22:20:35 +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:37 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671891723; 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=WsmvcMPQsLIE/6h+yHavejswEV+vki35btfiDXCdZUg=; b=QzaZvhgsByhJuKVE+tTaGwJamxHVQGLbOCAtpvV9Bxg4eNbtVsC1XXrwTpqnTNRSEv/MjK d49WDscFODzFAFf6UhIbApiqI7o3azjrC49dr90fd8lV9o62jXNfMDdFYyI+1fAhOFggb+ Ssrj8RRJX52vvUno9EdDau3Z5bRWh8g= X-MC-Unique: upzsuThVMsKUVfHTnhKTcw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: pfz1R3dkMcahzNljMp6q8A-1 From: Jiang Jiacheng To: Subject: [PATCH V3 2/7] qemu: Marking a device's bootindex can be changed Date: Sat, 24 Dec 2022 22:09:19 +0800 Message-ID: <20221224140924.581972-3-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.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.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: 1671891724979100001 Content-Type: text/plain; charset="utf-8" We explicitly specify the boot order of some device in XML file to get the desired boot order, just like: ... ... Those devices are considered to be able to change the bootindex by the following patches. To distinguish those devices from others, we add a bool bootIndexSpecified into _virDomainDeviceInfo, which means the device's bootindex is specified in domain's XML file and can be changed after.BootIndexSpecified will be set to true only if the device's bootindex is set in XML. Signed-off-by: Jiang Jiacheng --- src/conf/device_conf.h | 3 +++ src/conf/domain_conf.c | 1 + 2 files changed, 4 insertions(+) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index f2907dc596..5259e25c10 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -144,6 +144,9 @@ struct _virDomainDeviceInfo { * not formatted back. This allows HV drivers to update it if effectiveBootIndex =3D info->bootIndex; + info->bootIndexSpecified =3D true; =20 loadparm =3D virXMLPropString(node, "loadparm"); if (loadparm) { --=20 2.33.0 From nobody Sat May 4 18:45:32 2024 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 From nobody Sat May 4 18:45:32 2024 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=1671891723; cv=none; d=zohomail.com; s=zohoarc; b=FS4YnKD2ZOiCbFkET/hMoj/9yLIePdAYqfgt6/IbeGBS244A1XLcfY7XkE2WejgXFFJ7clP2nspHwPW8F85swwnExT8TBNxnqJAF0EwkWm1bkTGtXBnjgrz8WPQU0D5w3ourDHd/2zKysagVFeYYWJh2uPg/fR91O/kA/4SjXV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671891723; 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=eBqru31GQKaNNBoNtFQCMcxu90u1tQv9H0Zth+4MtbM=; b=l40f3/JVvyfHOQDW7U/bBnUXalfqEMocpp3PAgK9urFDAwriAHoYV9Le4vKBPOcC2sBPqE2q9x6ib4+CFSJA6sIjeaf0JZimQCI3g7LvXVo9IRSc7uGsBRP0uwr90N/GUGNfS5wSshMmK69eoCey9tjXzr0xitY1xNBTtyL8Afo= 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 1671891723580888.7657796855826; Sat, 24 Dec 2022 06:22:03 -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-583-l2kV0Y16Mr-XrmjucNiczQ-1; Sat, 24 Dec 2022 09:21:53 -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 C62CD3C0E46C; Sat, 24 Dec 2022 14:21:49 +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 B0B254014EB9; Sat, 24 Dec 2022 14:21:49 +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 BF82519465B6; Sat, 24 Dec 2022 14:21:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3228219465B1 for ; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 24D15492B02; 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 1D149492B01 for ; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 F312B3C02524 for ; Sat, 24 Dec 2022 14:21:44 +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-593-XI251KmZOG-yipIQ4OJzSw-1; Sat, 24 Dec 2022 09:21:42 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NfR6C6JcyzJqbB for ; Sat, 24 Dec 2022 22:20:35 +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=1671891723; 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=eBqru31GQKaNNBoNtFQCMcxu90u1tQv9H0Zth+4MtbM=; b=HRiZtVIYqnjGrN2kUDCgeaFnsL53ioIKz1T/ScNVtEoemkd7uCkmQQna9OUxMu4kV4wr2+ 6L34y3b3DEpPvDzxlRgoT5lll/OKW21hxb6GbPWvZ0T3SbAdy2WEmqINfp4jRlBg1zySHB tiuXhtZmm2rTxa7Fmx966IXJK8JMV8s= X-MC-Unique: l2kV0Y16Mr-XrmjucNiczQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: XI251KmZOG-yipIQ4OJzSw-1 From: Jiang Jiacheng To: Subject: [PATCH V3 4/7] qemu: Support update disk's bootindex Date: Sat, 24 Dec 2022 22:09:21 +0800 Message-ID: <20221224140924.581972-5-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.10 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: 1671891725003100002 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 | 37 ++++++++++++++++++++++++++++++++++++- src/qemu/qemu_domain.h | 5 +++++ src/qemu/qemu_driver.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6ec3be14c0..dfc4d15387 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8235,7 +8235,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); @@ -12309,3 +12310,37 @@ qemuCheckBootIndex(virDomainDeviceInfo *devInfo, =20 return 0; } + +/** + * qemuChangeDiskBootIndex: + * @vm: domain object + * @orig_disk: the origin disk + * @disk: the new disk to be updated to + * + * check device's type and if its type support update bootIndex, update it. + * + */ +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 change= d."), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + return 0; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 5869771a0d..da661d11da 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1144,3 +1144,8 @@ qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv); int qemuCheckBootIndex(virDomainDeviceInfo *devInfo, const int new_bootindex); + +int +qemuChangeDiskBootIndex(virDomainObj *vm, + virDomainDiskDef *orig_disk, + virDomainDiskDef *disk); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d509582719..d5fa9c022c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6795,6 +6795,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, @@ -6812,6 +6813,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 && @@ -6835,6 +6840,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; @@ -7531,6 +7541,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 From nobody Sat May 4 18:45:32 2024 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=1671891725; cv=none; d=zohomail.com; s=zohoarc; b=ADxN6m/imYRh4rOOF1OeIbsCjCV5p3DN3oYBC0PQ3PIVyfe8XAMUk4m5W1K3H0AOoIQxqxMxDdF9CYa03nDp0NKXc6yXEahs9TTnICHhzBufwNdv4lfsfeMizn6cRVR15eFNr96Nk6Tg6XqyKQ6OSWBRQioWmehRKh0Cq+AVhrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671891725; 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=4Y2dP2Qz0b2h5icB5JFwAONHz17A1ZKFHO9/hwujLbU=; b=eO6uOvw+rguyUCEUsIWiDmZY/qlPt7nF9KXwSW0K1oI/pCSLjVUFmEW6aR2LZf2LuqQsrCUX3wp2T0YBDQRh6hgnMc5OUv0Oyv7//P+N1OyUv3DZllWnptDQ7v30jGCv92aWDOO9ZDAHqkhyVm/2sqsjM/afNA3GFqOzor/vvBg= 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 1671891725232833.2403630650657; Sat, 24 Dec 2022 06:22:05 -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-537-qR6uGdJfPEmzaGUgeHVdyA-1; Sat, 24 Dec 2022 09:21:52 -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 525973C0E214; Sat, 24 Dec 2022 14:21:49 +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 37C06111F3BB; Sat, 24 Dec 2022 14:21:49 +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 6F9441947059; Sat, 24 Dec 2022 14:21:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC23B1946A40 for ; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9CF6C1400E6D; 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 95C41140E949 for ; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 7BE7E3C02523 for ; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-lcpRuhS1NmKXlVt1CTQYsw-1; Sat, 24 Dec 2022 09:21:42 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NfR323LY6zJpGp for ; Sat, 24 Dec 2022 22:17:50 +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=1671891724; 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=4Y2dP2Qz0b2h5icB5JFwAONHz17A1ZKFHO9/hwujLbU=; b=NfzG39saAJarYXKU3PEGnM/F28EbdnSqaccsnlUEN/AFXmkcuEybY5CEQGpsN8U06wlBkl kI3bU/Yb0RHTo6WqKDE7oDodD51Gc/nldU51TqMHlXPfs420EVGwGukvfLqRYVGjbVStPl h89vJhdvVodKBat6huj/ZA13ix5AYxc= X-MC-Unique: qR6uGdJfPEmzaGUgeHVdyA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: lcpRuhS1NmKXlVt1CTQYsw-1 From: Jiang Jiacheng To: Subject: [PATCH V3 5/7] qemu: Support update net's bootindex Date: Sat, 24 Dec 2022 22:09:22 +0800 Message-ID: <20221224140924.581972-6-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.7 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: 1671891726853100005 Content-Type: text/plain; charset="utf-8" Support to update the net'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. Signed-off-by: Jiang Jiacheng --- src/qemu/qemu_driver.c | 4 ++++ src/qemu/qemu_hotplug.c | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d5fa9c022c..633abdcbca 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7596,6 +7596,10 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef, false) < 0) return -1; =20 + if (qemuCheckBootIndex(&vmdef->nets[pos]->info, + net->info.bootIndex) < 0) + return -1; + if (virDomainNetUpdate(vmdef, pos, net)) return -1; =20 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6e300f547c..af0cec3c46 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3468,6 +3468,7 @@ qemuDomainChangeNet(virQEMUDriver *driver, bool needCoalesceChange =3D false; bool needVlanUpdate =3D false; bool needIsolatedPortChange =3D false; + int needChangeIndex =3D 0; int ret =3D -1; int changeidx =3D -1; g_autoptr(virConnect) conn =3D NULL; @@ -3633,11 +3634,8 @@ qemuDomainChangeNet(virQEMUDriver *driver, goto cleanup; } =20 - if (newdev->info.bootIndex =3D=3D 0) - newdev->info.bootIndex =3D olddev->info.bootIndex; - if (olddev->info.bootIndex !=3D newdev->info.bootIndex) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot modify network device boot index setting"= )); + if ((needChangeIndex =3D qemuCheckBootIndex(&olddev->info, + newdev->info.bootIndex)) < 0= ) { goto cleanup; } =20 @@ -3918,6 +3916,15 @@ qemuDomainChangeNet(virQEMUDriver *driver, needReplaceDevDef =3D true; } =20 + if (needChangeIndex) { + if (qemuDomainChangeBootIndex(vm, &olddev->info, newdev->info.boot= Index) < 0) + goto cleanup; + /* we successfully switched to the new boot index, and we've + * determined that the rest of newdev is equivalent to olddev, + * so move newdev into place */ + needReplaceDevDef =3D true; + } + if (needReplaceDevDef) { /* the changes above warrant replacing olddev with newdev in * the domain's nets list. --=20 2.33.0 From nobody Sat May 4 18:45:32 2024 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=1671891717; cv=none; d=zohomail.com; s=zohoarc; b=LDMQcVBr+LaNPooSgZmX7DGUmzDwXwJv3EI5aGpOB3SFpAEJa2yh4Hp3etAVp7yGUxBnig1/ASAHXLzoTosg8b6hXr4+J0u9DnhRVyT82qQsNtYN8tllhrZ93eRvKjGRmKNYjPhDCtAZtQKYN8Dx2zwvdglc0BASkbxtHgT7kOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671891717; 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=w3A0BSP3ibZ0WPBZ4OFUJwJ81ZpcWD6QClpa2tI63yw=; b=QCiInbdYDjt0DYCEZXzinOIEFUQWVSBT04+Ub7CgMr6gSE3fEqTequnS0A5TwyrjJYm9whWfI2oWf2jDR7oDHF+V+G+YcrNI1eSkkTE4HxWc5MCrkOXqhI9q4W/30CcDCY4T84I5+q8QjS8fxgZA/yYmOfqpk0fLidhdejbu3qU= 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 1671891717924515.8313962927043; Sat, 24 Dec 2022 06:21:57 -0800 (PST) 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-491-J9swZjVsMtOObVGU0APNHw-1; Sat, 24 Dec 2022 09:21:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA1B380D0EA; Sat, 24 Dec 2022 14:21:50 +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 942CA175A2; Sat, 24 Dec 2022 14:21:50 +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 64AB819465B1; Sat, 24 Dec 2022 14:21:50 +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 0AF031946A7E for ; Sat, 24 Dec 2022 14:21:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EF21F40C2005; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E844E40C2004 for ; Sat, 24 Dec 2022 14:21:45 +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 B3BBF811E9C for ; Sat, 24 Dec 2022 14:21:45 +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-481-2wmp3fNGN6OK1qWt_alH1w-1; Sat, 24 Dec 2022 09:21:42 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NfR6330XqzmWZV for ; Sat, 24 Dec 2022 22:20:27 +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:39 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671891716; 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=w3A0BSP3ibZ0WPBZ4OFUJwJ81ZpcWD6QClpa2tI63yw=; b=ECUDycAd3oc/zNDkdJwwQVygks6XtL5WzeTQClyhRjJIg8zwsekULVoD0XZ6OmAaiGwaFM dOhhy7eM2GZWgUMuySiWf313hEKs68AQSlPD+T3PWnW9yc9GLuHXV1rke9c4UDaNBaRHbP WQy5YYqEHgBPOJ+rPy7J96nzqnGyvGo= X-MC-Unique: J9swZjVsMtOObVGU0APNHw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 2wmp3fNGN6OK1qWt_alH1w-1 From: Jiang Jiacheng To: Subject: [PATCH V3 6/7] qemu: Support set bootindex to 0 to cancel bootindex setting Date: Sat, 24 Dec 2022 22:09:23 +0800 Message-ID: <20221224140924.581972-7-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.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.5 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: 1671891720846100003 Content-Type: text/plain; charset="utf-8" Support set bootindex to 0, which means cancel the previous bootindex setting. We get bootindex =3D 0 if the bootindex isn't set or specified to 0 in the device's xml, and is used with 'bootIndexSpecified'. Support format into xml when bootIndexSpecified is true wo keep the bootindex still changeble. Support set multiple bootindex =3D 0, and boot in a Qemu's default sequence 'disk->cdrom->net' if all devices' bootindex is set to 0; Signed-off-by: Jiang Jiacheng --- src/conf/domain_conf.c | 9 ++++++--- src/conf/domain_postparse.c | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7f045b0d4a..90881f7dfe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5146,7 +5146,11 @@ virDomainDeviceInfoFormat(virBuffer *buf, g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); =20 - if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) { + if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && + (info->bootIndex || info->bootIndexSpecified)) { + /* format the boot order =3D 0 in XML when its bootIndexSpecified = is true, + * which means the boot order could be changed by virsh update-dev= ice. + */ virBufferAsprintf(buf, "bootIndex); =20 if (info->loadparm) @@ -5308,8 +5312,7 @@ virDomainDeviceBootParseXML(xmlNodePtr node, { g_autofree char *loadparm =3D NULL; =20 - if (virXMLPropUInt(node, "order", 10, - VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + if (virXMLPropUInt(node, "order", 10, VIR_XML_PROP_REQUIRED, &info->bootIndex) < 0) return -1; =20 diff --git a/src/conf/domain_postparse.c b/src/conf/domain_postparse.c index 9a3e8f494c..2ba3186561 100644 --- a/src/conf/domain_postparse.c +++ b/src/conf/domain_postparse.c @@ -1031,7 +1031,7 @@ virDomainDefCollectBootOrder(virDomainDef *def G_GNUC= _UNUSED, GHashTable *bootHash =3D data; g_autofree char *order =3D NULL; =20 - if (info->bootIndex =3D=3D 0) + if (info->bootIndex =3D=3D 0 && !info->bootIndexSpecified) return 0; =20 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV && @@ -1045,6 +1045,12 @@ virDomainDefCollectBootOrder(virDomainDef *def G_GNU= C_UNUSED, order =3D g_strdup_printf("%u", info->bootIndex); =20 if (virHashLookup(bootHash, order)) { + /* 0 in the bootHash means cancel the bootIndex specified in + * XML, so it allowed to make more than one device use 0 with + * its bootIndexSpecified =3D true. + */ + if (info->bootIndex =3D=3D 0) + return 0; virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("boot order '%s' used for more than one device"), order); --=20 2.33.0 From nobody Sat May 4 18:45:32 2024 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=1671891737; cv=none; d=zohomail.com; s=zohoarc; b=SbYWXlPp1et3z6Eoec9tsqL+XG5Q2jBxmw0OJo/YHtEnEYnpchFwajrtqnNVYaeGHT+qsk6gu0cMCXF3zN6VEX81dvNPTR/GDbd5zngwcWTySbcxyGc2jMZmPU6vfGMeoYF4W76ogcOYr7QrxvCxsD2A5io4oFMKV/BZqUAqEfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671891737; 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=NyRcpUGG3Wc2NSI3/TOg51/wjSbn6kac6y6vfIhmPrk=; b=Mw7sR/HmXpDuP6NKeJ297ymPYo5pTUpqCL86KB7AB7RIhHbUuipUS9uYxR5n8nJu2wndQPqJv2dMVmUX01d5j4Yjg1aWS/dd54dW2p0ngHPxjQA5bjPLYFoknAtk4emUc+88v8DwiK8D2f1gnSx0QJDM936o92+qJKfoPEtPfbs= 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 1671891737293893.4482632517906; Sat, 24 Dec 2022 06:22:17 -0800 (PST) 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-394-Eavbi95dMxmb4WcE8ln2Sw-1; Sat, 24 Dec 2022 09:21:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4DA2F856503; Sat, 24 Dec 2022 14:21:50 +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 351CF79A1; Sat, 24 Dec 2022 14:21:50 +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 048F419465B1; Sat, 24 Dec 2022 14:21:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0BDD31946A7F for ; Sat, 24 Dec 2022 14:21:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D6ED853A0; Sat, 24 Dec 2022 14:21:45 +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 CF06B51E5 for ; Sat, 24 Dec 2022 14:21:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 A88861C05AF1 for ; Sat, 24 Dec 2022 14:21:45 +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-472-TBoiWb_6PReFpTppFEc6TQ-1; Sat, 24 Dec 2022 09:21:43 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NfR635t4ZzmWk0 for ; Sat, 24 Dec 2022 22:20:27 +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:39 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671891736; 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=NyRcpUGG3Wc2NSI3/TOg51/wjSbn6kac6y6vfIhmPrk=; b=Y0mGMDNfXQwCagQNKAVZpIcQ6l6h6WTKrnqrX/D3Le1Gk8298+TKUS5yuUGt+DoU71qysE 2me0aEDOEO6/FyAqLZiggeNaa41Ib3dmKEf5oDAKbiVYHUDKumf2ZmpZv8cZtTUvR3XxjO t44tmu9WlQul89+C4LSuqZV//UTp/TA= X-MC-Unique: Eavbi95dMxmb4WcE8ln2Sw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: TBoiWb_6PReFpTppFEc6TQ-1 From: Jiang Jiacheng To: Subject: [PATCH V3 7/7] test: add a test for bootIndex = 0 provided by the user Date: Sat, 24 Dec 2022 22:09:24 +0800 Message-ID: <20221224140924.581972-8-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.5 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.5 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: 1671891738958100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiang Jiacheng --- src/conf/schemas/domaincommon.rng | 2 +- tests/qemuxml2argvdata/boot-order-set-0.xml | 72 +++++++++++++++++++ tests/qemuxml2xmloutdata/boot-order-set-0.xml | 72 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/boot-order-set-0.xml create mode 100644 tests/qemuxml2xmloutdata/boot-order-set-0.xml diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index c588a48fd2..0f42911cf0 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -7160,7 +7160,7 @@ - + diff --git a/tests/qemuxml2argvdata/boot-order-set-0.xml b/tests/qemuxml2ar= gvdata/boot-order-set-0.xml new file mode 100644 index 0000000000..dc980e5e6f --- /dev/null +++ b/tests/qemuxml2argvdata/boot-order-set-0.xml @@ -0,0 +1,72 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + +
+ + +
+ + +
+ + + + + + + +
+ + + +