From nobody Thu Apr 25 22:03:27 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=1668651364; cv=none; d=zohomail.com; s=zohoarc; b=ZHH5IrijKm/KjOwjSaftP6ua2uAxsFup6X6ThCxEJvl1uath4VIAPc3tpLKylt3dhvqKUBjRrXN7j/h9III6z9VPy8SJgkrIiCjz9g6YaBIWqCOHxoNKK7xbGoutdbTBMQgdM2msusmSh9N5a2B/8P09Q1jnP9MdOGW4NSBEbjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668651364; 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=xGvFYGpvoOQ52UNYzgCFRKKauN8Sm/R4u2dF0jnSmX4=; b=dFlL2WDk5AUlQkU0B2ovztPZLe13Wx7sGglgiEyvjJ5LKjvHnZiI27DWYoVZQ/tuj3BmAd/a6l+PlUPmz4jlZzZBsi30DYaB89CQFy+/93UFkjn4IYHXjG3TY32Ii4ZOM8/0dr4UDq+y16W+ljZaEefQIufVsswqebZ4MsrZCGI= 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 1668651364015369.87366675877604; Wed, 16 Nov 2022 18:16:04 -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-655-dp-PxEhLMB6M1vvAZfGX2Q-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 35DD11869EC4; 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 C32001121331; Thu, 17 Nov 2022 02:15:13 +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 577E71946A51; Thu, 17 Nov 2022 02:15:12 +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 B558319465A2 for ; Thu, 17 Nov 2022 02:15:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ABA6240C2086; Thu, 17 Nov 2022 02:15:10 +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 A3F2F40C835A for ; Thu, 17 Nov 2022 02:15:10 +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 8A1BD3C01DED for ; Thu, 17 Nov 2022 02:15:10 +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-EMjl1kerMBmCeIPfkeOWSw-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 4NCNlk1QKmz15MkT 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:02 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668651363; 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=xGvFYGpvoOQ52UNYzgCFRKKauN8Sm/R4u2dF0jnSmX4=; b=Gf7mLKcJjlf8ySg5/osoPBHsANJeRJ12MWoCrvr7xeevY1RIDoDSVPiiRbaLIoKV/8b/XY 4Gh5sdYb6dMrWFSOmcVIivKNlarpsz1Ib8NLcGDGb0H0KttEaASaCeDtrM8zJOysch7F4+ uoEkN9IV4lFFrJhzik6x5gVwo5+ZSaQ= X-MC-Unique: dp-PxEhLMB6M1vvAZfGX2Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: EMjl1kerMBmCeIPfkeOWSw-1 From: Jiang Jiacheng To: Subject: [PATCH 1/7] qemu: Introduce qemuDomainChangeBootIndex API Date: Thu, 17 Nov 2022 10:05:27 +0800 Message-ID: <20221117020533.45412-2-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: 1668651365545100001 Content-Type: text/plain; charset="utf-8" Introduce qemuDomainChangeBootIndex api to support update device's bootinde= x. 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 | 40 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 5 +++++ src/qemu/qemu_monitor.c | 20 ++++++++++++++++++ src/qemu/qemu_monitor.h | 6 ++++++ src/qemu/qemu_monitor_json.c | 33 +++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 6 ++++++ 6 files changed, 110 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ae5bbcd138..0071a95cb6 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1641,3 +1641,43 @@ qemuHugepageMakeBasedir(virQEMUDriver *driver, =20 return 0; } + +/** + * qemuDomainChangeBootIndex: + * @vm: domain object + * @devInfo: origin device info + * @newBootIndex: new bootIndex + * + * check the alias and bootindex before send the command + * + * Returns: 0 on success, + * -1 otherwise. + */ +int +qemuDomainChangeBootIndex(virDomainObj *vm, + virDomainDeviceInfo *devInfo, + int newBootIndex) +{ + int ret =3D -1; + int dummyIndex =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); + + qemuDomainObjEnterMonitor(vm); + /* newBootIndex =3D 0 means cancel the specified bootIndex, send -1 to= qemu instead */ + if (!newBootIndex) + ret =3D qemuMonitorSetBootIndex(priv->mon, devInfo->alias, dummyIn= dex); + else + ret =3D qemuMonitorSetBootIndex(priv->mon, devInfo->alias, newBoot= Index); + 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 80f262cec7..2b89d9bdae 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4491,3 +4491,23 @@ qemuMonitorGetStatsByQOMPath(virJSONValue *arr, =20 return NULL; } + +/** + * qemuMonitorSetBootIndex: + * @mon: monitor object + * @alias: device's alias + * @bootIndex: new boot index + * + * Returns data from a call to 'qom-set' + */ +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 c690fc3655..0b9943e1f7 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1568,3 +1568,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 f4e942a32f..75de73e61b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8890,3 +8890,36 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, =20 return virJSONValueObjectStealArray(reply, "return"); } + +/** + * qemuMonitorSetBootIndex: + * @mon: monitor object + * @alias: device's alias + * @bootIndex: new boot index + * + * Set the bootindex of device to new bootIndex + * + * Returns: 0 on success, + * -1 otherwise. + */ +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 93789480c5..30cd92f232 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -824,3 +824,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 Thu Apr 25 22:03:27 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=1668651322; cv=none; d=zohomail.com; s=zohoarc; b=aE+xDoqzq5he0Yq+24tfGSDYG2yteRBdC083S4oaj8o2yCSkQnSH7Uvds9kORo7LbmIDukrmoayqIMJKvt299flTp1OpM8WHkmwSIYs5BF7ICaQqRfGUSrAdxFla51QTdpZNX0LssrtUr9Z/deF9qTYdjNjCVnI11ZwnJDySLKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668651322; 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=YiMca3XjVlWn5gVA2kYOgyMCgJyxyn5+/wQSYIUO/zk=; b=k+kSOPSKPM7T+t5O+9yI6vCnCykn7b6P2DtvRc3oHouQtum4lWTxyq09m7uilBs6k/rjyBwNSDFA5dmWWq3DCYbzwCtegbow7mVSbEXhgk31nbMHlyKci6Cd7S6k6dPwuoKXD4EGDH4xVgzm4VwbXZc/XFih7HkWDqioEhUARYg= 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 1668651322386710.1493888785451; Wed, 16 Nov 2022 18:15:22 -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-258-jg4rE5-gOk-Qixp789LRbg-1; Wed, 16 Nov 2022 21:15:16 -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 3A2A686C16D; 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 40A46492B05; Thu, 17 Nov 2022 02:15:13 +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 0C4E91946A44; Thu, 17 Nov 2022 02:15:12 +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 687C019465A2 for ; Thu, 17 Nov 2022 02:15:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4E06D2166B30; Thu, 17 Nov 2022 02:15:10 +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 474F62166B29 for ; Thu, 17 Nov 2022 02:15:10 +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 28A871C051A3 for ; Thu, 17 Nov 2022 02:15:10 +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-Q5Tl43-EO_WyLbIkc5HHlA-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 4NCNlk1bhdz15Mkq 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:02 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668651321; 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=YiMca3XjVlWn5gVA2kYOgyMCgJyxyn5+/wQSYIUO/zk=; b=U4hrqQvbFGm28SBWDpFKn6OD/N+Vz34WYJY9fUR/DbijQznaVxsnDDhYCkBlBEpC+FwQ3u M98so9icKFNFb04QHPNF1Wk4yMiO4ehbJVGFIRPzVmnIZng5CFxu7cjmZsNbEa6TKYf0ts TZ94w3u25CyYF86yaD6gVOp39Z9RisQ= X-MC-Unique: jg4rE5-gOk-Qixp789LRbg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Q5Tl43-EO_WyLbIkc5HHlA-1 From: Jiang Jiacheng To: Subject: [PATCH 2/7] qemu: Add bootIndexSpecified and support set bootIndex to '0' Date: Thu, 17 Nov 2022 10:05:28 +0800 Message-ID: <20221117020533.45412-3-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.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: 1668651323370100002 Content-Type: text/plain; charset="utf-8" Add a bool bootIndexSpecified into _virDomainDeviceInfo, which means whether the bootindex could be update or not. BootIndexSpecified will be set to true if bootindex is set in XML. Support set bootindex to 0, which means cancel the previous bootindex setti= ng, and format boot order =3D '0' into XML when its bootIndexSpecified is true = to keep its bootindex changeble. Signed-off-by: Jiang Jiacheng --- src/conf/device_conf.h | 3 +++ src/conf/domain_conf.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) 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 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) @@ -5304,12 +5307,12 @@ 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 info->effectiveBootIndex =3D info->bootIndex; + info->bootIndexSpecified =3D true; =20 loadparm =3D virXMLPropString(node, "loadparm"); if (loadparm) { --=20 2.33.0 From nobody Thu Apr 25 22:03:27 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=1668651326; cv=none; d=zohomail.com; s=zohoarc; b=BbDLbTtE4zpy47sWwEJtvRJ4TXtV2wPQE9x2SIJ/LhUsSLhhuCKHUlUVjsGGYkig5/E+lwq+AgRxSzmaLSyQSc5pmc+Ta3b+jjv1wUT57dsf7PR+e9wh5cddVnzdBiqUEu3q23Xk7KhU2LcjqCFpOkIJZ6hh3EcCjjLevwxhjYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668651326; 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=ytipWtWZ83xtloHlQs9rLJ6ohzWy+62zwENvruRKrmE=; b=mXrDajf1OER/zh4ufjacHBIbVKF2QSMwlUztW/cA5Ri5I2t4/zIA8VSdEcc7Ad64xLYrAfu5aderX3f9JCJXy74YwTS6ZMnhuQ69FX4odkgx+QoKsfe/saAMKuiuOHtIGICaxFOYR1Y03P1pbUY+lsNR6RLYVrOSu8jTMo1Ux1E= 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 1668651326235905.8547850227528; Wed, 16 Nov 2022 18:15:26 -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-245-JP8OKrufOASY8MwOnR7_zA-1; Wed, 16 Nov 2022 21:15:18 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77F3038123C9; 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 63DE42027064; 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 AED1419466DF; Thu, 17 Nov 2022 02:15:13 +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 CBCF119465B7 for ; Thu, 17 Nov 2022 02:15:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BE93F18EB4; Thu, 17 Nov 2022 02:15:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6DB117595 for ; Thu, 17 Nov 2022 02:15:11 +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 9771B29AB410 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-625-INQtuXMYOCiuVFdfhzaYUg-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 4NCNlk1mk7z15Mks 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:02 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668651324; 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=ytipWtWZ83xtloHlQs9rLJ6ohzWy+62zwENvruRKrmE=; b=UyGd3L263uXXAc/5Xhk7KKMW6Os/koHHIjyfP8CZOG3OAgg/+ALBqkMvKykEpYNltXU/7O kmkwX0YWXMzOHyfaUXrEjcnHQePMHiU+bamLXGW2ohw6KMFGEOeNpLcISs8SMTb5A6SrGz Cm3LBSz+vGaV2qZhMHoKjMjOFqZuH+A= X-MC-Unique: JP8OKrufOASY8MwOnR7_zA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: INQtuXMYOCiuVFdfhzaYUg-1 From: Jiang Jiacheng To: Subject: [PATCH 3/7] qemu: Introduce qemuCheckBootIndex and qemuChangeDiskBootIndex API Date: Thu, 17 Nov 2022 10:05:29 +0800 Message-ID: <20221117020533.45412-4-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.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.4 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: 1668651327375100009 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 | 67 ++++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 7 +++++ 2 files changed, 74 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 0071a95cb6..9a7992db01 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1681,3 +1681,70 @@ qemuDomainChangeBootIndex(virDomainObj *vm, =20 return ret; } + +/** + * qemuCheckBootIndex: + * @devInfo: origin device info + * @new_bootindex: new bootIndex + * + * check whether the device's bootIndex could be changed or neet to + * be changed + * + * Returns: 1 on need to change + * 0 on don't need to change + * -1 on could not change with an error + */ +int +qemuCheckBootIndex(virDomainDeviceInfo *devInfo, + const int new_bootindex) +{ + if (!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; +} + +/** + * 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. + * + * Returns: 0 on success + * -1 on fail + */ +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_conf.h b/src/qemu/qemu_conf.h index e7447191df..5b05a7392b 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -380,3 +380,10 @@ int qemuDomainChangeBootIndex(virDomainObj *vm, virDomainDeviceInfo *devInfo, int newBootIndex) ATTRIBUTE_NONNULL(2); + +int qemuCheckBootIndex(virDomainDeviceInfo *devInfo, + const int new_bootindex); + +int qemuChangeDiskBootIndex(virDomainObj *vm, + virDomainDiskDef *orig_disk, + virDomainDiskDef *disk); --=20 2.33.0 From nobody Thu Apr 25 22:03:27 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=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 From nobody Thu Apr 25 22:03:27 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=1668651325; cv=none; d=zohomail.com; s=zohoarc; b=QUFRp+hWnhJoFf+JpJtRJu3C5L+T86DO5LwDuVZhvCLcA9KMqYNkIcz+W9eSQyY/ldzXEPbWcRzXiPPsNSGOyLNjWW2i7EE/P9XZIckL+HmjCppGT6Hf9HNbnEO2Wb6HEAPLkHFYYaB+ahsAtJ5DsAHmLD/206wVxV2VjO6NMhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668651325; 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=RYZLOOtmK6vfRG0+bPAdkx5uVLexAXJmFL4RrJPan/Q=; b=DWMYXyrlRHT7B+yllJMhTWhlzZrBQS4E7jY6+l3jjZzsS3pLcHLW5a++dJZ2NO/PxchCtu2wojtqw3gaZ513QzlHvq/2anIadd+KFXWluDude8WLrusY6yWI+sDyY3d5RPFPbQmj/q1E7YjvFVm4UYljaBhE8vM+F5DPQ4V/ZjU= 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 1668651325842526.0801467575038; Wed, 16 Nov 2022 18:15:25 -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-632-dHz2QaTzNEC5lsXE_btO8Q-1; Wed, 16 Nov 2022 21:15:20 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BF31800186; Thu, 17 Nov 2022 02:15:17 +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 88904201F402; Thu, 17 Nov 2022 02:15:17 +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 6515C19465A3; Thu, 17 Nov 2022 02:15:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 814BE19465A2 for ; Thu, 17 Nov 2022 02:15:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 658A61121333; Thu, 17 Nov 2022 02:15:14 +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 5E42E112132C for ; Thu, 17 Nov 2022 02:15:14 +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 456D586C170 for ; Thu, 17 Nov 2022 02:15:14 +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-56-akP1u7ASPe--MOh3ExUfgA-1; Wed, 16 Nov 2022 21:15:12 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NCNlk26n4z15Mky 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=1668651324; 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=RYZLOOtmK6vfRG0+bPAdkx5uVLexAXJmFL4RrJPan/Q=; b=KypfSiKVzgov7KrCC4xrCR4M8rKh2uZhD+L+AiB7iN+nXllcCpvt7nIVvASlxwrIW2dXTD T7vg+CYBsy0sT3c5skoHtke+Vh9zFuRGvbx+WoVhysUXNgHsEeEZWB2Qa0ZsdrW4xwGLGw B+ngl/6wmkSu4FI13bJnlvEkVoelO8w= X-MC-Unique: dHz2QaTzNEC5lsXE_btO8Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: akP1u7ASPe--MOh3ExUfgA-1 From: Jiang Jiacheng To: Subject: [PATCH 5/7] qemu: Support update net's bootindex Date: Thu, 17 Nov 2022 10:05:31 +0800 Message-ID: <20221117020533.45412-6-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.3 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.4 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: 1668651327390100010 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 65abc04998..863b779514 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7568,6 +7568,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 da92ced2f4..5d1913d0c7 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 Thu Apr 25 22:03:27 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=1668651323; cv=none; d=zohomail.com; s=zohoarc; b=kEAq31IVpLB5kgVYvfm//xrx3pjGnXIO6ojAMFdrMsmLLW4NPDoWKFBj9pg4DXSkWo4CyJu9k2swsegRh8Nz0tWO2IzLsIidUQU7IhB9s0nWNybiZqZWf7fK2TeN/UNXLs+CAvyWmrCmm/sOgbsD0drC7ZxB7JmyGNXEbCSX/RQ= 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=XTzKpWPZC5y7Aj6so2KRuSNcdTeqjylB5jwrzA68Y/Y=; b=OaykorwbETzYTNO1J/ws4/jkUHX791wNc1lDonKvERYEEkFdNxUhUSiB/ttZGhzAsJiNG8rgrKl4KJneX4XYlGgyO4Mm8vYRgFh4/mgTeMlXklXMZnC6yx2Vt1glbjfXCHdOPCCczPftnxQUnWQWJg8k8JP+oretTledbJ6fkDM= 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 1668651323559574.018913675145; 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-660-RV-9wHDNO4iLKY9L9EhDYQ-1; Wed, 16 Nov 2022 21:15:18 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 39B481C05EBF; Thu, 17 Nov 2022 02:15:15 +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 276D92023A16; Thu, 17 Nov 2022 02:15:15 +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 1C4B019465A3; Thu, 17 Nov 2022 02:15:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5893E19465A2 for ; Thu, 17 Nov 2022 02:15:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3DB31111E3E4; Thu, 17 Nov 2022 02:15:14 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34EF2112132C for ; Thu, 17 Nov 2022 02:15:14 +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 160EC38123BC 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-286-ufW48ukcMziUGEk6VTkIKg-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 4NCNlr3JDtzRpNf 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=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=XTzKpWPZC5y7Aj6so2KRuSNcdTeqjylB5jwrzA68Y/Y=; b=BUNTvbk3RbPF8BnqgciktW87mjhkqkEw9kxL1inQ7qHPNPTiNjucJqMkHlEK53wRrxobeB vw9dzctiDGYc8uTuUSIIyoYWJfhAwZ1wB7kj0czh8FzEXJUaV1da66n7hrUVNnpE/SWIea cpE9V+TgTA+LCxwvEmQB50UEcojrPqc= X-MC-Unique: RV-9wHDNO4iLKY9L9EhDYQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ufW48ukcMziUGEk6VTkIKg-1 From: Jiang Jiacheng To: Subject: [PATCH 6/7] qemu: Support add bootindex = 0 to boothash when its bootIndexSpecified is true Date: Thu, 17 Nov 2022 10:05:32 +0800 Message-ID: <20221117020533.45412-7-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.3 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.4 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: 1668651325383100006 Content-Type: text/plain; charset="utf-8" Support add bootindex =3D 0 to boothash and return 0 if duplicated bootinde= x =3D 0 is set. It is nessary to add bootindex =3D 0 into boothash, otherwise libvirt will = auto set boot dev, which will cause bootindex unchangable. Meanwhile, bootindex =3D 0 means di= sable bootindex, so it should be allowed to set duplicated bootindex =3D 0. Signed-off-by: Jiang Jiacheng --- src/conf/domain_postparse.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 Thu Apr 25 22:03:27 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=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