From nobody Wed May 1 17:26:18 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=1665495932; cv=none; d=zohomail.com; s=zohoarc; b=I0AUFc7QU7wTqfBT8mtBU1plZfIx7hxJt3foXeQXy1VIV4peguDfJZe7j4/fbBD7qc2NMOcx8i3Wgh4pNUYrwWw57jTdw0rP8+bZZzKP59NX3IrLgcqIYAS4ylkRPdo/B/Ez9zZlhOX2wwRsfALjtqRXaumAu7xS7dtjKLTGVrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495932; 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=7jMxvIiEhT8oXMHub9f3zdQaeDT86GdJXrENlEDegZo=; b=gIp8yNvDsA9A2cuGxRm+NQ+4IonttYJRmbnX07qcgWc98BauPyhleNeZFhSShGJEMNA8H8/wiFJVtYbvXZwRsc0yGqvH56mcOQSfiW90rBy3v8+rcz4rXZ5CMmJ+wQQIriUtoAzvpVZrUnZJiQtIxIELgOcqKD2vTC5lctlOZ0Q= 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 1665495931844711.5539095115834; Tue, 11 Oct 2022 06:45:31 -0700 (PDT) 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-569-AYzQeGlCMzu6_LLtel_MEQ-1; Tue, 11 Oct 2022 09:45:27 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50A491C05ED4; Tue, 11 Oct 2022 13:45:19 +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 3CF984B401C; Tue, 11 Oct 2022 13:45:19 +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 07F901946A7B; Tue, 11 Oct 2022 13:45:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 848F21946A47 for ; Tue, 11 Oct 2022 13:45:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A82D3414A815; Tue, 11 Oct 2022 13:45:13 +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 95A51414A809 for ; Tue, 11 Oct 2022 13:45:13 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50CAD18E0941 for ; Tue, 11 Oct 2022 13:45:13 +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-121-gFKU5x95OnKxJq-yGM60FA-1; Tue, 11 Oct 2022 09:45:11 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Mmxjh5r1QzHttK for ; Tue, 11 Oct 2022 21:40:08 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 21:45:07 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495930; 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=7jMxvIiEhT8oXMHub9f3zdQaeDT86GdJXrENlEDegZo=; b=hLje+seAlK9D+vaXxZVxM5Fr8k8lw5qCgvhvOxfwmHppYyqzKKl7IRkUoDQ5zjZ9IAHYa7 hBbGOuhiOOb0yNg226Ve6yhf1LQIEXql+h1OZcbyvijEf5XG/ZQc5Phdj5J/euXDrqnr7V 1p6lWHZC0BChEfmJs97huER68v+3Z9g= X-MC-Unique: AYzQeGlCMzu6_LLtel_MEQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: gFKU5x95OnKxJq-yGM60FA-1 From: Jiang Jiacheng To: Subject: [PATCH 1/7] qemu: Introduce qemuDomainChangeBootIndex API Date: Tue, 11 Oct 2022 21:38:27 +0800 Message-ID: <20221011133834.384749-2-jiangjiacheng@huawei.com> In-Reply-To: <20221011133834.384749-1-jiangjiacheng@huawei.com> References: <20221011133834.384749-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.9 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: 1665495934076100001 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 | 24 ++++++++++++++++++++++++ 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, 75 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3b75cdeb95..b653f44f25 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1571,3 +1571,27 @@ qemuGetMemoryBackingPath(virQEMUDriver *driver, *memPath =3D g_strdup_printf("%s/%s", domainPath, alias); return 0; } + +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); + + 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 c40c452f58..4e2cd84fe5 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -359,3 +359,8 @@ int qemuGetMemoryBackingPath(virQEMUDriver *driver, const virDomainDef *def, const char *alias, char **memPath); + +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 c2808c75a3..1b120d766d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4417,3 +4417,15 @@ qemuMonitorExtractQueryStats(virJSONValue *info) =20 return g_steal_pointer(&hash_table); } + +int +qemuMonitorSetBootIndex(qemuMonitor *mon, + const char *name, + int bootIndex) +{ + VIR_DEBUG("name=3D%s, bootIndex=3D%d", name, bootIndex); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONSetBootIndex(mon, name, bootIndex); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 63269e15bc..f27431a3f2 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1529,3 +1529,9 @@ qemuMonitorQueryStats(qemuMonitor *mon, =20 GHashTable * qemuMonitorExtractQueryStats(virJSONValue *info); + +int +qemuMonitorSetBootIndex(qemuMonitor *mon, + const char *name, + 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 70fba50e6c..5cc1f2665a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8665,3 +8665,25 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, =20 return virJSONValueObjectStealArray(reply, "return"); } + +int +qemuMonitorJSONSetBootIndex(qemuMonitor *mon, + const char *name, + int bootIndex) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-set", "s:path", name, + "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 a53e6423df..8283c9b29a 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -818,3 +818,9 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, qemuMonitorQueryStatsTargetType target, char **vcpus, GPtrArray *providers); + +int +qemuMonitorJSONSetBootIndex(qemuMonitor *mon, + const char *name, + int bootIndex) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.33.0 From nobody Wed May 1 17:26:18 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=1665495943; cv=none; d=zohomail.com; s=zohoarc; b=PP3REch8xb4WmPadllElhBQx3HB9irLQi5a9T7aQztYMRmb6xEKHl3lV3QyIokhEYizKrBj8BA0kvJpDtib+x5l7Nn/0jxrca5lqFwvi4DmaUoNDYdY9fJHzFq2t2r8xzUTHIzFn/hNzce3X6TrXsL9e5ZaQdyCQV44fWWSv81c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JltxJfq8r7RWT8qABuABqwuZJ1Cj5HI/alU12w2pppI=; b=N/CcGeZzLDLdpeNB9U7nKs3JdJdGDesB9u7Y3YRUGcaNA7MEm5HBemwRneD3pbsQyLt0RR1TzHTba78Ik2XMYiJFCn5Lay94CVgwgQlCAWgU3x/dQ0YVSBKcteIqrDZ5iQfHOiPsJNWYH46ZoOUCrxkeUIn8BJbAiVD1rb8QYA4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1665495943367898.0902835863715; Tue, 11 Oct 2022 06:45:43 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-QttTzETYMQagtYFf-Gz5SA-1; Tue, 11 Oct 2022 09:45:27 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BF5718E0930; Tue, 11 Oct 2022 13:45:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85016492B05; Tue, 11 Oct 2022 13:45:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A2EC51946A5E; Tue, 11 Oct 2022 13:45:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 83C181946A45 for ; Tue, 11 Oct 2022 13:45:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EF4384B4017; Tue, 11 Oct 2022 13:45:13 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7C644B4016 for ; Tue, 11 Oct 2022 13:45:13 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 84DB51C05ACE for ; Tue, 11 Oct 2022 13:45:13 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-xGO9lJfwPryNljCXpb8INQ-1; Tue, 11 Oct 2022 09:45:11 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Mmxln6lFpzpSxV for ; Tue, 11 Oct 2022 21:41:57 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 21:45:07 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495941; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JltxJfq8r7RWT8qABuABqwuZJ1Cj5HI/alU12w2pppI=; b=O5ce4MQrG0opIEgbK/ET2WPrC4LBt28DDkl++Kvd2w+Rypgy+U0W4v6yA+G/pd35BIecWt eQf8zAAsPEc7ISvdywfMIzA1GBF/wY0GbVpAuY3cS031eCny4VMHkVgqYcofZJSHjLcaL2 w+lRyTETCO+MMaemcbK8DVWATQVDWIY= X-MC-Unique: QttTzETYMQagtYFf-Gz5SA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: xGO9lJfwPryNljCXpb8INQ-1 From: Jiang Jiacheng To: Subject: [PATCH 2/7] qemu: Introduce qemuCheckBootIndex and qemuChangeDiskBootIndex API Date: Tue, 11 Oct 2022 21:38:28 +0800 Message-ID: <20221011133834.384749-3-jiangjiacheng@huawei.com> In-Reply-To: <20221011133834.384749-1-jiangjiacheng@huawei.com> References: <20221011133834.384749-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yubihong@huawei.com, zhengchuan@huawei.com, linyilu@huawei.com, jiangjiacheng@huawei.com, xiexiangyou@huawei.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665495946200100001 Content-Type: text/plain; charset="utf-8" Introduce qemuCheckBootIndex to check the new bootindex and is it nessary to update the bootindex. Introduce qemuChangeDiskBootIndex to support update disk's bootindex according to different disks' type. Signed-off-by: Jiang Jiacheng --- src/qemu/qemu_conf.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 7 +++++++ 2 files changed, 52 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index b653f44f25..3255632254 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1595,3 +1595,48 @@ qemuDomainChangeBootIndex(virDomainObj *vm, =20 return ret; } + +int +qemuCheckBootIndex(const int orig_bootindex, + const int new_bootindex) +{ + if ((new_bootindex =3D=3D -1) && ((orig_bootindex =3D=3D 0) || (orig_b= ootindex =3D=3D -1))) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("this device does not set boot index, cannot canc= el it.")); + return -1; + } + + /* if the new bootindex is different from the old bootindex and not + * equal to 0, we will update the old bootindex. + */ + if (new_bootindex && (orig_bootindex !=3D new_bootindex)) { + return 1; + } + + return 0; +} + +int +qemuChangeDiskBootIndex(virDomainObj *vm, + virDomainDiskDef *orig_disk, + virDomainDiskDef *disk) +{ + switch (disk->device) { + case VIR_DOMAIN_DISK_DEVICE_CDROM: + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_LUN: + if (qemuDomainChangeBootIndex(vm, &orig_disk->info, + disk->info.bootIndex) < 0) + return -1; + + orig_disk->info.bootIndex =3D disk->info.bootIndex; + break; + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The boot index of disk bus '%s' cannot be update= d."), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + return 0; +} diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 4e2cd84fe5..43197afb7d 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -364,3 +364,10 @@ int qemuDomainChangeBootIndex(virDomainObj *vm, virDomainDeviceInfo *devInfo, int newBootIndex) ATTRIBUTE_NONNULL(2); + +int qemuCheckBootIndex(const int orig_bootindex, + const int new_bootindex); + +int qemuChangeDiskBootIndex(virDomainObj *vm, + virDomainDiskDef *orig_disk, + virDomainDiskDef *disk); --=20 2.33.0 From nobody Wed May 1 17:26:18 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=1665495938; cv=none; d=zohomail.com; s=zohoarc; b=Nk2e7iplKvXsDrTjdc7w10yturG9jGix0Bf8Xa/k7MwS/D2z90RBnpMjhz6NHaCO8Yw/CtFGJebX3qML0DkAZ85aocPB2VS3+FJa+UC9quhA3vbkqzpQxxe0QSjWk5ATfTsdm4iVwvqjSwsjy81xO5qaEBnXOTmXwlRsiOCBGmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495938; 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=XZ4X1EjUzZMWm1fKdVj6MQXVqufeJ6xlJfe+RY8le7M=; b=TkQxNObLYkPAKXpDpnE6gNbkCO6QSbGkSRC7WXcqDp3mlXNZcqrP90iDg1JxZWrxkZo6Q60cq5F/CE10lav4RbeCGRzy/RVJsA3WskC+j2ApbvsvscLrsPZVEbtfMAIa+wTUK7oUypHSWaD0hD3SHtjk45svzQ8mqZ92ojqQRaw= 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 1665495938627246.55759603796685; Tue, 11 Oct 2022 06:45:38 -0700 (PDT) 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-70-cTg5E99MNpCsqo6Bo1iAVw-1; Tue, 11 Oct 2022 09:45:28 -0400 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 D89D91C07553; Tue, 11 Oct 2022 13:45:20 +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 C44EFD1D1D; Tue, 11 Oct 2022 13:45:20 +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 A57061946A45; Tue, 11 Oct 2022 13:45:20 +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 5EFD01946A4C for ; Tue, 11 Oct 2022 13:45:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3F0E2E2032; Tue, 11 Oct 2022 13:45:20 +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 2F0F5D1D1D for ; Tue, 11 Oct 2022 13:45:15 +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 3A49F3814940 for ; Tue, 11 Oct 2022 13:45:15 +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-502-Rr008_2UNgqIy--iFqIWZw-1; Tue, 11 Oct 2022 09:45:13 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MmxmY4J2Sz1CF1P for ; Tue, 11 Oct 2022 21:42:37 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 21:45:08 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495937; 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=XZ4X1EjUzZMWm1fKdVj6MQXVqufeJ6xlJfe+RY8le7M=; b=InkIttWGd+O3+lISBSY2fI/x8ijq44tLzr2CAqzvjquIFI5aW4PGv++V8YS2OhsLhkPcQt 3b+fKHPRBJ4nPZQGXZVnpBpF0v2b6qs5gXDdZFJEOuqUd7FsaUPcFWOPjien6yetHpNDMk KrmRLISnfv2ebiQMZ1zLgYKsYIHnW1M= X-MC-Unique: cTg5E99MNpCsqo6Bo1iAVw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Rr008_2UNgqIy--iFqIWZw-1 From: Jiang Jiacheng To: Subject: [PATCH 3/7] qemu: Support update disk's bootindex Date: Tue, 11 Oct 2022 21:38:29 +0800 Message-ID: <20221011133834.384749-4-jiangjiacheng@huawei.com> In-Reply-To: <20221011133834.384749-1-jiangjiacheng@huawei.com> References: <20221011133834.384749-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.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: 1665495940095100005 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 fe3ce023a4..f7ee7b7844 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8121,7 +8121,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 707f4cc1bb..38cc5d0229 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7027,6 +7027,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, @@ -7044,6 +7045,10 @@ qemuDomainChangeDiskLive(virDomainObj *vm, if (!qemuDomainDiskChangeSupported(disk, orig_disk)) return -1; =20 + if ((needChangeIndex =3D qemuCheckBootIndex(orig_disk->info.bootIndex, + 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 && @@ -7067,6 +7072,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; @@ -7762,6 +7772,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(newDisk->info.bootIndex, + vmdef->disks[pos]->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 Wed May 1 17:26:18 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=1665495942; cv=none; d=zohomail.com; s=zohoarc; b=NtXih471CnrKQ42IFCBkyqUj6ROkUB+SPLMJlYK2W2ie7apem2Cmanr+8lKzDqXKA1/RS87wkCR5OS3BSweOhlFNWoZmaGBg+MV1gQyGcFJxnn7VEJ7XJ4If2OaGKNyPYEJAoGG39sCgXh61LvyENVSEAyRdjhGZpD1iSyq6I2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495942; 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=OgAATGHCuaYjPv3waKaEEr50Z1kB9IehcVMzZ+sRgHU=; b=jGv10ggzbOZPdYdxcR4+hwQ3rdJvMrei1KNTclavZgvb5MwizLP5V/zudl9ouoY8Yr2vVPjZyyQlZ7tJLPiKpPzSTFt5zj5BLcBWV4N1+QIGSpgRHhp+DDCcZj5TF6z+lTDZwCEZ5Yd1Ad5flUOHURgc6JUDJ4nkixI65bS6sOE= 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 166549594258913.140077990066175; Tue, 11 Oct 2022 06:45:42 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-349-3z1t7THGPrWymOxmx-tWHQ-1; Tue, 11 Oct 2022 09:45:35 -0400 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 9211B86EB20; Tue, 11 Oct 2022 13:45:21 +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 7F90ACF635; Tue, 11 Oct 2022 13:45:21 +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 6246819465A3; Tue, 11 Oct 2022 13:45:21 +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 5F86E1946A4F for ; Tue, 11 Oct 2022 13:45:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3FC3AE2039; Tue, 11 Oct 2022 13:45:20 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E9F4CF637 for ; Tue, 11 Oct 2022 13:45: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 6D8FF83B9F3 for ; Tue, 11 Oct 2022 13:45: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-467-5e87_VAzMQqGaRfrEWdg6Q-1; Tue, 11 Oct 2022 09:45:12 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MmxkC4SvLz1M8y6 for ; Tue, 11 Oct 2022 21:40: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.31; Tue, 11 Oct 2022 21:45:08 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495941; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=OgAATGHCuaYjPv3waKaEEr50Z1kB9IehcVMzZ+sRgHU=; b=b8y7oSv2fIuyKD7ERrukcLUzrMrY9a1pBBXV/hQ7bnRowTwImhpUPPWapaqCs0KH2QwpSx CclBOKgPD24hxzbPdVzrnFz6iPkzFBrqOohtdHHWcZNhV7pr8QQagdI+BKdELR2S6UcWDU MrZedq0jgdrNEdlfdtMPpipZwNU8V1g= X-MC-Unique: 3z1t7THGPrWymOxmx-tWHQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 5e87_VAzMQqGaRfrEWdg6Q-1 From: Jiang Jiacheng To: Subject: [PATCH 4/7] qemu: Support update net's bootindex Date: Tue, 11 Oct 2022 21:38:30 +0800 Message-ID: <20221011133834.384749-5-jiangjiacheng@huawei.com> In-Reply-To: <20221011133834.384749-1-jiangjiacheng@huawei.com> References: <20221011133834.384749-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.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: 1665495944107100001 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 38cc5d0229..7d32b3bc50 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7827,6 +7827,10 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef, false) < 0) return -1; =20 + if (qemuCheckBootIndex(net->info.bootIndex, + vmdef->nets[pos]->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 9b508dc8f0..370a272715 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3469,6 +3469,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; @@ -3634,11 +3635,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.bootIndex, + newdev->info.bootIndex))= < 0) { goto cleanup; } =20 @@ -3919,6 +3917,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 Wed May 1 17:26:18 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=1665495937; cv=none; d=zohomail.com; s=zohoarc; b=UCk8RbQa7FuHV4qfmNBxYIfRvAMYEUTFM0czuTvxQk7AN+za/64GEzdUIkejiNIY4b/i23vmV2mD2u7G/Tp8K9gQhfPIemW4ihclJy3r+Rg1dE/oloxLBCJ1ZQK8owIrFPRXD3+odBFe+9ATi5XhBKiwHJkzd93M5y75Wi3ZMS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495937; 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=XTee7ty9D+5ievVxWRlCbSBWdRnLXR7S75pPCnm/2HQ=; b=AXUr78gSAA56b8IkFH5/YLgbbSH/wj5btbTJ1ofyJhPGRXI0pEhG53NCxk6lHTJkHJbFzxUV4w+lzGpp8ydhD8EigNllaLObJtnIE4b2P1DIKyAf9IWr8h42OU/Wre80dEdUJQm19enDGOk2PWKIp5psool+85mU2d+WFFq/RxA= 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 1665495937810253.19114439319083; Tue, 11 Oct 2022 06:45:37 -0700 (PDT) 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-313-AjaF_fbqPLC-zzhwOJbHpA-1; Tue, 11 Oct 2022 09:45:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3EA63C6EABA; Tue, 11 Oct 2022 13:45:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DBF2C8E405; Tue, 11 Oct 2022 13:45:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C3D4E1946A6D; Tue, 11 Oct 2022 13:45:17 +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 81A461946A44 for ; Tue, 11 Oct 2022 13:45:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F24BB2166B26; Tue, 11 Oct 2022 13:45:15 +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 E69DA2144B22 for ; Tue, 11 Oct 2022 13:45:15 +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 B9F491010424 for ; Tue, 11 Oct 2022 13:45:15 +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-632-3o08V_5bNMO0bVbsduiGqA-1; Tue, 11 Oct 2022 09:45:13 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MmxkD0Zs2z1M8yS for ; Tue, 11 Oct 2022 21:40:36 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 21:45:09 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495935; 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=XTee7ty9D+5ievVxWRlCbSBWdRnLXR7S75pPCnm/2HQ=; b=AWZFV2dfuUuJqxzipt24YrF9NqYTmbxseYlqQXJTATP1rBD34N2tpoeoZgcHsOOVXx6UBk 7PZ0NMnXTHxswf7tLAzglmIDr9hnu5VrfOO1wIkM1/Fjv6SZTdFm4FDfJ+sFgMMthnSYYu ClnSr/Wku1NBjcYV2vkyMD6f4SW6j7M= X-MC-Unique: AjaF_fbqPLC-zzhwOJbHpA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 3o08V_5bNMO0bVbsduiGqA-1 From: Jiang Jiacheng To: Subject: [PATCH 5/7] qemu: Support set bootindex to -1 Date: Tue, 11 Oct 2022 21:38:31 +0800 Message-ID: <20221011133834.384749-6-jiangjiacheng@huawei.com> In-Reply-To: <20221011133834.384749-1-jiangjiacheng@huawei.com> References: <20221011133834.384749-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.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.8 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: 1665495940121100009 Content-Type: text/plain; charset="utf-8" Enable bootindex can be set to -1, it means cancel the device's bootindex. Change bootindex's type from unsigned int to int and modify other related codes concered with type. Signed-off-by: Jiang Jiacheng --- src/conf/device_conf.h | 4 ++-- src/conf/domain_conf.c | 15 ++++++++++----- src/conf/domain_postparse.c | 2 +- src/qemu/qemu_command.c | 38 ++++++++++++++++++------------------- src/qemu/qemu_process.c | 8 ++++---- src/qemu/qemu_validate.c | 6 +++--- 6 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index f2907dc596..a9df2e6e5d 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -139,11 +139,11 @@ struct _virDomainDeviceInfo { char *romfile; /* bootIndex is only used for disk, network interface, hostdev * and redirdev devices */ - unsigned int bootIndex; + int bootIndex; /* 'effectiveBootIndex' is same as 'bootIndex' (if provided in the XML= ) but * not formatted back. This allows HV drivers to update it if bootIndex) { - virBufferAsprintf(buf, "bootIndex); + virBufferAsprintf(buf, "bootIndex); =20 if (info->loadparm) virBufferAsprintf(buf, " loadparm=3D'%s'", info->loadparm); @@ -5254,10 +5254,15 @@ virDomainDeviceBootParseXML(xmlNodePtr node, { g_autofree char *loadparm =3D NULL; =20 - if (virXMLPropUInt(node, "order", 10, - VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, - &info->bootIndex) < 0) + if (virXMLPropInt(node, "order", 10, + VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + &info->bootIndex, -1) < 0) return -1; + if (info->bootIndex =3D=3D 0 || info->bootIndex < -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("incorrect boot order '%d', expecting positive in= teger or -1"), + info->bootIndex); + } =20 info->effectiveBootIndex =3D info->bootIndex; =20 @@ -27652,7 +27657,7 @@ virDomainDeviceInfoCheckBootIndex(virDomainDef *def= G_GNUC_UNUSED, =20 if (info->bootIndex =3D=3D data->newInfo->bootIndex) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("boot order %u is already used by another device"= ), + _("boot order %d is already used by another device"= ), data->newInfo->bootIndex); return -1; } diff --git a/src/conf/domain_postparse.c b/src/conf/domain_postparse.c index df59de2d0d..9810de7437 100644 --- a/src/conf/domain_postparse.c +++ b/src/conf/domain_postparse.c @@ -1041,7 +1041,7 @@ virDomainDefCollectBootOrder(virDomainDef *def G_GNUC= _UNUSED, */ return 0; } - order =3D g_strdup_printf("%u", info->bootIndex); + order =3D g_strdup_printf("%d", info->bootIndex); =20 if (virHashLookup(bootHash, order)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a31b8ee438..e124800bcc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1765,7 +1765,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, virTristateSwitch shareRW =3D VIR_TRISTATE_SWITCH_ABSENT; g_autofree char *chardev =3D NULL; g_autofree char *drive =3D NULL; - unsigned int bootindex =3D 0; + int bootindex =3D 0; unsigned int logical_block_size =3D 0; unsigned int physical_block_size =3D 0; g_autoptr(virJSONValue) wwn =3D NULL; @@ -1951,7 +1951,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, "S:drive", drive, "S:chardev", chardev, "s:id", disk->info.alias, - "p:bootindex", bootindex, + "z:bootindex", bootindex, "p:logical_block_size", logical_block_size, "p:physical_block_size", physical_block_size, "A:wwn", &wwn, @@ -2019,25 +2019,25 @@ qemuCommandAddExtDevice(virCommand *cmd, =20 static void qemuBuildFloppyCommandLineControllerOptionsImplicit(virCommand *cmd, - unsigned int bootindex= A, - unsigned int bootindex= B) + int bootindexA, + int bootindexB) { if (bootindexA > 0) { virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "isa-fdc.bootindexA=3D%u", bootindexA); + virCommandAddArgFormat(cmd, "isa-fdc.bootindexA=3D%d", bootindexA); } =20 if (bootindexB > 0) { virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "isa-fdc.bootindexB=3D%u", bootindexB); + virCommandAddArgFormat(cmd, "isa-fdc.bootindexB=3D%d", bootindexB); } } =20 =20 static int qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand *cmd, - unsigned int bootindex= A, - unsigned int bootindex= B, + int bootindexA, + int bootindexB, const virDomainDef *de= f, virQEMUCaps *qemuCaps) { @@ -2045,8 +2045,8 @@ qemuBuildFloppyCommandLineControllerOptionsExplicit(v= irCommand *cmd, =20 if (virJSONValueObjectAdd(&props, "s:driver", "isa-fdc", - "p:bootindexA", bootindexA, - "p:bootindexB", bootindexB, + "z:bootindexA", bootindexA, + "z:bootindexB", bootindexB, NULL) < 0) return -1; =20 @@ -2062,8 +2062,8 @@ qemuBuildFloppyCommandLineControllerOptions(virComman= d *cmd, const virDomainDef *def, virQEMUCaps *qemuCaps) { - unsigned int bootindexA =3D 0; - unsigned int bootindexB =3D 0; + int bootindexA =3D 0; + int bootindexB =3D 0; bool hasfloppy =3D false; size_t i; =20 @@ -2286,7 +2286,7 @@ qemuBuildVHostUserFsDevProps(virDomainFSDef *fs, "s:chardev", chardev_alias, "P:queue-size", fs->queue_size, "s:tag", fs->dst, - "p:bootindex", fs->info.bootIndex, + "z:bootindex", fs->info.bootIndex, NULL) < 0) return NULL; =20 @@ -3762,7 +3762,7 @@ qemuBuildNicDevProps(virDomainDef *def, "s:netdev", netdev, "s:id", net->info.alias, "s:mac", macaddr, - "p:bootindex", net->info.effectiveBootIndex, + "z:bootindex", net->info.effectiveBootIndex, NULL) < 0) return NULL; =20 @@ -4576,7 +4576,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, "s:driver", "vfio-pci", "s:host", host, "s:id", dev->info->alias, - "p:bootindex", dev->info->effectiveBootIndex, + "z:bootindex", dev->info->effectiveBootIndex, "S:failover_pair_id", failover_pair_id, NULL) < 0) return NULL; @@ -4643,7 +4643,7 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def, "p:hostbus", hostbus, "p:hostaddr", hostaddr, "s:id", dev->info->alias, - "p:bootindex", dev->info->bootIndex, + "z:bootindex", dev->info->bootIndex, "T:guest-reset", guestReset, "T:guest-resets-all", guestResetsAll, NULL) < 0) @@ -4733,7 +4733,7 @@ qemuBuildSCSIHostdevDevProps(const virDomainDef *def, "s:driver", "scsi-generic", "s:drive", backendAlias, "s:id", dev->info->alias, - "p:bootindex", dev->info->bootIndex, + "z:bootindex", dev->info->bootIndex, NULL) < 0) return NULL; =20 @@ -4831,7 +4831,7 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *= def, "s:sysfsdev", mdevPath, "S:display", qemuOnOffAuto(mdevsrc->display), "B:ramfb", ramfb, - "p:bootindex", dev->info->bootIndex, + "z:bootindex", dev->info->bootIndex, NULL) < 0) return NULL; =20 @@ -9022,7 +9022,7 @@ qemuBuildRedirdevDevProps(const virDomainDef *def, "s:chardev", chardev, "s:id", dev->info.alias, "S:filter", filter, - "p:bootindex", dev->info.bootIndex, + "z:bootindex", dev->info.bootIndex, NULL) < 0) return NULL; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 32f03ff79a..327307de9c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6264,10 +6264,10 @@ static void qemuProcessPrepareDeviceBootorder(virDomainDef *def) { size_t i; - unsigned int bootCD =3D 0; - unsigned int bootFloppy =3D 0; - unsigned int bootDisk =3D 0; - unsigned int bootNetwork =3D 0; + int bootCD =3D 0; + int bootFloppy =3D 0; + int bootDisk =3D 0; + int bootNetwork =3D 0; =20 if (def->os.nBootDevs =3D=3D 0) return; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 6403266559..c3ecd03dfb 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2520,7 +2520,7 @@ qemuValidateDomainMdevDefVFIOPCI(const virDomainHostd= evDef *hostdev, } =20 /* VFIO-PCI does not support boot */ - if (hostdev->info->bootIndex) { + if (hostdev->info->bootIndex > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("booting from assigned devices is not " "supported by mediated devices of " @@ -2576,7 +2576,7 @@ qemuValidateDomainMdevDefVFIOAP(const virDomainHostde= vDef *hostdev, } =20 /* VFIO-AP does not support boot */ - if (hostdev->info->bootIndex) { + if (hostdev->info->bootIndex > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("booting from assigned devices is not " "supported by mediated devices of " @@ -2687,7 +2687,7 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHos= tdevDef *hostdev, break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: - if (hostdev->info->bootIndex) { + if (hostdev->info->bootIndex > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("booting from assigned devices is not " "supported by vhost SCSI devices")); --=20 2.33.0 From nobody Wed May 1 17:26:18 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=1665495937; cv=none; d=zohomail.com; s=zohoarc; b=O8+yLUrnwYPXsLft2YuC9PSGn6JUQjGFkTw92apLmHDiUDv1vgBBhrqQ+JeivO3sQTihxZPVczvL2xHLHaHjgJ3N9bxhhZF0qKpavceQrIYCaCcUvRopWA65ENRxndzjWaAQR+0RSQ2V0Ahbo9UnHJ2MswLmk0lCZNqlcYGpdME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495937; 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=bjQircpUO+mCQD3QRKRE/BYhs1DhOwcmgvc7llMOJyE=; b=HOBf21bIXbTqpTKPCFl0TtzDCY1m2PCwOZ3K3KFo2JFXBi4eB/MEVjV2RWUqk3d5gT2Hu/1lgVJqXtXG+MexUQUo8reb1vhe8zp5VYIesZYGHaJcYaEDV+evtsOMjS2Ii8Xjc/YfR/x2TIb6eGEC80c+vTc288I2RcvjXxu1wcs= 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 1665495937291599.4805018389218; Tue, 11 Oct 2022 06:45:37 -0700 (PDT) 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-281-v2zCQevOMeqmlKiiPtVqVw-1; Tue, 11 Oct 2022 09:45:26 -0400 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 71A1329AA2FB; Tue, 11 Oct 2022 13:45:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3F36414A815; Tue, 11 Oct 2022 13:45: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 57F321946A44; Tue, 11 Oct 2022 13:45:17 +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 7F2A119465A0 for ; Tue, 11 Oct 2022 13:45:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E22E9145F978; Tue, 11 Oct 2022 13:45:15 +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 DA7D6145F977 for ; Tue, 11 Oct 2022 13:45:15 +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 9FFD0801585 for ; Tue, 11 Oct 2022 13:45:15 +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-647-m_qFM6iCPUqV_hLT8nWbBw-1; Tue, 11 Oct 2022 09:45:12 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MmxkN2nLWzVhq0 for ; Tue, 11 Oct 2022 21:40:44 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 21:45:09 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495936; 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=bjQircpUO+mCQD3QRKRE/BYhs1DhOwcmgvc7llMOJyE=; b=IlzyUAFraC10Fsijb18wQWp9FRgp/AP+j3adJLR8G3I9fTNnyWAOwDIW3HUxMPNeEG46sB IGmljRlTuk9LTDJAtX1gpve42fF6wzD7VCeX+IvclPeW3rPkXofQU8W38ZnhFbcYQqgW2l /XIaUmIUWLLK5K8HZttxUwmWDvbvcNE= X-MC-Unique: v2zCQevOMeqmlKiiPtVqVw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: m_qFM6iCPUqV_hLT8nWbBw-1 From: Jiang Jiacheng To: Subject: [PATCH 6/7] qemu: Support add bootindex = -1 to boothash Date: Tue, 11 Oct 2022 21:38:32 +0800 Message-ID: <20221011133834.384749-7-jiangjiacheng@huawei.com> In-Reply-To: <20221011133834.384749-1-jiangjiacheng@huawei.com> References: <20221011133834.384749-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.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.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: 1665495938058100001 Content-Type: text/plain; charset="utf-8" Support add bootindex =3D -1 to boothash and return 0 if duplicated bootind= ex =3D -1 is set. It is nessary to add bootindex =3D -1 into boothash, otherwise libvirt will= auto set boot dev, which will cause bootindex unchangable. Meanwhile, bootindex =3D -1 means d= isable bootindex, so it should be allowed to set duplicated bootindex =3D -1. Signed-off-by: Jiang Jiacheng --- src/conf/domain_postparse.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/conf/domain_postparse.c b/src/conf/domain_postparse.c index 9810de7437..d264a2ffee 100644 --- a/src/conf/domain_postparse.c +++ b/src/conf/domain_postparse.c @@ -1044,6 +1044,12 @@ virDomainDefCollectBootOrder(virDomainDef *def G_GNU= C_UNUSED, order =3D g_strdup_printf("%d", info->bootIndex); =20 if (virHashLookup(bootHash, order)) { + /* -1 means disable bootorder so it allowed to + * make more than one device use -1 + */ + if (info->bootIndex =3D=3D -1) { + return 0; + } virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("boot order '%s' used for more than one device"), order); --=20 2.33.0 From nobody Wed May 1 17:26:18 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=1665495937; cv=none; d=zohomail.com; s=zohoarc; b=G6Y3VuUh/B1SiAi8y9KUUbh+OmuyoG+axHevjUzuk/B81Ysil63RkOZZc+6iXc5TcohIegNsky3D/eOpwo1DFa48e717q7zZFkJowhanKaQPOLD0kHneZLM0gD+/Xl7tWJkFLT/3TGUlGq+ZNKsql1JBrM3zNx9sDnOWioH8XB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665495937; 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=BTwRobuyvyqjD0mc/b7lh/PwE/SedaDLnpXcnjVzu1s=; b=QVk1fbihTkfc9An7HU8TZdbVa3aBMXu8yYLMdx+p/rHwVHY8cK6VG1siTt8n/smn8uPwdFGrlOhszIw/cEEPY576dW4pb+9gqXMesAcwoPOzrjGSsO0fnyKdn4F17f/wdIOwqDDzx/RXhjAdYT0j+P2YMRQfgLwsNP/vmXOs3+M= 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 1665495937692118.96331191369211; Tue, 11 Oct 2022 06:45:37 -0700 (PDT) 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-615-JK60iqutOEKinDAhk_9fLA-1; Tue, 11 Oct 2022 09:45:29 -0400 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 04AD01C06ECD; Tue, 11 Oct 2022 13:45:20 +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 E1C06414A815; Tue, 11 Oct 2022 13:45:19 +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 525A71946A52; Tue, 11 Oct 2022 13:45:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BC77E19465A0 for ; Tue, 11 Oct 2022 13:45:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A10F04B4017; Tue, 11 Oct 2022 13:45:16 +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 991514B4016 for ; Tue, 11 Oct 2022 13:45:16 +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 7FAAE2999B28 for ; Tue, 11 Oct 2022 13:45:16 +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-14-FvmAx1tzPauaOsKRM0UVUg-1; Tue, 11 Oct 2022 09:45:14 -0400 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MmxkD44QgzlVvL for ; Tue, 11 Oct 2022 21:40:36 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 21:45:09 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665495936; 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=BTwRobuyvyqjD0mc/b7lh/PwE/SedaDLnpXcnjVzu1s=; b=fMkIA9s7raJGwEBfRZu33WPtOG8NwFe8TB6eGFrZJrJhPP5h+4lqleXQz7sUre3jHqjR4O NImjZbYKGN8yMNdctSrDXo0Bq+iOrK+vf0O6oKJ3SrtQA2wIh7/eQN2QLGnR2Aawc+ojg+ dFqewgSlR5LVOOeO6mucN7vMSMwkAvY= X-MC-Unique: JK60iqutOEKinDAhk_9fLA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: FvmAx1tzPauaOsKRM0UVUg-1 From: Jiang Jiacheng To: Subject: [PATCH 7/7] qemu: Reserve bootindex = -1 in virDomainDeviceDefCopy Date: Tue, 11 Oct 2022 21:38:33 +0800 Message-ID: <20221011133834.384749-8-jiangjiacheng@huawei.com> In-Reply-To: <20221011133834.384749-1-jiangjiacheng@huawei.com> References: <20221011133834.384749-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yubihong@huawei.com, zhengchuan@huawei.com, linyilu@huawei.com, jiangjiacheng@huawei.com, xiexiangyou@huawei.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.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: 1665495940085100004 Content-Type: text/plain; charset="utf-8" Since we don't format bootindex's xml when it is -1, we will lost bootindex if it is set to -1. So we should reserve bootindex =3D -1 in virDomainDevic= eDefCopy to save the message that we cancel a bootindex set. Signed-off-by: Jiang Jiacheng --- src/conf/domain_conf.c | 23 ++++++++++++++++++++--- src/conf/domain_conf.h | 4 ++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fe7e5f9116..d35fd995e4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28651,6 +28651,7 @@ virDomainDeviceDefCopy(virDomainDeviceDef *src, virDomainXMLOption *xmlopt, void *parseOpaque) { + virDomainDeviceDef* ret; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; int flags =3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_S= ECURE; int rc =3D -1; @@ -28746,9 +28747,13 @@ virDomainDeviceDefCopy(virDomainDeviceDef *src, return NULL; =20 xmlStr =3D virBufferContentAndReset(&buf); - return virDomainDeviceDefParse(xmlStr, def, xmlopt, parseOpaque, - VIR_DOMAIN_DEF_PARSE_INACTIVE | - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); + ret =3D virDomainDeviceDefParse(xmlStr, def, xmlopt, parseOpaque, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); + if (ret) + virDomainDeviceDefCopyBootIndex(ret, src); + =20 + return ret; } =20 =20 @@ -30669,3 +30674,15 @@ virDomainDefHasSpiceGraphics(const virDomainDef *d= ef) =20 return false; } + +void +virDomainDeviceDefCopyBootIndex(virDomainDeviceDef *dest, virDomainDeviceD= ef *src) +{ + if (src->type =3D=3D VIR_DOMAIN_DEVICE_DISK && + src->data.disk->info.bootIndex =3D=3D -1) + dest->data.disk->info.bootIndex =3D src->data.disk->info.bootIndex; + + if (src->type =3D=3D VIR_DOMAIN_DEVICE_NET && + src->data.net->info.bootIndex =3D=3D -1) + dest->data.net->info.bootIndex =3D src->data.net->info.bootIndex; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2b1497d78d..8a152df692 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4330,3 +4330,7 @@ virDomainObjGetMessages(virDomainObj *vm, =20 bool virDomainDefHasSpiceGraphics(const virDomainDef *def); + +void=20 +virDomainDeviceDefCopyBootIndex(virDomainDeviceDef *dest, + virDomainDeviceDef *src); --=20 2.33.0